mirror of
https://github.com/GTNewHorizons/ThaumicTinkerer.git
synced 2026-10-26 14:33:48 +00:00
Fix Dispersed Strikes
1. This fixes up the successiveStrikes counter. Previously it relies on a transient id to remember whether this is the same target. This id will not survive chunk unloads. It also cannot distinguish between second strike and third or fourth strike. To prevent runaway effect the successiveStrikes counter is capped at 5. 2. It changes the algorithm used by Dispersed Strikes to a more reasonable one.
This commit is contained in:
1 parent
52f872b6ad
commit
c8fdb5747f
1 file changed
+12
-12
@@ -36,10 +36,12 @@ import thaumic.tinkerer.common.lib.LibEnchantIDs;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ModEnchantmentHandler {
|
public class ModEnchantmentHandler {
|
||||||
|
|
||||||
public final String NBTLastTarget = "TTEnchantLastTarget";
|
public final String NBTLastTarget = "TTEnchantLastTarget";
|
||||||
|
public final String NBTLastTarget2 = "TTEnchantLastTarget2";
|
||||||
|
|
||||||
public final String NBTSuccessiveStrike = "TTEnchantSuccessiveStrike";
|
public final String NBTSuccessiveStrike = "TTEnchantSuccessiveStrike";
|
||||||
|
|
||||||
@@ -92,29 +94,27 @@ public class ModEnchantmentHandler {
|
|||||||
if (heldItem.stackTagCompound == null) {
|
if (heldItem.stackTagCompound == null) {
|
||||||
heldItem.stackTagCompound = new NBTTagCompound();
|
heldItem.stackTagCompound = new NBTTagCompound();
|
||||||
}
|
}
|
||||||
int lastTarget = heldItem.stackTagCompound.getInteger(NBTLastTarget);
|
UUID lastTarget = new UUID(heldItem.stackTagCompound.getLong(NBTLastTarget), heldItem.stackTagCompound.getLong(NBTLastTarget2));
|
||||||
int successiveStrikes = heldItem.stackTagCompound.getInteger(NBTSuccessiveStrike);
|
int successiveStrikes = heldItem.stackTagCompound.getInteger(NBTSuccessiveStrike);
|
||||||
int entityId = event.entityLiving.getEntityId();
|
UUID entityId = event.entityLiving.getUniqueID();
|
||||||
|
|
||||||
if (lastTarget != entityId) {
|
if (!lastTarget.equals(entityId)) {
|
||||||
heldItem.stackTagCompound.setInteger(NBTSuccessiveStrike, 0);
|
|
||||||
successiveStrikes = 0;
|
successiveStrikes = 0;
|
||||||
|
heldItem.stackTagCompound.setLong(NBTLastTarget, entityId.getMostSignificantBits());
|
||||||
|
heldItem.stackTagCompound.setLong(NBTLastTarget2, entityId.getLeastSignificantBits());
|
||||||
} else {
|
} else {
|
||||||
heldItem.stackTagCompound.setInteger(NBTSuccessiveStrike, successiveStrikes + 1);
|
successiveStrikes = Math.max(successiveStrikes + 1, 5);
|
||||||
successiveStrikes = 1;
|
|
||||||
}
|
}
|
||||||
|
heldItem.stackTagCompound.setInteger(NBTSuccessiveStrike, successiveStrikes);
|
||||||
|
|
||||||
if (focusedStrikes > 0) {
|
if (focusedStrikes > 0) {
|
||||||
event.ammount /= 2;
|
event.ammount /= 2;
|
||||||
event.ammount += (.5 * successiveStrikes * event.ammount * focusedStrikes);
|
event.ammount += (.5 * Math.max(successiveStrikes, 5) * event.ammount * focusedStrikes);
|
||||||
}
|
}
|
||||||
if (dispersedStrikes > 0) {
|
if (dispersedStrikes > 0) {
|
||||||
event.ammount *= 1 + (successiveStrikes / 5);
|
event.ammount *= 1 + 0.6 * dispersedStrikes + (successiveStrikes / 5);
|
||||||
event.ammount /= (1 + (successiveStrikes * 2));
|
event.ammount /= 1 + 0.25 * dispersedStrikes + (successiveStrikes * 2.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
heldItem.stackTagCompound.setInteger("TTEnchantLastTarget", entityId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int vampirism = EnchantmentHelper.getEnchantmentLevel(LibEnchantIDs.idVampirism, heldItem);
|
int vampirism = EnchantmentHelper.getEnchantmentLevel(LibEnchantIDs.idVampirism, heldItem);
|
||||||
|
|||||||
Reference in new issue
Block a user