mirror of
https://github.com/GTNewHorizons/Avaritia.git
synced 2026-11-20 12:19:39 +00:00
Dancing Around Mojang's Private Variables
This commit is contained in:
1 parent
151d29865c
commit
8d33b6b298
4 files changed
+103
-46
No files matched your search
@@ -70,5 +70,6 @@ public class Avaritia {
|
||||
Mincer.countThoseCalories();
|
||||
Grinder.lastMinuteChanges();
|
||||
Achievements.achieve();
|
||||
PotionHelper.healthInspection();
|
||||
}
|
||||
}
|
||||
@@ -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<Potion> badPotions;
|
||||
|
||||
public static void healthInspection(){
|
||||
badPotions = new ArrayList<Potion>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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<Potion> bad = new ArrayList<Potion>();
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user