diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/item/tool')
6 files changed, 524 insertions, 447 deletions
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java index 108ac4b83d..b78f81aa98 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java @@ -1,16 +1,15 @@ package gtPlusPlus.core.item.tool.misc; -import gtPlusPlus.core.item.base.BaseItemWithDamageValue; -import gtPlusPlus.core.lib.CORE; - import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.item.base.BaseItemWithDamageValue; +import gtPlusPlus.core.lib.CORE; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class SandstoneHammer extends BaseItemWithDamageValue{ @@ -18,14 +17,14 @@ public class SandstoneHammer extends BaseItemWithDamageValue{ * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item.ItemStack, int) */ @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { //Figure Out Damage return super.getColorFromItemStack(stack, HEX_OxFFFFFF); } - public SandstoneHammer(String unlocalizedName) { + public SandstoneHammer(final String unlocalizedName) { super(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); this.setMaxStackSize(1); @@ -34,13 +33,13 @@ public class SandstoneHammer extends BaseItemWithDamageValue{ @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { list.add(EnumChatFormatting.GRAY+"Allows you to craft sand from cobble, or sandstone from sand."); super.addInformation(stack, aPlayer, list, bool); - } + } @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) + public boolean doesContainerItemLeaveCraftingGrid(final ItemStack itemStack) { return false; } @@ -52,12 +51,12 @@ public class SandstoneHammer extends BaseItemWithDamageValue{ } @Override - public boolean hasContainerItem(ItemStack itemStack) + public boolean hasContainerItem(final ItemStack itemStack) { return true; } @Override - public ItemStack getContainerItem(ItemStack itemStack) + public ItemStack getContainerItem(final ItemStack itemStack) { itemStack.setItemDamage(itemStack.getItemDamage() + 8); @@ -66,12 +65,12 @@ public class SandstoneHammer extends BaseItemWithDamageValue{ @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(ItemStack par1ItemStack){ + public EnumRarity getRarity(final ItemStack par1ItemStack){ return EnumRarity.uncommon; } @Override - public boolean hasEffect(ItemStack par1ItemStack){ + public boolean hasEffect(final ItemStack par1ItemStack){ return false; } diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java index 55584faf2d..6499dc696b 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -1,5 +1,10 @@ package gtPlusPlus.core.item.tool.staballoy; +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -14,19 +19,13 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.*; import net.minecraft.world.World; -import java.util.List; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - public class MultiPickaxeBase extends StaballoyPickaxe{ /* (non-Javadoc) * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) */ @Override - public double getDurabilityForDisplay(ItemStack stack) { + public double getDurabilityForDisplay(final ItemStack stack) { if (super.getDurabilityForDisplay(stack) > 0){ return super.getDurabilityForDisplay(stack);} return 0; @@ -38,7 +37,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ public boolean isValid = true; private final Pair<?, ?> enchantment; - public MultiPickaxeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour, Object enchant) { + public MultiPickaxeBase(final String unlocalizedName, final ToolMaterial material, final int materialDurability, final int colour, final Object enchant) { super(Utils.sanitizeString(unlocalizedName), material); this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); //this.setTextureName(CORE.MODID + ":" + "itemPickaxe"); @@ -50,13 +49,13 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ this.materialName = material.name(); this.displayName = unlocalizedName; this.setCreativeTab(AddToCreativeTab.tabTools); - miningLevel = material.getHarvestLevel(); - - - + this.miningLevel = material.getHarvestLevel(); + + + if (enchant != null){ if (enchant instanceof Pair){ - this.enchantment = (Pair<?, ?>) enchant; + this.enchantment = (Pair<?, ?>) enchant; } else { this.enchantment = null; @@ -65,38 +64,38 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ else { this.enchantment = null; } - - try {isValid = addRecipe();} catch (Throwable e){} - if (colour != 0 && isValid && materialDurability > 10000){ + + try {this.isValid = this.addRecipe();} catch (final Throwable e){} + if ((colour != 0) && this.isValid && (materialDurability > 10000)){ if (GameRegistry.findItem(CORE.MODID, Utils.sanitizeString(unlocalizedName)) == null){ - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); - } + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + } } } /* - * - * - * - * Methods - * - * - * + * + * + * + * Methods + * + * + * */ private boolean addRecipe(){ - - String cleanName = Utils.sanitizeString(materialName); - - String plateDense = "plateDense"+cleanName; - String plateDouble = "plateDouble"+cleanName; - String rodLong = "stickLong"+cleanName; - String toolHammer = "craftingToolHardHammer"; - String toolWrench = "craftingToolWrench"; - String toolFile = "craftingToolFile"; - String toolScrewDriver = "craftingToolScrewdriver"; - + + final String cleanName = Utils.sanitizeString(this.materialName); + + final String plateDense = "plateDense"+cleanName; + final String plateDouble = "plateDouble"+cleanName; + final String rodLong = "stickLong"+cleanName; + final String toolHammer = "craftingToolHardHammer"; + final String toolWrench = "craftingToolWrench"; + final String toolFile = "craftingToolFile"; + final String toolScrewDriver = "craftingToolScrewdriver"; + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ Utils.LOG_WARNING("stickLong of "+cleanName+" does not exist."); return false; @@ -127,12 +126,12 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ } public final String getMaterialName() { - return materialName; + return this.materialName; } @Override - public String getItemStackDisplayName(ItemStack iStack) { - return displayName; + public String getItemStackDisplayName(final ItemStack iStack) { + return this.displayName; /*String name; if (getUnlocalizedName().toLowerCase().contains("wood")){ name = "Wooden"; @@ -155,22 +154,22 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ } @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (colour == 0){ + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0){ return MathUtils.generateSingularRandomHexValue(); } - return colour; + return this.colour; } @SuppressWarnings("static-method") - private float calculateDurabilityLoss(World world, int X, int Y, int Z){ + private float calculateDurabilityLoss(final World world, final int X, final int Y, final int Z){ float bDurabilityLoss = 0; Boolean correctTool = false; float bHardness = 0; - if (!world.isRemote){ + if (!world.isRemote){ try { - Block removalist = world.getBlock(X, Y, Z); + final Block removalist = world.getBlock(X, Y, Z); //Utils.LOG_WARNING(removalist.toString()); bHardness = removalist.getBlockHardness(world, X, Y, Z)*100; @@ -179,14 +178,14 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ bDurabilityLoss = 100; //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); - correctTool = canPickaxeBlock(removalist, world, new int[]{X,Y,Z}); + correctTool = this.canPickaxeBlock(removalist, world, new int[]{X,Y,Z}); Utils.LOG_WARNING(""+correctTool); if (!correctTool){ return 0; } - } catch (NullPointerException e){ + } catch (final NullPointerException e){ } } @@ -204,7 +203,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ String removalTool = ""; removalTool = block.getHarvestTool(1); - if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block, world, new int[]{X,Y,Z}, miningLevel)){ + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block, world, new int[]{X,Y,Z}, miningLevel)){ if (canPickaxeBlock(block, world, new int[]{X,Y,Z})){ if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ @@ -229,70 +228,72 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ } }*/ - public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ + @Override + public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer){ item.damageItem(damage, localPlayer); } - public void setItemDamage(ItemStack item, int damage){ + @Override + public void setItemDamage(final ItemStack item, final int damage){ item.setItemDamage(damage-1); } @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(ItemStack par1ItemStack){ + public EnumRarity getRarity(final ItemStack par1ItemStack){ return EnumRarity.uncommon; } @Override - public boolean hasEffect(ItemStack par1ItemStack){ + public boolean hasEffect(final ItemStack par1ItemStack){ return false; } @Override - public void onCreated(ItemStack mThisItem, World mWorld, EntityPlayer mPlayer) { + public void onCreated(final ItemStack mThisItem, final World mWorld, final EntityPlayer mPlayer) { Enchantment enchant = null; int enchantmentLevel = 0; - Pair<?, ?> Y = this.enchantment; + final Pair<?, ?> Y = this.enchantment; if (Y != null){ if (Y.getKey() != null){ - enchant = (Enchantment) ((Pair<?, ?>) this.enchantment).getKey(); + enchant = (Enchantment) ((Pair<?, ?>) this.enchantment).getKey(); } if (Y.getValue() != null){ - enchantmentLevel = (byte) ((Pair<?, ?>) this.enchantment).getValue(); + enchantmentLevel = (byte) ((Pair<?, ?>) this.enchantment).getValue(); } } - ItemStack itemToEnchant = mThisItem; - if (enchant != null && enchantmentLevel != 0 && enchantmentLevel >= 1){ + final ItemStack itemToEnchant = mThisItem; + if ((enchant != null) && (enchantmentLevel != 0) && (enchantmentLevel >= 1)){ itemToEnchant.addEnchantment(enchant, enchantmentLevel); } super.onCreated(itemToEnchant, mWorld, mPlayer); } @Override - public void getSubItems(Item mItem, CreativeTabs mCreativeTab, List mList) { + public void getSubItems(final Item mItem, final CreativeTabs mCreativeTab, final List mList) { Enchantment enchant = null; int enchantmentLevel = 0; - Pair<?, ?> Y = this.enchantment; + final Pair<?, ?> Y = this.enchantment; if (Y != null){ if (Y.getKey() != null){ - enchant = (Enchantment) ((Pair<?, ?>) this.enchantment).getKey(); + enchant = (Enchantment) ((Pair<?, ?>) this.enchantment).getKey(); } if (Y.getValue() != null){ - enchantmentLevel = (byte) ((Pair<?, ?>) this.enchantment).getValue(); + enchantmentLevel = (byte) ((Pair<?, ?>) this.enchantment).getValue(); } } - - Item thisItem = mItem; - ItemStack itemToEnchant = ItemUtils.getSimpleStack(thisItem); - if (enchant != null && enchantmentLevel != 0 && enchantmentLevel >= 1){ + + final Item thisItem = mItem; + final ItemStack itemToEnchant = ItemUtils.getSimpleStack(thisItem); + if ((enchant != null) && (enchantmentLevel != 0) && (enchantmentLevel >= 1)){ itemToEnchant.addEnchantment(enchant, enchantmentLevel); mList.add(itemToEnchant); } else { - mList.add(new ItemStack(thisItem, 1, 0)); + mList.add(new ItemStack(thisItem, 1, 0)); } - + } } diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java index 627108f509..175c212a6c 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java @@ -1,5 +1,8 @@ package gtPlusPlus.core.item.tool.staballoy; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.creative.AddToCreativeTab; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -8,9 +11,6 @@ import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.recipe.RecipeUtils; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class MultiSpadeBase extends StaballoySpade{ @@ -18,7 +18,7 @@ public class MultiSpadeBase extends StaballoySpade{ * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) */ @Override - public double getDurabilityForDisplay(ItemStack stack) { + public double getDurabilityForDisplay(final ItemStack stack) { if (super.getDurabilityForDisplay(stack) > 0){ return super.getDurabilityForDisplay(stack);} return 0; @@ -29,7 +29,7 @@ public class MultiSpadeBase extends StaballoySpade{ protected final String displayName; public boolean isValid = true; - public MultiSpadeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour) { + public MultiSpadeBase(final String unlocalizedName, final ToolMaterial material, final int materialDurability, final int colour) { super(Utils.sanitizeString(unlocalizedName), material); this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); //this.setTextureName(CORE.MODID + ":" + "itemShovel"); @@ -41,23 +41,23 @@ public class MultiSpadeBase extends StaballoySpade{ this.materialName = material.name(); this.displayName = unlocalizedName; this.setCreativeTab(AddToCreativeTab.tabTools); - try {isValid = addRecipe();} catch (Throwable e){} - if (colour != 0 && isValid){ + try {this.isValid = this.addRecipe();} catch (final Throwable e){} + if ((colour != 0) && this.isValid){ if (GameRegistry.findItem(CORE.MODID, Utils.sanitizeString(unlocalizedName)) == null){ - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); } } } private boolean addRecipe(){ - String cleanName = Utils.sanitizeString(materialName); - String plateDense = "plateDense"+cleanName; - String plateDouble = "plateDouble"+cleanName; - String rodLong = "stickLong"+cleanName; - String toolHammer = "craftingToolHardHammer"; - String toolWrench = "craftingToolWrench"; - String toolFile = "craftingToolFile"; - String toolScrewDriver = "craftingToolScrewdriver"; + final String cleanName = Utils.sanitizeString(this.materialName); + final String plateDense = "plateDense"+cleanName; + final String plateDouble = "plateDouble"+cleanName; + final String rodLong = "stickLong"+cleanName; + final String toolHammer = "craftingToolHardHammer"; + final String toolWrench = "craftingToolWrench"; + final String toolFile = "craftingToolFile"; + final String toolScrewDriver = "craftingToolScrewdriver"; if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ return false; @@ -73,7 +73,7 @@ public class MultiSpadeBase extends StaballoySpade{ return true; } return false; - } + } RecipeUtils.recipeBuilder( toolFile, plateDense, toolHammer, @@ -85,12 +85,12 @@ public class MultiSpadeBase extends StaballoySpade{ } public final String getMaterialName() { - return materialName; + return this.materialName; } @Override - public String getItemStackDisplayName(ItemStack iStack) { - return displayName; + public String getItemStackDisplayName(final ItemStack iStack) { + return this.displayName; /*String name; if (getUnlocalizedName().toLowerCase().contains("wood")){ name = "Wooden"; @@ -101,21 +101,21 @@ public class MultiSpadeBase extends StaballoySpade{ } @Override - public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { - if (colour == 0){ + public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { + if (this.colour == 0){ return MathUtils.generateSingularRandomHexValue(); } - return colour; - } + return this.colour; + } @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(ItemStack par1ItemStack){ + public EnumRarity getRarity(final ItemStack par1ItemStack){ return EnumRarity.uncommon; } @Override - public boolean hasEffect(ItemStack par1ItemStack){ + public boolean hasEffect(final ItemStack par1ItemStack){ return false; } diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java index 301671fc24..7ec396a8b1 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java @@ -1,9 +1,10 @@ package gtPlusPlus.core.item.tool.staballoy; -import gtPlusPlus.core.lib.CORE; - import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gtPlusPlus.core.lib.CORE; import net.minecraft.block.*; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; @@ -12,179 +13,249 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.*; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class StaballoyAxe extends ItemAxe{ public String mat; - public StaballoyAxe(String unlocalizedName, ToolMaterial material) { + public StaballoyAxe(final String unlocalizedName, final ToolMaterial material) { super(material); this.setUnlocalizedName(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); } - + // EXPLODE TREE byte[] tre= new byte[32000]; byte unchecked=0; byte needcheck=1; byte ignore =2; byte harvest =3; - - private boolean setcheck(int x, int y, int z) { - if(x<0 || x>19 || z<0 || z>19 || y<0 || y>79) return false; - int o=x+z*20+y*400; - if (tre[o]==unchecked) tre[o]=needcheck; + + private boolean setcheck(final int x, final int y, final int z) { + if((x<0) || (x>19) || (z<0) || (z>19) || (y<0) || (y>79)) { + return false; + } + final int o=x+(z*20)+(y*400); + if (this.tre[o]==this.unchecked) { + this.tre[o]=this.needcheck; + } return true; } - + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { list.add(EnumChatFormatting.GOLD+"Fells entire trees in a single swipe!.."); list.add(EnumChatFormatting.GRAY+"Ask Alkalus for new trees to be supported."); super.addInformation(stack, aPlayer, list, bool); } - - public static boolean canIgnore(Block bit){ - if (bit instanceof BlockAir)return true; - if (bit instanceof BlockGrass)return true; - if (bit instanceof BlockSand)return true; - if (bit instanceof BlockDirt)return true; - if (bit instanceof BlockCocoa)return true; - if (bit instanceof BlockVine)return true; - if (bit instanceof BlockMushroom)return true; - if (bit instanceof BlockSnow)return true; - if (bit instanceof BlockSnowBlock)return true; - if (bit instanceof BlockFlower)return true; - if (bit instanceof BlockTallGrass)return true; - if (bit instanceof BlockDoublePlant)return true; - + + public static boolean canIgnore(final Block bit){ + if (bit instanceof BlockAir) { + return true; + } + if (bit instanceof BlockGrass) { + return true; + } + if (bit instanceof BlockSand) { + return true; + } + if (bit instanceof BlockDirt) { + return true; + } + if (bit instanceof BlockCocoa) { + return true; + } + if (bit instanceof BlockVine) { + return true; + } + if (bit instanceof BlockMushroom) { + return true; + } + if (bit instanceof BlockSnow) { + return true; + } + if (bit instanceof BlockSnowBlock) { + return true; + } + if (bit instanceof BlockFlower) { + return true; + } + if (bit instanceof BlockTallGrass) { + return true; + } + if (bit instanceof BlockDoublePlant) { + return true; + } + //LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName()); return false; } - - private int check(World par1World, int x, int y, int z, int xo, int yo,int zo) { + + private int check(final World par1World, final int x, final int y, final int z, final int xo, final int yo,final int zo) { int f=0; - int o=x+z*20+y*400; - if (tre[o]==needcheck){ - tre[o]=ignore; - Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + final int o=x+(z*20)+(y*400); + if (this.tre[o]==this.needcheck){ + this.tre[o]=this.ignore; + final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase)||(bit instanceof BlockHugeMushroom) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ f=1; - tre[o]=harvest; + this.tre[o]=this.harvest; //if (bit instanceof BlockLog){ // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); //} - for(int xb=-1;xb<2;xb++) - for(int yb=-1;yb<2;yb++) - for(int zb=-1;zb<2;zb++) - if (!setcheck(x+xb,y+yb,z+zb))return 3; + for(int xb=-1;xb<2;xb++) { + for(int yb=-1;yb<2;yb++) { + for(int zb=-1;zb<2;zb++) { + if (!this.setcheck(x+xb,y+yb,z+zb)) { + return 3; + } + } + } + } }else{ - if (!canIgnore(bit)) return 2; + if (!canIgnore(bit)) { + return 2; + } } } return f; } - - public int checkTree(World par1World,int xo,int yo,int zo){ + + public int checkTree(final World par1World,final int xo,final int yo,final int zo){ boolean f; for (f=true;f==true;){ f=false; - for (int y=0;y<80;y++) - for(int z=0;z<20;z++) + for (int y=0;y<80;y++) { + for(int z=0;z<20;z++) { for(int x=0;x<20;x++){ - int r=check(par1World,x,y,z,xo,yo,zo); - if (r==3) return 3; - if (r==2) return 2; - if (r==1) f=true; + final int r=this.check(par1World,x,y,z,xo,yo,zo); + if (r==3) { + return 3; + } + if (r==2) { + return 2; + } + if (r==1) { + f=true; + } } - - for (int y=79;y>=0;y--) - for(int z=19;z>=0;z--) + } + } + + for (int y=79;y>=0;y--) { + for(int z=19;z>=0;z--) { for(int x=19;x>=0;x--){ - int r=check(par1World,x,y,z,xo,yo,zo); - if (r==2) return 3; + final int r=this.check(par1World,x,y,z,xo,yo,zo); + if (r==2) { + return 3; + } //if (r==2) return 2; - if (r==1) f=true; + if (r==1) { + f=true; + } } + } + } } return 1; } - - private int check2(World par1World, int x, int y, int z, int xo, int yo,int zo) { + + private int check2(final World par1World, final int x, final int y, final int z, final int xo, final int yo,final int zo) { int f=0; - int o=x+z*20+y*400; - if (tre[o]==needcheck){ - tre[o]=ignore; - Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + final int o=x+(z*20)+(y*400); + if (this.tre[o]==this.needcheck){ + this.tre[o]=this.ignore; + final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); if (bit instanceof BlockLog){ f=1; - tre[o]=harvest; + this.tre[o]=this.harvest; //if (bit instanceof BlockLog){ // LoonTools.log("^ Found log @ "+x+xo+" "+y+yo+" "+z+zo+" "); //} - for(int xb=-1;xb<2;xb++) - for(int yb=-1;yb<2;yb++) - for(int zb=-1;zb<2;zb++) - if (!setcheck(x+xb,y+yb,z+zb))return 3; + for(int xb=-1;xb<2;xb++) { + for(int yb=-1;yb<2;yb++) { + for(int zb=-1;zb<2;zb++) { + if (!this.setcheck(x+xb,y+yb,z+zb)) { + return 3; + } + } + } + } }else if (bit instanceof BlockLeavesBase){ }else{ - if (!canIgnore(bit)) return 2; + if (!canIgnore(bit)) { + return 2; + } } } return f; } - public int checkTree2(World par1World,int xo,int yo,int zo){ + public int checkTree2(final World par1World,final int xo,final int yo,final int zo){ boolean f; for (f=true;f==true;){ f=false; - for (int y=0;y<80;y++) - for(int z=0;z<20;z++) + for (int y=0;y<80;y++) { + for(int z=0;z<20;z++) { for(int x=0;x<20;x++){ - int r=check2(par1World,x,y,z,xo,yo,zo); - if (r==3) return 3; - if (r==2) return 2; - if (r==1) f=true; + final int r=this.check2(par1World,x,y,z,xo,yo,zo); + if (r==3) { + return 3; + } + if (r==2) { + return 2; + } + if (r==1) { + f=true; + } } - - for (int y=79;y>=0;y--) - for(int z=19;z>=0;z--) + } + } + + for (int y=79;y>=0;y--) { + for(int z=19;z>=0;z--) { for(int x=19;x>=0;x--){ - int r=check2(par1World,x,y,z,xo,yo,zo); - if (r==2) return 3; + final int r=this.check2(par1World,x,y,z,xo,yo,zo); + if (r==2) { + return 3; + } //if (r==2) return 2; - if (r==1) f=true; + if (r==1) { + f=true; + } } + } + } } return 1; } - - public void exploadTree(World par1World,int xo,int yo,int zo, EntityPlayer plr){ - for (int y=0;y<80;y++) - for(int z=0;z<20;z++) + + public void exploadTree(final World par1World,final int xo,final int yo,final int zo, final EntityPlayer plr){ + for (int y=0;y<80;y++) { + for(int z=0;z<20;z++) { for(int x=0;x<20;x++){ - int o=x+z*20+y*400; - if (tre[o]==harvest){ - Block bit = par1World.getBlock(x+xo, y+yo, z+zo); - int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); - + final int o=x+(z*20)+(y*400); + if (this.tre[o]==this.harvest){ + final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + final int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); + if ((bit instanceof BlockLog)||(bit instanceof BlockLeavesBase) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met); par1World.setBlockToAir(x+xo, y+yo, z+zo); } } } + } + } } - private static void breakMushroom(World wld, Block bit, EntityPlayer plr, boolean silk, int x, int y, int z, int met) { + private static void breakMushroom(final World wld, final Block bit, final EntityPlayer plr, final boolean silk, final int x, final int y, final int z, final int met) { if (silk){ - ItemStack stk = null; //TODO + final ItemStack stk = null; //TODO /*if (bit==Blocks.brown_mushroom_block) stk = new ItemStack(LoonToolItems.brown_mushroom_block,1,met); else if (bit==Blocks.red_mushroom_block) stk = new ItemStack(LoonToolItems.red_mushroom_block,1,met); else stk = new ItemStack(bit,1,met);*/ - EntityItem entityitem = new EntityItem(wld, x+0.5, y+0.5, z+0.5, stk); + final EntityItem entityitem = new EntityItem(wld, x+0.5, y+0.5, z+0.5, stk); entityitem.delayBeforeCanPickup = 10; wld.spawnEntityInWorld(entityitem); }else{ @@ -192,15 +263,15 @@ public class StaballoyAxe extends ItemAxe{ } wld.setBlockToAir(x, y, z); } - - public void exploadMushroom(World par1World,int xo,int yo,int zo, EntityPlayer plr, boolean silk){ - for (int y=0;y<80;y++) - for(int z=0;z<20;z++) + + public void exploadMushroom(final World par1World,final int xo,final int yo,final int zo, final EntityPlayer plr, final boolean silk){ + for (int y=0;y<80;y++) { + for(int z=0;z<20;z++) { for(int x=0;x<20;x++){ - int o=x+z*20+y*400; - if (tre[o]==harvest){ - Block bit = par1World.getBlock(x+xo, y+yo, z+zo); - int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); + final int o=x+(z*20)+(y*400); + if (this.tre[o]==this.harvest){ + final Block bit = par1World.getBlock(x+xo, y+yo, z+zo); + final int met = par1World.getBlockMetadata(x+xo, y+yo, z+zo); if (bit instanceof BlockHugeMushroom){ breakMushroom(par1World, bit, plr, silk, x+xo, y+yo, z+zo,met); }else{ @@ -209,54 +280,62 @@ public class StaballoyAxe extends ItemAxe{ } } } + } + } } - + @Override - public boolean onBlockDestroyed(ItemStack itm, World wld,Block blk, int x, int y,int z, EntityLivingBase plr) { + public boolean onBlockDestroyed(final ItemStack itm, final World wld,final Block blk, final int x, final int y,final int z, final EntityLivingBase plr) { if (!wld.isRemote){ - Block bit = wld.getBlock(x, y, z); - boolean silk=EnchantmentHelper.getSilkTouchModifier(plr); + final Block bit = wld.getBlock(x, y, z); + final boolean silk=EnchantmentHelper.getSilkTouchModifier(plr); if ((bit instanceof BlockHugeMushroom)){ - for (int n=0;n<32000;n++) tre[n]=unchecked; - int met = wld.getBlockMetadata(x, y, z); + for (int n=0;n<32000;n++) { + this.tre[n]=this.unchecked; + } + final int met = wld.getBlockMetadata(x, y, z); breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z,met); wld.setBlockToAir(x,y,z); - tre[2210]=needcheck; - if (checkTree(wld,x-10,y-4,z-10)==1){ - exploadMushroom(wld,x-10,y-4,z-10,(EntityPlayer) plr,silk); + this.tre[2210]=this.needcheck; + if (this.checkTree(wld,x-10,y-4,z-10)==1){ + this.exploadMushroom(wld,x-10,y-4,z-10,(EntityPlayer) plr,silk); } } - - if (bit instanceof BlockLog || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ + + if ((bit instanceof BlockLog) || (bit.getUnlocalizedName().toLowerCase().contains("log")) || (bit.getUnlocalizedName().toLowerCase().contains("wood"))){ //LoonTools.log("cutting tree @ "+x+" "+y+" "+z+" "); - for (int n=0;n<32000;n++) tre[n]=unchecked; - int met = wld.getBlockMetadata(x, y, z); + for (int n=0;n<32000;n++) { + this.tre[n]=this.unchecked; + } + final int met = wld.getBlockMetadata(x, y, z); bit.harvestBlock(wld, (EntityPlayer) plr, x, y, z,met); wld.setBlockToAir(x,y,z); - tre[2210]=needcheck; - if (checkTree(wld,x-10,y-4,z-10)==1){ - exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); + this.tre[2210]=this.needcheck; + if (this.checkTree(wld,x-10,y-4,z-10)==1){ + this.exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); }else{ - for (int n=0;n<32000;n++) tre[n]=unchecked; - tre[2210]=needcheck; - if (checkTree2(wld,x-10,y-4,z-10)==1){ - exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); + for (int n=0;n<32000;n++) { + this.tre[n]=this.unchecked; + } + this.tre[2210]=this.needcheck; + if (this.checkTree2(wld,x-10,y-4,z-10)==1){ + this.exploadTree(wld,x-10,y-4,z-10,(EntityPlayer) plr); } } } } return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr); } - + @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(ItemStack par1ItemStack){ + public EnumRarity getRarity(final ItemStack par1ItemStack){ return EnumRarity.rare; } @Override - public boolean hasEffect(ItemStack par1ItemStack){ + public boolean hasEffect(final ItemStack par1ItemStack){ return true; } }
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java index 81943536ae..64a53a4eb7 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -1,11 +1,12 @@ package gtPlusPlus.core.item.tool.staballoy; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.UtilsMining; - -import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -13,8 +14,6 @@ import net.minecraft.init.Blocks; import net.minecraft.item.*; import net.minecraft.util.*; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class StaballoyPickaxe extends ItemPickaxe{ @@ -22,7 +21,7 @@ public class StaballoyPickaxe extends ItemPickaxe{ * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) */ @Override - public double getDurabilityForDisplay(ItemStack stack) { + public double getDurabilityForDisplay(final ItemStack stack) { if (super.getDurabilityForDisplay(stack) > 0){ return super.getDurabilityForDisplay(stack);} return 0; @@ -37,46 +36,46 @@ public class StaballoyPickaxe extends ItemPickaxe{ protected int miningLevel; /* - * - * - * - * Methods - * - * - * + * + * + * + * Methods + * + * + * */ @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) { - localPlayer = aPlayer; - localWorld = world; - thisPickaxe = stack; + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer aPlayer) { + this.localPlayer = aPlayer; + this.localWorld = world; + this.thisPickaxe = stack; return super.onItemRightClick(stack, world, aPlayer); } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int X, int Y, int Z, EntityLivingBase entity) { + public boolean onBlockDestroyed(final ItemStack stack, final World world, final Block block, final int X, final int Y, final int Z, final EntityLivingBase entity) { //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); - localWorld = world; - thisPickaxe = stack; + this.localWorld = world; + this.thisPickaxe = stack; //checkFacing(world); - if (!world.isRemote){ - GetDestroyOrientation(block, lookingDirection, world, X, Y, Z, stack); + if (!world.isRemote){ + this.GetDestroyOrientation(block, this.lookingDirection, world, X, Y, Z, stack); } return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); } @SuppressWarnings("static-method") - private float calculateDurabilityLoss(World world, int X, int Y, int Z){ + private float calculateDurabilityLoss(final World world, final int X, final int Y, final int Z){ float bDurabilityLoss = 0; Boolean correctTool = false; float bHardness = 0; - if (!world.isRemote){ + if (!world.isRemote){ try { - Block removalist = world.getBlock(X, Y, Z); + final Block removalist = world.getBlock(X, Y, Z); //Utils.LOG_WARNING(removalist.toString()); bHardness = removalist.getBlockHardness(world, X, Y, Z); @@ -85,36 +84,36 @@ public class StaballoyPickaxe extends ItemPickaxe{ bDurabilityLoss = (bDurabilityLoss + bHardness); //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); - correctTool = canPickaxeBlock(removalist, world, new int[]{X,Y,Z}); + correctTool = this.canPickaxeBlock(removalist, world, new int[]{X,Y,Z}); Utils.LOG_WARNING(""+correctTool); if (!correctTool){ return 0; } - } catch (NullPointerException e){ + } catch (final NullPointerException e){ } } return 100; } - public Boolean canPickaxeBlock(Block currentBlock, World currentWorld, int[] xyz){ + public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld, final int[] xyz){ String correctTool = ""; - if (!currentWorld.isRemote){ + if (!currentWorld.isRemote){ try { correctTool = currentBlock.getHarvestTool(0); - if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, miningLevel) || correctTool.equals("pickaxe") || correctTool.equals("null")){ - //Utils.LOG_WARNING(correctTool); + if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("pickaxe") || correctTool.equals("null")){ + //Utils.LOG_WARNING(correctTool); return true;} - } catch (NullPointerException e){ + } catch (final NullPointerException e){ return false;} } return false; } - private void GetDestroyOrientation(Block block, String FACING, World world, int X, int Y, int Z, ItemStack heldItem){ - localWorld = world; + private void GetDestroyOrientation(final Block block, final String FACING, final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ + this.localWorld = world; float DURABILITY_LOSS = 0; if (!world.isRemote){ @@ -123,10 +122,10 @@ public class StaballoyPickaxe extends ItemPickaxe{ DURABILITY_LOSS = 0; for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { - float dur = calculateDurabilityLoss(world, X + i, Y, Z + j); - DURABILITY_LOSS = (DURABILITY_LOSS + dur); + final float dur = this.calculateDurabilityLoss(world, X + i, Y, Z + j); + DURABILITY_LOSS = (DURABILITY_LOSS + dur); Utils.LOG_WARNING("Added Loss: "+dur); - removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem); + this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem); } } } @@ -135,10 +134,10 @@ public class StaballoyPickaxe extends ItemPickaxe{ DURABILITY_LOSS = 0; for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { - float dur = calculateDurabilityLoss(world, X, Y + i, Z + j); + final float dur = this.calculateDurabilityLoss(world, X, Y + i, Z + j); DURABILITY_LOSS = (DURABILITY_LOSS + dur); Utils.LOG_WARNING("Added Loss: "+dur); - removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem); + this.removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem); } } } @@ -147,10 +146,10 @@ public class StaballoyPickaxe extends ItemPickaxe{ DURABILITY_LOSS = 0; for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { - float dur = calculateDurabilityLoss(world, X + j, Y + i, Z); + final float dur = this.calculateDurabilityLoss(world, X + j, Y + i, Z); DURABILITY_LOSS = (DURABILITY_LOSS + dur); Utils.LOG_WARNING("Added Loss: "+dur); - removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem); + this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem); } } } @@ -158,15 +157,15 @@ public class StaballoyPickaxe extends ItemPickaxe{ //int heldItemDurability = heldItem.getDamage(1); Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); //heldItem.setDamage(heldStack, DURABILITY_LOSS); - //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); Utils.LOG_WARNING("1x: "+(heldItem.getItemDamage())); - int itemdmg = heldItem.getItemDamage(); - int maxdmg = heldItem.getMaxDamage(); - int dodmg = (int)DURABILITY_LOSS; - int durNow = (int) maxdmg-itemdmg; - int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); - + final int itemdmg = heldItem.getItemDamage(); + final int maxdmg = heldItem.getMaxDamage(); + final int dodmg = (int)DURABILITY_LOSS; + final int durNow = maxdmg-itemdmg; + final int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); + Utils.LOG_WARNING( "Current Damage: " + itemdmg + " Max Damage: " + maxdmg @@ -174,10 +173,10 @@ public class StaballoyPickaxe extends ItemPickaxe{ + " Current Durability: " + durNow + " Remaining Durability: " + durLeft ); - - + + //Break Tool - if ((durNow-dodmg) <= (99) && itemdmg != 0){ + if (((durNow-dodmg) <= (99)) && (itemdmg != 0)){ //TODO break tool Utils.LOG_WARNING("Breaking Tool"); heldItem.stackSize = 0; @@ -186,10 +185,10 @@ public class StaballoyPickaxe extends ItemPickaxe{ else { //setItemDamage(heldItem, durLeft); Utils.LOG_WARNING(""+(durNow-durLeft)); - damageItem(heldItem, (durNow-durLeft)-1, localPlayer); + this.damageItem(heldItem, (durNow-durLeft)-1, this.localPlayer); } - - + + /*if (heldItem.getItemDamage() <= ((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)){ Utils.LOG_WARNING("2: "+DURABILITY_LOSS+" 3: "+((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); setItemDamage(heldItem, (int) (heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)); @@ -203,64 +202,64 @@ public class StaballoyPickaxe extends ItemPickaxe{ } } - - public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ + + public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer){ item.damageItem(damage, localPlayer); } - - public void setItemDamage(ItemStack item, int damage){ + + public void setItemDamage(final ItemStack item, final int damage){ item.setItemDamage(damage-1); } //Should clear up blocks quicker if I chain it. - public final void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ - localWorld = world; + public final void removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ + this.localWorld = world; try { - Block block = world.getBlock(X, Y, Z); - float dur = calculateDurabilityLoss(world, X, Y, Z); + final Block block = world.getBlock(X, Y, Z); + final float dur = this.calculateDurabilityLoss(world, X, Y, Z); Utils.LOG_WARNING(block.toString()); String removalTool = ""; removalTool = block.getHarvestTool(1); Utils.LOG_WARNING("Removing.1 "+removalTool); /*if ((removalTool.equalsIgnoreCase("pickaxe") || removalTool.equalsIgnoreCase("null") || removalTool == null)){ - Utils.LOG_WARNING("Removing.2"); + Utils.LOG_WARNING("Removing.2"); if (UtilsMining.getBlockType(block, world, new int[]{X,Y,Z}, miningLevel)) { - Utils.LOG_WARNING("Removing.3"); */ - if (canPickaxeBlock(block, world, new int[]{X,Y,Z})){ - Utils.LOG_WARNING("Removing.4"); - - if (block == Blocks.air){ - return; - } - - if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) >= 0) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + Utils.LOG_WARNING("Removing.3"); */ + if (this.canPickaxeBlock(block, world, new int[]{X,Y,Z})){ + Utils.LOG_WARNING("Removing.4"); + + if (block == Blocks.air){ + return; + } + + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) >= 0) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + Utils.LOG_WARNING("Removing.5"); + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ - Utils.LOG_WARNING("Removing.5"); - if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); world.setBlockToAir(X, Y, Z); - - } - + } + + } /*} - + }*/ } else { Utils.LOG_WARNING("Incorrect Tool for mining this block."); } - } catch (NullPointerException e){ + } catch (final NullPointerException e){ } } - public boolean checkFacing(World world){ - localWorld = world; - if (localPlayer != null){ - int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3; + public boolean checkFacing(final World world){ + this.localWorld = world; + if (this.localPlayer != null){ + final int direction = MathHelper.floor_double((this.localPlayer.rotationYaw * 4F) / 360F + 0.5D) & 3; //Utils.LOG_WARNING("Player - F: "+direction); //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); @@ -268,64 +267,64 @@ public class StaballoyPickaxe extends ItemPickaxe{ localPlayer.getLookVec().yCoord; }*/ - MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false); + final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, this.localPlayer, false); if (movingobjectposition != null){ - int sideHit = movingobjectposition.sideHit; + final int sideHit = movingobjectposition.sideHit; String playerStandingPosition = ""; - if (movingobjectposition != null) { + if (movingobjectposition != null) { //System.out.println("Side Hit: "+movingobjectposition.sideHit); } if (sideHit == 0){ playerStandingPosition = "above"; - FACING_HORIZONTAL = false; + this.FACING_HORIZONTAL = false; } else if (sideHit == 1){ playerStandingPosition = "below"; - FACING_HORIZONTAL = false; + this.FACING_HORIZONTAL = false; } else if (sideHit == 2){ playerStandingPosition = "facingSouth"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } else if (sideHit == 3){ playerStandingPosition = "facingNorth"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } else if (sideHit == 4){ playerStandingPosition = "facingEast"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } else if (sideHit == 5){ playerStandingPosition = "facingWest"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } - lookingDirection = playerStandingPosition; + this.lookingDirection = playerStandingPosition; - if (direction == 0){ - FACING = "south"; - } - else if (direction == 1){ - FACING = "west"; + if (direction == 0){ + this.FACING = "south"; } - else if (direction == 2){ - FACING = "north"; - } - else if (direction == 3){ - FACING = "east"; + else if (direction == 1){ + this.FACING = "west"; + } + else if (direction == 2){ + this.FACING = "north"; + } + else if (direction == 3){ + this.FACING = "east"; } } return true; } - return false; + return false; } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - thisPickaxe = stack; + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + this.thisPickaxe = stack; list.add(EnumChatFormatting.GRAY+"Mines a 3x3 at 100 durability per block mined."); list.add(EnumChatFormatting.GRAY+"Durability: "+(stack.getMaxDamage()-stack.getItemDamage())+"/"+stack.getMaxDamage()); //super.addInformation(stack, aPlayer, list, bool); @@ -333,25 +332,25 @@ public class StaballoyPickaxe extends ItemPickaxe{ @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(ItemStack par1ItemStack){ + public EnumRarity getRarity(final ItemStack par1ItemStack){ return EnumRarity.rare; } @Override - public boolean hasEffect(ItemStack par1ItemStack){ + public boolean hasEffect(final ItemStack par1ItemStack){ return true; } @Override - public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer aPlayer) { - thisPickaxe = itemstack; - localPlayer = aPlayer; - checkFacing(localPlayer.worldObj); + public boolean onBlockStartBreak(final ItemStack itemstack, final int X, final int Y, final int Z, final EntityPlayer aPlayer) { + this.thisPickaxe = itemstack; + this.localPlayer = aPlayer; + this.checkFacing(this.localPlayer.worldObj); return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); } - - public StaballoyPickaxe(String unlocalizedName, ToolMaterial material) { + + public StaballoyPickaxe(final String unlocalizedName, final ToolMaterial material) { super(material); this.setUnlocalizedName(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java index e5c3c92ced..4208b8c1af 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java @@ -1,11 +1,12 @@ package gtPlusPlus.core.item.tool.staballoy; +import java.util.List; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.player.UtilsMining; - -import java.util.List; - import net.minecraft.block.Block; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -13,8 +14,6 @@ import net.minecraft.init.Blocks; import net.minecraft.item.*; import net.minecraft.util.*; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class StaballoySpade extends ItemSpade{ @@ -22,7 +21,7 @@ public class StaballoySpade extends ItemSpade{ * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) */ @Override - public double getDurabilityForDisplay(ItemStack stack) { + public double getDurabilityForDisplay(final ItemStack stack) { if (super.getDurabilityForDisplay(stack) > 0){ return super.getDurabilityForDisplay(stack);} return 0; @@ -37,56 +36,56 @@ public class StaballoySpade extends ItemSpade{ private int miningLevel; /* - * - * - * - * Methods - * - * - * + * + * + * + * Methods + * + * + * */ @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) { - localPlayer = aPlayer; - localWorld = world; - thisPickaxe = stack; + public ItemStack onItemRightClick(final ItemStack stack, final World world, final EntityPlayer aPlayer) { + this.localPlayer = aPlayer; + this.localWorld = world; + this.thisPickaxe = stack; return super.onItemRightClick(stack, world, aPlayer); } @Override - public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int X, int Y, int Z, EntityLivingBase entity) { + public boolean onBlockDestroyed(final ItemStack stack, final World world, final Block block, final int X, final int Y, final int Z, final EntityLivingBase entity) { //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); - localWorld = world; - thisPickaxe = stack; + this.localWorld = world; + this.thisPickaxe = stack; //checkFacing(world); - if (!world.isRemote){ - GetDestroyOrientation(lookingDirection, world, X, Y, Z, stack); + if (!world.isRemote){ + this.GetDestroyOrientation(this.lookingDirection, world, X, Y, Z, stack); } return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity); } - public Boolean canPickaxeBlock(Block currentBlock, World currentWorld, int[] xyz){ + public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld, final int[] xyz){ String correctTool = ""; - if (!currentWorld.isRemote){ + if (!currentWorld.isRemote){ try { correctTool = currentBlock.getHarvestTool(0); //Utils.LOG_WARNING(correctTool); Utils.LOG_INFO("Tool for Block: "+correctTool+" | Current block: "+currentBlock.getLocalizedName()); - if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, miningLevel) || correctTool.equals("shovel")){ + if (UtilsMining.getBlockType(currentBlock, currentWorld, xyz, this.miningLevel) || correctTool.equals("shovel")){ return true;} - } catch (NullPointerException e){ + } catch (final NullPointerException e){ return false;} } return false; } - private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){ - localWorld = world; + private void GetDestroyOrientation(final String FACING, final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ + this.localWorld = world; float DURABILITY_LOSS = 0; if (!world.isRemote){ @@ -94,7 +93,7 @@ public class StaballoySpade extends ItemSpade{ DURABILITY_LOSS = 0; for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { - DURABILITY_LOSS = (DURABILITY_LOSS + removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem)); + DURABILITY_LOSS = (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem)); } } } @@ -103,7 +102,7 @@ public class StaballoySpade extends ItemSpade{ DURABILITY_LOSS = 0; for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { - DURABILITY_LOSS = (DURABILITY_LOSS + removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem)); + DURABILITY_LOSS = (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem)); } } } @@ -112,7 +111,7 @@ public class StaballoySpade extends ItemSpade{ DURABILITY_LOSS = 0; for(int i = -1; i < 2; i++) { for(int j = -1; j < 2; j++) { - DURABILITY_LOSS = (DURABILITY_LOSS + removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem)); + DURABILITY_LOSS = (DURABILITY_LOSS + this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem)); } } } @@ -120,14 +119,14 @@ public class StaballoySpade extends ItemSpade{ //int heldItemDurability = heldItem.getDamage(1); Utils.LOG_INFO("Total Loss: "+(int)DURABILITY_LOSS); //heldItem.setDamage(heldStack, DURABILITY_LOSS); - //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); + //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage()); //Utils.LOG_WARNING("Durability: "+heldStack.getDamage(heldStack)); Utils.LOG_INFO("1x: "+(heldItem.getItemDamage())); - int itemdmg = heldItem.getItemDamage(); - int maxdmg = heldItem.getMaxDamage(); - int dodmg = (int)DURABILITY_LOSS; - int durNow = (int) maxdmg-itemdmg; - int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); + final int itemdmg = heldItem.getItemDamage(); + final int maxdmg = heldItem.getMaxDamage(); + final int dodmg = (int)DURABILITY_LOSS; + final int durNow = maxdmg-itemdmg; + final int durLeft = (int) ((maxdmg-itemdmg)-DURABILITY_LOSS); Utils.LOG_INFO( "Current Damage: " + itemdmg @@ -139,7 +138,7 @@ public class StaballoySpade extends ItemSpade{ //Break Tool - if ((durNow-dodmg) <= (900) && itemdmg != 0){ + if (((durNow-dodmg) <= (900)) && (itemdmg != 0)){ //TODO break tool Utils.LOG_INFO("Breaking Tool"); heldItem.stackSize = 0; @@ -148,72 +147,72 @@ public class StaballoySpade extends ItemSpade{ else { //setItemDamage(heldItem, durLeft); Utils.LOG_INFO(""+(durNow-durLeft)); - damageItem(heldItem, (durNow-durLeft)-1, localPlayer); + this.damageItem(heldItem, (durNow-durLeft)-1, this.localPlayer); } DURABILITY_LOSS = 0; } } - public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ + public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer){ item.damageItem(damage, localPlayer); } - public void setItemDamage(ItemStack item, int damage){ + public void setItemDamage(final ItemStack item, final int damage){ item.setItemDamage(damage-1); } //Should clear up blocks quicker if I chain it. - public int removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ - localWorld = world; + public int removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z, final ItemStack heldItem){ + this.localWorld = world; Utils.LOG_INFO("Trying to drop/remove a block."); try { - Block block = world.getBlock(X, Y, Z); + final Block block = world.getBlock(X, Y, Z); Utils.LOG_WARNING(block.toString()); String removalTool = ""; removalTool = block.getHarvestTool(0); if (removalTool != null){ - if (removalTool.equals("shovel")){ - if (canPickaxeBlock(block, world, new int[]{X,Y,Z})){ - if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - - int itemdmg = heldItem.getItemDamage(); - int maxdmg = heldItem.getMaxDamage(); - int dodmg = (int)100; - int durNow = (int) maxdmg-itemdmg; - int durLeft = (int) ((maxdmg-itemdmg)-100); - - if ((durNow-dodmg) <= (900) && itemdmg != 0){ - //Do Nothing, Tool is useless. - return 0; + if (removalTool.equals("shovel")){ + if (this.canPickaxeBlock(block, world, new int[]{X,Y,Z})){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ + + final int itemdmg = heldItem.getItemDamage(); + final int maxdmg = heldItem.getMaxDamage(); + final int dodmg = 100; + final int durNow = maxdmg-itemdmg; + final int durLeft = (maxdmg-itemdmg)-100; + + if (((durNow-dodmg) <= (900)) && (itemdmg != 0)){ + //Do Nothing, Tool is useless. + return 0; + } + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + Utils.LOG_INFO("Adding 100 damage to item."); + return 100; } - block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); - world.setBlockToAir(X, Y, Z); - Utils.LOG_INFO("Adding 100 damage to item."); - return 100; + Utils.LOG_INFO("Incorrect Tool for mining this block. Wrong Block Water/lava/bedrock/blacklist"); + return 0; } - Utils.LOG_INFO("Incorrect Tool for mining this block. Wrong Block Water/lava/bedrock/blacklist"); + Utils.LOG_INFO("Incorrect Tool for mining this block. Cannot Shovel this block type."); return 0; } - Utils.LOG_INFO("Incorrect Tool for mining this block. Cannot Shovel this block type."); + Utils.LOG_INFO("Incorrect Tool for mining this block. Blocks mining tool is now Shovel."); return 0; } - Utils.LOG_INFO("Incorrect Tool for mining this block. Blocks mining tool is now Shovel."); + Utils.LOG_INFO("Either the block was air or it declares an invalid mining tool."); return 0; - } - Utils.LOG_INFO("Either the block was air or it declares an invalid mining tool."); - return 0; - } catch (NullPointerException e){ + } catch (final NullPointerException e){ Utils.LOG_INFO("Something Broke"); e.printStackTrace(); return 0; } } - public boolean checkFacing(World world){ - localWorld = world; - if (localPlayer != null){ - int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3; + public boolean checkFacing(final World world){ + this.localWorld = world; + if (this.localPlayer != null){ + final int direction = MathHelper.floor_double((this.localPlayer.rotationYaw * 4F) / 360F + 0.5D) & 3; //Utils.LOG_WARNING("Player - F: "+direction); //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord); @@ -221,88 +220,88 @@ public class StaballoySpade extends ItemSpade{ localPlayer.getLookVec().yCoord; }*/ - MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false); + final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, this.localPlayer, false); if (movingobjectposition != null){ - int sideHit = movingobjectposition.sideHit; + final int sideHit = movingobjectposition.sideHit; String playerStandingPosition = ""; - if (movingobjectposition != null) { + if (movingobjectposition != null) { //System.out.println("Side Hit: "+movingobjectposition.sideHit); } if (sideHit == 0){ playerStandingPosition = "above"; - FACING_HORIZONTAL = false; + this.FACING_HORIZONTAL = false; } else if (sideHit == 1){ playerStandingPosition = "below"; - FACING_HORIZONTAL = false; + this.FACING_HORIZONTAL = false; } else if (sideHit == 2){ playerStandingPosition = "facingSouth"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } else if (sideHit == 3){ playerStandingPosition = "facingNorth"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } else if (sideHit == 4){ playerStandingPosition = "facingEast"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } else if (sideHit == 5){ playerStandingPosition = "facingWest"; - FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL = true; } - lookingDirection = playerStandingPosition; + this.lookingDirection = playerStandingPosition; - if (direction == 0){ - FACING = "south"; - } - else if (direction == 1){ - FACING = "west"; + if (direction == 0){ + this.FACING = "south"; } - else if (direction == 2){ - FACING = "north"; - } - else if (direction == 3){ - FACING = "east"; + else if (direction == 1){ + this.FACING = "west"; + } + else if (direction == 2){ + this.FACING = "north"; + } + else if (direction == 3){ + this.FACING = "east"; } } return true; } - return false; + return false; } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) { - thisPickaxe = stack; + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + this.thisPickaxe = stack; list.add(EnumChatFormatting.GOLD+"Spades a 3x3 area in the direction you are facing."); super.addInformation(stack, aPlayer, list, bool); } @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(ItemStack par1ItemStack){ + public EnumRarity getRarity(final ItemStack par1ItemStack){ return EnumRarity.rare; } @Override - public boolean hasEffect(ItemStack par1ItemStack){ + public boolean hasEffect(final ItemStack par1ItemStack){ return true; } @Override - public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer aPlayer) { - thisPickaxe = itemstack; - localPlayer = aPlayer; - checkFacing(localPlayer.worldObj); + public boolean onBlockStartBreak(final ItemStack itemstack, final int X, final int Y, final int Z, final EntityPlayer aPlayer) { + this.thisPickaxe = itemstack; + this.localPlayer = aPlayer; + this.checkFacing(this.localPlayer.worldObj); return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer); } - public StaballoySpade(String unlocalizedName, ToolMaterial material) { + public StaballoySpade(final String unlocalizedName, final ToolMaterial material) { super(material); this.setUnlocalizedName(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); |