aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/item/tool
diff options
context:
space:
mode:
authordraknyte1 <draknyte1@hotmail.com>2016-11-04 15:23:26 +1000
committerdraknyte1 <draknyte1@hotmail.com>2016-11-04 15:23:26 +1000
commit0669f5eb9d5029a8b94ec552171b0837605f7747 (patch)
tree6b40e64c04d51b7a33cf2f0b35f7232cf37c4247 /src/Java/gtPlusPlus/core/item/tool
parent3654052fb63a571c5eaca7f20714b87c17f7e966 (diff)
downloadGT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.tar.gz
GT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.tar.bz2
GT5-Unofficial-0669f5eb9d5029a8b94ec552171b0837605f7747.zip
$ Cleaned up the entire project.
> Much neat, very nices.
Diffstat (limited to 'src/Java/gtPlusPlus/core/item/tool')
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java64
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java258
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java128
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java491
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java509
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java466
6 files changed, 1036 insertions, 880 deletions
diff --git a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java
index 9155c155db..7e00895b32 100644
--- a/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java
+++ b/src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java
@@ -11,53 +11,44 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
-public class SandstoneHammer extends BaseItemWithDamageValue{
+public class SandstoneHammer extends BaseItemWithDamageValue {
- /* (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) {
+ public SandstoneHammer(final 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(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
- list.add(EnumChatFormatting.GRAY+"Allows you to craft sand from cobble, or sandstone from sand.");
+ 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;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.minecraft.item.Item#getColorFromItemStack(net.minecraft.item.
+ * ItemStack, int)
+ */
@Override
- public boolean getShareTag()
- {
- return true;
- }
+ public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) {
+ // Figure Out Damage
- @Override
- public boolean hasContainerItem(ItemStack itemStack)
- {
- return true;
+ return super.getColorFromItemStack(stack, HEX_OxFFFFFF);
}
+
@Override
- public ItemStack getContainerItem(ItemStack itemStack)
- {
+ public ItemStack getContainerItem(final ItemStack itemStack) {
itemStack.setItemDamage(itemStack.getItemDamage() + 8);
return itemStack;
@@ -65,14 +56,23 @@ 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){
- return false;
+ public boolean getShareTag() {
+ return true;
+ }
+
+ @Override
+ public boolean hasContainerItem(final ItemStack itemStack) {
+ return true;
}
+ @Override
+ 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 19f6d42de8..b9736136bb 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java
@@ -17,163 +17,189 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-public class MultiPickaxeBase extends StaballoyPickaxe{
-
- /* (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 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) {
+public class MultiPickaxeBase extends StaballoyPickaxe {
+
+ 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(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 + ":" + "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 {isValid = addRecipe();} catch (Throwable e){}
- if (colour != 0 && isValid){
- GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName));
+ try {
+ this.isValid = this.addRecipe();
+ }
+ catch (final Throwable e) {
+ }
+ if (colour != 0 && this.isValid) {
+ GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName));
}
}
- /*
- *
- *
- *
- * Methods
- *
- *
- *
- */
-
- private boolean addRecipe(){
- String plateDense = "plateDense"+materialName;
- String rodLong = "stickLong"+materialName;
- String toolHammer = "craftingToolHardHammer";
- String toolWrench = "craftingToolWrench";
- String toolFile = "craftingToolFile";
- String toolScrewDriver = "craftingToolScrewdriver";
+ 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)){
+ 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;
}
- public final String getMaterialName() {
- return materialName;
+ /*
+ *
+ *
+ *
+ * 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 String getItemStackDisplayName(ItemStack iStack) {
+ public double getDurabilityForDisplay(final ItemStack stack) {
+ if (super.getDurabilityForDisplay(stack) > 0) {
+ return super.getDurabilityForDisplay(stack);
+ }
+ return 0;
+ }
+
+ @Override
+ public String getItemStackDisplayName(final ItemStack iStack) {
String name;
- if (getUnlocalizedName().toLowerCase().contains("wood")){
+ if (this.getUnlocalizedName().toLowerCase().contains("wood")) {
name = "Wooden";
}
- else if (getUnlocalizedName().toLowerCase().contains("cobblestone")){
+ else if (this.getUnlocalizedName().toLowerCase().contains("cobblestone")) {
name = "Cobblestone";
}
- else if (getUnlocalizedName().toLowerCase().contains("iron")){
+ else if (this.getUnlocalizedName().toLowerCase().contains("iron")) {
name = "Iron";
}
- else if (getUnlocalizedName().toLowerCase().contains("gold")){
+ else if (this.getUnlocalizedName().toLowerCase().contains("gold")) {
name = "Gold";
}
- else if (getUnlocalizedName().toLowerCase().contains("diamond")){
+ else if (this.getUnlocalizedName().toLowerCase().contains("diamond")) {
name = "Diamond";
}
else {
- name = materialName;
+ name = this.materialName;
}
- return name+" Multipickaxe";
+ return name + " Multipickaxe";
}
- @Override
- public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) {
- if (colour == 0){
- return MathUtils.generateSingularRandomHexValue();
- }
- return colour;
-
+ public final String getMaterialName() {
+ return this.materialName;
}
- @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){
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(final ItemStack par1ItemStack) {
+ return EnumRarity.uncommon;
+ }
- }
- }
- return bDurabilityLoss;
+ @Override
+ public boolean hasEffect(final ItemStack par1ItemStack) {
+ return false;
}
- //Should clear up blocks quicker if I chain it.
+ // Should clear up blocks quicker if I chain it.
@Override
- public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){
- localWorld = world;
+ public 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);
- 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 (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 (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);
@@ -189,29 +215,15 @@ public class MultiPickaxeBase extends StaballoyPickaxe{
Utils.LOG_WARNING("Incorrect Tool for mining this block.");
}
}
- } 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);
- }
+ catch (final NullPointerException e) {
-
- @Override
- @SideOnly(Side.CLIENT)
- public EnumRarity getRarity(ItemStack par1ItemStack){
- return EnumRarity.uncommon;
+ }
}
@Override
- public boolean hasEffect(ItemStack par1ItemStack){
- return false;
+ public void setItemDamage(final ItemStack item, final int damage) {
+ item.setItemDamage(damage - 1);
}
}
diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java
index 116820f06e..0c7eba48e8 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java
@@ -14,101 +14,107 @@ import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
-public class MultiSpadeBase extends StaballoySpade{
+public class MultiSpadeBase extends StaballoySpade {
- /* (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 Boolean FACING_HORIZONTAL = true;
- 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) {
+ 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) {
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 {isValid = addRecipe();} catch (Throwable e){}
- if (colour != 0 && isValid){
- GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName));
+ try {
+ this.isValid = this.addRecipe();
+ }
+ catch (final Throwable e) {
+ }
+ if (colour != 0 && this.isValid) {
+ GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName));
}
}
-
- 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)){
+
+ 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)) {
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;
}
-
- public final String getMaterialName() {
- return materialName;
+
+ @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;
}
-
+
@Override
- public String getItemStackDisplayName(ItemStack iStack) {
+ public String getItemStackDisplayName(final ItemStack iStack) {
String name;
- if (getUnlocalizedName().toLowerCase().contains("wood")){
+ if (this.getUnlocalizedName().toLowerCase().contains("wood")) {
name = "Wooden";
}
else {
- name = materialName;
+ name = this.materialName;
}
- return "Big "+name+" Spade";
+ return "Big " + name + " Spade";
}
- @Override
- public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) {
- if (colour == 0){
- return MathUtils.generateSingularRandomHexValue();
- }
- return colour;
- }
+ public final String getMaterialName() {
+ return this.materialName;
+ }
@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 f38c0db834..16852b5090 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java
@@ -14,248 +14,353 @@ import net.minecraft.item.*;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.world.World;
-public class StaballoyAxe extends ItemAxe{
+public class StaballoyAxe extends ItemAxe {
public String mat;
- public StaballoyAxe(String unlocalizedName, ToolMaterial material) {
+ // 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) {
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;
- return true;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
+
+ @SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
@Override
- 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.");
+ 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 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());
+
+ 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());
return false;
}
-
- 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;
+
+ 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;
+ }
}
}
return f;
}
-
- 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;
- }
-
- 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;
+
+ 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;
+ }
+ }
}
- }
- 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;
+ }
+ }
+ else if (bit instanceof BlockLeavesBase) {
+ }
+ else {
+ if (!this.canIgnore(bit)) {
+ return 2;
+ }
}
}
return f;
}
- public int checkTree2(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 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 (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 (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;
+ }
+ }
+
+ 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;
+ }
}
+ }
+ }
}
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++)
- 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);
+
+ 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;
}
}
}
- }
+ }
- private void breakMushroom(World wld, Block bit, EntityPlayer plr, boolean silk, int x, int y, int z, int met) {
- if (silk){
- 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);
- entityitem.delayBeforeCanPickup = 10;
- wld.spawnEntityInWorld(entityitem);
- }else{
- bit.harvestBlock(wld, plr, x, y, z, met);
- }
- 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++)
- 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 BlockHugeMushroom){
- breakMushroom(par1World, bit, plr, silk, x+xo, y+yo, z+zo,met);
- }else{
- bit.harvestBlock(par1World, plr, x+xo, y+yo, z+zo,met);
- par1World.setBlockToAir(x+xo, y+yo, z+zo);
+ 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.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;
}
-
- @Override
- public boolean onBlockDestroyed(ItemStack itm, World wld,Block blk, int x, int y,int z, EntityLivingBase plr) {
- if (!wld.isRemote){
- Block bit = wld.getBlock(x, y, z);
- 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);
- 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);
+ 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++) {
+ 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) {
+ this.breakMushroom(par1World, bit, plr, silk, x + xo, y + yo, z + zo, met);
+ }
+ else {
+ bit.harvestBlock(par1World, plr, x + xo, y + yo, z + zo, met);
+ par1World.setBlockToAir(x + xo, y + yo, z + zo);
+ }
+ }
}
}
-
- 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);
- 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);
- }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);
+ }
+ }
+
+ 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++) {
+ 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);
+ }
}
}
}
}
- 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;
+ }
+
+ @Override
+ 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) {
+ 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++) {
+ this.tre[n] = this.unchecked;
+ }
+ final int met = wld.getBlockMetadata(x, y, z);
+ this.breakMushroom(wld, bit, (EntityPlayer) plr, silk, x, y, z, met);
+ wld.setBlockToAir(x, y, z);
+ 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")) {
+ // LoonTools.log("cutting tree @ "+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);
+ 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++) {
+ 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);
+ }
+
+ 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;
}
} \ 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 b87cd2b1b9..5096b94054 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
@@ -15,331 +15,348 @@ import net.minecraft.item.*;
import net.minecraft.util.*;
import net.minecraft.world.World;
-public class StaballoyPickaxe extends ItemPickaxe{
+public class StaballoyPickaxe extends ItemPickaxe {
- /* (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 Boolean FACING_HORIZONTAL = true;
- protected Boolean FACING_HORIZONTAL = true;
- protected String FACING = "north";
- protected EntityPlayer localPlayer;
- protected String lookingDirection;
- protected World localWorld;
- public ItemStack thisPickaxe = null;
+ protected String FACING = "north";
+ protected EntityPlayer localPlayer;
+ protected String lookingDirection;
+ protected World localWorld;
+ public ItemStack thisPickaxe = null;
+ public StaballoyPickaxe(final String unlocalizedName, final ToolMaterial material) {
+ super(material);
+ this.setUnlocalizedName(unlocalizedName);
+ this.setTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.FACING_HORIZONTAL = true;
+ this.setMaxStackSize(1);
+ this.setMaxDamage(3200);
+ }
/*
- *
- *
- *
- * Methods
- *
- *
- *
+ *
+ *
+ *
+ * Methods
+ *
+ *
+ *
*/
+ @SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
@Override
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) {
- localPlayer = aPlayer;
- localWorld = world;
- 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) {
- //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
- localWorld = world;
- thisPickaxe = stack;
- //checkFacing(world);
- if (!world.isRemote){
- GetDestroyOrientation(lookingDirection, world, X, Y, Z, stack);
- }
-
- return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
+ 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);
}
@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);
- //Utils.LOG_WARNING(removalist.toString());
+ final Block removalist = world.getBlock(X, Y, Z);
+ // Utils.LOG_WARNING(removalist.toString());
bHardness = removalist.getBlockHardness(world, X, Y, Z);
- Utils.LOG_WARNING("Hardness: "+bHardness);
+ Utils.LOG_WARNING("Hardness: " + bHardness);
- bDurabilityLoss = (bDurabilityLoss + bHardness);
- //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss);
+ bDurabilityLoss = bDurabilityLoss + bHardness;
+ // Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss);
- correctTool = canPickaxeBlock(removalist, world);
- Utils.LOG_WARNING(""+correctTool);
+ correctTool = this.canPickaxeBlock(removalist, world);
+ Utils.LOG_WARNING("" + correctTool);
- if (!correctTool){
+ if (!correctTool) {
return 0;
}
- } catch (NullPointerException e){
+ }
+ catch (final NullPointerException e) {
}
}
return 100;
}
- public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){
+ public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld) {
String correctTool = "";
- if (!currentWorld.isRemote){
+ if (!currentWorld.isRemote) {
try {
correctTool = currentBlock.getHarvestTool(0);
- //Utils.LOG_WARNING(correctTool);
- if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("pickaxe")){
- return true;}
- } catch (NullPointerException e){
- return false;}
+ // Utils.LOG_WARNING(correctTool);
+ if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("pickaxe")) {
+ return true;
+ }
+ }
+ catch (final NullPointerException e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ 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);
+
+ /*
+ * if (localPlayer.getLookVec().yCoord > 0){
+ * localPlayer.getLookVec().yCoord; }
+ */
+
+ final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world,
+ this.localPlayer, false);
+ if (movingobjectposition != null) {
+ final int sideHit = movingobjectposition.sideHit;
+ String playerStandingPosition = "";
+ if (movingobjectposition != null) {
+ // System.out.println("Side Hit:
+ // "+movingobjectposition.sideHit);
+ }
+
+ if (sideHit == 0) {
+ playerStandingPosition = "above";
+ this.FACING_HORIZONTAL = false;
+ }
+ else if (sideHit == 1) {
+ playerStandingPosition = "below";
+ this.FACING_HORIZONTAL = false;
+ }
+ else if (sideHit == 2) {
+ playerStandingPosition = "facingSouth";
+ this.FACING_HORIZONTAL = true;
+ }
+ else if (sideHit == 3) {
+ playerStandingPosition = "facingNorth";
+ this.FACING_HORIZONTAL = true;
+ }
+ else if (sideHit == 4) {
+ playerStandingPosition = "facingEast";
+ this.FACING_HORIZONTAL = true;
+ }
+ else if (sideHit == 5) {
+ playerStandingPosition = "facingWest";
+ this.FACING_HORIZONTAL = true;
+ }
+ this.lookingDirection = playerStandingPosition;
+
+ if (direction == 0) {
+ this.FACING = "south";
+ }
+ 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;
}
- private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){
- localWorld = world;
+ public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer) {
+ item.damageItem(damage, localPlayer);
+ }
+
+ 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){
+ if (!world.isRemote) {
- if (FACING.equals("below") || FACING.equals("above")){
+ if (FACING.equals("below") || FACING.equals("above")) {
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);
- Utils.LOG_WARNING("Added Loss: "+dur);
- removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem);
+ for (int i = -1; i < 2; i++) {
+ for (int j = -1; j < 2; j++) {
+ final float dur = this.calculateDurabilityLoss(world, X + i, Y, Z + j);
+ DURABILITY_LOSS = DURABILITY_LOSS + dur;
+ Utils.LOG_WARNING("Added Loss: " + dur);
+ this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem);
}
}
}
- else if (FACING.equals("facingEast") || FACING.equals("facingWest")){
+ else if (FACING.equals("facingEast") || FACING.equals("facingWest")) {
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);
- DURABILITY_LOSS = (DURABILITY_LOSS + dur);
- Utils.LOG_WARNING("Added Loss: "+dur);
- removeBlockAndDropAsItem(world, X , Y + i, Z + j, heldItem);
+ for (int i = -1; i < 2; i++) {
+ for (int j = -1; j < 2; j++) {
+ final float dur = this.calculateDurabilityLoss(world, X, Y + i, Z + j);
+ DURABILITY_LOSS = DURABILITY_LOSS + dur;
+ Utils.LOG_WARNING("Added Loss: " + dur);
+ this.removeBlockAndDropAsItem(world, X, Y + i, Z + j, heldItem);
}
}
}
- else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){
+ else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")) {
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);
- DURABILITY_LOSS = (DURABILITY_LOSS + dur);
- Utils.LOG_WARNING("Added Loss: "+dur);
- removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem);
+ for (int i = -1; i < 2; i++) {
+ for (int j = -1; j < 2; j++) {
+ final float dur = this.calculateDurabilityLoss(world, X + j, Y + i, Z);
+ DURABILITY_LOSS = DURABILITY_LOSS + dur;
+ Utils.LOG_WARNING("Added Loss: " + dur);
+ this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem);
}
}
}
- //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("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);
-
- Utils.LOG_INFO(
- "Current Damage: " + itemdmg
- + " Max Damage: " + maxdmg
- + " Durability to be lost: " + dodmg
- + " Current Durability: " + durNow
- + " Remaining Durability: " + durLeft
- );
-
-
- //Break Tool
- if ((durNow-dodmg) <= (99) && itemdmg != 0){
- //TODO break tool
+ // 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("Durability: "+heldStack.getDamage(heldStack));
+ Utils.LOG_INFO("1x: " + heldItem.getItemDamage());
+ 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 + " Max Damage: " + maxdmg + " Durability to be lost: " + dodmg
+ + " Current Durability: " + durNow + " Remaining Durability: " + durLeft);
+
+ // Break Tool
+ if (durNow - dodmg <= 99 && itemdmg != 0) {
+ // TODO break tool
Utils.LOG_INFO("Breaking Tool");
heldItem.stackSize = 0;
}
- //Do Damage
+ // Do Damage
else {
- //setItemDamage(heldItem, durLeft);
- Utils.LOG_INFO(""+(durNow-durLeft));
- damageItem(heldItem, (durNow-durLeft)-1, localPlayer);
+ // setItemDamage(heldItem, durLeft);
+ Utils.LOG_INFO("" + (durNow - durLeft));
+ this.damageItem(heldItem, durNow - durLeft - 1, this.localPlayer);
}
-
-
- /*if (heldItem.getItemDamage() <= ((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS)){
- Utils.LOG_INFO("2: "+DURABILITY_LOSS+" 3: "+((heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS));
- setItemDamage(heldItem, (int) (heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())-DURABILITY_LOSS));
- }
- else {
- Utils.LOG_INFO("3: "+( heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage())));
- setItemDamage(heldItem, heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.getItemDamage()));
- }*/
- //Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage());
+
+ /*
+ * if (heldItem.getItemDamage() <=
+ * ((heldItem.getMaxDamage()-heldItem.getItemDamage())-
+ * DURABILITY_LOSS)){ Utils.LOG_INFO("2: "+DURABILITY_LOSS+" 3: "
+ * +((heldItem.getMaxDamage()-heldItem.getItemDamage())-
+ * DURABILITY_LOSS)); setItemDamage(heldItem, (int)
+ * (heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.
+ * getItemDamage())-DURABILITY_LOSS)); } else { Utils.LOG_INFO("3: "
+ * +( heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.
+ * getItemDamage()))); setItemDamage(heldItem,
+ * heldItem.getMaxDamage()-(heldItem.getMaxDamage()-heldItem.
+ * getItemDamage())); }
+ */
+ // Utils.LOG_WARNING("|GID|Durability: "+heldItem.getItemDamage());
DURABILITY_LOSS = 0;
}
}
-
- public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){
- item.damageItem(damage, localPlayer);
+
+ /*
+ * (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;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(final ItemStack par1ItemStack) {
+ return EnumRarity.rare;
+ }
+
+ @Override
+ public boolean hasEffect(final ItemStack par1ItemStack) {
+ return true;
+ }
+
+ @Override
+ 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);
+ this.localWorld = world;
+ this.thisPickaxe = stack;
+ // checkFacing(world);
+ if (!world.isRemote) {
+ this.GetDestroyOrientation(this.lookingDirection, world, X, Y, Z, stack);
+ }
+
+ return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
}
-
- public void setItemDamage(ItemStack item, int damage){
- item.setItemDamage(damage-1);
+
+ @Override
+ 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);
+ }
+
+ @Override
+ 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);
}
- //Should clear up blocks quicker if I chain it.
- public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){
- localWorld = world;
+ // Should clear up blocks quicker if I chain it.
+ public 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);
-
- 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)){
-
- 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){
- }
- }
-
- public boolean checkFacing(World world){
- localWorld = world;
- if (localPlayer != null){
- int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3;
- //Utils.LOG_WARNING("Player - F: "+direction);
- //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord);
+ 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 (localPlayer.getLookVec().yCoord > 0){
- localPlayer.getLookVec().yCoord;
- }*/
+ if (heldItem.getItemDamage() <= heldItem.getMaxDamage() - dur) {
- MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false);
- if (movingobjectposition != null){
- int sideHit = movingobjectposition.sideHit;
- String playerStandingPosition = "";
- if (movingobjectposition != null) {
- //System.out.println("Side Hit: "+movingobjectposition.sideHit);
- }
+ block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0);
+ world.setBlockToAir(X, Y, Z);
- if (sideHit == 0){
- playerStandingPosition = "above";
- FACING_HORIZONTAL = false;
- }
- else if (sideHit == 1){
- playerStandingPosition = "below";
- FACING_HORIZONTAL = false;
- }
- else if (sideHit == 2){
- playerStandingPosition = "facingSouth";
- FACING_HORIZONTAL = true;
- }
- else if (sideHit == 3){
- playerStandingPosition = "facingNorth";
- FACING_HORIZONTAL = true;
- }
- else if (sideHit == 4){
- playerStandingPosition = "facingEast";
- FACING_HORIZONTAL = true;
- }
- else if (sideHit == 5){
- playerStandingPosition = "facingWest";
- FACING_HORIZONTAL = true;
- }
- lookingDirection = playerStandingPosition;
+ }
- if (direction == 0){
- FACING = "south";
- }
- else if (direction == 1){
- FACING = "west";
+ }
}
- else if (direction == 2){
- FACING = "north";
- }
- else if (direction == 3){
- FACING = "east";
+ else {
+ Utils.LOG_WARNING("Incorrect Tool for mining this block.");
}
}
-
-
- return true;
}
- return false;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
- 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);
- }
+ catch (final NullPointerException e) {
- @Override
- @SideOnly(Side.CLIENT)
- public EnumRarity getRarity(ItemStack par1ItemStack){
- return EnumRarity.rare;
- }
-
- @Override
- public boolean hasEffect(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);
- return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer);
- }
- public StaballoyPickaxe(String unlocalizedName, ToolMaterial material) {
- super(material);
- this.setUnlocalizedName(unlocalizedName);
- this.setTextureName(CORE.MODID + ":" + unlocalizedName);
- this.FACING_HORIZONTAL=true;
- this.setMaxStackSize(1);
- this.setMaxDamage(3200);
+ public void setItemDamage(final ItemStack item, final int damage) {
+ item.setItemDamage(damage - 1);
}
}
diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
index 00711017e5..210bdcf378 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
@@ -15,297 +15,313 @@ import net.minecraft.item.*;
import net.minecraft.util.*;
import net.minecraft.world.World;
-public class StaballoySpade extends ItemSpade{
+public class StaballoySpade extends ItemSpade {
- /* (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 Boolean FACING_HORIZONTAL = true;
- protected Boolean FACING_HORIZONTAL = true;
- protected String FACING = "north";
- protected EntityPlayer localPlayer;
- protected String lookingDirection;
- protected World localWorld;
- public ItemStack thisPickaxe = null;
+ protected String FACING = "north";
+ protected EntityPlayer localPlayer;
+ protected String lookingDirection;
+ protected World localWorld;
+ public ItemStack thisPickaxe = null;
+ public StaballoySpade(final String unlocalizedName, final ToolMaterial material) {
+ super(material);
+ this.setUnlocalizedName(unlocalizedName);
+ this.setTextureName(CORE.MODID + ":" + unlocalizedName);
+ this.FACING_HORIZONTAL = true;
+ this.setMaxStackSize(1);
+ this.setMaxDamage(3200);
+ }
/*
- *
- *
- *
- * Methods
- *
- *
- *
+ *
+ *
+ *
+ * Methods
+ *
+ *
+ *
*/
+ @SuppressWarnings({
+ "unchecked", "rawtypes"
+ })
@Override
- public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) {
- localPlayer = aPlayer;
- localWorld = world;
- thisPickaxe = stack;
- return super.onItemRightClick(stack, world, aPlayer);
+ 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);
}
+ public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld) {
+ String correctTool = "";
+ if (!currentWorld.isRemote) {
+ try {
+ correctTool = currentBlock.getHarvestTool(0);
+ // Utils.LOG_WARNING(correctTool);
-
- @Override
- public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int X, int Y, int Z, EntityLivingBase entity) {
- //super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
- localWorld = world;
- thisPickaxe = stack;
- //checkFacing(world);
- if (!world.isRemote){
- GetDestroyOrientation(lookingDirection, world, X, Y, Z, stack);
+ Utils.LOG_INFO(
+ "Tool for Block: " + correctTool + " | Current block: " + currentBlock.getLocalizedName());
+ if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("shovel")) {
+ return true;
+ }
+ }
+ catch (final NullPointerException e) {
+ return false;
+ }
}
-
- return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
+ return false;
}
- public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){
- String correctTool = "";
- if (!currentWorld.isRemote){
- try {
- correctTool = currentBlock.getHarvestTool(0);
- //Utils.LOG_WARNING(correctTool);
+ 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);
+
+ /*
+ * if (localPlayer.getLookVec().yCoord > 0){
+ * localPlayer.getLookVec().yCoord; }
+ */
+
+ final MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world,
+ this.localPlayer, false);
+ if (movingobjectposition != null) {
+ final int sideHit = movingobjectposition.sideHit;
+ String playerStandingPosition = "";
+ if (movingobjectposition != null) {
+ // System.out.println("Side Hit:
+ // "+movingobjectposition.sideHit);
+ }
- Utils.LOG_INFO("Tool for Block: "+correctTool+" | Current block: "+currentBlock.getLocalizedName());
- if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("shovel")){
- return true;}
- } catch (NullPointerException e){
- return false;}
+ if (sideHit == 0) {
+ playerStandingPosition = "above";
+ this.FACING_HORIZONTAL = false;
+ }
+ else if (sideHit == 1) {
+ playerStandingPosition = "below";
+ this.FACING_HORIZONTAL = false;
+ }
+ else if (sideHit == 2) {
+ playerStandingPosition = "facingSouth";
+ this.FACING_HORIZONTAL = true;
+ }
+ else if (sideHit == 3) {
+ playerStandingPosition = "facingNorth";
+ this.FACING_HORIZONTAL = true;
+ }
+ else if (sideHit == 4) {
+ playerStandingPosition = "facingEast";
+ this.FACING_HORIZONTAL = true;
+ }
+ else if (sideHit == 5) {
+ playerStandingPosition = "facingWest";
+ this.FACING_HORIZONTAL = true;
+ }
+ this.lookingDirection = playerStandingPosition;
+
+ if (direction == 0) {
+ this.FACING = "south";
+ }
+ 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;
}
- private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){
- localWorld = world;
+ public void damageItem(final ItemStack item, final int damage, final EntityPlayer localPlayer) {
+ item.damageItem(damage, localPlayer);
+ }
+
+ 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){
+ if (!world.isRemote) {
- if (FACING.equals("below") || FACING.equals("above")){
+ if (FACING.equals("below") || FACING.equals("above")) {
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));
+ for (int i = -1; i < 2; i++) {
+ for (int j = -1; j < 2; j++) {
+ DURABILITY_LOSS = DURABILITY_LOSS
+ + this.removeBlockAndDropAsItem(world, X + i, Y, Z + j, heldItem);
}
}
}
- else if (FACING.equals("facingEast") || FACING.equals("facingWest")){
+ else if (FACING.equals("facingEast") || FACING.equals("facingWest")) {
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));
+ for (int i = -1; i < 2; i++) {
+ for (int j = -1; j < 2; j++) {
+ DURABILITY_LOSS = DURABILITY_LOSS
+ + this.removeBlockAndDropAsItem(world, X, Y + i, Z + j, heldItem);
}
}
}
- else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")){
+ else if (FACING.equals("facingNorth") || FACING.equals("facingSouth")) {
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));
+ for (int i = -1; i < 2; i++) {
+ for (int j = -1; j < 2; j++) {
+ DURABILITY_LOSS = DURABILITY_LOSS
+ + this.removeBlockAndDropAsItem(world, X + j, Y + i, Z, heldItem);
}
}
}
- //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("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);
-
- Utils.LOG_INFO(
- "Current Damage: " + itemdmg
- + " Max Damage: " + maxdmg
- + " Durability to be lost: " + dodmg
- + " Current Durability: " + durNow
- + " Remaining Durability: " + durLeft
- );
-
-
- //Break Tool
- if ((durNow-dodmg) <= (900) && itemdmg != 0){
- //TODO break tool
+ // 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("Durability: "+heldStack.getDamage(heldStack));
+ Utils.LOG_INFO("1x: " + heldItem.getItemDamage());
+ 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 + " Max Damage: " + maxdmg + " Durability to be lost: " + dodmg
+ + " Current Durability: " + durNow + " Remaining Durability: " + durLeft);
+
+ // Break Tool
+ if (durNow - dodmg <= 900 && itemdmg != 0) {
+ // TODO break tool
Utils.LOG_INFO("Breaking Tool");
heldItem.stackSize = 0;
}
- //Do Damage
+ // Do Damage
else {
- //setItemDamage(heldItem, durLeft);
- Utils.LOG_INFO(""+(durNow-durLeft));
- damageItem(heldItem, (durNow-durLeft)-1, localPlayer);
+ // setItemDamage(heldItem, durLeft);
+ Utils.LOG_INFO("" + (durNow - durLeft));
+ this.damageItem(heldItem, durNow - durLeft - 1, this.localPlayer);
}
DURABILITY_LOSS = 0;
}
}
- public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){
- item.damageItem(damage, localPlayer);
+ /*
+ * (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;
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(final ItemStack par1ItemStack) {
+ return EnumRarity.rare;
+ }
+
+ @Override
+ public boolean hasEffect(final ItemStack par1ItemStack) {
+ return true;
}
- public void setItemDamage(ItemStack item, int damage){
- item.setItemDamage(damage-1);
+ @Override
+ 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);
+ this.localWorld = world;
+ this.thisPickaxe = stack;
+ // checkFacing(world);
+ if (!world.isRemote) {
+ this.GetDestroyOrientation(this.lookingDirection, world, X, Y, Z, stack);
+ }
+
+ return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
+ }
+
+ @Override
+ 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);
+ }
+
+ @Override
+ 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);
}
- //Should clear up blocks quicker if I chain it.
- public int removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){
- localWorld = world;
+ // Should clear up blocks quicker if I chain it.
+ 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)){
- 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 != null) {
+ if (removalTool.equals("shovel")) {
+ 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) {
+
+ 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;
- //Utils.LOG_WARNING("Player - F: "+direction);
- //Utils.LOG_WARNING("Player - getLookVec(): "+localPlayer.getLookVec().yCoord);
-
- /*if (localPlayer.getLookVec().yCoord > 0){
- localPlayer.getLookVec().yCoord;
- }*/
-
- MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, (EntityPlayer) localPlayer, false);
- if (movingobjectposition != null){
- int sideHit = movingobjectposition.sideHit;
- String playerStandingPosition = "";
- if (movingobjectposition != null) {
- //System.out.println("Side Hit: "+movingobjectposition.sideHit);
- }
-
- if (sideHit == 0){
- playerStandingPosition = "above";
- FACING_HORIZONTAL = false;
- }
- else if (sideHit == 1){
- playerStandingPosition = "below";
- FACING_HORIZONTAL = false;
- }
- else if (sideHit == 2){
- playerStandingPosition = "facingSouth";
- FACING_HORIZONTAL = true;
- }
- else if (sideHit == 3){
- playerStandingPosition = "facingNorth";
- FACING_HORIZONTAL = true;
- }
- else if (sideHit == 4){
- playerStandingPosition = "facingEast";
- FACING_HORIZONTAL = true;
- }
- else if (sideHit == 5){
- playerStandingPosition = "facingWest";
- FACING_HORIZONTAL = true;
- }
- lookingDirection = playerStandingPosition;
-
- if (direction == 0){
- FACING = "south";
- }
- else if (direction == 1){
- FACING = "west";
- }
- else if (direction == 2){
- FACING = "north";
- }
- else if (direction == 3){
- FACING = "east";
- }
- }
-
-
- return true;
- }
- return false;
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool) {
- 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){
- return EnumRarity.rare;
- }
-
- @Override
- public boolean hasEffect(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);
- return super.onBlockStartBreak(itemstack, X, Y, Z, aPlayer);
- }
- public StaballoySpade(String unlocalizedName, ToolMaterial material) {
- super(material);
- this.setUnlocalizedName(unlocalizedName);
- this.setTextureName(CORE.MODID + ":" + unlocalizedName);
- this.FACING_HORIZONTAL=true;
- this.setMaxStackSize(1);
- this.setMaxDamage(3200);
+ public void setItemDamage(final ItemStack item, final int damage) {
+ item.setItemDamage(damage - 1);
}
}