diff --git a/src/main/java/fox/spiteful/avaritia/Avaritia.java b/src/main/java/fox/spiteful/avaritia/Avaritia.java index 98d013e..13204bf 100644 --- a/src/main/java/fox/spiteful/avaritia/Avaritia.java +++ b/src/main/java/fox/spiteful/avaritia/Avaritia.java @@ -70,5 +70,6 @@ public class Avaritia { Mincer.countThoseCalories(); Grinder.lastMinuteChanges(); Achievements.achieve(); + PotionHelper.healthInspection(); } } \ No newline at end of file diff --git a/src/main/java/fox/spiteful/avaritia/PotionHelper.java b/src/main/java/fox/spiteful/avaritia/PotionHelper.java new file mode 100644 index 0000000..bb3fc3b --- /dev/null +++ b/src/main/java/fox/spiteful/avaritia/PotionHelper.java @@ -0,0 +1,33 @@ +package fox.spiteful.avaritia; + +import cpw.mods.fml.relauncher.ReflectionHelper; +import net.minecraft.potion.Potion; +import org.apache.logging.log4j.Level; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.TreeSet; + +public class PotionHelper { + private static ArrayList badPotions; + + public static void healthInspection(){ + badPotions = new ArrayList(); + try { + Field stupidMojangPrivateVariable = ReflectionHelper.findField(Potion.class, "isBadEffect", "field_76418_K"); + + for(Potion potion : Potion.potionTypes){ + if(potion != null && stupidMojangPrivateVariable.getBoolean(potion)) + badPotions.add(potion); + } + } + catch(Exception e){ + Lumberjack.log(Level.ERROR, e, "Failure to get potions"); + e.printStackTrace(); + } + } + + public static boolean badPotion(Potion effect){ + return badPotions.contains(effect); + } +} diff --git a/src/main/java/fox/spiteful/avaritia/items/ItemArmorInfinity.java b/src/main/java/fox/spiteful/avaritia/items/ItemArmorInfinity.java index 47c1cde..58d96b8 100644 --- a/src/main/java/fox/spiteful/avaritia/items/ItemArmorInfinity.java +++ b/src/main/java/fox/spiteful/avaritia/items/ItemArmorInfinity.java @@ -4,6 +4,7 @@ import fox.spiteful.avaritia.Avaritia; import fox.spiteful.avaritia.Lumberjack; import fox.spiteful.avaritia.render.ModelArmorInfinity; import net.minecraft.client.model.ModelBiped; +import fox.spiteful.avaritia.PotionHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -11,6 +12,8 @@ import net.minecraft.item.EnumAction; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.common.util.EnumHelper; @@ -19,12 +22,15 @@ import org.apache.logging.log4j.Level; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import java.util.ArrayList; +import java.util.Collection; + public class ItemArmorInfinity extends ItemArmor { public static final ArmorMaterial infinite_armor = EnumHelper.addArmorMaterial("infinity", 9999, new int[]{6, 16, 12, 6}, 1000); public static final ModelArmorInfinity armorModel = new ModelArmorInfinity(1.0f); public static final ModelArmorInfinity legModel = new ModelArmorInfinity(0.5f); - + public ItemArmorInfinity(int slot){ super(infinite_armor, 0, slot); setCreativeTab(Avaritia.tab); @@ -46,6 +52,7 @@ public class ItemArmorInfinity extends ItemArmor { super.setDamage(stack, 0); } + @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if(armorType == 0){ @@ -55,6 +62,22 @@ public class ItemArmorInfinity extends ItemArmor { } else if(armorType == 1){ player.capabilities.allowFlying = true; + Collection effects = player.getActivePotionEffects(); + if(effects.size() > 0){ + ArrayList bad = new ArrayList(); + for(Object effect : effects){ + if(effect instanceof PotionEffect){ + PotionEffect potion = (PotionEffect)effect; + if(PotionHelper.badPotion(Potion.potionTypes[potion.getPotionID()])) + bad.add(Potion.potionTypes[potion.getPotionID()]); + } + } + if(bad.size() > 0){ + for(Potion potion : bad){ + player.removePotionEffect(potion.id); + } + } + } } else if(armorType == 2){ if(player.isBurning()) @@ -67,50 +90,50 @@ public class ItemArmorInfinity extends ItemArmor { { return LudicrousItems.cosmic; } - + @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel (EntityLivingBase entityLiving, ItemStack itemstack, int armorSlot){ - ModelArmorInfinity model = armorSlot == 2 ? legModel : armorModel; - - model.bipedHead.showModel = armorSlot == 0; - model.bipedHeadwear.showModel = armorSlot == 0; - model.bipedBody.showModel = armorSlot == 1; - model.bipedRightArm.showModel = armorSlot == 1; - model.bipedLeftArm.showModel = armorSlot == 1; - model.bipedRightLeg.showModel = armorSlot == 2 || armorSlot == 3; - model.bipedLeftLeg.showModel = armorSlot == 2 || armorSlot == 3; - - model.isSneak = entityLiving.isSneaking(); - model.isRiding = entityLiving.isRiding(); - model.isChild = entityLiving.isChild(); - - model.heldItemRight = 0; - model.aimedBow = false; - - EntityPlayer player = (EntityPlayer)entityLiving; - - ItemStack held_item = player.getEquipmentInSlot(0); - - if (held_item != null){ - model.heldItemRight = 1; - - if (player.getItemInUseCount() > 0){ - - EnumAction enumaction = held_item.getItemUseAction(); - - if (enumaction == EnumAction.bow){ - model.aimedBow = true; - }else if (enumaction == EnumAction.block){ - model.heldItemRight = 3; - } - - - } - - } - - return model; - } + @SideOnly(Side.CLIENT) + public ModelBiped getArmorModel (EntityLivingBase entityLiving, ItemStack itemstack, int armorSlot){ + ModelArmorInfinity model = armorSlot == 2 ? legModel : armorModel; + + model.bipedHead.showModel = armorSlot == 0; + model.bipedHeadwear.showModel = armorSlot == 0; + model.bipedBody.showModel = armorSlot == 1; + model.bipedRightArm.showModel = armorSlot == 1; + model.bipedLeftArm.showModel = armorSlot == 1; + model.bipedRightLeg.showModel = armorSlot == 2 || armorSlot == 3; + model.bipedLeftLeg.showModel = armorSlot == 2 || armorSlot == 3; + + model.isSneak = entityLiving.isSneaking(); + model.isRiding = entityLiving.isRiding(); + model.isChild = entityLiving.isChild(); + + model.heldItemRight = 0; + model.aimedBow = false; + + EntityPlayer player = (EntityPlayer)entityLiving; + + ItemStack held_item = player.getEquipmentInSlot(0); + + if (held_item != null){ + model.heldItemRight = 1; + + if (player.getItemInUseCount() > 0){ + + EnumAction enumaction = held_item.getItemUseAction(); + + if (enumaction == EnumAction.bow){ + model.aimedBow = true; + }else if (enumaction == EnumAction.block){ + model.heldItemRight = 3; + } + + + } + + } + + return model; + } } diff --git a/src/main/java/fox/spiteful/avaritia/items/tools/ItemSwordInfinity.java b/src/main/java/fox/spiteful/avaritia/items/tools/ItemSwordInfinity.java index 4fffb72..5a49cd7 100644 --- a/src/main/java/fox/spiteful/avaritia/items/tools/ItemSwordInfinity.java +++ b/src/main/java/fox/spiteful/avaritia/items/tools/ItemSwordInfinity.java @@ -57,7 +57,7 @@ public class ItemSwordInfinity extends ItemSword implements ICosmicRenderItem { stupidMojangProtectedVariable.setInt(victim, 60); } catch(Exception e){ - Lumberjack.log(Level.ERROR, e); + Lumberjack.log(Level.ERROR, e, "WHAT THE FUCK"); } victim.func_110142_aN().func_94547_a(new DamageSourceInfinitySword(player), victim.getHealth(), victim.getHealth()); victim.setHealth(0);