aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/item/tool
diff options
context:
space:
mode:
authorDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
committerDraknyte1 <Draknyte1@hotmail.com>2016-11-06 19:32:27 +1000
commitcbe0e497be8e466c380a5b4fa781b314ede9ada3 (patch)
treeb85848b432adf458e3abda466ee46d9dfc3e454b /src/Java/gtPlusPlus/core/item/tool
parentc40416b036c0e89451e1558253ccf07bbee028d0 (diff)
downloadGT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.gz
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.tar.bz2
GT5-Unofficial-cbe0e497be8e466c380a5b4fa781b314ede9ada3.zip
Revert "$ Cleaned up the entire project."
This reverts commit 0669f5eb9d5029a8b94ec552171b0837605f7747. # Conflicts: # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMTE_NuclearReactor.java # src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/GregtechMetaTileEntity_MassFabricator.java Revert "% Cleaned up Imports." This reverts commit 3654052fb63a571c5eaca7f20714b87c17f7e966.
Diffstat (limited to 'src/Java/gtPlusPlus/core/item/tool')
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/misc/SandstoneHammer.java73
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java260
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java134
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyAxe.java519
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java526
-rw-r--r--src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java483
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);
}
}
}
- }
-
- 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;
}
- 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);
- }
- }
- }
- }
+ 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 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);
+
+ 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);
}
}
}
- }
- }
- }
-
- @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 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);
+ 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);
}
}
-
- 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);
+
+ 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);
}
}
}
}
return super.onBlockDestroyed(itm, wld, blk, x, y, z, plr);
}
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(ItemStack par1ItemStack){
+ return EnumRarity.rare;
+ }
- 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;
- }
+ @Override
+ public boolean hasEffect(ItemStack par1ItemStack){
return true;
}
} \ No newline at end of file
diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
index 5096b94054..079e3cfc39 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java
@@ -1,362 +1,350 @@
package gtPlusPlus.core.item.tool.staballoy;
-import java.util.List;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.player.UtilsMining;
+
+import java.util.List;
+
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
-import net.minecraft.item.*;
-import net.minecraft.util.*;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemPickaxe;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
-public class StaballoyPickaxe extends ItemPickaxe {
-
- protected Boolean FACING_HORIZONTAL = true;
+public class StaballoyPickaxe extends ItemPickaxe{
- 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);
+ /* (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;
+ public ItemStack thisPickaxe = null;
+
/*
- *
- *
- *
- * Methods
- *
- *
- *
+ *
+ *
+ *
+ * Methods
+ *
+ *
+ *
*/
- @SuppressWarnings({
- "unchecked", "rawtypes"
- })
@Override
- 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);
+ 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);
}
@SuppressWarnings("static-method")
- private float calculateDurabilityLoss(final World world, final int X, final int Y, final int Z) {
+ private float calculateDurabilityLoss(World world, int X, int Y, int Z){
float bDurabilityLoss = 0;
Boolean correctTool = false;
float bHardness = 0;
- if (!world.isRemote) {
+ if (!world.isRemote){
try {
- final Block removalist = world.getBlock(X, Y, Z);
- // Utils.LOG_WARNING(removalist.toString());
+ 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 = this.canPickaxeBlock(removalist, world);
- Utils.LOG_WARNING("" + correctTool);
+ correctTool = canPickaxeBlock(removalist, world);
+ Utils.LOG_WARNING(""+correctTool);
- if (!correctTool) {
+ if (!correctTool){
return 0;
}
- }
- catch (final NullPointerException e) {
+ } catch (NullPointerException e){
}
}
return 100;
}
- public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld) {
+ public Boolean canPickaxeBlock(Block currentBlock, 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 (final NullPointerException e) {
- return false;
- }
+ //Utils.LOG_WARNING(correctTool);
+ if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("pickaxe")){
+ return true;}
+ } catch (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;
- }
-
- 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;
+ private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){
+ 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++) {
- 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);
+ 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);
}
}
}
- 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++) {
- 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);
+ 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);
}
}
}
- 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++) {
- 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);
+ 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);
}
}
}
- // 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
+ //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
Utils.LOG_INFO("Breaking Tool");
heldItem.stackSize = 0;
}
- // Do Damage
+ //Do Damage
else {
- // setItemDamage(heldItem, durLeft);
- Utils.LOG_INFO("" + (durNow - durLeft));
- this.damageItem(heldItem, durNow - durLeft - 1, this.localPlayer);
+ //setItemDamage(heldItem, durLeft);
+ Utils.LOG_INFO(""+(durNow-durLeft));
+ damageItem(heldItem, (durNow-durLeft)-1, 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;
}
}
-
- /*
- * (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);
- }
-
- @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);
+
+ public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){
+ item.damageItem(damage, localPlayer);
}
-
- @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);
+
+ public void setItemDamage(ItemStack item, int damage){
+ item.setItemDamage(damage-1);
}
- // 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;
+ //Should clear up blocks quicker if I chain it.
+ 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 (heldItem.getItemDamage() <= heldItem.getMaxDamage() - dur) {
-
- block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0);
- world.setBlockToAir(X, Y, Z);
-
+
+ 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){
+
}
- catch (final NullPointerException e) {
+ }
+
+ public boolean checkFacing(World world){
+ localWorld = world;
+ if (localPlayer != null){
+ int direction = MathHelper.floor_double((double)((localPlayer.rotationYaw * 4F) / 360F) + 0.5D) & 3;
+ //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.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);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public EnumRarity getRarity(ItemStack par1ItemStack){
+ return EnumRarity.rare;
+ }
+
+ @Override
+ public boolean hasEffect(ItemStack par1ItemStack){
+ return true;
}
- public void setItemDamage(final ItemStack item, final int damage) {
- item.setItemDamage(damage - 1);
+
+ @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);
}
}
diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
index 210bdcf378..79eac5816b 100644
--- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
+++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java
@@ -1,327 +1,316 @@
package gtPlusPlus.core.item.tool.staballoy;
-import java.util.List;
-
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.player.UtilsMining;
+
+import java.util.List;
+
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
-import net.minecraft.item.*;
-import net.minecraft.util.*;
+import net.minecraft.item.EnumRarity;
+import net.minecraft.item.ItemSpade;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
-public class StaballoySpade extends ItemSpade {
-
- protected Boolean FACING_HORIZONTAL = true;
+public class StaballoySpade extends ItemSpade{
- 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);
+ /* (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;
+ public ItemStack thisPickaxe = null;
+
/*
- *
- *
- *
- * Methods
- *
- *
- *
+ *
+ *
+ *
+ * Methods
+ *
+ *
+ *
*/
- @SuppressWarnings({
- "unchecked", "rawtypes"
- })
@Override
- 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 ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer aPlayer) {
+ localPlayer = aPlayer;
+ localWorld = world;
+ thisPickaxe = stack;
+ return super.onItemRightClick(stack, world, aPlayer);
}
- public Boolean canPickaxeBlock(final Block currentBlock, final World currentWorld) {
- String correctTool = "";
- if (!currentWorld.isRemote) {
- try {
- correctTool = currentBlock.getHarvestTool(0);
- // Utils.LOG_WARNING(correctTool);
- Utils.LOG_INFO(
- "Tool for Block: " + correctTool + " | Current block: " + currentBlock.getLocalizedName());
- if (UtilsMining.getBlockType(currentBlock) || correctTool.equals("shovel")) {
- 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);
- }
+ @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);
+ }
- 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;
+ return super.onBlockDestroyed(stack, world, block, X, Y, Z, entity);
+ }
- 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";
- }
- }
+ public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){
+ String correctTool = "";
+ if (!currentWorld.isRemote){
+ try {
+ correctTool = currentBlock.getHarvestTool(0);
+ //Utils.LOG_WARNING(correctTool);
- return true;
+ 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;}
}
return false;
}
- 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;
+ private void GetDestroyOrientation(String FACING, World world, int X, int Y, int Z, ItemStack heldItem){
+ 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
- + this.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 + 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
- + this.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 + 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
- + this.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 + 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());
- 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
+ //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
Utils.LOG_INFO("Breaking Tool");
heldItem.stackSize = 0;
}
- // Do Damage
+ //Do Damage
else {
- // setItemDamage(heldItem, durLeft);
- Utils.LOG_INFO("" + (durNow - durLeft));
- this.damageItem(heldItem, durNow - durLeft - 1, this.localPlayer);
+ //setItemDamage(heldItem, durLeft);
+ Utils.LOG_INFO(""+(durNow-durLeft));
+ damageItem(heldItem, (durNow-durLeft)-1, localPlayer);
}
DURABILITY_LOSS = 0;
}
}
- /*
- * (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);
- }
-
- @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);
+ public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){
+ item.damageItem(damage, localPlayer);
}
- @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);
+ public void setItemDamage(ItemStack item, int damage){
+ item.setItemDamage(damage-1);
}
- // 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;
+ //Should clear up blocks quicker if I chain it.
+ public int removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){
+ localWorld = world;
Utils.LOG_INFO("Trying to drop/remove a block.");
try {
- final Block block = world.getBlock(X, Y, Z);
+ 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 (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;
+ 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;
}
- Utils.LOG_INFO(
- "Incorrect Tool for mining this block. Wrong Block Water/lava/bedrock/blacklist");
- 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;
}
- Utils.LOG_INFO("Incorrect Tool for mining this block. Cannot Shovel this block type.");
+ 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. Blocks mining tool is now Shovel.");
+ Utils.LOG_INFO("Incorrect Tool for mining this block. Cannot Shovel this block type.");
return 0;
}
- Utils.LOG_INFO("Either the block was air or it declares an invalid mining tool.");
+ Utils.LOG_INFO("Incorrect Tool for mining this block. Blocks mining tool is now Shovel.");
return 0;
- }
- catch (final NullPointerException e) {
+ }
+ Utils.LOG_INFO("Either the block was air or it declares an invalid mining tool.");
+ return 0;
+ } catch (NullPointerException e){
Utils.LOG_INFO("Something Broke");
e.printStackTrace();
return 0;
}
}
- public void setItemDamage(final ItemStack item, final int damage) {
- item.setItemDamage(damage - 1);
+ 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);
}
}