Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/fox/spiteful/forbidden/FMEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,11 @@ public void onGetHurt(LivingHurtEvent event) {
}
}

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 (((ItemWandCasting) equip.getItem()).getCap(equip).getTag().equals("alchemical")
String capTag = ((ItemWandCasting) equip.getItem()).getCap(equip).getTag();
if (capTag.equals("alchemical") || capTag.equals("blood_iron")
&& ((ItemWandCasting) equip.getItem()).getRod(equip).getTag().startsWith("blood")) {
event.entityLiving.addPotionEffect(new PotionEffect(Potion.weakness.id, 60, 2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,45 @@
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 DarkWandRodOnUpdate {

public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.bm && Config.crossWand && player.ticksExisted % 25 == 0) {
try {
if (!checkHotbar(itemstack, player)) return;
if (!Compat.bm || !Config.crossWand || player.ticksExisted % 25 != 0) {
return;
}
try {
if (!checkHotbar(itemstack, player)) return;

SoulNetworkHandler.checkAndSetItemOwner(itemstack, player);
SoulNetworkHandler.checkAndSetItemOwner(itemstack, player);

int cost;
if (((ItemWandCasting) itemstack.getItem()).getCap(itemstack).getTag().equals("alchemical"))
cost = Config.bloodvis - 1;
else cost = Config.bloodvis;
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);
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;
}
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 e) {
return;
}
}

} catch (Exception ignored) {}
}

public boolean syphonHealth(EntityPlayer player) {
Expand All @@ -60,14 +58,8 @@ public boolean syphonHealth(EntityPlayer player) {
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,51 @@
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 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;
}
}
if (!Compat.bm || !Config.crossWand || player.ticksExisted % 100 != 0) {
return;
}
try {
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);

} catch (Throwable e) {
return;
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,24 @@
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) {
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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,33 @@
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 DarkWandRodOnUpdate {

public void onUpdate(ItemStack itemstack, EntityPlayer player) {
if (Compat.am2 && Config.crossWand) {
if (player.ticksExisted % 40 == 0) {

try {
IExtendedProperties prop = ArsMagicaApi.instance.getExtendedProperties(player);

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;
if (!Compat.am2 || !Config.crossWand || player.ticksExisted % 40 != 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) {}
try {
IExtendedProperties prop = ArsMagicaApi.instance.getExtendedProperties(player);
if (prop == null || prop.getCurrentMana() <= 0) return;

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) {}
}
}
Loading