From 85c804fa112fd1f19c91e45d150a787cfbf0f7a8 Mon Sep 17 00:00:00 2001 From: Shawn Buckley Date: Sun, 18 Oct 2015 23:04:39 -0400 Subject: Move source directory --- .../gregtech/common/blocks/GT_Block_Casings1.java | 90 ++++ .../gregtech/common/blocks/GT_Block_Casings2.java | 102 ++++ .../gregtech/common/blocks/GT_Block_Casings3.java | 93 ++++ .../gregtech/common/blocks/GT_Block_Casings4.java | 468 +++++++++++++++++ .../common/blocks/GT_Block_Casings_Abstract.java | 140 +++++ .../gregtech/common/blocks/GT_Block_Concretes.java | 104 ++++ .../gregtech/common/blocks/GT_Block_Granites.java | 80 +++ .../gregtech/common/blocks/GT_Block_Machines.java | 578 +++++++++++++++++++++ .../java/gregtech/common/blocks/GT_Block_Ores.java | 263 ++++++++++ .../common/blocks/GT_Block_Stones_Abstract.java | 175 +++++++ .../gregtech/common/blocks/GT_Item_Casings1.java | 29 ++ .../gregtech/common/blocks/GT_Item_Casings2.java | 25 + .../gregtech/common/blocks/GT_Item_Casings3.java | 12 + .../gregtech/common/blocks/GT_Item_Casings4.java | 12 + .../common/blocks/GT_Item_Casings_Abstract.java | 45 ++ .../gregtech/common/blocks/GT_Item_Concretes.java | 24 + .../gregtech/common/blocks/GT_Item_Granites.java | 12 + .../gregtech/common/blocks/GT_Item_Machines.java | 166 ++++++ .../java/gregtech/common/blocks/GT_Item_Ores.java | 54 ++ .../common/blocks/GT_Item_Stones_Abstract.java | 41 ++ .../common/blocks/GT_Material_Casings.java | 21 + .../common/blocks/GT_Material_Machines.java | 21 + .../gregtech/common/blocks/GT_Packet_Ores.java | 68 +++ .../gregtech/common/blocks/GT_TileEntity_Ores.java | 247 +++++++++ 24 files changed, 2870 insertions(+) create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings1.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings2.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings3.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings4.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Concretes.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Granites.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Machines.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Ores.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings1.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings2.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings3.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings4.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Concretes.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Granites.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Machines.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Ores.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Material_Casings.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Material_Machines.java create mode 100644 src/main/java/gregtech/common/blocks/GT_Packet_Ores.java create mode 100644 src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java (limited to 'src/main/java/gregtech/common/blocks') diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java new file mode 100644 index 0000000000..e8d3621c00 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java @@ -0,0 +1,90 @@ +package gregtech.common.blocks; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class GT_Block_Casings1 + extends GT_Block_Casings_Abstract +{ + public GT_Block_Casings1() + { + super(GT_Item_Casings1.class, "gt.blockcasings", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte)(i + 1)) { + Textures.BlockIcons.CASING_BLOCKS[i] = new GT_CopiedBlockTexture(this, 6, i); + } + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "ULV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "LV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "MV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "HV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "EV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "IV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "LuV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "ZPM Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "UV Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "MAX Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Bronze Plated Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Heat Proof Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Cupronickel Coil Block"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Kanthal Coil Block"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Nichrome Coil Block"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Superconducting Coil Block"); + ItemList.Casing_ULV.set(new ItemStack(this, 1, 0)); + ItemList.Casing_LV.set(new ItemStack(this, 1, 1)); + ItemList.Casing_MV.set(new ItemStack(this, 1, 2)); + ItemList.Casing_HV.set(new ItemStack(this, 1, 3)); + ItemList.Casing_EV.set(new ItemStack(this, 1, 4)); + ItemList.Casing_IV.set(new ItemStack(this, 1, 5)); + ItemList.Casing_LuV.set(new ItemStack(this, 1, 6)); + ItemList.Casing_ZPM.set(new ItemStack(this, 1, 7)); + ItemList.Casing_UV.set(new ItemStack(this, 1, 8)); + ItemList.Casing_MAX.set(new ItemStack(this, 1, 9)); + ItemList.Casing_BronzePlatedBricks.set(new ItemStack(this, 1, 10)); + ItemList.Casing_HeatProof.set(new ItemStack(this, 1, 11)); + ItemList.Casing_Coil_Cupronickel.set(new ItemStack(this, 1, 12)); + ItemList.Casing_Coil_Kanthal.set(new ItemStack(this, 1, 13)); + ItemList.Casing_Coil_Nichrome.set(new ItemStack(this, 1, 14)); + ItemList.Casing_Coil_Superconductor.set(new ItemStack(this, 1, 15)); + } + + public IIcon getIcon(int aSide, int aMeta) + { + if ((aMeta >= 0) && (aMeta < 16)) + { + switch (aMeta) + { + case 10: + return Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); + case 11: + return Textures.BlockIcons.MACHINE_HEATPROOFCASING.getIcon(); + case 12: + return Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); + case 13: + return Textures.BlockIcons.MACHINE_COIL_KANTHAL.getIcon(); + case 14: + return Textures.BlockIcons.MACHINE_COIL_NICHROME.getIcon(); + case 15: + return Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR.getIcon(); + } + if (aSide == 0) { + return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); + } + if (aSide == 1) { + return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); + } + return Textures.BlockIcons.MACHINECASINGS_SIDE[aMeta].getIcon(); + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + + public int colorMultiplier(IBlockAccess aWorld, int aX, int aY, int aZ) + { + return aWorld.getBlockMetadata(aX, aY, aZ) > 9 ? super.colorMultiplier(aWorld, aX, aY, aZ) : gregtech.api.enums.Dyes.MACHINE_METAL.mRGBa[0] << 16 | gregtech.api.enums.Dyes.MACHINE_METAL.mRGBa[1] << 8 | gregtech.api.enums.Dyes.MACHINE_METAL.mRGBa[2]; + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java new file mode 100644 index 0000000000..38054eb178 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java @@ -0,0 +1,102 @@ +package gregtech.common.blocks; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +public class GT_Block_Casings2 + extends GT_Block_Casings_Abstract +{ + public GT_Block_Casings2() + { + super(GT_Item_Casings2.class, "gt.blockcasings2", GT_Material_Casings.INSTANCE); + for (byte i = 0; i < 16; i = (byte)(i + 1)) { + Textures.BlockIcons.CASING_BLOCKS[(i + 16)] = new GT_CopiedBlockTexture(this, 6, i); + } + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Solid Steel Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Frost Proof Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Bronze Gear Box Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Steel Gear Box Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Titanium Gear Box Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Tungstensteel Gear Box Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Processor Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Data Drive Machine Casing"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Containment Field Machine Casing"); + 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"); + 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)); + ItemList.Casing_Gearbox_Steel.set(new ItemStack(this, 1, 3)); + ItemList.Casing_Gearbox_Titanium.set(new ItemStack(this, 1, 4)); + ItemList.Casing_Gearbox_TungstenSteel.set(new ItemStack(this, 1, 5)); + ItemList.Casing_Processor.set(new ItemStack(this, 1, 6)); + ItemList.Casing_DataDrive.set(new ItemStack(this, 1, 7)); + ItemList.Casing_ContainmentField.set(new ItemStack(this, 1, 8)); + ItemList.Casing_Assembler.set(new ItemStack(this, 1, 9)); + ItemList.Casing_Pump.set(new ItemStack(this, 1, 10)); + ItemList.Casing_Motor.set(new ItemStack(this, 1, 11)); + ItemList.Casing_Pipe_Bronze.set(new ItemStack(this, 1, 12)); + ItemList.Casing_Pipe_Steel.set(new ItemStack(this, 1, 13)); + ItemList.Casing_Pipe_Titanium.set(new ItemStack(this, 1, 14)); + ItemList.Casing_Pipe_TungstenSteel.set(new ItemStack(this, 1, 15)); + } + + public IIcon getIcon(int aSide, int aMeta) + { + switch (aMeta) + { + case 0: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + case 1: + return Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); + case 2: + return Textures.BlockIcons.MACHINE_CASING_GEARBOX_BRONZE.getIcon(); + case 3: + return Textures.BlockIcons.MACHINE_CASING_GEARBOX_STEEL.getIcon(); + case 4: + return Textures.BlockIcons.MACHINE_CASING_GEARBOX_TITANIUM.getIcon(); + case 5: + return Textures.BlockIcons.MACHINE_CASING_GEARBOX_TUNGSTENSTEEL.getIcon(); + case 6: + return Textures.BlockIcons.MACHINE_CASING_PROCESSOR.getIcon(); + case 7: + return Textures.BlockIcons.MACHINE_CASING_DATA_DRIVE.getIcon(); + case 8: + return Textures.BlockIcons.MACHINE_CASING_CONTAINMENT_FIELD.getIcon(); + case 9: + return Textures.BlockIcons.MACHINE_CASING_ASSEMBLER.getIcon(); + case 10: + return Textures.BlockIcons.MACHINE_CASING_PUMP.getIcon(); + case 11: + return Textures.BlockIcons.MACHINE_CASING_MOTOR.getIcon(); + case 12: + return Textures.BlockIcons.MACHINE_CASING_PIPE_BRONZE.getIcon(); + case 13: + return Textures.BlockIcons.MACHINE_CASING_PIPE_STEEL.getIcon(); + case 14: + return Textures.BlockIcons.MACHINE_CASING_PIPE_TITANIUM.getIcon(); + case 15: + return Textures.BlockIcons.MACHINE_CASING_PIPE_TUNGSTENSTEEL.getIcon(); + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + + public float getExplosionResistance(Entity aTNT, World aWorld, int aX, int aY, int aZ, double eX, double eY, double eZ) + { + return aWorld.getBlockMetadata(aX, aY, aZ) == 8 ? Blocks.bedrock.getExplosionResistance(aTNT) : super.getExplosionResistance(aTNT, aWorld, aX, aY, aZ, eX, eY, eZ); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java new file mode 100644 index 0000000000..467efc1297 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java @@ -0,0 +1,93 @@ +package gregtech.common.blocks; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +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(); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java new file mode 100644 index 0000000000..a0a3221d28 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -0,0 +1,468 @@ +package gregtech.common.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.util.GT_LanguageManager; +import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +public class GT_Block_Casings4 + extends GT_Block_Casings_Abstract +{ + public static boolean mConnectedMachineTextures = true; + + public GT_Block_Casings4() + { + super(GT_Item_Casings4.class, "gt.blockcasings4", GT_Material_Casings.INSTANCE); + 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() + ".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() + ".9.name", "Turbine Casing"); + + ItemList.Casing_RobustTungstenSteel.set(new ItemStack(this, 1, 0)); + ItemList.Casing_CleanStainlessSteel.set(new ItemStack(this, 1, 1)); + ItemList.Casing_StableTitanium.set(new ItemStack(this, 1, 2)); + ItemList.Casing_Firebox_Titanium.set(new ItemStack(this, 1, 3)); + ItemList.Casing_Fusion.set(new ItemStack(this,1,6)); + ItemList.Casing_Fusion_Coil.set(new ItemStack(this,1,7)); + ItemList.Casing_Fusion2.set(new ItemStack(this,1,8)); + ItemList.Casing_Turbine.set(new ItemStack(this,1,9)); + } + + public IIcon getIcon(int aSide, int aMeta) + { + switch (aMeta) + { + case 0: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 1: + return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); + case 2: + return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + case 3: + return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() : Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + case 4: + return Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW.getIcon(); + case 5: + return Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS.getIcon(); + case 6: + return Textures.BlockIcons.MACHINE_CASING_FUSION.getIcon(); + case 7: + return Textures.BlockIcons.MACHINE_CASING_FUSION_COIL.getIcon(); + case 8: + return Textures.BlockIcons.MACHINE_CASING_FUSION_2.getIcon(); + case 9: + return Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); + case 10: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 11: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 12: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 13: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 14: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 15: + return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + +@SideOnly(Side.CLIENT) +public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) +{ + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if ( ((tMeta != 6)&&(tMeta != 8)&&(tMeta != 9)) || (!mConnectedMachineTextures)) { + return getIcon(aSide, tMeta); + } + int tStartIndex = tMeta == 6 ? 1 : 13; + if (tMeta == 9) { + if ((aSide == 2) || (aSide == 3)) + { + TileEntity tTileEntity; + IMetaTileEntity tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[0].getIcon(); + } + return Textures.BlockIcons.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[3].getIcon(); + } + return Textures.BlockIcons.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[6].getIcon(); + } + return Textures.BlockIcons.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[1].getIcon(); + } + return Textures.BlockIcons.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[7].getIcon(); + } + return Textures.BlockIcons.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[8].getIcon(); + } + return Textures.BlockIcons.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[5].getIcon(); + } + return Textures.BlockIcons.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[2].getIcon(); + } + return Textures.BlockIcons.TURBINE[2].getIcon(); + } + } + else if ((aSide == 4) || (aSide == 5)) + { + TileEntity tTileEntity; + Object tMetaTileEntity; + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[0].getIcon(); + } + return Textures.BlockIcons.TURBINE[0].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[3].getIcon(); + } + return Textures.BlockIcons.TURBINE[3].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[6].getIcon(); + } + return Textures.BlockIcons.TURBINE[6].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[1].getIcon(); + } + return Textures.BlockIcons.TURBINE[1].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[7].getIcon(); + } + return Textures.BlockIcons.TURBINE[7].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[8].getIcon(); + } + return Textures.BlockIcons.TURBINE[8].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[5].getIcon(); + } + return Textures.BlockIcons.TURBINE[5].getIcon(); + } + if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity)tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity)tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) + { + if (((IGregTechTileEntity)tTileEntity).isActive()) { + return Textures.BlockIcons.TURBINE_ACTIVE[2].getIcon(); + } + return Textures.BlockIcons.TURBINE[2].getIcon(); + } + }return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + boolean[] tConnectedSides = { (aWorld.getBlock(xCoord, yCoord - 1, zCoord) == this) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == this) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == this) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == this) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == this) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == this) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; + switch (aSide) + { + case 0: + if (tConnectedSides[0]) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 1: + if (tConnectedSides[1] ) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[4] ) && (tConnectedSides[5] ) && (tConnectedSides[2] ) && (tConnectedSides[3] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5] ) && (tConnectedSides[2] ) && (tConnectedSides[3] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[4] ) && (!tConnectedSides[5]) && (tConnectedSides[2] ) && (tConnectedSides[3] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[4] ) && (tConnectedSides[5] ) && (!tConnectedSides[2]) && (tConnectedSides[3] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[4] ) && (tConnectedSides[5] ) && (tConnectedSides[2] ) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2] ) && (tConnectedSides[3] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[4] ) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[4] ) && (tConnectedSides[5] ) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[4]) && (tConnectedSides[5] ) && (tConnectedSides[2] ) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 2: + if (tConnectedSides[5] ) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2] ) && (!tConnectedSides[0]) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (!tConnectedSides[4]) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2] ) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 3: + if (tConnectedSides[3] ) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[2] ) && (!tConnectedSides[0]) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (!tConnectedSides[4]) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4] ) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[2] ) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[2] ) && (tConnectedSides[0] ) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[2]) && (tConnectedSides[0] ) && (tConnectedSides[4] ) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + case 4: + if (tConnectedSides[4] ) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0] ) && (!tConnectedSides[3]) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (!tConnectedSides[1]) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((tConnectedSides[0] ) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + case 5: + if (tConnectedSides[2] ) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); + } + if ((tConnectedSides[0] ) && (!tConnectedSides[3]) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (!tConnectedSides[1]) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1] ) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); + } + if ((tConnectedSides[0] ) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5] )) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); + } + if ((tConnectedSides[0] ) && (tConnectedSides[3] ) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); + } + if ((!tConnectedSides[0]) && (tConnectedSides[3] ) && (tConnectedSides[1] ) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + } + if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); + } + if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); + } + break; + } + return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); +}} \ No newline at end of file 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 new file mode 100644 index 0000000000..eb8b5bcab2 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java @@ -0,0 +1,140 @@ +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 java.util.List; +import java.util.Random; +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; + +public abstract class GT_Block_Casings_Abstract + extends GT_Generic_Block +{ + public GT_Block_Casings_Abstract(Class 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)); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java new file mode 100644 index 0000000000..ae432fa4a6 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java @@ -0,0 +1,104 @@ +package gregtech.common.blocks; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.block.Block; +import net.minecraft.block.BlockLiquid; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.fluids.IFluidBlock; + +public class GT_Block_Concretes + extends GT_Block_Stones_Abstract +{ + public GT_Block_Concretes() + { + super(GT_Item_Concretes.class, "gt.blockconcretes"); + setResistance(20.0F); + this.slipperiness = 0.9F; + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Dark Concrete"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Dark Concrete Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Dark Concrete Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Dark Concrete Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Cracked Dark Concrete Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Mossy Dark Concrete Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Chiseled Dark Concrete"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Smooth Dark Concrete"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Light Concrete"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Light Concrete Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Mossy Light Concrete Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Light Concrete Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Cracked Light Concrete Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Mossy Light Concrete Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Chiseled Light Concrete"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Smooth Light Concrete"); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 0)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 1)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 2)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 3)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 4)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 5)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 6)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 7)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 8)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 9)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 10)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 11)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 12)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 13)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 14)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 15)); + } + + 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); + } + + public IIcon getIcon(int aSide, int aMeta) + { + if ((aMeta >= 0) && (aMeta < 16)) { + return gregtech.api.enums.Textures.BlockIcons.CONCRETES[aMeta].getIcon(); + } + return gregtech.api.enums.Textures.BlockIcons.CONCRETES[0].getIcon(); + } + + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) + { + Block tBlock = aWorld.getBlock(aX, aY + 1, aZ); + if (((aEntity instanceof EntityLivingBase)) && (!(tBlock instanceof IFluidBlock)) && (!(tBlock instanceof BlockLiquid)) && (aEntity.onGround) && (!aEntity.isInWater()) && (!aEntity.isWet())) { + if (aEntity.isSneaking()) + { + aEntity.motionX *= 0.8999999761581421D; + aEntity.motionZ *= 0.8999999761581421D; + } + else + { + aEntity.motionX *= 1.100000023841858D; + aEntity.motionZ *= 1.100000023841858D; + } + } + } + + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) + { + Block tBlock = aWorld.getBlock(aX, aY + 1, aZ); + if (((tBlock instanceof IFluidBlock)) || ((tBlock instanceof BlockLiquid))) { + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 0.875D, aZ + 1); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java new file mode 100644 index 0000000000..906a3a2a87 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java @@ -0,0 +1,80 @@ +package gregtech.common.blocks; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class GT_Block_Granites + extends GT_Block_Stones_Abstract +{ + public GT_Block_Granites() + { + super(GT_Item_Granites.class, "gt.blockgranites"); + setResistance(60.0F); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Black Granite"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Black Granite Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Black Granite Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Black Granite Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Cracked Black Granite Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Mossy Black Granite Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Chiseled Black Granite"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Smooth Black Granite"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Red Granite"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Red Granite Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Mossy Red Granite Cobblestone"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Red Granite Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Cracked Red Granite Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Mossy Red Granite Bricks"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Chiseled Red Granite"); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Smooth Red Granite"); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 0)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 1)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 2)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 3)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 4)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 5)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 6)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 7)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 8)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 9)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 10)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 11)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 12)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 13)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 14)); + GT_OreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 15)); + } + + public int getHarvestLevel(int aMeta) + { + return 3; + } + + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) + { + return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; + } + + public IIcon getIcon(int aSide, int aMeta) + { + if ((aMeta >= 0) && (aMeta < 16)) { + return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); + } + return gregtech.api.enums.Textures.BlockIcons.GRANITES[0].getIcon(); + } + + 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_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java new file mode 100644 index 0000000000..5f756973c4 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -0,0 +1,578 @@ +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.enums.Textures.BlockIcons; +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.util.GT_BaseCrop; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_Utility; +import gregtech.common.render.GT_Renderer_Block; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +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; + +public class GT_Block_Machines + extends GT_Generic_Block + implements IDebugableBlock, ITileEntityProvider +{ + public static ThreadLocal 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); + } + + 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"); + for (IMetaTileEntity tMetaTileEntity : GregTech_API.METATILEENTITIES) { + try + { + 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"); + for (Runnable tRunnable : GregTech_API.sGTBlockIconload) { + try + { + 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) + { +// System.out.println("player hardness"); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (((tTileEntity instanceof BaseMetaTileEntity)) && (((BaseMetaTileEntity)tTileEntity).privateAccess()) && (!((BaseMetaTileEntity)tTileEntity).playerOwnsThis(aPlayer, true))) { +// System.out.println("locked"); + return -1.0F; + } +// System.out.println("unlocked"); +// System.out.println("hardness: "+super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ)); + 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) || (aPlayer.isSneaking())) { + 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 != null) && + ((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 Random(); + 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 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 != null) && ((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 != null) && ((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 != null) && ((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 != null) && ((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 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_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java new file mode 100644 index 0000000000..746b26deb5 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java @@ -0,0 +1,263 @@ +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.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.items.GT_Generic_Block; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.common.render.GT_Renderer_Block; +import java.util.ArrayList; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +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.boss.EntityDragon; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class GT_Block_Ores + extends GT_Generic_Block + implements ITileEntityProvider +{ + public static ThreadLocal mTemporaryTileEntity = new ThreadLocal(); + + public GT_Block_Ores() + { + super(GT_Item_Ores.class, "gt.blockores", Material.rock); + this.isBlockContainer = true; + setStepSound(soundTypeStone); + setCreativeTab(GregTech_API.TAB_GREGTECH_ORES); + for (int i = 0; i < 16; i++) { + GT_ModHandler.addValuableOre(this, i, 1); + } + for (int i = 1; i < GregTech_API.sGeneratedMaterials.length; i++) { + if (GregTech_API.sGeneratedMaterials[i] != null) + { + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + i + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 1000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 2000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 3000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 4000) + ".name", getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 16000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 17000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 18000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 19000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + (i + 20000) + ".name", "Small " + getLocalizedName(GregTech_API.sGeneratedMaterials[i])); + if ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x8) != 0) + { + GT_OreDictUnificator.registerOre(OrePrefixes.ore.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i)); + GT_OreDictUnificator.registerOre(OrePrefixes.oreNetherrack.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 1000)); + GT_OreDictUnificator.registerOre(OrePrefixes.oreEndstone.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 2000)); + GT_OreDictUnificator.registerOre(OrePrefixes.oreBlackgranite.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 3000)); + GT_OreDictUnificator.registerOre(OrePrefixes.oreRedgranite.get(GregTech_API.sGeneratedMaterials[i]), new ItemStack(this, 1, i + 4000)); + } + } + } + } + + public static boolean FUCKING_LOCK = false; + + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) + { + if (!FUCKING_LOCK) + { + FUCKING_LOCK = true; + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + ((GT_TileEntity_Ores)tTileEntity).onUpdated(); + } + } + FUCKING_LOCK = false; + } + + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) + { + if (!FUCKING_LOCK) + { + FUCKING_LOCK = true; + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + ((GT_TileEntity_Ores)tTileEntity).onUpdated(); + } + } + FUCKING_LOCK = false; + } + + public String getLocalizedName(Materials aMaterial) { + switch (aMaterial) { + 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: + return aMaterial.mDefaultLocalName; + default: + return aMaterial.mDefaultLocalName + OrePrefixes.ore.mLocalizedMaterialPost; + } + + } + + public boolean onBlockEventReceived(World p_149696_1_, int p_149696_2_, int p_149696_3_, int p_149696_4_, int p_149696_5_, int p_149696_6_) + { + super.onBlockEventReceived(p_149696_1_, p_149696_2_, p_149696_3_, p_149696_4_, p_149696_5_, p_149696_6_); + TileEntity tileentity = p_149696_1_.getTileEntity(p_149696_2_, p_149696_3_, p_149696_4_); + return tileentity != null ? tileentity.receiveClientEvent(p_149696_5_, p_149696_6_) : false; + } + + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) + { + return (!(entity instanceof EntityDragon)) && (super.canEntityDestroy(world, x, y, z, entity)); + } + + public String getHarvestTool(int aMeta) + { + return aMeta < 8 ? "pickaxe" : "shovel"; + } + + public int getHarvestLevel(int aMeta) + { + return aMeta % 8; + } + + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) + { + return 1.0F + getHarvestLevel(aWorld.getBlockMetadata(aX, aY, aZ)) * 1.0F; + } + + public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) + { + return 1.0F + getHarvestLevel(aWorld.getBlockMetadata(aX, aY, aZ)) * 1.0F; + } + + protected boolean canSilkHarvest() + { + return false; + } + + public String getUnlocalizedName() + { + return "gt.blockores"; + } + + public String getLocalizedName() + { + return StatCollector.translateToLocal(getUnlocalizedName() + ".name"); + } + + public int getRenderType() + { + if (GT_Renderer_Block.INSTANCE == null) { + return super.getRenderType(); + } + return GT_Renderer_Block.INSTANCE.mRenderID; + } + + 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 hasTileEntity(int aMeta) + { + return true; + } + + public boolean renderAsNormalBlock() + { + return true; + } + + public boolean isOpaqueCube() + { + return true; + } + + 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 Blocks.stone.getIcon(0, 0); + } + + public IIcon getIcon(int aSide, int aMeta) + { + return Blocks.stone.getIcon(0, 0); + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) {} + + public int getDamageValue(World aWorld, int aX, int aY, int aZ) + { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity != null) && ((tTileEntity instanceof GT_TileEntity_Ores))) { + return ((GT_TileEntity_Ores)tTileEntity).getMetaData(); + } + return 0; + } + + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) + { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + mTemporaryTileEntity.set((GT_TileEntity_Ores)tTileEntity); + } + super.breakBlock(aWorld, aX, aY, aZ, par5, par6); + aWorld.removeTileEntity(aX, aY, aZ); + } + + public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) + { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + return ((GT_TileEntity_Ores)tTileEntity).getDrops(aFortune); + } + return mTemporaryTileEntity.get() == null ? new ArrayList() : ((GT_TileEntity_Ores)mTemporaryTileEntity.get()).getDrops(aFortune); + } + + public TileEntity createTileEntity(World aWorld, int aMeta) + { + return new GT_TileEntity_Ores(); + } + + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) + { + for (int i = 0; i < GregTech_API.sGeneratedMaterials.length; i++) + { + Materials tMaterial = GregTech_API.sGeneratedMaterials[i]; + if ((tMaterial != null) && ((tMaterial.mTypes & 0x8) != 0)) + { + aList.add(new ItemStack(aItem, 1, i)); + aList.add(new ItemStack(aItem, 1, i + 1000)); + aList.add(new ItemStack(aItem, 1, i + 2000)); + aList.add(new ItemStack(aItem, 1, i + 3000)); + aList.add(new ItemStack(aItem, 1, i + 4000)); + aList.add(new ItemStack(aItem, 1, i + 16000)); + aList.add(new ItemStack(aItem, 1, i + 17000)); + aList.add(new ItemStack(aItem, 1, i + 18000)); + aList.add(new ItemStack(aItem, 1, i + 19000)); + aList.add(new ItemStack(aItem, 1, i + 20000)); + } + } + } +} 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 new file mode 100644 index 0000000000..d3963959ae --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java @@ -0,0 +1,175 @@ +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.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.IOreRecipeRegistrator; +import gregtech.api.interfaces.internal.IGT_RecipeAdder; +import gregtech.api.items.GT_Generic_Block; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_ModHandler.RecipeBits; +import gregtech.api.util.GT_Utility; +import java.util.List; +import java.util.Random; +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.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; + +public class GT_Block_Stones_Abstract + extends GT_Generic_Block + implements IOreRecipeRegistrator +{ + public GT_Block_Stones_Abstract(Class 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", Character.valueOf('X'), new ItemStack(this, 1, 7) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 14), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "f", "X", Character.valueOf('X'), new ItemStack(this, 1, 15) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 4), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "h", "X", Character.valueOf('X'), new ItemStack(this, 1, 3) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 12), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "h", "X", Character.valueOf('X'), new ItemStack(this, 1, 11) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 1), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "h", "X", Character.valueOf('X'), new ItemStack(this, 1, 0) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 1, 9), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "h", "X", Character.valueOf('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", Character.valueOf('X'), new ItemStack(this, 4, 0) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 11), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "XX", "XX", Character.valueOf('X'), new ItemStack(this, 4, 8) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 3), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "XX", "XX", Character.valueOf('X'), new ItemStack(this, 4, 7) }); + GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 11), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[] { "XX", "XX", Character.valueOf('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)); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java new file mode 100644 index 0000000000..634222e82f --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java @@ -0,0 +1,29 @@ +package gregtech.common.blocks; + +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class GT_Item_Casings1 + extends GT_Item_Casings_Abstract +{ + public GT_Item_Casings1(Block par1) + { + super(par1); + } + + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) + { + super.addInformation(aStack, aPlayer, aList, aF3_H); + switch (getDamage(aStack)) + { + case 12: + aList.add(this.mCoil01Tooltip); break; + case 13: + aList.add(this.mCoil02Tooltip); break; + case 14: + aList.add(this.mCoil03Tooltip); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java new file mode 100644 index 0000000000..a1b7f3e698 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java @@ -0,0 +1,25 @@ +package gregtech.common.blocks; + +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class GT_Item_Casings2 + extends GT_Item_Casings_Abstract +{ + public GT_Item_Casings2(Block par1) + { + super(par1); + } + + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) + { + super.addInformation(aStack, aPlayer, aList, aF3_H); + switch (getDamage(aStack)) + { + case 8: + aList.add(this.mBlastProofTooltip); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java new file mode 100644 index 0000000000..e27214ffef --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java @@ -0,0 +1,12 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +public class GT_Item_Casings3 + extends GT_Item_Casings_Abstract +{ + public GT_Item_Casings3(Block par1) + { + super(par1); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java new file mode 100644 index 0000000000..5c9e2fce95 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java @@ -0,0 +1,12 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +public class GT_Item_Casings4 + extends GT_Item_Casings_Abstract +{ + public GT_Item_Casings4(Block par1) + { + super(par1); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java new file mode 100644 index 0000000000..1412660479 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java @@ -0,0 +1,45 @@ +package gregtech.common.blocks; + +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_LanguageManager; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public abstract class GT_Item_Casings_Abstract + extends ItemBlock +{ + public GT_Item_Casings_Abstract(Block par1) + { + super(par1); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); + } + + public int getMetadata(int aMeta) + { + return aMeta; + } + + protected final String mNoMobsToolTip = GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + protected final String mNoTileEntityToolTip = GT_LanguageManager.addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + protected final String mCoil01Tooltip = GT_LanguageManager.addStringLocalization("gt.coil01tooltip", "Base Heating Capacity = 1800 Kelvin"); + protected final String mCoil02Tooltip = GT_LanguageManager.addStringLocalization("gt.coil02tooltip", "Base Heating Capacity = 2700 Kelvin"); + protected final String mCoil03Tooltip = GT_LanguageManager.addStringLocalization("gt.coil03tooltip", "Base Heating Capacity = 3600 Kelvin"); + protected final String mBlastProofTooltip = GT_LanguageManager.addStringLocalization("gt.blastprooftooltip", "This Block is Blast Proof"); + + public String getUnlocalizedName(ItemStack aStack) + { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) + { + super.addInformation(aStack, aPlayer, aList, aF3_H); + aList.add(this.mNoMobsToolTip); + aList.add(this.mNoTileEntityToolTip); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java new file mode 100644 index 0000000000..7f4d96193e --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java @@ -0,0 +1,24 @@ +package gregtech.common.blocks; + +import gregtech.api.util.GT_LanguageManager; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public class GT_Item_Concretes + extends GT_Item_Stones_Abstract +{ + public GT_Item_Concretes(Block par1) + { + super(par1); + } + + private final String mRunFasterToolTip = GT_LanguageManager.addStringLocalization("gt.runfastertooltip", "You can walk faster on this Block"); + + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) + { + super.addInformation(aStack, aPlayer, aList, aF3_H); + aList.add(this.mRunFasterToolTip); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Granites.java b/src/main/java/gregtech/common/blocks/GT_Item_Granites.java new file mode 100644 index 0000000000..57244ea7a7 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Granites.java @@ -0,0 +1,12 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +public class GT_Item_Granites + extends GT_Item_Stones_Abstract +{ + public GT_Item_Granites(Block par1) + { + super(par1); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java new file mode 100644 index 0000000000..0f7c4655a4 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -0,0 +1,166 @@ +package gregtech.common.blocks; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +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 java.util.List; +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; + +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", "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 new file mode 100644 index 0000000000..ab49dfdd88 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java @@ -0,0 +1,54 @@ +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; + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java new file mode 100644 index 0000000000..4b9336099f --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java @@ -0,0 +1,41 @@ +package gregtech.common.blocks; + +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_LanguageManager; +import java.util.List; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +public class GT_Item_Stones_Abstract + extends ItemBlock +{ + public GT_Item_Stones_Abstract(Block par1) + { + super(par1); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); + } + + public String getUnlocalizedName(ItemStack aStack) + { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + public int getMetadata(int aMeta) + { + return aMeta; + } + + private final String mNoMobsToolTip = GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) + { + super.addInformation(aStack, aPlayer, aList, aF3_H); + if (aStack.getItemDamage() % 8 >= 3) { + aList.add(this.mNoMobsToolTip); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Casings.java b/src/main/java/gregtech/common/blocks/GT_Material_Casings.java new file mode 100644 index 0000000000..f2df366a21 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Material_Casings.java @@ -0,0 +1,21 @@ +package gregtech.common.blocks; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; + +public class GT_Material_Casings + extends Material +{ + public static final Material INSTANCE = new GT_Material_Casings(); + + private GT_Material_Casings() + { + super(MapColor.ironColor); + setRequiresTool(); + } + + public boolean isOpaque() + { + return false; + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Machines.java b/src/main/java/gregtech/common/blocks/GT_Material_Machines.java new file mode 100644 index 0000000000..5abe245c99 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Material_Machines.java @@ -0,0 +1,21 @@ +package gregtech.common.blocks; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; + +public class GT_Material_Machines + extends Material +{ + public GT_Material_Machines() + { + super(MapColor.ironColor); + setRequiresTool(); + setImmovableMobility(); + setAdventureModeExempt(); + } + + public boolean isOpaque() + { + return false; + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java b/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java new file mode 100644 index 0000000000..4dbc01fda8 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java @@ -0,0 +1,68 @@ +package gregtech.common.blocks; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; +import com.google.common.io.ByteStreams; +import gregtech.api.net.GT_Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +public class GT_Packet_Ores + extends GT_Packet +{ + private int mX; + private int mZ; + private short mY; + private short mMetaData; + + public GT_Packet_Ores() + { + super(true); + } + + public GT_Packet_Ores(int aX, short aY, int aZ, short aMetaData) + { + super(false); + this.mX = aX; + this.mY = aY; + this.mZ = aZ; + this.mMetaData = aMetaData; + } + + public byte[] encode() + { + ByteArrayDataOutput tOut = ByteStreams.newDataOutput(12); + + tOut.writeInt(this.mX); + tOut.writeShort(this.mY); + tOut.writeInt(this.mZ); + tOut.writeShort(this.mMetaData); + + return tOut.toByteArray(); + } + + public GT_Packet decode(ByteArrayDataInput aData) + { + return new GT_Packet_Ores(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort()); + } + + public void process(IBlockAccess aWorld) + { + if (aWorld != null) + { + TileEntity tTileEntity = aWorld.getTileEntity(this.mX, this.mY, this.mZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) { + ((GT_TileEntity_Ores)tTileEntity).mMetaData = this.mMetaData; + } + if (((aWorld instanceof World)) && (((World)aWorld).isRemote)) { + ((World)aWorld).markBlockForUpdate(this.mX, this.mY, this.mZ); + } + } + } + + public byte getPacketID() + { + return 3; + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java new file mode 100644 index 0000000000..e032f781f7 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java @@ -0,0 +1,247 @@ +package gregtech.common.blocks; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; +import gregtech.api.net.IGT_NetworkHandler; +import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.Packet; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +public class GT_TileEntity_Ores + extends TileEntity + implements ITexturedTileEntity +{ + private static final ITexture[] mStoneTextures = { new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.netherrack, 0, 0), new GT_CopiedBlockTexture(Blocks.end_stone, 0, 0), new GT_RenderedTexture(Textures.BlockIcons.GRANITE_BLACK_STONE), new GT_RenderedTexture(Textures.BlockIcons.GRANITE_RED_STONE), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0) }; + public short mMetaData = 0; + public boolean mNatural = false; + public boolean mBlocked = true; + + public void readFromNBT(NBTTagCompound aNBT) + { + super.readFromNBT(aNBT); + this.mMetaData = aNBT.getShort("m"); + this.mNatural = aNBT.getBoolean("n"); + } + + public void writeToNBT(NBTTagCompound aNBT) + { + super.writeToNBT(aNBT); + aNBT.setShort("m", this.mMetaData); + aNBT.setBoolean("n", this.mNatural); + } + + public void onUpdated() + { + if ((!this.worldObj.isRemote) && (this.mBlocked)) + { + this.mBlocked = false; + GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, new GT_Packet_Ores(this.xCoord, (short)this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord); + } + } + + public Packet getDescriptionPacket() + { + if (!this.worldObj.isRemote) { + if ((this.mBlocked == (GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord + 1, this.yCoord, this.zCoord)) && (GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord - 1, this.yCoord, this.zCoord)) && (GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord + 1, this.zCoord)) && (GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord - 1, this.zCoord)) && (GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord, this.zCoord + 1)) && (GT_Utility.isOpaqueBlock(this.worldObj, this.xCoord, this.yCoord, this.zCoord - 1)) ? 1 : 0) == 0) { + GT_Values.NW.sendPacketToAllPlayersInRange(this.worldObj, new GT_Packet_Ores(this.xCoord, (short)this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord); + } + } + return null; + } + + public static byte getHarvestData(short aMetaData) + { + Materials aMaterial = GregTech_API.sGeneratedMaterials[(aMetaData % 1000)]; + return 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))); + } + + public void overrideOreBlockMaterial(Block aOverridingStoneBlock, byte aOverridingStoneMeta) + { + 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)); + } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.end_stone)) { + this.mMetaData = ((short)(this.mMetaData + 2000)); + } else if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, GregTech_API.sBlockGranites)) { + if (aOverridingStoneBlock == GregTech_API.sBlockGranites) + { + if (aOverridingStoneMeta < 8) { + this.mMetaData = ((short)(this.mMetaData + 3000)); + } else { + this.mMetaData = ((short)(this.mMetaData + 4000)); + } + } + else { + this.mMetaData = ((short)(this.mMetaData + 3000)); + } + } + this.worldObj.setBlockMetadataWithNotify(this.xCoord, this.yCoord, this.zCoord, getHarvestData(this.mMetaData), 0); + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData) + { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + Block tBlock = aWorld.getBlock(aX, aY, aZ); + if ((aMetaData > 0) && (tBlock != Blocks.air)) + { + if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) { + aMetaData += 1000; + } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) { + aMetaData += 2000; + } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites)) + { + if (tBlock == GregTech_API.sBlockGranites) + { + if (aWorld.getBlockMetadata(aX, aY, aZ) < 8) { + aMetaData += 3000; + } else { + aMetaData += 4000; + } + } + else { + aMetaData += 3000; + } + } + else if (!tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) { + return false; + } + aWorld.setBlock(aX, aY, aZ, GregTech_API.sBlockOres1, getHarvestData((short)aMetaData), 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof GT_TileEntity_Ores)) + { + ((GT_TileEntity_Ores)tTileEntity).mMetaData = ((short)aMetaData); + ((GT_TileEntity_Ores)tTileEntity).mNatural = true; + } + return true; + } + return false; + } + + public short getMetaData() + { + return this.mMetaData; + } + + public boolean canUpdate() + { + return false; + } + + public ArrayList getDrops(int aFortune) + { + ArrayList rList = new ArrayList(); + if (this.mMetaData <= 0) + { + rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); + return rList; + } + if (this.mMetaData < 16000) + { + rList.add(new ItemStack(GregTech_API.sBlockOres1, 1, this.mMetaData)); + return rList; + } + Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; + if (!this.mNatural) { + aFortune = 0; + } + if (aMaterial != null) + { + Random tRandom = new Random(this.xCoord ^ this.yCoord ^ this.zCoord); + ArrayList tSelector = new ArrayList(); + + + ItemStack tStack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 1; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.gemFlawless, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 2; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 12; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.gemFlawed, aMaterial, GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.gemChipped, aMaterial, GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GT_OreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + if (tSelector.size() > 0) + { + int i = 0; + for (int j = Math.max(1, aMaterial.mOreMultiplier + (aFortune > 0 ? tRandom.nextInt(1 + aFortune * aMaterial.mOreMultiplier) : 0) / 2); i < j; i++) { + rList.add(GT_Utility.copyAmount(1L, new Object[] { tSelector.get(tRandom.nextInt(tSelector.size())) })); + } + } + if (tRandom.nextInt(3 + aFortune) > 1) { + switch (this.mMetaData / 1000 % 16) + { + case 0: + rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Stone, 1L)); break; + case 1: + rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Netherrack, 1L)); break; + case 2: + rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.Endstone, 1L)); break; + case 3: + rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.GraniteBlack, 1L)); break; + case 4: + rList.add(GT_OreDictUnificator.get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, Materials.GraniteRed, 1L)); + } + } + } + return rList; + } + + public ITexture[] getTexture(byte aSide) + { + Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; + if ((aMaterial != null) && (this.mMetaData < 32000)) { + return new ITexture[] { mStoneTextures[(this.mMetaData / 1000 % 16)], new GT_RenderedTexture(aMaterial.mIconSet.mTextures[this.mMetaData/16000 ==0 ? OrePrefixes.ore.mTextureIndex:OrePrefixes.oreSmall.mTextureIndex], aMaterial.mRGBa) }; + } + return new ITexture[] { mStoneTextures[0], new GT_RenderedTexture(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex]) }; + } +} -- cgit