mirror of
https://github.com/GTNewHorizons/ForbiddenMagic.git
synced 2026-11-19 03:39:08 +00:00
Make staves extend their wand counterparts instead of copying logic
This commit is contained in:
1 parent
96b4d8d7da
commit
8939088024
9 files changed
+51
-78
No files matched your search
@@ -4,51 +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.common.items.wands.ItemWandCasting;
|
||||
|
||||
public class BloodStaffUpdate extends DarkWandRodOnUpdate {
|
||||
public class BloodStaffUpdate extends BloodWandUpdate {
|
||||
|
||||
@Override
|
||||
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
|
||||
if (!Compat.bm || !Config.crossWand || player.ticksExisted % 25 != 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (!checkHotbar(itemstack, player)) return;
|
||||
|
||||
SoulNetworkHandler.checkAndSetItemOwner(itemstack, player);
|
||||
|
||||
String capTag = ((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag();
|
||||
int cost = capTag.equals("alchemical") || capTag.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) {}
|
||||
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);
|
||||
|
||||
@@ -12,7 +12,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
public class BloodWandUpdate extends DarkWandRodOnUpdate {
|
||||
|
||||
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
|
||||
if (!Compat.bm || !Config.crossWand || player.ticksExisted % 100 != 0) {
|
||||
if (!Compat.bm || !Config.crossWand || player.ticksExisted % regenTimer() != 0) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -22,4 +22,11 @@ public abstract class DarkWandRodOnUpdate implements IWandRodOnUpdate {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The number of ticks between when the wand core regenerates vis
|
||||
*/
|
||||
protected int regenTimer() {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class InfernalWandUpdate extends DarkWandRodOnUpdate {
|
||||
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 (Aspect primal : primals) {
|
||||
|
||||
@@ -3,38 +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.common.items.wands.ItemWandCasting;
|
||||
|
||||
public class ManaStaffUpdate extends DarkWandRodOnUpdate {
|
||||
public class ManaStaffUpdate extends ManaWandUpdate {
|
||||
|
||||
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
|
||||
if (!Compat.am2 || !Config.crossWand || player.ticksExisted % 40 != 0) {
|
||||
return;
|
||||
}
|
||||
if (!(checkHotbar(itemstack, player))) return;
|
||||
super.onUpdate(itemstack, player);
|
||||
}
|
||||
|
||||
try {
|
||||
IExtendedProperties prop = ArsMagicaApi.instance.getExtendedProperties(player);
|
||||
if (prop == null || prop.getCurrentMana() <= 0) return;
|
||||
@Override
|
||||
protected int regenTimer() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
float cost = ((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("vinteum") ? 0.5F
|
||||
: 1.0F;
|
||||
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) {}
|
||||
@Override
|
||||
protected float getCost(boolean vinteumCaps) {
|
||||
return vinteumCaps ? 0.5F : 1.0F;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
public class ManaWandUpdate extends DarkWandRodOnUpdate {
|
||||
|
||||
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
|
||||
if (!Compat.am2 || !Config.crossWand || player.ticksExisted % 100 != 0) {
|
||||
if (!Compat.am2 || !Config.crossWand || player.ticksExisted % regenTimer() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ public class ManaWandUpdate extends DarkWandRodOnUpdate {
|
||||
IExtendedProperties prop = ArsMagicaApi.instance.getExtendedProperties(player);
|
||||
if (prop == null || prop.getCurrentMana() <= 0) return;
|
||||
|
||||
float cost = ((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("vinteum") ? 0.8F
|
||||
: 1.4F;
|
||||
float cost = getCost(((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("vinteum"));
|
||||
int maxVis = getMaxVis(itemstack);
|
||||
for (Aspect primal : primals) {
|
||||
int deficit = maxVis - ((ItemWandCasting) itemstack.getItem()).getVis(itemstack, primal);
|
||||
@@ -37,4 +36,8 @@ public class ManaWandUpdate extends DarkWandRodOnUpdate {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
protected float getCost(boolean vinteumCaps) {
|
||||
return vinteumCaps ? 0.8F : 1.4F;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
public class ProfaneWandUpdate extends DarkWandRodOnUpdate {
|
||||
|
||||
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
|
||||
if (player.ticksExisted % 20 != 0) {
|
||||
if (player.ticksExisted % regenTimer() != 0) {
|
||||
return;
|
||||
}
|
||||
NBTTagCompound tag = itemstack.getTagCompound();
|
||||
@@ -54,4 +54,9 @@ public class ProfaneWandUpdate extends DarkWandRodOnUpdate {
|
||||
tag.setInteger("contract", contract);
|
||||
itemstack.setTagCompound(tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int regenTimer() {
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import thaumcraft.common.items.wands.ItemWandCasting;
|
||||
public class TaintedWandUpdate extends DarkWandRodOnUpdate {
|
||||
|
||||
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
|
||||
if (player.ticksExisted % 100 != 0 || player.worldObj.getBiomeGenForCoords(
|
||||
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;
|
||||
|
||||
@@ -12,7 +12,9 @@ import vazkii.botania.api.mana.ManaItemHandler;
|
||||
public class YandereWandUpdate extends DarkWandRodOnUpdate {
|
||||
|
||||
public void onUpdate(ItemStack itemstack, EntityPlayer player) {
|
||||
if (!Compat.botan || !Config.crossWand || player.ticksExisted % 40 != 0 || !checkHotbar(itemstack, player)) {
|
||||
if (!Compat.botan || !Config.crossWand
|
||||
|| player.ticksExisted % regenTimer() != 0
|
||||
|| !checkHotbar(itemstack, player)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
@@ -34,4 +36,9 @@ public class YandereWandUpdate extends DarkWandRodOnUpdate {
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int regenTimer() {
|
||||
return 40;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user