diff options
Diffstat (limited to 'src/Java/gtPlusPlus/core/item/tool')
6 files changed, 934 insertions, 1061 deletions
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java index 7e00895b32..108ac4b83d 100644 --- a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java +++ b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java @@ -1,54 +1,64 @@ package gtPlusPlus.core.item.tool.misc; -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 java.util.List; + 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 { +public class SandstoneHammer extends BaseItemWithDamageValue{ - public SandstoneHammer(final String unlocalizedName) { + /* (non-Javadoc) + * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item.ItemStack, int) + */ + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + //Figure Out Damage + + + return super.getColorFromItemStack(stack, HEX_OxFFFFFF); + } + + public SandstoneHammer(String unlocalizedName) { super(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); this.setMaxStackSize(1); this.setMaxDamage(2500); } - @SuppressWarnings({ - "unchecked", "rawtypes" - }) + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - 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."); + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, 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(final ItemStack itemStack) { + public boolean doesContainerItemLeaveCraftingGrid(ItemStack itemStack) + { return false; } - /* - * (non-Javadoc) - * - * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item. - * ItemStack, int) - */ @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - // Figure Out Damage - - return super.getColorFromItemStack(stack, HEX_OxFFFFFF); + public boolean getShareTag() + { + return true; } @Override - public ItemStack getContainerItem(final ItemStack itemStack) { + public boolean hasContainerItem(ItemStack itemStack) + { + return true; + } + @Override + public ItemStack getContainerItem(ItemStack itemStack) + { itemStack.setItemDamage(itemStack.getItemDamage() + 8); return itemStack; @@ -56,23 +66,14 @@ public class SandstoneHammer extends BaseItemWithDamageValue { @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack) { + public EnumRarity getRarity(ItemStack par1ItemStack){ return EnumRarity.uncommon; } @Override - public boolean getShareTag() { - return true; - } - - @Override - public boolean hasContainerItem(final ItemStack itemStack) { - return true; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack) { + public boolean hasEffect(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 b9736136bb..99ee699dcf 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -1,8 +1,5 @@ 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; @@ -16,190 +13,167 @@ import net.minecraft.init.Blocks; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -public class MultiPickaxeBase extends StaballoyPickaxe { +public class MultiPickaxeBase extends StaballoyPickaxe{ - protected Boolean FACING_HORIZONTAL = true; + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } - protected String FACING = "north"; - protected EntityPlayer localPlayer; - protected String lookingDirection; - protected World localWorld; - protected ItemStack thisPickaxe = null; - protected final int colour; - protected final String materialName; - public boolean isValid = true; - public MultiPickaxeBase(final String unlocalizedName, final ToolMaterial material, final int materialDurability, - final int colour) { + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + protected ItemStack thisPickaxe = null; + protected final int colour; + protected final String materialName; + public boolean isValid = true; + + public MultiPickaxeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour) { super(Utils.sanitizeString(unlocalizedName), material); this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); this.setTextureName(CORE.MODID + ":" + "itemPickaxe"); - this.FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL=true; this.setMaxStackSize(1); this.setMaxDamage(materialDurability); this.colour = colour; - this.materialName = material.name(); + this.materialName = material.name(); this.setCreativeTab(AddToCreativeTab.tabTools); - try { - this.isValid = this.addRecipe(); - } - catch (final Throwable e) { - } - if (colour != 0 && this.isValid) { - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + try {isValid = addRecipe();} catch (Throwable e){} + if (colour != 0 && isValid){ + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); } } - private boolean addRecipe() { - final String plateDense = "plateDense" + this.materialName; - final String rodLong = "stickLong" + this.materialName; - final String toolHammer = "craftingToolHardHammer"; - final String toolWrench = "craftingToolWrench"; - final String toolFile = "craftingToolFile"; - final String toolScrewDriver = "craftingToolScrewdriver"; + /* + * + * + * + * Methods + * + * + * + */ + + private boolean addRecipe(){ + String plateDense = "plateDense"+materialName; + String rodLong = "stickLong"+materialName; + String toolHammer = "craftingToolHardHammer"; + String toolWrench = "craftingToolWrench"; + String toolFile = "craftingToolFile"; + String toolScrewDriver = "craftingToolScrewdriver"; - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)) { + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ return false; } - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)) { + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ return false; } - RecipeUtils.recipeBuilder(plateDense, plateDense, plateDense, toolFile, rodLong, toolHammer, toolWrench, - rodLong, toolScrewDriver, ItemUtils.getSimpleStack(this)); + RecipeUtils.recipeBuilder( + plateDense, plateDense, plateDense, + toolFile, rodLong, toolHammer, + toolWrench, rodLong, toolScrewDriver, + ItemUtils.getSimpleStack(this)); return true; } - /* - * - * - * - * Methods - * - * - * - */ - - @SuppressWarnings("static-method") - 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) { - try { - final Block removalist = world.getBlock(X, Y, Z); - // Utils.LOG_WARNING(removalist.toString()); - - bHardness = removalist.getBlockHardness(world, X, Y, Z) * 100; - Utils.LOG_WARNING("Hardness: " + bHardness); - - bDurabilityLoss = 100; - // Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); - - correctTool = this.canPickaxeBlock(removalist, world); - Utils.LOG_WARNING("" + correctTool); - - if (!correctTool) { - return 0; - } - - } - catch (final NullPointerException e) { - - } - } - return bDurabilityLoss; - } - - @Override - public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer) { - item.damageItem(damage, localPlayer); - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colour == 0) { - return MathUtils.generateSingularRandomHexValue(); - } - return this.colour; - - } - - /* - * (non-Javadoc) - * - * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item. - * ItemStack) - */ - @Override - public double getDurabilityForDisplay(final ItemStack stack) { - if (super.getDurabilityForDisplay(stack) > 0) { - return super.getDurabilityForDisplay(stack); - } - return 0; + public final String getMaterialName() { + return materialName; } @Override - public String getItemStackDisplayName(final ItemStack iStack) { + public String getItemStackDisplayName(ItemStack iStack) { String name; - if (this.getUnlocalizedName().toLowerCase().contains("wood")) { + if (getUnlocalizedName().toLowerCase().contains("wood")){ name = "Wooden"; } - else if (this.getUnlocalizedName().toLowerCase().contains("cobblestone")) { + else if (getUnlocalizedName().toLowerCase().contains("cobblestone")){ name = "Cobblestone"; } - else if (this.getUnlocalizedName().toLowerCase().contains("iron")) { + else if (getUnlocalizedName().toLowerCase().contains("iron")){ name = "Iron"; } - else if (this.getUnlocalizedName().toLowerCase().contains("gold")) { + else if (getUnlocalizedName().toLowerCase().contains("gold")){ name = "Gold"; } - else if (this.getUnlocalizedName().toLowerCase().contains("diamond")) { + else if (getUnlocalizedName().toLowerCase().contains("diamond")){ name = "Diamond"; } else { - name = this.materialName; + name = materialName; } - return name + " Multipickaxe"; - } - - public final String getMaterialName() { - return this.materialName; + return name+" Multipickaxe"; } @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack) { - return EnumRarity.uncommon; + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + } - @Override - public boolean hasEffect(final ItemStack par1ItemStack) { - return false; + @SuppressWarnings("static-method") + private float calculateDurabilityLoss(World world, int X, int Y, int Z){ + float bDurabilityLoss = 0; + Boolean correctTool = false; + float bHardness = 0; + if (!world.isRemote){ + try { + Block removalist = world.getBlock(X, Y, Z); + //Utils.LOG_WARNING(removalist.toString()); + + bHardness = removalist.getBlockHardness(world, X, Y, Z)*100; + Utils.LOG_WARNING("Hardness: "+bHardness); + + bDurabilityLoss = 100; + //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); + + correctTool = canPickaxeBlock(removalist, world); + Utils.LOG_WARNING(""+correctTool); + + if (!correctTool){ + return 0; + } + + } catch (NullPointerException e){ + + } + } + return bDurabilityLoss; } - // Should clear up blocks quicker if I chain it. + //Should clear up blocks quicker if I chain it. @Override - public void removeBlockAndDropAsItem(final World world, final int X, final int Y, final int Z, - final ItemStack heldItem) { - this.localWorld = world; + public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; try { - final Block block = world.getBlock(X, Y, Z); - final float dur = this.calculateDurabilityLoss(world, X, Y, Z); + Block block = world.getBlock(X, Y, Z); + float dur = calculateDurabilityLoss(world, X, Y, Z); Utils.LOG_WARNING(block.toString()); String removalTool = ""; removalTool = block.getHarvestTool(1); - if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block)) { - if (this.canPickaxeBlock(block, world)) { - if (block != Blocks.bedrock && block.getBlockHardness(world, X, Y, Z) != -1 - && block.getBlockHardness(world, X, Y, Z) <= 100 && block != Blocks.water - && block != Blocks.lava) { + if (removalTool.equals("pickaxe") || UtilsMining.getBlockType(block)){ + if (canPickaxeBlock(block, world)){ + if((block != Blocks.bedrock) && (block.getBlockHardness(world, X, Y, Z) != -1) && (block.getBlockHardness(world, X, Y, Z) <= 100) && (block != Blocks.water) && (block != Blocks.lava)){ - if (heldItem.getItemDamage() <= heldItem.getMaxDamage() - dur) { + if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-dur)){ block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); world.setBlockToAir(X, Y, Z); @@ -215,15 +189,29 @@ public class MultiPickaxeBase extends StaballoyPickaxe { Utils.LOG_WARNING("Incorrect Tool for mining this block."); } } - } - catch (final NullPointerException e) { + } catch (NullPointerException e){ } } + public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ + item.damageItem(damage, localPlayer); + } + + public void setItemDamage(ItemStack item, int damage){ + item.setItemDamage(damage-1); + } + + @Override - public void setItemDamage(final ItemStack item, final int damage) { - item.setItemDamage(damage - 1); + @SideOnly(Side.CLIENT) + public EnumRarity getRarity(ItemStack par1ItemStack){ + return EnumRarity.uncommon; + } + + @Override + public boolean hasEffect(ItemStack par1ItemStack){ + return false; } } diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java index 0c7eba48e8..0560893490 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java @@ -1,8 +1,5 @@ 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; @@ -13,108 +10,105 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -public class MultiSpadeBase extends StaballoySpade { +public class MultiSpadeBase extends StaballoySpade{ - protected Boolean FACING_HORIZONTAL = true; + /* (non-Javadoc) + * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item.ItemStack) + */ + @Override + public double getDurabilityForDisplay(ItemStack stack) { + if (super.getDurabilityForDisplay(stack) > 0){ + return super.getDurabilityForDisplay(stack);} + return 0; + } - protected String FACING = "north"; - protected EntityPlayer localPlayer; - protected String lookingDirection; - protected World localWorld; - protected ItemStack thisPickaxe = null; - protected final int colour; - protected final String materialName; - public boolean isValid = true; - public MultiSpadeBase(final String unlocalizedName, final ToolMaterial material, final int materialDurability, - final int colour) { + protected Boolean FACING_HORIZONTAL = true; + protected String FACING = "north"; + protected EntityPlayer localPlayer; + protected String lookingDirection; + protected World localWorld; + protected ItemStack thisPickaxe = null; + protected final int colour; + protected final String materialName; + public boolean isValid = true; + + public MultiSpadeBase(String unlocalizedName, ToolMaterial material, int materialDurability, int colour) { super(Utils.sanitizeString(unlocalizedName), material); this.setUnlocalizedName(Utils.sanitizeString(unlocalizedName)); this.setTextureName(CORE.MODID + ":" + "itemShovel"); - this.FACING_HORIZONTAL = true; + this.FACING_HORIZONTAL=true; this.setMaxStackSize(1); this.setMaxDamage(materialDurability); this.colour = colour; this.materialName = material.name(); this.setCreativeTab(AddToCreativeTab.tabTools); - try { - this.isValid = this.addRecipe(); - } - catch (final Throwable e) { - } - if (colour != 0 && this.isValid) { - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + try {isValid = addRecipe();} catch (Throwable e){} + if (colour != 0 && isValid){ + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); } } - - private boolean addRecipe() { - final String plateDense = "plateDense" + this.materialName; - final String rodLong = "stickLong" + this.materialName; - final String toolHammer = "craftingToolHardHammer"; - final String toolWrench = "craftingToolWrench"; - final String toolFile = "craftingToolFile"; - final String toolScrewDriver = "craftingToolScrewdriver"; - - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)) { + + private boolean addRecipe(){ + String plateDense = "plateDense"+materialName; + String rodLong = "stickLong"+materialName; + String toolHammer = "craftingToolHardHammer"; + String toolWrench = "craftingToolWrench"; + String toolFile = "craftingToolFile"; + String toolScrewDriver = "craftingToolScrewdriver"; + + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ return false; } - if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)) { + if (null == ItemUtils.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ return false; - } - - RecipeUtils.recipeBuilder(toolFile, plateDense, toolHammer, null, rodLong, null, toolWrench, rodLong, - toolScrewDriver, ItemUtils.getSimpleStack(this)); - + } + + RecipeUtils.recipeBuilder( + toolFile, plateDense, toolHammer, + null, rodLong, null, + toolWrench, rodLong, toolScrewDriver, + ItemUtils.getSimpleStack(this)); + return true; } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.colour == 0) { - return MathUtils.generateSingularRandomHexValue(); - } - return this.colour; - } - - /* - * (non-Javadoc) - * - * @see net.minecraft.item.Item#getDurabilityForDisplay(net.minecraft.item. - * ItemStack) - */ - @Override - public double getDurabilityForDisplay(final ItemStack stack) { - if (super.getDurabilityForDisplay(stack) > 0) { - return super.getDurabilityForDisplay(stack); - } - return 0; + + public final String getMaterialName() { + return materialName; } - + @Override - public String getItemStackDisplayName(final ItemStack iStack) { + public String getItemStackDisplayName(ItemStack iStack) { String name; - if (this.getUnlocalizedName().toLowerCase().contains("wood")) { + if (getUnlocalizedName().toLowerCase().contains("wood")){ name = "Wooden"; } else { - name = this.materialName; + name = materialName; } - return "Big " + name + " Spade"; + return "Big "+name+" Spade"; } - public final String getMaterialName() { - return this.materialName; - } + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + } @Override @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack) { + public EnumRarity getRarity(ItemStack par1ItemStack){ return EnumRarity.uncommon; } @Override - public boolean hasEffect(final ItemStack par1ItemStack) { + public boolean hasEffect(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 16852b5090..07c5800a1f 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java @@ -1,366 +1,279 @@ 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.block.Block; +import net.minecraft.block.BlockAir; +import net.minecraft.block.BlockCocoa; +import net.minecraft.block.BlockDirt; +import net.minecraft.block.BlockDoublePlant; +import net.minecraft.block.BlockFlower; +import net.minecraft.block.BlockGrass; +import net.minecraft.block.BlockHugeMushroom; +import net.minecraft.block.BlockLeavesBase; +import net.minecraft.block.BlockLog; +import net.minecraft.block.BlockMushroom; +import net.minecraft.block.BlockSand; +import net.minecraft.block.BlockSnow; +import net.minecraft.block.BlockSnowBlock; +import net.minecraft.block.BlockTallGrass; +import net.minecraft.block.BlockVine; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.*; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemAxe; +import net.minecraft.item.ItemStack; 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 class StaballoyAxe extends ItemAxe{ public String mat; - // EXPLODE TREE - byte[] tre = new byte[32000]; - - byte unchecked = 0; - byte needcheck = 1; - byte ignore = 2; - byte harvest = 3; - public StaballoyAxe(final String unlocalizedName, final ToolMaterial material) { + public StaballoyAxe(String unlocalizedName, ToolMaterial material) { super(material); this.setUnlocalizedName(unlocalizedName); this.setTextureName(CORE.MODID + ":" + unlocalizedName); } - - @SuppressWarnings({ - "unchecked", "rawtypes" - }) + + // 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; + return true; + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) @Override - 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."); + public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, 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); } - - private 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) { - 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); - */ - final EntityItem entityitem = new EntityItem(wld, x + 0.5, y + 0.5, z + 0.5, stk); - entityitem.delayBeforeCanPickup = 10; - wld.spawnEntityInWorld(entityitem); - } - else { - bit.harvestBlock(wld, plr, x, y, z, met); - } - wld.setBlockToAir(x, y, z); - } - - public 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()); + + public 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; + + //LoonTools.log("Found uncuttable "+bit.getClass().getSimpleName()); return false; } - - 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; - 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; - 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 (!this.setcheck(x + xb, y + yb, z + zb)) { - return 3; - } - } - } - } - } - else { - if (!this.canIgnore(bit)) { - return 2; - } + + private int check(World par1World, int x, int y, int z, int xo, int yo,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); + 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; + //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; + }else{ + if (!canIgnore(bit)) return 2; } } return f; } - - 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; - 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; - 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 (!this.setcheck(x + xb, y + yb, z + zb)) { - return 3; - } - } + + public int checkTree(World par1World,int xo,int yo,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 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; } - } - } - else if (bit instanceof BlockLeavesBase) { - } - else { - if (!this.canIgnore(bit)) { - return 2; - } + + 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; + if (r==2) return 2; + if (r==1) f=true; + } + } + return 1; + } + + private int check2(World par1World, int x, int y, int z, int xo, int yo,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); + if (bit instanceof BlockLog){ + f=1; + tre[o]=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; + }else if (bit instanceof BlockLeavesBase){ + }else{ + if (!canIgnore(bit)) return 2; } } return f; } - public int checkTree(final World par1World, final int xo, final int yo, final int zo) { + public int checkTree2(World par1World,int xo,int yo,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 x = 0; x < 20; x++) { - 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 (f=true;f==true;){ + f=false; + 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; } - } - } - - for (int y = 79; y >= 0; y--) { - for (int z = 19; z >= 0; z--) { - for (int x = 19; x >= 0; x--) { - 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; - } + + 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; + if (r==2) return 2; + if (r==1) f=true; } - } - } } return 1; } - - 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 x = 0; x < 20; x++) { - 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; + + 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++) + 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); + + 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); |
