diff --git a/src/main/java/thaumicboots/events/BootsEventHandler.java b/src/main/java/thaumicboots/events/BootsEventHandler.java index f20c976..77a4df5 100644 --- a/src/main/java/thaumicboots/events/BootsEventHandler.java +++ b/src/main/java/thaumicboots/events/BootsEventHandler.java @@ -6,18 +6,22 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.PlayerCapabilities; import net.minecraft.init.Blocks; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.Vec3; import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.entity.living.LivingEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import net.minecraftforge.event.entity.living.LivingFallEvent; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import emt.EMT; import flaxbeard.thaumicexploration.ThaumicExploration; import flaxbeard.thaumicexploration.common.ConfigTX; import flaxbeard.thaumicexploration.integration.TTIntegration; +import ic2.api.item.ElectricItem; import thaumicboots.item.boots.comet.ItemElectricCometBoots; import thaumicboots.item.boots.comet.ItemNanoCometBoots; import thaumicboots.item.boots.comet.ItemQuantumCometBoots; @@ -34,20 +38,24 @@ public class BootsEventHandler { @SubscribeEvent public void livingTick(LivingUpdateEvent event) { - if ((event.entity instanceof EntityPlayer)) { - EntityPlayer player = (EntityPlayer) event.entity; - checkAir(player); + if (!(event.entity instanceof EntityPlayer)) { + return; } - if ((event.entity.worldObj.isRemote) && (this.prevStep.containsKey(Integer.valueOf(event.entity.getEntityId()))) - && ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) == null) - || (!(((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemElectricMeteorBoots) - && !(((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemElectricCometBoots)))) { - event.entity.stepHeight = ((Float) this.prevStep.get(Integer.valueOf(event.entity.getEntityId()))) - .floatValue(); - this.prevStep.remove(Integer.valueOf(event.entity.getEntityId())); + EntityPlayer player = (EntityPlayer) event.entity; + checkAir(player); + + if (!(event.entity.worldObj.isRemote)) { + return; + } + + ItemStack boots = player.inventory.armorItemInSlot(0); + + if ((this.prevStep.containsKey(event.entity.getEntityId())) + && ((boots == null) || !((boots.getItem() instanceof ItemElectricMeteorBoots) + || (boots.getItem() instanceof ItemElectricCometBoots)))) { + event.entity.stepHeight = (this.prevStep.get(event.entity.getEntityId())); + this.prevStep.remove(event.entity.getEntityId()); } } @@ -58,24 +66,32 @@ public void joinWorld(EntityJoinWorldEvent event) { } } - HashMap prevStep = new HashMap(); + HashMap prevStep = new HashMap<>(); @SubscribeEvent public void playerJumps(LivingEvent.LivingJumpEvent event) { - if (((event.entity instanceof EntityPlayer)) - && (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) != null) - && ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemElectricMeteorBoots) - || ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemCometMeteorBoots) - || (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemMeteoricCometBoots) - || ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemMeteorVoidwalkerBoots))))) { - if (((EntityPlayer) event.entity).isSneaking()) { + + // if not a player + if (!(event.entity instanceof EntityPlayer)) { + return; + } + + EntityPlayer player = (EntityPlayer) event.entity; + + // if no boots equipped + if (player.inventory.armorItemInSlot(0) == null) { + return; + } + + Item item = player.inventory.armorItemInSlot(0).getItem(); + + if ((item instanceof ItemElectricMeteorBoots) || (item instanceof ItemCometMeteorBoots) + || (item instanceof ItemMeteoricCometBoots) + || (item instanceof ItemMeteorVoidwalkerBoots)) { + + if (player.isSneaking()) { Vec3 vector = event.entityLiving.getLook(0.5F); double total = Math.abs(vector.zCoord + vector.xCoord); - EntityPlayer player = (EntityPlayer) event.entity; double jump = 0; if (Loader.isModLoaded("ThaumicTinkerer")) { jump = TTIntegration.getAscentLevel((EntityPlayer) event.entity); @@ -92,83 +108,151 @@ public void playerJumps(LivingEvent.LivingJumpEvent event) { } else { // 0.275D is approx 3 blocks, 0.265D will get you to just 3 blocks, - - if ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemNanoMeteorBoots) - && !(((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemQuantumMeteorBoots)) { - event.entityLiving.motionY += 0.275D * 2.9; // 8 blocks - } else if (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemQuantumMeteorBoots) + if (item instanceof ItemQuantumMeteorBoots) { event.entityLiving.motionY += 0.275D * 4; // 12 blocks - else if (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemMeteorVoidwalkerBoots) { - event.entityLiving.motionY += 0.275D * 3.2; // 3 blocks - } else + } else if (item instanceof ItemNanoMeteorBoots) { + event.entityLiving.motionY += 0.275D * 2.9; // 8 blocks + } else if (item instanceof ItemMeteorVoidwalkerBoots) { + event.entityLiving.motionY += 0.275D * 3.2; // 3 blocks + } else { event.entityLiving.motionY += 0.275D * 1.9; // 5 blocks + } + } + } + + else if ((item instanceof ItemElectricCometBoots) || (item instanceof ItemCometVoidwalkerBoots)) { + // 0.55D is approx 5.5 blocks, so 0.275 is around 2.25 additional blocks + if (item instanceof ItemNanoCometBoots) { + event.entityLiving.motionY += 0.275D * 2.3; // 5.5 blocks + } else if (item instanceof ItemQuantumCometBoots) { + event.entityLiving.motionY += 0.275D * 3.3; // 12 blocks + } else if (item instanceof ItemCometVoidwalkerBoots) { + event.entityLiving.motionY += 0.450D; // 3.5 blocks + } else { + event.entityLiving.motionY += 0.275D; // 3 blocks + } + } + + else if ((item instanceof ItemElectricVoidwalkerBoots) || (item instanceof ItemNanoVoidwalkerBoots) + || (item instanceof ItemQuantumVoidwalkerBoots)) { + + if (item instanceof ItemElectricVoidwalkerBoots) { + event.entityLiving.motionY += 0.275D * 1.7; + } else if (item instanceof ItemNanoVoidwalkerBoots) { + event.entityLiving.motionY += 0.275D * 2.7; + } else { // ItemQuantumVoidwalkerBoots + event.entityLiving.motionY += 0.275D * 3.7; + } + } + } + + @SubscribeEvent + public void onLivingFall(LivingFallEvent event) { + if (!EMT.instance.isSimulating()) { + return; + } + + // if entity isn't a player + if (!(event.entity instanceof EntityPlayer)) { + return; + } + + EntityPlayer entity = (EntityPlayer) event.entity; + + // if no boots equiped + if (entity.inventory.armorInventory[0] == null) { + return; + } + ItemStack itemStack = entity.inventory.armorInventory[0]; + Item item = itemStack.getItem(); + + // if the boots aren't Comet boots or its derivative + if (!(item instanceof ItemElectricCometBoots)) { + return; + } + + ItemElectricCometBoots bootItem = (ItemElectricCometBoots) item; + + // nullifying the fall damages due to jump boost + if (event.distance <= bootItem.getMinimumHeight()) { + event.setCanceled(true); + return; + } + + double energyDemand = bootItem.getPowerConsumption(event.distance); + + // if boots can be discharged nullifying the fall damages + if (energyDemand <= ElectricItem.manager.getCharge(itemStack)) { + ElectricItem.manager.discharge(itemStack, energyDemand, Integer.MAX_VALUE, true, false, false); + event.setCanceled(true); + } + } + + public void grief(EntityPlayer player) { + // anti-griefing config + if (!ConfigTX.allowBootsIce) { + return; + } + for (int x = -5; x < 6; x++) { + for (int z = -5; z < 6; z++) { + int X = (int) (player.posX + x); + int Y = (int) (player.posY - 1); + int Z = (int) (player.posZ + z); + + // if the block isn't water + if (player.worldObj.getBlock(X, Y, Z) != Blocks.water) { + continue; + } + + // if the block hasn't some water properties + if (player.worldObj.getBlock(X, Y, Z).getMaterial() != Material.water) { + continue; + } + + // if the metadata of the block isn't 0 + if (player.worldObj.getBlockMetadata(X, Y, Z) != 0) { + continue; + } + + // if the player is in water + if (player.isInWater()) { + continue; + } + + // ??? + if ((Math.abs(x) + Math.abs(z) >= 8)) { + continue; + } + + player.worldObj.setBlock(X, Y, Z, ThaumicExploration.meltyIce); + player.worldObj.spawnParticle("snowballpoof", X, Y + 1, Z, 0.0D, 0.025D, 0.0D); } - } else if (((event.entity instanceof EntityPlayer)) - && (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) != null) - && ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemElectricCometBoots) - || (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemCometVoidwalkerBoots))) { - // 0.55D is approx 5.5 blocks, so 0.275 is around 2.25 additional blocks - if ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemNanoCometBoots) - && !(((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemQuantumCometBoots)) { - event.entityLiving.motionY += 0.275D * 2.3; // 5.5 blocks - } else if (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemQuantumCometBoots) - event.entityLiving.motionY += 0.275D * 3.3; // 12 blocks - else if (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemCometVoidwalkerBoots) { - event.entityLiving.motionY += 0.450D; // 3.5 blocks - } else - event.entityLiving.motionY += 0.275D; // 3 blocks - } else - if (((event.entity instanceof EntityPlayer)) - && (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) != null) - && ((((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemElectricVoidwalkerBoots) - || (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemNanoVoidwalkerBoots) - || (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemQuantumVoidwalkerBoots))) { - if (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemElectricVoidwalkerBoots) { - event.entityLiving.motionY += 0.275D * 1.7; // 3 blocks - } else if (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemNanoVoidwalkerBoots) { - event.entityLiving.motionY += 0.275D * 2.7; // 3 - // blocks - } else - if (((EntityPlayer) event.entity).inventory.armorItemInSlot(0) - .getItem() instanceof ItemQuantumVoidwalkerBoots) { - event.entityLiving.motionY += 0.275D * 3.7; // 3 - // blocks - } - } + } } // TODO boot effect public void checkAir(EntityPlayer player) { + + // no item in boots slot + if (player.inventory.armorItemInSlot(0) == null) { + return; + } + + Item item = player.inventory.armorItemInSlot(0).getItem(); + // meteor boots - if ((player.inventory.armorItemInSlot(0) != null) - && ((player.inventory.armorItemInSlot(0).getItem() instanceof ItemElectricMeteorBoots) - || (player.inventory.armorItemInSlot(0).getItem() instanceof ItemMeteorVoidwalkerBoots))) { - ItemStack item = player.inventory.armorItemInSlot(0); - if (!item.hasTagCompound()) { + if ((item instanceof ItemElectricMeteorBoots) || (item instanceof ItemMeteorVoidwalkerBoots)) { + ItemStack itemStack = player.inventory.armorItemInSlot(0); + if (!itemStack.hasTagCompound()) { NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); - item.setTagCompound(par1NBTTagCompound); - item.stackTagCompound.setBoolean("IsSmashing", false); - item.stackTagCompound.setInteger("smashTicks", 0); - item.stackTagCompound.setInteger("airTicks", 0); + itemStack.setTagCompound(par1NBTTagCompound); + itemStack.stackTagCompound.setBoolean("IsSmashing", false); + itemStack.stackTagCompound.setInteger("smashTicks", 0); + itemStack.stackTagCompound.setInteger("airTicks", 0); } - boolean smashing = item.stackTagCompound.getBoolean("IsSmashing"); - int ticks = item.stackTagCompound.getInteger("smashTicks"); - int ticksAir = item.stackTagCompound.getInteger("airTicks"); + boolean smashing = itemStack.stackTagCompound.getBoolean("IsSmashing"); + int ticks = itemStack.stackTagCompound.getInteger("smashTicks"); + int ticksAir = itemStack.stackTagCompound.getInteger("airTicks"); if (player.onGround || player.isOnLadder()) { int size = 0; @@ -200,31 +284,17 @@ public void checkAir(EntityPlayer player) { ticksAir = 0; } if (smashing) { + for (String particleName : new String[] { "flame", "smoke", "flame" }) { + player.worldObj.spawnParticle( + particleName, + player.posX + Math.random() - 0.5F, + player.posY + Math.random() - 0.5F, + player.posZ + Math.random() - 0.5F, + 0.0D, + 0.0D, + 0.0D); + } - player.worldObj.spawnParticle( - "flame", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.posY + Math.random() - 0.5F), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.0D, - 0.0D); - player.worldObj.spawnParticle( - "smoke", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.posY + Math.random() - 0.5F), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.0D, - 0.0D); - player.worldObj.spawnParticle( - "flame", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.posY + Math.random() - 0.5F), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.0D, - 0.0D); player.motionY -= 0.1F; ticks++; } else { @@ -232,273 +302,139 @@ public void checkAir(EntityPlayer player) { if (!player.isWet() && motion > 0.1F) { player.worldObj.spawnParticle( "flame", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.boundingBox.minY + 0.25F + ((Math.random() - 0.5) * 0.25F)), - (double) (player.posZ + Math.random() - 0.5F), + player.posX + Math.random() - 0.5F, + player.boundingBox.minY + 0.25F + ((Math.random() - 0.5) * 0.25F), + player.posZ + Math.random() - 0.5F, 0.0D, 0.025D, 0.0D); - // player.worldObj.spawnParticle("flame", (double)(player.posX + Math.random()-0.5F), - // (double)(player.boundingBox.minY + 0.25F + ((Math.random()-0.5)*0.25F)), (double)(player.posZ + - // Math.random()-0.5F), 0.0D, 0.025D, 0.0D); } } - item.stackTagCompound.setBoolean("IsSmashing", smashing); - item.stackTagCompound.setInteger("smashTicks", ticks); - item.stackTagCompound.setInteger("airTicks", ticksAir); + itemStack.stackTagCompound.setBoolean("IsSmashing", smashing); + itemStack.stackTagCompound.setInteger("smashTicks", ticks); + itemStack.stackTagCompound.setInteger("airTicks", ticksAir); } + // comet boots - else if ((player.inventory.armorItemInSlot(0) != null) - && (((player.inventory.armorItemInSlot(0).getItem() instanceof ItemElectricCometBoots)) - || (player.inventory.armorItemInSlot(0).getItem() instanceof ItemCometVoidwalkerBoots))) { - - Vec3 vector = player.getLook(1.0F); - ItemStack item = player.inventory.armorItemInSlot(0); - if (!item.hasTagCompound()) { - NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); - item.setTagCompound(par1NBTTagCompound); - item.stackTagCompound.setInteger("runTicks", 0); - } - - // anti-griefing config - if (ConfigTX.allowBootsIce) { - for (int x = -5; x < 6; x++) { - for (int z = -5; z < 6; z++) { - if ((player.worldObj.getBlock( - (int) (player.posX + x), - (int) (player.posY - 1), - (int) (player.posZ + z)) == Blocks.water - || player.worldObj.getBlock( - (int) (player.posX + x), - (int) (player.posY - 1), - (int) (player.posZ + z)) == Blocks.water) - && player.worldObj.getBlock( - (int) (player.posX + x), - (int) player.posY - 1, - (int) (player.posZ + z)).getMaterial() == Material.water - && player.worldObj.getBlockMetadata( - (int) (player.posX + x), - (int) player.posY - 1, - (int) (player.posZ + z)) == 0 - && !player.isInWater() - && (Math.abs(x) + Math.abs(z) < 8)) { - player.worldObj.setBlock( - (int) (player.posX + x), - (int) player.posY - 1, - (int) (player.posZ + z), - ThaumicExploration.meltyIce); - player.worldObj.spawnParticle( - "snowballpoof", - (int) (player.posX + x), - (int) player.posY, - (int) (player.posZ + z), - 0.0D, - 0.025D, - 0.0D); - } - } - } - } - - int ticks = item.stackTagCompound.getInteger("runTicks"); - - double motion = Math.abs(player.motionX) + Math.abs(player.motionZ) - + Math.abs(player.motionY); - if (motion > 0.1F || !player.onGround || player.isOnLadder()) { - if (ticks < 100) ticks++; - } else { - ticks = 0; - } - - if (!player.isWet() && motion > 0.1F) { - player.worldObj.spawnParticle( - "fireworksSpark", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.boundingBox.minY + 0.25F + ((Math.random() - 0.5) * 0.25F)), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.025D, - 0.0D); - - // player.worldObj.spawnParticle("snowballpoof", (double)(player.posX + - // Math.random()-0.5F), - // (double)(player.boundingBox.minY + 0.25F + ((Math.random()-0.5)*0.25F)), - // (double)(player.posZ - // + - // Math.random()-0.5F), 0.0D, 0.025D, 0.0D); - } - - item.stackTagCompound.setInteger("runTicks", ticks); - } else - if ((player.inventory.armorItemInSlot(0) != null) - && (((player.inventory.armorItemInSlot(0).getItem() instanceof ItemMeteoricCometBoots)) - || (player.inventory.armorItemInSlot(0).getItem() instanceof ItemCometMeteorBoots))) { - ItemStack item = player.inventory.armorItemInSlot(0); - if (!item.hasTagCompound()) { - NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); - item.setTagCompound(par1NBTTagCompound); - item.stackTagCompound.setBoolean("IsSmashingMix", false); - item.stackTagCompound.setInteger("smashTicksMix", 0); - item.stackTagCompound.setInteger("airTicksMix", 0); - item.stackTagCompound.setInteger("runTicksMix", 0); - } - // anti-griefing config - if (ConfigTX.allowBootsIce) { - for (int x = -5; x < 6; x++) { - for (int z = -5; z < 6; z++) { - if ((player.worldObj.getBlock( - (int) (player.posX + x), - (int) (player.posY - 1), - (int) (player.posZ + z)) == Blocks.water - || player.worldObj.getBlock( - (int) (player.posX + x), - (int) (player.posY - 1), - (int) (player.posZ + z)) == Blocks.water) - && player.worldObj.getBlock( - (int) (player.posX + x), - (int) player.posY - 1, - (int) (player.posZ + z)).getMaterial() == Material.water - && player.worldObj.getBlockMetadata( - (int) (player.posX + x), - (int) player.posY - 1, - (int) (player.posZ + z)) == 0 - && !player.isInWater() - && (Math.abs(x) + Math.abs(z) < 8)) { - player.worldObj.setBlock( - (int) (player.posX + x), - (int) player.posY - 1, - (int) (player.posZ + z), - ThaumicExploration.meltyIce); - player.worldObj.spawnParticle( - "snowballpoof", - (int) (player.posX + x), - (int) player.posY, - (int) (player.posZ + z), - 0.0D, - 0.025D, - 0.0D); - } - } - } - } - - boolean smashing = item.stackTagCompound.getBoolean("IsSmashingMix"); - int ticksSmash = item.stackTagCompound.getInteger("smashTicksMix"); - int ticksAir = item.stackTagCompound.getInteger("airTicksMix"); - int ticksRun = item.stackTagCompound.getInteger("runTicksMix"); - double motionRun = Math.abs(player.motionX) + Math.abs(player.motionZ) - + Math.abs(player.motionY); - if (motionRun > 0.1F || !player.onGround || player.isOnLadder()) { - if (ticksRun < 100) ticksRun++; - } else { - ticksRun = 0; - } - if (player.onGround || player.isOnLadder()) { - int size = 0; - if (ticksSmash > 5) size = 1; - if (ticksSmash > 10) size = 2; - if (ticksSmash > 15) size = 3; - smashing = false; - ticksSmash = 0; - ticksAir = 0; - if (size > 0) { - player.worldObj.createExplosion( - player, - player.posX, - player.posY, - player.posZ, - size, - false); - } - } - - // COME ON AND SLAM - if (!player.onGround && !player.isOnLadder() && !player.isInWater()) { - if (!player.isSneaking()) { - ticksAir++; - } - - if (player.isSneaking() && ticksAir > 5) { - smashing = true; - } - } - - if (player.capabilities.isFlying) { - smashing = false; - ticksSmash = 0; - ticksAir = 0; - } - if (smashing) { - - player.worldObj.spawnParticle( - "flame", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.posY + Math.random() - 0.5F), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.0D, - 0.0D); - player.worldObj.spawnParticle( - "smoke", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.posY + Math.random() - 0.5F), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.0D, - 0.0D); - player.worldObj.spawnParticle( - "flame", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.posY + Math.random() - 0.5F), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.0D, - 0.0D); - player.motionY -= 0.1F; - ticksSmash++; - } - - if (!player.isWet() && motionRun > 0.1F) { - player.worldObj.spawnParticle( - "fireworksSpark", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.boundingBox.minY + 0.25F - + ((Math.random() - 0.5) * 0.25F)), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.025D, - 0.0D); - player.worldObj.spawnParticle( - "flame", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.boundingBox.minY + 0.25F - + ((Math.random() - 0.5) * 0.25F)), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.025D, - 0.0D); - player.worldObj.spawnParticle( - "flame", - (double) (player.posX + Math.random() - 0.5F), - (double) (player.boundingBox.minY + 0.25F - + ((Math.random() - 0.5) * 0.25F)), - (double) (player.posZ + Math.random() - 0.5F), - 0.0D, - 0.025D, - 0.0D); - // player.worldObj.spawnParticle("snowballpoof", (double)(player.posX + - // Math.random()-0.5F), - // (double)(player.boundingBox.minY + 0.25F + ((Math.random()-0.5)*0.25F)), - // (double)(player.posZ - // + - // Math.random()-0.5F), 0.0D, 0.025D, 0.0D); - } - - item.stackTagCompound.setInteger("runTicksMix", ticksRun); - item.stackTagCompound.setBoolean("IsSmashingMix", smashing); - item.stackTagCompound.setInteger("smashTicksMix", ticksSmash); - item.stackTagCompound.setInteger("airTicksMix", ticksAir); - } + else if ((item instanceof ItemElectricCometBoots) || (item instanceof ItemCometVoidwalkerBoots)) { + ItemStack itemStack = player.inventory.armorItemInSlot(0); + if (!itemStack.hasTagCompound()) { + NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); + itemStack.setTagCompound(par1NBTTagCompound); + itemStack.stackTagCompound.setInteger("runTicks", 0); + } + + grief(player); + + int ticks = itemStack.stackTagCompound.getInteger("runTicks"); + + double motion = Math.abs(player.motionX) + Math.abs(player.motionZ) + Math.abs(player.motionY); + if (motion > 0.1F || !player.onGround || player.isOnLadder()) { + if (ticks < 100) ticks++; + } else { + ticks = 0; + } + + if (!player.isWet() && motion > 0.1F) { + player.worldObj.spawnParticle( + "fireworksSpark", + player.posX + Math.random() - 0.5F, + player.boundingBox.minY + 0.25F + ((Math.random() - 0.5) * 0.25F), + player.posZ + Math.random() - 0.5F, + 0.0D, + 0.025D, + 0.0D); + } + + itemStack.stackTagCompound.setInteger("runTicks", ticks); + } + + else if ((item instanceof ItemMeteoricCometBoots || (item instanceof ItemCometMeteorBoots))) { + ItemStack itemStack = player.inventory.armorItemInSlot(0); + if (!itemStack.hasTagCompound()) { + NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); + itemStack.setTagCompound(par1NBTTagCompound); + itemStack.stackTagCompound.setBoolean("IsSmashingMix", false); + itemStack.stackTagCompound.setInteger("smashTicksMix", 0); + itemStack.stackTagCompound.setInteger("airTicksMix", 0); + itemStack.stackTagCompound.setInteger("runTicksMix", 0); + } + grief(player); + + boolean smashing = itemStack.stackTagCompound.getBoolean("IsSmashingMix"); + int ticksSmash = itemStack.stackTagCompound.getInteger("smashTicksMix"); + int ticksAir = itemStack.stackTagCompound.getInteger("airTicksMix"); + int ticksRun = itemStack.stackTagCompound.getInteger("runTicksMix"); + double motionRun = Math.abs(player.motionX) + Math.abs(player.motionZ) + Math.abs(player.motionY); + if (motionRun > 0.1F || !player.onGround || player.isOnLadder()) { + if (ticksRun < 100) ticksRun++; + } else { + ticksRun = 0; + } + if (player.onGround || player.isOnLadder()) { + int size = 0; + if (ticksSmash > 5) size = 1; + if (ticksSmash > 10) size = 2; + if (ticksSmash > 15) size = 3; + smashing = false; + ticksSmash = 0; + ticksAir = 0; + if (size > 0) { + player.worldObj.createExplosion(player, player.posX, player.posY, player.posZ, size, false); + } + } + + // COME ON AND SLAM + if (!player.onGround && !player.isOnLadder() && !player.isInWater()) { + if (!player.isSneaking()) { + ticksAir++; + } + + if (player.isSneaking() && ticksAir > 5) { + smashing = true; + } + } + + if (player.capabilities.isFlying) { + smashing = false; + ticksSmash = 0; + ticksAir = 0; + } + if (smashing) { + + for (String particleName : new String[] { "flame", "smoke", "flame" }) { + player.worldObj.spawnParticle( + particleName, + player.posX + Math.random() - 0.5F, + player.posY + Math.random() - 0.5F, + player.posZ + Math.random() - 0.5F, + 0.0D, + 0.0D, + 0.0D); + } + + player.motionY -= 0.1F; + ticksSmash++; + } + + if (!player.isWet() && motionRun > 0.1F) { + for (String particleName : new String[] { "fireworksSpark", "flame", "flame" }) { + player.worldObj.spawnParticle( + particleName, + player.posX + Math.random() - 0.5F, + player.boundingBox.minY + 0.25F + ((Math.random() - 0.5) * 0.25F), + player.posZ + Math.random() - 0.5F, + 0.0D, + 0.025D, + 0.0D); + } + } + + itemStack.stackTagCompound.setInteger("runTicksMix", ticksRun); + itemStack.stackTagCompound.setBoolean("IsSmashingMix", smashing); + itemStack.stackTagCompound.setInteger("smashTicksMix", ticksSmash); + itemStack.stackTagCompound.setInteger("airTicksMix", ticksAir); + } } } diff --git a/src/main/java/thaumicboots/item/boots/comet/ItemElectricCometBoots.java b/src/main/java/thaumicboots/item/boots/comet/ItemElectricCometBoots.java index ea69103..31b39d9 100644 --- a/src/main/java/thaumicboots/item/boots/comet/ItemElectricCometBoots.java +++ b/src/main/java/thaumicboots/item/boots/comet/ItemElectricCometBoots.java @@ -35,17 +35,48 @@ public class ItemElectricCometBoots extends ItemArmor implements IRepairable, IRunicArmor, IElectricItem, IVisDiscountGear, ISpecialArmor { public IIcon icon; - - public int maxCharge = 100000; - public int energyPerDamage = 1000; - public int visDiscount = 2; - - public double transferLimit = 100; + public float baseBonus; + public float minimumHeight; + public int maxCharge; + public int energyPerDamage; + public int visDiscount; + public int runicCharge; + public int tier; + public double minimumDistance; + public double damageAbsorptionRatio; + public double baseAbsorptionRatio; + public double transferLimit; + public boolean provideEnergy; + public String iconResPath; + public String armorResPath; + public String unlocalisedName; + public EnumRarity rarity; public ItemElectricCometBoots(ArmorMaterial par2EnumArmorMaterial, int par3, int par4) { super(par2EnumArmorMaterial, par3, par4); + setBootsData(); setCreativeTab(TabThaumicBoots.tabThaumicBoots); - setUnlocalizedName("ItemElectricComet"); + setUnlocalizedName(unlocalisedName); + + } + + protected void setBootsData() { + maxCharge = 100_000; + energyPerDamage = 1_000; + runicCharge = 0; + visDiscount = 2; + provideEnergy = false; + baseAbsorptionRatio = 0.15D; + damageAbsorptionRatio = 1.5D; + transferLimit = 100; + baseBonus = 0.165F; + minimumHeight = 4F; + minimumDistance = 20d; + tier = 2; + iconResPath = "thaumicboots:electricComet_16x"; + armorResPath = "thaumicboots:model/electricbootsComet.png"; + unlocalisedName = "ItemElectricComet"; + rarity = EnumRarity.rare; } @SideOnly(Side.CLIENT) @@ -63,7 +94,7 @@ public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister ir) { - this.icon = ir.registerIcon("thaumicboots:electricComet_16x"); + this.icon = ir.registerIcon(iconResPath); } @SideOnly(Side.CLIENT) @@ -73,7 +104,7 @@ public IIcon func_77617_a(int par1) { @Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, String layer) { - return "thaumicboots:model/electricbootsComet.png"; + return armorResPath; } @Override @@ -82,13 +113,39 @@ public EnumRarity getRarity(ItemStack par1ItemStack) { } public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.isItemEqual(new ItemStack(Items.leather)) ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); + return par2ItemStack.isItemEqual(new ItemStack(Items.leather)) + || super.getIsRepairable(par1ItemStack, par2ItemStack); + } + + public float getPowerConsumptionMultiplier(float distance) { + return (distance > minimumDistance) ? distance * 3 : distance; + } + + public float getPowerConsumption(float distance) { + return energyPerDamage * (getPowerConsumptionMultiplier(distance) - getMinimumHeight()); + } + + public float getMinimumHeight() { + return minimumHeight; + } + + protected float computeBonus(ItemStack itemStack, EntityPlayer player) { + int ticks = player.inventory.armorItemInSlot(0).stackTagCompound.getInteger("runTicks"); + + float bonus = baseBonus + ((ticks / 5) * 0.003F); + if (ElectricItem.manager.getCharge(itemStack) == 0) { + bonus = 0; + } else if (player.isInWater()) { + bonus /= 4.0F; + } + + return bonus; } @Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - if (player.capabilities.isFlying || player.moveForward == 0F) { + + if (player.capabilities.isFlying || player.moveForward <= 0F) { return; } @@ -104,14 +161,8 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { player.inventory.armorItemInSlot(0).setTagCompound(par1NBTTagCompound); player.inventory.armorItemInSlot(0).stackTagCompound.setInteger("runTicks", 0); } - int ticks = player.inventory.armorItemInSlot(0).stackTagCompound.getInteger("runTicks"); - float bonus = 0.165F; - bonus = bonus + ((ticks / 5) * 0.003F); - if (ElectricItem.manager.getCharge(itemStack) == 0) { - bonus = 0; - } else if (player.isInWater()) { - bonus /= 4.0F; - } + + float bonus = computeBonus(itemStack, player); if (player.onGround || player.isOnLadder()) { player.moveFlying(0.0F, 1.0F, bonus); @@ -120,24 +171,10 @@ public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { } else { player.jumpMovementFactor = 0.05F; } - - if (player.fallDistance > 4.0F) { - player.fallDistance -= 0.50F; - - float distanceMultiplicator = (player.fallDistance > 20.0F) ? player.fallDistance * 3 : player.fallDistance; - float tEnergyDemand = energyPerDamage * (distanceMultiplicator - 3.5F); - - if (tEnergyDemand <= ElectricItem.manager.getCharge(itemStack)) { - ElectricItem.manager.discharge(itemStack, tEnergyDemand, Integer.MAX_VALUE, true, false, false); - player.fallDistance = 0.0F; - } - } else { - player.fallDistance = 0.0F; - } } public int getRunicCharge(ItemStack arg0) { - return 0; + return runicCharge; } @Override @@ -169,11 +206,11 @@ public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource s } public double getDamageAbsorptionRatio() { - return 1.25D; + return damageAbsorptionRatio; } - private double getBaseAbsorptionRatio() { - return 0.15D; + protected double getBaseAbsorptionRatio() { + return baseAbsorptionRatio; } @Override @@ -187,7 +224,7 @@ public int getEnergyPerDamage() { @Override public boolean canProvideEnergy(ItemStack itemStack) { - return false; + return provideEnergy; } @Override diff --git a/src/main/java/thaumicboots/item/boots/comet/ItemNanoCometBoots.java b/src/main/java/thaumicboots/item/boots/comet/ItemNanoCometBoots.java index ca64e42..a49d479 100644 --- a/src/main/java/thaumicboots/item/boots/comet/ItemNanoCometBoots.java +++ b/src/main/java/thaumicboots/item/boots/comet/ItemNanoCometBoots.java @@ -1,227 +1,32 @@ package thaumicboots.item.boots.comet; -import java.util.List; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.ISpecialArmor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import emt.util.EMTConfigHandler; -import emt.util.EMTTextHelper; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; -import thaumcraft.api.IRepairable; -import thaumcraft.api.IRunicArmor; -import thaumcraft.api.IVisDiscountGear; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.common.Thaumcraft; -import thaumcraft.common.items.armor.Hover; -import thaumicboots.main.utils.TabThaumicBoots; - -public class ItemNanoCometBoots extends ItemElectricCometBoots - implements IRepairable, IRunicArmor, IElectricItem, IVisDiscountGear, ISpecialArmor { - - public IIcon icon; - public int maxCharge = 1000000; - public int energyPerDamage = 5000; - public int visDiscount = 4; - - public double transferLimit = 1600; +public class ItemNanoCometBoots extends ItemElectricCometBoots { public ItemNanoCometBoots(ArmorMaterial par2EnumArmorMaterial, int par3, int par4) { super(par2EnumArmorMaterial, par3, par4); - setCreativeTab(TabThaumicBoots.tabThaumicBoots); - setUnlocalizedName("ItemNanoComet"); - } - - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.icon = ir.registerIcon("thaumicboots:nanoComet_16x"); - } - - @SideOnly(Side.CLIENT) - public IIcon func_77617_a(int par1) { - return this.icon; - } - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String layer) { - return "thaumicboots:model/nanobootsComet.png"; - } - - @Override - public EnumRarity getRarity(ItemStack par1ItemStack) { - return EnumRarity.rare; - } - - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.isItemEqual(new ItemStack(Items.leather)) ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - if (player.capabilities.isFlying || player.moveForward == 0F) { - return; - } - - if (player.worldObj.isRemote) { - if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(Integer.valueOf(player.getEntityId()))) { - Thaumcraft.instance.entityEventHandler.prevStep - .put(Integer.valueOf(player.getEntityId()), Float.valueOf(player.stepHeight)); - } - player.stepHeight = 1.0F; - } - if (!player.inventory.armorItemInSlot(0).hasTagCompound()) { - NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); - player.inventory.armorItemInSlot(0).setTagCompound(par1NBTTagCompound); - player.inventory.armorItemInSlot(0).stackTagCompound.setInteger("runTicks", 0); - } - - int ticks = player.inventory.armorItemInSlot(0).stackTagCompound.getInteger("runTicks"); - float bonus = (float) EMTConfigHandler.nanoBootsSpeed + 0.110F; - bonus = bonus + ((ticks / 5) * 0.003F); - if (ElectricItem.manager.getCharge(itemStack) == 0) { - bonus = 0; - } else if (player.isInWater()) { - bonus /= 4.0F; - } - - if (player.onGround || player.isOnLadder()) { - player.moveFlying(0.0F, 1.0F, bonus); - } else if (Hover.getHover(player.getEntityId())) { - player.jumpMovementFactor = 0.03F; - } else { - player.jumpMovementFactor = 0.05F; - } - - if (player.fallDistance > 6.0F) { - player.fallDistance -= 1.0F; - - float distanceMultiplier = (player.fallDistance > EMTConfigHandler.nanoBootsMaxDrop) - ? player.fallDistance * 3 - : player.fallDistance; - float tEnergyDemand = energyPerDamage * (distanceMultiplier - 5.0F); - - if (tEnergyDemand <= ElectricItem.manager.getCharge(itemStack)) { - ElectricItem.manager.discharge(itemStack, tEnergyDemand, Integer.MAX_VALUE, true, false, false); - player.fallDistance = 0.0F; - } - - } else { - player.fallDistance = 0.0F; - } - - } - - public int getRunicCharge(ItemStack arg0) { - return 0; - } - - @Override - public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, - double damage, int slot) { - if (source.isUnblockable()) { - return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 0); - } else { - double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio(); - int energyPerDamage = getEnergyPerDamage(); - double damageLimit = energyPerDamage <= 0 ? 0 - : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage; - return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, absorptionRatio, (int) damageLimit); - } - } - - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage()) { - return (int) Math.round(20D * getBaseAbsorptionRatio() * getDamageAbsorptionRatio()); - } else { - return 0; - } - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - ElectricItem.manager.discharge(stack, damage * getEnergyPerDamage(), 0x7fffffff, true, false, false); - } - - public double getDamageAbsorptionRatio() { - return 1.5D; - } - - private double getBaseAbsorptionRatio() { - return 0.15D; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { - list.add(EMTTextHelper.PURPLE + EMTTextHelper.localize("tooltip.EMT.visDiscount") + ": " + visDiscount + "%"); - } - - public int getEnergyPerDamage() { - return energyPerDamage; - } - - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return false; - } - - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } - - @Override - public int getTier(ItemStack itemStack) { - return 3; - } - - @Override - public double getTransferLimit(ItemStack itemStack) { - return transferLimit; - } - - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } - - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; } @Override - public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect) { - return visDiscount; + protected void setBootsData() { + maxCharge = 1_000_000; + energyPerDamage = 5_000; + visDiscount = 4; + transferLimit = 1_600; + iconResPath = "thaumicboots:nanoComet_16x"; + armorResPath = "thaumicboots:model/nanobootsComet.png"; + unlocalisedName = "ItemNanoComet"; + rarity = EnumRarity.rare; + baseBonus = (float) EMTConfigHandler.nanoBootsSpeed + 0.110F; + minimumHeight = 6F; + minimumDistance = EMTConfigHandler.nanoBootsMaxDrop; + runicCharge = 0; + damageAbsorptionRatio = 1.5D; + baseAbsorptionRatio = 0.15D; + provideEnergy = false; + tier = 3; } } diff --git a/src/main/java/thaumicboots/item/boots/comet/ItemQuantumCometBoots.java b/src/main/java/thaumicboots/item/boots/comet/ItemQuantumCometBoots.java index 7a2b813..c500366 100644 --- a/src/main/java/thaumicboots/item/boots/comet/ItemQuantumCometBoots.java +++ b/src/main/java/thaumicboots/item/boots/comet/ItemQuantumCometBoots.java @@ -1,225 +1,32 @@ package thaumicboots.item.boots.comet; -import java.util.List; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.DamageSource; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.ISpecialArmor; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import emt.util.EMTConfigHandler; -import emt.util.EMTTextHelper; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; -import thaumcraft.api.IRepairable; -import thaumcraft.api.IRunicArmor; -import thaumcraft.api.IVisDiscountGear; -import thaumcraft.api.aspects.Aspect; -import thaumcraft.common.Thaumcraft; -import thaumcraft.common.items.armor.Hover; -import thaumicboots.main.utils.TabThaumicBoots; - -public class ItemQuantumCometBoots extends ItemElectricCometBoots - implements IRepairable, IRunicArmor, IElectricItem, IVisDiscountGear, ISpecialArmor { - - public IIcon icon; - public int maxCharge = 10000000; - public int energyPerDamage = 20000; - public int visDiscount = 5; - - public double transferLimit = 12000; +public class ItemQuantumCometBoots extends ItemElectricCometBoots { public ItemQuantumCometBoots(ArmorMaterial par2EnumArmorMaterial, int par3, int par4) { super(par2EnumArmorMaterial, par3, par4); - setCreativeTab(TabThaumicBoots.tabThaumicBoots); - setUnlocalizedName("ItemQuantumComet"); - } - - @SideOnly(Side.CLIENT) - public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { - ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { - ItemStack charged = new ItemStack(this, 1); - ElectricItem.manager.charge(charged, 2147483647, 2147483647, true, false); - itemList.add(charged); - } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); - } - } - - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister ir) { - this.icon = ir.registerIcon("thaumicboots:quantumComet_16x"); - } - - @SideOnly(Side.CLIENT) - public IIcon func_77617_a(int par1) { - return this.icon; - } - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String layer) { - return "thaumicboots:model/quantumbootsComet.png"; - } - - @Override - public EnumRarity getRarity(ItemStack par1ItemStack) { - return EnumRarity.rare; - } - - public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { - return par2ItemStack.isItemEqual(new ItemStack(Items.leather)) ? true - : super.getIsRepairable(par1ItemStack, par2ItemStack); - } - - @Override - public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { - if (player.capabilities.isFlying || player.moveForward == 0F) { - return; - } - - if (player.worldObj.isRemote) { - if (!Thaumcraft.instance.entityEventHandler.prevStep.containsKey(Integer.valueOf(player.getEntityId()))) { - Thaumcraft.instance.entityEventHandler.prevStep - .put(Integer.valueOf(player.getEntityId()), Float.valueOf(player.stepHeight)); - } - player.stepHeight = 1.0F; - } - if (!player.inventory.armorItemInSlot(0).hasTagCompound()) { - NBTTagCompound par1NBTTagCompound = new NBTTagCompound(); - player.inventory.armorItemInSlot(0).setTagCompound(par1NBTTagCompound); - player.inventory.armorItemInSlot(0).stackTagCompound.setInteger("runTicks", 0); - } - int ticks = player.inventory.armorItemInSlot(0).stackTagCompound.getInteger("runTicks"); - float bonus = (float) EMTConfigHandler.quantumBootsSpeed + 0.220F; - bonus = bonus + ((ticks / 5) * 0.003F); - if (ElectricItem.manager.getCharge(itemStack) == 0) { - bonus = 0; - } else if (player.isInWater()) { - bonus /= 4.0F; - } - - if (player.onGround || player.isOnLadder()) { - player.moveFlying(0.0F, 1.0F, bonus); - } else if (Hover.getHover(player.getEntityId())) { - player.jumpMovementFactor = 0.03F; - } else { - player.jumpMovementFactor = 0.05F; - } - - if (player.fallDistance > 10.0F) { - player.fallDistance -= 2.0F; - - float distanceMultiplier = (player.fallDistance > EMTConfigHandler.quantumBootsMaxDrop) - ? player.fallDistance * 3 - : player.fallDistance; - float tEnergyDemand = energyPerDamage * (distanceMultiplier - 8.0F); - - if (tEnergyDemand <= ElectricItem.manager.getCharge(itemStack)) { - ElectricItem.manager.discharge(itemStack, tEnergyDemand, Integer.MAX_VALUE, true, false, false); - player.fallDistance = 0.0F; - } - - } else { - player.fallDistance = 0.0F; - } - } - - public int getRunicCharge(ItemStack arg0) { - return 0; - } - - @Override - public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, - double damage, int slot) { - if (source.isUnblockable()) { - return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, 0.0D, 0); - } else { - double absorptionRatio = getBaseAbsorptionRatio() * getDamageAbsorptionRatio(); - int energyPerDamage = getEnergyPerDamage(); - double damageLimit = energyPerDamage <= 0 ? 0 - : (25 * ElectricItem.manager.getCharge(armor)) / energyPerDamage; - return new net.minecraftforge.common.ISpecialArmor.ArmorProperties(0, absorptionRatio, (int) damageLimit); - } - } - - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { - if (ElectricItem.manager.getCharge(armor) >= getEnergyPerDamage()) { - return (int) Math.round(20D * getBaseAbsorptionRatio() * getDamageAbsorptionRatio()); - } else { - return 0; - } - } - - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) { - ElectricItem.manager.discharge(stack, damage * getEnergyPerDamage(), 0x7fffffff, true, false, false); - } - - public double getDamageAbsorptionRatio() { - return 2D; - } - - private double getBaseAbsorptionRatio() { - return 0.15D; - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer par2EntityPlayer, List list, boolean par4) { - list.add(EMTTextHelper.PURPLE + EMTTextHelper.localize("tooltip.EMT.visDiscount") + ": " + visDiscount + "%"); - } - - public int getEnergyPerDamage() { - return energyPerDamage; - } - - @Override - public boolean canProvideEnergy(ItemStack itemStack) { - return false; - } - - @Override - public double getMaxCharge(ItemStack itemStack) { - return maxCharge; - } - - @Override - public int getTier(ItemStack itemStack) { - return 4; - } - - @Override - public double getTransferLimit(ItemStack itemStack) { - return transferLimit; - } - - @Override - public Item getChargedItem(ItemStack itemStack) { - return this; - } - - @Override - public Item getEmptyItem(ItemStack itemStack) { - return this; } @Override - public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect) { - return visDiscount; + protected void setBootsData() { + maxCharge = 10_000_000; + energyPerDamage = 20_000; + visDiscount = 5; + transferLimit = 12_000; + unlocalisedName = "ItemQuantumComet"; + iconResPath = "thaumicboots:quantumComet_16x"; + armorResPath = "thaumicboots:model/quantumbootsComet.png"; + rarity = EnumRarity.rare; + baseBonus = (float) EMTConfigHandler.quantumBootsSpeed + 0.220F; + minimumDistance = EMTConfigHandler.quantumBootsMaxDrop; + minimumHeight = 10F; + runicCharge = 0; + damageAbsorptionRatio = 2D; + baseAbsorptionRatio = 0.15D; + provideEnergy = false; + tier = 4; } }