diff options
Diffstat (limited to 'src/main/java/gregtech/common/blocks')
18 files changed, 1217 insertions, 1159 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java index 6cb65158c6..2285d3f2af 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java @@ -29,10 +29,10 @@ public class GT_Block_Casings2 GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Assembler Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Pump Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Motor Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Bronze Pipe Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Steel Pipe Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Titanium Pipe Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Tungstensteel Pipe Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Bronze Pipe Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Steel Pipe Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Titanium Pipe Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Tungstensteel Pipe Casing"); ItemList.Casing_SolidSteel.set(new ItemStack(this, 1, 0)); ItemList.Casing_FrostProof.set(new ItemStack(this, 1, 1)); ItemList.Casing_Gearbox_Bronze.set(new ItemStack(this, 1, 2)); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java index 5cc1067e4c..428369e569 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java @@ -1,88 +1,88 @@ -package gregtech.common.blocks; - -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.objects.GT_CopiedBlockTexture; -import gregtech.api.util.GT_LanguageManager; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -public class GT_Block_Casings3 - extends GT_Block_Casings_Abstract { - public GT_Block_Casings3() { - super(GT_Item_Casings3.class, "gt.blockcasings3", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.CASING_BLOCKS[(i + 32)] = new GT_CopiedBlockTexture(this, 6, i); - } - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Yellow Stripes Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Yellow Stripes Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Radioactive Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Bio Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Explosion Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Fire Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Acid Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Magic Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Frost Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Noise Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Grate Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Vent Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Radiation Proof Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Bronze Firebox Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Steel Firebox Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Tungstensteel Firebox Casing"); - ItemList.Casing_Stripes_A.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Stripes_B.set(new ItemStack(this, 1, 1)); - ItemList.Casing_RadioactiveHazard.set(new ItemStack(this, 1, 2)); - ItemList.Casing_BioHazard.set(new ItemStack(this, 1, 3)); - ItemList.Casing_ExplosionHazard.set(new ItemStack(this, 1, 4)); - ItemList.Casing_FireHazard.set(new ItemStack(this, 1, 5)); - ItemList.Casing_AcidHazard.set(new ItemStack(this, 1, 6)); - ItemList.Casing_MagicHazard.set(new ItemStack(this, 1, 7)); - ItemList.Casing_FrostHazard.set(new ItemStack(this, 1, 8)); - ItemList.Casing_NoiseHazard.set(new ItemStack(this, 1, 9)); - ItemList.Casing_Grate.set(new ItemStack(this, 1, 10)); - ItemList.Casing_Vent.set(new ItemStack(this, 1, 11)); - ItemList.Casing_RadiationProof.set(new ItemStack(this, 1, 12)); - ItemList.Casing_Firebox_Bronze.set(new ItemStack(this, 1, 13)); - ItemList.Casing_Firebox_Steel.set(new ItemStack(this, 1, 14)); - ItemList.Casing_Firebox_TungstenSteel.set(new ItemStack(this, 1, 15)); - } - - public IIcon getIcon(int aSide, int aMeta) { - switch (aMeta) { - case 0: - return Textures.BlockIcons.MACHINE_CASING_STRIPES_A.getIcon(); - case 1: - return Textures.BlockIcons.MACHINE_CASING_STRIPES_B.getIcon(); - case 2: - return Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); - case 3: - return Textures.BlockIcons.MACHINE_CASING_BIOHAZARD.getIcon(); - case 4: - return Textures.BlockIcons.MACHINE_CASING_EXPLOSIONHAZARD.getIcon(); - case 5: - return Textures.BlockIcons.MACHINE_CASING_FIREHAZARD.getIcon(); - case 6: - return Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD.getIcon(); - case 7: - return Textures.BlockIcons.MACHINE_CASING_MAGICHAZARD.getIcon(); - case 8: - return Textures.BlockIcons.MACHINE_CASING_FROSTHAZARD.getIcon(); - case 9: - return Textures.BlockIcons.MACHINE_CASING_NOISEHAZARD.getIcon(); - case 10: - return Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon(); - case 11: - return Textures.BlockIcons.MACHINE_CASING_VENT.getIcon(); - case 12: - return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); - case 13: - return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() : Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); - case 14: - return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - case 15: - return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - } - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - } -} +package gregtech.common.blocks;
+
+import gregtech.api.enums.ItemList;
+import gregtech.api.enums.Textures;
+import gregtech.api.objects.GT_CopiedBlockTexture;
+import gregtech.api.util.GT_LanguageManager;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+
+public class GT_Block_Casings3
+ extends GT_Block_Casings_Abstract {
+ public GT_Block_Casings3() {
+ super(GT_Item_Casings3.class, "gt.blockcasings3", GT_Material_Casings.INSTANCE);
+ for (byte i = 0; i < 16; i = (byte) (i + 1)) {
+ Textures.BlockIcons.CASING_BLOCKS[(i + 32)] = new GT_CopiedBlockTexture(this, 6, i);
+ }
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Yellow Stripes Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Yellow Stripes Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Radioactive Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Bio Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Explosion Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Fire Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Acid Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Magic Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Frost Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Noise Hazard Sign Block");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Grate Machine Casing");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Filter Machine Casing");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Radiation Proof Machine Casing");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Bronze Firebox Casing");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Steel Firebox Casing");
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Tungstensteel Firebox Casing");
+ ItemList.Casing_Stripes_A.set(new ItemStack(this, 1, 0));
+ ItemList.Casing_Stripes_B.set(new ItemStack(this, 1, 1));
+ ItemList.Casing_RadioactiveHazard.set(new ItemStack(this, 1, 2));
+ ItemList.Casing_BioHazard.set(new ItemStack(this, 1, 3));
+ ItemList.Casing_ExplosionHazard.set(new ItemStack(this, 1, 4));
+ ItemList.Casing_FireHazard.set(new ItemStack(this, 1, 5));
+ ItemList.Casing_AcidHazard.set(new ItemStack(this, 1, 6));
+ ItemList.Casing_MagicHazard.set(new ItemStack(this, 1, 7));
+ ItemList.Casing_FrostHazard.set(new ItemStack(this, 1, 8));
+ ItemList.Casing_NoiseHazard.set(new ItemStack(this, 1, 9));
+ ItemList.Casing_Grate.set(new ItemStack(this, 1, 10));
+ ItemList.Casing_Vent.set(new ItemStack(this, 1, 11));
+ ItemList.Casing_RadiationProof.set(new ItemStack(this, 1, 12));
+ ItemList.Casing_Firebox_Bronze.set(new ItemStack(this, 1, 13));
+ ItemList.Casing_Firebox_Steel.set(new ItemStack(this, 1, 14));
+ ItemList.Casing_Firebox_TungstenSteel.set(new ItemStack(this, 1, 15));
+ }
+
+ public IIcon getIcon(int aSide, int aMeta) {
+ switch (aMeta) {
+ case 0:
+ return Textures.BlockIcons.MACHINE_CASING_STRIPES_A.getIcon();
+ case 1:
+ return Textures.BlockIcons.MACHINE_CASING_STRIPES_B.getIcon();
+ case 2:
+ return Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon();
+ case 3:
+ return Textures.BlockIcons.MACHINE_CASING_BIOHAZARD.getIcon();
+ case 4:
+ return Textures.BlockIcons.MACHINE_CASING_EXPLOSIONHAZARD.getIcon();
+ case 5:
+ return Textures.BlockIcons.MACHINE_CASING_FIREHAZARD.getIcon();
+ case 6:
+ return Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD.getIcon();
+ case 7:
+ return Textures.BlockIcons.MACHINE_CASING_MAGICHAZARD.getIcon();
+ case 8:
+ return Textures.BlockIcons.MACHINE_CASING_FROSTHAZARD.getIcon();
+ case 9:
+ return Textures.BlockIcons.MACHINE_CASING_NOISEHAZARD.getIcon();
+ case 10:
+ return Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon();
+ case 11:
+ return Textures.BlockIcons.MACHINE_CASING_VENT.getIcon();
+ case 12:
+ return Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon();
+ case 13:
+ return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() : Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon();
+ case 14:
+ return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
+ case 15:
+ return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon();
+ }
+ return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon();
+ }
+}
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java index 3c3535e4da..639cbf5d6f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -23,20 +23,22 @@ public class GT_Block_Casings4 for (byte i = 0; i < 16; i = (byte) (i + 1)) { Textures.BlockIcons.CASING_BLOCKS[(i + 48)] = new GT_CopiedBlockTexture(this, 6, i); } - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Robust Tungstensteel Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Stable Titanium Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Robust Tungstensteel Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Stable Titanium Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Titanium Firebox Casing"); // GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Fusion Casing"); // GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Fusion Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Fusion Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Fusion Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Fusion Casing MK II"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Fusion Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Fusion Coil Block"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Fusion Machine Casing MK II"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Turbine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Stainless Steel Turbine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Titanium Turbine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Tungstensteel Turbine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Engine Intake Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Chemically Inert Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "PTFE Pipe Machine Casing"); ItemList.Casing_RobustTungstenSteel.set(new ItemStack(this, 1, 0)); ItemList.Casing_CleanStainlessSteel.set(new ItemStack(this, 1, 1)); @@ -50,6 +52,8 @@ public class GT_Block_Casings4 ItemList.Casing_Turbine2.set(new ItemStack(this, 1, 11)); ItemList.Casing_Turbine3.set(new ItemStack(this, 1, 12)); ItemList.Casing_EngineIntake.set(new ItemStack(this, 1, 13)); + ItemList.Casing_Chemically_Inert.set(new ItemStack(this, 1, 14)); + ItemList.Casing_Pipe_Polytetrafluoroethylene.set(new ItemStack(this, 1, 15)); } public IIcon getIcon(int aSide, int aMeta) { @@ -83,9 +87,9 @@ public class GT_Block_Casings4 case 13: return Textures.BlockIcons.MACHINE_CASING_ENGINE_INTAKE.getIcon(); case 14: - return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + return Textures.BlockIcons.MACHINE_CASING_CHEMICALLY_INERT.getIcon(); case 15: - return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + return Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE.getIcon(); } return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java index 1909651c89..8b03a10b29 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java @@ -1,121 +1,122 @@ -package gregtech.common.blocks; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.items.GT_Generic_Block; -import gregtech.api.util.GT_LanguageManager; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import java.util.List; -import java.util.Random; - -public abstract class GT_Block_Casings_Abstract - extends GT_Generic_Block { - public GT_Block_Casings_Abstract(Class<? extends ItemBlock> aItemClass, String aName, Material aMaterial) { - super(aItemClass, aName, aMaterial); - setStepSound(soundTypeMetal); - setCreativeTab(GregTech_API.TAB_GREGTECH); - GregTech_API.registerMachineBlock(this, -1); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); - } - - public String getHarvestTool(int aMeta) { - return "wrench"; - } - - public int getHarvestLevel(int aMeta) { - return 2; - } - - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); - } - - public float getExplosionResistance(Entity aTNT) { - return Blocks.iron_block.getExplosionResistance(aTNT); - } - - protected boolean canSilkHarvest() { - return false; - } - - public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - public String getUnlocalizedName() { - return this.mUnlocalizedName; - } - - public String getLocalizedName() { - return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); - } - - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return true; - } - - public boolean renderAsNormalBlock() { - return true; - } - - public boolean isOpaqueCube() { - return true; - } - - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { - return false; - } - - public int damageDropped(int par1) { - return par1; - } - - public int getDamageValue(World par1World, int par2, int par3, int par4) { - return par1World.getBlockMetadata(par2, par3, par4); - } - - public int quantityDropped(Random par1Random) { - return 1; - } - - public Item getItemDropped(int par1, Random par2Random, int par3) { - return Item.getItemFromBlock(this); - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) { - } - - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { - for (int i = 0; i < 16; i++) { - aList.add(new ItemStack(aItem, 1, i)); - } - } -} +package gregtech.common.blocks;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gregtech.api.items.GT_Generic_Block;
+import gregtech.api.util.GT_LanguageManager;
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+import java.util.List;
+import java.util.Random;
+
+public abstract class GT_Block_Casings_Abstract
+ extends GT_Generic_Block {
+ public GT_Block_Casings_Abstract(Class<? extends ItemBlock> aItemClass, String aName, Material aMaterial) {
+ super(aItemClass, aName, aMaterial);
+ setStepSound(soundTypeMetal);
+ setCreativeTab(GregTech_API.TAB_GREGTECH);
+ GregTech_API.registerMachineBlock(this, -1);
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this");
+ }
+
+ public String getHarvestTool(int aMeta) {
+ return "wrench";
+ }
+
+ public int getHarvestLevel(int aMeta) {
+ return 2;
+ }
+
+ public float getBlockHardness(World aWorld, int aX, int aY, int aZ) {
+ return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ);
+ }
+
+ public float getExplosionResistance(Entity aTNT) {
+ return Blocks.iron_block.getExplosionResistance(aTNT);
+ }
+
+ protected boolean canSilkHarvest() {
+ return false;
+ }
+
+ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+
+ public String getUnlocalizedName() {
+ return this.mUnlocalizedName;
+ }
+
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal(this.mUnlocalizedName + ".name");
+ }
+
+ public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) {
+ return false;
+ }
+
+ public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) {
+ return true;
+ }
+
+ public boolean renderAsNormalBlock() {
+ return true;
+ }
+
+ public boolean isOpaqueCube() {
+ return true;
+ }
+
+ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) {
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+
+ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
+ return false;
+ }
+
+ public int damageDropped(int par1) {
+ return par1;
+ }
+
+ public int getDamageValue(World par1World, int par2, int par3, int par4) {
+ return par1World.getBlockMetadata(par2, par3, par4);
+ }
+
+ public int quantityDropped(Random par1Random) {
+ return 1;
+ }
+
+ public Item getItemDropped(int par1, Random par2Random, int par3) {
+ return Item.getItemFromBlock(this);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister aIconRegister) {
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) {
+ for (int i = 0; i < 16; i++) {
+ ItemStack aStack = new ItemStack(aItem, 1, i);
+ if (!aStack.getDisplayName().contains(".name")) aList.add(aStack);
+ }
+ }
+}
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index 419a7ed596..9472374a7c 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -1,531 +1,531 @@ -package gregtech.common.blocks; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IDebugableBlock; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -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.BaseTileEntity; -import gregtech.api.objects.XSTR; -import gregtech.api.util.GT_BaseCrop; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.common.render.GT_Renderer_Block; -import net.minecraft.block.Block; -import net.minecraft.block.ITileEntityProvider; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; -import net.minecraft.util.StatCollector; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -public class GT_Block_Machines - extends GT_Generic_Block - implements IDebugableBlock, ITileEntityProvider { - public static ThreadLocal<IGregTechTileEntity> mTemporaryTileEntity = new ThreadLocal(); - - public GT_Block_Machines() { - super(GT_Item_Machines.class, "gt.blockmachines", new GT_Material_Machines()); - GregTech_API.registerMachineBlock(this, -1); - setHardness(1.0F); - setResistance(10.0F); - setStepSound(soundTypeMetal); - setCreativeTab(GregTech_API.TAB_GREGTECH); - this.isBlockContainer = true; - } - - public String getHarvestTool(int aMeta) { - switch (aMeta / 4) { - case 0: - return "wrench"; - case 1: - return "wrench"; - case 2: - return "cutter"; - case 3: - return "axe"; - } - return "wrench"; - } - - public int getHarvestLevel(int aMeta) { - return aMeta % 4; - } - - protected boolean canSilkHarvest() { - return false; - } - - public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseTileEntity)) { - ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); - } - } - - public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { - super.onBlockAdded(aWorld, aX, aY, aZ); - if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - public String getUnlocalizedName() { - return "gt.blockmachines"; - } - - public String getLocalizedName() { - return StatCollector.translateToLocal(getUnlocalizedName() + ".name"); - } - - public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return 0; - } - - public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0) ? 100 : 0; - } - - public int getRenderType() { - if (GT_Renderer_Block.INSTANCE == null) { - return super.getRenderType(); - } - return GT_Renderer_Block.INSTANCE.mRenderID; - } - - public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { - return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); - } - - public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); - } - - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean canConnectRedstone(IBlockAccess var1, int var2, int var3, int var4, int var5) { - return true; - } - - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean hasTileEntity(int aMeta) { - return true; - } - - public boolean hasComparatorInputOverride() { - return true; - } - - public boolean renderAsNormalBlock() { - return false; - } - - public boolean canProvidePower() { - return true; - } - - public boolean isOpaqueCube() { - return false; - } - - public TileEntity createNewTileEntity(World aWorld, int aMeta) { - return createTileEntity(aWorld, aMeta); - } - - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - public IIcon getIcon(int aSide, int aMeta) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { - super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity != null ? tTileEntity.receiveClientEvent(aData1, aData2) : false; - } - - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - ((IGregTechTileEntity) tTileEntity).addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - return; - } - super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - } - - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) - { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override //THIS - public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { - TileEntity tTileEntity = blockAccess.getTileEntity(aX,aY,aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - AxisAlignedBB bbb=((IGregTechTileEntity)tTileEntity).getCollisionBoundingBoxFromPool(((IGregTechTileEntity)tTileEntity).getWorld(), 0, 0, 0); - minX=bbb.minX; - minY=bbb.minY; - minZ=bbb.minZ; - maxX=bbb.maxX; - maxY=bbb.maxY; - maxZ=bbb.maxZ; - return; - } - super.setBlockBoundsBasedOnState(blockAccess,aX,aY,aZ); - } - - @Override - public void setBlockBoundsForItemRender() { - super.setBlockBounds(0,0,0,1,1,1); - } - - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - return; - } - super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) { - if (GregTech_API.sPostloadFinished) { - GT_Log.out.println("GT_Mod: Setting up Icon Register for Blocks"); - GregTech_API.sBlockIcons = aIconRegister; - - GT_Log.out.println("GT_Mod: Registering MetaTileEntity specific Textures"); - try { - for (IMetaTileEntity tMetaTileEntity : GregTech_API.METATILEENTITIES) { - if (tMetaTileEntity != null) { - tMetaTileEntity.registerIcons(aIconRegister); - } - } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} - GT_Log.out.println("GT_Mod: Registering Crop specific Textures"); - try { - for (GT_BaseCrop tCrop : GT_BaseCrop.sCropList) { - tCrop.registerSprites(aIconRegister); - } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - GT_Log.out.println("GT_Mod: Starting Block Icon Load Phase"); - System.out.println("GT_Mod: Starting Block Icon Load Phase"); - try { - for (Runnable tRunnable : GregTech_API.sGTBlockIconload) { - tRunnable.run(); - } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} - GT_Log.out.println("GT_Mod: Finished Block Icon Load Phase"); - System.out.println("GT_Mod: Finished Block Icon Load Phase"); - } - } - - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return super.getBlockHardness(aWorld, aX, aY, aZ); - } - - 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))) { - return -1.0F; - } - return super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); - } - - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, float par2, float par3) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return false; - } - if(aPlayer.isSneaking()){ - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if(tCurrentItem!=null){ - if(!GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)){ - return false; - } - }else {return false;} - } - if ((tTileEntity instanceof IGregTechTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { - return false; - } - if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) { - return true; - } - return ((IGregTechTileEntity) tTileEntity).onRightclick(aPlayer, (byte) aSide, par1, par2, par3); - } - return false; - } - - public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { - ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); - } - } - - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getMetaTileID(); - } - return 0; - } - - 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(); - } - super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); - } - - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; - Random tRandom = new XSTR(); - mTemporaryTileEntity.set(tGregTechTileEntity); - for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { - ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); - if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) { - EntityItem tItemEntity = new EntityItem(aWorld, aX + tRandom.nextFloat() * 0.8F + 0.1F, aY + tRandom.nextFloat() * 0.8F + 0.1F, aZ + tRandom.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); - if (tItem.hasTagCompound()) { - tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); - } - tItemEntity.motionX = (tRandom.nextGaussian() * 0.0500000007450581D); - tItemEntity.motionY = (tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D); - tItemEntity.motionZ = (tRandom.nextGaussian() * 0.0500000007450581D); - aWorld.spawnEntityInWorld(tItemEntity); - tItem.stackSize = 0; - tGregTechTileEntity.setInventorySlotContents(i, null); - } - } - } - super.breakBlock(aWorld, aX, aY, aZ, par5, par6); - aWorld.removeTileEntity(aX, aY, aZ); - } - - public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getDrops(); - } - return mTemporaryTileEntity.get() == null ? new ArrayList() : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops(); - } - - public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide); - } - return 0; - } - - public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if ((aSide < 0) || (aSide > 5)) { - return 0; - } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); - } - return 0; - } - - public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if ((aSide < 0) || (aSide > 5)) { - return 0; - } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); - } - return 0; - } - - public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { - 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(); - } - } else { - super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7); - } - } - } - - public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { - if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { - return true; - } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null) { - if ((tTileEntity instanceof BaseMetaTileEntity)) { - return true; - } - if (((tTileEntity instanceof BaseMetaPipeEntity)) && ((((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0)) { - return true; - } - if (((tTileEntity instanceof ICoverable)) && (((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0)) { - return true; - } - } - return false; - } - - public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return 0; - } - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getLightOpacity(); - } - return aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0; - } - - 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(); - } - return 0; - } - - public TileEntity createTileEntity(World aWorld, int aMeta) { - if (aMeta < 4) { - return GregTech_API.constructBaseMetaTileEntity(); - } - return new BaseMetaPipeEntity(); - } - - public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { - return ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6); - } - return 10.0F; - } - - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { - for (int i = 1; i < GregTech_API.METATILEENTITIES.length; i++) { - if (GregTech_API.METATILEENTITIES[i] != null) { - par3List.add(new ItemStack(par1, 1, i)); - } - } - } - - public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return; - } - if ((tTileEntity instanceof IGregTechTileEntity)) { - IGregTechTileEntity var6 = (IGregTechTileEntity) tTileEntity; - if (aPlayer == null) { - var6.setFrontFacing((byte) 1); - } else { - int var7 = MathHelper.floor_double(aPlayer.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3; - int var8 = Math.round(aPlayer.rotationPitch); - if ((var8 >= 65) && (var6.isValidFacing((byte) 1))) { - var6.setFrontFacing((byte) 1); - } else if ((var8 <= -65) && (var6.isValidFacing((byte) 0))) { - var6.setFrontFacing((byte) 0); - } else { - switch (var7) { - case 0: - var6.setFrontFacing((byte) 2); - break; - case 1: - var6.setFrontFacing((byte) 5); - break; - case 2: - var6.setFrontFacing((byte) 3); - break; - case 3: - var6.setFrontFacing((byte) 4); - } - } - } - } - } - - 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 BaseMetaPipeEntity)) { - return ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); - } - return null; - } - - public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) ((aColor ^ 0xFFFFFFFF) & 0xF)) { - return false; - } - ((IGregTechTileEntity) tTileEntity).setColorization((byte) ((aColor ^ 0xFFFFFFFF) & 0xF)); - return true; - } - return false; - } -} +package gregtech.common.blocks;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IDebugableBlock;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+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.BaseTileEntity;
+import gregtech.api.objects.XSTR;
+import gregtech.api.util.GT_BaseCrop;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.render.GT_Renderer_Block;
+import net.minecraft.block.Block;
+import net.minecraft.block.ITileEntityProvider;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.Explosion;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+public class GT_Block_Machines
+ extends GT_Generic_Block
+ implements IDebugableBlock, ITileEntityProvider {
+ public static ThreadLocal<IGregTechTileEntity> mTemporaryTileEntity = new ThreadLocal();
+
+ public GT_Block_Machines() {
+ super(GT_Item_Machines.class, "gt.blockmachines", new GT_Material_Machines());
+ GregTech_API.registerMachineBlock(this, -1);
+ setHardness(1.0F);
+ setResistance(10.0F);
+ setStepSound(soundTypeMetal);
+ setCreativeTab(GregTech_API.TAB_GREGTECH);
+ this.isBlockContainer = true;
+ }
+
+ public String getHarvestTool(int aMeta) {
+ switch (aMeta / 4) {
+ case 0:
+ return "wrench";
+ case 1:
+ return "wrench";
+ case 2:
+ return "cutter";
+ case 3:
+ return "axe";
+ }
+ return "wrench";
+ }
+
+ public int getHarvestLevel(int aMeta) {
+ return aMeta % 4;
+ }
+
+ protected boolean canSilkHarvest() {
+ return false;
+ }
+
+ public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if ((tTileEntity instanceof BaseTileEntity)) {
+ ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ);
+ }
+ }
+
+ public void onBlockAdded(World aWorld, int aX, int aY, int aZ) {
+ super.onBlockAdded(aWorld, aX, aY, aZ);
+ if (GregTech_API.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ }
+ }
+
+ public String getUnlocalizedName() {
+ return "gt.blockmachines";
+ }
+
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal(getUnlocalizedName() + ".name");
+ }
+
+ public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) {
+ return 0;
+ }
+
+ public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) {
+ return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0) ? 100 : 0;
+ }
+
+ public int getRenderType() {
+ if (GT_Renderer_Block.INSTANCE == null) {
+ return super.getRenderType();
+ }
+ return GT_Renderer_Block.INSTANCE.mRenderID;
+ }
+
+ public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) {
+ return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0);
+ }
+
+ public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) {
+ return (GregTech_API.sMachineFlammable) && (aWorld.getBlockMetadata(aX, aY, aZ) == 0);
+ }
+
+ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) {
+ return false;
+ }
+
+ public boolean canConnectRedstone(IBlockAccess var1, int var2, int var3, int var4, int var5) {
+ return true;
+ }
+
+ public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) {
+ return false;
+ }
+
+ public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) {
+ return false;
+ }
+
+ public boolean hasTileEntity(int aMeta) {
+ return true;
+ }
+
+ public boolean hasComparatorInputOverride() {
+ return true;
+ }
+
+ public boolean renderAsNormalBlock() {
+ return false;
+ }
+
+ public boolean canProvidePower() {
+ return true;
+ }
+
+ public boolean isOpaqueCube() {
+ return false;
+ }
+
+ public TileEntity createNewTileEntity(World aWorld, int aMeta) {
+ return createTileEntity(aWorld, aMeta);
+ }
+
+ public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) {
+ return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon();
+ }
+
+ public IIcon getIcon(int aSide, int aMeta) {
+ return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon();
+ }
+
+ public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) {
+ super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2);
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ return tTileEntity != null ? tTileEntity.receiveClientEvent(aData1, aData2) : false;
+ }
+
+ public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) {
+ ((IGregTechTileEntity) tTileEntity).addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
+ return;
+ }
+ super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider);
+ }
+
+ public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) {
+ return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ }
+ return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ)
+ {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) {
+ return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ }
+ return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ);
+ }
+
+ @Override //THIS
+ public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) {
+ TileEntity tTileEntity = blockAccess.getTileEntity(aX,aY,aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) {
+ AxisAlignedBB bbb=((IGregTechTileEntity)tTileEntity).getCollisionBoundingBoxFromPool(((IGregTechTileEntity)tTileEntity).getWorld(), 0, 0, 0);
+ minX=bbb.minX;
+ minY=bbb.minY;
+ minZ=bbb.minZ;
+ maxX=bbb.maxX;
+ maxY=bbb.maxY;
+ maxZ=bbb.maxZ;
+ return;
+ }
+ super.setBlockBoundsBasedOnState(blockAccess,aX,aY,aZ);
+ }
+
+ @Override
+ public void setBlockBoundsForItemRender() {
+ super.setBlockBounds(0,0,0,1,1,1);
+ }
+
+ public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) {
+ ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider);
+ return;
+ }
+ super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister aIconRegister) {
+ if (GregTech_API.sPostloadFinished) {
+ GT_Log.out.println("GT_Mod: Setting up Icon Register for Blocks");
+ GregTech_API.sBlockIcons = aIconRegister;
+
+ GT_Log.out.println("GT_Mod: Registering MetaTileEntity specific Textures");
+ try {
+ for (IMetaTileEntity tMetaTileEntity : GregTech_API.METATILEENTITIES) {
+ if (tMetaTileEntity != null) {
+ tMetaTileEntity.registerIcons(aIconRegister);
+ }
+ }
+ } catch (Throwable e) {e.printStackTrace(GT_Log.err);}
+ GT_Log.out.println("GT_Mod: Registering Crop specific Textures");
+ try {
+ for (GT_BaseCrop tCrop : GT_BaseCrop.sCropList) {
+ tCrop.registerSprites(aIconRegister);
+ }
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+ GT_Log.out.println("GT_Mod: Starting Block Icon Load Phase");
+ System.out.println("GT_Mod: Starting Block Icon Load Phase");
+ try {
+ for (Runnable tRunnable : GregTech_API.sGTBlockIconload) {
+ tRunnable.run();
+ }
+ } catch (Throwable e) {e.printStackTrace(GT_Log.err);}
+ GT_Log.out.println("GT_Mod: Finished Block Icon Load Phase");
+ System.out.println("GT_Mod: Finished Block Icon Load Phase");
+ }
+ }
+
+ public float getBlockHardness(World aWorld, int aX, int aY, int aZ) {
+ return super.getBlockHardness(aWorld, aX, aY, aZ);
+ }
+
+ 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))) {
+ return -1.0F;
+ }
+ return super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ);
+ }
+
+ public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, float par2, float par3) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (tTileEntity == null) {
+ return false;
+ }
+ if(aPlayer.isSneaking()){
+ ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem();
+ if(tCurrentItem!=null){
+ if(!GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList)){
+ return false;
+ }
+ }else {return false;}
+ }
+ if ((tTileEntity instanceof IGregTechTileEntity)) {
+ if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) {
+ return false;
+ }
+ if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) {
+ return true;
+ }
+ return ((IGregTechTileEntity) tTileEntity).onRightclick(aPlayer, (byte) aSide, par1, par2, par3);
+ }
+ return false;
+ }
+
+ public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity))) {
+ ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer);
+ }
+ }
+
+ public int getDamageValue(World aWorld, int aX, int aY, int aZ) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if ((tTileEntity instanceof IGregTechTileEntity)) {
+ return ((IGregTechTileEntity) tTileEntity).getMetaTileID();
+ }
+ return 0;
+ }
+
+ 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();
+ }
+ super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion);
+ }
+
+ public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) {
+ GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ);
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if ((tTileEntity instanceof IGregTechTileEntity)) {
+ IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity;
+ Random tRandom = new XSTR();
+ mTemporaryTileEntity.set(tGregTechTileEntity);
+ for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) {
+ ItemStack tItem = tGregTechTileEntity.getStackInSlot(i);
+ if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) {
+ EntityItem tItemEntity = new EntityItem(aWorld, aX + tRandom.nextFloat() * 0.8F + 0.1F, aY + tRandom.nextFloat() * 0.8F + 0.1F, aZ + tRandom.nextFloat() * 0.8F + 0.1F, new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage()));
+ if (tItem.hasTagCompound()) {
+ tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy());
+ }
+ tItemEntity.motionX = (tRandom.nextGaussian() * 0.0500000007450581D);
+ tItemEntity.motionY = (tRandom.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D);
+ tItemEntity.motionZ = (tRandom.nextGaussian() * 0.0500000007450581D);
+ aWorld.spawnEntityInWorld(tItemEntity);
+ tItem.stackSize = 0;
+ tGregTechTileEntity.setInventorySlotContents(i, null);
+ }
+ }
+ }
+ super.breakBlock(aWorld, aX, aY, aZ, par5, par6);
+ aWorld.removeTileEntity(aX, aY, aZ);
+ }
+
+ public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if ((tTileEntity instanceof IGregTechTileEntity)) {
+ return ((IGregTechTileEntity) tTileEntity).getDrops();
+ }
+ return mTemporaryTileEntity.get() == null ? new ArrayList() : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops();
+ }
+
+ public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity))) {
+ return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide);
+ }
+ return 0;
+ }
+
+ public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) {
+ if ((aSide < 0) || (aSide > 5)) {
+ return 0;
+ }
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity))) {
+ return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide));
+ }
+ return 0;
+ }
+
+ public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) {
+ if ((aSide < 0) || (aSide > 5)) {
+ return 0;
+ }
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity))) {
+ return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide));
+ }
+ return 0;
+ }
+
+ public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) {
+ 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();
+ }
+ } else {
+ super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, par5, chance, par7);
+ }
+ }
+ }
+
+ public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) {
+ if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) {
+ return true;
+ }
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (tTileEntity != null) {
+ if ((tTileEntity instanceof BaseMetaTileEntity)) {
+ return true;
+ }
+ if (((tTileEntity instanceof BaseMetaPipeEntity)) && ((((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0)) {
+ return true;
+ }
+ if (((tTileEntity instanceof ICoverable)) && (((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (tTileEntity == null) {
+ return 0;
+ }
+ if ((tTileEntity instanceof IGregTechTileEntity)) {
+ return ((IGregTechTileEntity) tTileEntity).getLightOpacity();
+ }
+ return aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0;
+ }
+
+ 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();
+ }
+ return 0;
+ }
+
+ public TileEntity createTileEntity(World aWorld, int aMeta) {
+ if (aMeta < 4) {
+ return GregTech_API.constructBaseMetaTileEntity();
+ }
+ return new BaseMetaPipeEntity();
+ }
+
+ public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (((tTileEntity instanceof IGregTechTileEntity))) {
+ return ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6);
+ }
+ return 10.0F;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
+ for (int i = 1; i < GregTech_API.METATILEENTITIES.length; i++) {
+ if (GregTech_API.METATILEENTITIES[i] != null) {
+ par3List.add(new ItemStack(par1, 1, i));
+ }
+ }
+ }
+
+ public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if (tTileEntity == null) {
+ return;
+ }
+ if ((tTileEntity instanceof IGregTechTileEntity)) {
+ IGregTechTileEntity var6 = (IGregTechTileEntity) tTileEntity;
+ if (aPlayer == null) {
+ var6.setFrontFacing((byte) 1);
+ } else {
+ int var7 = MathHelper.floor_double(aPlayer.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3;
+ int var8 = Math.round(aPlayer.rotationPitch);
+ if ((var8 >= 65) && (var6.isValidFacing((byte) 1))) {
+ var6.setFrontFacing((byte) 1);
+ } else if ((var8 <= -65) && (var6.isValidFacing((byte) 0))) {
+ var6.setFrontFacing((byte) 0);
+ } else {
+ switch (var7) {
+ case 0:
+ var6.setFrontFacing((byte) 2);
+ break;
+ case 1:
+ var6.setFrontFacing((byte) 5);
+ break;
+ case 2:
+ var6.setFrontFacing((byte) 3);
+ break;
+ case 3:
+ var6.setFrontFacing((byte) 4);
+ }
+ }
+ }
+ }
+ }
+
+ 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 BaseMetaPipeEntity)) {
+ return ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel);
+ }
+ return null;
+ }
+
+ public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) {
+ TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
+ if ((tTileEntity instanceof IGregTechTileEntity)) {
+ if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) ((aColor ^ 0xFFFFFFFF) & 0xF)) {
+ return false;
+ }
+ ((IGregTechTileEntity) tTileEntity).setColorization((byte) ((aColor ^ 0xFFFFFFFF) & 0xF));
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java index f3347772ce..2f54c9c415 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java @@ -14,18 +14,23 @@ public class GT_Block_Metal extends GT_Block_Storage { public Materials[] mMats; public OrePrefixes mPrefix; public IIconContainer[] mBlockIcons; + public boolean mHideBlocks; public GT_Block_Metal(String aName, Materials[] aMats, OrePrefixes aPrefix, IIconContainer[] aBlockIcons) { super(GT_Item_Storage.class, aName, Material.iron); mMats = aMats; mPrefix = aPrefix; mBlockIcons = aBlockIcons; + mHideBlocks = Loader.isModLoaded("NotEnoughItems"); + for (int i = 0; i < aMats.length; i++) { - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + i + ".name", "Block of " + aMats[i].mDefaultLocalName); - GT_OreDictUnificator.registerOre(aPrefix, aMats[i], new ItemStack(this, 1, i)); + if (aMats[i].mMetaItemSubID > 0 && aMats[i].mHasParentMod) { + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + i + ".name", "Block of " + aMats[i].mDefaultLocalName); + GT_OreDictUnificator.registerOre(aPrefix, aMats[i], new ItemStack(this, 1, i)); + } } - if(aMats.length<16 && Loader.isModLoaded("NotEnoughItems")){ - for( int i = aMats.length;i<16;i++)codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i)); + if (aMats.length<16 && Loader.isModLoaded("NotEnoughItems")) { + for (int i = aMats.length; i < 16; i++) codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i)); } } @@ -35,5 +40,4 @@ public class GT_Block_Metal extends GT_Block_Storage { } return null; } - } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java index 84336378c5..70200e5199 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java @@ -27,6 +27,20 @@ public class GT_Block_Ores extends GT_Block_Ores_Abstract { } @Override + public int getBaseBlockHarvestLevel(int aMeta) { + switch (aMeta) { + case 3: + case 4:return 3; + case 0: + case 1: + case 2: + case 5: + case 6: + default:return 0; + } + } + + @Override public Block getDroppedBlock() { return GregTech_API.sBlockOres1; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java index d0eaaae08d..4b61da0f3f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java @@ -70,6 +70,10 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements } } + public int getBaseBlockHarvestLevel(int aMeta) { + return 0; + } + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { if (!FUCKING_LOCK) { FUCKING_LOCK = true; @@ -93,28 +97,28 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements } public String getLocalizedName(Materials aMaterial) { - switch (aMaterial) { - case InfusedAir: - case InfusedDull: - case InfusedEarth: - case InfusedEntropy: - case InfusedFire: - case InfusedOrder: - case InfusedVis: - case InfusedWater: + switch (aMaterial.mName) { + case "InfusedAir": + case "InfusedDull": + case "InfusedEarth": + case "InfusedEntropy": + case "InfusedFire": + case "InfusedOrder": + case "InfusedVis": + case "InfusedWater": return aMaterial.mDefaultLocalName + " Infused Stone"; - case Vermiculite: - case Bentonite: - case Kaolinite: - case Talc: - case BasalticMineralSand: - case GraniticMineralSand: - case GlauconiteSand: - case CassiteriteSand: - case GarnetSand: - case QuartzSand: - case Pitchblende: - case FullersEarth: + case "Vermiculite": + case "Bentonite": + case "Kaolinite": + case "Talc": + case "BasalticMineralSand": + case "GraniticMineralSand": + case "GlauconiteSand": + case "CassiteriteSand": + case "GarnetSand": + case "QuartzSand": + case "Pitchblende": + case "FullersEarth": return aMaterial.mDefaultLocalName; default: return aMaterial.mDefaultLocalName + OrePrefixes.ore.mLocalizedMaterialPost; @@ -261,4 +265,4 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements } } } -} +}
\ No newline at end of file diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java index ac17e65b93..52c5710ae9 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java @@ -29,6 +29,11 @@ public class GT_Block_Ores_UB1 extends GT_Block_Ores_Abstract { } @Override + public int getBaseBlockHarvestLevel(int aMeta) { + return aUBBlock.getHarvestLevel(aMeta); + } + + @Override public Block getDroppedBlock() { return GregTech_API.sBlockOresUb1; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java index e4caa95db7..78526c84c5 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java @@ -29,6 +29,11 @@ public class GT_Block_Ores_UB2 extends GT_Block_Ores_Abstract { } @Override + public int getBaseBlockHarvestLevel(int aMeta) { + return aUBBlock.getHarvestLevel(aMeta); + } + + @Override public Block getDroppedBlock() { return GregTech_API.sBlockOresUb2; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java index 85721556a3..dc5e07a115 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java @@ -29,6 +29,11 @@ public class GT_Block_Ores_UB3 extends GT_Block_Ores_Abstract { } @Override + public int getBaseBlockHarvestLevel(int aMeta) { + return aUBBlock.getHarvestLevel(aMeta); + } + + @Override public Block getDroppedBlock() { return GregTech_API.sBlockOresUb3; } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java index caa8baed80..b4a068949a 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java @@ -8,19 +8,19 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.items.GT_Generic_Block; +import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.objects.ItemData; import gregtech.api.objects.MaterialStack; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; -import ic2.core.block.EntityIC2Explosive; -import ic2.core.block.EntityItnt; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityTNTPrimed; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -39,6 +39,9 @@ public class GT_Block_Reinforced extends GT_Generic_Block { public GT_Block_Reinforced(String aName) { super(GT_Item_Storage.class, aName, new GT_Material_Reinforced()); + for (byte i = 0; i < 16; i = (byte) (i + 1)) { + Textures.BlockIcons.CASING_BLOCKS[(i + 80)] = new GT_CopiedBlockTexture(this, 6, i); + } setStepSound(soundTypeStone); setCreativeTab(GregTech_API.TAB_GREGTECH); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Bronzeplate Reinforced Block"); @@ -51,7 +54,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Magic Solid Super Fuel"); ItemList.Block_BronzePlate.set(new ItemStack(this.setHardness(60.0f).setResistance(150.0f), 1, 0)); ItemList.Block_IridiumTungstensteel.set(new ItemStack(this.setHardness(200.0f).setResistance(600.0f), 1, 1)); - ItemList.Block_Plascrete.set(new ItemStack(this.setHardness(80.0f).setResistance(350.0f), 1, 2)); + ItemList.Block_Plascrete.set(new ItemStack(this.setHardness(40.0f).setResistance(100.0f), 1, 2)); ItemList.Block_TungstenSteelReinforced.set(new ItemStack(this.setHardness(100.0f).setResistance(400.0f), 1, 3)); ItemList.Block_BrittleCharcoal.set(new ItemStack(this.setHardness(0.5f).setResistance(8.0f), 1, 4)); ItemList.Block_Powderbarrel.set(new ItemStack(this.setHardness(2.5f).setResistance(2.0f), 1, 5)); @@ -62,7 +65,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { GT_ModHandler.addCraftingRecipe(ItemList.Block_IridiumTungstensteel.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hBP", 'P', OrePrefixes.plate.get(Materials.Iridium), 'B', ItemList.Block_TungstenSteelReinforced.get(1L, new Object[0])}); GT_OreDictUnificator.setItemData(ItemList.Block_IridiumTungstensteel.get(1, new Object[0]), new ItemData(new MaterialStack(Materials.Iridium, OrePrefixes.plate.mMaterialAmount), new MaterialStack(Materials.TungstenSteel, 2*OrePrefixes.plate.mMaterialAmount),new MaterialStack(Materials.Concrete, OrePrefixes.dust.mMaterialAmount))); GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(Items.coal, 1, 1), new Object[]{ItemList.Block_BrittleCharcoal.get(1, new Object[0])}); - GT_ModHandler.addCraftingRecipe(ItemList.Block_Powderbarrel.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WSW","GGG","WGW", 'W', OrePrefixes.plank.get(Materials.Wood), 'G', new ItemStack(Items.gunpowder,1),'S',new ItemStack(Items.string,1)}); + GT_ModHandler.addCraftingRecipe(ItemList.Block_Powderbarrel.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WSW","GGG","WGW", 'W', OrePrefixes.plate.get(Materials.Wood), 'G', new ItemStack(Items.gunpowder,1),'S',new ItemStack(Items.string,1)}); } @@ -73,6 +76,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { public int getHarvestLevel(int aMeta) { if (aMeta == 4||aMeta == 5 || aMeta == 6 || aMeta == 7) return 1; + if (aMeta == 2) return 2; return 4; } @@ -115,7 +119,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return 200.0F; } if (tMeta == 2) { - return 80.0F; + return 40.0F; } if (tMeta == 3) { return 100.0F; @@ -138,7 +142,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return 600.0F; } if (tMeta == 2) { - return 350.0F; + return 100.0F; } if (tMeta == 3) { return 400.0F; @@ -208,14 +212,10 @@ public class GT_Block_Reinforced extends GT_Generic_Block { public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { - if(world.getBlockMetadata(x, y, z)==5){ - EntityIC2Explosive entitytntprimed = getExplosionEntity(world, x, y, z, player == null ? null : player); - if (entitytntprimed == null) { - return false; - } - + if(!world.isRemote && world.getBlockMetadata(x, y, z)==5){ + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, x + 0.5F, y + 0.5F, z + 0.5F, player); world.spawnEntityInWorld(entitytntprimed); - world.playSoundAtEntity(entitytntprimed, "random.fuse", 1.0F, 1.0F); + world.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F); world.setBlockToAir(x, y, z); return false; @@ -223,15 +223,6 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return super.removedByPlayer(world, player, x, y, z); } - public EntityIC2Explosive getExplosionEntity(World world, int x, int y, int z, EntityLivingBase igniter) - { - EntityIC2Explosive ret; - ret = new EntityItnt(world, x + 0.5D, y + 0.5D, z + 0.5D); - ret.setIgniter(igniter); - - return ret; - } - public void onBlockAdded(World world, int x, int y, int z) { super.onBlockAdded(world, x, y, z); @@ -247,21 +238,19 @@ public class GT_Block_Reinforced extends GT_Generic_Block { } } - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - EntityIC2Explosive entitytntprimed = getExplosionEntity(world, x, y, z, explosion == null ? null : explosion.getExplosivePlacedBy()); - if (entitytntprimed == null) { - return; + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + if (!world.isRemote && world.getBlockMetadata(x, y, z)==5){ + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, x + 0.5F, y + 0.5F, z + 0.5F, explosion.getExplosivePlacedBy()); + entitytntprimed.fuse = (world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8); + world.spawnEntityInWorld(entitytntprimed); } - entitytntprimed.fuse = (world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8); - world.spawnEntityInWorld(entitytntprimed); + super.onBlockExploded(world, x, y, z, explosion); } public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) { if ((player.getCurrentEquippedItem() != null) && (player.getCurrentEquippedItem().getItem() == Items.flint_and_steel)&&par1World.getBlockMetadata(x, y, z)==5) { -// par1World.setBlockMetadataWithNotify(x, y, z, 6, 7); removedByPlayer(par1World, player, x, y, z); return true; @@ -276,7 +265,12 @@ public class GT_Block_Reinforced extends GT_Generic_Block { @SideOnly(Side.CLIENT) public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { for (int i = 0; i < 16; i++) { - aList.add(new ItemStack(aItem, 1, i)); + ItemStack aStack = new ItemStack(aItem, 1, i); + if (!aStack.getDisplayName().contains(".name")) aList.add(aStack); } } + + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return !(entity instanceof EntityWither); + } } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java index a3e8f19dd0..064f684168 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java @@ -1,149 +1,150 @@ -package gregtech.common.blocks; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.*; -import gregtech.api.interfaces.IOreRecipeRegistrator; -import gregtech.api.items.GT_Generic_Block; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import java.util.List; -import java.util.Random; - -public class GT_Block_Stones_Abstract - extends GT_Generic_Block - implements IOreRecipeRegistrator { - public GT_Block_Stones_Abstract(Class<? extends ItemBlock> aItemClass, String aName) { - super(aItemClass, aName, Material.rock); - OrePrefixes.crafting.add(this); - setStepSound(soundTypeStone); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 0), new ItemStack(this, 1, 7)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 1), new ItemStack(this, 1, 0)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 2), new ItemStack(this, 1, 0)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 3), new ItemStack(this, 1, 0)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 4), new ItemStack(this, 1, 0)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 5), new ItemStack(this, 1, 0)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 6), new ItemStack(this, 1, 0)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 7), new ItemStack(this, 1, 0)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 8), new ItemStack(this, 1, 15)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 9), new ItemStack(this, 1, 8)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 10), new ItemStack(this, 1, 8)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 11), new ItemStack(this, 1, 8)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 12), new ItemStack(this, 1, 8)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 13), new ItemStack(this, 1, 8)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 14), new ItemStack(this, 1, 8)); - GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 15), new ItemStack(this, 1, 8)); - GT_Values.RA.addAssemblerRecipe(new ItemStack(this, 1, 0), ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), new ItemStack(this, 1, 3), 50, 4); - GT_Values.RA.addAssemblerRecipe(new ItemStack(this, 1, 8), ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), new ItemStack(this, 1, 11), 50, 4); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 6), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"f", "X", 'X', new ItemStack(this, 1, 7)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 14), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"f", "X", 'X', new ItemStack(this, 1, 15)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 4), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 3)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 12), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 11)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 1), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 0)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 9), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 8)}); - GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 3), new ItemStack(this, 1, 4), 16, 10); - GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 11), new ItemStack(this, 1, 12), 16, 10); - GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 0), new ItemStack(this, 1, 1), 16, 10); - GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 8), new ItemStack(this, 1, 9), 16, 10); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 3), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 0)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 11), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 8)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 3), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 7)}); - GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 11), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 15)}); - } - - public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack) { - if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { - GT_Values.RA.addLaserEngraverRecipe(new ItemStack(this, 1, 7), GT_Utility.copyAmount(0L, new Object[]{aStack}), new ItemStack(this, 1, 6), 50, 16); - GT_Values.RA.addLaserEngraverRecipe(new ItemStack(this, 1, 15), GT_Utility.copyAmount(0L, new Object[]{aStack}), new ItemStack(this, 1, 14), 50, 16); - } - } - - public String getHarvestTool(int aMeta) { - return "pickaxe"; - } - - public int getHarvestLevel(int aMeta) { - return 1; - } - - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; - } - - public String getUnlocalizedName() { - return this.mUnlocalizedName; - } - - public String getLocalizedName() { - return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); - } - - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return true; - } - - public boolean renderAsNormalBlock() { - return true; - } - - public boolean isOpaqueCube() { - return true; - } - - public IIcon getIcon(int aSide, int aMeta) { - if ((aMeta >= 0) && (aMeta < 16)) { - return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); - } - return null; - } - - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) % 8 < 3; - } - - public int damageDropped(int par1) { - return par1 % 8 == 0 ? par1 + 1 : par1; - } - - public int getDamageValue(World par1World, int par2, int par3, int par4) { - return par1World.getBlockMetadata(par2, par3, par4); - } - - public int quantityDropped(Random par1Random) { - return 1; - } - - public Item getItemDropped(int par1, Random par2Random, int par3) { - return Item.getItemFromBlock(this); - } - - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) { - } - - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { - for (int i = 0; i < 16; i++) { - aList.add(new ItemStack(aItem, 1, i)); - } - } -} +package gregtech.common.blocks;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.*;
+import gregtech.api.interfaces.IOreRecipeRegistrator;
+import gregtech.api.items.GT_Generic_Block;
+import gregtech.api.util.GT_ModHandler;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.material.Material;
+import net.minecraft.client.renderer.texture.IIconRegister;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.EnumCreatureType;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IIcon;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.World;
+
+import java.util.List;
+import java.util.Random;
+
+public class GT_Block_Stones_Abstract
+ extends GT_Generic_Block
+ implements IOreRecipeRegistrator {
+ public GT_Block_Stones_Abstract(Class<? extends ItemBlock> aItemClass, String aName) {
+ super(aItemClass, aName, Material.rock);
+ OrePrefixes.crafting.add(this);
+ setStepSound(soundTypeStone);
+ setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS);
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 0), new ItemStack(this, 1, 7));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 1), new ItemStack(this, 1, 0));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 2), new ItemStack(this, 1, 0));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 3), new ItemStack(this, 1, 0));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 4), new ItemStack(this, 1, 0));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 5), new ItemStack(this, 1, 0));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 6), new ItemStack(this, 1, 0));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 7), new ItemStack(this, 1, 0));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 8), new ItemStack(this, 1, 15));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 9), new ItemStack(this, 1, 8));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 10), new ItemStack(this, 1, 8));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 11), new ItemStack(this, 1, 8));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 12), new ItemStack(this, 1, 8));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 13), new ItemStack(this, 1, 8));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 14), new ItemStack(this, 1, 8));
+ GT_ModHandler.addSmeltingRecipe(new ItemStack(this, 1, 15), new ItemStack(this, 1, 8));
+ GT_Values.RA.addAssemblerRecipe(new ItemStack(this, 1, 0), ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), new ItemStack(this, 1, 3), 50, 4);
+ GT_Values.RA.addAssemblerRecipe(new ItemStack(this, 1, 8), ItemList.Circuit_Integrated.getWithDamage(0L, 4L, new Object[0]), new ItemStack(this, 1, 11), 50, 4);
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 6), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"f", "X", 'X', new ItemStack(this, 1, 7)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 14), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"f", "X", 'X', new ItemStack(this, 1, 15)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 4), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 3)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 12), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 11)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 1), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 0)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 9), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"h", "X", 'X', new ItemStack(this, 1, 8)});
+ GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 3), new ItemStack(this, 1, 4), 16, 10);
+ GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 11), new ItemStack(this, 1, 12), 16, 10);
+ GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 0), new ItemStack(this, 1, 1), 16, 10);
+ GT_Values.RA.addForgeHammerRecipe(new ItemStack(this, 1, 8), new ItemStack(this, 1, 9), 16, 10);
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 3), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 0)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 11), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 8)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 3), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 7)});
+ GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 11), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 15)});
+ }
+
+ public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack) {
+ if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) {
+ GT_Values.RA.addLaserEngraverRecipe(new ItemStack(this, 1, 7), GT_Utility.copyAmount(0L, new Object[]{aStack}), new ItemStack(this, 1, 6), 50, 16);
+ GT_Values.RA.addLaserEngraverRecipe(new ItemStack(this, 1, 15), GT_Utility.copyAmount(0L, new Object[]{aStack}), new ItemStack(this, 1, 14), 50, 16);
+ }
+ }
+ @Override
+ public String getHarvestTool(int aMeta) {
+ return "pickaxe";
+ }
+ @Override
+ public int getHarvestLevel(int aMeta) {
+ return 1;
+ }
+ @Override
+ public float getBlockHardness(World aWorld, int aX, int aY, int aZ) {
+ return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F;
+ }
+ @Override
+ public String getUnlocalizedName() {
+ return this.mUnlocalizedName;
+ }
+ @Override
+ public String getLocalizedName() {
+ return StatCollector.translateToLocal(this.mUnlocalizedName + ".name");
+ }
+ @Override
+ public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) {
+ return false;
+ }
+ @Override
+ public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) {
+ return true;
+ }
+ @Override
+ public boolean renderAsNormalBlock() {
+ return true;
+ }
+ @Override
+ public boolean isOpaqueCube() {
+ return true;
+ }
+ @Override
+ public IIcon getIcon(int aSide, int aMeta) {
+ if ((aMeta >= 0) && (aMeta < 16)) {
+ return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon();
+ }
+ return null;
+ }
+
+ @Override
+ public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
+ return world.getBlockMetadata(x, y, z) % 8 < 3;
+ }
+ @Override
+ public int damageDropped(int par1) {
+ return par1 % 8 == 0 ? par1 + 1 : par1;
+ }
+ @Override
+ public int getDamageValue(World par1World, int par2, int par3, int par4) {
+ return par1World.getBlockMetadata(par2, par3, par4);
+ }
+ @Override
+ public int quantityDropped(Random par1Random) {
+ return 1;
+ }
+
+ public Item getItemDropped(int par1, Random par2Random, int par3) {
+ return Item.getItemFromBlock(this);
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void registerBlockIcons(IIconRegister aIconRegister) {
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) {
+ for (int i = 0; i < 16; i++) {
+ aList.add(new ItemStack(aItem, 1, i));
+ }
+ }
+}
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java b/src/main/java/gregtech/common/blocks/GT_Block_Storage.java index e2272a6503..768fed6619 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Storage.java @@ -95,7 +95,7 @@ public class GT_Block_Storage extends GT_Generic_Block { @SideOnly(Side.CLIENT) public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { for (int i = 0; i < 16; i++) { - aList.add(new ItemStack(aItem, 1, i)); + if (!(new ItemStack(aItem, 1, i).getDisplayName().contains(".name"))) aList.add(new ItemStack(aItem, 1, i)); } } } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index 28ca4f86f5..97cd810ec1 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -1,146 +1,152 @@ -package gregtech.common.blocks; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_ItsNotMyFaultException; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - -import java.util.List; - -public class GT_Item_Machines - extends ItemBlock { - public GT_Item_Machines(Block par1) { - super(par1); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH); - } - - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { - try { - int tDamage = getDamage(aStack); - if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { - return; - } - if (tDamage == 0) { - aList.add("WARNING, THE EXISTENCE OF THIS ITEM IS A BUG"); - aList.add("IF YOU GOT IT IN SURVIVAL THEN PLEASE REPORT IT"); - } else { - TileEntity temp = GregTech_API.sBlockMachines.createTileEntity(aPlayer == null ? GT_Values.DW : aPlayer.worldObj, GregTech_API.METATILEENTITIES[tDamage] == null ? 0 : GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType()); - if (temp != null) { - temp.setWorldObj(aPlayer == null ? GT_Values.DW : aPlayer.worldObj); - temp.xCoord = 0; - temp.yCoord = 0; - temp.zCoord = 0; - if ((temp instanceof IGregTechTileEntity)) { - IGregTechTileEntity tTileEntity = (IGregTechTileEntity) temp; - tTileEntity.setInitialValuesAsNBT(new NBTTagCompound(), (short) tDamage); - if (tTileEntity.getDescription() != null) { - int i = 0; - for (String tDescription : tTileEntity.getDescription()) { - if (GT_Utility.isStringValid(tDescription)) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished )); - } - } - } - if (tTileEntity.getEUCapacity() > 0L) { - if (tTileEntity.getInputVoltage() > 0L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY); - } - if (tTileEntity.getOutputVoltage() > 0L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + EnumChatFormatting.GRAY); - } - if (tTileEntity.getOutputAmperage() > 1L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY); - } - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "EU Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY); - } - } - } - } - NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - if (aNBT.getBoolean("mMuffler")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished )); - } - if (aNBT.getBoolean("mSteamConverter")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished )); - } - int tAmount = 0; - if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { - aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished )); - } - } - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - return false; - } - - public String getUnlocalizedName(ItemStack aStack) { - short tDamage = (short) getDamage(aStack); - if ((tDamage < 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { - return ""; - } - if (GregTech_API.METATILEENTITIES[tDamage] != null) { - return getUnlocalizedName() + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName(); - } - return ""; - } - - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - super.onCreated(aStack, aWorld, aPlayer); - short tDamage = (short) getDamage(aStack); - if ((tDamage < 0) || ((tDamage >= GregTech_API.METATILEENTITIES.length) && (GregTech_API.METATILEENTITIES[tDamage] != null))) { - GregTech_API.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer); - } - } - - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { - short tDamage = (short) getDamage(aStack); - if (tDamage > 0) { - if (GregTech_API.METATILEENTITIES[tDamage] == null) { - return false; - } - int tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType(); - if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tMetaData, 3)) { - return false; - } - if (aWorld.getBlock(aX, aY, aZ) != this.field_150939_a) { - throw new GT_ItsNotMyFaultException("Failed to place Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don't report this Bug to me, I don't know how to fix it."); - } - if (aWorld.getBlockMetadata(aX, aY, aZ) != tMetaData) { - throw new GT_ItsNotMyFaultException("Failed to set the MetaValue of the Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don't report this Bug to me, I don't know how to fix it."); - } - IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null) { - tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage); - if (aPlayer != null) { - tTileEntity.setOwnerName(aPlayer.getDisplayName()); - } - tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound()); - } - } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { - return false; - } - if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { - this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); - this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); - } - return true; - } -} +package gregtech.common.blocks;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.util.GT_ItsNotMyFaultException;
+import gregtech.api.util.GT_LanguageManager;
+import gregtech.api.util.GT_Log;
+import gregtech.api.util.GT_Utility;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.world.World;
+
+import java.util.List;
+
+public class GT_Item_Machines
+ extends ItemBlock {
+ public GT_Item_Machines(Block par1) {
+ super(par1);
+ setMaxDamage(0);
+ setHasSubtypes(true);
+ setCreativeTab(GregTech_API.TAB_GREGTECH);
+ }
+
+ public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) {
+ try {
+ int tDamage = getDamage(aStack);
+ if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) {
+ return;
+ }
+ if (tDamage == 0) {
+ aList.add("WARNING, THE EXISTENCE OF THIS ITEM IS A BUG");
+ aList.add("IF YOU GOT IT IN SURVIVAL THEN PLEASE REPORT IT");
+ } else {
+ TileEntity temp = GregTech_API.sBlockMachines.createTileEntity(aPlayer == null ? GT_Values.DW : aPlayer.worldObj, GregTech_API.METATILEENTITIES[tDamage] == null ? 0 : GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType());
+ if (temp != null) {
+ temp.setWorldObj(aPlayer == null ? GT_Values.DW : aPlayer.worldObj);
+ temp.xCoord = 0;
+ temp.yCoord = 0;
+ temp.zCoord = 0;
+ if ((temp instanceof IGregTechTileEntity)) {
+ IGregTechTileEntity tTileEntity = (IGregTechTileEntity) temp;
+ tTileEntity.setInitialValuesAsNBT(new NBTTagCompound(), (short) tDamage);
+ if (tTileEntity.getDescription() != null) {
+ int i = 0;
+ for (String tDescription : tTileEntity.getDescription()) {
+ if (GT_Utility.isStringValid(tDescription)) {
+ if(tDescription.contains("%%%")){
+ String[] tString = tDescription.split("%%%");
+ if(tString.length>=2){
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tString[0], !GregTech_API.sPostloadFinished )+" "+tString[1]);
+ }
+ }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished );
+ aList.add(tTranslated.equals("") ? tDescription : tTranslated);}
+ }else i++;
+ }
+ }
+ if (tTileEntity.getEUCapacity() > 0L) {
+ if (tTileEntity.getInputVoltage() > 0L) {
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY);
+ }
+ if (tTileEntity.getOutputVoltage() > 0L) {
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + EnumChatFormatting.GRAY);
+ }
+ if (tTileEntity.getOutputAmperage() > 1L) {
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY);
+ }
+ aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "EU Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY);
+ }
+ }
+ }
+ }
+ NBTTagCompound aNBT = aStack.getTagCompound();
+ if (aNBT != null) {
+ if (aNBT.getBoolean("mMuffler")) {
+ aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished ));
+ }
+ if (aNBT.getBoolean("mSteamConverter")) {
+ aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade", !GregTech_API.sPostloadFinished ));
+ }
+ int tAmount = 0;
+ if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) {
+ aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished ));
+ }
+ }
+ } catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+
+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
+ return false;
+ }
+
+ public String getUnlocalizedName(ItemStack aStack) {
+ short tDamage = (short) getDamage(aStack);
+ if ((tDamage < 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) {
+ return "";
+ }
+ if (GregTech_API.METATILEENTITIES[tDamage] != null) {
+ return getUnlocalizedName() + "." + GregTech_API.METATILEENTITIES[tDamage].getMetaName();
+ }
+ return "";
+ }
+
+ public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) {
+ super.onCreated(aStack, aWorld, aPlayer);
+ short tDamage = (short) getDamage(aStack);
+ if ((tDamage < 0) || ((tDamage >= GregTech_API.METATILEENTITIES.length) && (GregTech_API.METATILEENTITIES[tDamage] != null))) {
+ GregTech_API.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer);
+ }
+ }
+
+ public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) {
+ short tDamage = (short) getDamage(aStack);
+ if (tDamage > 0) {
+ if (GregTech_API.METATILEENTITIES[tDamage] == null) {
+ return false;
+ }
+ int tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType();
+ if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tMetaData, 3)) {
+ return false;
+ }
+ if (aWorld.getBlock(aX, aY, aZ) != this.field_150939_a) {
+ throw new GT_ItsNotMyFaultException("Failed to place Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don't report this Bug to me, I don't know how to fix it.");
+ }
+ if (aWorld.getBlockMetadata(aX, aY, aZ) != tMetaData) {
+ throw new GT_ItsNotMyFaultException("Failed to set the MetaValue of the Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don't report this Bug to me, I don't know how to fix it.");
+ }
+ IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aWorld.getTileEntity(aX, aY, aZ);
+ if (tTileEntity != null) {
+ tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage);
+ if (aPlayer != null) {
+ tTileEntity.setOwnerName(aPlayer.getDisplayName());
+ }
+ tTileEntity.getMetaTileEntity().initDefaultModes(aStack.getTagCompound());
+ }
+ } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) {
+ return false;
+ }
+ if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) {
+ this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack);
+ this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage);
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java index abdcd2ab2f..399c5d6bdd 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java @@ -1,45 +1,45 @@ -package gregtech.common.blocks; - -import gregtech.api.GregTech_API; -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public class GT_Item_Ores - extends ItemBlock { - public GT_Item_Ores(Block par1) { - super(par1); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - return false; - } - - public String getUnlocalizedName(ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); - } - - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { - short tDamage = (short) getDamage(aStack); - if (tDamage > 0) { - if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, GT_TileEntity_Ores.getHarvestData(tDamage), 3)) { - return false; - } - GT_TileEntity_Ores tTileEntity = (GT_TileEntity_Ores) aWorld.getTileEntity(aX, aY, aZ); - tTileEntity.mMetaData = tDamage; - tTileEntity.mNatural = false; - } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3)) { - return false; - } - if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { - this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); - this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); - } - return true; - } -} +package gregtech.common.blocks;
+
+import gregtech.api.GregTech_API;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemBlock;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+public class GT_Item_Ores
+ extends ItemBlock {
+ public GT_Item_Ores(Block par1) {
+ super(par1);
+ setMaxDamage(0);
+ setHasSubtypes(true);
+ setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS);
+ }
+
+ public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
+ return false;
+ }
+
+ public String getUnlocalizedName(ItemStack aStack) {
+ return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack);
+ }
+
+ public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) {
+ short tDamage = (short) getDamage(aStack);
+ if (tDamage > 0) {
+ if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, GT_TileEntity_Ores.getHarvestData(tDamage, ((GT_Block_Ores_Abstract) field_150939_a).getBaseBlockHarvestLevel(aMeta % 16000 / 1000)), 3)) {
+ return false;
+ }
+ GT_TileEntity_Ores tTileEntity = (GT_TileEntity_Ores) aWorld.getTileEntity(aX, aY, aZ);
+ tTileEntity.mMetaData = tDamage;
+ tTileEntity.mNatural = false;
+ } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3)) {
+ return false;
+ }
+ if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) {
+ this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack);
+ this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage);
+ }
+ return true;
+ }
+}
diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java index a6cf425caa..4aa9ba6931 100644 --- a/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java @@ -12,6 +12,6 @@ public class GT_Material_Reinforced } public boolean isOpaque() { - return false; + return true; } } diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java index a8cbcb3313..9310e832d8 100644 --- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java @@ -28,11 +28,11 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit public boolean mNatural = false; public boolean mBlocked = true; - public static byte getHarvestData(short aMetaData) { + public static byte getHarvestData(short aMetaData, int aBaseBlockHarvestLevel) { Materials aMaterial = GregTech_API.sGeneratedMaterials[(aMetaData % 1000)]; - byte tByte = aMaterial == null ? 0 : (byte) Math.max((aMetaData % 16000 / 1000 == 3) || (aMetaData % 16000 / 1000 == 4) ? 3 : 0, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1))); + byte tByte = aMaterial == null ? 0 : (byte) Math.max(aBaseBlockHarvestLevel, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1))); if(GT_Mod.gregtechproxy.mChangeHarvestLevels ){ - tByte = aMaterial == null ? 0 : (byte) Math.max((aMetaData % 16000 / 1000 == 3) || (aMetaData % 16000 / 1000 == 4) ? GT_Mod.gregtechproxy.mGraniteHavestLevel : 0, Math.min(GT_Mod.gregtechproxy.mMaxHarvestLevel, GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1))); + tByte = aMaterial == null ? 0 : (byte) Math.max(aBaseBlockHarvestLevel, Math.min(GT_Mod.gregtechproxy.mMaxHarvestLevel, GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1))); } return tByte; } @@ -69,6 +69,20 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit aMetaData += (BlockMeta * 1000); //System.out.println("Block changed to UB3"); } + //} else if (BlockName.equals("tile.moonBlock") && (BlockMeta == 3 || BlockMeta == 4)) { + // if (GregTech_API.sBlockOresGC != null) { + // switch (BlockMeta) { + // case 3: tOreBlock = GregTech_API.sBlockOresGC; break; + // case 4: aMetaData += 1000; tOreBlock = GregTech_API.sBlockOresGC; break; + // } + // } + //} else if (BlockName.equals("tile.mars") && (BlockMeta == 6 || BlockMeta == 9)) { + // if (GregTech_API.sBlockOresGC != null) { + // switch (BlockMeta) { + // case 6: aMetaData += 2000; tOreBlock = GregTech_API.sBlockOresGC; break; + // case 9: aMetaData += 3000; tOreBlock = GregTech_API.sBlockOresGC; break; + // } + // } } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) { aMetaData += 1000; } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) { @@ -97,7 +111,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit return false; } //System.out.println(tOreBlock); - aWorld.setBlock(aX, aY, aZ, tOreBlock, getHarvestData((short) aMetaData), 0); + aWorld.setBlock(aX, aY, aZ, tOreBlock, getHarvestData((short) aMetaData, ((GT_Block_Ores_Abstract) tOreBlock).getBaseBlockHarvestLevel(aMetaData % 16000 / 1000)), 0); TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof GT_TileEntity_Ores)) { ((GT_TileEntity_Ores) tTileEntity).mMetaData = ((short) aMetaData); @@ -137,6 +151,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit } public void overrideOreBlockMaterial(Block aOverridingStoneBlock, byte aOverridingStoneMeta) { + if(this.worldObj == null || blockType==null)return; this.mMetaData = ((short) (int) (this.mMetaData % 1000L + this.mMetaData / 16000L * 16000L)); if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.netherrack)) { this.mMetaData = ((short) (this.mMetaData + 1000)); @@ -163,7 +178,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit this.mMetaData = ((short) (this.mMetaData + 5000)); } } - this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(this.mMetaData), 0); + this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(this.mMetaData, ((GT_Block_Ores_Abstract) blockType).getBaseBlockHarvestLevel(mMetaData % 16000 / 1000)), 0); } public void convertOreBlock(World aWorld, int aX, int aY, int aZ) { @@ -172,7 +187,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof GT_TileEntity_Ores) { ((GT_TileEntity_Ores) tTileEntity).mMetaData = aMeta; - this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(aMeta), 0); + this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(aMeta, ((GT_Block_Ores_Abstract) tTileEntity.blockType).getBaseBlockHarvestLevel(aMeta % 16000 / 1000)), 0); } } |