From 9353aa711b1d750ff945acdfed2d3b956291b615 Mon Sep 17 00:00:00 2001 From: Shawn Buckley Date: Wed, 21 Oct 2015 22:06:25 -0400 Subject: Reformat code --- .../common/items/behaviors/Behaviour_Arrow.java | 189 +++++++-------- .../items/behaviors/Behaviour_Arrow_Potion.java | 85 +++---- .../common/items/behaviors/Behaviour_Crowbar.java | 86 +++---- .../common/items/behaviors/Behaviour_DataOrb.java | 182 +++++++------- .../items/behaviors/Behaviour_DataStick.java | 53 ++-- .../common/items/behaviors/Behaviour_Hoe.java | 90 ++++--- .../common/items/behaviors/Behaviour_Lighter.java | 203 +++++++--------- .../common/items/behaviors/Behaviour_None.java | 116 ++++----- .../behaviors/Behaviour_Plunger_Essentia.java | 63 +++-- .../items/behaviors/Behaviour_Plunger_Fluid.java | 67 +++-- .../items/behaviors/Behaviour_Plunger_Item.java | 95 ++++---- .../items/behaviors/Behaviour_PrintedPages.java | 53 ++-- .../items/behaviors/Behaviour_Prospecting.java | 209 ++++++++-------- .../common/items/behaviors/Behaviour_Scanner.java | 51 ++-- .../common/items/behaviors/Behaviour_Scoop.java | 70 +++--- .../items/behaviors/Behaviour_Screwdriver.java | 72 +++--- .../common/items/behaviors/Behaviour_Sense.java | 66 +++-- .../items/behaviors/Behaviour_SensorKit.java | 62 +++-- .../items/behaviors/Behaviour_SoftHammer.java | 193 +++++++-------- .../items/behaviors/Behaviour_Sonictron.java | 215 ++++++++-------- .../items/behaviors/Behaviour_Spray_Color.java | 209 ++++++++-------- .../common/items/behaviors/Behaviour_Wrench.java | 270 +++++++++------------ .../items/behaviors/Behaviour_WrittenBook.java | 38 ++- 23 files changed, 1244 insertions(+), 1493 deletions(-) (limited to 'src/main/java/gregtech/common/items/behaviors') diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow.java index d0be735248..acb6986ec6 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow.java @@ -3,8 +3,6 @@ package gregtech.common.items.behaviors; import gregtech.api.enums.SubTag; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GT_Utility.GT_EnchantmentHelper; -import gregtech.api.util.GT_Utility.ItemNBT; import gregtech.common.entities.GT_Entity_Arrow; import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.IBlockSource; @@ -13,7 +11,6 @@ import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.PlayerCapabilities; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -21,109 +18,95 @@ import net.minecraft.util.EnumFacing; import net.minecraft.world.World; public class Behaviour_Arrow - extends Behaviour_None -{ - public static Behaviour_Arrow DEFAULT_WOODEN = new Behaviour_Arrow(GT_Entity_Arrow.class, 1.0F, 6.0F); - public static Behaviour_Arrow DEFAULT_PLASTIC = new Behaviour_Arrow(GT_Entity_Arrow.class, 1.5F, 6.0F); - private final int mLevel; - private final Enchantment mEnchantment; - private final float mSpeedMultiplier; - private final float mPrecision; - private final Class mArrow; - - public Behaviour_Arrow(Class aArrow, float aSpeed, float aPrecision) - { - this(aArrow, aSpeed, aPrecision, null, 0); - } - - public Behaviour_Arrow(Class aArrow, float aSpeed, float aPrecision, Enchantment aEnchantment, int aLevel) - { - this.mArrow = aArrow; - this.mSpeedMultiplier = aSpeed; - this.mPrecision = aPrecision; - this.mEnchantment = aEnchantment; - this.mLevel = aLevel; - } - - public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) - { - if ((aEntity instanceof EntityLivingBase)) - { - GT_Utility.GT_EnchantmentHelper.applyBullshitA((EntityLivingBase)aEntity, aPlayer, aStack); - GT_Utility.GT_EnchantmentHelper.applyBullshitB(aPlayer, aEntity, aStack); - if (!aPlayer.capabilities.isCreativeMode) { - aStack.stackSize -= 1; - } - if (aStack.stackSize <= 0) { - aPlayer.destroyCurrentEquippedItem(); - } - return false; + extends Behaviour_None { + public static Behaviour_Arrow DEFAULT_WOODEN = new Behaviour_Arrow(GT_Entity_Arrow.class, 1.0F, 6.0F); + public static Behaviour_Arrow DEFAULT_PLASTIC = new Behaviour_Arrow(GT_Entity_Arrow.class, 1.5F, 6.0F); + private final int mLevel; + private final Enchantment mEnchantment; + private final float mSpeedMultiplier; + private final float mPrecision; + private final Class mArrow; + + public Behaviour_Arrow(Class aArrow, float aSpeed, float aPrecision) { + this(aArrow, aSpeed, aPrecision, null, 0); } - return false; - } - - public boolean isItemStackUsable(GT_MetaBase_Item aItem, ItemStack aStack) - { - if ((this.mEnchantment != null) && (this.mLevel > 0)) - { - NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack); - if (!tNBT.getBoolean("GT.HasBeenUpdated")) - { - tNBT.setBoolean("GT.HasBeenUpdated", true); - GT_Utility.ItemNBT.setNBT(aStack, tNBT); - GT_Utility.ItemNBT.addEnchantment(aStack, this.mEnchantment, this.mLevel); - } + + public Behaviour_Arrow(Class aArrow, float aSpeed, float aPrecision, Enchantment aEnchantment, int aLevel) { + this.mArrow = aArrow; + this.mSpeedMultiplier = aSpeed; + this.mPrecision = aPrecision; + this.mEnchantment = aEnchantment; + this.mLevel = aLevel; } - return true; - } - - public boolean canDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) - { - return true; - } - - public ItemStack onDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) - { - World aWorld = aSource.getWorld(); - IPosition tPosition = BlockDispenser.func_149939_a(aSource); - EnumFacing tFacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); - GT_Entity_Arrow tEntityArrow = (GT_Entity_Arrow)getProjectile(aItem, SubTag.PROJECTILE_ARROW, aStack, aWorld, tPosition.getX(), tPosition.getY(), tPosition.getZ()); - if (tEntityArrow != null) - { - tEntityArrow.setThrowableHeading(tFacing.getFrontOffsetX(), tFacing.getFrontOffsetY() + 0.1F, tFacing.getFrontOffsetZ(), this.mSpeedMultiplier * 1.1F, this.mPrecision); - tEntityArrow.setArrowItem(aStack); - tEntityArrow.canBePickedUp = 1; - aWorld.spawnEntityInWorld(tEntityArrow); - if (aStack.stackSize < 100) { - aStack.stackSize -= 1; - } - return aStack; + + public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { + if ((aEntity instanceof EntityLivingBase)) { + GT_Utility.GT_EnchantmentHelper.applyBullshitA((EntityLivingBase) aEntity, aPlayer, aStack); + GT_Utility.GT_EnchantmentHelper.applyBullshitB(aPlayer, aEntity, aStack); + if (!aPlayer.capabilities.isCreativeMode) { + aStack.stackSize -= 1; + } + if (aStack.stackSize <= 0) { + aPlayer.destroyCurrentEquippedItem(); + } + return false; + } + return false; } - return super.onDispense(aItem, aSource, aStack); - } - - public boolean hasProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack) - { - return aProjectileType == SubTag.PROJECTILE_ARROW; - } - - public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) - { - if (!hasProjectile(aItem, aProjectileType, aStack)) { - return null; + + public boolean isItemStackUsable(GT_MetaBase_Item aItem, ItemStack aStack) { + if ((this.mEnchantment != null) && (this.mLevel > 0)) { + NBTTagCompound tNBT = GT_Utility.ItemNBT.getNBT(aStack); + if (!tNBT.getBoolean("GT.HasBeenUpdated")) { + tNBT.setBoolean("GT.HasBeenUpdated", true); + GT_Utility.ItemNBT.setNBT(aStack, tNBT); + GT_Utility.ItemNBT.addEnchantment(aStack, this.mEnchantment, this.mLevel); + } + } + return true; } - GT_Entity_Arrow rArrow = (GT_Entity_Arrow)GT_Utility.callConstructor(this.mArrow.getName(), -1, null, true, new Object[] { aWorld, Double.valueOf(aX), Double.valueOf(aY), Double.valueOf(aZ) }); - rArrow.setArrowItem(aStack); - return rArrow; - } - - public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed) - { - if (!hasProjectile(aItem, aProjectileType, aStack)) { - return null; + + public boolean canDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) { + return true; + } + + public ItemStack onDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) { + World aWorld = aSource.getWorld(); + IPosition tPosition = BlockDispenser.func_149939_a(aSource); + EnumFacing tFacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); + GT_Entity_Arrow tEntityArrow = (GT_Entity_Arrow) getProjectile(aItem, SubTag.PROJECTILE_ARROW, aStack, aWorld, tPosition.getX(), tPosition.getY(), tPosition.getZ()); + if (tEntityArrow != null) { + tEntityArrow.setThrowableHeading(tFacing.getFrontOffsetX(), tFacing.getFrontOffsetY() + 0.1F, tFacing.getFrontOffsetZ(), this.mSpeedMultiplier * 1.1F, this.mPrecision); + tEntityArrow.setArrowItem(aStack); + tEntityArrow.canBePickedUp = 1; + aWorld.spawnEntityInWorld(tEntityArrow); + if (aStack.stackSize < 100) { + aStack.stackSize -= 1; + } + return aStack; + } + return super.onDispense(aItem, aSource, aStack); + } + + public boolean hasProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack) { + return aProjectileType == SubTag.PROJECTILE_ARROW; + } + + public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) { + if (!hasProjectile(aItem, aProjectileType, aStack)) { + return null; + } + GT_Entity_Arrow rArrow = (GT_Entity_Arrow) GT_Utility.callConstructor(this.mArrow.getName(), -1, null, true, new Object[]{aWorld, Double.valueOf(aX), Double.valueOf(aY), Double.valueOf(aZ)}); + rArrow.setArrowItem(aStack); + return rArrow; + } + + public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed) { + if (!hasProjectile(aItem, aProjectileType, aStack)) { + return null; + } + GT_Entity_Arrow rArrow = (GT_Entity_Arrow) GT_Utility.callConstructor(this.mArrow.getName(), -1, null, true, new Object[]{aWorld, aEntity, Float.valueOf(this.mSpeedMultiplier * aSpeed)}); + rArrow.setArrowItem(aStack); + return rArrow; } - GT_Entity_Arrow rArrow = (GT_Entity_Arrow)GT_Utility.callConstructor(this.mArrow.getName(), -1, null, true, new Object[] { aWorld, aEntity, Float.valueOf(this.mSpeedMultiplier * aSpeed) }); - rArrow.setArrowItem(aStack); - return rArrow; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow_Potion.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow_Potion.java index 98c099e4ed..80a646bde4 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow_Potion.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Arrow_Potion.java @@ -3,7 +3,6 @@ package gregtech.common.items.behaviors; import gregtech.api.enums.SubTag; import gregtech.api.items.GT_MetaBase_Item; import gregtech.common.entities.GT_Entity_Arrow_Potion; -import java.util.Random; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -14,53 +13,47 @@ import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; public class Behaviour_Arrow_Potion - extends Behaviour_Arrow -{ - private final int[] mPotions; - - public Behaviour_Arrow_Potion(float aSpeed, float aPrecision, int... aPotions) - { - super(GT_Entity_Arrow_Potion.class, aSpeed, aPrecision); - this.mPotions = aPotions; - } - - public Behaviour_Arrow_Potion(float aSpeed, float aPrecision, Enchantment aEnchantment, int aLevel, int... aPotions) - { - super(GT_Entity_Arrow_Potion.class, aSpeed, aPrecision, aEnchantment, aLevel); - this.mPotions = aPotions; - } - - public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) - { - if ((aEntity instanceof EntityLivingBase)) { - for (int i = 3; i < this.mPotions.length; i += 4) { - if (aEntity.worldObj.rand.nextInt(100) < this.mPotions[i]) { - ((EntityLivingBase)aEntity).addPotionEffect(new PotionEffect(this.mPotions[(i - 3)], this.mPotions[(i - 2)], this.mPotions[(i - 1)], false)); + extends Behaviour_Arrow { + private final int[] mPotions; + + public Behaviour_Arrow_Potion(float aSpeed, float aPrecision, int... aPotions) { + super(GT_Entity_Arrow_Potion.class, aSpeed, aPrecision); + this.mPotions = aPotions; + } + + public Behaviour_Arrow_Potion(float aSpeed, float aPrecision, Enchantment aEnchantment, int aLevel, int... aPotions) { + super(GT_Entity_Arrow_Potion.class, aSpeed, aPrecision, aEnchantment, aLevel); + this.mPotions = aPotions; + } + + public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { + if ((aEntity instanceof EntityLivingBase)) { + for (int i = 3; i < this.mPotions.length; i += 4) { + if (aEntity.worldObj.rand.nextInt(100) < this.mPotions[i]) { + ((EntityLivingBase) aEntity).addPotionEffect(new PotionEffect(this.mPotions[(i - 3)], this.mPotions[(i - 2)], this.mPotions[(i - 1)], false)); + } + } } - } + return super.onLeftClickEntity(aItem, aStack, aPlayer, aEntity); } - return super.onLeftClickEntity(aItem, aStack, aPlayer, aEntity); - } - - public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) - { - if (!hasProjectile(aItem, aProjectileType, aStack)) { - return null; + + public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) { + if (!hasProjectile(aItem, aProjectileType, aStack)) { + return null; + } + GT_Entity_Arrow_Potion rArrow = new GT_Entity_Arrow_Potion(aWorld, aX, aY, aZ); + rArrow.setArrowItem(aStack); + rArrow.setPotions(this.mPotions); + return rArrow; } - GT_Entity_Arrow_Potion rArrow = new GT_Entity_Arrow_Potion(aWorld, aX, aY, aZ); - rArrow.setArrowItem(aStack); - rArrow.setPotions(this.mPotions); - return rArrow; - } - - public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed) - { - if (!hasProjectile(aItem, aProjectileType, aStack)) { - return null; + + public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed) { + if (!hasProjectile(aItem, aProjectileType, aStack)) { + return null; + } + GT_Entity_Arrow_Potion rArrow = new GT_Entity_Arrow_Potion(aWorld, aEntity, aSpeed); + rArrow.setArrowItem(aStack); + rArrow.setPotions(this.mPotions); + return rArrow; } - GT_Entity_Arrow_Potion rArrow = new GT_Entity_Arrow_Potion(aWorld, aEntity, aSpeed); - rArrow.setArrowItem(aStack); - rArrow.setPotions(this.mPotions); - return rArrow; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java index 827239a64e..8524f7ca17 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Crowbar.java @@ -4,7 +4,6 @@ import gregtech.api.GregTech_API; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; -import java.util.Map; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -12,52 +11,45 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class Behaviour_Crowbar - extends Behaviour_None -{ - private final int mVanillaCosts; - private final int mEUCosts; - - public Behaviour_Crowbar(int aVanillaCosts, int aEUCosts) - { - this.mVanillaCosts = aVanillaCosts; - this.mEUCosts = aEUCosts; - } - - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - if (aWorld.isRemote) { - return false; - } - if (GT_ModHandler.getModItem("Railcraft", "fluid.creosote.bucket", 1L) != null) { - return false; - } - Block aBlock = aWorld.getBlock(aX, aY, aZ); - if (aBlock == null) { - return false; - } - byte aMeta = (byte)aWorld.getBlockMetadata(aX, aY, aZ); - if (aBlock == Blocks.rail) - { - if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) - { - aWorld.isRemote = true; - aWorld.setBlock(aX, aY, aZ, aBlock, (aMeta + 1) % 10, 0); - aWorld.isRemote = false; - GT_Utility.sendSoundToPlayers(aWorld, (String)GregTech_API.sSoundList.get(Integer.valueOf(0)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; + extends Behaviour_None { + private final int mVanillaCosts; + private final int mEUCosts; + + public Behaviour_Crowbar(int aVanillaCosts, int aEUCosts) { + this.mVanillaCosts = aVanillaCosts; + this.mEUCosts = aEUCosts; } - if ((aBlock == Blocks.detector_rail) || (aBlock == Blocks.activator_rail) || (aBlock == Blocks.golden_rail)) - { - if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) - { - aWorld.isRemote = true; - aWorld.setBlock(aX, aY, aZ, aBlock, aMeta / 8 * 8 + (aMeta % 8 + 1) % 6, 0); - aWorld.isRemote = false; - GT_Utility.sendSoundToPlayers(aWorld, (String)GregTech_API.sSoundList.get(Integer.valueOf(0)), 1.0F, -1.0F, aX, aY, aZ); - } - return true; + + public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if (aWorld.isRemote) { + return false; + } + if (GT_ModHandler.getModItem("Railcraft", "fluid.creosote.bucket", 1L) != null) { + return false; + } + Block aBlock = aWorld.getBlock(aX, aY, aZ); + if (aBlock == null) { + return false; + } + byte aMeta = (byte) aWorld.getBlockMetadata(aX, aY, aZ); + if (aBlock == Blocks.rail) { + if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { + aWorld.isRemote = true; + aWorld.setBlock(aX, aY, aZ, aBlock, (aMeta + 1) % 10, 0); + aWorld.isRemote = false; + GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(0)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + if ((aBlock == Blocks.detector_rail) || (aBlock == Blocks.activator_rail) || (aBlock == Blocks.golden_rail)) { + if (GT_ModHandler.damageOrDechargeItem(aStack, this.mVanillaCosts, this.mEUCosts, aPlayer)) { + aWorld.isRemote = true; + aWorld.setBlock(aX, aY, aZ, aBlock, aMeta / 8 * 8 + (aMeta % 8 + 1) % 6, 0); + aWorld.isRemote = false; + GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(0)), 1.0F, -1.0F, aX, aY, aZ); + } + return true; + } + return false; } - return false; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java index b09b23cc2f..995a438ff4 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataOrb.java @@ -2,114 +2,102 @@ package gregtech.common.items.behaviors; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_Utility; -import java.util.List; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import java.util.List; + public class Behaviour_DataOrb - extends Behaviour_None -{ - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) - { - if (!getDataTitle(aStack).equals("")) - { - aList.add(getDataTitle(aStack)); - aList.add(getDataName(aStack)); + extends Behaviour_None { + public static void copyInventory(ItemStack[] aInventory, ItemStack[] aNewContent, int aIndexlength) { + for (int i = 0; i < aIndexlength; i++) { + if (aNewContent[i] == null) { + aInventory[i] = null; + } else { + aInventory[i] = GT_Utility.copy(new Object[]{aNewContent[i]}); + } + } } - return aList; - } - - public static void copyInventory(ItemStack[] aInventory, ItemStack[] aNewContent, int aIndexlength) - { - for (int i = 0; i < aIndexlength; i++) { - if (aNewContent[i] == null) { - aInventory[i] = null; - } else { - aInventory[i] = GT_Utility.copy(new Object[] { aNewContent[i] }); - } - } - } - - public static String getDataName(ItemStack aStack) - { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - return ""; - } - return tNBT.getString("mDataName"); - } - - public static String getDataTitle(ItemStack aStack) - { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - return ""; + + public static String getDataName(ItemStack aStack) { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + return ""; + } + return tNBT.getString("mDataName"); } - return tNBT.getString("mDataTitle"); - } - - public static NBTTagCompound setDataName(ItemStack aStack, String aDataName) - { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); + + public static String getDataTitle(ItemStack aStack) { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + return ""; + } + return tNBT.getString("mDataTitle"); } - tNBT.setString("mDataName", aDataName); - aStack.setTagCompound(tNBT); - return tNBT; - } - - public static NBTTagCompound setDataTitle(ItemStack aStack, String aDataTitle) - { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); + + public static NBTTagCompound setDataName(ItemStack aStack, String aDataName) { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + tNBT.setString("mDataName", aDataName); + aStack.setTagCompound(tNBT); + return tNBT; } - tNBT.setString("mDataTitle", aDataTitle); - aStack.setTagCompound(tNBT); - return tNBT; - } - - public static ItemStack[] getNBTInventory(ItemStack aStack) - { - ItemStack[] tInventory = new ItemStack[256]; - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - return tInventory; + + public static NBTTagCompound setDataTitle(ItemStack aStack, String aDataTitle) { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + tNBT.setString("mDataTitle", aDataTitle); + aStack.setTagCompound(tNBT); + return tNBT; } - NBTTagList tNBT_ItemList = tNBT.getTagList("Inventory", 10); - for (int i = 0; i < tNBT_ItemList.tagCount(); i++) - { - NBTTagCompound tag = tNBT_ItemList.getCompoundTagAt(i); - byte slot = tag.getByte("Slot"); - if ((slot >= 0) && (slot < tInventory.length)) { - tInventory[slot] = GT_Utility.loadItem(tag); - } + + public static ItemStack[] getNBTInventory(ItemStack aStack) { + ItemStack[] tInventory = new ItemStack[256]; + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + return tInventory; + } + NBTTagList tNBT_ItemList = tNBT.getTagList("Inventory", 10); + for (int i = 0; i < tNBT_ItemList.tagCount(); i++) { + NBTTagCompound tag = tNBT_ItemList.getCompoundTagAt(i); + byte slot = tag.getByte("Slot"); + if ((slot >= 0) && (slot < tInventory.length)) { + tInventory[slot] = GT_Utility.loadItem(tag); + } + } + return tInventory; } - return tInventory; - } - - public static NBTTagCompound setNBTInventory(ItemStack aStack, ItemStack[] aInventory) - { - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); + + public static NBTTagCompound setNBTInventory(ItemStack aStack, ItemStack[] aInventory) { + NBTTagCompound tNBT = aStack.getTagCompound(); + if (tNBT == null) { + tNBT = new NBTTagCompound(); + } + NBTTagList tNBT_ItemList = new NBTTagList(); + for (int i = 0; i < aInventory.length; i++) { + ItemStack stack = aInventory[i]; + if (stack != null) { + NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("Slot", (byte) i); + stack.writeToNBT(tag); + tNBT_ItemList.appendTag(tag); + } + } + tNBT.setTag("Inventory", tNBT_ItemList); + aStack.setTagCompound(tNBT); + return tNBT; } - NBTTagList tNBT_ItemList = new NBTTagList(); - for (int i = 0; i < aInventory.length; i++) - { - ItemStack stack = aInventory[i]; - if (stack != null) - { - NBTTagCompound tag = new NBTTagCompound(); - tag.setByte("Slot", (byte)i); - stack.writeToNBT(tag); - tNBT_ItemList.appendTag(tag); - } + + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + if (!getDataTitle(aStack).equals("")) { + aList.add(getDataTitle(aStack)); + aList.add(getDataName(aStack)); + } + return aList; } - tNBT.setTag("Inventory", tNBT_ItemList); - aStack.setTagCompound(tNBT); - return tNBT; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataStick.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataStick.java index 8d0809f279..105c39022a 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_DataStick.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_DataStick.java @@ -2,36 +2,33 @@ package gregtech.common.items.behaviors; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GT_Utility.ItemNBT; -import java.util.List; import net.minecraft.item.ItemStack; +import java.util.List; + public class Behaviour_DataStick - extends Behaviour_None -{ - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) - { - String tString = GT_Utility.ItemNBT.getBookTitle(aStack); - if (GT_Utility.isStringValid(tString)) { - aList.add(tString); - } - tString = GT_Utility.ItemNBT.getBookAuthor(aStack); - if (GT_Utility.isStringValid(tString)) { - aList.add("by " + tString); - } - short tMapID = GT_Utility.ItemNBT.getMapID(aStack); - if (tMapID >= 0) { - aList.add("Map ID: " + tMapID); - } - tString = GT_Utility.ItemNBT.getPunchCardData(aStack); - if (GT_Utility.isStringValid(tString)) - { - aList.add("Punch Card Data"); - int i = 0; - for (int j = tString.length(); i < j; i += 64) { - aList.add(tString.substring(i, Math.min(i + 64, j))); - } + extends Behaviour_None { + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + String tString = GT_Utility.ItemNBT.getBookTitle(aStack); + if (GT_Utility.isStringValid(tString)) { + aList.add(tString); + } + tString = GT_Utility.ItemNBT.getBookAuthor(aStack); + if (GT_Utility.isStringValid(tString)) { + aList.add("by " + tString); + } + short tMapID = GT_Utility.ItemNBT.getMapID(aStack); + if (tMapID >= 0) { + aList.add("Map ID: " + tMapID); + } + tString = GT_Utility.ItemNBT.getPunchCardData(aStack); + if (GT_Utility.isStringValid(tString)) { + aList.add("Punch Card Data"); + int i = 0; + for (int j = tString.length(); i < j; i += 64) { + aList.add(tString.substring(i, Math.min(i + 64, j))); + } + } + return aList; } - return aList; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java index fc995e3a13..2f9d31c3f5 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Hoe.java @@ -1,68 +1,60 @@ package gregtech.common.items.behaviors; -import cpw.mods.fml.common.eventhandler.*; +import cpw.mods.fml.common.eventhandler.Event; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; -import java.util.List; import net.minecraft.block.Block; -import net.minecraft.block.Block.SoundType; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.PlayerCapabilities; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.UseHoeEvent; +import java.util.List; + public class Behaviour_Hoe - extends Behaviour_None -{ - private final int mCosts; - - public Behaviour_Hoe(int aCosts) - { - this.mCosts = aCosts; - } - - public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - if (!aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { - return false; - } - UseHoeEvent event = new UseHoeEvent(aPlayer, aStack, aWorld, aX, aY, aZ); - if (MinecraftForge.EVENT_BUS.post(event)) { - return false; + extends Behaviour_None { + private final int mCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.hoe", "Can till Dirt"); + + public Behaviour_Hoe(int aCosts) { + this.mCosts = aCosts; } - if (event.getResult() == Event.Result.ALLOW) - { - if (!aPlayer.capabilities.isCreativeMode) { - ((GT_MetaGenerated_Tool)aItem).doDamage(aStack, this.mCosts); - } - return true; + + public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if (!aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack)) { + return false; + } + UseHoeEvent event = new UseHoeEvent(aPlayer, aStack, aWorld, aX, aY, aZ); + if (MinecraftForge.EVENT_BUS.post(event)) { + return false; + } + if (event.getResult() == Event.Result.ALLOW) { + if (!aPlayer.capabilities.isCreativeMode) { + ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); + } + return true; + } + Block aBlock = aWorld.getBlock(aX, aY, aZ); + if ((aSide != 0) && (GT_Utility.isBlockAir(aWorld, aX, aY + 1, aZ)) && ((aBlock == Blocks.grass) || (aBlock == Blocks.dirt))) { + aWorld.playSoundEffect(aX + 0.5F, aY + 0.5F, aZ + 0.5F, Blocks.farmland.stepSound.getStepResourcePath(), (Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.farmland.stepSound.getPitch() * 0.8F); + if (aWorld.isRemote) { + return true; + } + aWorld.setBlock(aX, aY, aZ, Blocks.farmland); + if (!aPlayer.capabilities.isCreativeMode) { + ((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts); + } + return true; + } + return false; } - Block aBlock = aWorld.getBlock(aX, aY, aZ); - if ((aSide != 0) && (GT_Utility.isBlockAir(aWorld, aX, aY + 1, aZ)) && ((aBlock == Blocks.grass) || (aBlock == Blocks.dirt))) - { - aWorld.playSoundEffect(aX + 0.5F, aY + 0.5F, aZ + 0.5F, Blocks.farmland.stepSound.getStepResourcePath(), (Blocks.farmland.stepSound.getVolume() + 1.0F) / 2.0F, Blocks.farmland.stepSound.getPitch() * 0.8F); - if (aWorld.isRemote) { - return true; - } - aWorld.setBlock(aX, aY, aZ, Blocks.farmland); - if (!aPlayer.capabilities.isCreativeMode) { - ((GT_MetaGenerated_Tool)aItem).doDamage(aStack, this.mCosts); - } - return true; + + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + aList.add(this.mTooltip); + return aList; } - return false; - } - - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.hoe", "Can till Dirt"); - - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) - { - aList.add(this.mTooltip); - return aList; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java index ef287d1204..a3d192ddd2 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Lighter.java @@ -5,133 +5,116 @@ import gregtech.api.GregTech_API; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; -import gregtech.api.util.GT_Utility.ItemNBT; -import java.util.List; -import java.util.Map; import net.minecraft.entity.Entity; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.PlayerCapabilities; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import java.util.List; + public class Behaviour_Lighter - extends Behaviour_None -{ - private final ItemStack mEmptyLighter; - private final ItemStack mUsedLighter; - private final ItemStack mFullLighter; - private final long mFuelAmount; - - public Behaviour_Lighter(ItemStack aEmptyLighter, ItemStack aUsedLighter, ItemStack aFullLighter, long aFuelAmount) - { - this.mFullLighter = aFullLighter; - this.mUsedLighter = aUsedLighter; - this.mEmptyLighter = aEmptyLighter; - this.mFuelAmount = aFuelAmount; - } - - public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) - { - if ((aPlayer.worldObj.isRemote) || (aStack.stackSize != 1)) { - return false; + extends Behaviour_None { + private final ItemStack mEmptyLighter; + private final ItemStack mUsedLighter; + private final ItemStack mFullLighter; + private final long mFuelAmount; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.tooltip", "Can light things on Fire"); + private final String mTooltipUses = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.uses", "Remaining Uses:"); + private final String mTooltipUnstackable = GT_LanguageManager.addStringLocalization("gt.behaviour.unstackable", "Not usable when stacked!"); + + public Behaviour_Lighter(ItemStack aEmptyLighter, ItemStack aUsedLighter, ItemStack aFullLighter, long aFuelAmount) { + this.mFullLighter = aFullLighter; + this.mUsedLighter = aUsedLighter; + this.mEmptyLighter = aEmptyLighter; + this.mFuelAmount = aFuelAmount; } - boolean rOutput = false; - if ((aEntity instanceof EntityCreeper)) - { - prepare(aStack); - long tFuelAmount = GT_Utility.ItemNBT.getLighterFuel(aStack); - if (GT_Utility.areStacksEqual(aStack, this.mUsedLighter, true)) - { - GT_Utility.sendSoundToPlayers(aPlayer.worldObj, (String)GregTech_API.sSoundList.get(Integer.valueOf(6)), 1.0F, 1.0F, MathHelper.floor_double(aEntity.posX), MathHelper.floor_double(aEntity.posY), MathHelper.floor_double(aEntity.posZ)); - ((EntityCreeper)aEntity).func_146079_cb(); - if (!aPlayer.capabilities.isCreativeMode) { - tFuelAmount -= 1L; + + public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { + if ((aPlayer.worldObj.isRemote) || (aStack.stackSize != 1)) { + return false; } - rOutput = true; - } - GT_Utility.ItemNBT.setLighterFuel(aStack, tFuelAmount); - if (tFuelAmount <= 0L) { - useUp(aStack); - } - } - return rOutput; - } - - public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - return false; - } - - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - if ((aWorld.isRemote) || (aStack.stackSize != 1)) { - return false; - } - boolean rOutput = false; - - ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); - aX += tDirection.offsetX;aY += tDirection.offsetY;aZ += tDirection.offsetZ; - if ((!GT_Utility.isBlockAir(aWorld, aX, aY, aZ)) || (!aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack))) { - return false; + boolean rOutput = false; + if ((aEntity instanceof EntityCreeper)) { + prepare(aStack); + long tFuelAmount = GT_Utility.ItemNBT.getLighterFuel(aStack); + if (GT_Utility.areStacksEqual(aStack, this.mUsedLighter, true)) { + GT_Utility.sendSoundToPlayers(aPlayer.worldObj, (String) GregTech_API.sSoundList.get(Integer.valueOf(6)), 1.0F, 1.0F, MathHelper.floor_double(aEntity.posX), MathHelper.floor_double(aEntity.posY), MathHelper.floor_double(aEntity.posZ)); + ((EntityCreeper) aEntity).func_146079_cb(); + if (!aPlayer.capabilities.isCreativeMode) { + tFuelAmount -= 1L; + } + rOutput = true; + } + GT_Utility.ItemNBT.setLighterFuel(aStack, tFuelAmount); + if (tFuelAmount <= 0L) { + useUp(aStack); + } + } + return rOutput; } - prepare(aStack); - long tFuelAmount = GT_Utility.ItemNBT.getLighterFuel(aStack); - if (GT_Utility.areStacksEqual(aStack, this.mUsedLighter, true)) - { - GT_Utility.sendSoundToPlayers(aWorld, (String)GregTech_API.sSoundList.get(Integer.valueOf(6)), 1.0F, 1.0F, aX, aY, aZ); - aWorld.setBlock(aX, aY, aZ, Blocks.fire); - if (!aPlayer.capabilities.isCreativeMode) { - tFuelAmount -= 1L; - } - rOutput = true; + + public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + return false; } - GT_Utility.ItemNBT.setLighterFuel(aStack, tFuelAmount); - if (tFuelAmount <= 0L) { - useUp(aStack); + + public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if ((aWorld.isRemote) || (aStack.stackSize != 1)) { + return false; + } + boolean rOutput = false; + + ForgeDirection tDirection = ForgeDirection.getOrientation(aSide); + aX += tDirection.offsetX; + aY += tDirection.offsetY; + aZ += tDirection.offsetZ; + if ((!GT_Utility.isBlockAir(aWorld, aX, aY, aZ)) || (!aPlayer.canPlayerEdit(aX, aY, aZ, aSide, aStack))) { + return false; + } + prepare(aStack); + long tFuelAmount = GT_Utility.ItemNBT.getLighterFuel(aStack); + if (GT_Utility.areStacksEqual(aStack, this.mUsedLighter, true)) { + GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(6)), 1.0F, 1.0F, aX, aY, aZ); + aWorld.setBlock(aX, aY, aZ, Blocks.fire); + if (!aPlayer.capabilities.isCreativeMode) { + tFuelAmount -= 1L; + } + rOutput = true; + } + GT_Utility.ItemNBT.setLighterFuel(aStack, tFuelAmount); + if (tFuelAmount <= 0L) { + useUp(aStack); + } + return rOutput; } - return rOutput; - } - - private void prepare(ItemStack aStack) - { - if (GT_Utility.areStacksEqual(aStack, this.mFullLighter, true)) - { - aStack.func_150996_a(this.mUsedLighter.getItem()); - Items.feather.setDamage(aStack, Items.feather.getDamage(this.mUsedLighter)); - GT_Utility.ItemNBT.setLighterFuel(aStack, this.mFuelAmount); + + private void prepare(ItemStack aStack) { + if (GT_Utility.areStacksEqual(aStack, this.mFullLighter, true)) { + aStack.func_150996_a(this.mUsedLighter.getItem()); + Items.feather.setDamage(aStack, Items.feather.getDamage(this.mUsedLighter)); + GT_Utility.ItemNBT.setLighterFuel(aStack, this.mFuelAmount); + } } - } - - private void useUp(ItemStack aStack) - { - if (this.mEmptyLighter == null) - { - aStack.stackSize -= 1; + + private void useUp(ItemStack aStack) { + if (this.mEmptyLighter == null) { + aStack.stackSize -= 1; + } else { + aStack.func_150996_a(this.mEmptyLighter.getItem()); + Items.feather.setDamage(aStack, Items.feather.getDamage(this.mEmptyLighter)); + } } - else - { - aStack.func_150996_a(this.mEmptyLighter.getItem()); - Items.feather.setDamage(aStack, Items.feather.getDamage(this.mEmptyLighter)); + + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + aList.add(this.mTooltip); + NBTTagCompound tNBT = aStack.getTagCompound(); + long tFuelAmount = tNBT == null ? 0L : GT_Utility.areStacksEqual(aStack, this.mFullLighter, true) ? this.mFuelAmount : tNBT.getLong("GT.LighterFuel"); + aList.add(this.mTooltipUses + " " + tFuelAmount); + aList.add(this.mTooltipUnstackable); + return aList; } - } - - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.tooltip", "Can light things on Fire"); - private final String mTooltipUses = GT_LanguageManager.addStringLocalization("gt.behaviour.lighter.uses", "Remaining Uses:"); - private final String mTooltipUnstackable = GT_LanguageManager.addStringLocalization("gt.behaviour.unstackable", "Not usable when stacked!"); - - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) - { - aList.add(this.mTooltip); - NBTTagCompound tNBT = aStack.getTagCompound(); - long tFuelAmount = tNBT == null ? 0L : GT_Utility.areStacksEqual(aStack, this.mFullLighter, true) ? this.mFuelAmount : tNBT.getLong("GT.LighterFuel"); - aList.add(this.mTooltipUses + " " + tFuelAmount); - aList.add(this.mTooltipUnstackable); - return aList; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java index 43f84393fc..66ed8bb672 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_None.java @@ -3,7 +3,6 @@ package gregtech.common.items.behaviors; import gregtech.api.enums.SubTag; import gregtech.api.interfaces.IItemBehaviour; import gregtech.api.items.GT_MetaBase_Item; -import java.util.List; import net.minecraft.block.BlockDispenser; import net.minecraft.dispenser.BehaviorDefaultDispenseItem; import net.minecraft.dispenser.IBlockSource; @@ -16,67 +15,58 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; +import java.util.List; + public class Behaviour_None - implements IItemBehaviour -{ - public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) - { - return false; - } - - public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - return false; - } - - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - return false; - } - - public ItemStack onItemRightClick(GT_MetaBase_Item aItem, ItemStack aStack, World aWorld, EntityPlayer aPlayer) - { - return aStack; - } - - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) - { - return aList; - } - - public void onUpdate(GT_MetaBase_Item aItem, ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) {} - - public boolean isItemStackUsable(GT_MetaBase_Item aItem, ItemStack aStack) - { - return true; - } - - public boolean canDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) - { - return false; - } - - public ItemStack onDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) - { - EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); - IPosition iposition = BlockDispenser.func_149939_a(aSource); - ItemStack itemstack1 = aStack.splitStack(1); - BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); - return aStack; - } - - public boolean hasProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack) - { - return false; - } - - public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) - { - return null; - } - - public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed) - { - return null; - } + implements IItemBehaviour { + public boolean onLeftClickEntity(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, Entity aEntity) { + return false; + } + + public boolean onItemUse(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + return false; + } + + public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + return false; + } + + public ItemStack onItemRightClick(GT_MetaBase_Item aItem, ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + return aStack; + } + + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + return aList; + } + + public void onUpdate(GT_MetaBase_Item aItem, ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) { + } + + public boolean isItemStackUsable(GT_MetaBase_Item aItem, ItemStack aStack) { + return true; + } + + public boolean canDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) { + return false; + } + + public ItemStack onDispense(GT_MetaBase_Item aItem, IBlockSource aSource, ItemStack aStack) { + EnumFacing enumfacing = BlockDispenser.func_149937_b(aSource.getBlockMetadata()); + IPosition iposition = BlockDispenser.func_149939_a(aSource); + ItemStack itemstack1 = aStack.splitStack(1); + BehaviorDefaultDispenseItem.doDispense(aSource.getWorld(), itemstack1, 6, enumfacing, iposition); + return aStack; + } + + public boolean hasProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack) { + return false; + } + + public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, double aX, double aY, double aZ) { + return null; + } + + public EntityArrow getProjectile(GT_MetaBase_Item aItem, SubTag aProjectileType, ItemStack aStack, World aWorld, EntityLivingBase aEntity, float aSpeed) { + return null; + } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java index 9d3d8e4d4b..f546a82379 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Essentia.java @@ -5,49 +5,42 @@ import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; -import java.util.List; -import java.util.Map; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.PlayerCapabilities; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import thaumcraft.api.aspects.IEssentiaTransport; +import java.util.List; + public class Behaviour_Plunger_Essentia - extends Behaviour_None -{ - private final int mCosts; - - public Behaviour_Plunger_Essentia(int aCosts) - { - this.mCosts = aCosts; - } - - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - if (aWorld.isRemote) { - return false; + extends Behaviour_None { + private final int mCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.plunger.essentia", "Clears Essentia from Containers and Tubes"); + + public Behaviour_Plunger_Essentia(int aCosts) { + this.mCosts = aCosts; } - TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((aTileEntity instanceof IEssentiaTransport)) && ( - (aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool)aItem).doDamage(aStack, this.mCosts)))) - { - GT_Utility.sendSoundToPlayers(aWorld, (String)GregTech_API.sSoundList.get(Integer.valueOf(101)), 1.0F, -1.0F, aX, aY, aZ); - for (ForgeDirection tDirection : ForgeDirection.VALID_DIRECTIONS) { - ((IEssentiaTransport)aTileEntity).takeEssentia(((IEssentiaTransport)aTileEntity).getEssentiaType(tDirection), ((IEssentiaTransport)aTileEntity).getEssentiaAmount(tDirection), tDirection); - } - return true; + + public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if (aWorld.isRemote) { + return false; + } + TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (((aTileEntity instanceof IEssentiaTransport)) && ( + (aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts)))) { + GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(101)), 1.0F, -1.0F, aX, aY, aZ); + for (ForgeDirection tDirection : ForgeDirection.VALID_DIRECTIONS) { + ((IEssentiaTransport) aTileEntity).takeEssentia(((IEssentiaTransport) aTileEntity).getEssentiaType(tDirection), ((IEssentiaTransport) aTileEntity).getEssentiaAmount(tDirection), tDirection); + } + return true; + } + return false; + } + + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + aList.add(this.mTooltip); + return aList; } - return false; - } - - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.plunger.essentia", "Clears Essentia from Containers and Tubes"); - - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) - { - aList.add(this.mTooltip); - return aList; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java index fa3155e933..4b087986b5 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Fluid.java @@ -5,52 +5,45 @@ import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; -import java.util.List; -import java.util.Map; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.PlayerCapabilities; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; +import java.util.List; + public class Behaviour_Plunger_Fluid - extends Behaviour_None -{ - private final int mCosts; - - public Behaviour_Plunger_Fluid(int aCosts) - { - this.mCosts = aCosts; - } - - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - if (aWorld.isRemote) { - return false; + extends Behaviour_None { + private final int mCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.plunger.fluid", "Clears 1000 Liters of Fluid from Tanks"); + + public Behaviour_Plunger_Fluid(int aCosts) { + this.mCosts = aCosts; } - TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((aTileEntity instanceof IFluidHandler)) { - for (ForgeDirection tDirection : ForgeDirection.VALID_DIRECTIONS) { - if (((IFluidHandler)aTileEntity).drain(tDirection, 1000, false) != null) { - if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool)aItem).doDamage(aStack, this.mCosts))) - { - ((IFluidHandler)aTileEntity).drain(tDirection, 1000, true); - GT_Utility.sendSoundToPlayers(aWorld, (String)GregTech_API.sSoundList.get(Integer.valueOf(101)), 1.0F, -1.0F, aX, aY, aZ); - return true; - } + + public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if (aWorld.isRemote) { + return false; + } + TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((aTileEntity instanceof IFluidHandler)) { + for (ForgeDirection tDirection : ForgeDirection.VALID_DIRECTIONS) { + if (((IFluidHandler) aTileEntity).drain(tDirection, 1000, false) != null) { + if ((aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool) aItem).doDamage(aStack, this.mCosts))) { + ((IFluidHandler) aTileEntity).drain(tDirection, 1000, true); + GT_Utility.sendSoundToPlayers(aWorld, (String) GregTech_API.sSoundList.get(Integer.valueOf(101)), 1.0F, -1.0F, aX, aY, aZ); + return true; + } + } + } } - } + return false; + } + + public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) { + aList.add(this.mTooltip); + return aList; } - return false; - } - - private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.plunger.fluid", "Clears 1000 Liters of Fluid from Tanks"); - - public List getAdditionalToolTips(GT_MetaBase_Item aItem, List aList, ItemStack aStack) - { - aList.add(this.mTooltip); - return aList; - } } diff --git a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java index f601e795f2..049a5bfbcb 100644 --- a/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java +++ b/src/main/java/gregtech/common/items/behaviors/Behaviour_Plunger_Item.java @@ -3,75 +3,66 @@ package gregtech.common.items.behaviors; import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.metatileentity.IMetaTileEntityItemPipe; -import gregtech.api.interfaces.metatileentity.IMetaTileEntityItemPipe.Util; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.PlayerCapabilities; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; +import java.util.HashMap; +import java.util.List; + public class Behaviour_Plunger_Item - extends Behaviour_None -{ - private final int mCosts; - - public Behaviour_Plunger_Item(int aCosts) - { - this.mCosts = aCosts; - } - - public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) - { - if (aWorld.isRemote) { - return false; + extends Behaviour_None { + private final int mCosts; + private final String mTooltip = GT_LanguageManager.addStringLocalization("gt.behaviour.plunger.item", "Clears Items from Pipes"); + + public Behaviour_Plunger_Item(int aCosts) { + this.mCosts = aCosts; } - TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((aTileEntity instanceof IGregTechTileEntity)) - { - IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity)aTileEntity).getMetaTileEntity(); - if ((tMetaTileEntity instanceof IMetaTileEntityItemPipe)) { - for (Object tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes((IMetaTileEntityItemPipe)tMetaTileEntity, new HashMap(), 0L, false, true)).keySet()) - { - int i = 0; - for (int j = ((IMetaTileEntityItemPipe)tTileEntity).getSizeInventory(); i < j; i++) { - if (((IMetaTileEntityItemPipe)tTileEntity).isValidSlot(i)) { - if ((((IMetaTileEntityItemPipe)tTileEntity).getStackInSlot(i) != null) && ( - (aPlayer.capabilities.isCreativeMode) || (((GT_MetaGenerated_Tool)aItem).doDamage(aStack, this.mCosts)))) - { - ItemStack tStack = ((IMetaTileEntityItemPipe)tTileEntity).decrStackSize(i, 64); - if (tStack != null) + public boolean onItemUseFirst(GT_MetaBase_Item aItem, ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { + if (aWorld.isRemote) { + return false; + } + TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((aTileEntity instanceof IGregTechTileEntity)) { + IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aTileEntity).getMetaTileEntity(); + if ((tMetaTileEntity instanceof IMetaTileEntityItemPipe)) { + for (Object tTileEntity : GT_Utility.sortMapByValuesAcending(IMetaTileEntityItemPipe.Util.scanPipes((IMetaTileEntityItemPipe) tMetaTileEntity, new HashMap(), 0L, false, true)).keySet()) + { - EntityItem tEntity = new EntityItem(aWorld, ((IGregTechTileEntity)aTileEntity).getOffsetX((byte)aSide, 1) + 0.5D, ((IGregTechTileEntity)aTileEntity).getOffsetY((byte)aSide, 1) + 0.5D, ((IGregTechTileEntity)aTileEntity).getOffsetZ((byte)aSide, 1) + 0.5D, tStack); - tEntity.motionX = 0.0D;tEntity.motionY = 0.0D;tEntity.motionZ = 0.0D; - aWorld.spawnEntityInWorld(tEntity); - GT_Utility.sendSoundToPlayers(aWorld, (String)GregTech_API.sSoundList.get(Integer.valueOf(101)), 1.0F, -1.0F, aX, aY, aZ); + int i = 0; + for (int j = ((IMetaTileEntityItemPipe) tTileEntity).getSizeInventory(); i < j; i++) { + if (((IMetaTileEntityItemPipe) tTileE