Wand Cap and Core Refactor (#18)

Co-authored-by: Martin Robertz <[email protected]>
Co-authored-by: Nikolay S. <[email protected]>
This commit is contained in:
authored and GitHub committed 2025-10-12 21:05:30 +02:00
1 parent 25aa0955d3
commit 8807501582
12 files changed
+234 -266

No files matched your search

+2 -2
View File
@@ -41,11 +41,11 @@ developmentEnvironmentUserName = Developer
# Enables using modern Java syntax (up to version 17) via Jabel, while still targeting JVM 8.
# See https://github.com/bsideup/jabel for details on how this works.
enableModernJavaSyntax = false
enableModernJavaSyntax = true
# Enables injecting missing generics into the decompiled source code for a better coding experience.
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
enableGenericInjection = false
enableGenericInjection = true
# Generate a class with a String field for the mod version named as defined below.
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
@@ -68,6 +68,7 @@ import fox.spiteful.forbidden.items.tools.ItemTaintPickaxe;
import fox.spiteful.forbidden.potions.DarkPotions;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.entities.ITaintedMob;
import thaumcraft.api.wands.WandCap;
import thaumcraft.common.config.ConfigItems;
import thaumcraft.common.items.wands.ItemWandCasting;
import thaumcraft.common.lib.utils.Utils;
@@ -481,7 +482,7 @@ public class FMEventHandler {
ItemStack wand = ((EntityPlayer) event.entityLiving).getCurrentEquippedItem();
if (event.source.getDamageType().equals("taint")
&& ((ItemWandCasting) wand.getItem()).getRod(wand).getTag().equals("tainted")) {
&& ((ItemWandCasting) wand.getItem()).getRod(wand) == ForbiddenItems.WAND_ROD_TAINTED) {
for (int x = 0; x < 3; x++) {
((ItemWandCasting) wand.getItem()).addVis(wand, primals[randy.nextInt(6)], 1, true);
@@ -489,17 +490,19 @@ public class FMEventHandler {
}
if ((event.source.getDamageType().equals("wither") || event.source.isFireDamage())
&& ((ItemWandCasting) wand.getItem()).getRod(wand).getTag().equals("infernal")) {
&& ((ItemWandCasting) wand.getItem()).getRod(wand) == ForbiddenItems.WAND_ROD_INFERNAL) {
event.setCanceled(true);
}
}
if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer) {
ItemStack equip = ((EntityPlayer) event.source.getEntity()).getCurrentEquippedItem();
if (equip != null && equip.getItem() instanceof ItemWandCasting) {
if (((ItemWandCasting) equip.getItem()).getCap(equip).getTag().equals("alchemical")
&& ((ItemWandCasting) equip.getItem()).getRod(equip).getTag().startsWith("blood")) {
if (event.source.getEntity() instanceof EntityPlayer player) {
ItemStack equip = player.getCurrentEquippedItem();
if (equip != null && equip.getItem() instanceof ItemWandCasting wand) {
WandCap cap = wand.getCap(equip);
// "blood_iron" is the Blood Iron Infused Cap from Blood Arsenal
if ((cap == ForbiddenItems.WAND_CAP_ALCHEMICAL || cap.getTag().equals("blood_iron"))
&& wand.getRod(equip).getTag().startsWith("blood")) {
event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
}
}
@@ -4,53 +4,20 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import fox.spiteful.forbidden.Config;
import fox.spiteful.forbidden.compat.Compat;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.items.wands.ItemWandCasting;
public class BloodStaffUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class BloodStaffUpdate extends BloodWandUpdate {
@Override
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.bm && Config.crossWand && player.ticksExisted % 25 == 0) {
try {
if (!checkHotbar(itemstack, player)) return;
SoulNetworkHandler.checkAndSetItemOwner(itemstack, player);
int cost;
if (((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("alchemical"))
cost = Config.bloodvis - 1;
else cost = Config.bloodvis;
cost = Math.max(0, cost);
for (int x = 0; x < primals.length; x++) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
if (deficit > 0) {
deficit = Math.min(deficit, 100);
if (player.capabilities.isCreativeMode)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
else if (SoulNetworkHandler.syphonFromNetwork(itemstack, cost * deficit) > 0)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
else if (syphonHealth(player)) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
return;
} else return;
}
}
} catch (Exception e) {
return;
}
}
if (!(checkHotbar(itemstack, player))) return;
super.onUpdate(itemstack, player);
}
@Override
protected int regenTimer() {
return 25;
}
@Override
public boolean syphonHealth(EntityPlayer player) {
if (player.getHealth() > 3) {
player.setHealth(player.getHealth() - 3);
@@ -60,14 +27,8 @@ public class BloodStaffUpdate implements IWandRodOnUpdate {
player.setHealth(0);
player.onDeath(new DamageSource("blooderp"));
return true;
} else return false;
}
private boolean checkHotbar(ItemStack stack, EntityPlayer player) {
for (int x = 0; x < 9; ++x) {
ItemStack item = player.inventory.getStackInSlot(x);
if (item == stack) return true;
} else {
return false;
}
return false;
}
}
@@ -6,52 +6,56 @@ import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import fox.spiteful.forbidden.Config;
import fox.spiteful.forbidden.compat.Compat;
import fox.spiteful.forbidden.items.ForbiddenItems;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.api.wands.WandCap;
import thaumcraft.common.items.wands.ItemWandCasting;
public class BloodWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class BloodWandUpdate extends DarkWandRodOnUpdate {
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.bm && Config.crossWand && player.ticksExisted % 100 == 0) {
try {
SoulNetworkHandler.checkAndSetItemOwner(itemstack, player);
int cost;
if (((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("alchemical"))
cost = Config.bloodvis - 1;
else cost = Config.bloodvis;
cost = Math.max(0, cost);
for (int x = 0; x < primals.length; x++) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
if (deficit > 0) {
deficit = Math.min(deficit, 100);
if (player.capabilities.isCreativeMode)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
else if (SoulNetworkHandler.syphonFromNetwork(itemstack, cost * deficit) > 0)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
else if (syphonHealth(player)) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
return;
} else return;
}
}
} catch (Throwable e) {
return;
}
if (!Compat.bm || !Config.crossWand || player.ticksExisted % regenTimer() != 0) {
return;
}
try {
SoulNetworkHandler.checkAndSetItemOwner(itemstack, player);
WandCap cap = ((ItemWandCasting) itemstack.getItem()).getCap(itemstack);
// "blood_iron" is the Blood Iron Infused Cap from Blood Arsenal
int cost = cap == ForbiddenItems.WAND_CAP_ALCHEMICAL || cap.getTag().equals("blood_iron")
? Config.bloodvis - 1
: Config.bloodvis;
cost = Math.max(0, cost);
int maxVis = getMaxVis(itemstack);
for (Aspect primal : primals) {
int deficit = maxVis - ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit <= 0) {
continue;
}
deficit = Math.min(deficit, 100);
if (player.capabilities.isCreativeMode)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
else if (SoulNetworkHandler.syphonFromNetwork(itemstack, cost * deficit) > 0)
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
else if (syphonHealth(player)) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
return;
} else {
return;
}
}
} catch (Exception ignored) {}
}
public boolean syphonHealth(EntityPlayer player) {
if (player.getHealth() > 6) {
player.setHealth(player.getHealth() - 3);
return true;
} else return false;
} else {
return false;
}
}
}
@@ -4,23 +4,15 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.items.wands.ItemWandCasting;
public class CreativeWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class CreativeWandUpdate extends DarkWandRodOnUpdate {
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
for (int x = 0; x < primals.length; x++) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x])
< ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)) {
((ItemWandCasting) itemstack.getItem()).addVis(
itemstack,
primals[x],
((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]),
true);
int maxVis = getMaxVis(itemstack);
for (Aspect primal : primals) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal) < maxVis) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, maxVis, true);
}
}
}
@@ -0,0 +1,32 @@
package fox.spiteful.forbidden.items.wands;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.items.wands.ItemWandCasting;
public abstract class DarkWandRodOnUpdate implements IWandRodOnUpdate {
static final Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
protected static int getMaxVis(ItemStack itemstack) {
return ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack);
}
protected boolean checkHotbar(ItemStack stack, EntityPlayer player) {
for (int x = 0; x < 9; ++x) {
ItemStack item = player.inventory.getStackInSlot(x);
if (item == stack) return true;
}
return false;
}
/**
* The number of ticks between when the wand core regenerates vis
*/
protected int regenTimer() {
return 100;
}
}
@@ -5,26 +5,24 @@ import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.items.wands.ItemWandCasting;
public class InfernalWandUpdate implements IWandRodOnUpdate {
public class InfernalWandUpdate extends DarkWandRodOnUpdate {
Aspect primals[] = { Aspect.ORDER, Aspect.ENTROPY, Aspect.AIR, Aspect.EARTH, Aspect.WATER };
static final 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.ticksExisted % regenTimer() == 0) {
int maxVis = getMaxVis(itemstack);
if (player.worldObj.provider.dimensionId == -1) {
for (int x = 0; x < primals.length; x++) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x])
< ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack) / 10) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
for (Aspect primal : primals) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal) < maxVis / 10) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
}
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, Aspect.FIRE)
< ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack) / 5) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, Aspect.FIRE) < maxVis / 5) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, Aspect.FIRE, 1, true);
}
}
@@ -3,45 +3,20 @@ package fox.spiteful.forbidden.items.wands;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import am2.api.ArsMagicaApi;
import am2.api.IExtendedProperties;
import fox.spiteful.forbidden.Config;
import fox.spiteful.forbidden.compat.Compat;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.items.wands.ItemWandCasting;
public class ManaStaffUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class ManaStaffUpdate extends ManaWandUpdate {
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.am2 && Config.crossWand) {
if (player.ticksExisted % 40 == 0) {
if (!(checkHotbar(itemstack, player))) return;
super.onUpdate(itemstack, player);
}
try {
IExtendedProperties prop = ArsMagicaApi.instance.getExtendedProperties(player);
@Override
protected int regenTimer() {
return 40;
}
float cost;
if (((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("vinteum"))
cost = 0.5F;
else cost = 1.0F;
if (prop == null || prop.getCurrentMana() <= 0) return;
for (int x = 0; x < primals.length; x++) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
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);
}
}
}
} catch (Throwable e) {}
}
}
@Override
protected float getCost(boolean hasVinteumCaps) {
return hasVinteumCaps ? 0.5F : 1.0F;
}
}
@@ -7,41 +7,39 @@ import am2.api.ArsMagicaApi;
import am2.api.IExtendedProperties;
import fox.spiteful.forbidden.Config;
import fox.spiteful.forbidden.compat.Compat;
import fox.spiteful.forbidden.items.ForbiddenItems;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.items.wands.ItemWandCasting;
public class ManaWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class ManaWandUpdate extends DarkWandRodOnUpdate {
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.am2 && Config.crossWand) {
if (player.ticksExisted % 100 == 0) {
try {
IExtendedProperties prop = ArsMagicaApi.instance.getExtendedProperties(player);
float cost;
if (((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("vinteum"))
cost = 0.8F;
else cost = 1.4F;
if (prop == null || prop.getCurrentMana() <= 0) return;
for (int x = 0; x < primals.length; x++) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
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);
}
}
}
} catch (Throwable e) {}
}
if (!Compat.am2 || !Config.crossWand || player.ticksExisted % regenTimer() != 0) {
return;
}
try {
IExtendedProperties prop = ArsMagicaApi.instance.getExtendedProperties(player);
if (prop == null || prop.getCurrentMana() <= 0) return;
float cost = getCost(
((ItemWandCasting) itemstack.getItem()).getCap(itemstack) == ForbiddenItems.WAND_CAP_VINTEUM);
int maxVis = getMaxVis(itemstack);
for (Aspect primal : primals) {
int deficit = maxVis - ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit <= 0) {
continue;
}
deficit = Math.min(deficit, 100);
if (prop.getCurrentMana() > cost * deficit) {
prop.setCurrentMana(prop.getCurrentMana() - cost * deficit);
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
} catch (Exception ignored) {}
}
protected float getCost(boolean hasVinteumCaps) {
return hasVinteumCaps ? 0.8F : 1.4F;
}
}
@@ -6,48 +6,57 @@ import net.minecraft.nbt.NBTTagCompound;
import fox.spiteful.forbidden.items.ForbiddenItems;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.Thaumcraft;
import thaumcraft.common.items.wands.ItemWandCasting;
public class ProfaneWandUpdate implements IWandRodOnUpdate {
Aspect[] primals = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class ProfaneWandUpdate extends DarkWandRodOnUpdate {
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (player.ticksExisted % 20 == 0) {
NBTTagCompound tag = itemstack.getTagCompound();
if (!tag.hasKey("contract")) {
Thaumcraft.proxy.getResearchManager().completeResearch(player, "ROD_profane");
tag.setInteger("contract", 25000);
} else if (tag.getInteger("contract") <= 0) return;
for (int x = 0; x < primals.length && tag.getInteger("contract") > 0; x++) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
if (deficit > 0) {
int restore = Math.min(tag.getInteger("contract"), deficit);
((ItemWandCasting) itemstack.getItem()).addRealVis(itemstack, primals[x], 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) {
((ItemWandCasting) itemstack.getItem()).setRod(itemstack, ForbiddenItems.WAND_ROD_PROFANED);
Thaumcraft.addStickyWarpToPlayer(player, 1);
player.worldObj.spawnParticle(
"largeexplode",
player.posX,
player.posY + (double) (player.height / 2.0F),
player.posZ,
0.0D,
0.0D,
0.0D);
}
itemstack.setTagCompound(tag);
if (player.ticksExisted % regenTimer() != 0) {
return;
}
NBTTagCompound tag = itemstack.getTagCompound();
int contract;
if (!tag.hasKey("contract")) {
Thaumcraft.proxy.getResearchManager().completeResearch(player, "ROD_profane");
contract = 25000;
} else {
contract = tag.getInteger("contract");
if (contract <= 0) return;
}
int maxVis = getMaxVis(itemstack);
for (Aspect primal : primals) {
int deficit = maxVis - ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit <= 0) {
continue;
}
int restore = Math.min(contract, deficit);
((ItemWandCasting) itemstack.getItem()).addRealVis(itemstack, primal, restore, true);
contract -= restore;
if (player.worldObj.rand.nextInt(2501) < restore) Thaumcraft.addStickyWarpToPlayer(player, 1);
if (contract <= 0) break;
}
if (contract <= 0) {
((ItemWandCasting) itemstack.getItem()).setRod(itemstack, ForbiddenItems.WAND_ROD_PROFANED);
Thaumcraft.addStickyWarpToPlayer(player, 1);
player.worldObj.spawnParticle(
"largeexplode",
player.posX,
player.posY + (double) (player.height / 2.0F),
player.posZ,
0.0D,
0.0D,
0.0D);
}
tag.setInteger("contract", contract);
itemstack.setTagCompound(tag);
}
@Override
protected int regenTimer() {
return 20;
}
}
@@ -2,24 +2,23 @@ package fox.spiteful.forbidden.items.wands;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.common.items.wands.ItemWandCasting;
public class TaintedWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class TaintedWandUpdate extends DarkWandRodOnUpdate {
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])
< ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack) / 10) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primals[x], 1, true);
}
if (player.ticksExisted % regenTimer() != 0 || player.worldObj.getBiomeGenForCoords(
MathHelper.floor_double(player.posX),
MathHelper.floor_double(player.posZ)).biomeID != thaumcraft.common.config.Config.biomeTaintID) {
return;
}
int maxVis = getMaxVis(itemstack);
for (Aspect primal : primals) {
if (((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal) < maxVis / 10) {
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
}
}
@@ -5,47 +5,44 @@ import net.minecraft.item.ItemStack;
import fox.spiteful.forbidden.Config;
import fox.spiteful.forbidden.compat.Compat;
import fox.spiteful.forbidden.items.ForbiddenItems;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.wands.IWandRodOnUpdate;
import thaumcraft.api.wands.WandCap;
import thaumcraft.common.items.wands.ItemWandCasting;
import vazkii.botania.api.mana.ManaItemHandler;
public class YandereWandUpdate implements IWandRodOnUpdate {
Aspect primals[] = Aspect.getPrimalAspects().toArray(new Aspect[0]);
public class YandereWandUpdate extends DarkWandRodOnUpdate {
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;
else cost = Config.manavis;
cost = Math.max(0, cost);
for (int x = 0; x < primals.length; x++) {
int deficit = ((ItemWandCasting) itemstack.getItem()).getMaxVis(itemstack)
- ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primals[x]);
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);
}
}
} catch (Throwable e) {
return;
}
if (!Compat.botan || !Config.crossWand
|| player.ticksExisted % regenTimer() != 0
|| !checkHotbar(itemstack, player)) {
return;
}
try {
int cost;
WandCap cap = ((ItemWandCasting) itemstack.getItem()).getCap(itemstack);
cost = cap == ForbiddenItems.WAND_CAP_MANASTEEL || cap == ForbiddenItems.WAND_CAP_ELEMENTIUM
? Config.manavis - 2
: Config.manavis;
cost = Math.max(0, cost);
int maxVis = getMaxVis(itemstack);
for (Aspect primal : primals) {
int deficit = maxVis - ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
if (deficit <= 0) {
continue;
}
deficit = Math.min(deficit, 100);
if (ManaItemHandler.requestManaExact(itemstack, player, cost * deficit, true))
((ItemWandCasting) itemstack.getItem()).addVis(itemstack, primal, 1, true);
}
} catch (Exception ignored) {}
}
private boolean checkHotbar(ItemStack stack, EntityPlayer player) {
for (int x = 0; x < 9; ++x) {
ItemStack item = player.inventory.getStackInSlot(x);
if (item == stack) return true;
}
return false;
@Override
protected int regenTimer() {
return 40;
}
}