diff options
Diffstat (limited to 'src/Java/gtPlusPlus')
15 files changed, 895 insertions, 90 deletions
diff --git a/src/Java/gtPlusPlus/GTplusplus.java b/src/Java/gtPlusPlus/GTplusplus.java index 537dc7963f..89988a1248 100644 --- a/src/Java/gtPlusPlus/GTplusplus.java +++ b/src/Java/gtPlusPlus/GTplusplus.java @@ -15,6 +15,7 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.Recipe_GT.Gregtech_Recipe_Map; import gtPlusPlus.core.commands.CommandMath; import gtPlusPlus.core.common.CommonProxy; +import gtPlusPlus.core.handler.Recipes.RegistrationHandler; import gtPlusPlus.core.handler.events.LoginEventHandler; import gtPlusPlus.core.item.general.RF2EU_Battery; import gtPlusPlus.core.lib.CORE; @@ -165,6 +166,8 @@ implements ActionListener Utils.LOG_INFO("Activating GT OreDictionary Handler, this can take some time."); Utils.LOG_INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); + Utils.LOG_INFO("| Recipes succesfully Loaded: "+RegistrationHandler.recipesSuccess+" | Failed: "+RegistrationHandler.recipesFailed + " |"); + Utils.LOG_INFO("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); Meta_GT_Proxy.activateOreDictHandler(); Utils.LOG_INFO("Finally, we are finished. Have some cripsy bacon as a reward."); } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index fd7d005e55..27488794bc 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -21,6 +21,7 @@ import gtPlusPlus.core.item.general.fuelrods.FuelRod_Base; import gtPlusPlus.core.item.init.ItemsFoods; import gtPlusPlus.core.item.tool.misc.SandstoneHammer; import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; import gtPlusPlus.core.item.tool.staballoy.StaballoyAxe; import gtPlusPlus.core.item.tool.staballoy.StaballoyPickaxe; import gtPlusPlus.core.lib.CORE; @@ -109,6 +110,7 @@ public final class ModItems { public static Item itemPersonalHealingDevice; public static MultiPickaxeBase MP_GTMATERIAL; + public static MultiSpadeBase MS_GTMATERIAL; public static ItemStack FluidCell; @@ -231,8 +233,15 @@ public final class ModItems { boolean gtStyleTools = LoadedMods.Gregtech; + + Materials[] rm = Materials.values(); + for (Materials m : rm){ + MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, m); + MS_GTMATERIAL = UtilsItems.generateMultiShovel(gtStyleTools, m); + } + - MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Wood); + /*MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Wood); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Cobblestone); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Iron); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.WroughtIron); @@ -277,7 +286,7 @@ public final class ModItems { MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.BlueSteel); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Neodymium); MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.Desh); - MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.ElectrumFlux); + MP_GTMATERIAL = UtilsItems.generateMultiPick(gtStyleTools, Materials.ElectrumFlux);*/ //EnderIO Resources if (LoadedMods.EnderIO || LOAD_ALL_CONTENT){ diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java index 60353f2d1b..2978579d0b 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiPickaxeBase.java @@ -37,6 +37,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ 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); @@ -46,12 +47,15 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ this.setMaxStackSize(1); this.setMaxDamage(materialDurability); this.colour = colour; - this.materialName = material.name(); - GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + this.materialName = material.name(); this.setCreativeTab(AddToCreativeTab.tabTools); - try {addRecipe();} catch (Throwable e){} + try {isValid = addRecipe();} catch (Throwable e){} + if (colour != 0 && isValid){ + GameRegistry.registerItem(this, Utils.sanitizeString(unlocalizedName)); + } + } - + /* * * @@ -61,25 +65,35 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ * * */ - - private void addRecipe(){ + + 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 == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ + return false; + } + if (null == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ + return false; + } + UtilsRecipe.recipeBuilder( plateDense, plateDense, plateDense, toolFile, rodLong, toolHammer, toolWrench, rodLong, toolScrewDriver, UtilsItems.getSimpleStack(this)); + + return true; } - + public final String getMaterialName() { return materialName; } - + @Override public String getItemStackDisplayName(ItemStack iStack) { @@ -113,7 +127,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ return colour; } - + @SuppressWarnings("static-method") private float calculateDurabilityLoss(World world, int X, int Y, int Z){ float bDurabilityLoss = 0; @@ -127,7 +141,7 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ bHardness = removalist.getBlockHardness(world, X, Y, Z)*100; Utils.LOG_WARNING("Hardness: "+bHardness); - bDurabilityLoss = bHardness; + bDurabilityLoss = 100; //Utils.LOG_WARNING("Durability Loss: "+bDurabilityLoss); correctTool = canPickaxeBlock(removalist, world); @@ -154,21 +168,21 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ 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); - + + block.dropBlockAsItem(world, X, Y, Z, world.getBlockMetadata(X, Y, Z), 0); + world.setBlockToAir(X, Y, Z); + } else { return; } - + } } else { @@ -179,13 +193,15 @@ public class MultiPickaxeBase extends StaballoyPickaxe{ } } - - - @Override + public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ - item.damageItem(damage*100, localPlayer); + item.damageItem(damage, localPlayer); } - + + public void setItemDamage(ItemStack item, int damage){ + item.setItemDamage(damage-1); + } + @Override @SideOnly(Side.CLIENT) diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java new file mode 100644 index 0000000000..972ba0ca12 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/MultiSpadeBase.java @@ -0,0 +1,115 @@ +package gtPlusPlus.core.item.tool.staballoy; + +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.item.UtilsItems; +import gtPlusPlus.core.util.math.MathUtils; +import gtPlusPlus.core.util.recipe.UtilsRecipe; +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{ + + /* (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 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.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)); + } + } + + 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 == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(rodLong, 1)){ + return false; + } + if (null == UtilsItems.getItemStackOfAmountFromOreDictNoBroken(plateDense, 1)){ + return false; + } + + UtilsRecipe.recipeBuilder( + toolFile, plateDense, toolHammer, + null, rodLong, null, + toolWrench, rodLong, toolScrewDriver, + UtilsItems.getSimpleStack(this)); + + return true; + } + + public final String getMaterialName() { + return materialName; + } + + @Override + public String getItemStackDisplayName(ItemStack iStack) { + + String name; + if (getUnlocalizedName().toLowerCase().contains("wood")){ + name = "Wooden"; + } + else { + name = materialName; + } + return "Big "+name+" Spade"; + } + + @Override + public int getColorFromItemStack(ItemStack stack, int HEX_OxFFFFFF) { + if (colour == 0){ + return MathUtils.generateSingularRandomHexValue(); + } + return colour; + } + + @Override + @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/StaballoyPickaxe.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java index d20ad259e7..46e727edd1 100644 --- a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoyPickaxe.java @@ -99,7 +99,7 @@ public class StaballoyPickaxe extends ItemPickaxe{ } } - return bDurabilityLoss; + return 100; } public Boolean canPickaxeBlock(Block currentBlock, World currentWorld){ @@ -158,16 +158,48 @@ public class StaballoyPickaxe extends ItemPickaxe{ } //int heldItemDurability = heldItem.getDamage(1); - Utils.LOG_WARNING("Total Loss: "+(int)DURABILITY_LOSS); + 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)); - if (heldItem.getItemDamage() <= (heldItem.getMaxDamage()-DURABILITY_LOSS)){ - damageItem(heldItem, (int) DURABILITY_LOSS, localPlayer); + 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 else { - damageItem(heldItem, heldItem.getMaxDamage()-heldItem.getItemDamage(), 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()); DURABILITY_LOSS = 0; @@ -177,6 +209,10 @@ public class StaballoyPickaxe extends ItemPickaxe{ public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ item.damageItem(damage, localPlayer); } + + public void setItemDamage(ItemStack item, int damage){ + item.setItemDamage(damage-1); + } //Should clear up blocks quicker if I chain it. public void removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ diff --git a/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java new file mode 100644 index 0000000000..79eac5816b --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/tool/staballoy/StaballoySpade.java @@ -0,0 +1,316 @@ +package gtPlusPlus.core.item.tool.staballoy; + +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.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{ + + /* (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 + * + * + * + */ + + @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 Boolean canPickaxeBlock(Block currentBlock, 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 (NullPointerException e){ + return false;} + } + return false; + } + + 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 (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)); + } + } + } + + 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)); + } + } + } + + 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)); + } + } + } + + //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 + else { + //setItemDamage(heldItem, durLeft); + Utils.LOG_INFO(""+(durNow-durLeft)); + damageItem(heldItem, (durNow-durLeft)-1, localPlayer); + } + DURABILITY_LOSS = 0; + + } + } + + public void damageItem(ItemStack item, int damage, EntityPlayer localPlayer){ + item.damageItem(damage, localPlayer); + } + + public void setItemDamage(ItemStack item, int damage){ + item.setItemDamage(damage-1); + } + + //Should clear up blocks quicker if I chain it. + public int removeBlockAndDropAsItem(World world, int X, int Y, int Z, ItemStack heldItem){ + localWorld = world; + Utils.LOG_INFO("Trying to drop/remove a block."); + try { + 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; + } + 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. Cannot Shovel this block type."); + return 0; + } + Utils.LOG_INFO("Incorrect Tool for mining this block. Blocks mining tool is now Shovel."); + return 0; + } + 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 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); + } +} diff --git a/src/Java/gtPlusPlus/core/lib/CORE.java b/src/Java/gtPlusPlus/core/lib/CORE.java index a1c6f4405a..777bf16dc0 100644 --- a/src/Java/gtPlusPlus/core/lib/CORE.java +++ b/src/Java/gtPlusPlus/core/lib/CORE.java @@ -7,15 +7,10 @@ import gtPlusPlus.xmod.gregtech.api.enums.GregtechOrePrefixes.GT_Materials; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; -import java.util.ArrayList; -import java.util.List; import java.util.Map; -import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.config.Configuration; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; public class CORE { @@ -34,10 +29,7 @@ public class CORE { @Deprecated public static IGregtech_RecipeAdder sRecipeAdder; public static GregtechRecipe GT_Recipe = new GregtechRecipe(); - - @SideOnly(Side.CLIENT) - public static IIconRegister GT_BlockIcons, GT_ItemIcons; - public static List<Runnable> GT_BlockIconload = new ArrayList<Runnable>(); + public static Configuration Config; public static final String GT_Tooltip = "Added by: " + EnumChatFormatting.DARK_GREEN+"Alkalus "+EnumChatFormatting.GRAY+"- "+EnumChatFormatting.RED+"[GT++]"; public static final String GT_Tooltip_Radioactive = EnumChatFormatting.GRAY+"Warning: "+EnumChatFormatting.GREEN+"Radioactive! "+EnumChatFormatting.GOLD+" Avoid direct handling without hazmat protection."; diff --git a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java index 197482f1ae..52392aeb00 100644 --- a/src/Java/gtPlusPlus/core/util/item/UtilsItems.java +++ b/src/Java/gtPlusPlus/core/util/item/UtilsItems.java @@ -20,6 +20,7 @@ import gtPlusPlus.core.item.base.rods.BaseItemRodLong; import gtPlusPlus.core.item.base.rotors.BaseItemRotor; import gtPlusPlus.core.item.base.screws.BaseItemScrew; import gtPlusPlus.core.item.tool.staballoy.MultiPickaxeBase; +import gtPlusPlus.core.item.tool.staballoy.MultiSpadeBase; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.Material; @@ -372,7 +373,45 @@ public class UtilsItems { Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) ); - return MP_Redstone; + if (MP_Redstone.isValid){ + return MP_Redstone; + } + return null; + + } + + public static MultiSpadeBase generateMultiShovel(boolean GT_Durability, Materials material){ + ToolMaterial customMaterial = Utils.generateMaterialFromGT(material); + Utils.LOG_INFO("Generating a Multi-Shovel out of "+material.name()); + short[] rgb; + rgb = material.getRGBA(); + int dur = customMaterial.getMaxUses(); + Utils.LOG_INFO("Determined durability for "+material.name()+" is "+dur); + if (GT_Durability){ + dur = material.mDurability*100; + Utils.LOG_INFO("Using gregtech durability value, "+material.name()+" is now "+dur+"."); + } + else if (dur <= 0){ + dur = material.mDurability; + Utils.LOG_INFO("Determined durability too low, "+material.name()+" is now "+dur+" based on the GT material durability."); + } + + if (dur <= 0){ + Utils.LOG_INFO("Still too low, "+material.name()+" will now go unused."); + return null; + } + + MultiSpadeBase MP_Redstone = new MultiSpadeBase( + material.name()+" Multishovel", + (customMaterial), + dur, + Utils.rgbtoHexValue(rgb[0],rgb[1],rgb[2]) + ); + + if (MP_Redstone.isValid){ + return MP_Redstone; + } + return null; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java index 705f5b338e..dca5d7301c 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechTextures.java @@ -1,9 +1,9 @@ package gtPlusPlus.xmod.gregtech.api.enums; -import gregtech.api.GregTech_API; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_IconContainer; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.Interface_Texture; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; @@ -51,7 +51,7 @@ public class GregtechTextures { protected IIcon mIcon; private BlockIcons() { - CORE.GT_BlockIconload.add(this); + Meta_GT_Proxy.GT_BlockIconload.add(this); } @Override @@ -66,7 +66,7 @@ public class GregtechTextures { @Override public void run() { - mIcon = GregTech_API.sBlockIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); + mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + "iconsets/" + this); } @Override @@ -80,7 +80,7 @@ public class GregtechTextures { public CustomIcon(String aIconName) { mIconName = aIconName; - CORE.GT_BlockIconload.add(this); + Meta_GT_Proxy.GT_BlockIconload.add(this); } @Override @@ -95,7 +95,7 @@ public class GregtechTextures { @Override public void run() { - mIcon = CORE.GT_BlockIcons.registerIcon(CORE.MODID + ":" + mIconName); + mIcon = Meta_GT_Proxy.sBlockIcons.registerIcon(CORE.MODID + ":" + mIconName); } @Override @@ -107,10 +107,12 @@ public class GregtechTextures { public enum ItemIcons implements Interface_IconContainer, Runnable { - VOID // The Empty Texture - , RENDERING_ERROR, SKOOKUMCHOOCHER, DURABILITY_BAR_0, DURABILITY_BAR_1, DURABILITY_BAR_2, DURABILITY_BAR_3, DURABILITY_BAR_4, DURABILITY_BAR_5, DURABILITY_BAR_6, DURABILITY_BAR_7, DURABILITY_BAR_8, ENERGY_BAR_0, ENERGY_BAR_1, ENERGY_BAR_2, ENERGY_BAR_3, ENERGY_BAR_4, ENERGY_BAR_5, ENERGY_BAR_6, ENERGY_BAR_7, ENERGY_BAR_8, TURBINE, TURBINE_SMALL, TURBINE_LARGE, TURBINE_HUGE; + VOID, // The Empty Texture + RENDERING_ERROR, //The Purple/Black Texture + SKOOKUMCHOOCHER, //The Skookum Tool Texture + TURBINE_SMALL, TURBINE_LARGE, TURBINE_HUGE; - public static final Interface_IconContainer[] + /* public static final Interface_IconContainer[] DURABILITY_BAR = new Interface_IconContainer[]{ DURABILITY_BAR_0, DURABILITY_BAR_1, @@ -132,14 +134,14 @@ public class GregtechTextures { ENERGY_BAR_6, ENERGY_BAR_7, ENERGY_BAR_8, - }; + };*/ //public static final Interface_Texture[] ERROR_RENDERING = new Interface_Texture[]{new GregtechRenderedTexture(RENDERING_ERROR)}; protected IIcon mIcon, mOverlay; private ItemIcons() { - GregTech_API.sGTItemIconload.add(this); + Meta_GT_Proxy.GT_ItemIconload.add(this); } @Override @@ -159,8 +161,8 @@ public class GregtechTextures { @Override public void run() { - mIcon = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this); - mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this + "_OVERLAY"); + mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this); + mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + "iconsets/" + this + "_OVERLAY"); } public static class CustomIcon implements Interface_IconContainer, Runnable { @@ -169,7 +171,7 @@ public class GregtechTextures { public CustomIcon(String aIconName) { mIconName = aIconName; - GregTech_API.sGTItemIconload.add(this); + Meta_GT_Proxy.GT_ItemIconload.add(this); } @Override @@ -184,8 +186,8 @@ public class GregtechTextures { @Override public void run() { - mIcon = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName); - mOverlay = GregTech_API.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName + "_OVERLAY"); + mIcon = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName); + mOverlay = Meta_GT_Proxy.sItemIcons.registerIcon(CORE.MODID+ ":" + mIconName + "_OVERLAY"); } @Override diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java index 05abaa00da..98fcc6d6bb 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/Meta_GT_Proxy.java @@ -11,6 +11,7 @@ import gregtech.api.enums.SubTag; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.ToolDictNames; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntityEx; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.GT_Log; @@ -34,6 +35,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; +import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -41,12 +43,22 @@ import net.minecraftforge.oredict.OreDictionary; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class Meta_GT_Proxy { //Store Some MetaTileEntity Data here, why not? public static final IMetaTileEntity[] METATILEENTITIES = new IMetaTileEntity[GregTech_API.MAXIMUM_METATILE_IDS]; + public static List<Runnable> GT_BlockIconload = new ArrayList<Runnable>(); + public static List<Runnable> GT_ItemIconload = new ArrayList<Runnable>(); + + + + @SideOnly(Side.CLIENT) + public static IIconRegister sBlockIcons, sItemIcons; + //Silly Vars private static final Collection<String> mIgnoredItems = new HashSet<String>(Arrays.asList(new String[]{"itemGhastTear", "itemFlint", "itemClay", "itemBucketSaltWater", "itemBucketFreshWater", "itemBucketWater", "itemRock", "itemReed", "itemArrow", "itemSaw", "itemKnife", "itemHammer", "itemChisel", "itemRubber", @@ -899,6 +911,25 @@ public class Meta_GT_Proxy { } + /** + * This gives you a new BaseMetaTileEntity. As some Interfaces are not always loaded (Buildcraft, Univeral Electricity) I have to use Invocation at the Constructor of the BaseMetaTileEntity + */ + private static Class<BaseMetaTileEntityEx> sBaseMetaTileEntityClass = null; + public static BaseMetaTileEntityEx constructBaseMetaTileEntity() { + if (sBaseMetaTileEntityClass == null) { + try { + return (BaseMetaTileEntityEx) (sBaseMetaTileEntityClass = BaseMetaTileEntityEx.class).newInstance(); + } catch (Throwable e) {/*Do nothing*/} + } + + try { + return (BaseMetaTileEntityEx) (sBaseMetaTileEntityClass.newInstance()); + } catch (Throwable e) { + Utils.LOG_INFO("Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + e.printStackTrace(GT_Log.err); + throw new RuntimeException(e); + } + } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java index 9c6a780952..0b47d3c5c1 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/blocks/GregtechBlockMachines.java @@ -8,9 +8,8 @@ import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_Generic_Block; import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseMetaTileEntityEx; import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.util.GT_BaseCrop; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Item_Machines; @@ -108,7 +107,7 @@ public class GregtechBlockMachines @Override public String getUnlocalizedName() { - return "gt.blockmachines"; + return "gt.plusplus.blockmachines"; } @Override @@ -240,12 +239,12 @@ public class GregtechBlockMachines super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); } - @Override - @SideOnly(Side.CLIENT) + @Override //TODO + @SideOnly(Side.CLIENT) //TODO public void registerBlockIcons(IIconRegister aIconRegister) { - //if (GregTech_API.sPostloadFinished) { + if (GregTech_API.sPostloadFinished) { Utils.LOG_INFO("Setting up Icon Register for Blocks"); - GregTech_API.sBlockIcons = aIconRegister; + Meta_GT_Proxy.sBlockIcons = aIconRegister; Utils.LOG_INFO("Registering MetaTileEntity specific Textures"); for (IMetaTileEntity tMetaTileEntity : Meta_GT_Proxy.METATILEENTITIES) { @@ -257,17 +256,10 @@ public class GregtechBlockMachines e.printStackTrace(GT_Log.err); } } - Utils.LOG_INFO("Registering Crop specific Textures"); - try { - for (GT_BaseCrop tCrop : GT_BaseCrop.sCropList) { - tCrop.registerSprites(aIconRegister); - } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } + Utils.LOG_INFO("Starting Block Icon Load Phase"); System.out.println("Starting Block Icon Load Phase"); - for (Runnable tRunnable : GregTech_API.sGTBlockIconload) { + for (Runnable tRunnable : Meta_GT_Proxy.GT_BlockIconload) { try { tRunnable.run(); } catch (Throwable e) { @@ -276,7 +268,7 @@ public class GregtechBlockMachines } Utils.LOG_INFO("Finished Block Icon Load Phase"); System.out.println("Finished Block Icon Load Phase"); - // } + } } @Override @@ -287,7 +279,7 @@ public class GregtechBlockMachines @Override public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof BaseMetaTileEntity)) && (((BaseMetaTileEntity) tTileEntity).privateAccess()) && (!((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true))) { + if (((tTileEntity instanceof BaseMetaTileEntityEx)) && (((BaseMetaTileEntityEx) tTileEntity).privateAccess()) && (!((BaseMetaTileEntityEx) tTileEntity).playerOwnsThis(aPlayer, true))) { return -1.0F; } return super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); @@ -340,8 +332,8 @@ public class GregtechBlockMachines @Override public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { + ((BaseMetaTileEntityEx) tTileEntity).doEnergyExplosion(); } super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); } @@ -421,8 +413,8 @@ public class GregtechBlockMachines if (!aWorld.isRemote) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity != null) && (chance < 1.0F)) { - if (((tTileEntity instanceof BaseMetaTileEntity)) && (GregTech_API.sMachineNonWrenchExplosions)) { - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + if (((tTileEntity instanceof BaseMetaTileEntityEx)) && (GregTech_API.sMachineNonWrenchExplosions)) { + ((BaseMetaTileEntityEx) tTileEntity).doEnergyExplosion(); } } else { super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); @@ -437,7 +429,7 @@ public class GregtechBlockMachines } TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null) { - if ((tTileEntity instanceof BaseMetaTileEntity)) { + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { return true; } if (((tTileEntity instanceof BaseMetaPipeEntity)) && ((((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0)) { @@ -465,16 +457,16 @@ public class GregtechBlockMachines @Override public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { - return ((BaseMetaTileEntity) tTileEntity).getLightValue(); + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { + return ((BaseMetaTileEntityEx) tTileEntity).getLightValue(); } return 0; } - @Override + @Override //TODO public TileEntity createTileEntity(World aWorld, int aMeta) { if (aMeta < 4) { - return GregTech_API.constructBaseMetaTileEntity(); + return Meta_GT_Proxy.constructBaseMetaTileEntity(); } return new BaseMetaPipeEntity(); } @@ -537,8 +529,8 @@ public class GregtechBlockMachines @Override public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { - return ((BaseMetaTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); + if ((tTileEntity instanceof BaseMetaTileEntityEx)) { + return ((BaseMetaTileEntityEx) tTileEntity).getDebugInfo(aPlayer, aLogLevel); } if ((tTileEntity instanceof BaseMetaPipeEntity)) { return ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java index d913f56869..29a8a5948a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/items/MetaGeneratedGregtechItems.java @@ -1,5 +1,6 @@ package gtPlusPlus.xmod.gregtech.common.items; +import static gtPlusPlus.core.util.Utils.getTcAspectStack; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; @@ -16,7 +17,6 @@ import gregtech.api.util.GT_OreDictUnificator; import gregtech.common.covers.GT_Cover_Arm; import gregtech.common.covers.GT_Cover_Conveyor; import gregtech.common.covers.GT_Cover_Pump; -import static gtPlusPlus.core.util.Utils.getTcAspectStack; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -192,10 +192,18 @@ public class MetaGeneratedGregtechItems extends Gregtech_MetaItem_X32 { GregtechItemList.Fluid_Cell_1L.set(addItem(tLastID = 64, "1L Wrought Iron Fluid Cell", "Holds exactly one litre worth of liquid.", new Object[]{new ItemData(Materials.WroughtIron, OrePrefixes.plate.mMaterialAmount * 8L + 4L * OrePrefixes.ring.mMaterialAmount, new MaterialStack[0]), getTcAspectStack(TC_Aspects.VACUOS, 2L), getTcAspectStack(TC_Aspects.AQUA, 1L)})); setFluidContainerStats(32000 + tLastID, 1L, 64L); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 8L), GregtechItemList.Fluid_Cell_1L.get(4L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 8L), GregtechItemList.Fluid_Cell_16L.get(4L, new Object[0]), 50, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 8L), GregtechItemList.Fluid_Cell_36L.get(4L, new Object[0]), 75, 32); - GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 4L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 8L), GregtechItemList.Fluid_Cell_144L.get(4L, new Object[0]), 75, 32); + if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK){ + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.WroughtIron, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 1L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Bronze, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 1L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Brass, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 1L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Invar, 1L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 1L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); + } + else { + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.WroughtIron, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.WroughtIron, 4L), GregtechItemList.Fluid_Cell_1L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bronze, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Bronze, 4L), GregtechItemList.Fluid_Cell_16L.get(1L, new Object[0]), 50, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Brass, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Brass, 4L), GregtechItemList.Fluid_Cell_36L.get(1L, new Object[0]), 75, 32); + GT_Values.RA.addAssemblerRecipe(GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Invar, 8L), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Invar, 4L), GregtechItemList.Fluid_Cell_144L.get(1L, new Object[0]), 75, 32); + } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java new file mode 100644 index 0000000000..77787cd2bf --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_NBT_Tank.java @@ -0,0 +1,202 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.storage; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntityEx; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTankEx; +import gregtech.api.objects.GT_RenderedTexture; +import gtPlusPlus.core.util.Utils; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; + +public class GT_NBT_Tank + extends GT_MetaTileEntity_BasicTankEx { + + + /*protected String fluidName = getFluidName(); + protected int fluidAmount = getInternalFluidAmount();*/ + + /*private String getFluidName(){ + String x; + if (internalTank != null){ + x = internalTank.getFluid().getName(); + } + else { + x = "null"; + } + return x; + } + + private int getInternalFluidAmount(){ + int x; + if (internalTank != null){ + x = internalTank.amount; + } + else { + x = 0; + } + return x; + }*/ + + public GT_NBT_Tank(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 3, "Stores " + ((int) (Math.pow(2, aTier) * 32000)) + "L of fluid"); + } + + public GT_NBT_Tank(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 3, aDescription, aTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return new ITexture[0][0][0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == 1 ? new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER_ACTIVE)} : new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_SIDE_POTIONBREWER)}; + } + + /* @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + }*/ + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + Utils.LOG_INFO("Dumping Fluid data. Name: "+mFluid.getFluid().getName()+" Amount: "+mFluid.amount+"L"); + if (mFluid != null) aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + mFluid = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mFluid")); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + Utils.LOG_INFO("Right Click on Block"); + if (aBaseMetaTileEntity.isClientSide()){ + Utils.LOG_INFO("MTE is ClientSide"); + return true; + } + Utils.LOG_INFO("MTE is not ClientSide"); + aBaseMetaTileEntity.openGUI(aPlayer); + Utils.LOG_INFO("MTE is now has an open GUI"); + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(byte aFacing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public final byte getUpdateData() { + return 0x00; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public boolean doesEmptyContainers() { + return true; + } + + @Override + public boolean canTankBeFilled() { + return true; + } + + @Override + public boolean canTankBeEmptied() { + return true; + } + + @Override + public boolean displaysItemStack() { + return true; + } + + @Override + public boolean displaysStackSize() { + return false; + } + + @Override + public String[] getInfoData() { + + if (mFluid == null) { + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + "No Fluid", + Integer.toString(0) + "L", + Integer.toString(getCapacity()) + "L"}; + } + return new String[]{ + GT_Values.VOLTAGE_NAMES[mTier]+" Fluid Tank", + "Stored Fluid:", + mFluid.getLocalizedName(), + Integer.toString(mFluid.amount) + "L", + Integer.toString(getCapacity()) + "L"}; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public MetaTileEntityEx newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_NBT_Tank(mName, mTier, mDescription, mTextures); + } + + @Override + public int getCapacity() { + return (int) (Math.pow(2, mTier) * 32000); + } + + @Override + public int getTankPressure() { + return 100; + } + + @Override + public void sendSound(byte aIndex) { + + } + + @Override + public void sendLoopStart(byte aIndex) { + + } + + @Override + public void sendLoopEnd(byte aIndex) { + + } + +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java index b953f0d672..5cda3ac867 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/Gregtech_Blocks.java @@ -1,8 +1,12 @@ package gtPlusPlus.xmod.gregtech.loaders; +import gregtech.api.metatileentity.BaseMetaTileEntityEx; import gtPlusPlus.core.block.ModBlocks; -import gtPlusPlus.xmod.gregtech.common.blocks.GregtechBlockMachines; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.xmod.gregtech.common.Meta_GT_Proxy; import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks; +import cpw.mods.fml.common.event.FMLInterModComms; +import cpw.mods.fml.common.registry.GameRegistry; public class Gregtech_Blocks { @@ -10,7 +14,28 @@ public class Gregtech_Blocks { //Casing Blocks ModBlocks.blockCasingsMisc = new GregtechMetaCasingBlocks(); - ModBlocks.blockMetaTileEntity = new GregtechBlockMachines(); + //ModBlocks.blockMetaTileEntity = new GregtechBlockMachines(); + //registerDefailtGtTe(); + + + + + } + + //Register default Tile Entity + private static void registerDefailtGtTe(){ + Utils.LOG_INFO("Registering new GT TileEntities."); + + BaseMetaTileEntityEx tBaseMetaTileEntity = Meta_GT_Proxy.constructBaseMetaTileEntity(); + + Utils.LOG_INFO("Testing BaseMetaTileEntity."); + if (tBaseMetaTileEntity == null) { + Utils.LOG_INFO("Fatal Error ocurred while initializing TileEntities, crashing Minecraft."); + throw new RuntimeException(""); + } + Utils.LOG_INFO("Registering the BaseMetaTileEntityEx."); + GameRegistry.registerTileEntity(tBaseMetaTileEntity.getClass(), "BaseMetaTileEntityEx"); + FMLInterModComms.sendMessage("appliedenergistics2", "whitelist-spatial", tBaseMetaTileEntity.getClass().getName()); } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java index 4f8f2e3c1f..e1af53a627 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechTieredFluidTanks.java @@ -4,6 +4,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_MetaTileEntity_TieredTank; +import gtPlusPlus.xmod.gregtech.common.tileentities.storage.GT_NBT_Tank; public class GregtechTieredFluidTanks { @@ -12,6 +13,7 @@ public class GregtechTieredFluidTanks if (LoadedMods.Gregtech){ Utils.LOG_INFO("Gregtech5u Content | Registering Fluid Tanks."); run1(); + //run2(); } } @@ -32,4 +34,21 @@ public class GregtechTieredFluidTanks } + + private static void run2() + { + int ID = 900; + GregtechItemList.GT_FluidTank_ULV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.00", "Ultra Low Voltage Fluid Tank", 0).getStackForm(1L)); + GregtechItemList.GT_FluidTank_LV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.01", "Low Voltage Fluid Tank", 1).getStackForm(1L)); + GregtechItemList.GT_FluidTank_MV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.02", "Medium Voltage Fluid Tank", 2).getStackForm(1L)); + GregtechItemList.GT_FluidTank_HV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.03", "High Voltage Fluid Tank", 3).getStackForm(1L)); + GregtechItemList.GT_FluidTank_EV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.04", "Extreme Voltage Fluid Tank", 4).getStackForm(1L)); + GregtechItemList.GT_FluidTank_IV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.05", "Insane Voltage Fluid Tank", 5).getStackForm(1L)); + GregtechItemList.GT_FluidTank_LuV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.06", "Ludicrous Voltage Fluid Tank", 6).getStackForm(1L)); + GregtechItemList.GT_FluidTank_ZPM.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.07", "ZPM Voltage Fluid Tank", 7).getStackForm(1L)); + GregtechItemList.GT_FluidTank_UV.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.08", "Ultimate Voltage Fluid Tank", 8).getStackForm(1L)); + GregtechItemList.GT_FluidTank_MAX.set(new GT_NBT_Tank(ID++, "fluidtankEx.tier.09", "MAX Voltage Fluid Tank", 9).getStackForm(1L)); + + + } } |