Clean up the wand update classes:

Clean up c-style array declarations
Use enhanced for loops
Rename ignored exception variables and remove redundant returns
This commit is contained in:
koolkrafter5 committed 2025-08-13 15:09:14 -04:00
1 parent b95d777e54
commit c11690273c
10 files changed
+51 -57

No files matched your search

@@ -495,9 +495,9 @@ public class FMEventHandler {
}
}
if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
if (event.source.getEntity() instanceof EntityPlayer) {
ItemStack equip = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem();
if (equip != null && equip.getItem() instanceof ItemWandCasting) {
if (equip.getItem() instanceof ItemWandCasting) {
String capTag = ((ItemWandCasting) equip.getItem()).getCap(equip).getTag();
if (capTag.equals("alchemical") || capTag.equals("blood_iron")
&& ((ItemWandCasting) equip.getItem()).getRod(equip).getTag().startsWith("blood")) {
@@ -13,7 +13,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class BloodStaffUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.bm && Config.crossWand && player.ticksExisted % 25 == 0) {
@@ -30,25 +30,23 @@ public class BloodStaffUpdate implements IWandRodOnUpdate {
cost = Math.max(0, cost);
for (int x = 0; x < primals.length; x++) {
for (Aspect primal : primals) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit > 0) {
deficit = Math.min(deficit, 100);
if (player.capabilities.isCreativeMode)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
else if (SoulNetworkHandler.syphonFromNetwork(itemstack, cost * deficit) > 0)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
else if (syphonHealth(player)) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
return;
} else return;
}
}
} catch (Exception e) {
return;
}
} catch (Exception ignored) {}
}
}
@@ -12,7 +12,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class BloodWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.bm && Config.crossWand && player.ticksExisted % 100 == 0) {
@@ -27,25 +27,23 @@ public class BloodWandUpdate implements IWandRodOnUpdate {
cost = Math.max(0, cost);
for (int x = 0; x < primals.length; x++) {
for (Aspect primal : primals) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit > 0) {
deficit = Math.min(deficit, 100);
if (player.capabilities.isCreativeMode)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
else if (SoulNetworkHandler.syphonFromNetwork(itemstack, cost * deficit) > 0)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
else if (syphonHealth(player)) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
return;
} else return;
}
}
} catch (Throwable e) {
return;
}
} catch (Throwable ignored) {}
}
}
@@ -9,17 +9,17 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class CreativeWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
for (int x = 0; x < primals.length; x++) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x])
for (Aspect primal : primals) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal)
< ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)) {
((ItemWandCasting) itemstack.getItem()).addVis(
itemstack,
primals[x],
primal,
((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]),
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal),
true);
}
}
@@ -10,15 +10,15 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class InfernalWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = { Aspect.ORDER, Aspect.ENTROPY, Aspect.AIR, Aspect.EARTH, Aspect.WATER };
Aspect[] primals = { Aspect.ORDER, Aspect.ENTROPY, Aspect.AIR, Aspect.EARTH, Aspect.WATER };
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (player.ticksExisted % 100 == 0) {
if (player.worldObj.provider.dimensionId == -1) {
for (int x = 0; x < primals.length; x++) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x])
for (Aspect primal : primals) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal)
< ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack) / 10) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
}
@@ -13,7 +13,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class ManaStaffUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.am2 && Config.crossWand) {
@@ -29,18 +29,18 @@ public class ManaStaffUpdate implements IWandRodOnUpdate {
if (prop == null || prop.getCurrentMana() <= 0) return;
for (int x = 0; x < primals.length; x++) {
for (Aspect primal : primals) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit > 0) {
deficit = Math.min(deficit, 100);
if (prop.getCurrentMana() > cost * deficit) {
prop.setCurrentMana(prop.getCurrentMana() - cost * deficit);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
}
} catch (Throwable e) {}
} catch (Throwable ignored) {}
}
}
}
@@ -13,7 +13,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class ManaWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.am2 && Config.crossWand) {
@@ -29,18 +29,18 @@ public class ManaWandUpdate implements IWandRodOnUpdate {
if (prop == null || prop.getCurrentMana() <= 0) return;
for (int x = 0; x < primals.length; x++) {
for (Aspect primal : primals) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit > 0) {
deficit = Math.min(deficit, 100);
if (prop.getCurrentMana() > cost * deficit) {
prop.setCurrentMana(prop.getCurrentMana() - cost * deficit);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
}
} catch (Throwable e) {}
} catch (Throwable ignored) {}
}
}
}
@@ -12,7 +12,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class ProfaneWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
@@ -24,15 +24,16 @@ public class ProfaneWandUpdate implements IWandRodOnUpdate {
tag.setInteger("contract", 25000);
} else if (tag.getInteger("contract") <= 0) return;
for (int x = 0; x < primals.length && tag.getInteger("contract") > 0; x++) {
for (Aspect primal : primals) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit > 0) {
int restore = Math.min(tag.getInteger("contract"), deficit);
((ItemWandCasting) itemstack.getItem()).addRealVis(itemstack, primals[x], restore, true);
((ItemWandCasting) itemstack.getItem()).addRealVis(itemstack, primal, restore, true);
tag.setInteger("contract", tag.getInteger("contract") - restore);
if (player.worldObj.rand.nextInt(2501) < restore) Thaumcraft.addStickyWarpToPlayer(player, 1);
}
if (tag.getInteger("contract") <= 0) break;
}
if (tag.getInteger("contract") <= 0) {
@@ -9,16 +9,16 @@ import thaumcraft.common.items.wands.ItemWandCasting;
public class TaintedWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (player.ticksExisted % 100 == 0
&& player.worldObj.getBiomeGenForCoords((int) player.posX, (int) player.posZ).biomeID
== thaumcraft.common.config.Config.biomeTaintID) {
for (int x = 0; x < primals.length; x++) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x])
for (Aspect primal : primals) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal)
< ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack) / 10) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
}
@@ -12,32 +12,29 @@ import vazkii.botania.api.mana.ManaItemHandler;
public class YandereWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.botan && Config.crossWand && player.ticksExisted % 40 == 0 && checkHotbar(itemstack, player)) {
try {
int cost;
if (((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("manasteel")
|| ((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("elementium"))
cost = Config.manavis - 2;
String capTag = ((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag();
if (capTag.equals("manasteel") || capTag.equals("elementium")) cost = Config.manavis - 2;
else cost = Config.manavis;
cost = Math.max(0, cost);
for (int x = 0; x < primals.length; x++) {
for (Aspect primal : primals) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit > 0) {
deficit = Math.min(deficit, 100);
if (ManaItemHandler.requestManaExact(itemstack, player, cost * deficit, true))
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
} catch (Throwable e) {
return;
}
} catch (Throwable ignored) {}
}
}