From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- .../java/gregtech/common/blocks/BlockCasings1.java | 107 ++++ .../gregtech/common/blocks/BlockCasings10.java | 76 +++ .../gregtech/common/blocks/BlockCasings11.java | 58 ++ .../java/gregtech/common/blocks/BlockCasings2.java | 102 +++ .../java/gregtech/common/blocks/BlockCasings3.java | 82 +++ .../java/gregtech/common/blocks/BlockCasings4.java | 239 +++++++ .../java/gregtech/common/blocks/BlockCasings5.java | 161 +++++ .../java/gregtech/common/blocks/BlockCasings6.java | 94 +++ .../java/gregtech/common/blocks/BlockCasings8.java | 188 ++++++ .../java/gregtech/common/blocks/BlockCasings9.java | 96 +++ .../common/blocks/BlockCasingsAbstract.java | 143 +++++ .../gregtech/common/blocks/BlockConcretes.java | 83 +++ .../common/blocks/BlockCyclotronCoils.java | 131 ++++ .../java/gregtech/common/blocks/BlockDrone.java | 65 ++ .../java/gregtech/common/blocks/BlockFrameBox.java | 446 +++++++++++++ .../java/gregtech/common/blocks/BlockGlass1.java | 107 ++++ .../java/gregtech/common/blocks/BlockGranites.java | 77 +++ .../java/gregtech/common/blocks/BlockLaser.java | 104 +++ .../java/gregtech/common/blocks/BlockMachines.java | 703 +++++++++++++++++++++ .../java/gregtech/common/blocks/BlockMetal.java | 68 ++ .../java/gregtech/common/blocks/BlockOres.java | 154 +++++ .../gregtech/common/blocks/BlockOresAbstract.java | 324 ++++++++++ .../gregtech/common/blocks/BlockReinforced.java | 409 ++++++++++++ .../java/gregtech/common/blocks/BlockStones.java | 62 ++ .../common/blocks/BlockStonesAbstract.java | 250 ++++++++ .../java/gregtech/common/blocks/BlockStorage.java | 103 +++ .../common/blocks/BlockTintedIndustrialGlass.java | 98 +++ .../common/blocks/BlockWormholeRender.java | 75 +++ .../gregtech/common/blocks/GT_Block_Casings1.java | 108 ---- .../gregtech/common/blocks/GT_Block_Casings10.java | 76 --- .../gregtech/common/blocks/GT_Block_Casings11.java | 58 -- .../gregtech/common/blocks/GT_Block_Casings2.java | 102 --- .../gregtech/common/blocks/GT_Block_Casings3.java | 82 --- .../gregtech/common/blocks/GT_Block_Casings4.java | 239 ------- .../gregtech/common/blocks/GT_Block_Casings5.java | 161 ----- .../gregtech/common/blocks/GT_Block_Casings6.java | 94 --- .../gregtech/common/blocks/GT_Block_Casings8.java | 188 ------ .../gregtech/common/blocks/GT_Block_Casings9.java | 96 --- .../common/blocks/GT_Block_Casings_Abstract.java | 144 ----- .../gregtech/common/blocks/GT_Block_Concretes.java | 83 --- .../gregtech/common/blocks/GT_Block_Drone.java | 65 -- .../gregtech/common/blocks/GT_Block_FrameBox.java | 446 ------------- .../gregtech/common/blocks/GT_Block_Glass1.java | 107 ---- .../gregtech/common/blocks/GT_Block_Granites.java | 77 --- .../gregtech/common/blocks/GT_Block_Laser.java | 104 --- .../gregtech/common/blocks/GT_Block_Machines.java | 703 --------------------- .../gregtech/common/blocks/GT_Block_Metal.java | 68 -- .../java/gregtech/common/blocks/GT_Block_Ores.java | 154 ----- .../common/blocks/GT_Block_Ores_Abstract.java | 324 ---------- .../common/blocks/GT_Block_Reinforced.java | 409 ------------ .../gregtech/common/blocks/GT_Block_Stones.java | 62 -- .../common/blocks/GT_Block_Stones_Abstract.java | 250 -------- .../gregtech/common/blocks/GT_Block_Storage.java | 103 --- .../blocks/GT_Block_TintedIndustrialGlass.java | 98 --- .../gregtech/common/blocks/GT_Cyclotron_Coils.java | 131 ---- .../common/blocks/GT_Cyclotron_Item_Casings.java | 10 - .../common/blocks/GT_Item_Block_Laser.java | 24 - .../gregtech/common/blocks/GT_Item_Casings1.java | 14 - .../gregtech/common/blocks/GT_Item_Casings10.java | 14 - .../gregtech/common/blocks/GT_Item_Casings11.java | 14 - .../gregtech/common/blocks/GT_Item_Casings2.java | 26 - .../gregtech/common/blocks/GT_Item_Casings3.java | 14 - .../gregtech/common/blocks/GT_Item_Casings4.java | 14 - .../gregtech/common/blocks/GT_Item_Casings5.java | 36 -- .../gregtech/common/blocks/GT_Item_Casings6.java | 14 - .../gregtech/common/blocks/GT_Item_Casings8.java | 14 - .../gregtech/common/blocks/GT_Item_Casings9.java | 28 - .../common/blocks/GT_Item_Casings_Abstract.java | 63 -- .../gregtech/common/blocks/GT_Item_Concretes.java | 25 - .../gregtech/common/blocks/GT_Item_Frames.java | 60 -- .../gregtech/common/blocks/GT_Item_Glass1.java | 36 -- .../gregtech/common/blocks/GT_Item_Granites.java | 10 - .../common/blocks/GT_Item_LongDistancePipe.java | 43 -- .../gregtech/common/blocks/GT_Item_Machines.java | 430 ------------- .../java/gregtech/common/blocks/GT_Item_Ores.java | 81 --- .../common/blocks/GT_Item_Stones_Abstract.java | 42 -- .../gregtech/common/blocks/GT_Item_Storage.java | 47 -- .../blocks/GT_Item_TintedIndustrialGlass.java | 10 - .../common/blocks/GT_Material_Casings.java | 19 - .../common/blocks/GT_Material_Machines.java | 19 - .../common/blocks/GT_Material_Reinforced.java | 18 - .../gregtech/common/blocks/GT_Packet_Ores.java | 62 -- .../gregtech/common/blocks/GT_TileEntity_Ores.java | 486 -------------- .../common/blocks/GT_WormholeRenderBlock.java | 75 --- .../gregtech/common/blocks/ItemBlockLaser.java | 24 + .../java/gregtech/common/blocks/ItemCasings1.java | 14 + .../java/gregtech/common/blocks/ItemCasings10.java | 14 + .../java/gregtech/common/blocks/ItemCasings11.java | 14 + .../java/gregtech/common/blocks/ItemCasings2.java | 26 + .../java/gregtech/common/blocks/ItemCasings3.java | 14 + .../java/gregtech/common/blocks/ItemCasings4.java | 14 + .../java/gregtech/common/blocks/ItemCasings5.java | 36 ++ .../java/gregtech/common/blocks/ItemCasings6.java | 14 + .../java/gregtech/common/blocks/ItemCasings8.java | 14 + .../java/gregtech/common/blocks/ItemCasings9.java | 28 + .../common/blocks/ItemCasingsAbstract.java | 63 ++ .../java/gregtech/common/blocks/ItemConcretes.java | 25 + .../common/blocks/ItemCyclotronCasings.java | 10 + .../java/gregtech/common/blocks/ItemFrames.java | 60 ++ .../java/gregtech/common/blocks/ItemGlass1.java | 36 ++ .../java/gregtech/common/blocks/ItemGranites.java | 10 + .../common/blocks/ItemLongDistancePipe.java | 43 ++ .../java/gregtech/common/blocks/ItemMachines.java | 430 +++++++++++++ src/main/java/gregtech/common/blocks/ItemOres.java | 81 +++ .../gregtech/common/blocks/ItemStonesAbstract.java | 42 ++ .../java/gregtech/common/blocks/ItemStorage.java | 47 ++ .../common/blocks/ItemTintedIndustrialGlass.java | 10 + .../gregtech/common/blocks/MaterialCasings.java | 19 + .../gregtech/common/blocks/MaterialMachines.java | 19 + .../gregtech/common/blocks/MaterialReinforced.java | 18 + .../java/gregtech/common/blocks/PacketOres.java | 62 ++ .../gregtech/common/blocks/TileEntityOres.java | 482 ++++++++++++++ 112 files changed, 6274 insertions(+), 6280 deletions(-) create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings1.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings10.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings11.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings2.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings3.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings4.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings5.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings6.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings8.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasings9.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCasingsAbstract.java create mode 100644 src/main/java/gregtech/common/blocks/BlockConcretes.java create mode 100644 src/main/java/gregtech/common/blocks/BlockCyclotronCoils.java create mode 100644 src/main/java/gregtech/common/blocks/BlockDrone.java create mode 100644 src/main/java/gregtech/common/blocks/BlockFrameBox.java create mode 100644 src/main/java/gregtech/common/blocks/BlockGlass1.java create mode 100644 src/main/java/gregtech/common/blocks/BlockGranites.java create mode 100644 src/main/java/gregtech/common/blocks/BlockLaser.java create mode 100644 src/main/java/gregtech/common/blocks/BlockMachines.java create mode 100644 src/main/java/gregtech/common/blocks/BlockMetal.java create mode 100644 src/main/java/gregtech/common/blocks/BlockOres.java create mode 100644 src/main/java/gregtech/common/blocks/BlockOresAbstract.java create mode 100644 src/main/java/gregtech/common/blocks/BlockReinforced.java create mode 100644 src/main/java/gregtech/common/blocks/BlockStones.java create mode 100644 src/main/java/gregtech/common/blocks/BlockStonesAbstract.java create mode 100644 src/main/java/gregtech/common/blocks/BlockStorage.java create mode 100644 src/main/java/gregtech/common/blocks/BlockTintedIndustrialGlass.java create mode 100644 src/main/java/gregtech/common/blocks/BlockWormholeRender.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings1.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings10.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings11.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings2.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings3.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings4.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings5.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings6.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings8.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings9.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Concretes.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Drone.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Glass1.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Granites.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Laser.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Machines.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Metal.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Ores.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Stones.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_Storage.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Block_TintedIndustrialGlass.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Cyclotron_Item_Casings.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Block_Laser.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings1.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings10.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings11.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings2.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings3.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings4.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings5.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings6.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings8.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings9.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Concretes.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Frames.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Glass1.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Granites.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Machines.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Ores.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_Storage.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Item_TintedIndustrialGlass.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Material_Casings.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Material_Machines.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_Packet_Ores.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java delete mode 100644 src/main/java/gregtech/common/blocks/GT_WormholeRenderBlock.java create mode 100644 src/main/java/gregtech/common/blocks/ItemBlockLaser.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings1.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings10.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings11.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings2.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings3.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings4.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings5.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings6.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings8.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasings9.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCasingsAbstract.java create mode 100644 src/main/java/gregtech/common/blocks/ItemConcretes.java create mode 100644 src/main/java/gregtech/common/blocks/ItemCyclotronCasings.java create mode 100644 src/main/java/gregtech/common/blocks/ItemFrames.java create mode 100644 src/main/java/gregtech/common/blocks/ItemGlass1.java create mode 100644 src/main/java/gregtech/common/blocks/ItemGranites.java create mode 100644 src/main/java/gregtech/common/blocks/ItemLongDistancePipe.java create mode 100644 src/main/java/gregtech/common/blocks/ItemMachines.java create mode 100644 src/main/java/gregtech/common/blocks/ItemOres.java create mode 100644 src/main/java/gregtech/common/blocks/ItemStonesAbstract.java create mode 100644 src/main/java/gregtech/common/blocks/ItemStorage.java create mode 100644 src/main/java/gregtech/common/blocks/ItemTintedIndustrialGlass.java create mode 100644 src/main/java/gregtech/common/blocks/MaterialCasings.java create mode 100644 src/main/java/gregtech/common/blocks/MaterialMachines.java create mode 100644 src/main/java/gregtech/common/blocks/MaterialReinforced.java create mode 100644 src/main/java/gregtech/common/blocks/PacketOres.java create mode 100644 src/main/java/gregtech/common/blocks/TileEntityOres.java (limited to 'src/main/java/gregtech/common/blocks') diff --git a/src/main/java/gregtech/common/blocks/BlockCasings1.java b/src/main/java/gregtech/common/blocks/BlockCasings1.java new file mode 100644 index 0000000000..5410847176 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings1.java @@ -0,0 +1,107 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings1 extends BlockCasingsAbstract { + + /** + * Texture Index Information Textures.BlockIcons.casingTexturePages[0][0-63] - Gregtech + * Textures.BlockIcons.casingTexturePages[0][64-127] - GT++ Textures.BlockIcons.casingTexturePages[1][0-127] - + * Gregtech Textures.BlockIcons.casingTexturePages[2][0-127] - Free Textures.BlockIcons.casingTexturePages[3][0-127] + * - Free Textures.BlockIcons.casingTexturePages[4][0-127] - Free Textures.BlockIcons.casingTexturePages[5][0-127] - + * Free Textures.BlockIcons.casingTexturePages[6][0-127] - Free Textures.BlockIcons.casingTexturePages[7][0-127] - + * TecTech Textures.BlockIcons.casingTexturePages[8][0-127] - TecTech + */ + public BlockCasings1() { + super(ItemCasings1.class, "gt.blockcasings", MaterialCasings.INSTANCE, 16); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "ULV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "LV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "MV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "HV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "EV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "IV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "LuV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "ZPM Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "UV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "UHV Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Bronze Plated Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Heat Proof Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Dimensionally Transcendent Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Dimensional Injection Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Dimensional Bridge"); + GTLanguageManager.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_Dim_Trans.set(new ItemStack(this, 1, 12)); + ItemList.Casing_Dim_Injector.set(new ItemStack(this, 1, 13)); + ItemList.Casing_Dim_Bridge.set(new ItemStack(this, 1, 14)); + ItemList.Casing_Coil_Superconductor.set(new ItemStack(this, 1, 15)); + } + + @Override + public int getTextureIndex(int aMeta) { + return aMeta; + } + + @Override + public IIcon getIcon(int ordinalSide, 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_DIM_TRANS_CASING.getIcon(); + } + case 13 -> { + return Textures.BlockIcons.MACHINE_DIM_INJECTOR.getIcon(); + } + case 14 -> { + return Textures.BlockIcons.MACHINE_DIM_BRIDGE.getIcon(); + } + case 15 -> { + return Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR.getIcon(); + } + } + if (ordinalSide == 0) { + return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); + } + if (ordinalSide == 1) { + return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); + } + return Textures.BlockIcons.MACHINECASINGS_SIDE[aMeta].getIcon(); + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + + @Override + 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/BlockCasings10.java b/src/main/java/gregtech/common/blocks/BlockCasings10.java new file mode 100644 index 0000000000..11c3f81f01 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings10.java @@ -0,0 +1,76 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +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.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings10 extends BlockCasingsAbstract { + + public BlockCasings10() { + super(ItemCasings10.class, "gt.blockcasings10", MaterialCasings.INSTANCE, 16); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "MagTech Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Laser Containment Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Quark Exclusion Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Pressure Containment Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Electric Compressor Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Compression Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Neutronium Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Active Neutronium Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Neutronium Stabilization Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Coolant Duct"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Heating Duct"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".11.name", "Extreme Density Space-Bending Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".12.name", "Background Radiation Absorbent Casing"); + + ItemList.Casing_Electromagnetic_Separator.set(new ItemStack(this, 1, 0)); + ItemList.Casing_Laser.set(new ItemStack(this, 1, 1)); + ItemList.BlockQuarkContainmentCasing.set(new ItemStack(this, 1, 2)); + ItemList.Casing_Autoclave.set(new ItemStack(this, 1, 3)); + ItemList.Compressor_Casing.set(new ItemStack(this, 1, 4)); + ItemList.Compressor_Pipe_Casing.set(new ItemStack(this, 1, 5)); + ItemList.Neutronium_Casing.set(new ItemStack(this, 1, 6)); + ItemList.Neutronium_Active_Casing.set(new ItemStack(this, 1, 7)); + ItemList.Neutronium_Stable_Casing.set(new ItemStack(this, 1, 8)); + ItemList.Coolant_Duct_Casing.set(new ItemStack(this, 1, 9)); + ItemList.Heating_Duct_Casing.set(new ItemStack(this, 1, 10)); + ItemList.Extreme_Density_Casing.set(new ItemStack(this, 1, 11)); + ItemList.Background_Radiation_Casing.set(new ItemStack(this, 1, 12)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (16 << 7) | (aMeta + 48); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.MACHINE_CASING_EMS.getIcon(); + case 1 -> Textures.BlockIcons.MACHINE_CASING_LASER.getIcon(); + case 2 -> Textures.BlockIcons.BLOCK_QUARK_CONTAINMENT_CASING.getIcon(); + case 3 -> Textures.BlockIcons.MACHINE_CASING_AUTOCLAVE.getIcon(); + case 4 -> Textures.BlockIcons.COMPRESSOR_CASING.getIcon(); + case 5 -> Textures.BlockIcons.COMPRESSOR_PIPE_CASING.getIcon(); + case 6 -> Textures.BlockIcons.NEUTRONIUM_CASING.getIcon(); + case 7 -> Textures.BlockIcons.NEUTRONIUM_ACTIVE_CASING.getIcon(); + case 8 -> Textures.BlockIcons.NEUTRONIUM_STABLE_CASING.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TUNGSTENSTEEL.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_CASING_PIPE_BRONZE.getIcon(); + case 11 -> Textures.BlockIcons.EXTREME_DENSITY_CASING.getIcon(); + case 12 -> Textures.BlockIcons.RADIATION_ABSORBENT_CASING.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + }; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCasings11.java b/src/main/java/gregtech/common/blocks/BlockCasings11.java new file mode 100644 index 0000000000..a654aae3d7 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings11.java @@ -0,0 +1,58 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +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.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings11 extends BlockCasingsAbstract { + + public BlockCasings11() { + super(ItemCasings11.class, "gt.blockcasings11", MaterialCasings.INSTANCE, 16); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Tin Item Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Brass Item Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Electrum Item Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Platinum Item Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Osmium Item Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Quantium Item Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Fluxed Electrum Item Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Black Plutonium Item Pipe Casing"); + + ItemList.Casing_Item_Pipe_Tin.set(new ItemStack(this, 1, 0)); + ItemList.Casing_Item_Pipe_Brass.set(new ItemStack(this, 1, 1)); + ItemList.Casing_Item_Pipe_Electrum.set(new ItemStack(this, 1, 2)); + ItemList.Casing_Item_Pipe_Platinum.set(new ItemStack(this, 1, 3)); + ItemList.Casing_Item_Pipe_Osmium.set(new ItemStack(this, 1, 4)); + ItemList.Casing_Item_Pipe_Quantium.set(new ItemStack(this, 1, 5)); + ItemList.Casing_Item_Pipe_Fluxed_Electrum.set(new ItemStack(this, 1, 6)); + ItemList.Casing_Item_Pipe_Black_Plutonium.set(new ItemStack(this, 1, 7)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (16 << 7) | (aMeta + 64); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 1 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_BRASS.getIcon(); + case 2 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_ELECTRUM.getIcon(); + case 3 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_PLATINUM.getIcon(); + case 4 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_OSMIUM.getIcon(); + case 5 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_QUANTIUM.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_FLUXED_ELECTRUM.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_BLACK_PLUTONIUM.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_TIN.getIcon(); + }; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCasings2.java b/src/main/java/gregtech/common/blocks/BlockCasings2.java new file mode 100644 index 0000000000..441bbd9b82 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings2.java @@ -0,0 +1,102 @@ +package gregtech.common.blocks; + +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; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings2 extends BlockCasingsAbstract { + + public BlockCasings2() { + super(ItemCasings2.class, "gt.blockcasings2", MaterialCasings.INSTANCE, 96); + // Special handler for Pyrolyse Oven Casing on hatches... + Textures.BlockIcons.casingTexturePages[0][22] = TextureFactory.of( + Block.getBlockFromItem( + ItemList.Casing_ULV.get(1) + .getItem()), + 0, + ForgeDirection.UNKNOWN, + Dyes.MACHINE_METAL.mRGBa); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Solid Steel Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Frost Proof Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Bronze Gear Box Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Steel Gear Box Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Titanium Gear Box Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Assembling Line Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Processor Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Data Drive Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Containment Field Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Assembler Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Pump Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Motor Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Bronze Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Steel Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Titanium Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Tungstensteel Pipe Casing"); + ItemList.Casing_SolidSteel.set(new ItemStack(this, 1, 0)); + ItemList.Casing_FrostProof.set(new ItemStack(this, 1, 1)); + ItemList.Casing_Gearbox_Bronze.set(new ItemStack(this, 1, 2)); + 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)); + } + + @Override + public int getTextureIndex(int aMeta) { + return aMeta == 6 ? ((1 << 7) + 96) : aMeta + 16; + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + case 1 -> Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); + case 2 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_BRONZE.getIcon(); + case 3 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_STEEL.getIcon(); + case 4 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_TITANIUM.getIcon(); + case 5 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_TUNGSTENSTEEL.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_CASING_PROCESSOR.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_CASING_DATA_DRIVE.getIcon(); + case 8 -> Textures.BlockIcons.MACHINE_CASING_CONTAINMENT_FIELD.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_CASING_ASSEMBLER.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_CASING_PUMP.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_MOTOR.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_CASING_PIPE_BRONZE.getIcon(); + case 13 -> Textures.BlockIcons.MACHINE_CASING_PIPE_STEEL.getIcon(); + case 14 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TITANIUM.getIcon(); + case 15 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TUNGSTENSTEEL.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + }; + } + + @Override + 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/BlockCasings3.java b/src/main/java/gregtech/common/blocks/BlockCasings3.java new file mode 100644 index 0000000000..fdd48b62ed --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings3.java @@ -0,0 +1,82 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings3 extends BlockCasingsAbstract { + + public BlockCasings3() { + super(ItemCasings3.class, "gt.blockcasings3", MaterialCasings.INSTANCE, 16); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Yellow Stripes Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Yellow Stripes Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Radioactive Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Bio Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Explosion Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Fire Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Acid Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Magic Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Frost Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Noise Hazard Sign Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Grate Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Filter Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Radiation Proof Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Bronze Firebox Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Steel Firebox Casing"); + GTLanguageManager.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)); + } + + @Override + public int getTextureIndex(int aMeta) { + return aMeta + 32; + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_A.getIcon(); + case 1 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_B.getIcon(); + case 2 -> Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); + case 3 -> Textures.BlockIcons.MACHINE_CASING_BIOHAZARD.getIcon(); + case 4 -> Textures.BlockIcons.MACHINE_CASING_EXPLOSIONHAZARD.getIcon(); + case 5 -> Textures.BlockIcons.MACHINE_CASING_FIREHAZARD.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_CASING_MAGICHAZARD.getIcon(); + case 8 -> Textures.BlockIcons.MACHINE_CASING_FROSTHAZARD.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_CASING_NOISEHAZARD.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_VENT.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); + case 13 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() + : Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); + case 14 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() + : Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + case 15 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() + : Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + }; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCasings4.java b/src/main/java/gregtech/common/blocks/BlockCasings4.java new file mode 100644 index 0000000000..0cba916548 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings4.java @@ -0,0 +1,239 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GTMod; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTRenderingWorld; +import gregtech.common.tileentities.machines.multi.MTELargeTurbine; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings4 extends BlockCasingsAbstract { + + /** + * This mapping is used to look up which texture should be used to render the connected texture for fusion casings. + *

+ * This mapping is computed from that giant if ladder from #getIcon in commit + * da3421547afadc49938b5b6a7f9a9679afa1d570 The exact meaning of these numbers are like black magic. Read the + * original getIcon implementation to understand why it is 0, 1, etc, if that if ladder is even intelligible. + */ + private static final int[][] mapping = new int[][] { + { 7, 7, 7, 7, 0, 7, 0, 7, 1, 7, 1, 7, 8, 7, 8, 7, 0, 7, 0, 7, 0, 7, 0, 7, 9, 7, 9, 7, 3, 7, 3, 7, 1, 7, 1, 7, + 11, 7, 11, 7, 1, 7, 1, 7, 2, 7, 2, 7, 10, 7, 10, 7, 5, 7, 5, 7, 4, 7, 4, 7, 6, 7, 6, 7 }, + { 7, 7, 7, 7, 0, 0, 7, 7, 1, 1, 7, 7, 8, 8, 7, 7, 0, 0, 7, 7, 0, 0, 7, 7, 9, 9, 7, 7, 3, 3, 7, 7, 1, 1, 7, 7, + 11, 11, 7, 7, 1, 1, 7, 7, 2, 2, 7, 7, 10, 10, 7, 7, 5, 5, 7, 7, 4, 4, 7, 7, 6, 6, 7, 7 }, + { 7, 1, 1, 1, 0, 9, 10, 4, 7, 1, 1, 1, 0, 9, 10, 4, 0, 8, 11, 2, 0, 3, 5, 6, 0, 8, 11, 2, 0, 3, 5, 6, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + { 7, 1, 1, 1, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, + 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7 }, + { 7, 1, 1, 1, 7, 1, 1, 1, 0, 8, 11, 2, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, + 0, 9, 10, 4, 0, 3, 5, 6, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, + { 7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 0, 8, 11, 2, + 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7, 0, 8, 11, 2, 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7 }, }; + + public static boolean mConnectedMachineTextures = true; + + public BlockCasings4() { + super(ItemCasings4.class, "gt.blockcasings4", MaterialCasings.INSTANCE, 16); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".0.name", "Robust Tungstensteel Machine Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Stable Titanium Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Titanium Firebox Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Fusion Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Fusion Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Fusion Machine Casing MK II"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Turbine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Stainless Steel Turbine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Titanium Turbine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Tungstensteel Turbine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Engine Intake Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Mining Osmiridium Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Firebricks"); + + 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)); + ItemList.Casing_Turbine1.set(new ItemStack(this, 1, 10)); + ItemList.Casing_Turbine2.set(new ItemStack(this, 1, 11)); + ItemList.Casing_Turbine3.set(new ItemStack(this, 1, 12)); + ItemList.Casing_EngineIntake.set(new ItemStack(this, 1, 13)); + ItemList.Casing_MiningOsmiridium.set(new ItemStack(this, 1, 14)); + ItemList.Casing_Firebricks.set(new ItemStack(this, 1, 15)); + + GTMod.gregtechproxy.mCTMBlockCache.put(this, (byte) 6, true); + GTMod.gregtechproxy.mCTMBlockCache.put(this, (byte) 8, true); + } + + @Override + public int getTextureIndex(int aMeta) { + return aMeta + 48; + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 1 -> Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); + case 2 -> Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + case 3 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() + : Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + case 4 -> + // Do not overwrite! + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW.getIcon(); + case 5 -> + // Do not overwrite! + Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_CASING_FUSION.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_CASING_FUSION_COIL.getIcon(); + case 8 -> Textures.BlockIcons.MACHINE_CASING_FUSION_2.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_STAINLESSSTEEL.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TITANIUM.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TUNGSTENSTEEL.getIcon(); + case 13 -> Textures.BlockIcons.MACHINE_CASING_ENGINE_INTAKE.getIcon(); + case 14 -> Textures.BlockIcons.MACHINE_CASING_MINING_OSMIRIDIUM.getIcon(); + case 15 -> Textures.BlockIcons.MACHINE_CASING_DENSEBRICKS.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + }; + } + + @Deprecated + public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean hasTurbine) { + return switch (meta) { + case 10 -> active ? Textures.BlockIcons.TURBINE_ACTIVE1[iconIndex].getIcon() + : hasTurbine ? Textures.BlockIcons.TURBINE1[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE_EMPTY1[iconIndex].getIcon(); + case 11 -> active ? Textures.BlockIcons.TURBINE_ACTIVE2[iconIndex].getIcon() + : hasTurbine ? Textures.BlockIcons.TURBINE2[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE_EMPTY2[iconIndex].getIcon(); + case 12 -> active ? Textures.BlockIcons.TURBINE_ACTIVE3[iconIndex].getIcon() + : hasTurbine ? Textures.BlockIcons.TURBINE3[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE_EMPTY3[iconIndex].getIcon(); + default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() + : hasTurbine ? Textures.BlockIcons.TURBINE[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE_EMPTY[iconIndex].getIcon(); + }; + } + + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; + if (tTile.getMetaTileEntity() instanceof MTELargeTurbine turbine && tTile.getFrontFacing() + .ordinal() == ordinalSide) { + if (turbine.isNewStyleRendering()) return 0; + if (tTile.isActive()) return 1; + return turbine.hasTurbine() ? 2 : 3; + } + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + aWorld = GTRenderingWorld.getInstance(aWorld); + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + if (tMeta != 6 && tMeta != 8 && tMeta != 9 && tMeta != 10 && tMeta != 11 && tMeta != 12 + || !mConnectedMachineTextures) { + return getIcon(ordinalSide, tMeta); + } + // noinspection ConstantValue // tMeta < 13 should stay because mConnectedMachineTextures can be changed + if (tMeta > 8 && tMeta < 13) { + int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; + switch (ordinalSide / 2) { + case 0 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord, + zCoord + i, + ordinalSide)) != 0) { + return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); + } + } + } + } + case 1 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord + i, + zCoord, + ordinalSide)) != 0) { + return getTurbineCasing( + tMeta, + 4 + i * 3 - j * tInvertLeftRightMod, + tState == 1, + tState == 2); + } + } + } + } + case 2 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord, + yCoord + i, + zCoord + j, + ordinalSide)) != 0) { + return getTurbineCasing( + tMeta, + 4 + i * 3 + j * tInvertLeftRightMod, + tState == 1, + tState == 2); + } + } + } + } + } + return switch (tMeta) { + case 10 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_STAINLESSSTEEL.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TITANIUM.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TUNGSTENSTEEL.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + }; + } + int tStartIndex = tMeta == 6 ? 1 : 13; + int tIndexIntoMapping = 0; + if (isSameBlock(aWorld, xCoord, yCoord - 1, zCoord, tMeta)) tIndexIntoMapping |= 1; + if (isSameBlock(aWorld, xCoord, yCoord + 1, zCoord, tMeta)) tIndexIntoMapping |= 1 << 1; + if (isSameBlock(aWorld, xCoord + 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 2; + if (isSameBlock(aWorld, xCoord, yCoord, zCoord + 1, tMeta)) tIndexIntoMapping |= 1 << 3; + if (isSameBlock(aWorld, xCoord - 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 4; + if (isSameBlock(aWorld, xCoord, yCoord, zCoord - 1, tMeta)) tIndexIntoMapping |= 1 << 5; + return Textures.BlockIcons.CONNECTED_HULLS[tStartIndex + mapping[ordinalSide][tIndexIntoMapping]].getIcon(); + } + + private boolean isSameBlock(IBlockAccess aWorld, int aX, int aY, int aZ, int aMeta) { + return aWorld.getBlock(aX, aY, aZ) == this && aWorld.getBlockMetadata(aX, aY, aZ) == aMeta; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCasings5.java b/src/main/java/gregtech/common/blocks/BlockCasings5.java new file mode 100644 index 0000000000..15b3eedcba --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings5.java @@ -0,0 +1,161 @@ +package gregtech.common.blocks; + +import static gregtech.api.enums.HeatingCoilLevel.EV; +import static gregtech.api.enums.HeatingCoilLevel.HV; +import static gregtech.api.enums.HeatingCoilLevel.IV; +import static gregtech.api.enums.HeatingCoilLevel.LV; +import static gregtech.api.enums.HeatingCoilLevel.LuV; +import static gregtech.api.enums.HeatingCoilLevel.MAX; +import static gregtech.api.enums.HeatingCoilLevel.MV; +import static gregtech.api.enums.HeatingCoilLevel.None; +import static gregtech.api.enums.HeatingCoilLevel.UEV; +import static gregtech.api.enums.HeatingCoilLevel.UHV; +import static gregtech.api.enums.HeatingCoilLevel.UIV; +import static gregtech.api.enums.HeatingCoilLevel.UMV; +import static gregtech.api.enums.HeatingCoilLevel.UV; +import static gregtech.api.enums.HeatingCoilLevel.UXV; +import static gregtech.api.enums.HeatingCoilLevel.ZPM; + +import java.util.function.Consumer; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHeatingCoil; +import gregtech.api.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings5 extends BlockCasingsAbstract implements IHeatingCoil { + + public BlockCasings5() { + super(ItemCasings5.class, "gt.blockcasings5", MaterialCasings.INSTANCE, 16); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Cupronickel Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Kanthal Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Nichrome Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "TPV-Alloy Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "HSS-G Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Naquadah Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Naquadah Alloy Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Electrum Flux Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Awakened Draconium Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "HSS-S Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Trinium Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Infinity Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Hypogen Coil Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Eternal Coil Block"); + + ItemList.Casing_Coil_Cupronickel.set(new ItemStack(this, 1, 0)); + ItemList.Casing_Coil_Kanthal.set(new ItemStack(this, 1, 1)); + ItemList.Casing_Coil_Nichrome.set(new ItemStack(this, 1, 2)); + ItemList.Casing_Coil_TungstenSteel.set(new ItemStack(this, 1, 3)); + ItemList.Casing_Coil_HSSG.set(new ItemStack(this, 1, 4)); + ItemList.Casing_Coil_Naquadah.set(new ItemStack(this, 1, 5)); + ItemList.Casing_Coil_NaquadahAlloy.set(new ItemStack(this, 1, 6)); + ItemList.Casing_Coil_ElectrumFlux.set(new ItemStack(this, 1, 7)); + ItemList.Casing_Coil_AwakenedDraconium.set(new ItemStack(this, 1, 8)); + ItemList.Casing_Coil_HSSS.set(new ItemStack(this, 1, 9)); + ItemList.Casing_Coil_Trinium.set(new ItemStack(this, 1, 10)); + ItemList.Casing_Coil_Infinity.set(new ItemStack(this, 1, 11)); + ItemList.Casing_Coil_Hypogen.set(new ItemStack(this, 1, 12)); + ItemList.Casing_Coil_Eternal.set(new ItemStack(this, 1, 13)); + ItemList.Casing_Shielded_Accelerator.set(new ItemStack(this, 1, 14)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (1 << 7) | aMeta; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); + case 1 -> Textures.BlockIcons.MACHINE_COIL_KANTHAL.getIcon(); + case 2 -> Textures.BlockIcons.MACHINE_COIL_NICHROME.getIcon(); + case 3 -> Textures.BlockIcons.MACHINE_COIL_TUNGSTENSTEEL.getIcon(); + case 4 -> Textures.BlockIcons.MACHINE_COIL_HSSG.getIcon(); + case 5 -> Textures.BlockIcons.MACHINE_COIL_NAQUADAH.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_COIL_NAQUADAHALLOY.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_COIL_ELECTRUMFLUX.getIcon(); + case 8 -> Textures.BlockIcons.MACHINE_COIL_AWAKENEDDRACONIUM.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_COIL_HSSS.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_COIL_TRINIUM.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_COIL_INFINITY.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_COIL_HYPOGEN.getIcon(); + case 13 -> Textures.BlockIcons.MACHINE_COIL_ETERNAL.getIcon(); + case 14 -> Textures.BlockIcons.MACHINE_CASING_SHIELDED_ACCELERATOR.getIcon(); + default -> Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); + }; + } + + /*--------------- COIL CHECK IMPL. ------------*/ + + public static HeatingCoilLevel getCoilHeatFromDamage(int meta) { + return switch (meta) { + case 0 -> LV; + case 1 -> MV; + case 2 -> HV; + case 3 -> EV; + case 4 -> IV; + case 5 -> ZPM; + case 6 -> UV; + case 7 -> UEV; + case 8 -> UIV; + case 9 -> LuV; + case 10 -> UHV; + case 11 -> UMV; + case 12 -> UXV; + case 13 -> MAX; + default -> None; + }; + } + + public static int getMetaFromCoilHeat(HeatingCoilLevel level) { + return switch (level) { + case LV -> 0; + case MV -> 1; + case HV -> 2; + case EV -> 3; + case IV -> 4; + case ZPM -> 5; + case UV -> 6; + case UEV -> 7; + case UIV -> 8; + case LuV -> 9; + case UHV -> 10; + case UMV -> 11; + case UXV -> 12; + case MAX -> 13; + default -> 0; + }; + } + + @Override + public HeatingCoilLevel getCoilHeat(int meta) { + getOnCoilCheck().accept(this); + return getCoilHeatFromDamage(meta); + } + + /*--------------- CALLBACK ------------*/ + + private Consumer callback = coil -> {}; + + @Override + public void setOnCoilCheck(Consumer callback) { + this.callback = callback; + } + + @Override + public Consumer getOnCoilCheck() { + return this.callback; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCasings6.java b/src/main/java/gregtech/common/blocks/BlockCasings6.java new file mode 100644 index 0000000000..e638f36547 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings6.java @@ -0,0 +1,94 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +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.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings6 extends BlockCasingsAbstract { + + public BlockCasings6() { + super(ItemCasings6.class, "gt.blockcasings6", MaterialCasings.INSTANCE, 16); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Hermetic Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Hermetic Casing I"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Hermetic Casing II"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Hermetic Casing III"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Hermetic Casing IV"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Hermetic Casing V"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Hermetic Casing VI"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Hermetic Casing VII"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Hermetic Casing VIII"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Hermetic Casing IX"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Hermetic Casing X"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Hermetic Casing XI"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Hermetic Casing XII"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Hermetic Casing XIII"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Hermetic Casing XIV"); + + ItemList.Casing_Tank_0.set(new ItemStack(this, 1, 0)); + ItemList.Casing_Tank_1.set(new ItemStack(this, 1, 1)); + ItemList.Casing_Tank_2.set(new ItemStack(this, 1, 2)); + ItemList.Casing_Tank_3.set(new ItemStack(this, 1, 3)); + ItemList.Casing_Tank_4.set(new ItemStack(this, 1, 4)); + ItemList.Casing_Tank_5.set(new ItemStack(this, 1, 5)); + ItemList.Casing_Tank_6.set(new ItemStack(this, 1, 6)); + ItemList.Casing_Tank_7.set(new ItemStack(this, 1, 7)); + ItemList.Casing_Tank_8.set(new ItemStack(this, 1, 8)); + ItemList.Casing_Tank_9.set(new ItemStack(this, 1, 9)); + ItemList.Casing_Tank_10.set(new ItemStack(this, 1, 10)); + ItemList.Casing_Tank_11.set(new ItemStack(this, 1, 11)); + ItemList.Casing_Tank_12.set(new ItemStack(this, 1, 12)); + ItemList.Casing_Tank_13.set(new ItemStack(this, 1, 13)); + ItemList.Casing_Tank_14.set(new ItemStack(this, 1, 14)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (8 << 7) | (aMeta + 112); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + if (ordinalSide == 0) { + return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); + } + if (ordinalSide == 1) { + return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); + } + return switch (aMeta) { + case 1 -> Textures.BlockIcons.MACHINE_CASING_TANK_1.getIcon(); + case 2 -> Textures.BlockIcons.MACHINE_CASING_TANK_2.getIcon(); + case 3 -> Textures.BlockIcons.MACHINE_CASING_TANK_3.getIcon(); + case 4 -> Textures.BlockIcons.MACHINE_CASING_TANK_4.getIcon(); + case 5 -> Textures.BlockIcons.MACHINE_CASING_TANK_5.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_CASING_TANK_6.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_CASING_TANK_7.getIcon(); + case 8 -> Textures.BlockIcons.MACHINE_CASING_TANK_8.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_CASING_TANK_9.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_CASING_TANK_10.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_TANK_11.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_CASING_TANK_12.getIcon(); + case 13 -> Textures.BlockIcons.MACHINE_CASING_TANK_13.getIcon(); + case 14 -> Textures.BlockIcons.MACHINE_CASING_TANK_14.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_TANK_0.getIcon(); + }; + } + + @Override + public int colorMultiplier(IBlockAccess aWorld, int aX, int aY, int aZ) { + return 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/BlockCasings8.java b/src/main/java/gregtech/common/blocks/BlockCasings8.java new file mode 100644 index 0000000000..2e8781bca1 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings8.java @@ -0,0 +1,188 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +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.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTRenderingWorld; +import gregtech.common.tileentities.machines.multi.MTELargeTurbine; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings8 extends BlockCasingsAbstract { + + public static boolean mConnectedMachineTextures = true; + + // WATCH OUT FOR TEXTURE ID's + public BlockCasings8() { + super(ItemCasings8.class, "gt.blockcasings8", MaterialCasings.INSTANCE, 15); + /* + * DO NOT USE INDEX 15 ! USED HERE: https://github.com/GTNewHorizons/KubaTech/pull/101 + */ + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemically Inert Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "PTFE Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mining Neutronium Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Mining Black Plutonium Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Extreme Engine Intake Casing"); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + ".5.name", + "Europium Reinforced Radiation Proof Machine Casing"); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + ".6.name", + "Advanced Rhodium Plated Palladium Machine Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".7.name", "Advanced Iridium Plated Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Magical Machine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "HSS-S Turbine Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Radiant Naquadah Alloy Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".11.name", "Basic Photolithographic Framework Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".12.name", "Reinforced Photolithographic Framework Casing"); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + ".13.name", + "Radiation Proof Photolithographic Framework Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Infinity Cooled Casing"); + + ItemList.Casing_Chemically_Inert.set(new ItemStack(this, 1, 0)); + ItemList.Casing_Pipe_Polytetrafluoroethylene.set(new ItemStack(this, 1, 1)); + ItemList.Casing_MiningNeutronium.set(new ItemStack(this, 1, 2)); + ItemList.Casing_MiningBlackPlutonium.set(new ItemStack(this, 1, 3)); + ItemList.Casing_ExtremeEngineIntake.set(new ItemStack(this, 1, 4)); + ItemList.Casing_AdvancedRadiationProof.set(new ItemStack(this, 1, 5)); + ItemList.Casing_Advanced_Rhodium_Palladium.set(new ItemStack(this, 1, 6)); + ItemList.Casing_Advanced_Iridium.set(new ItemStack(this, 1, 7)); + ItemList.Casing_Magical.set(new ItemStack(this, 1, 8)); + ItemList.Casing_TurbineGasAdvanced.set(new ItemStack(this, 1, 9)); + ItemList.RadiantNaquadahAlloyCasing.set(new ItemStack(this, 1, 10)); + ItemList.BasicPhotolithographicFrameworkCasing.set(new ItemStack(this, 1, 11)); + ItemList.ReinforcedPhotolithographicFrameworkCasing.set(new ItemStack(this, 1, 12)); + ItemList.RadiationProofPhotolithographicFrameworkCasing.set(new ItemStack(this, 1, 13)); + ItemList.InfinityCooledCasing.set(new ItemStack(this, 1, 14)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (1 << 7) | (aMeta + 48); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.MACHINE_CASING_CHEMICALLY_INERT.getIcon(); + case 1 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE.getIcon(); + case 2 -> Textures.BlockIcons.MACHINE_CASING_MINING_NEUTRONIUM.getIcon(); + case 3 -> Textures.BlockIcons.MACHINE_CASING_MINING_BLACKPLUTONIUM.getIcon(); + case 4 -> Textures.BlockIcons.MACHINE_CASING_EXTREME_ENGINE_INTAKE.getIcon(); // changed color in a + // terrible way + case 5 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDRADIATIONPROOF.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_CASING_RHODIUM_PALLADIUM.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_CASING_IRIDIUM.getIcon(); + case 8 -> Textures.BlockIcons.MACHINE_CASING_MAGICAL.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDGAS.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_CASING_RADIANT_NAQUADAH_ALLOY.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_1.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_2.getIcon(); + case 13 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_3.getIcon(); + case 14 -> Textures.BlockIcons.INFINITY_COOLED_CASING.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + }; + } + + public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean hasTurbine) { + // noinspection SwitchStatementWithTooFewBranches // "if" is harder to edit + return switch (meta) { + case 9 -> active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon() + : hasTurbine ? Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE_ADVGASEMPTY[iconIndex].getIcon(); + default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() + : hasTurbine ? Textures.BlockIcons.TURBINE[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE_EMPTY[iconIndex].getIcon(); + }; + } + + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; + if (tTile.getMetaTileEntity() instanceof MTELargeTurbine turbine && tTile.getFrontFacing() + .ordinal() == ordinalSide) { + if (turbine.isNewStyleRendering()) return 0; + if (tTile.isActive()) return 1; + return turbine.hasTurbine() ? 2 : 3; + } + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + aWorld = GTRenderingWorld.getInstance(aWorld); + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + + if (tMeta != 9 || !mConnectedMachineTextures) { + return getIcon(ordinalSide, tMeta); + } + + int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; + + switch (ordinalSide / 2) { + case 0 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, ordinalSide)) + != 0) { + return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); + } + } + } + } + case 1 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, ordinalSide)) + != 0) { + return getTurbineCasing( + tMeta, + 4 + i * 3 - j * tInvertLeftRightMod, + tState == 1, + tState == 2); + } + } + } + } + case 2 -> { + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + if (i == 0 && j == 0) continue; + int tState; + if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, ordinalSide)) + != 0) { + return getTurbineCasing( + tMeta, + 4 + i * 3 + j * tInvertLeftRightMod, + tState == 1, + tState == 2); + } + } + } + } + } + + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCasings9.java b/src/main/java/gregtech/common/blocks/BlockCasings9.java new file mode 100644 index 0000000000..a58ac1f25c --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasings9.java @@ -0,0 +1,96 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +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.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class BlockCasings9 extends BlockCasingsAbstract { + + public BlockCasings9() { + super(ItemCasings9.class, "gt.blockcasings9", MaterialCasings.INSTANCE, 16); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "PBI Pipe Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Advanced Filter Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".1.tooltip", "Less than five 0.1μm particles per m^3"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Primitive Wooden Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".3.name", "Superplasticizer-Treated High Strength Concrete"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Sterile Water Plant Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".5.name", "Reinforced Sterile Water Plant Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Slick Sterile Flocculation Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".7.name", "Stabilized Naquadah Water Plant Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".8.name", "Inert Neutralization Water Plant Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Reactive Gas Containment Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Inert Filtration Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".11.name", "Heat-Resistant Trinium Plated Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".12.name", "Naquadria-Reinforced Water Plant Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".13.name", "High Energy Ultraviolet Emitter Casing"); + // placeholder name + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".14.name", "Particle Beam Guidance Pipe Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".15.name", "Femtometer-Calibrated Particle Beam Casing"); + + ItemList.Casing_Pipe_Polybenzimidazole.set(new ItemStack(this, 1, 0)); + ItemList.Casing_Vent_T2.set(new ItemStack(this, 1, 1)); + ItemList.WoodenCasing.set(new ItemStack(this, 1, 2)); + ItemList.BlockIndustrialStrengthConcrete.set(new ItemStack(this, 1, 3)); + ItemList.BlockIndustrialWaterPlantCasing.set(new ItemStack(this, 1, 4)); + ItemList.BlockSterileWaterPlantCasing.set(new ItemStack(this, 1, 5)); + ItemList.BlockFlocculationCasing.set(new ItemStack(this, 1, 6)); + ItemList.BlockNaquadahReinforcedWaterPlantCasing.set(new ItemStack(this, 1, 7)); + ItemList.BlockExtremeCorrosionResistantCasing.set(new ItemStack(this, 1, 8)); + ItemList.BlockHighPressureResistantCasing.set(new ItemStack(this, 1, 9)); + ItemList.BlockOzoneCasing.set(new ItemStack(this, 1, 10)); + ItemList.BlockPlasmaHeatingCasing.set(new ItemStack(this, 1, 11)); + ItemList.BlockNaquadriaReinforcedWaterPlantCasing.set(new ItemStack(this, 1, 12)); + ItemList.BlockUltraVioletLaserEmitter.set(new ItemStack(this, 1, 13)); + ItemList.BlockQuarkPipe.set(new ItemStack(this, 1, 14)); + ItemList.BlockQuarkReleaseChamber.set(new ItemStack(this, 1, 15)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (16 << 7) | (aMeta + 16); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYBENZIMIDAZOLE.getIcon(); + case 1 -> Textures.BlockIcons.MACHINE_CASING_VENT_T2.getIcon(); + case 2 -> ordinalSide >= 2 ? Textures.BlockIcons.TEXTURE_METAL_PANEL_E.getIcon() + : Textures.BlockIcons.TEXTURE_METAL_PANEL_E_A.getIcon(); + case 3 -> Textures.BlockIcons.INDUSTRIAL_STRENGTH_CONCRETE.getIcon(); + case 4 -> Textures.BlockIcons.MACHINE_CASING_INDUSTRIAL_WATER_PLANT.getIcon(); + case 5 -> Textures.BlockIcons.WATER_PLANT_CONCRETE_CASING.getIcon(); + case 6 -> Textures.BlockIcons.MACHINE_CASING_FLOCCULATION.getIcon(); + case 7 -> Textures.BlockIcons.MACHINE_CASING_NAQUADAH_REINFORCED_WATER_PLANT.getIcon(); + case 8 -> Textures.BlockIcons.MACHINE_CASING_EXTREME_CORROSION_RESISTANT.getIcon(); + case 9 -> Textures.BlockIcons.MACHINE_CASING_HIGH_PRESSURE_RESISTANT.getIcon(); + case 10 -> Textures.BlockIcons.MACHINE_CASING_OZONE.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_PLASMA_HEATER.getIcon(); + case 12 -> Textures.BlockIcons.NAQUADRIA_REINFORCED_WATER_PLANT_CASING.getIcon(); + case 13 -> Textures.BlockIcons.UV_BACKLIGHT_STERILIZER_CASING.getIcon(); + case 14 -> Textures.BlockIcons.BLOCK_QUARK_PIPE.getIcon(); + case 15 -> Textures.BlockIcons.BLOCK_QUARK_RELEASE_CHAMBER.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + }; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCasingsAbstract.java b/src/main/java/gregtech/common/blocks/BlockCasingsAbstract.java new file mode 100644 index 0000000000..5481f1f058 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCasingsAbstract.java @@ -0,0 +1,143 @@ +package gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Textures; +import gregtech.api.items.GTGenericBlock; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLanguageManager; + +/** + * The base class for casings. Casings are the blocks that are mainly used to build multiblocks. + */ +public abstract class BlockCasingsAbstract extends GTGenericBlock + implements gregtech.api.interfaces.IHasIndexedTexture { + + public BlockCasingsAbstract(Class aItemClass, String aName, Material aMaterial) { + super(aItemClass, aName, aMaterial); + setStepSound(soundTypeMetal); + setCreativeTab(GregTechAPI.TAB_GREGTECH); + GregTechAPI.registerMachineBlock(this, -1); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); + } + + public BlockCasingsAbstract(Class aItemClass, String aName, Material aMaterial, int aMaxMeta) { + this(aItemClass, aName, aMaterial); + for (int i = 0; i < aMaxMeta; i++) { + Textures.BlockIcons.setCasingTextureForId(getTextureIndex(i), TextureFactory.of(this, i)); + } + } + + @Override + public String getHarvestTool(int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return 2; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public float getExplosionResistance(Entity aTNT) { + return Blocks.iron_block.getExplosionResistance(aTNT); + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public String getUnlocalizedName() { + return this.mUnlocalizedName; + } + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return true; + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTechAPI.isMachineBlock(this, aMetaData)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlockMetadata(aX, aY, aZ); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) {} + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { + for (int i = 0; i < 16; i++) { + ItemStack aStack = new ItemStack(aItem, 1, i); + if (!aStack.getDisplayName() + .contains(".name")) aList.add(aStack); + } + } + + /** + * Provide a fallback to subclasses in addons. + */ + @Override + public int getTextureIndex(int aMeta) { + return Textures.BlockIcons.ERROR_TEXTURE_INDEX; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockConcretes.java b/src/main/java/gregtech/common/blocks/BlockConcretes.java new file mode 100644 index 0000000000..1bf8dcf2fe --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockConcretes.java @@ -0,0 +1,83 @@ +package gregtech.common.blocks; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IBlockOnWalkOver; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; + +public class BlockConcretes extends BlockStonesAbstract implements IBlockOnWalkOver { + + public BlockConcretes() { + super(ItemConcretes.class, "gt.blockconcretes"); + setResistance(20.0F); + // this.slipperiness = 0.9F; + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Dark Concrete"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Dark Concrete Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Dark Concrete Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Dark Concrete Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Cracked Dark Concrete Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Mossy Dark Concrete Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Chiseled Dark Concrete"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Smooth Dark Concrete"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Light Concrete"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Light Concrete Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Mossy Light Concrete Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Light Concrete Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Cracked Light Concrete Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Mossy Light Concrete Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Chiseled Light Concrete"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Smooth Light Concrete"); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 0)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 1)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 2)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 3)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 4)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 5)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 6)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 7)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 8)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 9)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 10)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 11)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 12)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 13)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 14)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.Concrete, new ItemStack(this, 1, 15)); + } + + @Override + public int getHarvestLevel(int aMeta) { + return 1; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public IIcon getIcon(int ordinalSide, 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(); + } + + @Override + public void onWalkOver(EntityLivingBase aEntity, World aWorld, int aX, int aY, int aZ) { + if ((aEntity.motionX != 0 || aEntity.motionZ != 0) && !aEntity.isInWater() + && !aEntity.isWet() + && !aEntity.isSneaking()) { + double tSpeed = (aWorld.getBlock(aX, aY - 1, aZ).slipperiness >= 0.8 ? 1.5 : 1.2); + aEntity.motionX *= tSpeed; + aEntity.motionZ *= tSpeed; + } + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockCyclotronCoils.java b/src/main/java/gregtech/common/blocks/BlockCyclotronCoils.java new file mode 100644 index 0000000000..437e48a37a --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockCyclotronCoils.java @@ -0,0 +1,131 @@ +package gregtech.common.blocks; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.util.GTLanguageManager; + +public class BlockCyclotronCoils extends BlockCasingsAbstract { + + public BlockCyclotronCoils() { + super(ItemCyclotronCasings.class, "gt.blockcasings.cyclotron_coils", MaterialCasings.INSTANCE, 16); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "MV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "HV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "EV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "IV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "LuV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "ZPM Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "UV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "UHV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "UEV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "UIV Solenoid Superconductor Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "UMV Solenoid Superconductor Coil"); + + ItemList.Superconducting_Magnet_Solenoid_MV.set(new ItemStack(this, 1, 0)); + ItemList.Superconducting_Magnet_Solenoid_HV.set(new ItemStack(this, 1, 1)); + ItemList.Superconducting_Magnet_Solenoid_EV.set(new ItemStack(this, 1, 2)); + ItemList.Superconducting_Magnet_Solenoid_IV.set(new ItemStack(this, 1, 3)); + ItemList.Superconducting_Magnet_Solenoid_LuV.set(new ItemStack(this, 1, 4)); + ItemList.Superconducting_Magnet_Solenoid_ZPM.set(new ItemStack(this, 1, 5)); + ItemList.Superconducting_Magnet_Solenoid_UV.set(new ItemStack(this, 1, 6)); + ItemList.Superconducting_Magnet_Solenoid_UHV.set(new ItemStack(this, 1, 7)); + ItemList.Superconducting_Magnet_Solenoid_UEV.set(new ItemStack(this, 1, 8)); + ItemList.Superconducting_Magnet_Solenoid_UIV.set(new ItemStack(this, 1, 9)); + ItemList.Superconducting_Magnet_Solenoid_UMV.set(new ItemStack(this, 1, 10)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (2 << 7) | (aMeta); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.MV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.MV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 1 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.HV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.HV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 2 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.EV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.EV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 3 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.IV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.IV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 4 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.LuV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.LuV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 5 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.ZPM_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.ZPM_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 6 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.UV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.UV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 7 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.UHV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.UHV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 8 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.UEV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.UEV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 9 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.UIV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.UIV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + case 10 -> { + if (ordinalSide == 0 || ordinalSide == 1) { + return Textures.BlockIcons.UMV_TOP_CYCLOTRON_SOLENOID.getIcon(); + } + return Textures.BlockIcons.UMV_SIDE_CYCLOTRON_SOLENOID.getIcon(); + } + } + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + + public int getVoltageTier(int meta) { + return meta + 2; + } + + @Override + 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/BlockDrone.java b/src/main/java/gregtech/common/blocks/BlockDrone.java new file mode 100644 index 0000000000..2d1bedff9a --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockDrone.java @@ -0,0 +1,65 @@ +package gregtech.common.blocks; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.common.tileentities.render.TileEntityDrone; + +public class BlockDrone extends Block { + + public BlockDrone() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + this.setCreativeTab(GregTechAPI.TAB_GREGTECH); + this.setBlockName("gt.dronerender"); + this.setLightLevel(100.0f); + GameRegistry.registerBlock(this, getUnlocalizedName()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canRenderInPass(int a) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEntityDrone(); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(); + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockFrameBox.java b/src/main/java/gregtech/common/blocks/BlockFrameBox.java new file mode 100644 index 0000000000..59ca98ef8e --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockFrameBox.java @@ -0,0 +1,446 @@ +package gregtech.common.blocks; + +import static gregtech.api.enums.GTValues.W; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockContainer; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.metatileentity.CoverableTileEntity; +import gregtech.api.metatileentity.implementations.MTEFrame; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gregtech.common.render.GTRendererBlock; + +public class BlockFrameBox extends BlockContainer { + + protected final String mUnlocalizedName; + + private static final String DOT_NAME = ".name"; + private static final String DOT_TOOLTIP = ".tooltip"; + + // We need to keep around a temporary TE to preserve this TE after breaking the block, so we can + // properly call getDrops() on it + private static final ThreadLocal mTemporaryTileEntity = new ThreadLocal<>(); + + public BlockFrameBox() { + super(new MaterialMachines()); + this.mUnlocalizedName = "gt.blockframes"; + setBlockName(this.mUnlocalizedName); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + "." + W + ".name", "Any Sub Block of this one"); + + GameRegistry.registerBlock(this, ItemFrames.class, getUnlocalizedName()); + + for (int meta = 1; meta < GregTechAPI.sGeneratedMaterials.length; meta++) { + Materials material = GregTechAPI.sGeneratedMaterials[meta]; + if (material != null && (material.mTypes & 0x02) != 0) { + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + meta + DOT_NAME, + GTLanguageManager.i18nPlaceholder ? getLocalizedNameFormat(material) : getLocalizedName(material)); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + "." + meta + DOT_TOOLTIP, material.getToolTip()); + } + } + } + + public ItemStack getStackForm(int amount, int meta) { + return new ItemStack(this, amount, meta); + } + + public String getLocalizedNameFormat(Materials aMaterial) { + return switch (aMaterial.mName) { + case "InfusedAir", "InfusedDull", "InfusedEarth", "InfusedEntropy", "InfusedFire", "InfusedOrder", "InfusedVis", "InfusedWater" -> "%material Infused Stone"; + case "Vermiculite", "Bentonite", "Kaolinite", "Talc", "BasalticMineralSand", "GraniticMineralSand", "GlauconiteSand", "CassiteriteSand", "GarnetSand", "QuartzSand", "Pitchblende", "FullersEarth" -> "%material"; + default -> "%material" + " Frame Box"; + }; + } + + @Override + public String getUnlocalizedName() { + return mUnlocalizedName; + } + + public String getLocalizedName(Materials aMaterial) { + return aMaterial.getDefaultLocalizedNameForItem(getLocalizedNameFormat(aMaterial)); + } + + private boolean isCover(ItemStack item) { + return GTUtility.isStackInList(item, GregTechAPI.sCovers.keySet()); + } + + private void createFrame(World worldIn, int x, int y, int z, BaseMetaPipeEntity baseMte) { + // Obtain metadata to grab proper material identifier + int meta = worldIn.getBlockMetadata(x, y, z); + Materials material = getMaterial(meta); + MTEFrame frame = new MTEFrame("GT_Frame_" + material, material); + baseMte.setMetaTileEntity(frame); + frame.setBaseMetaTileEntity(baseMte); + } + + private BaseMetaPipeEntity spawnFrameEntity(World worldIn, int x, int y, int z) { + // Spawn a TE frame box at this location, then apply the cover + BaseMetaPipeEntity newTileEntity = new BaseMetaPipeEntity(); + createFrame(worldIn, x, y, z, newTileEntity); + worldIn.setTileEntity(x, y, z, newTileEntity); + return newTileEntity; + } + + // Get the material that this frame box is made of + public static Materials getMaterial(int meta) { + return GregTechAPI.sGeneratedMaterials[meta]; + } + + @Override + public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, + float subY, float subZ) { + // Get ForgeDirection from side identifier. + ForgeDirection direction = ForgeDirection.getOrientation(side); + // If this block already holds a TE, just forward the call + TileEntity te = worldIn.getTileEntity(x, y, z); + if (te instanceof BaseMetaPipeEntity baseTileEntity) { + // If this baseTileEntity has no MetaTileEntity associated with it, we need to create it + // This happens on world load for some reason + if (baseTileEntity.getMetaTileEntity() == null) { + createFrame(worldIn, x, y, z, baseTileEntity); + } + return baseTileEntity.onRightclick(player, direction, subX, subY, subZ); + } + + // If there was no TileEntity yet, we need to check if the player was holding a cover item and if so + // spawn a new frame box to apply the cover to + ItemStack item = player.getHeldItem(); + if (isCover(item)) { + BaseMetaPipeEntity newTileEntity = spawnFrameEntity(worldIn, x, y, z); + newTileEntity.onRightclick(player, direction, subX, subY, subZ); + return true; + } + + return false; + } + + @Override + public int getRenderType() { + if (GTRendererBlock.INSTANCE == null) { + return super.getRenderType(); + } + return GTRendererBlock.mRenderID; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderBlockPass() { + return 1; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + for (int i = 0; i < GregTechAPI.sGeneratedMaterials.length; i++) { + Materials tMaterial = GregTechAPI.sGeneratedMaterials[i]; + // If material is not null and has a frame box item associated with it + if ((tMaterial != null) && ((tMaterial.mTypes & 0x02) != 0)) { + aList.add(new ItemStack(aItem, 1, i)); + } + } + } + + @Override + public String getHarvestTool(int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return aMeta % 4; + } + + @Override + public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + ForgeDirection forgeSide = switch (ordinalSide) { + case (-2) -> ForgeDirection.DOWN; + case (-1) -> ForgeDirection.UP; + case (0) -> ForgeDirection.NORTH; + case (2) -> ForgeDirection.SOUTH; + case (3) -> ForgeDirection.WEST; + case (1) -> ForgeDirection.EAST; + default -> ForgeDirection.UNKNOWN; + }; + final TileEntity frameEntity = aWorld.getTileEntity(aX, aY, aZ); + return frameEntity instanceof CoverableTileEntity cte && cte.getCoverInfoAtSide(forgeSide) + .getCoverID() != 0; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlockMetadata(aX, aY, aZ); + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onBlockDestroyed(); + mTemporaryTileEntity.set(gtTE); + } + // Cause structure update + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetadata); + } + + @Override + public void onBlockAdded(World worldIn, int x, int y, int z) { + // Cause structure update + GregTechAPI.causeMachineUpdate(worldIn, x, y, z); + super.onBlockAdded(worldIn, x, y, z); + } + + @Override + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + gtTE.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + return; + } + super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); + } + + @Override + public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return (tTileEntity instanceof BaseMetaTileEntity baseMTE) && baseMTE.privateAccess() + && !baseMTE.playerOwnsThis(aPlayer, true) ? -1.0F + : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); + } + + @Override + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseTileEntity baseTE) { + baseTE.onAdjacentBlockChange(aTileX, aTileY, aTileZ); + } + } + + @Override + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaPipeEntity baseMetaPipe) { + baseMetaPipe.onNeighborBlockChange(aX, aY, aZ); + } + } + + @Override + public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, + List outputAABB, Entity collider) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + gtTE.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + return; + } + super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + return gtTE.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + return gtTE.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @Override + public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { + if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { + return true; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaTileEntity) { + return true; + } + if (tTileEntity instanceof BaseMetaPipeEntity baseMetaPipe && (baseMetaPipe.mConnections & 0xFFFFFFC0) != 0) { + return true; + } + return (tTileEntity instanceof ICoverable coverable) && coverable.getCoverIDAtSide(side) != 0; + } + + @Override // THIS + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { + final TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { + final AxisAlignedBB bbb = gtTE.getCollisionBoundingBoxFromPool(gtTE.getWorld(), 0, 0, 0); + minX = bbb.minX; // This essentially sets block bounds + minY = bbb.minY; + minZ = bbb.minZ; + maxX = bbb.maxX; + maxY = bbb.maxY; + maxZ = bbb.maxZ; + return; + } + super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); + } + + @Override + public void setBlockBoundsForItemRender() { + super.setBlockBounds(0, 0, 0, 1, 1, 1); + } + + @Override + public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return 0; + } + + @Override + public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return 0; + } + + @Override + public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { + return false; + } + + @Override + public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean hasTileEntity(int aMeta) { + return true; + } + + @Override + public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { + super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity != null && tTileEntity.receiveClientEvent(aData1, aData2); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { + // Find temporary TE if there was one + final IGregTechTileEntity tempTe = mTemporaryTileEntity.get(); + ArrayList drops = new ArrayList<>(); + drops.add(getStackForm(1, metadata)); + // If there is one, grab all attached covers and drop them + if (tempTe != null) { + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + ItemStack cover = tempTe.getCoverItemAtSide(direction); + if (cover != null) drops.add(cover); + } + } + // Make sure to clear the temporary TE + mTemporaryTileEntity.remove(); + return drops; + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { + return 0; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); + } + return 0; + } + + @Override + public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { + return 0; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getStrongOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); + } + return 0; + } + + @Override + public IIcon getIcon(int side, int meta) { + Materials material = GregTechAPI.sGeneratedMaterials[meta]; + if (material == null) return null; + return material.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon(); + } + + public ITexture[] getTexture(int meta) { + Materials material = getMaterial(meta); + if (material == null) return null; + return new ITexture[] { TextureFactory.of( + material.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex], + Dyes.getModulation(-1, material.mRGBa)) }; + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + return null; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockGlass1.java b/src/main/java/gregtech/common/blocks/BlockGlass1.java new file mode 100644 index 0000000000..a8a287248b --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockGlass1.java @@ -0,0 +1,107 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +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.util.GTLanguageManager; + +/** + * The glass is split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + * + * This class hosts various special types of tiered glass with not many tiers. + */ +public class BlockGlass1 extends BlockCasingsAbstract { + + public BlockGlass1() { + super(ItemGlass1.class, "gt.blockglass1", Material.glass, 4); + this.opaque = false; + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemical Grade Glass"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".1.name", "Electron-Permeable Neutronium Coated Glass"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Omni-Purpose Infinity Fused Glass"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".3.name", "Non-Photonic Matter Exclusion Glass"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".4.name", "Hawking Radiation Realignment Focus"); + + ItemList.GlassPHResistant.set(new ItemStack(this, 1, 0)); + ItemList.GlassUVResistant.set(new ItemStack(this, 1, 1)); + ItemList.GlassOmniPurposeInfinityFused.set(new ItemStack(this, 1, 2)); + ItemList.GlassQuarkContainment.set(new ItemStack(this, 1, 3)); + ItemList.GlassQuarkContainment.set(new ItemStack(this, 1, 3)); + ItemList.Hawking_Glass.set(new ItemStack(this, 1, 4)); + } + + @Override + public int getTextureIndex(int aMeta) { + // Page 16, 0-16 + return (16 << 7) | (aMeta); + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.GLASS_PH_RESISTANT.getIcon(); + case 1 -> Textures.BlockIcons.NEUTRONIUM_COATED_UV_RESISTANT_GLASS.getIcon(); + case 2 -> Textures.BlockIcons.OMNI_PURPOSE_INFINITY_FUSED_GLASS.getIcon(); + case 3 -> Textures.BlockIcons.GLASS_QUARK_CONTAINMENT.getIcon(); + case 4 -> Textures.BlockIcons.HAWKING_GLASS.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + }; + } + + /** + * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given + * coordinates. Args: blockAccess, x, y, z, side + */ + @SideOnly(Side.CLIENT) + @Override + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + Block block = worldIn.getBlock(x, y, z); + + if (worldIn.getBlockMetadata(x, y, z) != worldIn.getBlockMetadata( + x - Facing.offsetsXForSide[side], + y - Facing.offsetsYForSide[side], + z - Facing.offsetsZForSide[side])) { + return true; + } + + if (block == this) { + return false; + } + + return super.shouldSideBeRendered(worldIn, x, y, z, side); + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockGranites.java b/src/main/java/gregtech/common/blocks/BlockGranites.java new file mode 100644 index 0000000000..43a3f7a7e2 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockGranites.java @@ -0,0 +1,77 @@ +package gregtech.common.blocks; + +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; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; + +public class BlockGranites extends BlockStonesAbstract { + + public BlockGranites() { + super(ItemGranites.class, "gt.blockgranites"); + setResistance(60.0F); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Black Granite"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Black Granite Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Black Granite Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Black Granite Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Cracked Black Granite Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Mossy Black Granite Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Chiseled Black Granite"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Smooth Black Granite"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Red Granite"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Red Granite Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Mossy Red Granite Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Red Granite Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Cracked Red Granite Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Mossy Red Granite Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Chiseled Red Granite"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Smooth Red Granite"); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 0)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 1)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 2)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 3)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 4)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 5)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 6)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteBlack, new ItemStack(this, 1, 7)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 8)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 9)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 10)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 11)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 12)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 13)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 14)); + GTOreDictUnificator.registerOre(OrePrefixes.stone, Materials.GraniteRed, new ItemStack(this, 1, 15)); + } + + @Override + public int getHarvestLevel(int aMeta) { + return 3; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; + } + + @Override + public IIcon getIcon(int ordinalSide, 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(); + } + + @Override + 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/BlockLaser.java b/src/main/java/gregtech/common/blocks/BlockLaser.java new file mode 100644 index 0000000000..8a67ed6bc9 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockLaser.java @@ -0,0 +1,104 @@ +package gregtech.common.blocks; + +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.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.tileentities.render.TileEntityLaser; + +public class BlockLaser extends Block implements ITileEntityProvider { + + public static IIcon[] textures; + + public BlockLaser() { + super(Material.iron); + setBlockName("LaserPlate"); + this.setCreativeTab(GregTechAPI.TAB_GREGTECH); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".name", "Laser Resistant Plate"); + GregTechAPI.registerMachineBlock(this, -1); + GameRegistry.registerBlock(this, ItemBlockLaser.class, getUnlocalizedName()); + ItemList.Laser_Plate.set(new ItemStack(this, 1)); + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTechAPI.isMachineBlock(this, aMetaData)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public String getHarvestTool(int aMeta) { + return "wrench"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return 2; + } + + @Override + public String getUnlocalizedName() { + return "gt.laserplate"; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = Textures.BlockIcons.LASER_PLATE.getIcon(); + } + + @Override + public IIcon getIcon(int side, int meta) { + return blockIcon; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public float getBlockHardness(World world, int x, int y, int z) { + return 1.0f; + } + + @Override + public int damageDropped(int meta) { + return meta; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityLaser(); + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockMachines.java b/src/main/java/gregtech/common/blocks/BlockMachines.java new file mode 100644 index 0000000000..1db6f51730 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockMachines.java @@ -0,0 +1,703 @@ +package gregtech.common.blocks; + +import static gregtech.GTMod.GT_FML_LOGGER; +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + +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.init.Blocks; +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.StatCollector; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import com.cricketcraft.chisel.api.IFacade; + +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IDebugableBlock; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IDebugableTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.items.GTGenericBlock; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.metatileentity.CoverableTileEntity; +import gregtech.api.util.GTBaseCrop; +import gregtech.api.util.GTLog; +import gregtech.api.util.GTUtility; +import gregtech.common.covers.CoverInfo; +import gregtech.common.render.GTRendererBlock; +import gregtech.common.tileentities.storage.MTEQuantumChest; +import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.MTERedstoneBase; + +@Optional.Interface(iface = "com.cricketcraft.chisel.api.IFacade", modid = "ChiselAPI") +public class BlockMachines extends GTGenericBlock implements IDebugableBlock, ITileEntityProvider, IFacade { + + private static final ThreadLocal mTemporaryTileEntity = new ThreadLocal<>(); + private boolean renderAsNormalBlock; + + public BlockMachines() { + super(ItemMachines.class, "gt.blockmachines", new MaterialMachines()); + GregTechAPI.registerMachineBlock(this, -1); + setHardness(1.0F); + setResistance(10.0F); + setStepSound(soundTypeMetal); + setCreativeTab(GregTechAPI.TAB_GREGTECH); + this.isBlockContainer = true; + this.renderAsNormalBlock = true; + this.useNeighborBrightness = true; + } + + @Override + public String getHarvestTool(int aMeta) { + if (aMeta >= 8 && aMeta <= 11) { + return "cutter"; + } + return "wrench"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return aMeta % 4; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof BaseTileEntity)) { + ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); + } + } + + @Override + public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof BaseMetaPipeEntity)) { + ((BaseMetaPipeEntity) tTileEntity).onNeighborBlockChange(aX, aY, aZ); + } + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + super.onBlockAdded(aWorld, aX, aY, aZ); + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public String getUnlocalizedName() { + return "gt.blockmachines"; + } + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(getUnlocalizedName() + ".name"); + } + + @Override + public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return 0; + } + + @Override + public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return GregTechAPI.sMachineFlammable && (aWorld.getBlockMetadata(aX, aY, aZ) == 0) ? 100 : 0; + } + + @Override + public int getRenderType() { + if (GTRendererBlock.INSTANCE == null) { + return super.getRenderType(); + } + return GTRendererBlock.INSTANCE.mRenderID; + } + + @Override + public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { + return GregTechAPI.sMachineFlammable && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); + } + + @Override + public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { + return GregTechAPI.sMachineFlammable && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + ForgeDirection forgeSide = switch (ordinalSide) { + case (-2) -> ForgeDirection.DOWN; + case (-1) -> ForgeDirection.UP; + case (0) -> ForgeDirection.NORTH; + case (2) -> ForgeDirection.SOUTH; + case (3) -> ForgeDirection.WEST; + case (1) -> ForgeDirection.EAST; + default -> ForgeDirection.UNKNOWN; + }; + final TileEntity machineEntity = aWorld.getTileEntity(aX, aY, aZ); + return machineEntity instanceof BaseMetaTileEntity bmte && (bmte.getCoverInfoAtSide(forgeSide) + .getCoverID() != 0 || bmte.getMetaTileEntity() instanceof MTERedstoneBase); + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean hasTileEntity(int aMeta) { + return true; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return renderAsNormalBlock; + } + + public BlockMachines setRenderAsNormalBlock(boolean aBool) { + renderAsNormalBlock = aBool; + return this; + } + + @Override + public boolean canProvidePower() { + return true; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public TileEntity createNewTileEntity(World aWorld, int aMeta) { + return createTileEntity(aWorld, aMeta); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { + return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + @SideOnly(Side.CLIENT) + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); + } + + @Override + public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { + super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity != null && tTileEntity.receiveClientEvent(aData1, aData2); + } + + @Override + public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, + List outputAABB, Entity collider) { + final 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); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { + return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); + } + + @Override // THIS + public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { + final TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity + && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { + final AxisAlignedBB bbb = ((IGregTechTileEntity) tTileEntity) + .getCollisionBoundingBoxFromPool(((IGregTechTileEntity) tTileEntity).getWorld(), 0, 0, 0); + minX = bbb.minX; // This essentially sets block bounds + minY = bbb.minY; + minZ = bbb.minZ; + maxX = bbb.maxX; + maxY = bbb.maxY; + maxZ = bbb.maxZ; + return; + } + super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); + } + + @Override + public void setBlockBoundsForItemRender() { + super.setBlockBounds(0, 0, 0, 1, 1, 1); + } + + @Override + public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { + final 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) + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + if (!GregTechAPI.sPostloadFinished) return; + GTLog.out.println("GTMod: Setting up Icon Register for Blocks"); + GregTechAPI.setBlockIconRegister(aIconRegister); + + GTLog.out.println("GTMod: Registering MetaTileEntity specific Textures"); + try { + for (int i = 1; i < GregTechAPI.METATILEENTITIES.length; i++) { + if (GregTechAPI.METATILEENTITIES[i] != null) { + GregTechAPI.METATILEENTITIES[i].registerIcons(aIconRegister); + } + } + } catch (Exception e) { + e.printStackTrace(GTLog.err); + } + GTLog.out.println("GTMod: Registering Crop specific Textures"); + try { + for (GTBaseCrop tCrop : GTBaseCrop.sCropList) { + tCrop.registerSprites(aIconRegister); + } + } catch (Exception e) { + e.printStackTrace(GTLog.err); + } + GTLog.out.println("GTMod: Starting Block Icon Load Phase"); + GT_FML_LOGGER.info("GTMod: Starting Block Icon Load Phase"); + try { + for (Runnable tRunnable : GregTechAPI.sGTBlockIconload) { + tRunnable.run(); + } + } catch (Exception e) { + e.printStackTrace(GTLog.err); + } + GTLog.out.println("GTMod: Finished Block Icon Load Phase"); + GT_FML_LOGGER.info("GTMod: Finished Block Icon Load Phase"); + } + + @Override + public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) tTileEntity).privateAccess() + && !((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true) ? -1.0F + : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); + } + + @Override + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, + float aOffsetX, float aOffsetY, float aOffsetZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity == null) { + return false; + } + if (aPlayer.isSneaking()) { + final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + if (tCurrentItem != null && !GTUtility.isStackInList(tCurrentItem, GregTechAPI.sScrewdriverList) + && !GTUtility.isStackInList(tCurrentItem, GregTechAPI.sWrenchList) + && !GTUtility.isStackInList(tCurrentItem, GregTechAPI.sWireCutterList) + && !GTUtility.isStackInList(tCurrentItem, GregTechAPI.sSolderingToolList) + && !GTUtility.isStackInList(tCurrentItem, GregTechAPI.sJackhammerList)) return false; + } + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + if (gtTE.getTimer() < 1L) { + return false; + } + if ((!aWorld.isRemote) && !gtTE.isUseableByPlayer(aPlayer)) { + return true; + } + return ((IGregTechTileEntity) tTileEntity) + .onRightclick(aPlayer, ForgeDirection.getOrientation(ordinalSide), aOffsetX, aOffsetY, aOffsetZ); + } + return false; + } + + @Override + public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onLeftclick(aPlayer); + } + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getMetaTileID(); + } + return 0; + } + + @Override + public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaTileEntity baseTE) { + GTLog.exp.printf( + "Explosion at : %d | %d | %d DIMID: %s due to near explosion!%n", + aX, + aY, + aZ, + aWorld.provider.dimensionId); + baseTE.doEnergyExplosion(); + } + super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onBlockDestroyed(); + mTemporaryTileEntity.set(gtTE); + if (!(gtTE.getMetaTileEntity() instanceof MTEQuantumChest)) { + for (int i = 0; i < gtTE.getSizeInventory(); i++) { + final ItemStack tItem = gtTE.getStackInSlot(i); + if ((tItem != null) && (tItem.stackSize > 0) && (gtTE.isValidSlot(i)) && gtTE.shouldDropItemAt(i)) { + final EntityItem tItemEntity = new EntityItem( + aWorld, + aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + aY + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + aZ + XSTR_INSTANCE.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 = (XSTR_INSTANCE.nextGaussian() * 0.05D); + tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.25D); + tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.05D); + aWorld.spawnEntityInWorld(tItemEntity); + tItem.stackSize = 0; + gtTE.setInventorySlotContents(i, null); + } + } + } + } + super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetadata); + aWorld.removeTileEntity(aX, aY, aZ); + } + + @Override + public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getDrops(); + } + final IGregTechTileEntity tGregTechTileEntity = mTemporaryTileEntity.get(); + final ArrayList tDrops; + if (tGregTechTileEntity == null) { + tDrops = new ArrayList<>(); + } else { + tDrops = tGregTechTileEntity.getDrops(); + mTemporaryTileEntity.remove(); + } + return tDrops; + } + + @Override + public boolean removedByPlayer(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, boolean aWillHarvest) { + // This delays deletion of the block until after getDrops + return aWillHarvest || super.removedByPlayer(aWorld, aPlayer, aX, aY, aZ, false); + } + + @Override + public void harvestBlock(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, int aMeta) { + super.harvestBlock(aWorld, aPlayer, aX, aY, aZ, aMeta); + aWorld.setBlockToAir(aX, aY, aZ); + } + + @Override + public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int ordinalSide) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getComparatorValue(ForgeDirection.getOrientation(ordinalSide)); + } + return 0; + } + + @Override + public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { + return 0; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); + } + return 0; + } + + @Override + public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { + return 0; + } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getStrongOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); + } + return 0; + } + + @Override + public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int aMetadata, float chance, + int aFortune) { + if (!aWorld.isRemote) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity != null && (chance < 1.0F)) { + if (tTileEntity instanceof BaseMetaTileEntity bmte && (GregTechAPI.sMachineNonWrenchExplosions)) { + GTLog.exp.printf( + "Explosion at : %d | %d | %d DIMID: %s NonWrench picking/Rain!%n", + aX, + aY, + aZ, + aWorld.provider.dimensionId); + bmte.doEnergyExplosion(); + } + } else { + super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, aMetadata, chance, aFortune); + } + } + } + + @Override + public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { + if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { + return true; + } + final 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; + } + return tTileEntity instanceof ICoverable && ((ICoverable) tTileEntity).getCoverIDAtSide(side) != 0; + } + return false; + } + + @Override + public boolean isBlockNormalCube() { + return true; + } + + /** + * Returns the default ambient occlusion value based on block opacity + */ + @SideOnly(Side.CLIENT) + @Override + public float getAmbientOcclusionLightValue() { + return this.renderAsNormalBlock() ? 0.2F : 0.5F; + } + + /** + * @inheritDoc + */ + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World aWorld, int aX, int aY, int aZ, Random aRandom) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + ((IGregTechTileEntity) tTileEntity).onRandomDisplayTick(); + } + } + + @Override + public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + return ((IGregTechTileEntity) tTileEntity).getLightOpacity(); + } + return aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0; + } + + @Override + public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof BaseMetaTileEntity) { + return ((BaseMetaTileEntity) tTileEntity).getLightValue(); + } + return 0; + } + + @Override + public TileEntity createTileEntity(World aWorld, int aMeta) { + return GregTechAPI.createTileEntity(aMeta); + } + + @Override + public float getExplosionResistance(Entity entity, World aWorld, int aX, int aY, int aZ, double explosionX, + double explosionY, double explosionZ) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity) { + return ((IGregTechTileEntity) tTileEntity).getBlastResistance(ForgeDirection.UNKNOWN); + } + return 10.0F; + } + + @SideOnly(Side.CLIENT) + @Override + public void getSubBlocks(Item item, CreativeTabs aCreativeTab, List outputSubBlocks) { + for (int i = 1; i < GregTechAPI.METATILEENTITIES.length; i++) { + if (GregTechAPI.METATILEENTITIES[i] != null) { + outputSubBlocks.add(new ItemStack(item, 1, i)); + } + } + } + + @Override + public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity iGregTechTileEntity)) return; + iGregTechTileEntity.setFrontFacing( + BaseTileEntity.getSideForPlayerPlacing(aPlayer, ForgeDirection.UP, iGregTechTileEntity.getValidFacings())); + } + + @Override + public ArrayList getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { + final TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IDebugableTileEntity) { + return ((IDebugableTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); + } + return new ArrayList<>(); + } + + @Override + public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection side, int aColor) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IColoredTileEntity coloredTE) { + if (coloredTE.getColorization() == (byte) ((~aColor) & 0xF)) { + return false; + } + coloredTE.setColorization((byte) ((~aColor) & 0xF)); + return true; + } + return false; + } + + @Override + public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof CoverableTileEntity tile) { + final ForgeDirection dir = ForgeDirection.getOrientation(ordinalSide); + if (dir != ForgeDirection.UNKNOWN) { + final Block facadeBlock = tile.getCoverInfoAtSide(dir) + .getFacadeBlock(); + if (facadeBlock != null) return facadeBlock; + } else { + // we do not allow more than one type of facade per block, so no need to check every side + // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable + for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { + final Block facadeBlock = tile.getCoverInfoAtSide(tSide) + .getFacadeBlock(); + if (facadeBlock != null) { + return facadeBlock; + } + } + } + } + return Blocks.air; + } + + @Override + public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof CoverableTileEntity tile) { + final ForgeDirection dir = ForgeDirection.getOrientation(ordinalSide); + if (ordinalSide != -1) { + final CoverInfo coverInfo = tile.getCoverInfoAtSide(dir); + final Block facadeBlock = coverInfo.getFacadeBlock(); + if (facadeBlock != null) return coverInfo.getFacadeMeta(); + } else { + // we do not allow more than one type of facade per block, so no need to check every side + // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable + for (final ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { + final CoverInfo coverInfo = tile.getCoverInfoAtSide(d); + final Block facadeBlock = coverInfo.getFacadeBlock(); + if (facadeBlock != null) { + return coverInfo.getFacadeMeta(); + } + } + } + } + return 0; + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockMetal.java b/src/main/java/gregtech/common/blocks/BlockMetal.java new file mode 100644 index 0000000000..642de8b39c --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockMetal.java @@ -0,0 +1,68 @@ +package gregtech.common.blocks; + +import static gregtech.api.enums.Mods.NotEnoughItems; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; + +public class BlockMetal extends BlockStorage { + + public Materials[] mMats; + public OrePrefixes mPrefix; + public IIconContainer[] mBlockIcons; + public boolean mHideBlocks; + public static boolean mNEIisLoaded = NotEnoughItems.isModLoaded(); + + public BlockMetal(String aName, Materials[] aMats, OrePrefixes aPrefix, IIconContainer[] aBlockIcons) { + super(ItemStorage.class, aName, Material.iron); + mMats = aMats; + mPrefix = aPrefix; + mBlockIcons = aBlockIcons; + mHideBlocks = mNEIisLoaded; + + for (int i = 0; i < aMats.length; i++) { + if (aMats[i].mMetaItemSubID > 0 && aMats[i].mHasParentMod) { + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + i + ".name", + "Block of " + (GTLanguageManager.i18nPlaceholder ? "%material" : aMats[i].mDefaultLocalName)); + GTOreDictUnificator.registerOre(aPrefix, aMats[i], new ItemStack(this, 1, i)); + } + } + if (aMats.length < 16 && mNEIisLoaded) { + for (int i = aMats.length; i < 16; i++) codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i)); + } + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + if ((aMeta >= 0) && (aMeta < 16) && aMeta < mMats.length) { + return mBlockIcons[aMeta].getIcon(); + } + return null; + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { + if (GregTechAPI.isMachineBlock(this, aMetaData)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + +} diff --git a/src/main/java/gregtech/common/blocks/BlockOres.java b/src/main/java/gregtech/common/blocks/BlockOres.java new file mode 100644 index 0000000000..f2ae18f195 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockOres.java @@ -0,0 +1,154 @@ +package gregtech.common.blocks; + +import static gregtech.api.enums.Textures.BlockIcons.BASALT_STONE; +import static gregtech.api.enums.Textures.BlockIcons.GRANITE_BLACK_STONE; +import static gregtech.api.enums.Textures.BlockIcons.GRANITE_RED_STONE; +import static gregtech.api.enums.Textures.BlockIcons.MARBLE_STONE; + +import java.util.Arrays; + +import net.minecraft.block.Block; +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GTMod; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; + +public class BlockOres extends BlockOresAbstract { + + private static final String UNLOCALIZED_NAME = "gt.blockores"; + + public BlockOres() { + super(UNLOCALIZED_NAME, 7, false, Material.rock); + } + + @Override + public String getUnlocalizedName() { + return UNLOCALIZED_NAME; + } + + @Override + public OrePrefixes[] getProcessingPrefix() { // Must have 8 entries; an entry can be null to disable automatic + // recipes. + return new OrePrefixes[] { OrePrefixes.ore, OrePrefixes.oreNetherrack, OrePrefixes.oreEndstone, + OrePrefixes.oreBlackgranite, OrePrefixes.oreRedgranite, OrePrefixes.oreMarble, OrePrefixes.oreBasalt, + null }; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int meta) { + int index = ((meta / 1000) % 16); + return switch (index) { + case 1 -> Blocks.netherrack.getIcon(ordinalSide, 0); + case 2 -> Blocks.end_stone.getIcon(ordinalSide, 0); + case 3 -> GRANITE_BLACK_STONE.getIcon(); + case 4 -> GRANITE_RED_STONE.getIcon(); + case 5 -> MARBLE_STONE.getIcon(); + case 6 -> BASALT_STONE.getIcon(); + default -> Blocks.stone.getIcon(ordinalSide, 0); + }; + } + + /** + * @inheritDoc + */ + @Override + public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { + return (side == ForgeDirection.UP && getDamageValue(world, x, y, z) / 1000 % 16 == 1); + } + + /** + * @inheritDoc + */ + @Override + public MapColor getMapColor(int meta) { + return meta == 1 ? MapColor.netherrackColor : MapColor.stoneColor; + } + + @Override + public int getBaseBlockHarvestLevel(int aMeta) { + return switch (aMeta) { + case 3, 4 -> 3; + default -> 0; + }; + } + + @Override + public Block getDroppedBlock() { + return GregTechAPI.sBlockOres1; + } + + @Override + public Materials[] getDroppedDusts() { // Must have 8 entries; can be null. + return new Materials[] { Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, + Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone }; + } + + @Override + public boolean[] getEnabledMetas() { + return new boolean[] { true, true, true, GTMod.gregtechproxy.enableBlackGraniteOres, + GTMod.gregtechproxy.enableRedGraniteOres, GTMod.gregtechproxy.enableMarbleOres, + GTMod.gregtechproxy.enableBasaltOres, true }; + } + + @Override + public ITexture[] getTextureSet() { + final ITexture[] rTextures = new ITexture[16]; // Must have 16 entries. + Arrays.fill(rTextures, TextureFactory.of(Blocks.stone)); + rTextures[1] = TextureFactory.of(Blocks.netherrack); + rTextures[2] = TextureFactory.of(Blocks.end_stone); + rTextures[3] = TextureFactory.builder() + .addIcon(GRANITE_BLACK_STONE) + .stdOrient() + .build(); + rTextures[4] = TextureFactory.builder() + .addIcon(GRANITE_RED_STONE) + .stdOrient() + .build(); + rTextures[5] = TextureFactory.builder() + .addIcon(MARBLE_STONE) + .stdOrient() + .build(); + rTextures[6] = TextureFactory.builder() + .addIcon(BASALT_STONE) + .stdOrient() + .build(); + return rTextures; + } + + @Override + public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) { + + if (EnchantmentHelper.getSilkTouchModifier(player)) { + TileEntityOres.shouldSilkTouch = true; + super.harvestBlock(worldIn, player, x, y, z, meta); + + if (TileEntityOres.shouldSilkTouch) { + TileEntityOres.shouldSilkTouch = false; + } + return; + } + + if (!(player instanceof FakePlayer)) { + TileEntityOres.shouldFortune = true; + } + super.harvestBlock(worldIn, player, x, y, z, meta); + if (TileEntityOres.shouldFortune) { + TileEntityOres.shouldFortune = false; + } + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockOresAbstract.java b/src/main/java/gregtech/common/blocks/BlockOresAbstract.java new file mode 100644 index 0000000000..f147c1c41d --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockOresAbstract.java @@ -0,0 +1,324 @@ +package gregtech.common.blocks; + +import static gregtech.api.enums.Mods.NotEnoughItems; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.particle.EffectRenderer; +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.entity.player.EntityPlayer; +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.MovingObjectPosition; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GTMod; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.items.GTGenericBlock; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; +import gregtech.common.render.GTRendererBlock; + +public abstract class BlockOresAbstract extends GTGenericBlock implements ITileEntityProvider { + + private static final String DOT_NAME = ".name"; + private static final String DOT_TOOLTIP = ".tooltip"; + public static ThreadLocal mTemporaryTileEntity = new ThreadLocal<>(); + public static boolean FUCKING_LOCK = false; + public static boolean tHideOres; + public static Set aBlockedOres = new HashSet<>(); + + protected BlockOresAbstract(String aUnlocalizedName, int aOreMetaCount, boolean aHideFirstMeta, + Material aMaterial) { + super(ItemOres.class, aUnlocalizedName, aMaterial); + this.isBlockContainer = true; + setStepSound(soundTypeStone); + setCreativeTab(GregTechAPI.TAB_GREGTECH_ORES); + tHideOres = NotEnoughItems.isModLoaded() && GTMod.gregtechproxy.mHideUnusedOres; + if (aOreMetaCount > 8 || aOreMetaCount < 0) aOreMetaCount = 8; + + for (int i = 0; i < 16; i++) { + GTModHandler.addValuableOre(this, i, 1); + } + for (int i = 1; i < GregTechAPI.sGeneratedMaterials.length; i++) { + if (GregTechAPI.sGeneratedMaterials[i] != null) { + for (int j = 0; j < aOreMetaCount; j++) { + if (!this.getEnabledMetas()[j]) continue; + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + (i + (j * 1000)) + DOT_NAME, + GTLanguageManager.i18nPlaceholder ? getLocalizedNameFormat(GregTechAPI.sGeneratedMaterials[i]) + : getLocalizedName(GregTechAPI.sGeneratedMaterials[i])); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + (i + (j * 1000)) + DOT_TOOLTIP, + GregTechAPI.sGeneratedMaterials[i].getToolTip()); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + ((i + 16000) + (j * 1000)) + DOT_NAME, + "Small " + (GTLanguageManager.i18nPlaceholder + ? getLocalizedNameFormat(GregTechAPI.sGeneratedMaterials[i]) + : getLocalizedName(GregTechAPI.sGeneratedMaterials[i]))); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + ((i + 16000) + (j * 1000)) + DOT_TOOLTIP, + GregTechAPI.sGeneratedMaterials[i].getToolTip()); + if ((GregTechAPI.sGeneratedMaterials[i].mTypes & 0x8) != 0 + && !aBlockedOres.contains(GregTechAPI.sGeneratedMaterials[i])) { + GTOreDictUnificator.registerOre( + this.getProcessingPrefix()[j] != null + ? this.getProcessingPrefix()[j].get(GregTechAPI.sGeneratedMaterials[i]) + : "", + new ItemStack(this, 1, i + (j * 1000))); + if (tHideOres) { + if (!(j == 0 && !aHideFirstMeta)) { + codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + (j * 1000))); + } + codechicken.nei.api.API.hideItem(new ItemStack(this, 1, (i + 16000) + (j * 1000))); + } + } + } + } + } + } + + public int getBaseBlockHarvestLevel(int aMeta) { + return 0; + } + + @Override + 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 TileEntityOres)) { + ((TileEntityOres) tTileEntity).onUpdated(); + } + } + FUCKING_LOCK = false; + } + + @Override + 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 TileEntityOres)) { + ((TileEntityOres) tTileEntity).onUpdated(); + } + } + FUCKING_LOCK = false; + } + + public String getLocalizedNameFormat(Materials aMaterial) { + return switch (aMaterial.mName) { + case "InfusedAir", "InfusedDull", "InfusedEarth", "InfusedEntropy", "InfusedFire", "InfusedOrder", "InfusedVis", "InfusedWater" -> "%material Infused Stone"; + case "Vermiculite", "Bentonite", "Kaolinite", "Talc", "BasalticMineralSand", "GraniticMineralSand", "GlauconiteSand", "CassiteriteSand", "GarnetSand", "QuartzSand", "Pitchblende", "FullersEarth" -> "%material"; + default -> "%material" + OrePrefixes.ore.mLocalizedMaterialPost; + }; + } + + public String getLocalizedName(Materials aMaterial) { + return aMaterial.getDefaultLocalizedNameForItem(getLocalizedNameFormat(aMaterial)); + } + + @Override + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, + float aOffsetX, float aOffsetY, float aOffsetZ) { + if (!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode) { + return false; + } + + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof TileEntityOres)) { + return false; + } + + boolean tNatural = (((TileEntityOres) tTileEntity).mNatural = !((TileEntityOres) tTileEntity).mNatural); + GTUtility.sendChatToPlayer(aPlayer, "Ore \"mNatural\" flag set to: " + tNatural); + return true; + } + + @Override + 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_); + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return (!(entity instanceof EntityDragon)) && (super.canEntityDestroy(world, x, y, z, entity)); + } + + @Override + public String getHarvestTool(int aMeta) { + return aMeta < 8 ? "pickaxe" : "shovel"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return aMeta == 5 || aMeta == 6 ? 2 : aMeta % 8; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return 1.0F + getHarvestLevel(aWorld.getBlockMetadata(aX, aY, aZ)) * 1.0F; + } + + @Override + public float getExplosionResistance(Entity entity, 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; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } + + @Override + public abstract String getUnlocalizedName(); + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(getUnlocalizedName() + DOT_NAME); + } + + @Override + public int getRenderType() { + if (GTRendererBlock.INSTANCE == null) { + return super.getRenderType(); + } + return GTRendererBlock.INSTANCE.mRenderID; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return true; + } + + @Override + public boolean hasTileEntity(int aMeta) { + return true; + } + + @Override + public TileEntity createNewTileEntity(World aWorld, int aMeta) { + return createTileEntity(aWorld, aMeta); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return Blocks.stone.getIcon(0, 0); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) {} + + @Override + @SideOnly(Side.CLIENT) + public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) { + GTRendererBlock + .addHitEffects(effectRenderer, this, worldObj, target.blockX, target.blockY, target.blockZ, target.sideHit); + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) { + GTRendererBlock.addDestroyEffects(effectRenderer, this, world, x, y, z); + return true; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (((tTileEntity instanceof TileEntityOres))) { + return ((TileEntityOres) tTileEntity).getMetaData(); + } + return 0; + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof TileEntityOres)) { + mTemporaryTileEntity.set((TileEntityOres) tTileEntity); + } + super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetadata); + aWorld.removeTileEntity(aX, aY, aZ); + } + + public abstract OrePrefixes[] getProcessingPrefix(); // Must have 8 entries; an entry can be null to disable + // automatic recipes. + + public abstract boolean[] getEnabledMetas(); // Must have 8 entries. + + public abstract Block getDroppedBlock(); + + public abstract Materials[] getDroppedDusts(); // Must have 8 entries; can be null. + + @Override + 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 TileEntityOres)) { + return ((TileEntityOres) tTileEntity).getDrops(getDroppedBlock(), aFortune); + } + return mTemporaryTileEntity.get() == null ? new ArrayList<>() + : mTemporaryTileEntity.get() + .getDrops(getDroppedBlock(), aFortune); + } + + @Override + public TileEntity createTileEntity(World aWorld, int aMeta) { + return new TileEntityOres(); + } + + public abstract ITexture[] getTextureSet(); // Must have 16 entries. + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aTab, List aList) { + for (int i = 0; i < GregTechAPI.sGeneratedMaterials.length; i++) { + Materials tMaterial = GregTechAPI.sGeneratedMaterials[i]; + if ((tMaterial != null) && ((tMaterial.mTypes & 0x8) != 0) && !aBlockedOres.contains(tMaterial)) { + for (int meta = i; meta < 23000 + i; meta += 1000) { + if (!(new ItemStack(aItem, 1, meta).getDisplayName() + .contains(DOT_NAME))) aList.add(new ItemStack(aItem, 1, meta)); + } + } + } + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockReinforced.java b/src/main/java/gregtech/common/blocks/BlockReinforced.java new file mode 100644 index 0000000000..034d18e62e --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockReinforced.java @@ -0,0 +1,409 @@ +package gregtech.common.blocks; + +import static gregtech.api.objects.XSTR.XSTR_INSTANCE; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.item.EntityTNTPrimed; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.Explosion; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SoundResource; +import gregtech.api.enums.Textures; +import gregtech.api.items.GTGenericBlock; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.WorldSpawnedEventBuilder; + +public class BlockReinforced extends GTGenericBlock { + + public BlockReinforced(String aName) { + super(ItemStorage.class, aName, new MaterialReinforced()); + for (int i = 0; i < 16; i++) { + Textures.BlockIcons.casingTexturePages[1][i + 80] = TextureFactory.of(this, i); + } + setStepSound(soundTypeStone); + setCreativeTab(GregTechAPI.TAB_GREGTECH); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Bronzeplate Reinforced Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Iridium Reinforced Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Plascrete Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Tungstensteel Reinforced Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Brittle Charcoal"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Powderbarrel"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Solid Super Fuel"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Magic Solid Super Fuel"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Steel Reinforced Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Titanium Reinforced Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Naquadah Reinforced Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Neutronium Reinforced Block"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Raw Deep Dark Portal Block"); + ItemList.Block_BronzePlate.set( + new ItemStack( + this.setHardness(60.0f) + .setResistance(150.0f), + 1, + 0)); + ItemList.Block_IridiumTungstensteel.set( + new ItemStack( + this.setHardness(400.0f) + .setResistance(600.0f), + 1, + 1)); + ItemList.Block_Plascrete.set( + new ItemStack( + this.setHardness(5.0f) + .setResistance(6.0f), + 1, + 2)); + ItemList.Block_TungstenSteelReinforced.set( + new ItemStack( + this.setHardness(250.0f) + .setResistance(400.0f), + 1, + 3)); + ItemList.Block_BrittleCharcoal.set( + new ItemStack( + this.setHardness(0.5f) + .setResistance(8.0f), + 1, + 4)); + ItemList.Block_Powderbarrel.set( + new ItemStack( + this.setHardness(2.5f) + .setResistance(2.0f), + 1, + 5)); + ItemList.Block_SSFUEL.set( + new ItemStack( + this.setHardness(2.5f) + .setResistance(2.0f), + 1, + 6)); + ItemList.Block_MSSFUEL.set( + new ItemStack( + this.setHardness(2.5f) + .setResistance(2.0f), + 1, + 7)); + ItemList.Block_SteelPlate.set( + new ItemStack( + this.setHardness(150.0f) + .setResistance(200.0f), + 1, + 8)); + ItemList.Block_TitaniumPlate.set( + new ItemStack( + this.setHardness(200.0f) + .setResistance(300.0f), + 1, + 9)); + ItemList.Block_NaquadahPlate.set( + new ItemStack( + this.setHardness(500.0f) + .setResistance(1000.0f), + 1, + 10)); + ItemList.Block_NeutroniumPlate.set( + new ItemStack( + this.setHardness(750.0f) + .setResistance(2500.0f), + 1, + 11)); + ItemList.Block_BedrockiumCompressed.set( + new ItemStack( + this.setHardness(1500.0f) + .setResistance(5000.0f), + 1, + 12)); + GTModHandler.addShapelessCraftingRecipe( + new ItemStack(Items.coal, 1, 1), + new Object[] { ItemList.Block_BrittleCharcoal.get(1) }); + GTModHandler.addCraftingRecipe( + ItemList.Block_Powderbarrel.get(1L), + GTModHandler.RecipeBits.REVERSIBLE, + new Object[] { "WSW", "GGG", "WGW", 'W', OrePrefixes.plate.get(Materials.Wood), 'G', + new ItemStack(Items.gunpowder, 1), 'S', new ItemStack(Items.string, 1) }); + } + + @Override + public String getHarvestTool(int aMeta) { + if (aMeta == 5 || aMeta == 4 || aMeta == 6 || aMeta == 7) return "axe"; + if (aMeta == 2) return "wrench"; + return "pickaxe"; + } + + @Override + public int getHarvestLevel(int aMeta) { + if (aMeta == 4 || aMeta == 5 || aMeta == 6 || aMeta == 7) return 1; + if (aMeta == 2) return 2; + if (aMeta == 9 || aMeta == 3 || aMeta == 1) return 5; + if (aMeta == 10 || aMeta == 11) return 7; + return 4; + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + if ((aMeta >= 0) && (aMeta < 16)) { + switch (aMeta) { + case 0 -> { + return Textures.BlockIcons.BLOCK_BRONZEPREIN.getIcon(); + } + case 1 -> { + return Textures.BlockIcons.BLOCK_IRREIN.getIcon(); + } + case 2 -> { + return Textures.BlockIcons.BLOCK_PLASCRETE.getIcon(); + } + case 3 -> { + return Textures.BlockIcons.BLOCK_TSREIN.getIcon(); + } + case 4, 6, 7 -> { + return Blocks.coal_block.getIcon(0, 0); + } + case 5 -> { + return Textures.BlockIcons.COVER_WOOD_PLATE.getIcon(); + } + case 8 -> { + return Textures.BlockIcons.BLOCK_STEELPREIN.getIcon(); + } + case 9 -> { + return Textures.BlockIcons.BLOCK_TITANIUMPREIN.getIcon(); + } + case 10 -> { + return Textures.BlockIcons.BLOCK_NAQUADAHPREIN.getIcon(); + } + case 11 -> { + return Textures.BlockIcons.BLOCK_NEUTRONIUMPREIN.getIcon(); + } + case 12 -> { + return Textures.BlockIcons.BLOCK_DEEP_DARK_RAW.getIcon(); + } + } + } + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + if (aWorld == null) { + return 0.0F; + } + if (aWorld.isAirBlock(aX, aY, aZ)) { + return 0.0F; + } + int tMeta = aWorld.getBlockMetadata(aX, aY, aZ); + if (tMeta == 0) { + return 60.0F; + } + if (tMeta == 1) { + return 400.0F; + } + if (tMeta == 2) { + return 5.0F; + } + if (tMeta == 3) { + return 250.0F; + } + if (tMeta == 4 || tMeta == 5 || tMeta == 6 || tMeta == 7) { + return 0.5F; + } + if (tMeta == 8) { + return 150.0F; + } + if (tMeta == 9) { + return 200.0F; + } + if (tMeta == 10) { + return 500.0F; + } + if (tMeta == 11) { + return 750.0F; + } + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX, + double explosionY, double explosionZ) { + if (world == null) { + return 0.0F; + } + int tMeta = world.getBlockMetadata(x, y, z); + if (tMeta == 0) { + return 150.0F; + } + if (tMeta == 1) { + return 600.0F; + } + if (tMeta == 2) { + return 6.0F; + } + if (tMeta == 3) { + return 400.0F; + } + if (tMeta == 4 || tMeta == 6 || tMeta == 7) { + return 8.0F; + } + if (tMeta == 5) { + return 1.0F; + } + if (tMeta == 8) { + return 200.0F; + } + if (tMeta == 9) { + return 300.0F; + } + if (tMeta == 10) { + return 1000.0F; + } + if (tMeta == 11) { + return 2500.0F; + } + return super.getExplosionResistance(entity, world, x, y, z, explosionX, explosionY, explosionZ); + } + + @Override + public String getUnlocalizedName() { + return this.mUnlocalizedName; + } + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return true; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlockMetadata(aX, aY, aZ); + } + + @Override + public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int aMetadata, float chance, + int aFortune) { + if (aMetadata == 4) { + this.dropBlockAsItem(aWorld, aX, aY, aZ, new ItemStack(Items.coal, XSTR_INSTANCE.nextInt(2) + 1, 1)); + } else { + super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, aMetadata, chance, aFortune); + } + } + + @SuppressWarnings("deprecation") + @Override + public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { + if (!world.isRemote && world.getBlockMetadata(x, y, z) == 5) { + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, x + 0.5F, y + 0.5F, z + 0.5F, player); + world.spawnEntityInWorld(entitytntprimed); + new WorldSpawnedEventBuilder.SoundAtEntityEventBuilder().setPitch(1f) + .setVolume(1f) + .setIdentifier(SoundResource.GAME_TNT_PRIMED) + .setEntity(entitytntprimed) + .setWorld(world) + .run(); + world.setBlockToAir(x, y, z); + return false; + } + return super.removedByPlayer(world, player, x, y, z); + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); + if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 5) { + removedByPlayer(world, null, x, y, z); + } + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) { + if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 5) { + removedByPlayer(world, null, x, y, z); + } + } + + @Override + public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { + if (!world.isRemote && world.getBlockMetadata(x, y, z) == 5) { + EntityTNTPrimed entitytntprimed = new EntityTNTPrimed( + world, + x + 0.5F, + y + 0.5F, + z + 0.5F, + explosion.getExplosivePlacedBy()); + entitytntprimed.fuse = (world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8); + world.spawnEntityInWorld(entitytntprimed); + } + super.onBlockExploded(world, x, y, z, explosion); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int ordinalSide, + float xOffset, float yOffset, float zOffset) { + if ((player.getCurrentEquippedItem() != null) && (player.getCurrentEquippedItem() + .getItem() == Items.flint_and_steel) && world.getBlockMetadata(x, y, z) == 5) { + removedByPlayer(world, player, x, y, z); + + return true; + } + return super.onBlockActivated(world, x, y, z, player, ordinalSide, xOffset, yOffset, zOffset); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) {} + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { + for (int i = 0; i < 16; i++) { + ItemStack aStack = new ItemStack(aItem, 1, i); + if (!aStack.getDisplayName() + .contains(".name")) aList.add(aStack); + } + } + + @Override + 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/BlockStones.java b/src/main/java/gregtech/common/blocks/BlockStones.java new file mode 100644 index 0000000000..895a103016 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockStones.java @@ -0,0 +1,62 @@ +package gregtech.common.blocks; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.World; + +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTOreDictUnificator; + +public class BlockStones extends BlockStonesAbstract { + + public BlockStones() { + super(ItemGranites.class, "gt.blockstones"); + setResistance(60.0F); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Marble"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Marble Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Marble Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Marble Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Cracked Marble Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Mossy Marble Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Chiseled Marble"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Smooth Marble"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Basalt"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Basalt Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Mossy Basalt Cobblestone"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Basalt Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Cracked Basalt Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Mossy Basalt Bricks"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Chiseled Basalt"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Smooth Basalt"); + for (int i = 0; i < 16; i++) { + GTOreDictUnificator + .registerOre(OrePrefixes.stone, i < 8 ? Materials.Marble : Materials.Basalt, new ItemStack(this, 1, i)); + GTOreDictUnificator + .registerOre(OrePrefixes.block, i < 8 ? Materials.Marble : Materials.Basalt, new ItemStack(this, 1, i)); + GTOreDictUnificator.registerOre( + (i < 8 ? Materials.Marble.mName.toLowerCase() : Materials.Basalt.mName.toLowerCase()), + new ItemStack(this, 1, i)); + } + } + + @Override + public int getHarvestLevel(int aMeta) { + return 2; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + if ((aMeta >= 0) && (aMeta < 16)) { + return gregtech.api.enums.Textures.BlockIcons.STONES[aMeta].getIcon(); + } + return gregtech.api.enums.Textures.BlockIcons.STONES[0].getIcon(); + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockStonesAbstract.java b/src/main/java/gregtech/common/blocks/BlockStonesAbstract.java new file mode 100644 index 0000000000..3d8c4e9feb --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockStonesAbstract.java @@ -0,0 +1,250 @@ +package gregtech.common.blocks; + +import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; +import static gregtech.api.recipe.RecipeMaps.hammerRecipes; +import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTRecipeBuilder.TICKS; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OreDictNames; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.IOreRecipeRegistrator; +import gregtech.api.items.GTGenericBlock; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTUtility; + +public class BlockStonesAbstract extends GTGenericBlock implements IOreRecipeRegistrator { + + public BlockStonesAbstract(Class aItemClass, String aName) { + super(aItemClass, aName, Material.rock); + OrePrefixes.crafting.add(this); + setStepSound(soundTypeStone); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + + this.registerSmeltingRecipes(); + this.registerAssemblerRecipes(); + this.registerCraftingRecipes(); + this.registerForgeHammerRecipes(); + + } + + private void registerSmeltingRecipes() { + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 0), new ItemStack(this, 1, 7)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 1), new ItemStack(this, 1, 0)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 2), new ItemStack(this, 1, 0)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 3), new ItemStack(this, 1, 0)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 4), new ItemStack(this, 1, 0)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 5), new ItemStack(this, 1, 0)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 6), new ItemStack(this, 1, 0)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 7), new ItemStack(this, 1, 0)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 8), new ItemStack(this, 1, 15)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 9), new ItemStack(this, 1, 8)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 10), new ItemStack(this, 1, 8)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 11), new ItemStack(this, 1, 8)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 12), new ItemStack(this, 1, 8)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 13), new ItemStack(this, 1, 8)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 14), new ItemStack(this, 1, 8)); + GTModHandler.addSmeltingRecipe(new ItemStack(this, 1, 15), new ItemStack(this, 1, 8)); + + } + + private void registerAssemblerRecipes() { + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 0), GTUtility.getIntegratedCircuit(4)) + .itemOutputs(new ItemStack(this, 1, 3)) + .duration(2 * SECONDS + 10 * TICKS) + .eut(4) + .addTo(assemblerRecipes); + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 8), GTUtility.getIntegratedCircuit(4)) + .itemOutputs(new ItemStack(this, 1, 11)) + .duration(2 * SECONDS + 10 * TICKS) + .eut(4) + .addTo(assemblerRecipes); + } + + private void registerCraftingRecipes() { + GTModHandler.addCraftingRecipe( + new ItemStack(this, 1, 6), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "f", "X", 'X', new ItemStack(this, 1, 7) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 1, 14), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "f", "X", 'X', new ItemStack(this, 1, 15) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 1, 4), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "h", "X", 'X', new ItemStack(this, 1, 3) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 1, 12), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "h", "X", 'X', new ItemStack(this, 1, 11) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 1, 1), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "h", "X", 'X', new ItemStack(this, 1, 0) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 1, 9), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "h", "X", 'X', new ItemStack(this, 1, 8) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 4, 3), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 0) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 4, 11), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 8) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 4, 3), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 7) }); + GTModHandler.addCraftingRecipe( + new ItemStack(this, 4, 11), + GTModHandler.RecipeBits.NOT_REMOVABLE, + new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 15) }); + } + + private void registerForgeHammerRecipes() { + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 3)) + .itemOutputs(new ItemStack(this, 1, 4)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 11)) + .itemOutputs(new ItemStack(this, 1, 12)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 0)) + .itemOutputs(new ItemStack(this, 1, 1)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 8)) + .itemOutputs(new ItemStack(this, 1, 9)) + .duration(16 * TICKS) + .eut(10) + .addTo(hammerRecipes); + } + + @Override + public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, + ItemStack aStack) { + if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 7), GTUtility.copyAmount(0, aStack)) + .itemOutputs(new ItemStack(this, 1, 6)) + .duration(2 * SECONDS + 10 * TICKS) + .eut(16) + .addTo(laserEngraverRecipes); + + GTValues.RA.stdBuilder() + .itemInputs(new ItemStack(this, 1, 15), GTUtility.copyAmount(0, aStack)) + .itemOutputs(new ItemStack(this, 1, 14)) + .duration(2 * SECONDS + 10 * TICKS) + .eut(16) + .addTo(laserEngraverRecipes); + + } + } + + @Override + public String getHarvestTool(int aMeta) { + return "pickaxe"; + } + + @Override + public int getHarvestLevel(int aMeta) { + return 1; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; + } + + @Override + public String getUnlocalizedName() { + return this.mUnlocalizedName; + } + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return true; + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + if ((aMeta >= 0) && (aMeta < 16)) { + return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); + } + return null; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return world.getBlockMetadata(x, y, z) % 8 < 3; + } + + @Override + public int damageDropped(int metadata) { + return metadata % 8 == 0 ? metadata + 1 : metadata; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlockMetadata(aX, aY, aZ); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) {} + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, 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/BlockStorage.java b/src/main/java/gregtech/common/blocks/BlockStorage.java new file mode 100644 index 0000000000..1886d25d9b --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockStorage.java @@ -0,0 +1,103 @@ +package gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; +import net.minecraft.init.Blocks; +import net.minecraft.item.Item; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.items.GTGenericBlock; + +public class BlockStorage extends GTGenericBlock { + + protected BlockStorage(Class aItemClass, String aName, Material aMaterial) { + super(aItemClass, aName, aMaterial); + setStepSound(soundTypeMetal); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + } + + @Override + public String getHarvestTool(int aMeta) { + return "pickaxe"; + } + + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } + + @Override + public int getHarvestLevel(int aMeta) { + return 1; + } + + @Override + public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { + return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); + } + + @Override + public float getExplosionResistance(Entity aTNT) { + return Blocks.iron_block.getExplosionResistance(aTNT); + } + + @Override + public String getUnlocalizedName() { + return this.mUnlocalizedName; + } + + @Override + public String getLocalizedName() { + return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return true; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return true; + } + + @Override + public int damageDropped(int metadata) { + return metadata; + } + + @Override + public int getDamageValue(World aWorld, int aX, int aY, int aZ) { + return aWorld.getBlockMetadata(aX, aY, aZ); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister aIconRegister) {} + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { + for (int i = 0; i < 16; i++) { + if (!(new ItemStack(aItem, 1, i).getDisplayName() + .contains(".name"))) aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockTintedIndustrialGlass.java b/src/main/java/gregtech/common/blocks/BlockTintedIndustrialGlass.java new file mode 100644 index 0000000000..16a22e7c35 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockTintedIndustrialGlass.java @@ -0,0 +1,98 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Facing; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.oredict.OreDictionary; + +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.util.GTLanguageManager; + +public class BlockTintedIndustrialGlass extends BlockCasingsAbstract { + + public BlockTintedIndustrialGlass() { + super(ItemGlass1.class, "gt.blocktintedglass", Material.glass, 4); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Tinted Industrial Glass (White)"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".1.name", "Tinted Industrial Glass (Light Gray)"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Tinted Industrial Glass (Gray)"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Tinted Industrial Glass (Black)"); + ItemList.GlassTintedIndustrialWhite.set(new ItemStack(this, 1, 0)); + ItemList.GlassTintedIndustrialLightGray.set(new ItemStack(this, 1, 1)); + ItemList.GlassTintedIndustrialGray.set(new ItemStack(this, 1, 2)); + ItemList.GlassTintedIndustrialBlack.set(new ItemStack(this, 1, 3)); + + // Register tinted industrial glass as EV-Tier glass + OreDictionary.registerOre("blockGlassEV", this); + + this.opaque = false; + } + + @Override + public int getTextureIndex(int aMeta) { + // Page 16, 32-47 + return (16 << 7) | (aMeta + 32); + } + + @Override + public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int ordinalSide, int aMeta) { + return switch (aMeta) { + case 0 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_WHITE.getIcon(); + case 1 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_LIGHT_GRAY.getIcon(); + case 2 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_GRAY.getIcon(); + case 3 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_BLACK.getIcon(); + default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + }; + } + + /** + * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given + * coordinates. Args: blockAccess, x, y, z, side + */ + @SideOnly(Side.CLIENT) + @Override + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + Block block = worldIn.getBlock(x, y, z); + + if (worldIn.getBlockMetadata(x, y, z) != worldIn.getBlockMetadata( + x - Facing.offsetsXForSide[side], + y - Facing.offsetsYForSide[side], + z - Facing.offsetsZForSide[side])) { + return true; + } + + if (block == this) { + return false; + } + + return super.shouldSideBeRendered(worldIn, x, y, z, side); + } +} diff --git a/src/main/java/gregtech/common/blocks/BlockWormholeRender.java b/src/main/java/gregtech/common/blocks/BlockWormholeRender.java new file mode 100644 index 0000000000..7ae7615639 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockWormholeRender.java @@ -0,0 +1,75 @@ +package gregtech.common.blocks; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.common.tileentities.render.TileEntityWormhole; + +public class BlockWormholeRender extends Block { + + public BlockWormholeRender() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + // this.setCreativeTab(TecTech.creativeTabTecTech); + this.setBlockName("WormholeRenderer"); + this.setLightLevel(100.0f); + GameRegistry.registerBlock(this, getUnlocalizedName()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @Override + public String getUnlocalizedName() { + return "gt.wormholerenderer"; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canRenderInPass(int a) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEntityWormhole(); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(); + } + + @Override + public boolean isCollidable() { + return true; + } + +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java deleted file mode 100644 index 897011eba9..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java +++ /dev/null @@ -1,108 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings1 extends GT_Block_Casings_Abstract { - - /** - * Texture Index Information Textures.BlockIcons.casingTexturePages[0][0-63] - Gregtech - * Textures.BlockIcons.casingTexturePages[0][64-127] - GT++ Textures.BlockIcons.casingTexturePages[1][0-127] - - * Gregtech Textures.BlockIcons.casingTexturePages[2][0-127] - Free Textures.BlockIcons.casingTexturePages[3][0-127] - * - Free Textures.BlockIcons.casingTexturePages[4][0-127] - Free Textures.BlockIcons.casingTexturePages[5][0-127] - - * Free Textures.BlockIcons.casingTexturePages[6][0-127] - Free Textures.BlockIcons.casingTexturePages[7][0-127] - - * TecTech Textures.BlockIcons.casingTexturePages[8][0-127] - TecTech - */ - public GT_Block_Casings1() { - super(GT_Item_Casings1.class, "gt.blockcasings", GT_Material_Casings.INSTANCE, 16); - - 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", "UHV 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", "Dimensionally Transcendent Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Dimensional Injection Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Dimensional Bridge"); - 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_Dim_Trans.set(new ItemStack(this, 1, 12)); - ItemList.Casing_Dim_Injector.set(new ItemStack(this, 1, 13)); - ItemList.Casing_Dim_Bridge.set(new ItemStack(this, 1, 14)); - ItemList.Casing_Coil_Superconductor.set(new ItemStack(this, 1, 15)); - } - - @Override - public int getTextureIndex(int aMeta) { - return aMeta; - } - - @Override - public IIcon getIcon(int ordinalSide, 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_DIM_TRANS_CASING.getIcon(); - } - case 13 -> { - return Textures.BlockIcons.MACHINE_DIM_INJECTOR.getIcon(); - } - case 14 -> { - return Textures.BlockIcons.MACHINE_DIM_BRIDGE.getIcon(); - } - case 15 -> { - return Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR.getIcon(); - } - } - if (ordinalSide == 0) { - return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); - } - if (ordinalSide == 1) { - return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); - } - return Textures.BlockIcons.MACHINECASINGS_SIDE[aMeta].getIcon(); - } - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - } - - @Override - 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_Casings10.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings10.java deleted file mode 100644 index 1a0902da97..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings10.java +++ /dev/null @@ -1,76 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -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.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings10 extends GT_Block_Casings_Abstract { - - public GT_Block_Casings10() { - super(GT_Item_Casings10.class, "gt.blockcasings10", GT_Material_Casings.INSTANCE, 16); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "MagTech Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Laser Containment Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Quark Exclusion Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Pressure Containment Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Electric Compressor Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Compression Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Neutronium Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Active Neutronium Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Neutronium Stabilization Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Coolant Duct"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Heating Duct"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".11.name", "Extreme Density Space-Bending Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".12.name", "Background Radiation Absorbent Casing"); - - ItemList.Casing_Electromagnetic_Separator.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Laser.set(new ItemStack(this, 1, 1)); - ItemList.BlockQuarkContainmentCasing.set(new ItemStack(this, 1, 2)); - ItemList.Casing_Autoclave.set(new ItemStack(this, 1, 3)); - ItemList.Compressor_Casing.set(new ItemStack(this, 1, 4)); - ItemList.Compressor_Pipe_Casing.set(new ItemStack(this, 1, 5)); - ItemList.Neutronium_Casing.set(new ItemStack(this, 1, 6)); - ItemList.Neutronium_Active_Casing.set(new ItemStack(this, 1, 7)); - ItemList.Neutronium_Stable_Casing.set(new ItemStack(this, 1, 8)); - ItemList.Coolant_Duct_Casing.set(new ItemStack(this, 1, 9)); - ItemList.Heating_Duct_Casing.set(new ItemStack(this, 1, 10)); - ItemList.Extreme_Density_Casing.set(new ItemStack(this, 1, 11)); - ItemList.Background_Radiation_Casing.set(new ItemStack(this, 1, 12)); - } - - @Override - public int getTextureIndex(int aMeta) { - return (16 << 7) | (aMeta + 48); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.MACHINE_CASING_EMS.getIcon(); - case 1 -> Textures.BlockIcons.MACHINE_CASING_LASER.getIcon(); - case 2 -> Textures.BlockIcons.BLOCK_QUARK_CONTAINMENT_CASING.getIcon(); - case 3 -> Textures.BlockIcons.MACHINE_CASING_AUTOCLAVE.getIcon(); - case 4 -> Textures.BlockIcons.COMPRESSOR_CASING.getIcon(); - case 5 -> Textures.BlockIcons.COMPRESSOR_PIPE_CASING.getIcon(); - case 6 -> Textures.BlockIcons.NEUTRONIUM_CASING.getIcon(); - case 7 -> Textures.BlockIcons.NEUTRONIUM_ACTIVE_CASING.getIcon(); - case 8 -> Textures.BlockIcons.NEUTRONIUM_STABLE_CASING.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TUNGSTENSTEEL.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_CASING_PIPE_BRONZE.getIcon(); - case 11 -> Textures.BlockIcons.EXTREME_DENSITY_CASING.getIcon(); - case 12 -> Textures.BlockIcons.RADIATION_ABSORBENT_CASING.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - }; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings11.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings11.java deleted file mode 100644 index b4ec07ab70..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings11.java +++ /dev/null @@ -1,58 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -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.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings11 extends GT_Block_Casings_Abstract { - - public GT_Block_Casings11() { - super(GT_Item_Casings11.class, "gt.blockcasings11", GT_Material_Casings.INSTANCE, 16); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Tin Item Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Brass Item Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Electrum Item Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Platinum Item Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Osmium Item Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Quantium Item Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Fluxed Electrum Item Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Black Plutonium Item Pipe Casing"); - - ItemList.Casing_Item_Pipe_Tin.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Item_Pipe_Brass.set(new ItemStack(this, 1, 1)); - ItemList.Casing_Item_Pipe_Electrum.set(new ItemStack(this, 1, 2)); - ItemList.Casing_Item_Pipe_Platinum.set(new ItemStack(this, 1, 3)); - ItemList.Casing_Item_Pipe_Osmium.set(new ItemStack(this, 1, 4)); - ItemList.Casing_Item_Pipe_Quantium.set(new ItemStack(this, 1, 5)); - ItemList.Casing_Item_Pipe_Fluxed_Electrum.set(new ItemStack(this, 1, 6)); - ItemList.Casing_Item_Pipe_Black_Plutonium.set(new ItemStack(this, 1, 7)); - } - - @Override - public int getTextureIndex(int aMeta) { - return (16 << 7) | (aMeta + 64); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 1 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_BRASS.getIcon(); - case 2 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_ELECTRUM.getIcon(); - case 3 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_PLATINUM.getIcon(); - case 4 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_OSMIUM.getIcon(); - case 5 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_QUANTIUM.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_FLUXED_ELECTRUM.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_BLACK_PLUTONIUM.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_ITEM_PIPE_TIN.getIcon(); - }; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java deleted file mode 100644 index f1fbc30236..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java +++ /dev/null @@ -1,102 +0,0 @@ -package gregtech.common.blocks; - -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; -import net.minecraftforge.common.util.ForgeDirection; - -import gregtech.api.enums.Dyes; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -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, 96); - // Special handler for Pyrolyse Oven Casing on hatches... - Textures.BlockIcons.casingTexturePages[0][22] = TextureFactory.of( - Block.getBlockFromItem( - ItemList.Casing_ULV.get(1) - .getItem()), - 0, - ForgeDirection.UNKNOWN, - Dyes.MACHINE_METAL.mRGBa); - - 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", "Assembling Line 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 Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Steel Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Titanium Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Tungstensteel Pipe Casing"); - ItemList.Casing_SolidSteel.set(new ItemStack(this, 1, 0)); - ItemList.Casing_FrostProof.set(new ItemStack(this, 1, 1)); - ItemList.Casing_Gearbox_Bronze.set(new ItemStack(this, 1, 2)); - 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)); - } - - @Override - public int getTextureIndex(int aMeta) { - return aMeta == 6 ? ((1 << 7) + 96) : aMeta + 16; - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - case 1 -> Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); - case 2 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_BRONZE.getIcon(); - case 3 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_STEEL.getIcon(); - case 4 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_TITANIUM.getIcon(); - case 5 -> Textures.BlockIcons.MACHINE_CASING_GEARBOX_TUNGSTENSTEEL.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_CASING_PROCESSOR.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_CASING_DATA_DRIVE.getIcon(); - case 8 -> Textures.BlockIcons.MACHINE_CASING_CONTAINMENT_FIELD.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_CASING_ASSEMBLER.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_CASING_PUMP.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_CASING_MOTOR.getIcon(); - case 12 -> Textures.BlockIcons.MACHINE_CASING_PIPE_BRONZE.getIcon(); - case 13 -> Textures.BlockIcons.MACHINE_CASING_PIPE_STEEL.getIcon(); - case 14 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TITANIUM.getIcon(); - case 15 -> Textures.BlockIcons.MACHINE_CASING_PIPE_TUNGSTENSTEEL.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - }; - } - - @Override - 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 deleted file mode 100644 index ada77814c8..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java +++ /dev/null @@ -1,82 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -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, 16); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Yellow Stripes Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Yellow Stripes Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Radioactive Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Bio Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Explosion Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Fire Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Acid Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Magic Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Frost Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Noise Hazard Sign Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Grate Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Filter Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Radiation Proof Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Bronze Firebox Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Steel Firebox Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Tungstensteel Firebox Casing"); - ItemList.Casing_Stripes_A.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Stripes_B.set(new ItemStack(this, 1, 1)); - ItemList.Casing_RadioactiveHazard.set(new ItemStack(this, 1, 2)); - ItemList.Casing_BioHazard.set(new ItemStack(this, 1, 3)); - ItemList.Casing_ExplosionHazard.set(new ItemStack(this, 1, 4)); - ItemList.Casing_FireHazard.set(new ItemStack(this, 1, 5)); - ItemList.Casing_AcidHazard.set(new ItemStack(this, 1, 6)); - ItemList.Casing_MagicHazard.set(new ItemStack(this, 1, 7)); - ItemList.Casing_FrostHazard.set(new ItemStack(this, 1, 8)); - ItemList.Casing_NoiseHazard.set(new ItemStack(this, 1, 9)); - ItemList.Casing_Grate.set(new ItemStack(this, 1, 10)); - ItemList.Casing_Vent.set(new ItemStack(this, 1, 11)); - ItemList.Casing_RadiationProof.set(new ItemStack(this, 1, 12)); - ItemList.Casing_Firebox_Bronze.set(new ItemStack(this, 1, 13)); - ItemList.Casing_Firebox_Steel.set(new ItemStack(this, 1, 14)); - ItemList.Casing_Firebox_TungstenSteel.set(new ItemStack(this, 1, 15)); - } - - @Override - public int getTextureIndex(int aMeta) { - return aMeta + 32; - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_A.getIcon(); - case 1 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_B.getIcon(); - case 2 -> Textures.BlockIcons.MACHINE_CASING_RADIOACTIVEHAZARD.getIcon(); - case 3 -> Textures.BlockIcons.MACHINE_CASING_BIOHAZARD.getIcon(); - case 4 -> Textures.BlockIcons.MACHINE_CASING_EXPLOSIONHAZARD.getIcon(); - case 5 -> Textures.BlockIcons.MACHINE_CASING_FIREHAZARD.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_CASING_ACIDHAZARD.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_CASING_MAGICHAZARD.getIcon(); - case 8 -> Textures.BlockIcons.MACHINE_CASING_FROSTHAZARD.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_CASING_NOISEHAZARD.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_CASING_VENT.getIcon(); - case 12 -> Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); - case 13 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() - : Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); - case 14 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() - : Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - case 15 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() - : Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - default -> 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 deleted file mode 100644 index 77f36a4523..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ /dev/null @@ -1,239 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.GT_Mod; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_RenderingWorld; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { - - /** - * This mapping is used to look up which texture should be used to render the connected texture for fusion casings. - *

- * This mapping is computed from that giant if ladder from #getIcon in commit - * da3421547afadc49938b5b6a7f9a9679afa1d570 The exact meaning of these numbers are like black magic. Read the - * original getIcon implementation to understand why it is 0, 1, etc, if that if ladder is even intelligible. - */ - private static final int[][] mapping = new int[][] { - { 7, 7, 7, 7, 0, 7, 0, 7, 1, 7, 1, 7, 8, 7, 8, 7, 0, 7, 0, 7, 0, 7, 0, 7, 9, 7, 9, 7, 3, 7, 3, 7, 1, 7, 1, 7, - 11, 7, 11, 7, 1, 7, 1, 7, 2, 7, 2, 7, 10, 7, 10, 7, 5, 7, 5, 7, 4, 7, 4, 7, 6, 7, 6, 7 }, - { 7, 7, 7, 7, 0, 0, 7, 7, 1, 1, 7, 7, 8, 8, 7, 7, 0, 0, 7, 7, 0, 0, 7, 7, 9, 9, 7, 7, 3, 3, 7, 7, 1, 1, 7, 7, - 11, 11, 7, 7, 1, 1, 7, 7, 2, 2, 7, 7, 10, 10, 7, 7, 5, 5, 7, 7, 4, 4, 7, 7, 6, 6, 7, 7 }, - { 7, 1, 1, 1, 0, 9, 10, 4, 7, 1, 1, 1, 0, 9, 10, 4, 0, 8, 11, 2, 0, 3, 5, 6, 0, 8, 11, 2, 0, 3, 5, 6, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, - { 7, 1, 1, 1, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, - 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7 }, - { 7, 1, 1, 1, 7, 1, 1, 1, 0, 8, 11, 2, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, - 0, 9, 10, 4, 0, 3, 5, 6, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 }, - { 7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 0, 8, 11, 2, - 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7, 0, 8, 11, 2, 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7 }, }; - - public static boolean mConnectedMachineTextures = true; - - public GT_Block_Casings4() { - super(GT_Item_Casings4.class, "gt.blockcasings4", GT_Material_Casings.INSTANCE, 16); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".0.name", "Robust Tungstensteel Machine Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Stable Titanium Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Titanium Firebox Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Fusion Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Fusion Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Fusion Machine Casing MK II"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Turbine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Stainless Steel Turbine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Titanium Turbine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Tungstensteel Turbine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Engine Intake Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Mining Osmiridium Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Firebricks"); - - 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)); - ItemList.Casing_Turbine1.set(new ItemStack(this, 1, 10)); - ItemList.Casing_Turbine2.set(new ItemStack(this, 1, 11)); - ItemList.Casing_Turbine3.set(new ItemStack(this, 1, 12)); - ItemList.Casing_EngineIntake.set(new ItemStack(this, 1, 13)); - ItemList.Casing_MiningOsmiridium.set(new ItemStack(this, 1, 14)); - ItemList.Casing_Firebricks.set(new ItemStack(this, 1, 15)); - - GT_Mod.gregtechproxy.mCTMBlockCache.put(this, (byte) 6, true); - GT_Mod.gregtechproxy.mCTMBlockCache.put(this, (byte) 8, true); - } - - @Override - public int getTextureIndex(int aMeta) { - return aMeta + 48; - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - case 1 -> Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); - case 2 -> Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - case 3 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() - : Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - case 4 -> - // Do not overwrite! - Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW.getIcon(); - case 5 -> - // Do not overwrite! - Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_CASING_FUSION.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_CASING_FUSION_COIL.getIcon(); - case 8 -> Textures.BlockIcons.MACHINE_CASING_FUSION_2.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_STAINLESSSTEEL.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TITANIUM.getIcon(); - case 12 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TUNGSTENSTEEL.getIcon(); - case 13 -> Textures.BlockIcons.MACHINE_CASING_ENGINE_INTAKE.getIcon(); - case 14 -> Textures.BlockIcons.MACHINE_CASING_MINING_OSMIRIDIUM.getIcon(); - case 15 -> Textures.BlockIcons.MACHINE_CASING_DENSEBRICKS.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - }; - } - - @Deprecated - public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean hasTurbine) { - return switch (meta) { - case 10 -> active ? Textures.BlockIcons.TURBINE_ACTIVE1[iconIndex].getIcon() - : hasTurbine ? Textures.BlockIcons.TURBINE1[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE_EMPTY1[iconIndex].getIcon(); - case 11 -> active ? Textures.BlockIcons.TURBINE_ACTIVE2[iconIndex].getIcon() - : hasTurbine ? Textures.BlockIcons.TURBINE2[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE_EMPTY2[iconIndex].getIcon(); - case 12 -> active ? Textures.BlockIcons.TURBINE_ACTIVE3[iconIndex].getIcon() - : hasTurbine ? Textures.BlockIcons.TURBINE3[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE_EMPTY3[iconIndex].getIcon(); - default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() - : hasTurbine ? Textures.BlockIcons.TURBINE[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE_EMPTY[iconIndex].getIcon(); - }; - } - - private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine && tTile.getFrontFacing() - .ordinal() == ordinalSide) { - if (turbine.isNewStyleRendering()) return 0; - if (tTile.isActive()) return 1; - return turbine.hasTurbine() ? 2 : 3; - } - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { - aWorld = GT_RenderingWorld.getInstance(aWorld); - int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if (tMeta != 6 && tMeta != 8 && tMeta != 9 && tMeta != 10 && tMeta != 11 && tMeta != 12 - || !mConnectedMachineTextures) { - return getIcon(ordinalSide, tMeta); - } - // noinspection ConstantValue // tMeta < 13 should stay because mConnectedMachineTextures can be changed - if (tMeta > 8 && tMeta < 13) { - int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; - switch (ordinalSide / 2) { - case 0 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide( - aWorld, - xCoord + j, - yCoord, - zCoord + i, - ordinalSide)) != 0) { - return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); - } - } - } - } - case 1 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide( - aWorld, - xCoord + j, - yCoord + i, - zCoord, - ordinalSide)) != 0) { - return getTurbineCasing( - tMeta, - 4 + i * 3 - j * tInvertLeftRightMod, - tState == 1, - tState == 2); - } - } - } - } - case 2 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide( - aWorld, - xCoord, - yCoord + i, - zCoord + j, - ordinalSide)) != 0) { - return getTurbineCasing( - tMeta, - 4 + i * 3 + j * tInvertLeftRightMod, - tState == 1, - tState == 2); - } - } - } - } - } - return switch (tMeta) { - case 10 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_STAINLESSSTEEL.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TITANIUM.getIcon(); - case 12 -> Textures.BlockIcons.MACHINE_CASING_TURBINE_TUNGSTENSTEEL.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - }; - } - int tStartIndex = tMeta == 6 ? 1 : 13; - int tIndexIntoMapping = 0; - if (isSameBlock(aWorld, xCoord, yCoord - 1, zCoord, tMeta)) tIndexIntoMapping |= 1; - if (isSameBlock(aWorld, xCoord, yCoord + 1, zCoord, tMeta)) tIndexIntoMapping |= 1 << 1; - if (isSameBlock(aWorld, xCoord + 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 2; - if (isSameBlock(aWorld, xCoord, yCoord, zCoord + 1, tMeta)) tIndexIntoMapping |= 1 << 3; - if (isSameBlock(aWorld, xCoord - 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 4; - if (isSameBlock(aWorld, xCoord, yCoord, zCoord - 1, tMeta)) tIndexIntoMapping |= 1 << 5; - return Textures.BlockIcons.CONNECTED_HULLS[tStartIndex + mapping[ordinalSide][tIndexIntoMapping]].getIcon(); - } - - private boolean isSameBlock(IBlockAccess aWorld, int aX, int aY, int aZ, int aMeta) { - return aWorld.getBlock(aX, aY, aZ) == this && aWorld.getBlockMetadata(aX, aY, aZ) == aMeta; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java deleted file mode 100644 index 0cb1934dec..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ /dev/null @@ -1,161 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.enums.HeatingCoilLevel.EV; -import static gregtech.api.enums.HeatingCoilLevel.HV; -import static gregtech.api.enums.HeatingCoilLevel.IV; -import static gregtech.api.enums.HeatingCoilLevel.LV; -import static gregtech.api.enums.HeatingCoilLevel.LuV; -import static gregtech.api.enums.HeatingCoilLevel.MAX; -import static gregtech.api.enums.HeatingCoilLevel.MV; -import static gregtech.api.enums.HeatingCoilLevel.None; -import static gregtech.api.enums.HeatingCoilLevel.UEV; -import static gregtech.api.enums.HeatingCoilLevel.UHV; -import static gregtech.api.enums.HeatingCoilLevel.UIV; -import static gregtech.api.enums.HeatingCoilLevel.UMV; -import static gregtech.api.enums.HeatingCoilLevel.UV; -import static gregtech.api.enums.HeatingCoilLevel.UXV; -import static gregtech.api.enums.HeatingCoilLevel.ZPM; - -import java.util.function.Consumer; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IHeatingCoil; -import gregtech.api.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings5 extends GT_Block_Casings_Abstract implements IHeatingCoil { - - public GT_Block_Casings5() { - super(GT_Item_Casings5.class, "gt.blockcasings5", GT_Material_Casings.INSTANCE, 16); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Cupronickel Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Kanthal Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Nichrome Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "TPV-Alloy Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "HSS-G Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Naquadah Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Naquadah Alloy Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Electrum Flux Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Awakened Draconium Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "HSS-S Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Trinium Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Infinity Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Hypogen Coil Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Eternal Coil Block"); - - ItemList.Casing_Coil_Cupronickel.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Coil_Kanthal.set(new ItemStack(this, 1, 1)); - ItemList.Casing_Coil_Nichrome.set(new ItemStack(this, 1, 2)); - ItemList.Casing_Coil_TungstenSteel.set(new ItemStack(this, 1, 3)); - ItemList.Casing_Coil_HSSG.set(new ItemStack(this, 1, 4)); - ItemList.Casing_Coil_Naquadah.set(new ItemStack(this, 1, 5)); - ItemList.Casing_Coil_NaquadahAlloy.set(new ItemStack(this, 1, 6)); - ItemList.Casing_Coil_ElectrumFlux.set(new ItemStack(this, 1, 7)); - ItemList.Casing_Coil_AwakenedDraconium.set(new ItemStack(this, 1, 8)); - ItemList.Casing_Coil_HSSS.set(new ItemStack(this, 1, 9)); - ItemList.Casing_Coil_Trinium.set(new ItemStack(this, 1, 10)); - ItemList.Casing_Coil_Infinity.set(new ItemStack(this, 1, 11)); - ItemList.Casing_Coil_Hypogen.set(new ItemStack(this, 1, 12)); - ItemList.Casing_Coil_Eternal.set(new ItemStack(this, 1, 13)); - ItemList.Casing_Shielded_Accelerator.set(new ItemStack(this, 1, 14)); - } - - @Override - public int getTextureIndex(int aMeta) { - return (1 << 7) | aMeta; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); - case 1 -> Textures.BlockIcons.MACHINE_COIL_KANTHAL.getIcon(); - case 2 -> Textures.BlockIcons.MACHINE_COIL_NICHROME.getIcon(); - case 3 -> Textures.BlockIcons.MACHINE_COIL_TUNGSTENSTEEL.getIcon(); - case 4 -> Textures.BlockIcons.MACHINE_COIL_HSSG.getIcon(); - case 5 -> Textures.BlockIcons.MACHINE_COIL_NAQUADAH.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_COIL_NAQUADAHALLOY.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_COIL_ELECTRUMFLUX.getIcon(); - case 8 -> Textures.BlockIcons.MACHINE_COIL_AWAKENEDDRACONIUM.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_COIL_HSSS.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_COIL_TRINIUM.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_COIL_INFINITY.getIcon(); - case 12 -> Textures.BlockIcons.MACHINE_COIL_HYPOGEN.getIcon(); - case 13 -> Textures.BlockIcons.MACHINE_COIL_ETERNAL.getIcon(); - case 14 -> Textures.BlockIcons.MACHINE_CASING_SHIELDED_ACCELERATOR.getIcon(); - default -> Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); - }; - } - - /*--------------- COIL CHECK IMPL. ------------*/ - - public static HeatingCoilLevel getCoilHeatFromDamage(int meta) { - return switch (meta) { - case 0 -> LV; - case 1 -> MV; - case 2 -> HV; - case 3 -> EV; - case 4 -> IV; - case 5 -> ZPM; - case 6 -> UV; - case 7 -> UEV; - case 8 -> UIV; - case 9 -> LuV; - case 10 -> UHV; - case 11 -> UMV; - case 12 -> UXV; - case 13 -> MAX; - default -> None; - }; - } - - public static int getMetaFromCoilHeat(HeatingCoilLevel level) { - return switch (level) { - case LV -> 0; - case MV -> 1; - case HV -> 2; - case EV -> 3; - case IV -> 4; - case ZPM -> 5; - case UV -> 6; - case UEV -> 7; - case UIV -> 8; - case LuV -> 9; - case UHV -> 10; - case UMV -> 11; - case UXV -> 12; - case MAX -> 13; - default -> 0; - }; - } - - @Override - public HeatingCoilLevel getCoilHeat(int meta) { - getOnCoilCheck().accept(this); - return getCoilHeatFromDamage(meta); - } - - /*--------------- CALLBACK ------------*/ - - private Consumer callback = coil -> {}; - - @Override - public void setOnCoilCheck(Consumer callback) { - this.callback = callback; - } - - @Override - public Consumer getOnCoilCheck() { - return this.callback; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java deleted file mode 100644 index 9bdbf256cc..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java +++ /dev/null @@ -1,94 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -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.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings6 extends GT_Block_Casings_Abstract { - - public GT_Block_Casings6() { - super(GT_Item_Casings6.class, "gt.blockcasings6", GT_Material_Casings.INSTANCE, 16); - - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Hermetic Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Hermetic Casing I"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Hermetic Casing II"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Hermetic Casing III"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Hermetic Casing IV"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Hermetic Casing V"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Hermetic Casing VI"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Hermetic Casing VII"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Hermetic Casing VIII"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Hermetic Casing IX"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Hermetic Casing X"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Hermetic Casing XI"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Hermetic Casing XII"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Hermetic Casing XIII"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Hermetic Casing XIV"); - - ItemList.Casing_Tank_0.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Tank_1.set(new ItemStack(this, 1, 1)); - ItemList.Casing_Tank_2.set(new ItemStack(this, 1, 2)); - ItemList.Casing_Tank_3.set(new ItemStack(this, 1, 3)); - ItemList.Casing_Tank_4.set(new ItemStack(this, 1, 4)); - ItemList.Casing_Tank_5.set(new ItemStack(this, 1, 5)); - ItemList.Casing_Tank_6.set(new ItemStack(this, 1, 6)); - ItemList.Casing_Tank_7.set(new ItemStack(this, 1, 7)); - ItemList.Casing_Tank_8.set(new ItemStack(this, 1, 8)); - ItemList.Casing_Tank_9.set(new ItemStack(this, 1, 9)); - ItemList.Casing_Tank_10.set(new ItemStack(this, 1, 10)); - ItemList.Casing_Tank_11.set(new ItemStack(this, 1, 11)); - ItemList.Casing_Tank_12.set(new ItemStack(this, 1, 12)); - ItemList.Casing_Tank_13.set(new ItemStack(this, 1, 13)); - ItemList.Casing_Tank_14.set(new ItemStack(this, 1, 14)); - } - - @Override - public int getTextureIndex(int aMeta) { - return (8 << 7) | (aMeta + 112); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - if (ordinalSide == 0) { - return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); - } - if (ordinalSide == 1) { - return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); - } - return switch (aMeta) { - case 1 -> Textures.BlockIcons.MACHINE_CASING_TANK_1.getIcon(); - case 2 -> Textures.BlockIcons.MACHINE_CASING_TANK_2.getIcon(); - case 3 -> Textures.BlockIcons.MACHINE_CASING_TANK_3.getIcon(); - case 4 -> Textures.BlockIcons.MACHINE_CASING_TANK_4.getIcon(); - case 5 -> Textures.BlockIcons.MACHINE_CASING_TANK_5.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_CASING_TANK_6.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_CASING_TANK_7.getIcon(); - case 8 -> Textures.BlockIcons.MACHINE_CASING_TANK_8.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_CASING_TANK_9.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_CASING_TANK_10.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_CASING_TANK_11.getIcon(); - case 12 -> Textures.BlockIcons.MACHINE_CASING_TANK_12.getIcon(); - case 13 -> Textures.BlockIcons.MACHINE_CASING_TANK_13.getIcon(); - case 14 -> Textures.BlockIcons.MACHINE_CASING_TANK_14.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_TANK_0.getIcon(); - }; - } - - @Override - public int colorMultiplier(IBlockAccess aWorld, int aX, int aY, int aZ) { - return 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_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java deleted file mode 100644 index 0baeea1411..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java +++ /dev/null @@ -1,188 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -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.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_RenderingWorld; -import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { - - public static boolean mConnectedMachineTextures = true; - - // WATCH OUT FOR TEXTURE ID's - public GT_Block_Casings8() { - super(GT_Item_Casings8.class, "gt.blockcasings8", GT_Material_Casings.INSTANCE, 15); - /* - * DO NOT USE INDEX 15 ! USED HERE: https://github.com/GTNewHorizons/KubaTech/pull/101 - */ - - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemically Inert Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "PTFE Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mining Neutronium Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Mining Black Plutonium Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Extreme Engine Intake Casing"); - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + ".5.name", - "Europium Reinforced Radiation Proof Machine Casing"); - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + ".6.name", - "Advanced Rhodium Plated Palladium Machine Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".7.name", "Advanced Iridium Plated Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Magical Machine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "HSS-S Turbine Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Radiant Naquadah Alloy Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".11.name", "Basic Photolithographic Framework Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".12.name", "Reinforced Photolithographic Framework Casing"); - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + ".13.name", - "Radiation Proof Photolithographic Framework Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Infinity Cooled Casing"); - - ItemList.Casing_Chemically_Inert.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Pipe_Polytetrafluoroethylene.set(new ItemStack(this, 1, 1)); - ItemList.Casing_MiningNeutronium.set(new ItemStack(this, 1, 2)); - ItemList.Casing_MiningBlackPlutonium.set(new ItemStack(this, 1, 3)); - ItemList.Casing_ExtremeEngineIntake.set(new ItemStack(this, 1, 4)); - ItemList.Casing_AdvancedRadiationProof.set(new ItemStack(this, 1, 5)); - ItemList.Casing_Advanced_Rhodium_Palladium.set(new ItemStack(this, 1, 6)); - ItemList.Casing_Advanced_Iridium.set(new ItemStack(this, 1, 7)); - ItemList.Casing_Magical.set(new ItemStack(this, 1, 8)); - ItemList.Casing_TurbineGasAdvanced.set(new ItemStack(this, 1, 9)); - ItemList.RadiantNaquadahAlloyCasing.set(new ItemStack(this, 1, 10)); - ItemList.BasicPhotolithographicFrameworkCasing.set(new ItemStack(this, 1, 11)); - ItemList.ReinforcedPhotolithographicFrameworkCasing.set(new ItemStack(this, 1, 12)); - ItemList.RadiationProofPhotolithographicFrameworkCasing.set(new ItemStack(this, 1, 13)); - ItemList.InfinityCooledCasing.set(new ItemStack(this, 1, 14)); - } - - @Override - public int getTextureIndex(int aMeta) { - return (1 << 7) | (aMeta + 48); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.MACHINE_CASING_CHEMICALLY_INERT.getIcon(); - case 1 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE.getIcon(); - case 2 -> Textures.BlockIcons.MACHINE_CASING_MINING_NEUTRONIUM.getIcon(); - case 3 -> Textures.BlockIcons.MACHINE_CASING_MINING_BLACKPLUTONIUM.getIcon(); - case 4 -> Textures.BlockIcons.MACHINE_CASING_EXTREME_ENGINE_INTAKE.getIcon(); // changed color in a - // terrible way - case 5 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDRADIATIONPROOF.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_CASING_RHODIUM_PALLADIUM.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_CASING_IRIDIUM.getIcon(); - case 8 -> Textures.BlockIcons.MACHINE_CASING_MAGICAL.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_CASING_ADVANCEDGAS.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_CASING_RADIANT_NAQUADAH_ALLOY.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_1.getIcon(); - case 12 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_2.getIcon(); - case 13 -> Textures.BlockIcons.MACHINE_CASING_PCB_TIER_3.getIcon(); - case 14 -> Textures.BlockIcons.INFINITY_COOLED_CASING.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - }; - } - - public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean hasTurbine) { - // noinspection SwitchStatementWithTooFewBranches // "if" is harder to edit - return switch (meta) { - case 9 -> active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon() - : hasTurbine ? Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE_ADVGASEMPTY[iconIndex].getIcon(); - default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() - : hasTurbine ? Textures.BlockIcons.TURBINE[iconIndex].getIcon() - : Textures.BlockIcons.TURBINE_EMPTY[iconIndex].getIcon(); - }; - } - - private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine && tTile.getFrontFacing() - .ordinal() == ordinalSide) { - if (turbine.isNewStyleRendering()) return 0; - if (tTile.isActive()) return 1; - return turbine.hasTurbine() ? 2 : 3; - } - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { - aWorld = GT_RenderingWorld.getInstance(aWorld); - final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - - if (tMeta != 9 || !mConnectedMachineTextures) { - return getIcon(ordinalSide, tMeta); - } - - int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; - - switch (ordinalSide / 2) { - case 0 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, ordinalSide)) - != 0) { - return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); - } - } - } - } - case 1 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, ordinalSide)) - != 0) { - return getTurbineCasing( - tMeta, - 4 + i * 3 - j * tInvertLeftRightMod, - tState == 1, - tState == 2); - } - } - } - } - case 2 -> { - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i == 0 && j == 0) continue; - int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, ordinalSide)) - != 0) { - return getTurbineCasing( - tMeta, - 4 + i * 3 + j * tInvertLeftRightMod, - tState == 1, - tState == 2); - } - } - } - } - } - - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java deleted file mode 100644 index 6f33cda013..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java +++ /dev/null @@ -1,96 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; - -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.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Block_Casings9 extends GT_Block_Casings_Abstract { - - public GT_Block_Casings9() { - super(GT_Item_Casings9.class, "gt.blockcasings9", GT_Material_Casings.INSTANCE, 16); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "PBI Pipe Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Advanced Filter Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".1.tooltip", "Less than five 0.1μm particles per m^3"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Primitive Wooden Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".3.name", "Superplasticizer-Treated High Strength Concrete"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Sterile Water Plant Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".5.name", "Reinforced Sterile Water Plant Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Slick Sterile Flocculation Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".7.name", "Stabilized Naquadah Water Plant Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".8.name", "Inert Neutralization Water Plant Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Reactive Gas Containment Casing"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Inert Filtration Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".11.name", "Heat-Resistant Trinium Plated Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".12.name", "Naquadria-Reinforced Water Plant Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".13.name", "High Energy Ultraviolet Emitter Casing"); - // placeholder name - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".14.name", "Particle Beam Guidance Pipe Casing"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".15.name", "Femtometer-Calibrated Particle Beam Casing"); - - ItemList.Casing_Pipe_Polybenzimidazole.set(new ItemStack(this, 1, 0)); - ItemList.Casing_Vent_T2.set(new ItemStack(this, 1, 1)); - ItemList.WoodenCasing.set(new ItemStack(this, 1, 2)); - ItemList.BlockIndustrialStrengthConcrete.set(new ItemStack(this, 1, 3)); - ItemList.BlockIndustrialWaterPlantCasing.set(new ItemStack(this, 1, 4)); - ItemList.BlockSterileWaterPlantCasing.set(new ItemStack(this, 1, 5)); - ItemList.BlockFlocculationCasing.set(new ItemStack(this, 1, 6)); - ItemList.BlockNaquadahReinforcedWaterPlantCasing.set(new ItemStack(this, 1, 7)); - ItemList.BlockExtremeCorrosionResistantCasing.set(new ItemStack(this, 1, 8)); - ItemList.BlockHighPressureResistantCasing.set(new ItemStack(this, 1, 9)); - ItemList.BlockOzoneCasing.set(new ItemStack(this, 1, 10)); - ItemList.BlockPlasmaHeatingCasing.set(new ItemStack(this, 1, 11)); - ItemList.BlockNaquadriaReinforcedWaterPlantCasing.set(new ItemStack(this, 1, 12)); - ItemList.BlockUltraVioletLaserEmitter.set(new ItemStack(this, 1, 13)); - ItemList.BlockQuarkPipe.set(new ItemStack(this, 1, 14)); - ItemList.BlockQuarkReleaseChamber.set(new ItemStack(this, 1, 15)); - } - - @Override - public int getTextureIndex(int aMeta) { - return (16 << 7) | (aMeta + 16); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYBENZIMIDAZOLE.getIcon(); - case 1 -> Textures.BlockIcons.MACHINE_CASING_VENT_T2.getIcon(); - case 2 -> ordinalSide >= 2 ? Textures.BlockIcons.TEXTURE_METAL_PANEL_E.getIcon() - : Textures.BlockIcons.TEXTURE_METAL_PANEL_E_A.getIcon(); - case 3 -> Textures.BlockIcons.INDUSTRIAL_STRENGTH_CONCRETE.getIcon(); - case 4 -> Textures.BlockIcons.MACHINE_CASING_INDUSTRIAL_WATER_PLANT.getIcon(); - case 5 -> Textures.BlockIcons.WATER_PLANT_CONCRETE_CASING.getIcon(); - case 6 -> Textures.BlockIcons.MACHINE_CASING_FLOCCULATION.getIcon(); - case 7 -> Textures.BlockIcons.MACHINE_CASING_NAQUADAH_REINFORCED_WATER_PLANT.getIcon(); - case 8 -> Textures.BlockIcons.MACHINE_CASING_EXTREME_CORROSION_RESISTANT.getIcon(); - case 9 -> Textures.BlockIcons.MACHINE_CASING_HIGH_PRESSURE_RESISTANT.getIcon(); - case 10 -> Textures.BlockIcons.MACHINE_CASING_OZONE.getIcon(); - case 11 -> Textures.BlockIcons.MACHINE_CASING_PLASMA_HEATER.getIcon(); - case 12 -> Textures.BlockIcons.NAQUADRIA_REINFORCED_WATER_PLANT_CASING.getIcon(); - case 13 -> Textures.BlockIcons.UV_BACKLIGHT_STERILIZER_CASING.getIcon(); - case 14 -> Textures.BlockIcons.BLOCK_QUARK_PIPE.getIcon(); - case 15 -> Textures.BlockIcons.BLOCK_QUARK_RELEASE_CHAMBER.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - }; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java deleted file mode 100644 index cfa51f8e99..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java +++ /dev/null @@ -1,144 +0,0 @@ -package gregtech.common.blocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.items.GT_Generic_Block; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_LanguageManager; - -/** - * The base class for casings. Casings are the blocks that are mainly used to build multiblocks. - */ -public abstract class GT_Block_Casings_Abstract extends GT_Generic_Block - implements gregtech.api.interfaces.IHasIndexedTexture { - - 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 GT_Block_Casings_Abstract(Class aItemClass, String aName, Material aMaterial, - int aMaxMeta) { - this(aItemClass, aName, aMaterial); - for (int i = 0; i < aMaxMeta; i++) { - Textures.BlockIcons.setCasingTextureForId(getTextureIndex(i), TextureFactory.of(this, i)); - } - } - - @Override - public String getHarvestTool(int aMeta) { - return "wrench"; - } - - @Override - public int getHarvestLevel(int aMeta) { - return 2; - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); - } - - @Override - public float getExplosionResistance(Entity aTNT) { - return Blocks.iron_block.getExplosionResistance(aTNT); - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - 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); - } - } - - @Override - public String getUnlocalizedName() { - return this.mUnlocalizedName; - } - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return true; - } - - @Override - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { - if (GregTech_API.isMachineBlock(this, aMetaData)) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { - return false; - } - - @Override - public int damageDropped(int metadata) { - return metadata; - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - return aWorld.getBlockMetadata(aX, aY, aZ); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) {} - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { - for (int i = 0; i < 16; i++) { - ItemStack aStack = new ItemStack(aItem, 1, i); - if (!aStack.getDisplayName() - .contains(".name")) aList.add(aStack); - } - } - - /** - * Provide a fallback to subclasses in addons. - */ - @Override - public int getTextureIndex(int aMeta) { - return Textures.BlockIcons.ERROR_TEXTURE_INDEX; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java deleted file mode 100644 index c7b7e2bb04..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java +++ /dev/null @@ -1,83 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.IBlockOnWalkOver; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; - -public class GT_Block_Concretes extends GT_Block_Stones_Abstract implements IBlockOnWalkOver { - - 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)); - } - - @Override - public int getHarvestLevel(int aMeta) { - return 1; - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ); - } - - @Override - public IIcon getIcon(int ordinalSide, 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(); - } - - @Override - public void onWalkOver(EntityLivingBase aEntity, World aWorld, int aX, int aY, int aZ) { - if ((aEntity.motionX != 0 || aEntity.motionZ != 0) && !aEntity.isInWater() - && !aEntity.isWet() - && !aEntity.isSneaking()) { - double tSpeed = (aWorld.getBlock(aX, aY - 1, aZ).slipperiness >= 0.8 ? 1.5 : 1.2); - aEntity.motionX *= tSpeed; - aEntity.motionZ *= tSpeed; - } - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Drone.java b/src/main/java/gregtech/common/blocks/GT_Block_Drone.java deleted file mode 100644 index 81d1acc228..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Drone.java +++ /dev/null @@ -1,65 +0,0 @@ -package gregtech.common.blocks; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.common.tileentities.render.TileDrone; - -public class GT_Block_Drone extends Block { - - public GT_Block_Drone() { - super(Material.iron); - this.setResistance(20f); - this.setHardness(-1.0f); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - this.setBlockName("gt.dronerender"); - this.setLightLevel(100.0f); - GameRegistry.registerBlock(this, getUnlocalizedName()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean canRenderInPass(int a) { - return true; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } - - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileDrone(); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { - return new ArrayList<>(); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java b/src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java deleted file mode 100644 index 76e3180d58..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_FrameBox.java +++ /dev/null @@ -1,446 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.enums.GT_Values.W; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.BaseMetaPipeEntity; -import gregtech.api.metatileentity.BaseMetaTileEntity; -import gregtech.api.metatileentity.BaseTileEntity; -import gregtech.api.metatileentity.CoverableTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; -import gregtech.common.render.GT_Renderer_Block; - -public class GT_Block_FrameBox extends BlockContainer { - - protected final String mUnlocalizedName; - - private static final String DOT_NAME = ".name"; - private static final String DOT_TOOLTIP = ".tooltip"; - - // We need to keep around a temporary TE to preserve this TE after breaking the block, so we can - // properly call getDrops() on it - private static final ThreadLocal mTemporaryTileEntity = new ThreadLocal<>(); - - public GT_Block_FrameBox() { - super(new GT_Material_Machines()); - this.mUnlocalizedName = "gt.blockframes"; - setBlockName(this.mUnlocalizedName); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + W + ".name", "Any Sub Block of this one"); - - GameRegistry.registerBlock(this, GT_Item_Frames.class, getUnlocalizedName()); - - for (int meta = 1; meta < GregTech_API.sGeneratedMaterials.length; meta++) { - Materials material = GregTech_API.sGeneratedMaterials[meta]; - if (material != null && (material.mTypes & 0x02) != 0) { - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + "." + meta + DOT_NAME, - GT_LanguageManager.i18nPlaceholder ? getLocalizedNameFormat(material) : getLocalizedName(material)); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + "." + meta + DOT_TOOLTIP, material.getToolTip()); - } - } - } - - public ItemStack getStackForm(int amount, int meta) { - return new ItemStack(this, amount, meta); - } - - public String getLocalizedNameFormat(Materials aMaterial) { - return switch (aMaterial.mName) { - case "InfusedAir", "InfusedDull", "InfusedEarth", "InfusedEntropy", "InfusedFire", "InfusedOrder", "InfusedVis", "InfusedWater" -> "%material Infused Stone"; - case "Vermiculite", "Bentonite", "Kaolinite", "Talc", "BasalticMineralSand", "GraniticMineralSand", "GlauconiteSand", "CassiteriteSand", "GarnetSand", "QuartzSand", "Pitchblende", "FullersEarth" -> "%material"; - default -> "%material" + " Frame Box"; - }; - } - - @Override - public String getUnlocalizedName() { - return mUnlocalizedName; - } - - public String getLocalizedName(Materials aMaterial) { - return aMaterial.getDefaultLocalizedNameForItem(getLocalizedNameFormat(aMaterial)); - } - - private boolean isCover(ItemStack item) { - return GT_Utility.isStackInList(item, GregTech_API.sCovers.keySet()); - } - - private void createFrame(World worldIn, int x, int y, int z, BaseMetaPipeEntity baseMte) { - // Obtain metadata to grab proper material identifier - int meta = worldIn.getBlockMetadata(x, y, z); - Materials material = getMaterial(meta); - GT_MetaPipeEntity_Frame frame = new GT_MetaPipeEntity_Frame("GT_Frame_" + material, material); - baseMte.setMetaTileEntity(frame); - frame.setBaseMetaTileEntity(baseMte); - } - - private BaseMetaPipeEntity spawnFrameEntity(World worldIn, int x, int y, int z) { - // Spawn a TE frame box at this location, then apply the cover - BaseMetaPipeEntity newTileEntity = new BaseMetaPipeEntity(); - createFrame(worldIn, x, y, z, newTileEntity); - worldIn.setTileEntity(x, y, z, newTileEntity); - return newTileEntity; - } - - // Get the material that this frame box is made of - public static Materials getMaterial(int meta) { - return GregTech_API.sGeneratedMaterials[meta]; - } - - @Override - public boolean onBlockActivated(World worldIn, int x, int y, int z, EntityPlayer player, int side, float subX, - float subY, float subZ) { - // Get ForgeDirection from side identifier. - ForgeDirection direction = ForgeDirection.getOrientation(side); - // If this block already holds a TE, just forward the call - TileEntity te = worldIn.getTileEntity(x, y, z); - if (te instanceof BaseMetaPipeEntity baseTileEntity) { - // If this baseTileEntity has no MetaTileEntity associated with it, we need to create it - // This happens on world load for some reason - if (baseTileEntity.getMetaTileEntity() == null) { - createFrame(worldIn, x, y, z, baseTileEntity); - } - return baseTileEntity.onRightclick(player, direction, subX, subY, subZ); - } - - // If there was no TileEntity yet, we need to check if the player was holding a cover item and if so - // spawn a new frame box to apply the cover to - ItemStack item = player.getHeldItem(); - if (isCover(item)) { - BaseMetaPipeEntity newTileEntity = spawnFrameEntity(worldIn, x, y, z); - newTileEntity.onRightclick(player, direction, subX, subY, subZ); - return true; - } - - return false; - } - - @Override - public int getRenderType() { - if (GT_Renderer_Block.INSTANCE == null) { - return super.getRenderType(); - } - return GT_Renderer_Block.mRenderID; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public int getRenderBlockPass() { - return 1; - } - - @Override - @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 material is not null and has a frame box item associated with it - if ((tMaterial != null) && ((tMaterial.mTypes & 0x02) != 0)) { - aList.add(new ItemStack(aItem, 1, i)); - } - } - } - - @Override - public String getHarvestTool(int aMeta) { - return "wrench"; - } - - @Override - public int getHarvestLevel(int aMeta) { - return aMeta % 4; - } - - @Override - public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - ForgeDirection forgeSide = switch (ordinalSide) { - case (-2) -> ForgeDirection.DOWN; - case (-1) -> ForgeDirection.UP; - case (0) -> ForgeDirection.NORTH; - case (2) -> ForgeDirection.SOUTH; - case (3) -> ForgeDirection.WEST; - case (1) -> ForgeDirection.EAST; - default -> ForgeDirection.UNKNOWN; - }; - final TileEntity frameEntity = aWorld.getTileEntity(aX, aY, aZ); - return frameEntity instanceof CoverableTileEntity cte && cte.getCoverInfoAtSide(forgeSide) - .getCoverID() != 0; - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - return aWorld.getBlockMetadata(aX, aY, aZ); - } - - @Override - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - gtTE.onBlockDestroyed(); - mTemporaryTileEntity.set(gtTE); - } - // Cause structure update - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetadata); - } - - @Override - public void onBlockAdded(World worldIn, int x, int y, int z) { - // Cause structure update - GregTech_API.causeMachineUpdate(worldIn, x, y, z); - super.onBlockAdded(worldIn, x, y, z); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { - gtTE.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - return; - } - super.onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return (tTileEntity instanceof BaseMetaTileEntity baseMTE) && baseMTE.privateAccess() - && !baseMTE.playerOwnsThis(aPlayer, true) ? -1.0F - : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); - } - - @Override - public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseTileEntity baseTE) { - baseTE.onAdjacentBlockChange(aTileX, aTileY, aTileZ); - } - } - - @Override - public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseMetaPipeEntity baseMetaPipe) { - baseMetaPipe.onNeighborBlockChange(aX, aY, aZ); - } - } - - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, - List outputAABB, Entity collider) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { - gtTE.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - return; - } - super.addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { - return gtTE.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { - return gtTE.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { - if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { - return true; - } - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseMetaTileEntity) { - return true; - } - if (tTileEntity instanceof BaseMetaPipeEntity baseMetaPipe && (baseMetaPipe.mConnections & 0xFFFFFFC0) != 0) { - return true; - } - return (tTileEntity instanceof ICoverable coverable) && coverable.getCoverIDAtSide(side) != 0; - } - - @Override // THIS - public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { - final TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE && gtTE.getMetaTileEntity() != null) { - final AxisAlignedBB bbb = gtTE.getCollisionBoundingBoxFromPool(gtTE.getWorld(), 0, 0, 0); - minX = bbb.minX; // This essentially sets block bounds - minY = bbb.minY; - minZ = bbb.minZ; - maxX = bbb.maxX; - maxY = bbb.maxY; - maxZ = bbb.maxZ; - return; - } - super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); - } - - @Override - public void setBlockBoundsForItemRender() { - super.setBlockBounds(0, 0, 0, 1, 1, 1); - } - - @Override - public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return 0; - } - - @Override - public int getFireSpreadSpeed(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return 0; - } - - @Override - public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { - return false; - } - - @Override - public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return false; - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean hasTileEntity(int aMeta) { - return true; - } - - @Override - public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { - super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity != null && tTileEntity.receiveClientEvent(aData1, aData2); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int metadata, int fortune) { - // Find temporary TE if there was one - final IGregTechTileEntity tempTe = mTemporaryTileEntity.get(); - ArrayList drops = new ArrayList<>(); - drops.add(getStackForm(1, metadata)); - // If there is one, grab all attached covers and drop them - if (tempTe != null) { - for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { - ItemStack cover = tempTe.getCoverItemAtSide(direction); - if (cover != null) drops.add(cover); - } - } - // Make sure to clear the temporary TE - mTemporaryTileEntity.remove(); - return drops; - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - if (ordinalSide < 0 || ordinalSide > 5) { - return 0; - } - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - return gtTE.getOutputRedstoneSignal( - ForgeDirection.getOrientation(ordinalSide) - .getOpposite()); - } - return 0; - } - - @Override - public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - if (ordinalSide < 0 || ordinalSide > 5) { - return 0; - } - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - return gtTE.getStrongOutputRedstoneSignal( - ForgeDirection.getOrientation(ordinalSide) - .getOpposite()); - } - return 0; - } - - @Override - public IIcon getIcon(int side, int meta) { - Materials material = GregTech_API.sGeneratedMaterials[meta]; - if (material == null) return null; - return material.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex].getIcon(); - } - - public ITexture[] getTexture(int meta) { - Materials material = getMaterial(meta); - if (material == null) return null; - return new ITexture[] { TextureFactory.of( - material.mIconSet.mTextures[OrePrefixes.frameGt.mTextureIndex], - Dyes.getModulation(-1, material.mRGBa)) }; - } - - @Override - public TileEntity createNewTileEntity(World worldIn, int meta) { - return null; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Glass1.java b/src/main/java/gregtech/common/blocks/GT_Block_Glass1.java deleted file mode 100644 index 2aa5613d11..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Glass1.java +++ /dev/null @@ -1,107 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Facing; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -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.util.GT_LanguageManager; - -/** - * The glass is split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - * - * This class hosts various special types of tiered glass with not many tiers. - */ -public class GT_Block_Glass1 extends GT_Block_Casings_Abstract { - - public GT_Block_Glass1() { - super(GT_Item_Glass1.class, "gt.blockglass1", Material.glass, 4); - this.opaque = false; - - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemical Grade Glass"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".1.name", "Electron-Permeable Neutronium Coated Glass"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Omni-Purpose Infinity Fused Glass"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".3.name", "Non-Photonic Matter Exclusion Glass"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".4.name", "Hawking Radiation Realignment Focus"); - - ItemList.GlassPHResistant.set(new ItemStack(this, 1, 0)); - ItemList.GlassUVResistant.set(new ItemStack(this, 1, 1)); - ItemList.GlassOmniPurposeInfinityFused.set(new ItemStack(this, 1, 2)); - ItemList.GlassQuarkContainment.set(new ItemStack(this, 1, 3)); - ItemList.GlassQuarkContainment.set(new ItemStack(this, 1, 3)); - ItemList.Hawking_Glass.set(new ItemStack(this, 1, 4)); - } - - @Override - public int getTextureIndex(int aMeta) { - // Page 16, 0-16 - return (16 << 7) | (aMeta); - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() { - return 1; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.GLASS_PH_RESISTANT.getIcon(); - case 1 -> Textures.BlockIcons.NEUTRONIUM_COATED_UV_RESISTANT_GLASS.getIcon(); - case 2 -> Textures.BlockIcons.OMNI_PURPOSE_INFINITY_FUSED_GLASS.getIcon(); - case 3 -> Textures.BlockIcons.GLASS_QUARK_CONTAINMENT.getIcon(); - case 4 -> Textures.BlockIcons.HAWKING_GLASS.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - }; - } - - /** - * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given - * coordinates. Args: blockAccess, x, y, z, side - */ - @SideOnly(Side.CLIENT) - @Override - public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { - Block block = worldIn.getBlock(x, y, z); - - if (worldIn.getBlockMetadata(x, y, z) != worldIn.getBlockMetadata( - x - Facing.offsetsXForSide[side], - y - Facing.offsetsYForSide[side], - z - Facing.offsetsZForSide[side])) { - return true; - } - - if (block == this) { - return false; - } - - return super.shouldSideBeRendered(worldIn, x, y, z, side); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java deleted file mode 100644 index 69ebc2e733..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java +++ /dev/null @@ -1,77 +0,0 @@ -package gregtech.common.blocks; - -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; - -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; - -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)); - } - - @Override - public int getHarvestLevel(int aMeta) { - return 3; - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; - } - - @Override - public IIcon getIcon(int ordinalSide, 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(); - } - - @Override - 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_Laser.java b/src/main/java/gregtech/common/blocks/GT_Block_Laser.java deleted file mode 100644 index 038b114284..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Laser.java +++ /dev/null @@ -1,104 +0,0 @@ -package gregtech.common.blocks; - -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.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; -import gregtech.common.tileentities.render.TileLaser; - -public class GT_Block_Laser extends Block implements ITileEntityProvider { - - public static IIcon[] textures; - - public GT_Block_Laser() { - super(Material.iron); - setBlockName("LaserPlate"); - this.setCreativeTab(GregTech_API.TAB_GREGTECH); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".name", "Laser Resistant Plate"); - GregTech_API.registerMachineBlock(this, -1); - GameRegistry.registerBlock(this, GT_Item_Block_Laser.class, getUnlocalizedName()); - ItemList.Laser_Plate.set(new ItemStack(this, 1)); - } - - @Override - 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); - } - } - - @Override - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { - if (GregTech_API.isMachineBlock(this, aMetaData)) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - - @Override - public String getHarvestTool(int aMeta) { - return "wrench"; - } - - @Override - public int getHarvestLevel(int aMeta) { - return 2; - } - - @Override - public String getUnlocalizedName() { - return "gt.laserplate"; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = Textures.BlockIcons.LASER_PLATE.getIcon(); - } - - @Override - public IIcon getIcon(int side, int meta) { - return blockIcon; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public float getBlockHardness(World world, int x, int y, int z) { - return 1.0f; - } - - @Override - public int damageDropped(int meta) { - return meta; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } - - @Override - public TileEntity createNewTileEntity(World world, int meta) { - return new TileLaser(); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java deleted file mode 100644 index 2f80929d94..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ /dev/null @@ -1,703 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - -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.init.Blocks; -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.StatCollector; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import com.cricketcraft.chisel.api.IFacade; - -import cpw.mods.fml.common.Optional; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.IDebugableBlock; -import gregtech.api.interfaces.tileentity.IColoredTileEntity; -import gregtech.api.interfaces.tileentity.ICoverable; -import gregtech.api.interfaces.tileentity.IDebugableTileEntity; -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.metatileentity.CoverableTileEntity; -import gregtech.api.util.GT_BaseCrop; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; -import gregtech.common.covers.CoverInfo; -import gregtech.common.render.GT_Renderer_Block; -import gregtech.common.tileentities.storage.GT_MetaTileEntity_QuantumChest; -import gtPlusPlus.xmod.gregtech.common.tileentities.redstone.GT_MetaTileEntity_RedstoneBase; - -@Optional.Interface(iface = "com.cricketcraft.chisel.api.IFacade", modid = "ChiselAPI") -public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlock, ITileEntityProvider, IFacade { - - private static final ThreadLocal mTemporaryTileEntity = new ThreadLocal<>(); - private boolean renderAsNormalBlock; - - 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; - this.renderAsNormalBlock = true; - this.useNeighborBrightness = true; - } - - @Override - public String getHarvestTool(int aMeta) { - if (aMeta >= 8 && aMeta <= 11) { - return "cutter"; - } - return "wrench"; - } - - @Override - public int getHarvestLevel(int aMeta) { - return aMeta % 4; - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int aTileX, int aTileY, int aTileZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseTileEntity)) { - ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); - } - } - - @Override - public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaPipeEntity)) { - ((BaseMetaPipeEntity) tTileEntity).onNeighborBlockChange(aX, aY, aZ); - } - } - - @Override - 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); - } - } - - @Override - public String getUnlocalizedName() { - return "gt.blockmachines"; - } - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(getUnlocalizedName() + ".name"); - } - - @Override - public int getFlammability(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return 0; - } - - @Override - 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; - } - - @Override - public int getRenderType() { - if (GT_Renderer_Block.INSTANCE == null) { - return super.getRenderType(); - } - return GT_Renderer_Block.INSTANCE.mRenderID; - } - - @Override - public boolean isFireSource(World aWorld, int aX, int aY, int aZ, ForgeDirection side) { - return GregTech_API.sMachineFlammable && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); - } - - @Override - public boolean isFlammable(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection face) { - return GregTech_API.sMachineFlammable && (aWorld.getBlockMetadata(aX, aY, aZ) == 0); - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - ForgeDirection forgeSide = switch (ordinalSide) { - case (-2) -> ForgeDirection.DOWN; - case (-1) -> ForgeDirection.UP; - case (0) -> ForgeDirection.NORTH; - case (2) -> ForgeDirection.SOUTH; - case (3) -> ForgeDirection.WEST; - case (1) -> ForgeDirection.EAST; - default -> ForgeDirection.UNKNOWN; - }; - final TileEntity machineEntity = aWorld.getTileEntity(aX, aY, aZ); - return machineEntity instanceof BaseMetaTileEntity bmte && (bmte.getCoverInfoAtSide(forgeSide) - .getCoverID() != 0 || bmte.getMetaTileEntity() instanceof GT_MetaTileEntity_RedstoneBase); - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean hasTileEntity(int aMeta) { - return true; - } - - @Override - public boolean hasComparatorInputOverride() { - return true; - } - - @Override - public boolean renderAsNormalBlock() { - return renderAsNormalBlock; - } - - public GT_Block_Machines setRenderAsNormalBlock(boolean aBool) { - renderAsNormalBlock = aBool; - return this; - } - - @Override - public boolean canProvidePower() { - return true; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public TileEntity createNewTileEntity(World aWorld, int aMeta) { - return createTileEntity(aWorld, aMeta); - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); - } - - @Override - public boolean onBlockEventReceived(World aWorld, int aX, int aY, int aZ, int aData1, int aData2) { - super.onBlockEventReceived(aWorld, aX, aY, aZ, aData1, aData2); - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity != null && tTileEntity.receiveClientEvent(aData1, aData2); - } - - @Override - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, - List outputAABB, Entity collider) { - final 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); - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { - return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { - return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - - @Override // THIS - public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { - final TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity - && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - final AxisAlignedBB bbb = ((IGregTechTileEntity) tTileEntity) - .getCollisionBoundingBoxFromPool(((IGregTechTileEntity) tTileEntity).getWorld(), 0, 0, 0); - minX = bbb.minX; // This essentially sets block bounds - minY = bbb.minY; - minZ = bbb.minZ; - maxX = bbb.maxX; - maxY = bbb.maxY; - maxZ = bbb.maxZ; - return; - } - super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); - } - - @Override - public void setBlockBoundsForItemRender() { - super.setBlockBounds(0, 0, 0, 1, 1, 1); - } - - @Override - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - final 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) - @Override - public void registerBlockIcons(IIconRegister aIconRegister) { - if (!GregTech_API.sPostloadFinished) return; - GT_Log.out.println("GT_Mod: Setting up Icon Register for Blocks"); - GregTech_API.setBlockIconRegister(aIconRegister); - - GT_Log.out.println("GT_Mod: Registering MetaTileEntity specific Textures"); - try { - for (int i = 1; i < GregTech_API.METATILEENTITIES.length; i++) { - if (GregTech_API.METATILEENTITIES[i] != null) { - GregTech_API.METATILEENTITIES[i].registerIcons(aIconRegister); - } - } - } catch (Exception 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 (Exception e) { - e.printStackTrace(GT_Log.err); - } - GT_Log.out.println("GT_Mod: Starting Block Icon Load Phase"); - GT_FML_LOGGER.info("GT_Mod: Starting Block Icon Load Phase"); - try { - for (Runnable tRunnable : GregTech_API.sGTBlockIconload) { - tRunnable.run(); - } - } catch (Exception e) { - e.printStackTrace(GT_Log.err); - } - GT_Log.out.println("GT_Mod: Finished Block Icon Load Phase"); - GT_FML_LOGGER.info("GT_Mod: Finished Block Icon Load Phase"); - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) tTileEntity).privateAccess() - && !((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true) ? -1.0F - : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); - } - - @Override - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, - float aOffsetX, float aOffsetY, float aOffsetZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return false; - } - if (aPlayer.isSneaking()) { - final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if (tCurrentItem != null && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) - && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList) - && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) - && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList) - && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sJackhammerList)) return false; - } - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - if (gtTE.getTimer() < 1L) { - return false; - } - if ((!aWorld.isRemote) && !gtTE.isUseableByPlayer(aPlayer)) { - return true; - } - return ((IGregTechTileEntity) tTileEntity) - .onRightclick(aPlayer, ForgeDirection.getOrientation(ordinalSide), aOffsetX, aOffsetY, aOffsetZ); - } - return false; - } - - @Override - public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - gtTE.onLeftclick(aPlayer); - } - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - return gtTE.getMetaTileID(); - } - return 0; - } - - @Override - public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseMetaTileEntity baseTE) { - GT_Log.exp.printf( - "Explosion at : %d | %d | %d DIMID: %s due to near explosion!%n", - aX, - aY, - aZ, - aWorld.provider.dimensionId); - baseTE.doEnergyExplosion(); - } - super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); - } - - @Override - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - gtTE.onBlockDestroyed(); - mTemporaryTileEntity.set(gtTE); - if (!(gtTE.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) { - for (int i = 0; i < gtTE.getSizeInventory(); i++) { - final ItemStack tItem = gtTE.getStackInSlot(i); - if ((tItem != null) && (tItem.stackSize > 0) && (gtTE.isValidSlot(i)) && gtTE.shouldDropItemAt(i)) { - final EntityItem tItemEntity = new EntityItem( - aWorld, - aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, - aY + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, - aZ + XSTR_INSTANCE.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 = (XSTR_INSTANCE.nextGaussian() * 0.05D); - tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.25D); - tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.05D); - aWorld.spawnEntityInWorld(tItemEntity); - tItem.stackSize = 0; - gtTE.setInventorySlotContents(i, null); - } - } - } - } - super.breakBlock(aWorld, aX, aY, aZ, aBlock, aMetadata); - aWorld.removeTileEntity(aX, aY, aZ); - } - - @Override - public ArrayList getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - return gtTE.getDrops(); - } - final IGregTechTileEntity tGregTechTileEntity = mTemporaryTileEntity.get(); - final ArrayList tDrops; - if (tGregTechTileEntity == null) { - tDrops = new ArrayList<>(); - } else { - tDrops = tGregTechTileEntity.getDrops(); - mTemporaryTileEntity.remove(); - } - return tDrops; - } - - @Override - public boolean removedByPlayer(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, boolean aWillHarvest) { - // This delays deletion of the block until after getDrops - return aWillHarvest || super.removedByPlayer(aWorld, aPlayer, aX, aY, aZ, false); - } - - @Override - public void harvestBlock(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, int aMeta) { - super.harvestBlock(aWorld, aPlayer, aX, aY, aZ, aMeta); - aWorld.setBlockToAir(aX, aY, aZ); - } - - @Override - public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int ordinalSide) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - return gtTE.getComparatorValue(ForgeDirection.getOrientation(ordinalSide)); - } - return 0; - } - - @Override - public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - if (ordinalSide < 0 || ordinalSide > 5) { - return 0; - } - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - return gtTE.getOutputRedstoneSignal( - ForgeDirection.getOrientation(ordinalSide) - .getOpposite()); - } - return 0; - } - - @Override - public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - if (ordinalSide < 0 || ordinalSide > 5) { - return 0; - } - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity gtTE) { - return gtTE.getStrongOutputRedstoneSignal( - ForgeDirection.getOrientation(ordinalSide) - .getOpposite()); - } - return 0; - } - - @Override - public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int aMetadata, float chance, - int aFortune) { - if (!aWorld.isRemote) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null && (chance < 1.0F)) { - if (tTileEntity instanceof BaseMetaTileEntity bmte && (GregTech_API.sMachineNonWrenchExplosions)) { - GT_Log.exp.printf( - "Explosion at : %d | %d | %d DIMID: %s NonWrench picking/Rain!%n", - aX, - aY, - aZ, - aWorld.provider.dimensionId); - bmte.doEnergyExplosion(); - } - } else { - super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, aMetadata, chance, aFortune); - } - } - } - - @Override - public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { - if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { - return true; - } - final 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; - } - return tTileEntity instanceof ICoverable && ((ICoverable) tTileEntity).getCoverIDAtSide(side) != 0; - } - return false; - } - - @Override - public boolean isBlockNormalCube() { - return true; - } - - /** - * Returns the default ambient occlusion value based on block opacity - */ - @SideOnly(Side.CLIENT) - @Override - public float getAmbientOcclusionLightValue() { - return this.renderAsNormalBlock() ? 0.2F : 0.5F; - } - - /** - * @inheritDoc - */ - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World aWorld, int aX, int aY, int aZ, Random aRandom) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - ((IGregTechTileEntity) tTileEntity).onRandomDisplayTick(); - } - } - - @Override - public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getLightOpacity(); - } - return aWorld.getBlockMetadata(aX, aY, aZ) == 0 ? 255 : 0; - } - - @Override - public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseMetaTileEntity) { - return ((BaseMetaTileEntity) tTileEntity).getLightValue(); - } - return 0; - } - - @Override - public TileEntity createTileEntity(World aWorld, int aMeta) { - return GregTech_API.createTileEntity(aMeta); - } - - @Override - public float getExplosionResistance(Entity entity, World aWorld, int aX, int aY, int aZ, double explosionX, - double explosionY, double explosionZ) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getBlastResistance(ForgeDirection.UNKNOWN); - } - return 10.0F; - } - - @SideOnly(Side.CLIENT) - @Override - public void getSubBlocks(Item item, CreativeTabs aCreativeTab, List outputSubBlocks) { - for (int i = 1; i < GregTech_API.METATILEENTITIES.length; i++) { - if (GregTech_API.METATILEENTITIES[i] != null) { - outputSubBlocks.add(new ItemStack(item, 1, i)); - } - } - } - - @Override - public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (!(tTileEntity instanceof IGregTechTileEntity iGregTechTileEntity)) return; - iGregTechTileEntity.setFrontFacing( - BaseTileEntity.getSideForPlayerPlacing(aPlayer, ForgeDirection.UP, iGregTechTileEntity.getValidFacings())); - } - - @Override - public ArrayList getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { - final TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IDebugableTileEntity) { - return ((IDebugableTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); - } - return new ArrayList<>(); - } - - @Override - public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection side, int aColor) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IColoredTileEntity coloredTE) { - if (coloredTE.getColorization() == (byte) ((~aColor) & 0xF)) { - return false; - } - coloredTE.setColorization((byte) ((~aColor) & 0xF)); - return true; - } - return false; - } - - @Override - public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof CoverableTileEntity tile) { - final ForgeDirection dir = ForgeDirection.getOrientation(ordinalSide); - if (dir != ForgeDirection.UNKNOWN) { - final Block facadeBlock = tile.getCoverInfoAtSide(dir) - .getFacadeBlock(); - if (facadeBlock != null) return facadeBlock; - } else { - // we do not allow more than one type of facade per block, so no need to check every side - // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable - for (final ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { - final Block facadeBlock = tile.getCoverInfoAtSide(tSide) - .getFacadeBlock(); - if (facadeBlock != null) { - return facadeBlock; - } - } - } - } - return Blocks.air; - } - - @Override - public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { - final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof CoverableTileEntity tile) { - final ForgeDirection dir = ForgeDirection.getOrientation(ordinalSide); - if (ordinalSide != -1) { - final CoverInfo coverInfo = tile.getCoverInfoAtSide(dir); - final Block facadeBlock = coverInfo.getFacadeBlock(); - if (facadeBlock != null) return coverInfo.getFacadeMeta(); - } else { - // we do not allow more than one type of facade per block, so no need to check every side - // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable - for (final ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - final CoverInfo coverInfo = tile.getCoverInfoAtSide(d); - final Block facadeBlock = coverInfo.getFacadeBlock(); - if (facadeBlock != null) { - return coverInfo.getFacadeMeta(); - } - } - } - } - return 0; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java deleted file mode 100644 index 753c590e51..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java +++ /dev/null @@ -1,68 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.enums.Mods.NotEnoughItems; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - -import gregtech.api.GregTech_API; -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; - -public class GT_Block_Metal extends GT_Block_Storage { - - public Materials[] mMats; - public OrePrefixes mPrefix; - public IIconContainer[] mBlockIcons; - public boolean mHideBlocks; - public static boolean mNEIisLoaded = NotEnoughItems.isModLoaded(); - - public GT_Block_Metal(String aName, Materials[] aMats, OrePrefixes aPrefix, IIconContainer[] aBlockIcons) { - super(GT_Item_Storage.class, aName, Material.iron); - mMats = aMats; - mPrefix = aPrefix; - mBlockIcons = aBlockIcons; - mHideBlocks = mNEIisLoaded; - - for (int i = 0; i < aMats.length; i++) { - if (aMats[i].mMetaItemSubID > 0 && aMats[i].mHasParentMod) { - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + "." + i + ".name", - "Block of " + (GT_LanguageManager.i18nPlaceholder ? "%material" : aMats[i].mDefaultLocalName)); - GT_OreDictUnificator.registerOre(aPrefix, aMats[i], new ItemStack(this, 1, i)); - } - } - if (aMats.length < 16 && mNEIisLoaded) { - for (int i = aMats.length; i < 16; i++) codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i)); - } - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - if ((aMeta >= 0) && (aMeta < 16) && aMeta < mMats.length) { - return mBlockIcons[aMeta].getIcon(); - } - return null; - } - - @Override - 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); - } - } - - @Override - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetaData) { - if (GregTech_API.isMachineBlock(this, aMetaData)) { - GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); - } - } - -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java deleted file mode 100644 index 015baa2319..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java +++ /dev/null @@ -1,154 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.enums.Textures.BlockIcons.BASALT_STONE; -import static gregtech.api.enums.Textures.BlockIcons.GRANITE_BLACK_STONE; -import static gregtech.api.enums.Textures.BlockIcons.GRANITE_RED_STONE; -import static gregtech.api.enums.Textures.BlockIcons.MARBLE_STONE; - -import java.util.Arrays; - -import net.minecraft.block.Block; -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; -import net.minecraftforge.common.util.FakePlayer; -import net.minecraftforge.common.util.ForgeDirection; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.ITexture; -import gregtech.api.render.TextureFactory; - -public class GT_Block_Ores extends GT_Block_Ores_Abstract { - - private static final String UNLOCALIZED_NAME = "gt.blockores"; - - public GT_Block_Ores() { - super(UNLOCALIZED_NAME, 7, false, Material.rock); - } - - @Override - public String getUnlocalizedName() { - return UNLOCALIZED_NAME; - } - - @Override - public OrePrefixes[] getProcessingPrefix() { // Must have 8 entries; an entry can be null to disable automatic - // recipes. - return new OrePrefixes[] { OrePrefixes.ore, OrePrefixes.oreNetherrack, OrePrefixes.oreEndstone, - OrePrefixes.oreBlackgranite, OrePrefixes.oreRedgranite, OrePrefixes.oreMarble, OrePrefixes.oreBasalt, - null }; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int meta) { - int index = ((meta / 1000) % 16); - return switch (index) { - case 1 -> Blocks.netherrack.getIcon(ordinalSide, 0); - case 2 -> Blocks.end_stone.getIcon(ordinalSide, 0); - case 3 -> GRANITE_BLACK_STONE.getIcon(); - case 4 -> GRANITE_RED_STONE.getIcon(); - case 5 -> MARBLE_STONE.getIcon(); - case 6 -> BASALT_STONE.getIcon(); - default -> Blocks.stone.getIcon(ordinalSide, 0); - }; - } - - /** - * @inheritDoc - */ - @Override - public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) { - return (side == ForgeDirection.UP && getDamageValue(world, x, y, z) / 1000 % 16 == 1); - } - - /** - * @inheritDoc - */ - @Override - public MapColor getMapColor(int meta) { - return meta == 1 ? MapColor.netherrackColor : MapColor.stoneColor; - } - - @Override - public int getBaseBlockHarvestLevel(int aMeta) { - return switch (aMeta) { - case 3, 4 -> 3; - default -> 0; - }; - } - - @Override - public Block getDroppedBlock() { - return GregTech_API.sBlockOres1; - } - - @Override - public Materials[] getDroppedDusts() { // Must have 8 entries; can be null. - return new Materials[] { Materials.Stone, Materials.Netherrack, Materials.Endstone, Materials.GraniteBlack, - Materials.GraniteRed, Materials.Marble, Materials.Basalt, Materials.Stone }; - } - - @Override - public boolean[] getEnabledMetas() { - return new boolean[] { true, true, true, GT_Mod.gregtechproxy.enableBlackGraniteOres, - GT_Mod.gregtechproxy.enableRedGraniteOres, GT_Mod.gregtechproxy.enableMarbleOres, - GT_Mod.gregtechproxy.enableBasaltOres, true }; - } - - @Override - public ITexture[] getTextureSet() { - final ITexture[] rTextures = new ITexture[16]; // Must have 16 entries. - Arrays.fill(rTextures, TextureFactory.of(Blocks.stone)); - rTextures[1] = TextureFactory.of(Blocks.netherrack); - rTextures[2] = TextureFactory.of(Blocks.end_stone); - rTextures[3] = TextureFactory.builder() - .addIcon(GRANITE_BLACK_STONE) - .stdOrient() - .build(); - rTextures[4] = TextureFactory.builder() - .addIcon(GRANITE_RED_STONE) - .stdOrient() - .build(); - rTextures[5] = TextureFactory.builder() - .addIcon(MARBLE_STONE) - .stdOrient() - .build(); - rTextures[6] = TextureFactory.builder() - .addIcon(BASALT_STONE) - .stdOrient() - .build(); - return rTextures; - } - - @Override - public void harvestBlock(World worldIn, EntityPlayer player, int x, int y, int z, int meta) { - - if (EnchantmentHelper.getSilkTouchModifier(player)) { - GT_TileEntity_Ores.shouldSilkTouch = true; - super.harvestBlock(worldIn, player, x, y, z, meta); - - if (GT_TileEntity_Ores.shouldSilkTouch) { - GT_TileEntity_Ores.shouldSilkTouch = false; - } - return; - } - - if (!(player instanceof FakePlayer)) { - GT_TileEntity_Ores.shouldFortune = true; - } - super.harvestBlock(worldIn, player, x, y, z, meta); - if (GT_TileEntity_Ores.shouldFortune) { - GT_TileEntity_Ores.shouldFortune = false; - } - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java deleted file mode 100644 index 8e68c5c39a..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java +++ /dev/null @@ -1,324 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.enums.Mods.NotEnoughItems; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.block.ITileEntityProvider; -import net.minecraft.block.material.Material; -import net.minecraft.client.particle.EffectRenderer; -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.entity.player.EntityPlayer; -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.MovingObjectPosition; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.ITexture; -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.api.util.GT_Utility; -import gregtech.common.render.GT_Renderer_Block; - -public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements ITileEntityProvider { - - private static final String DOT_NAME = ".name"; - private static final String DOT_TOOLTIP = ".tooltip"; - public static ThreadLocal mTemporaryTileEntity = new ThreadLocal<>(); - public static boolean FUCKING_LOCK = false; - public static boolean tHideOres; - public static Set aBlockedOres = new HashSet<>(); - - protected GT_Block_Ores_Abstract(String aUnlocalizedName, int aOreMetaCount, boolean aHideFirstMeta, - Material aMaterial) { - super(GT_Item_Ores.class, aUnlocalizedName, aMaterial); - this.isBlockContainer = true; - setStepSound(soundTypeStone); - setCreativeTab(GregTech_API.TAB_GREGTECH_ORES); - tHideOres = NotEnoughItems.isModLoaded() && GT_Mod.gregtechproxy.mHideUnusedOres; - if (aOreMetaCount > 8 || aOreMetaCount < 0) aOreMetaCount = 8; - - 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) { - for (int j = 0; j < aOreMetaCount; j++) { - if (!this.getEnabledMetas()[j]) continue; - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + "." + (i + (j * 1000)) + DOT_NAME, - GT_LanguageManager.i18nPlaceholder ? getLocalizedNameFormat(GregTech_API.sGeneratedMaterials[i]) - : getLocalizedName(GregTech_API.sGeneratedMaterials[i])); - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + "." + (i + (j * 1000)) + DOT_TOOLTIP, - GregTech_API.sGeneratedMaterials[i].getToolTip()); - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + "." + ((i + 16000) + (j * 1000)) + DOT_NAME, - "Small " + (GT_LanguageManager.i18nPlaceholder - ? getLocalizedNameFormat(GregTech_API.sGeneratedMaterials[i]) - : getLocalizedName(GregTech_API.sGeneratedMaterials[i]))); - GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + "." + ((i + 16000) + (j * 1000)) + DOT_TOOLTIP, - GregTech_API.sGeneratedMaterials[i].getToolTip()); - if ((GregTech_API.sGeneratedMaterials[i].mTypes & 0x8) != 0 - && !aBlockedOres.contains(GregTech_API.sGeneratedMaterials[i])) { - GT_OreDictUnificator.registerOre( - this.getProcessingPrefix()[j] != null - ? this.getProcessingPrefix()[j].get(GregTech_API.sGeneratedMaterials[i]) - : "", - new ItemStack(this, 1, i + (j * 1000))); - if (tHideOres) { - if (!(j == 0 && !aHideFirstMeta)) { - codechicken.nei.api.API.hideItem(new ItemStack(this, 1, i + (j * 1000))); - } - codechicken.nei.api.API.hideItem(new ItemStack(this, 1, (i + 16000) + (j * 1000))); - } - } - } - } - } - } - - public int getBaseBlockHarvestLevel(int aMeta) { - return 0; - } - - @Override - 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; - } - - @Override - 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 getLocalizedNameFormat(Materials aMaterial) { - return switch (aMaterial.mName) { - case "InfusedAir", "InfusedDull", "InfusedEarth", "InfusedEntropy", "InfusedFire", "InfusedOrder", "InfusedVis", "InfusedWater" -> "%material Infused Stone"; - case "Vermiculite", "Bentonite", "Kaolinite", "Talc", "BasalticMineralSand", "GraniticMineralSand", "GlauconiteSand", "CassiteriteSand", "GarnetSand", "QuartzSand", "Pitchblende", "FullersEarth" -> "%material"; - default -> "%material" + OrePrefixes.ore.mLocalizedMaterialPost; - }; - } - - public String getLocalizedName(Materials aMaterial) { - return aMaterial.getDefaultLocalizedNameForItem(getLocalizedNameFormat(aMaterial)); - } - - @Override - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, - float aOffsetX, float aOffsetY, float aOffsetZ) { - if (!aPlayer.isSneaking() || !aPlayer.capabilities.isCreativeMode) { - return false; - } - - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (!(tTileEntity instanceof GT_TileEntity_Ores)) { - return false; - } - - boolean tNatural = (((GT_TileEntity_Ores) tTileEntity).mNatural = !((GT_TileEntity_Ores) tTileEntity).mNatural); - GT_Utility.sendChatToPlayer(aPlayer, "Ore \"mNatural\" flag set to: " + tNatural); - return true; - } - - @Override - 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_); - } - - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { - return (!(entity instanceof EntityDragon)) && (super.canEntityDestroy(world, x, y, z, entity)); - } - - @Override - public String getHarvestTool(int aMeta) { - return aMeta < 8 ? "pickaxe" : "shovel"; - } - - @Override - public int getHarvestLevel(int aMeta) { - return aMeta == 5 || aMeta == 6 ? 2 : aMeta % 8; - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return 1.0F + getHarvestLevel(aWorld.getBlockMetadata(aX, aY, aZ)) * 1.0F; - } - - @Override - public float getExplosionResistance(Entity entity, 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; - } - - @Override - protected boolean canSilkHarvest() { - return false; - } - - @Override - public abstract String getUnlocalizedName(); - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(getUnlocalizedName() + DOT_NAME); - } - - @Override - public int getRenderType() { - if (GT_Renderer_Block.INSTANCE == null) { - return super.getRenderType(); - } - return GT_Renderer_Block.INSTANCE.mRenderID; - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return true; - } - - @Override - public boolean hasTileEntity(int aMeta) { - return true; - } - - @Override - public TileEntity createNewTileEntity(World aWorld, int aMeta) { - return createTileEntity(aWorld, aMeta); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { - return Blocks.stone.getIcon(0, 0); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return Blocks.stone.getIcon(0, 0); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) {} - - @Override - @SideOnly(Side.CLIENT) - public boolean addHitEffects(World worldObj, MovingObjectPosition target, EffectRenderer effectRenderer) { - GT_Renderer_Block - .addHitEffects(effectRenderer, this, worldObj, target.blockX, target.blockY, target.blockZ, target.sideHit); - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer effectRenderer) { - GT_Renderer_Block.addDestroyEffects(effectRenderer, this, world, x, y, z); - return true; - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof GT_TileEntity_Ores))) { - return ((GT_TileEntity_Ores) tTileEntity).getMetaData(); - } - return 0; - } - - @Override - public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { - 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, aBlock, aMetadata); - aWorld.removeTileEntity(aX, aY, aZ); - } - - public abstract OrePrefixes[] getProcessingPrefix(); // Must have 8 entries; an entry can be null to disable - // automatic recipes. - - public abstract boolean[] getEnabledMetas(); // Must have 8 entries. - - public abstract Block getDroppedBlock(); - - public abstract Materials[] getDroppedDusts(); // Must have 8 entries; can be null. - - @Override - 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(getDroppedBlock(), aFortune); - } - return mTemporaryTileEntity.get() == null ? new ArrayList<>() - : mTemporaryTileEntity.get() - .getDrops(getDroppedBlock(), aFortune); - } - - @Override - public TileEntity createTileEntity(World aWorld, int aMeta) { - return new GT_TileEntity_Ores(); - } - - public abstract ITexture[] getTextureSet(); // Must have 16 entries. - - @Override - @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) && !aBlockedOres.contains(tMaterial)) { - for (int meta = i; meta < 23000 + i; meta += 1000) { - if (!(new ItemStack(aItem, 1, meta).getDisplayName() - .contains(DOT_NAME))) aList.add(new ItemStack(aItem, 1, meta)); - } - } - } - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java deleted file mode 100644 index a78fe5b70d..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ /dev/null @@ -1,409 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.objects.XSTR.XSTR_INSTANCE; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.boss.EntityWither; -import net.minecraft.entity.item.EntityTNTPrimed; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.StatCollector; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.SoundResource; -import gregtech.api.enums.Textures; -import gregtech.api.items.GT_Generic_Block; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.WorldSpawnedEventBuilder; - -public class GT_Block_Reinforced extends GT_Generic_Block { - - public GT_Block_Reinforced(String aName) { - super(GT_Item_Storage.class, aName, new GT_Material_Reinforced()); - for (int i = 0; i < 16; i++) { - Textures.BlockIcons.casingTexturePages[1][i + 80] = TextureFactory.of(this, i); - } - setStepSound(soundTypeStone); - setCreativeTab(GregTech_API.TAB_GREGTECH); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Bronzeplate Reinforced Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Iridium Reinforced Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Plascrete Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Tungstensteel Reinforced Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Brittle Charcoal"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Powderbarrel"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Solid Super Fuel"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Magic Solid Super Fuel"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Steel Reinforced Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Titanium Reinforced Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Naquadah Reinforced Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Neutronium Reinforced Block"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Raw Deep Dark Portal Block"); - ItemList.Block_BronzePlate.set( - new ItemStack( - this.setHardness(60.0f) - .setResistance(150.0f), - 1, - 0)); - ItemList.Block_IridiumTungstensteel.set( - new ItemStack( - this.setHardness(400.0f) - .setResistance(600.0f), - 1, - 1)); - ItemList.Block_Plascrete.set( - new ItemStack( - this.setHardness(5.0f) - .setResistance(6.0f), - 1, - 2)); - ItemList.Block_TungstenSteelReinforced.set( - new ItemStack( - this.setHardness(250.0f) - .setResistance(400.0f), - 1, - 3)); - ItemList.Block_BrittleCharcoal.set( - new ItemStack( - this.setHardness(0.5f) - .setResistance(8.0f), - 1, - 4)); - ItemList.Block_Powderbarrel.set( - new ItemStack( - this.setHardness(2.5f) - .setResistance(2.0f), - 1, - 5)); - ItemList.Block_SSFUEL.set( - new ItemStack( - this.setHardness(2.5f) - .setResistance(2.0f), - 1, - 6)); - ItemList.Block_MSSFUEL.set( - new ItemStack( - this.setHardness(2.5f) - .setResistance(2.0f), - 1, - 7)); - ItemList.Block_SteelPlate.set( - new ItemStack( - this.setHardness(150.0f) - .setResistance(200.0f), - 1, - 8)); - ItemList.Block_TitaniumPlate.set( - new ItemStack( - this.setHardness(200.0f) - .setResistance(300.0f), - 1, - 9)); - ItemList.Block_NaquadahPlate.set( - new ItemStack( - this.setHardness(500.0f) - .setResistance(1000.0f), - 1, - 10)); - ItemList.Block_NeutroniumPlate.set( - new ItemStack( - this.setHardness(750.0f) - .setResistance(2500.0f), - 1, - 11)); - ItemList.Block_BedrockiumCompressed.set( - new ItemStack( - this.setHardness(1500.0f) - .setResistance(5000.0f), - 1, - 12)); - GT_ModHandler.addShapelessCraftingRecipe( - new ItemStack(Items.coal, 1, 1), - new Object[] { ItemList.Block_BrittleCharcoal.get(1) }); - GT_ModHandler.addCraftingRecipe( - ItemList.Block_Powderbarrel.get(1L), - GT_ModHandler.RecipeBits.REVERSIBLE, - new Object[] { "WSW", "GGG", "WGW", 'W', OrePrefixes.plate.get(Materials.Wood), 'G', - new ItemStack(Items.gunpowder, 1), 'S', new ItemStack(Items.string, 1) }); - } - - @Override - public String getHarvestTool(int aMeta) { - if (aMeta == 5 || aMeta == 4 || aMeta == 6 || aMeta == 7) return "axe"; - if (aMeta == 2) return "wrench"; - return "pickaxe"; - } - - @Override - public int getHarvestLevel(int aMeta) { - if (aMeta == 4 || aMeta == 5 || aMeta == 6 || aMeta == 7) return 1; - if (aMeta == 2) return 2; - if (aMeta == 9 || aMeta == 3 || aMeta == 1) return 5; - if (aMeta == 10 || aMeta == 11) return 7; - return 4; - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - case 0 -> { - return Textures.BlockIcons.BLOCK_BRONZEPREIN.getIcon(); - } - case 1 -> { - return Textures.BlockIcons.BLOCK_IRREIN.getIcon(); - } - case 2 -> { - return Textures.BlockIcons.BLOCK_PLASCRETE.getIcon(); - } - case 3 -> { - return Textures.BlockIcons.BLOCK_TSREIN.getIcon(); - } - case 4, 6, 7 -> { - return Blocks.coal_block.getIcon(0, 0); - } - case 5 -> { - return Textures.BlockIcons.COVER_WOOD_PLATE.getIcon(); - } - case 8 -> { - return Textures.BlockIcons.BLOCK_STEELPREIN.getIcon(); - } - case 9 -> { - return Textures.BlockIcons.BLOCK_TITANIUMPREIN.getIcon(); - } - case 10 -> { - return Textures.BlockIcons.BLOCK_NAQUADAHPREIN.getIcon(); - } - case 11 -> { - return Textures.BlockIcons.BLOCK_NEUTRONIUMPREIN.getIcon(); - } - case 12 -> { - return Textures.BlockIcons.BLOCK_DEEP_DARK_RAW.getIcon(); - } - } - } - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - if (aWorld == null) { - return 0.0F; - } - if (aWorld.isAirBlock(aX, aY, aZ)) { - return 0.0F; - } - int tMeta = aWorld.getBlockMetadata(aX, aY, aZ); - if (tMeta == 0) { - return 60.0F; - } - if (tMeta == 1) { - return 400.0F; - } - if (tMeta == 2) { - return 5.0F; - } - if (tMeta == 3) { - return 250.0F; - } - if (tMeta == 4 || tMeta == 5 || tMeta == 6 || tMeta == 7) { - return 0.5F; - } - if (tMeta == 8) { - return 150.0F; - } - if (tMeta == 9) { - return 200.0F; - } - if (tMeta == 10) { - return 500.0F; - } - if (tMeta == 11) { - return 750.0F; - } - return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); - } - - @Override - public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX, - double explosionY, double explosionZ) { - if (world == null) { - return 0.0F; - } - int tMeta = world.getBlockMetadata(x, y, z); - if (tMeta == 0) { - return 150.0F; - } - if (tMeta == 1) { - return 600.0F; - } - if (tMeta == 2) { - return 6.0F; - } - if (tMeta == 3) { - return 400.0F; - } - if (tMeta == 4 || tMeta == 6 || tMeta == 7) { - return 8.0F; - } - if (tMeta == 5) { - return 1.0F; - } - if (tMeta == 8) { - return 200.0F; - } - if (tMeta == 9) { - return 300.0F; - } - if (tMeta == 10) { - return 1000.0F; - } - if (tMeta == 11) { - return 2500.0F; - } - return super.getExplosionResistance(entity, world, x, y, z, explosionX, explosionY, explosionZ); - } - - @Override - public String getUnlocalizedName() { - return this.mUnlocalizedName; - } - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return true; - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { - return false; - } - - @Override - public int damageDropped(int metadata) { - return metadata; - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - return aWorld.getBlockMetadata(aX, aY, aZ); - } - - @Override - public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int aMetadata, float chance, - int aFortune) { - if (aMetadata == 4) { - this.dropBlockAsItem(aWorld, aX, aY, aZ, new ItemStack(Items.coal, XSTR_INSTANCE.nextInt(2) + 1, 1)); - } else { - super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, aMetadata, chance, aFortune); - } - } - - @SuppressWarnings("deprecation") - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z) { - if (!world.isRemote && world.getBlockMetadata(x, y, z) == 5) { - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(world, x + 0.5F, y + 0.5F, z + 0.5F, player); - world.spawnEntityInWorld(entitytntprimed); - new WorldSpawnedEventBuilder.SoundAtEntityEventBuilder().setPitch(1f) - .setVolume(1f) - .setIdentifier(SoundResource.GAME_TNT_PRIMED) - .setEntity(entitytntprimed) - .setWorld(world) - .run(); - world.setBlockToAir(x, y, z); - return false; - } - return super.removedByPlayer(world, player, x, y, z); - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) { - super.onBlockAdded(world, x, y, z); - if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 5) { - removedByPlayer(world, null, x, y, z); - } - } - - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block neighbor) { - if (world.isBlockIndirectlyGettingPowered(x, y, z) && world.getBlockMetadata(x, y, z) == 5) { - removedByPlayer(world, null, x, y, z); - } - } - - @Override - public void onBlockExploded(World world, int x, int y, int z, Explosion explosion) { - if (!world.isRemote && world.getBlockMetadata(x, y, z) == 5) { - EntityTNTPrimed entitytntprimed = new EntityTNTPrimed( - world, - x + 0.5F, - y + 0.5F, - z + 0.5F, - explosion.getExplosivePlacedBy()); - entitytntprimed.fuse = (world.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8); - world.spawnEntityInWorld(entitytntprimed); - } - super.onBlockExploded(world, x, y, z, explosion); - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int ordinalSide, - float xOffset, float yOffset, float zOffset) { - if ((player.getCurrentEquippedItem() != null) && (player.getCurrentEquippedItem() - .getItem() == Items.flint_and_steel) && world.getBlockMetadata(x, y, z) == 5) { - removedByPlayer(world, player, x, y, z); - - return true; - } - return super.onBlockActivated(world, x, y, z, player, ordinalSide, xOffset, yOffset, zOffset); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) {} - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { - for (int i = 0; i < 16; i++) { - ItemStack aStack = new ItemStack(aItem, 1, i); - if (!aStack.getDisplayName() - .contains(".name")) aList.add(aStack); - } - } - - @Override - public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { - return !(entity instanceof EntityWither); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Stones.java b/src/main/java/gregtech/common/blocks/GT_Block_Stones.java deleted file mode 100644 index 4ca52aee56..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones.java +++ /dev/null @@ -1,62 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.World; - -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_OreDictUnificator; - -public class GT_Block_Stones extends GT_Block_Stones_Abstract { - - public GT_Block_Stones() { - super(GT_Item_Granites.class, "gt.blockstones"); - setResistance(60.0F); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Marble"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Marble Cobblestone"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Mossy Marble Cobblestone"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Marble Bricks"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Cracked Marble Bricks"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Mossy Marble Bricks"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Chiseled Marble"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Smooth Marble"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Basalt"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Basalt Cobblestone"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Mossy Basalt Cobblestone"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Basalt Bricks"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Cracked Basalt Bricks"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "Mossy Basalt Bricks"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "Chiseled Basalt"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Smooth Basalt"); - for (int i = 0; i < 16; i++) { - GT_OreDictUnificator - .registerOre(OrePrefixes.stone, i < 8 ? Materials.Marble : Materials.Basalt, new ItemStack(this, 1, i)); - GT_OreDictUnificator - .registerOre(OrePrefixes.block, i < 8 ? Materials.Marble : Materials.Basalt, new ItemStack(this, 1, i)); - GT_OreDictUnificator.registerOre( - (i < 8 ? Materials.Marble.mName.toLowerCase() : Materials.Basalt.mName.toLowerCase()), - new ItemStack(this, 1, i)); - } - } - - @Override - public int getHarvestLevel(int aMeta) { - return 2; - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - if ((aMeta >= 0) && (aMeta < 16)) { - return gregtech.api.enums.Textures.BlockIcons.STONES[aMeta].getIcon(); - } - return gregtech.api.enums.Textures.BlockIcons.STONES[0].getIcon(); - } -} 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 deleted file mode 100644 index 4a5bb9456e..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java +++ /dev/null @@ -1,250 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.recipe.RecipeMaps.assemblerRecipes; -import static gregtech.api.recipe.RecipeMaps.hammerRecipes; -import static gregtech.api.recipe.RecipeMaps.laserEngraverRecipes; -import static gregtech.api.util.GT_RecipeBuilder.SECONDS; -import static gregtech.api.util.GT_RecipeBuilder.TICKS; - -import java.util.List; - -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import 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.Materials; -import gregtech.api.enums.OreDictNames; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.IOreRecipeRegistrator; -import gregtech.api.items.GT_Generic_Block; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; - -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); - - this.registerSmeltingRecipes(); - this.registerAssemblerRecipes(); - this.registerCraftingRecipes(); - this.registerForgeHammerRecipes(); - - } - - private void registerSmeltingRecipes() { - 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)); - - } - - private void registerAssemblerRecipes() { - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 0), GT_Utility.getIntegratedCircuit(4)) - .itemOutputs(new ItemStack(this, 1, 3)) - .duration(2 * SECONDS + 10 * TICKS) - .eut(4) - .addTo(assemblerRecipes); - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 8), GT_Utility.getIntegratedCircuit(4)) - .itemOutputs(new ItemStack(this, 1, 11)) - .duration(2 * SECONDS + 10 * TICKS) - .eut(4) - .addTo(assemblerRecipes); - } - - private void registerCraftingRecipes() { - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 1, 6), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "f", "X", 'X', new ItemStack(this, 1, 7) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 1, 14), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "f", "X", 'X', new ItemStack(this, 1, 15) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 1, 4), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "h", "X", 'X', new ItemStack(this, 1, 3) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 1, 12), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "h", "X", 'X', new ItemStack(this, 1, 11) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 1, 1), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "h", "X", 'X', new ItemStack(this, 1, 0) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 1, 9), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "h", "X", 'X', new ItemStack(this, 1, 8) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 4, 3), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 0) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 4, 11), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 8) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 4, 3), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 7) }); - GT_ModHandler.addCraftingRecipe( - new ItemStack(this, 4, 11), - GT_ModHandler.RecipeBits.NOT_REMOVABLE, - new Object[] { "XX", "XX", 'X', new ItemStack(this, 4, 15) }); - } - - private void registerForgeHammerRecipes() { - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 3)) - .itemOutputs(new ItemStack(this, 1, 4)) - .duration(16 * TICKS) - .eut(10) - .addTo(hammerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 11)) - .itemOutputs(new ItemStack(this, 1, 12)) - .duration(16 * TICKS) - .eut(10) - .addTo(hammerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 0)) - .itemOutputs(new ItemStack(this, 1, 1)) - .duration(16 * TICKS) - .eut(10) - .addTo(hammerRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 8)) - .itemOutputs(new ItemStack(this, 1, 9)) - .duration(16 * TICKS) - .eut(10) - .addTo(hammerRecipes); - } - - @Override - public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, - ItemStack aStack) { - if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { - - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 7), GT_Utility.copyAmount(0, aStack)) - .itemOutputs(new ItemStack(this, 1, 6)) - .duration(2 * SECONDS + 10 * TICKS) - .eut(16) - .addTo(laserEngraverRecipes); - - GT_Values.RA.stdBuilder() - .itemInputs(new ItemStack(this, 1, 15), GT_Utility.copyAmount(0, aStack)) - .itemOutputs(new ItemStack(this, 1, 14)) - .duration(2 * SECONDS + 10 * TICKS) - .eut(16) - .addTo(laserEngraverRecipes); - - } - } - - @Override - public String getHarvestTool(int aMeta) { - return "pickaxe"; - } - - @Override - public int getHarvestLevel(int aMeta) { - return 1; - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return this.blockHardness = Blocks.stone.getBlockHardness(aWorld, aX, aY, aZ) * 3.0F; - } - - @Override - public String getUnlocalizedName() { - return this.mUnlocalizedName; - } - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return true; - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - if ((aMeta >= 0) && (aMeta < 16)) { - return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); - } - return null; - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { - return world.getBlockMetadata(x, y, z) % 8 < 3; - } - - @Override - public int damageDropped(int metadata) { - return metadata % 8 == 0 ? metadata + 1 : metadata; - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - return aWorld.getBlockMetadata(aX, aY, aZ); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) {} - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { - for (int i = 0; i < 16; i++) { - aList.add(new ItemStack(aItem, 1, i)); - } - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java b/src/main/java/gregtech/common/blocks/GT_Block_Storage.java deleted file mode 100644 index ada3f01cde..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java +++ /dev/null @@ -1,103 +0,0 @@ -package gregtech.common.blocks; - -import java.util.List; - -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.init.Blocks; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.StatCollector; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.items.GT_Generic_Block; - -public class GT_Block_Storage extends GT_Generic_Block { - - protected GT_Block_Storage(Class aItemClass, String aName, Material aMaterial) { - super(aItemClass, aName, aMaterial); - setStepSound(soundTypeMetal); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - @Override - public String getHarvestTool(int aMeta) { - return "pickaxe"; - } - - @Override - public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { - return true; - } - - @Override - public int getHarvestLevel(int aMeta) { - return 1; - } - - @Override - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); - } - - @Override - public float getExplosionResistance(Entity aTNT) { - return Blocks.iron_block.getExplosionResistance(aTNT); - } - - @Override - public String getUnlocalizedName() { - return this.mUnlocalizedName; - } - - @Override - public String getLocalizedName() { - return StatCollector.translateToLocal(this.mUnlocalizedName + ".name"); - } - - @Override - public boolean canBeReplacedByLeaves(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return true; - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { - return true; - } - - @Override - public int damageDropped(int metadata) { - return metadata; - } - - @Override - public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - return aWorld.getBlockMetadata(aX, aY, aZ); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister aIconRegister) {} - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item aItem, CreativeTabs aCreativeTab, List aList) { - for (int i = 0; i < 16; i++) { - if (!(new ItemStack(aItem, 1, i).getDisplayName() - .contains(".name"))) aList.add(new ItemStack(aItem, 1, i)); - } - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_TintedIndustrialGlass.java b/src/main/java/gregtech/common/blocks/GT_Block_TintedIndustrialGlass.java deleted file mode 100644 index 93c6ebb298..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Block_TintedIndustrialGlass.java +++ /dev/null @@ -1,98 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.item.ItemStack; -import net.minecraft.util.Facing; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.oredict.OreDictionary; - -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.util.GT_LanguageManager; - -public class GT_Block_TintedIndustrialGlass extends GT_Block_Casings_Abstract { - - public GT_Block_TintedIndustrialGlass() { - super(GT_Item_Glass1.class, "gt.blocktintedglass", Material.glass, 4); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Tinted Industrial Glass (White)"); - GT_LanguageManager - .addStringLocalization(getUnlocalizedName() + ".1.name", "Tinted Industrial Glass (Light Gray)"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Tinted Industrial Glass (Gray)"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Tinted Industrial Glass (Black)"); - ItemList.GlassTintedIndustrialWhite.set(new ItemStack(this, 1, 0)); - ItemList.GlassTintedIndustrialLightGray.set(new ItemStack(this, 1, 1)); - ItemList.GlassTintedIndustrialGray.set(new ItemStack(this, 1, 2)); - ItemList.GlassTintedIndustrialBlack.set(new ItemStack(this, 1, 3)); - - // Register tinted industrial glass as EV-Tier glass - OreDictionary.registerOre("blockGlassEV", this); - - this.opaque = false; - } - - @Override - public int getTextureIndex(int aMeta) { - // Page 16, 32-47 - return (16 << 7) | (aMeta + 32); - } - - @Override - public boolean isNormalCube(IBlockAccess aWorld, int aX, int aY, int aZ) { - return false; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public int getRenderBlockPass() { - return 1; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int ordinalSide, int aMeta) { - return switch (aMeta) { - case 0 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_WHITE.getIcon(); - case 1 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_LIGHT_GRAY.getIcon(); - case 2 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_GRAY.getIcon(); - case 3 -> Textures.BlockIcons.GLASS_TINTED_INDUSTRIAL_BLACK.getIcon(); - default -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); - }; - } - - /** - * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given - * coordinates. Args: blockAccess, x, y, z, side - */ - @SideOnly(Side.CLIENT) - @Override - public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { - Block block = worldIn.getBlock(x, y, z); - - if (worldIn.getBlockMetadata(x, y, z) != worldIn.getBlockMetadata( - x - Facing.offsetsXForSide[side], - y - Facing.offsetsYForSide[side], - z - Facing.offsetsZForSide[side])) { - return true; - } - - if (block == this) { - return false; - } - - return super.shouldSideBeRendered(worldIn, x, y, z, side); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java b/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java deleted file mode 100644 index 3c4250540c..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java +++ /dev/null @@ -1,131 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; - -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Textures; -import gregtech.api.util.GT_LanguageManager; - -public class GT_Cyclotron_Coils extends GT_Block_Casings_Abstract { - - public GT_Cyclotron_Coils() { - super(GT_Cyclotron_Item_Casings.class, "gt.blockcasings.cyclotron_coils", GT_Material_Casings.INSTANCE, 16); - - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "MV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "HV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "EV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "IV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "LuV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "ZPM Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "UV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "UHV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "UEV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "UIV Solenoid Superconductor Coil"); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "UMV Solenoid Superconductor Coil"); - - ItemList.Superconducting_Magnet_Solenoid_MV.set(new ItemStack(this, 1, 0)); - ItemList.Superconducting_Magnet_Solenoid_HV.set(new ItemStack(this, 1, 1)); - ItemList.Superconducting_Magnet_Solenoid_EV.set(new ItemStack(this, 1, 2)); - ItemList.Superconducting_Magnet_Solenoid_IV.set(new ItemStack(this, 1, 3)); - ItemList.Superconducting_Magnet_Solenoid_LuV.set(new ItemStack(this, 1, 4)); - ItemList.Superconducting_Magnet_Solenoid_ZPM.set(new ItemStack(this, 1, 5)); - ItemList.Superconducting_Magnet_Solenoid_UV.set(new ItemStack(this, 1, 6)); - ItemList.Superconducting_Magnet_Solenoid_UHV.set(new ItemStack(this, 1, 7)); - ItemList.Superconducting_Magnet_Solenoid_UEV.set(new ItemStack(this, 1, 8)); - ItemList.Superconducting_Magnet_Solenoid_UIV.set(new ItemStack(this, 1, 9)); - ItemList.Superconducting_Magnet_Solenoid_UMV.set(new ItemStack(this, 1, 10)); - } - - @Override - public int getTextureIndex(int aMeta) { - return (2 << 7) | (aMeta); - } - - @Override - public IIcon getIcon(int ordinalSide, int aMeta) { - if ((aMeta >= 0) && (aMeta < 16)) { - switch (aMeta) { - case 0 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.MV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.MV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 1 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.HV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.HV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 2 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.EV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.EV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 3 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.IV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.IV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 4 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.LuV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.LuV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 5 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.ZPM_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.ZPM_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 6 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.UV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.UV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 7 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.UHV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.UHV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 8 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.UEV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.UEV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 9 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.UIV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.UIV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - case 10 -> { - if (ordinalSide == 0 || ordinalSide == 1) { - return Textures.BlockIcons.UMV_TOP_CYCLOTRON_SOLENOID.getIcon(); - } - return Textures.BlockIcons.UMV_SIDE_CYCLOTRON_SOLENOID.getIcon(); - } - } - } - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - } - - public int getVoltageTier(int meta) { - return meta + 2; - } - - @Override - 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_Cyclotron_Item_Casings.java b/src/main/java/gregtech/common/blocks/GT_Cyclotron_Item_Casings.java deleted file mode 100644 index f1ca45a805..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Cyclotron_Item_Casings.java +++ /dev/null @@ -1,10 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -public class GT_Cyclotron_Item_Casings extends GT_Item_Casings_Abstract { - - public GT_Cyclotron_Item_Casings(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Block_Laser.java b/src/main/java/gregtech/common/blocks/GT_Item_Block_Laser.java deleted file mode 100644 index db4f6ddddc..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Block_Laser.java +++ /dev/null @@ -1,24 +0,0 @@ -package gregtech.common.blocks; - -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 gregtech.api.util.GT_LanguageManager; - -public class GT_Item_Block_Laser extends ItemBlock { - - public GT_Item_Block_Laser(Block block) { - super(block); - } - - @Override - public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean f3_h) { - tooltip.add( - GT_LanguageManager - .addStringLocalization("gt.laserplatingtooltip", "Engineered to withstand extreme temperatures")); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java deleted file mode 100644 index 1a86a2e534..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings1 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings1(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings10.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings10.java deleted file mode 100644 index 519549ce6b..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings10.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings10 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings10(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings11.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings11.java deleted file mode 100644 index 2941022b9c..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings11.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings11 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings11(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java deleted file mode 100644 index f98c169c7f..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java +++ /dev/null @@ -1,26 +0,0 @@ -package gregtech.common.blocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings2 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings2(Block block) { - super(block); - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - super.addInformation(aStack, aPlayer, aList, aF3_H); - if (getDamage(aStack) == 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 deleted file mode 100644 index 861774d96f..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings3 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings3(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java deleted file mode 100644 index e2badca2cb..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings4 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings4(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java deleted file mode 100644 index 3b3ab68cb1..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java +++ /dev/null @@ -1,36 +0,0 @@ -package gregtech.common.blocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.enums.HeatingCoilLevel; -import gregtech.api.util.GT_LanguageManager; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings5 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings5(Block block) { - super(block); - } - - protected static final String mCoilHeatTooltip = GT_LanguageManager - .addStringLocalization("gt.coilheattooltip", "Base Heating Capacity = "); - protected static final String mCoilUnitTooltip = GT_LanguageManager - .addStringLocalization("gt.coilunittooltip", " Kelvin"); - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - super.addInformation(aStack, aPlayer, aList, aF3_H); - HeatingCoilLevel coilLevel = GT_Block_Casings5.getCoilHeatFromDamage(aStack.getItemDamage()); - aList.add(mCoilHeatTooltip + coilLevel.getHeat() + mCoilUnitTooltip); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java deleted file mode 100644 index af533acfa8..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings6 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings6(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java deleted file mode 100644 index e3f3bbdf97..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java +++ /dev/null @@ -1,14 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings8 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings8(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings9.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings9.java deleted file mode 100644 index e9b39ee2cd..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings9.java +++ /dev/null @@ -1,28 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -/** - * The casings are split into separate files because they are registered as regular blocks, and a regular block can have - * 16 subtypes at most. - */ -public class GT_Item_Casings9 extends GT_Item_Casings_Abstract { - - public GT_Item_Casings9(Block block) { - super(block); - } - - /* - * @Override - * public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - * // Add tooltip info if it was given - * String localizedTooltip = GT_LanguageManager.getTranslation(aStack.getUnlocalizedName() + ".tooltip"); - * // getTranslation returns the key if no translation was found, but this just means - * // no tooltip was set. - * if (localizedTooltip.startsWith("gt.")) { - * aList.add(localizedTooltip); - * } - * super.addInformation(aStack, aPlayer, aList, aF3_H); - * } - */ -} 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 deleted file mode 100644 index 46b0aba237..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java +++ /dev/null @@ -1,63 +0,0 @@ -package gregtech.common.blocks; - -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 gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; - -public abstract class GT_Item_Casings_Abstract extends ItemBlock { - - 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 mCoil04Tooltip = GT_LanguageManager - .addStringLocalization("gt.coil04tooltip", "Base Heating Capacity = 4500 Kelvin"); - protected final String mCoil05Tooltip = GT_LanguageManager - .addStringLocalization("gt.coil05tooltip", "Base Heating Capacity = 5400 Kelvin"); - protected final String mCoil06Tooltip = GT_LanguageManager - .addStringLocalization("gt.coil06tooltip", "Base Heating Capacity = 7200 Kelvin"); - protected final String mCoil07Tooltip = GT_LanguageManager - .addStringLocalization("gt.coil07tooltip", "Base Heating Capacity = 9001 Kelvin"); - protected final String mCoil08Tooltip = GT_LanguageManager - .addStringLocalization("gt.coil08tooltip", "Base Heating Capacity = 9900 Kelvin"); - protected final String mCoil09Tooltip = GT_LanguageManager - .addStringLocalization("gt.coil09tooltip", "Base Heating Capacity = 10800 Kelvin"); - protected final String mBlastProofTooltip = GT_LanguageManager - .addStringLocalization("gt.blastprooftooltip", "This Block is Blast Proof"); - - public GT_Item_Casings_Abstract(Block block) { - super(block); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - @Override - public int getMetadata(int aMeta) { - return aMeta; - } - - @Override - public String getUnlocalizedName(ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); - } - - @Override - 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 deleted file mode 100644 index 44c094aa41..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java +++ /dev/null @@ -1,25 +0,0 @@ -package gregtech.common.blocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import gregtech.api.util.GT_LanguageManager; - -public class GT_Item_Concretes extends GT_Item_Stones_Abstract { - - private final String mRunFasterToolTip = GT_LanguageManager - .addStringLocalization("gt.runfastertooltip", "You can walk faster on this Block"); - - public GT_Item_Concretes(Block block) { - super(block); - } - - @Override - 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_Frames.java b/src/main/java/gregtech/common/blocks/GT_Item_Frames.java deleted file mode 100644 index 002e19f5a6..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Frames.java +++ /dev/null @@ -1,60 +0,0 @@ -package gregtech.common.blocks; - -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 gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; -import gregtech.api.util.GT_LanguageManager; - -public class GT_Item_Frames extends ItemBlock { - - public GT_Item_Frames(Block block) { - super(block); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - private Block block() { - return this.field_150939_a; - } - - @Override - public String getUnlocalizedName(ItemStack aStack) { - return this.block() - .getUnlocalizedName() + "." - + getDamage(aStack); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String aName = super.getItemStackDisplayName(aStack); - if (this.block() instanceof GT_Block_FrameBox) { - aName = Materials.getLocalizedNameForItem(aName, aStack.getItemDamage()); - } - return aName; - } - - @Override - public int getColorFromItemStack(ItemStack aStack, int aPass) { - int meta = aStack.getItemDamage(); - Materials material = GT_Block_FrameBox.getMaterial(meta); - return (material.mRGBa[0] << 16) | (material.mRGBa[1] << 8) | material.mRGBa[2]; - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - aList.add(GT_LanguageManager.getTranslation("gt.blockframes." + aStack.getItemDamage() + ".tooltip")); - aList.add(GT_LanguageManager.getTranslation("gt.blockmachines.gt_frame.desc.format")); - } - - @Override - public int getMetadata(int meta) { - return meta; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Glass1.java b/src/main/java/gregtech/common/blocks/GT_Item_Glass1.java deleted file mode 100644 index e8d0b6c236..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Glass1.java +++ /dev/null @@ -1,36 +0,0 @@ -package gregtech.common.blocks; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -import gregtech.api.util.GT_LanguageManager; - -/** - * The glass types are split into separate files because they are registered as regular blocks, and a regular block can - * have - * 16 subtypes at most. - */ -public class GT_Item_Glass1 extends GT_Item_Casings_Abstract { - - protected final String chemicalGlassTooltip = GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + ".0.tooltip", - "Able to resist the most extreme chemical conditions."); - protected final String hawkingGlassTooltip = GT_LanguageManager.addStringLocalization( - getUnlocalizedName() + ".4.tooltip", - "Controls the outward flow of Hawking Radiation to stabilize a black hole."); - - public GT_Item_Glass1(Block block) { - super(block); - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - switch (getDamage(aStack)) { - case 0 -> aList.add(chemicalGlassTooltip); - case 4 -> aList.add(hawkingGlassTooltip); - } - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Granites.java b/src/main/java/gregtech/common/blocks/GT_Item_Granites.java deleted file mode 100644 index 6e3eb8f12c..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Granites.java +++ /dev/null @@ -1,10 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -public class GT_Item_Granites extends GT_Item_Stones_Abstract { - - public GT_Item_Granites(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.java b/src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.java deleted file mode 100644 index 52d0db5165..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.java +++ /dev/null @@ -1,43 +0,0 @@ -package gregtech.common.blocks; - -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 gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; - -public class GT_Item_LongDistancePipe extends ItemBlock { - - 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!"); - - public GT_Item_LongDistancePipe(Block block) { - super(block); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - @Override - public int getMetadata(int aMeta) { - return aMeta; - } - - @Override - public String getUnlocalizedName(ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); - } - - @Override - 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_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java deleted file mode 100644 index 059a3fda94..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ /dev/null @@ -1,430 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.GT_Mod.GT_FML_LOGGER; - -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.potion.Potion; -import net.minecraft.potion.PotionEffect; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.Dyes; -import gregtech.api.enums.Materials; -import gregtech.api.interfaces.ISecondaryDescribable; -import gregtech.api.interfaces.metatileentity.IConnectable; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.CoverableTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Item; -import gregtech.api.util.GT_ItsNotMyFaultException; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; -import gregtech.common.tileentities.storage.GT_MetaTileEntity_DigitalTankBase; -import gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperChest; -import gregtech.common.tileentities.storage.GT_MetaTileEntity_SuperTank; - -public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { - - public GT_Item_Machines(Block block) { - super(block); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH); - } - - public static IMetaTileEntity getMetaTileEntity(ItemStack aStack) { - if (GT_Utility.isStackInvalid(aStack)) return null; - if (!(aStack.getItem() instanceof GT_Item_Machines)) return null; - if (aStack.getItemDamage() < 0 || aStack.getItemDamage() > GregTech_API.METATILEENTITIES.length) return null; - return GregTech_API.METATILEENTITIES[aStack.getItemDamage()]; - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - try { - final int tDamage = getDamage(aStack); - if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { - return; - } - - if (GregTech_API.METATILEENTITIES[tDamage] != null) { - final IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); - if (!GregTech_API.sPostloadFinished - && tTileEntity.getMetaTileEntity() instanceof ISecondaryDescribable) { - final String[] tSecondaryDescription = ((ISecondaryDescribable) tTileEntity.getMetaTileEntity()) - .getSecondaryDescription(); - addDescription(null, tSecondaryDescription, tDamage, "_Secondary"); - } - { - final IMetaTileEntity tMetaTileEntity = tTileEntity.getMetaTileEntity(); - final String tSuffix = (tMetaTileEntity instanceof ISecondaryDescribable - && ((ISecondaryDescribable) tMetaTileEntity).isDisplaySecondaryDescription()) ? "_Secondary" - : ""; - addDescription(aList, tTileEntity.getDescription(), tDamage, tSuffix); - tMetaTileEntity.addAdditionalTooltipInformation(aStack, aList); - } - if (tTileEntity.getEUCapacity() > 0L) { - if (tTileEntity.getInputVoltage() > 0L) { - final byte inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); - aList.add( - GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ") - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(tTileEntity.getInputVoltage()) - + " (" - + GT_Utility.getColoredTierNameFromTier(inputTier) - + EnumChatFormatting.GREEN - + ")" - + EnumChatFormatting.GRAY); - } - if (tTileEntity.getOutputVoltage() > 0L) { - final byte outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); - aList.add( - GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ") - + EnumChatFormatting.GREEN - + GT_Utility.formatNumbers(tTileEntity.getOutputVoltage()) - + " (" - + GT_Utility.getColoredTierNameFromTier(outputTier) - + EnumChatFormatting.GREEN - + ")" - + EnumChatFormatting.GRAY); - } - if (tTileEntity.getOutputAmperage() > 1L) { - aList.add( - GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ") - + EnumChatFormatting.YELLOW - + GT_Utility.formatNumbers(tTileEntity.getOutputAmperage()) - + EnumChatFormatting.GRAY); - } - aList.add( - GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ") - + EnumChatFormatting.BLUE - + GT_Utility.formatNumbers(tTileEntity.getEUCapacity()) - + EnumChatFormatting.GRAY - + " EU"); - } - } - final NBTTagCompound aNBT = aStack.getTagCompound(); - if (aNBT != null) { - if (aNBT.getBoolean("mMuffler")) { - aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade")); - } - if (aNBT.getBoolean("mSteamConverter")) { - aList.add( - GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade")); - } - int tAmount = 0; - if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { - aList.add( - tAmount + " " - + GT_LanguageManager - .addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades")); - } - - CoverableTileEntity.addInstalledCoversInformation(aNBT, aList); - if (aNBT.hasKey("mColor") && aNBT.getByte("mColor") != -1) { - aList.add( - GT_LanguageManager.addStringLocalization("GT_TileEntity_COLORED", "Colored") + " (" - + Dyes.get(aNBT.getByte("mColor") - 1).formatting - + Dyes.get(aNBT.getByte("mColor") - 1).mName - + EnumChatFormatting.GRAY - + ")"); - } - } - } catch (Throwable e) { - GT_FML_LOGGER.error("addInformation", e); - } - } - - private void addDescription(@Nullable List aList, @Nullable String[] aDescription, int aDamage, - String aSuffix) { - if (aDescription == null) return; - for (int i = 0, tLength = aDescription.length; i < tLength; i++) { - String tDescLine = aDescription[i]; - if (!GT_Utility.isStringValid(tDescLine)) continue; - - String tKey = String.format("TileEntity_DESCRIPTION_%05d%s_Index_%02d", aDamage, aSuffix, i); - if (tDescLine.contains("%%%")) { - final String[] tSplitStrings = tDescLine.split("%%%"); - final StringBuilder tBuffer = new StringBuilder(); - final String[] tRep = new String[tSplitStrings.length / 2]; - for (int j = 0; j < tSplitStrings.length; j++) if (j % 2 == 0) tBuffer.append(tSplitStrings[j]); - else { - tBuffer.append("%s"); - tRep[j / 2] = tSplitStrings[j]; - } - final String tTranslated = String - .format(GT_LanguageManager.addStringLocalization(tKey, tBuffer.toString()), (Object[]) tRep); - if (aList != null) aList.add(tTranslated); - } else { - String tTranslated = GT_LanguageManager.addStringLocalization(tKey, tDescLine); - if (aList != null) aList.add(tTranslated.equals("") ? tDescLine : tTranslated); - } - } - } - - @SideOnly(Side.CLIENT) - public void registerDescription(int aDamage) { - if (aDamage >= GregTech_API.METATILEENTITIES.length) return; - if (GregTech_API.METATILEENTITIES[aDamage] != null) { - final IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aDamage].getBaseMetaTileEntity() - .getMetaTileEntity(); - if (tMetaTileEntity instanceof ISecondaryDescribable) { - final String[] tSecondaryDescription = ((ISecondaryDescribable) tMetaTileEntity) - .getSecondaryDescription(); - addDescription(null, tSecondaryDescription, aDamage, "_Secondary"); - } - addDescription(null, tMetaTileEntity.getDescription(), aDamage, ""); - } - } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, - int ordinalSide, float hitX, float hitY, float hitZ) { - return false; - } - - @Override - public String getUnlocalizedName(ItemStack aStack) { - final 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 ""; - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String aName = super.getItemStackDisplayName(aStack); - final short aDamage = (short) getDamage(aStack); - if (aDamage >= 0 && aDamage < GregTech_API.METATILEENTITIES.length - && GregTech_API.METATILEENTITIES[aDamage] != null) { - Materials aMaterial = null; - if (GregTech_API.METATILEENTITIES[aDamage] instanceof GT_MetaPipeEntity_Item) { - aMaterial = ((GT_MetaPipeEntity_Item) GregTech_API.METATILEENTITIES[aDamage]).mMaterial; - } else if (GregTech_API.METATILEENTITIES[aDamage] instanceof GT_MetaPipeEntity_Fluid) { - aMaterial = ((GT_MetaPipeEntity_Fluid) GregTech_API.METATILEENTITIES[aDamage]).mMaterial; - } else if (GregTech_API.METATILEENTITIES[aDamage] instanceof GT_MetaPipeEntity_Cable) { - aMaterial = ((GT_MetaPipeEntity_Cable) GregTech_API.METATILEENTITIES[aDamage]).mMaterial; - } else if (GregTech_API.METATILEENTITIES[aDamage] instanceof GT_MetaPipeEntity_Frame) { - aMaterial = ((GT_MetaPipeEntity_Frame) GregTech_API.METATILEENTITIES[aDamage]).mMaterial; - } - if (aMaterial != null) { - aName = aMaterial.getLocalizedNameForItem(aName); - } - } - return aName; - } - - @Override - public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - super.onCreated(aStack, aWorld, aPlayer); - final 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); - } - } - - @Override - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int ordinalSide, float hitX, float hitY, float hitZ, int aMeta) { - final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); - final short tDamage = (short) getDamage(aStack); - if (tDamage > 0) { - if (GregTech_API.METATILEENTITIES[tDamage] == null) { - return false; - } - final 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."); - } - final 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.setOwnerUuid(aPlayer.getUniqueID()); - } - tTileEntity.getMetaTileEntity() - .initDefaultModes(aStack.getTagCompound()); - final ForgeDirection oppositeSide = side.getOpposite(); - if (tTileEntity.getMetaTileEntity() instanceof IConnectable connectable) { - // If we're connectable, try connecting to whatever we're up against - connectable.connect(oppositeSide); - } else if (aPlayer != null && aPlayer.isSneaking()) { - // If we're being placed against something that is connectable, try telling it to connect to us - final IGregTechTileEntity aTileEntity = tTileEntity.getIGregTechTileEntityAtSide(oppositeSide); - if (aTileEntity != null && aTileEntity.getMetaTileEntity() instanceof IConnectable connectable) { - connectable.connect(side); - } - } - } - } 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; - } - - @Override - public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) { - super.onUpdate(aStack, aWorld, aPlayer, aTimer, aIsInHand); - final short tDamage = (short) getDamage(aStack); - final EntityLivingBase tPlayer = (EntityPlayer) aPlayer; - if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_SuperChest - || GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_SuperTank) { - final NBTTagCompound tNBT = aStack.stackTagCompound; - if (tNBT == null) return; - if (tNBT.hasNoTags()) { - aStack.setTagCompound(null); - return; - } - if ((tNBT.hasKey("mItemCount") && tNBT.getInteger("mItemCount") > 0) || (tNBT.hasKey("mFluid") - && FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")).amount > 64000)) { - final FluidStack tFluid = FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")); - int tEffectDuration = 1200; - if (tFluid != null) { - final double tFluidAmount = tFluid.amount; - final double tMiddlePoint = 4096000; - final double tSmoothingCoefficient = 2000000; - final int tMaxDuration = 12000; - final double tmp = (tFluidAmount - tMiddlePoint) / tSmoothingCoefficient; - tEffectDuration = (int) (Math.exp(tmp) / (Math.exp(tmp) + Math.exp(-tmp)) * tMaxDuration); - } - tPlayer.addPotionEffect(new PotionEffect(Potion.hunger.id, tEffectDuration, 1)); - tPlayer.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, tEffectDuration, 1)); - tPlayer.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, tEffectDuration, 1)); - tPlayer.addPotionEffect(new PotionEffect(Potion.weakness.id, tEffectDuration, 1)); - } - } - } - - @Override - public FluidStack getFluid(ItemStack container) { - if (container != null) { - final NBTTagCompound tNBT = container.stackTagCompound; - if (tNBT != null && tNBT.hasKey("mFluid", 10)) { - return FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")); - } - } - return null; - } - - @Override - public int getCapacity(ItemStack container) { - if (container != null) { - final int tDamage = container.getItemDamage(); - final IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; - if (tMetaTile != null) return tMetaTile.getCapacity(); - } - return 0; - } - - @Nullable - private Fluid getLockedFluid(@Nonnull ItemStack container) { - final NBTTagCompound tag = container.stackTagCompound; - if (tag == null) return null; - String lockedName = tag.getString("lockedFluidName"); - if (GT_Utility.isStringInvalid(lockedName)) return null; - return FluidRegistry.getFluid(lockedName); - } - - @Override - public int fill(ItemStack container, FluidStack resource, boolean doFill) { - if (container != null && resource != null) { - final int tDamage = container.getItemDamage(); - final IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; - if (!(tMetaTile instanceof GT_MetaTileEntity_DigitalTankBase)) { - return 0; - } - if (container.stackTagCompound == null) container.stackTagCompound = new NBTTagCompound(); - final FluidStack tStoredFluid = getFluid(container); - final int tCapacity = getCapacity(container); - if (tCapacity <= 0) return 0; - final Fluid lockedFluid = getLockedFluid(container); - if (lockedFluid != null && resource.getFluid() != lockedFluid) { - return 0; - } - if (tStoredFluid != null && tStoredFluid.isFluidEqual(resource)) { - final int tAmount = Math.min(tCapacity - tStoredFluid.amount, resource.amount); - if (doFill) { - final FluidStack tNewFluid = new FluidStack(tStoredFluid, tAmount + tStoredFluid.amount); - container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); - } - return tAmount; - } - if (tStoredFluid == null) { - final int tAmount = Math.min(tCapacity, resource.amount); - if (doFill) { - final FluidStack tNewFluid = new FluidStack(resource, tAmount); - container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); - } - return tAmount; - } - } - return 0; - } - - @Override - public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { - if (container != null && container.hasTagCompound()) { - final int tDamage = container.getItemDamage(); - final IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; - if (!(tMetaTile instanceof GT_MetaTileEntity_DigitalTankBase)) { - return null; - } - final FluidStack tStoredFluid = getFluid(container); - if (tStoredFluid != null) { - final int tAmount = Math.min(maxDrain, tStoredFluid.amount); - final FluidStack tNewFluid = new FluidStack(tStoredFluid, tStoredFluid.amount - tAmount); - final FluidStack tOutputFluid = new FluidStack(tStoredFluid, tAmount); - if (doDrain) { - if (tNewFluid.amount <= 0) { - container.stackTagCompound.removeTag("mFluid"); - if (container.stackTagCompound.hasNoTags()) container.setTagCompound(null); - } else { - container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); - } - } - return tOutputFluid; - } - } - return null; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java deleted file mode 100644 index 2ba78572b3..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java +++ /dev/null @@ -1,81 +0,0 @@ -package gregtech.common.blocks; - -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.util.StatCollector; -import net.minecraft.world.World; - -import org.apache.commons.lang3.StringUtils; - -import gregtech.api.GregTech_API; -import gregtech.api.enums.Materials; - -public class GT_Item_Ores extends ItemBlock { - - public GT_Item_Ores(Block block) { - super(block); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, - int ordinalSide, float hitX, float hitY, float hitZ) { - return false; - } - - @Override - public String getUnlocalizedName(ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String aName = super.getItemStackDisplayName(aStack); - if (this.field_150939_a instanceof GT_Block_Ores_Abstract) { - aName = Materials.getLocalizedNameForItem(aName, aStack.getItemDamage() % 1000); - } - return aName; - } - - @Override - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, - int ordinalSide, float hitX, float hitY, float hitZ, int aMeta) { - short tDamage = (short) getDamage(aStack); - if (tDamage > 0) { - if (!aWorld.setBlock( - aX, - aY, - aZ, - this.field_150939_a, - GT_TileEntity_Ores.getHarvestData( - tDamage, - ((GT_Block_Ores_Abstract) field_150939_a).getBaseBlockHarvestLevel(aMeta % 16000 / 1000)), - 3)) { - return false; - } - GT_TileEntity_Ores tTileEntity = (GT_TileEntity_Ores) aWorld.getTileEntity(aX, aY, aZ); - tTileEntity.mMetaData = tDamage; - tTileEntity.mNatural = false; - } else if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3)) { - return false; - } - if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { - this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); - this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, tDamage); - } - return true; - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - String formula = StatCollector - .translateToLocal(field_150939_a.getUnlocalizedName() + '.' + getDamage(aStack) + ".tooltip"); - if (!StringUtils.isBlank(formula)) aList.add(formula); - } -} 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 deleted file mode 100644 index 5b73108301..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java +++ /dev/null @@ -1,42 +0,0 @@ -package gregtech.common.blocks; - -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 gregtech.api.GregTech_API; -import gregtech.api.util.GT_LanguageManager; - -public class GT_Item_Stones_Abstract extends ItemBlock { - - private final String mNoMobsToolTip = GT_LanguageManager - .addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); - - public GT_Item_Stones_Abstract(Block block) { - super(block); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - @Override - public String getUnlocalizedName(ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); - } - - @Override - public int getMetadata(int aMeta) { - return aMeta; - } - - @Override - 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_Item_Storage.java b/src/main/java/gregtech/common/blocks/GT_Item_Storage.java deleted file mode 100644 index 4ac1b9cdfd..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_Storage.java +++ /dev/null @@ -1,47 +0,0 @@ -package gregtech.common.blocks; - -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 gregtech.api.GregTech_API; - -public class GT_Item_Storage extends ItemBlock { - - public GT_Item_Storage(Block block) { - super(block); - setMaxDamage(0); - setHasSubtypes(true); - setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); - } - - @Override - public String getUnlocalizedName(ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); - } - - @Override - public String getItemStackDisplayName(ItemStack aStack) { - String aName = super.getItemStackDisplayName(aStack); - if (this.field_150939_a instanceof GT_Block_Metal) { - int aDamage = aStack.getItemDamage(); - if (aDamage >= 0 && aDamage < ((GT_Block_Metal) this.field_150939_a).mMats.length) { - aName = ((GT_Block_Metal) this.field_150939_a).mMats[aDamage].getLocalizedNameForItem(aName); - } - } - return aName; - } - - @Override - public int getMetadata(int aMeta) { - return aMeta; - } - - @Override - public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - super.addInformation(aStack, aPlayer, aList, aF3_H); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_TintedIndustrialGlass.java b/src/main/java/gregtech/common/blocks/GT_Item_TintedIndustrialGlass.java deleted file mode 100644 index 9f633922ac..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Item_TintedIndustrialGlass.java +++ /dev/null @@ -1,10 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.Block; - -public class GT_Item_TintedIndustrialGlass extends GT_Item_Casings_Abstract { - - public GT_Item_TintedIndustrialGlass(Block block) { - super(block); - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Casings.java b/src/main/java/gregtech/common/blocks/GT_Material_Casings.java deleted file mode 100644 index 2fc839768f..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Material_Casings.java +++ /dev/null @@ -1,19 +0,0 @@ -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(); - } - - @Override - public boolean isOpaque() { - return true; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Machines.java b/src/main/java/gregtech/common/blocks/GT_Material_Machines.java deleted file mode 100644 index df8b57226c..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Material_Machines.java +++ /dev/null @@ -1,19 +0,0 @@ -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(); - } - - @Override - public boolean isOpaque() { - return true; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java deleted file mode 100644 index 2e3301bb60..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java +++ /dev/null @@ -1,18 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.block.material.MapColor; -import net.minecraft.block.material.Material; - -public class GT_Material_Reinforced extends Material { - - public GT_Material_Reinforced() { - super(MapColor.stoneColor); - setRequiresTool(); - setAdventureModeExempt(); - } - - @Override - public boolean isOpaque() { - return true; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java b/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java deleted file mode 100644 index a65ac47c44..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java +++ /dev/null @@ -1,62 +0,0 @@ -package gregtech.common.blocks; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import com.google.common.io.ByteArrayDataInput; - -import gregtech.api.net.GT_PacketTypes; -import gregtech.api.net.GT_Packet_New; -import io.netty.buffer.ByteBuf; - -public class GT_Packet_Ores extends GT_Packet_New { - - 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; - } - - @Override - public void encode(ByteBuf aOut) { - aOut.writeInt(this.mX); - aOut.writeShort(this.mY); - aOut.writeInt(this.mZ); - aOut.writeShort(this.mMetaData); - } - - @Override - public GT_Packet_New decode(ByteArrayDataInput aData) { - return new GT_Packet_Ores(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort()); - } - - @Override - 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); - } - } - } - - @Override - public byte getPacketID() { - return GT_PacketTypes.ORES.id; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java deleted file mode 100644 index de69c011a2..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java +++ /dev/null @@ -1,486 +0,0 @@ -package gregtech.common.blocks; - -import static gregtech.api.enums.TextureSet.SET_NONE; - -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; - -import org.jetbrains.annotations.NotNull; - -import gregtech.GT_Mod; -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.tileentity.IAllSidedTexturedTileEntity; -import gregtech.api.objects.XSTR; -import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; - -public class GT_TileEntity_Ores extends TileEntity implements IAllSidedTexturedTileEntity { - - public short mMetaData = 0; - protected static boolean shouldFortune = false; - protected static boolean shouldSilkTouch = false; - public boolean mNatural = false; - public boolean mBlocked = true; - public boolean mBlockedChecked = false; - private short mMetadataForCachedTexture = -1; - private ITexture[] mCachedTexture; - - public static byte getHarvestData(short aMetaData, int aBaseBlockHarvestLevel) { - Materials aMaterial = GregTech_API.sGeneratedMaterials[(aMetaData % 1000)]; - byte tByte = aMaterial == null ? 0 - : (byte) Math - .max(aBaseBlockHarvestLevel, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1))); - if (GT_Mod.gregtechproxy.mChangeHarvestLevels) { - tByte = aMaterial == null ? 0 - : (byte) Math.max( - aBaseBlockHarvestLevel, - Math.min( - GT_Mod.gregtechproxy.mMaxHarvestLevel, - GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1))); - } - return tByte; - } - - public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { - return setOreBlock(aWorld, aX, aY, aZ, aMetaData, isSmallOre, true); - } - - public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre, - boolean air) { - if (!air) { - aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); - } - Block tBlock = aWorld.getBlock(aX, aY, aZ); - Block tOreBlock = GregTech_API.sBlockOres1; - int BlockMeta = aWorld.getBlockMetadata(aX, aY, aZ); - String BlockName = tBlock.getUnlocalizedName(); - aMetaData += isSmallOre ? 16000 : 0; - if ((aMetaData > 0) && ((tBlock != Blocks.air) || air)) { - if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) { - // Do nothing, stone background is default background. - // Do this comparison first since stone is most common - } else 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, GregTech_API.sBlockStones)) { - if (tBlock == GregTech_API.sBlockStones) { - if (aWorld.getBlockMetadata(aX, aY, aZ) < 8) { - aMetaData += 5000; - } else { - aMetaData += 6000; - } - } else { - aMetaData += 5000; - } - } else if (BlockName.equals("tile.igneousStone")) { - if (GregTech_API.sBlockOresUb1 != null) { - tOreBlock = GregTech_API.sBlockOresUb1; - aMetaData += (BlockMeta * 1000); - // GT_FML_LOGGER.info("Block changed to UB1"); - } - } else if (BlockName.equals("tile.metamorphicStone")) { - if (GregTech_API.sBlockOresUb2 != null) { - tOreBlock = GregTech_API.sBlockOresUb2; - aMetaData += (BlockMeta * 1000); - // GT_FML_LOGGER.info("Block changed to UB2"); - } - } else if (BlockName.equals("tile.sedimentaryStone")) { - if (GregTech_API.sBlockOresUb3 != null) { - tOreBlock = GregTech_API.sBlockOresUb3; - aMetaData += (BlockMeta * 1000); - // GT_FML_LOGGER.info("Block changed to UB3"); - } - } else { - return false; - } - // GT_FML_LOGGER.info(tOreBlock); - aWorld.setBlock( - aX, - aY, - aZ, - tOreBlock, - getHarvestData( - (short) aMetaData, - ((GT_Block_Ores_Abstract) tOreBlock).getBaseBlockHarvestLevel(aMetaData % 16000 / 1000)), - 0); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof GT_TileEntity_Ores)) { - ((GT_TileEntity_Ores) tTileEntity).mMetaData = ((short) aMetaData); - ((GT_TileEntity_Ores) tTileEntity).mNatural = true; - } - return true; - } - return false; - } - - @Override - public void readFromNBT(NBTTagCompound aNBT) { - super.readFromNBT(aNBT); - this.mMetaData = aNBT.getShort("m"); - this.mNatural = aNBT.getBoolean("n"); - } - - @Override - 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); - } - } - - @Override - public Packet getDescriptionPacket() { - if (!this.worldObj.isRemote) { - boolean sendUpdate = mBlockedChecked ? !mBlocked : checkBlocked(); - if (sendUpdate) { - 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; - } - - private boolean checkBlocked() { - // this is called very frequently and is performance critical. unroll the loop. - mBlockedChecked = true; - if (!worldObj.blockExists(xCoord + 1, yCoord, zCoord)) { - mBlockedChecked = false; - } else if (!GT_Utility.isOpaqueBlock(worldObj, xCoord + 1, yCoord, zCoord)) { - mBlocked = false; - return true; - } - if (!worldObj.blockExists(xCoord - 1, yCoord, zCoord)) { - mBlockedChecked = false; - } else if (!GT_Utility.isOpaqueBlock(worldObj, xCoord - 1, yCoord, zCoord)) { - mBlocked = false; - return true; - } - if (!worldObj.blockExists(xCoord, yCoord + 1, zCoord)) { - mBlockedChecked = false; - } else if (!GT_Utility.isOpaqueBlock(worldObj, xCoord, yCoord + 1, zCoord)) { - mBlocked = false; - return true; - } - if (!worldObj.blockExists(xCoord, yCoord - 1, zCoord)) { - mBlockedChecked = false; - } else if (!GT_Utility.isOpaqueBlock(worldObj, xCoord, yCoord - 1, zCoord)) { - mBlocked = false; - return true; - } - if (!worldObj.blockExists(xCoord, yCoord, zCoord + 1)) { - mBlockedChecked = false; - } else if (!GT_Utility.isOpaqueBlock(worldObj, xCoord, yCoord, zCoord + 1)) { - mBlocked = false; - return true; - } - if (!worldObj.blockExists(xCoord, yCoord, zCoord - 1)) { - mBlockedChecked = false; - } else if (!GT_Utility.isOpaqueBlock(worldObj, xCoord, yCoord, zCoord - 1)) { - mBlocked = false; - return true; - } - mBlocked = true; - return false; - } - - public void overrideOreBlockMaterial(Block aOverridingStoneBlock, byte aOverridingStoneMeta) { - if (this.worldObj == null || blockType == null) return; - this.mMetaData = ((short) (int) (this.mMetaData % 1000L + this.mMetaData / 16000L * 16000L)); - if (aOverridingStoneBlock - .isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.netherrack)) { - this.mMetaData = ((short) (this.mMetaData + 1000)); - } 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)); - } - } else if (aOverridingStoneBlock.isReplaceableOreGen( - this.worldObj, - this.xCoord, - this.yCoord, - this.zCoord, - GregTech_API.sBlockStones)) { - if (aOverridingStoneBlock == GregTech_API.sBlockStones) { - if (aOverridingStoneMeta < 8) { - this.mMetaData = ((short) (this.mMetaData + 5000)); - } else { - this.mMetaData = ((short) (this.mMetaData + 6000)); - } - } else { - this.mMetaData = ((short) (this.mMetaData + 5000)); - } - } - this.worldObj.setBlockMetadataWithNotify( - this.xCoord, - this.yCoord, - this.zCoord, - getHarvestData( - this.mMetaData, - ((GT_Block_Ores_Abstract) blockType).getBaseBlockHarvestLevel(mMetaData % 16000 / 1000)), - 0); - } - - public void convertOreBlock(World aWorld, int aX, int aY, int aZ) { - short aMeta = ((short) (this.mMetaData % 1000 + (this.mMetaData / 16000 * 16000))); - aWorld.setBlock(aX, aY, aZ, GregTech_API.sBlockOres1); - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof GT_TileEntity_Ores) { - ((GT_TileEntity_Ores) tTileEntity).mMetaData = aMeta; - this.worldObj.setBlockMetadataWithNotify( - this.xCoord, - this.yCoord, - this.zCoord, - getHarvestData( - aMeta, - ((GT_Block_Ores_Abstract) tTileEntity.blockType).getBaseBlockHarvestLevel(aMeta % 16000 / 1000)), - 0); - } - } - - public short getMetaData() { - return this.mMetaData; - } - - @Override - public boolean canUpdate() { - return false; - } - - public ArrayList getDrops(Block aDroppedOre, int aFortune) { - ArrayList rList = new ArrayList<>(); - if (this.mMetaData <= 0) { - rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); - return rList; - } - Materials aOreMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; - if (this.mMetaData < 16000) { - boolean tIsRich = false; - - // For Sake of god of balance! - - // Dense ore - - // NetherOre - if (GT_Mod.gregtechproxy.mNetherOreYieldMultiplier && !tIsRich) { - tIsRich = (this.mMetaData >= 1000 && this.mMetaData < 2000); - } - // EndOre - if (GT_Mod.gregtechproxy.mEndOreYieldMultiplier && !tIsRich) { - tIsRich = (this.mMetaData >= 2000 && this.mMetaData < 3000); - } - - // Silk Touch - if (shouldSilkTouch) { - rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); - - } else { - switch (GT_Mod.gregtechproxy.oreDropSystem) { - case Item -> { - rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, (tIsRich ? 2 : 1))); - } - // TODO: Test - case FortuneItem -> { - // if shouldFortune and isNatural then get fortune drops - // if not shouldFortune or not isNatural then get normal drops - // if not shouldFortune and isNatural then get normal drops - // if shouldFortune and not isNatural then get normal drops - if (shouldFortune && this.mNatural && aFortune > 0) { - int aMinAmount = 1; - // Max applicable fortune - if (aFortune > 3) aFortune = 3; - int amount = aMinAmount - + Math.max(worldObj.rand.nextInt(aFortune * (tIsRich ? 2 : 1) + 2) - 1, 0); - for (int i = 0; i < amount; i++) { - rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); - } - } else { - for (int i = 0; i < (tIsRich ? 2 : 1); i++) { - rList.add(GT_OreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); - } - } - } - case UnifiedBlock -> { - // Unified ore - for (int i = 0; i < (tIsRich ? 2 : 1); i++) { - rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData % 1000)); - } - } - case PerDimBlock -> { - // Per Dimension ore - if (tIsRich) { - rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); - } else { - rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData % 1000)); - } - } - case Block -> { - // Regular ore - rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); - } - } - } - return rList; - } - - // Everyone gets a free small fortune boost - aFortune += 1; - if (!this.mNatural) { - aFortune = 0; - } - if (aOreMaterial != null) { - Random tRandom = new XSTR(this.xCoord ^ this.yCoord ^ this.zCoord); - ArrayList tSelector = new ArrayList<>(); - - Materials aMaterial = aOreMaterial.mOreReplacement; - - 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.isEmpty()) { - 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(1, tSelector.get(tRandom.nextInt(tSelector.size())))); - } - } - if (tRandom.nextInt(3 + aFortune) > 1) { - Materials dustMat = ((GT_Block_Ores_Abstract) aDroppedOre).getDroppedDusts()[this.mMetaData / 1000 - % 16]; - if (dustMat != null) rList.add( - GT_OreDictUnificator - .get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, dustMat, 1L)); - } - } - return rList; - } - - @Override - public ITexture[] getTexture(Block aBlock) { - if (mMetadataForCachedTexture == mMetaData && mCachedTexture != null) return mCachedTexture; - - mMetadataForCachedTexture = mMetaData; - mCachedTexture = getTextureInternal(aBlock); - return mCachedTexture; - } - - private ITexture @NotNull [] getTextureInternal(Block aBlock) { - Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; - if ((aMaterial != null) && (this.mMetaData < 32000) && (aBlock instanceof GT_Block_Ores_Abstract)) { - ITexture iTexture = TextureFactory.builder() - .addIcon( - aMaterial.mIconSet.mTextures[this.mMetaData / 16000 == 0 ? OrePrefixes.ore.mTextureIndex - : OrePrefixes.oreSmall.mTextureIndex]) - .setRGBA(aMaterial.mRGBa) - .stdOrient() - .build(); - return new ITexture[] { ((GT_Block_Ores_Abstract) aBlock).getTextureSet()[((this.mMetaData / 1000) % 16)], - iTexture }; - } - return new ITexture[] { TextureFactory.of(Blocks.stone, 0), TextureFactory.builder() - .addIcon(SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex]) - .stdOrient() - .build() }; - } -} diff --git a/src/main/java/gregtech/common/blocks/GT_WormholeRenderBlock.java b/src/main/java/gregtech/common/blocks/GT_WormholeRenderBlock.java deleted file mode 100644 index 1c6e434477..0000000000 --- a/src/main/java/gregtech/common/blocks/GT_WormholeRenderBlock.java +++ /dev/null @@ -1,75 +0,0 @@ -package gregtech.common.blocks; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.common.tileentities.render.TileWormhole; - -public class GT_WormholeRenderBlock extends Block { - - public GT_WormholeRenderBlock() { - super(Material.iron); - this.setResistance(20f); - this.setHardness(-1.0f); - // this.setCreativeTab(TecTech.creativeTabTecTech); - this.setBlockName("WormholeRenderer"); - this.setLightLevel(100.0f); - GameRegistry.registerBlock(this, getUnlocalizedName()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister iconRegister) { - blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); - } - - @Override - public String getUnlocalizedName() { - return "gt.wormholerenderer"; - } - - @Override - public boolean isOpaqueCube() { - return false; - } - - @Override - public boolean canRenderInPass(int a) { - return true; - } - - @Override - public boolean renderAsNormalBlock() { - return false; - } - - @Override - public boolean hasTileEntity(int metadata) { - return true; - } - - @Override - public TileEntity createTileEntity(World world, int metadata) { - return new TileWormhole(); - } - - @Override - public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { - return new ArrayList<>(); - } - - @Override - public boolean isCollidable() { - return true; - } - -} diff --git a/src/main/java/gregtech/common/blocks/ItemBlockLaser.java b/src/main/java/gregtech/common/blocks/ItemBlockLaser.java new file mode 100644 index 0000000000..c8b4d4ce06 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemBlockLaser.java @@ -0,0 +1,24 @@ +package gregtech.common.blocks; + +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 gregtech.api.util.GTLanguageManager; + +public class ItemBlockLaser extends ItemBlock { + + public ItemBlockLaser(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean f3_h) { + tooltip.add( + GTLanguageManager + .addStringLocalization("gt.laserplatingtooltip", "Engineered to withstand extreme temperatures")); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings1.java b/src/main/java/gregtech/common/blocks/ItemCasings1.java new file mode 100644 index 0000000000..ad1c8c09e1 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings1.java @@ -0,0 +1,14 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings1 extends ItemCasingsAbstract { + + public ItemCasings1(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings10.java b/src/main/java/gregtech/common/blocks/ItemCasings10.java new file mode 100644 index 0000000000..0931987cd4 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings10.java @@ -0,0 +1,14 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings10 extends ItemCasingsAbstract { + + public ItemCasings10(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings11.java b/src/main/java/gregtech/common/blocks/ItemCasings11.java new file mode 100644 index 0000000000..5cae92a55d --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings11.java @@ -0,0 +1,14 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings11 extends ItemCasingsAbstract { + + public ItemCasings11(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings2.java b/src/main/java/gregtech/common/blocks/ItemCasings2.java new file mode 100644 index 0000000000..b0981c0dc3 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings2.java @@ -0,0 +1,26 @@ +package gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings2 extends ItemCasingsAbstract { + + public ItemCasings2(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + if (getDamage(aStack) == 8) { + aList.add(this.mBlastProofTooltip); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings3.java b/src/main/java/gregtech/common/blocks/ItemCasings3.java new file mode 100644 index 0000000000..737c9e5145 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings3.java @@ -0,0 +1,14 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings3 extends ItemCasingsAbstract { + + public ItemCasings3(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings4.java b/src/main/java/gregtech/common/blocks/ItemCasings4.java new file mode 100644 index 0000000000..97d160105a --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings4.java @@ -0,0 +1,14 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings4 extends ItemCasingsAbstract { + + public ItemCasings4(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings5.java b/src/main/java/gregtech/common/blocks/ItemCasings5.java new file mode 100644 index 0000000000..4192fb2a64 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings5.java @@ -0,0 +1,36 @@ +package gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.util.GTLanguageManager; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings5 extends ItemCasingsAbstract { + + public ItemCasings5(Block block) { + super(block); + } + + protected static final String mCoilHeatTooltip = GTLanguageManager + .addStringLocalization("gt.coilheattooltip", "Base Heating Capacity = "); + protected static final String mCoilUnitTooltip = GTLanguageManager + .addStringLocalization("gt.coilunittooltip", " Kelvin"); + + @Override + @SideOnly(Side.CLIENT) + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + HeatingCoilLevel coilLevel = BlockCasings5.getCoilHeatFromDamage(aStack.getItemDamage()); + aList.add(mCoilHeatTooltip + coilLevel.getHeat() + mCoilUnitTooltip); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings6.java b/src/main/java/gregtech/common/blocks/ItemCasings6.java new file mode 100644 index 0000000000..36a25f7796 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings6.java @@ -0,0 +1,14 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings6 extends ItemCasingsAbstract { + + public ItemCasings6(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings8.java b/src/main/java/gregtech/common/blocks/ItemCasings8.java new file mode 100644 index 0000000000..7183d78986 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings8.java @@ -0,0 +1,14 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings8 extends ItemCasingsAbstract { + + public ItemCasings8(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasings9.java b/src/main/java/gregtech/common/blocks/ItemCasings9.java new file mode 100644 index 0000000000..c4ae95a2f7 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasings9.java @@ -0,0 +1,28 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +/** + * The casings are split into separate files because they are registered as regular blocks, and a regular block can have + * 16 subtypes at most. + */ +public class ItemCasings9 extends ItemCasingsAbstract { + + public ItemCasings9(Block block) { + super(block); + } + + /* + * @Override + * public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + * // Add tooltip info if it was given + * String localizedTooltip = GTLanguageManager.getTranslation(aStack.getUnlocalizedName() + ".tooltip"); + * // getTranslation returns the key if no translation was found, but this just means + * // no tooltip was set. + * if (localizedTooltip.startsWith("gt.")) { + * aList.add(localizedTooltip); + * } + * super.addInformation(aStack, aPlayer, aList, aF3_H); + * } + */ +} diff --git a/src/main/java/gregtech/common/blocks/ItemCasingsAbstract.java b/src/main/java/gregtech/common/blocks/ItemCasingsAbstract.java new file mode 100644 index 0000000000..577b1fb821 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCasingsAbstract.java @@ -0,0 +1,63 @@ +package gregtech.common.blocks; + +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 gregtech.api.GregTechAPI; +import gregtech.api.util.GTLanguageManager; + +public abstract class ItemCasingsAbstract extends ItemBlock { + + protected final String mNoMobsToolTip = GTLanguageManager + .addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + protected final String mNoTileEntityToolTip = GTLanguageManager + .addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + protected final String mCoil01Tooltip = GTLanguageManager + .addStringLocalization("gt.coil01tooltip", "Base Heating Capacity = 1800 Kelvin"); + protected final String mCoil02Tooltip = GTLanguageManager + .addStringLocalization("gt.coil02tooltip", "Base Heating Capacity = 2700 Kelvin"); + protected final String mCoil03Tooltip = GTLanguageManager + .addStringLocalization("gt.coil03tooltip", "Base Heating Capacity = 3600 Kelvin"); + protected final String mCoil04Tooltip = GTLanguageManager + .addStringLocalization("gt.coil04tooltip", "Base Heating Capacity = 4500 Kelvin"); + protected final String mCoil05Tooltip = GTLanguageManager + .addStringLocalization("gt.coil05tooltip", "Base Heating Capacity = 5400 Kelvin"); + protected final String mCoil06Tooltip = GTLanguageManager + .addStringLocalization("gt.coil06tooltip", "Base Heating Capacity = 7200 Kelvin"); + protected final String mCoil07Tooltip = GTLanguageManager + .addStringLocalization("gt.coil07tooltip", "Base Heating Capacity = 9001 Kelvin"); + protected final String mCoil08Tooltip = GTLanguageManager + .addStringLocalization("gt.coil08tooltip", "Base Heating Capacity = 9900 Kelvin"); + protected final String mCoil09Tooltip = GTLanguageManager + .addStringLocalization("gt.coil09tooltip", "Base Heating Capacity = 10800 Kelvin"); + protected final String mBlastProofTooltip = GTLanguageManager + .addStringLocalization("gt.blastprooftooltip", "This Block is Blast Proof"); + + public ItemCasingsAbstract(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + } + + @Override + public int getMetadata(int aMeta) { + return aMeta; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + @Override + 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/ItemConcretes.java b/src/main/java/gregtech/common/blocks/ItemConcretes.java new file mode 100644 index 0000000000..64f778d5d4 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemConcretes.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; + +import gregtech.api.util.GTLanguageManager; + +public class ItemConcretes extends ItemStonesAbstract { + + private final String mRunFasterToolTip = GTLanguageManager + .addStringLocalization("gt.runfastertooltip", "You can walk faster on this Block"); + + public ItemConcretes(Block block) { + super(block); + } + + @Override + 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/ItemCyclotronCasings.java b/src/main/java/gregtech/common/blocks/ItemCyclotronCasings.java new file mode 100644 index 0000000000..febd101e0f --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemCyclotronCasings.java @@ -0,0 +1,10 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +public class ItemCyclotronCasings extends ItemCasingsAbstract { + + public ItemCyclotronCasings(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemFrames.java b/src/main/java/gregtech/common/blocks/ItemFrames.java new file mode 100644 index 0000000000..daa6ca2d2e --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemFrames.java @@ -0,0 +1,60 @@ +package gregtech.common.blocks; + +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 gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; +import gregtech.api.util.GTLanguageManager; + +public class ItemFrames extends ItemBlock { + + public ItemFrames(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + } + + private Block block() { + return this.field_150939_a; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.block() + .getUnlocalizedName() + "." + + getDamage(aStack); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + if (this.block() instanceof BlockFrameBox) { + aName = Materials.getLocalizedNameForItem(aName, aStack.getItemDamage()); + } + return aName; + } + + @Override + public int getColorFromItemStack(ItemStack aStack, int aPass) { + int meta = aStack.getItemDamage(); + Materials material = BlockFrameBox.getMaterial(meta); + return (material.mRGBa[0] << 16) | (material.mRGBa[1] << 8) | material.mRGBa[2]; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(GTLanguageManager.getTranslation("gt.blockframes." + aStack.getItemDamage() + ".tooltip")); + aList.add(GTLanguageManager.getTranslation("gt.blockmachines.gt_frame.desc.format")); + } + + @Override + public int getMetadata(int meta) { + return meta; + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemGlass1.java b/src/main/java/gregtech/common/blocks/ItemGlass1.java new file mode 100644 index 0000000000..5605bba48d --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemGlass1.java @@ -0,0 +1,36 @@ +package gregtech.common.blocks; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import gregtech.api.util.GTLanguageManager; + +/** + * The glass types are split into separate files because they are registered as regular blocks, and a regular block can + * have + * 16 subtypes at most. + */ +public class ItemGlass1 extends ItemCasingsAbstract { + + protected final String chemicalGlassTooltip = GTLanguageManager.addStringLocalization( + getUnlocalizedName() + ".0.tooltip", + "Able to resist the most extreme chemical conditions."); + protected final String hawkingGlassTooltip = GTLanguageManager.addStringLocalization( + getUnlocalizedName() + ".4.tooltip", + "Controls the outward flow of Hawking Radiation to stabilize a black hole."); + + public ItemGlass1(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + switch (getDamage(aStack)) { + case 0 -> aList.add(chemicalGlassTooltip); + case 4 -> aList.add(hawkingGlassTooltip); + } + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemGranites.java b/src/main/java/gregtech/common/blocks/ItemGranites.java new file mode 100644 index 0000000000..090ebc2a5a --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemGranites.java @@ -0,0 +1,10 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +public class ItemGranites extends ItemStonesAbstract { + + public ItemGranites(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemLongDistancePipe.java b/src/main/java/gregtech/common/blocks/ItemLongDistancePipe.java new file mode 100644 index 0000000000..55f5c2c768 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemLongDistancePipe.java @@ -0,0 +1,43 @@ +package gregtech.common.blocks; + +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 gregtech.api.GregTechAPI; +import gregtech.api.util.GTLanguageManager; + +public class ItemLongDistancePipe extends ItemBlock { + + protected final String mNoMobsToolTip = GTLanguageManager + .addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + protected final String mNoTileEntityToolTip = GTLanguageManager + .addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + + public ItemLongDistancePipe(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + } + + @Override + public int getMetadata(int aMeta) { + return aMeta; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + @Override + 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/ItemMachines.java b/src/main/java/gregtech/common/blocks/ItemMachines.java new file mode 100644 index 0000000000..ff031c8456 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemMachines.java @@ -0,0 +1,430 @@ +package gregtech.common.blocks; + +import static gregtech.GTMod.GT_FML_LOGGER; + +import java.util.List; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import net.minecraft.block.Block; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.potion.Potion; +import net.minecraft.potion.PotionEffect; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidContainerItem; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISecondaryDescribable; +import gregtech.api.interfaces.metatileentity.IConnectable; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.CoverableTileEntity; +import gregtech.api.metatileentity.implementations.MTECable; +import gregtech.api.metatileentity.implementations.MTEFluid; +import gregtech.api.metatileentity.implementations.MTEFrame; +import gregtech.api.metatileentity.implementations.MTEItem; +import gregtech.api.util.GTItsNotMyFaultException; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gregtech.common.tileentities.storage.MTEDigitalTankBase; +import gregtech.common.tileentities.storage.MTESuperChest; +import gregtech.common.tileentities.storage.MTESuperTank; + +public class ItemMachines extends ItemBlock implements IFluidContainerItem { + + public ItemMachines(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTechAPI.TAB_GREGTECH); + } + + public static IMetaTileEntity getMetaTileEntity(ItemStack aStack) { + if (GTUtility.isStackInvalid(aStack)) return null; + if (!(aStack.getItem() instanceof ItemMachines)) return null; + if (aStack.getItemDamage() < 0 || aStack.getItemDamage() > GregTechAPI.METATILEENTITIES.length) return null; + return GregTechAPI.METATILEENTITIES[aStack.getItemDamage()]; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + try { + final int tDamage = getDamage(aStack); + if ((tDamage <= 0) || (tDamage >= GregTechAPI.METATILEENTITIES.length)) { + return; + } + + if (GregTechAPI.METATILEENTITIES[tDamage] != null) { + final IGregTechTileEntity tTileEntity = GregTechAPI.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); + if (!GregTechAPI.sPostloadFinished + && tTileEntity.getMetaTileEntity() instanceof ISecondaryDescribable) { + final String[] tSecondaryDescription = ((ISecondaryDescribable) tTileEntity.getMetaTileEntity()) + .getSecondaryDescription(); + addDescription(null, tSecondaryDescription, tDamage, "_Secondary"); + } + { + final IMetaTileEntity tMetaTileEntity = tTileEntity.getMetaTileEntity(); + final String tSuffix = (tMetaTileEntity instanceof ISecondaryDescribable + && ((ISecondaryDescribable) tMetaTileEntity).isDisplaySecondaryDescription()) ? "_Secondary" + : ""; + addDescription(aList, tTileEntity.getDescription(), tDamage, tSuffix); + tMetaTileEntity.addAdditionalTooltipInformation(aStack, aList); + } + if (tTileEntity.getEUCapacity() > 0L) { + if (tTileEntity.getInputVoltage() > 0L) { + final byte inputTier = GTUtility.getTier(tTileEntity.getInputVoltage()); + aList.add( + GTLanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ") + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(tTileEntity.getInputVoltage()) + + " (" + + GTUtility.getColoredTierNameFromTier(inputTier) + + EnumChatFormatting.GREEN + + ")" + + EnumChatFormatting.GRAY); + } + if (tTileEntity.getOutputVoltage() > 0L) { + final byte outputTier = GTUtility.getTier(tTileEntity.getOutputVoltage()); + aList.add( + GTLanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ") + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(tTileEntity.getOutputVoltage()) + + " (" + + GTUtility.getColoredTierNameFromTier(outputTier) + + EnumChatFormatting.GREEN + + ")" + + EnumChatFormatting.GRAY); + } + if (tTileEntity.getOutputAmperage() > 1L) { + aList.add( + GTLanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ") + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(tTileEntity.getOutputAmperage()) + + EnumChatFormatting.GRAY); + } + aList.add( + GTLanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ") + + EnumChatFormatting.BLUE + + GTUtility.formatNumbers(tTileEntity.getEUCapacity()) + + EnumChatFormatting.GRAY + + " EU"); + } + } + final NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT != null) { + if (aNBT.getBoolean("mMuffler")) { + aList.add(GTLanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade")); + } + if (aNBT.getBoolean("mSteamConverter")) { + aList.add( + GTLanguageManager.addStringLocalization("GT_TileEntity_STEAMCONVERTER", "has Steam Upgrade")); + } + int tAmount = 0; + if ((tAmount = aNBT.getByte("mSteamTanks")) > 0) { + aList.add( + tAmount + " " + + GTLanguageManager + .addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades")); + } + + CoverableTileEntity.addInstalledCoversInformation(aNBT, aList); + if (aNBT.hasKey("mColor") && aNBT.getByte("mColor") != -1) { + aList.add( + GTLanguageManager.addStringLocalization("GT_TileEntity_COLORED", "Colored") + " (" + + Dyes.get(aNBT.getByte("mColor") - 1).formatting + + Dyes.get(aNBT.getByte("mColor") - 1).mName + + EnumChatFormatting.GRAY + + ")"); + } + } + } catch (Throwable e) { + GT_FML_LOGGER.error("addInformation", e); + } + } + + private void addDescription(@Nullable List aList, @Nullable String[] aDescription, int aDamage, + String aSuffix) { + if (aDescription == null) return; + for (int i = 0, tLength = aDescription.length; i < tLength; i++) { + String tDescLine = aDescription[i]; + if (!GTUtility.isStringValid(tDescLine)) continue; + + String tKey = String.format("TileEntity_DESCRIPTION_%05d%s_Index_%02d", aDamage, aSuffix, i); + if (tDescLine.contains("%%%")) { + final String[] tSplitStrings = tDescLine.split("%%%"); + final StringBuilder tBuffer = new StringBuilder(); + final String[] tRep = new String[tSplitStrings.length / 2]; + for (int j = 0; j < tSplitStrings.length; j++) if (j % 2 == 0) tBuffer.append(tSplitStrings[j]); + else { + tBuffer.append("%s"); + tRep[j / 2] = tSplitStrings[j]; + } + final String tTranslated = String + .format(GTLanguageManager.addStringLocalization(tKey, tBuffer.toString()), (Object[]) tRep); + if (aList != null) aList.add(tTranslated); + } else { + String tTranslated = GTLanguageManager.addStringLocalization(tKey, tDescLine); + if (aList != null) aList.add(tTranslated.equals("") ? tDescLine : tTranslated); + } + } + } + + @SideOnly(Side.CLIENT) + public void registerDescription(int aDamage) { + if (aDamage >= GregTechAPI.METATILEENTITIES.length) return; + if (GregTechAPI.METATILEENTITIES[aDamage] != null) { + final IMetaTileEntity tMetaTileEntity = GregTechAPI.METATILEENTITIES[aDamage].getBaseMetaTileEntity() + .getMetaTileEntity(); + if (tMetaTileEntity instanceof ISecondaryDescribable) { + final String[] tSecondaryDescription = ((ISecondaryDescribable) tMetaTileEntity) + .getSecondaryDescription(); + addDescription(null, tSecondaryDescription, aDamage, "_Secondary"); + } + addDescription(null, tMetaTileEntity.getDescription(), aDamage, ""); + } + } + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, + int ordinalSide, float hitX, float hitY, float hitZ) { + return false; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + final short tDamage = (short) getDamage(aStack); + if ((tDamage < 0) || (tDamage >= GregTechAPI.METATILEENTITIES.length)) { + return ""; + } + if (GregTechAPI.METATILEENTITIES[tDamage] != null) { + return getUnlocalizedName() + "." + GregTechAPI.METATILEENTITIES[tDamage].getMetaName(); + } + return ""; + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + final short aDamage = (short) getDamage(aStack); + if (aDamage >= 0 && aDamage < GregTechAPI.METATILEENTITIES.length + && GregTechAPI.METATILEENTITIES[aDamage] != null) { + Materials aMaterial = null; + if (GregTechAPI.METATILEENTITIES[aDamage] instanceof MTEItem) { + aMaterial = ((MTEItem) GregTechAPI.METATILEENTITIES[aDamage]).mMaterial; + } else if (GregTechAPI.METATILEENTITIES[aDamage] instanceof MTEFluid) { + aMaterial = ((MTEFluid) GregTechAPI.METATILEENTITIES[aDamage]).mMaterial; + } else if (GregTechAPI.METATILEENTITIES[aDamage] instanceof MTECable) { + aMaterial = ((MTECable) GregTechAPI.METATILEENTITIES[aDamage]).mMaterial; + } else if (GregTechAPI.METATILEENTITIES[aDamage] instanceof MTEFrame) { + aMaterial = ((MTEFrame) GregTechAPI.METATILEENTITIES[aDamage]).mMaterial; + } + if (aMaterial != null) { + aName = aMaterial.getLocalizedNameForItem(aName); + } + } + return aName; + } + + @Override + public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + super.onCreated(aStack, aWorld, aPlayer); + final short tDamage = (short) getDamage(aStack); + if ((tDamage < 0) + || ((tDamage >= GregTechAPI.METATILEENTITIES.length) && (GregTechAPI.METATILEENTITIES[tDamage] != null))) { + GregTechAPI.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer); + } + } + + @Override + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ, int aMeta) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + final short tDamage = (short) getDamage(aStack); + if (tDamage > 0) { + if (GregTechAPI.METATILEENTITIES[tDamage] == null) { + return false; + } + final int tMetaData = GregTechAPI.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 GTItsNotMyFaultException( + "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 GTItsNotMyFaultException( + "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."); + } + final 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.setOwnerUuid(aPlayer.getUniqueID()); + } + tTileEntity.getMetaTileEntity() + .initDefaultModes(aStack.getTagCompound()); + final ForgeDirection oppositeSide = side.getOpposite(); + if (tTileEntity.getMetaTileEntity() instanceof IConnectable connectable) { + // If we're connectable, try connecting to whatever we're up against + connectable.connect(oppositeSide); + } else if (aPlayer != null && aPlayer.isSneaking()) { + // If we're being placed against something that is connectable, try telling it to connect to us + final IGregTechTileEntity aTileEntity = tTileEntity.getIGregTechTileEntityAtSide(oppositeSide); + if (aTileEntity != null && aTileEntity.getMetaTileEntity() instanceof IConnectable connectable) { + connectable.connect(side); + } + } + } + } 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; + } + + @Override + public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) { + super.onUpdate(aStack, aWorld, aPlayer, aTimer, aIsInHand); + final short tDamage = (short) getDamage(aStack); + final EntityLivingBase tPlayer = (EntityPlayer) aPlayer; + if (GregTechAPI.METATILEENTITIES[tDamage] instanceof MTESuperChest + || GregTechAPI.METATILEENTITIES[tDamage] instanceof MTESuperTank) { + final NBTTagCompound tNBT = aStack.stackTagCompound; + if (tNBT == null) return; + if (tNBT.hasNoTags()) { + aStack.setTagCompound(null); + return; + } + if ((tNBT.hasKey("mItemCount") && tNBT.getInteger("mItemCount") > 0) || (tNBT.hasKey("mFluid") + && FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")).amount > 64000)) { + final FluidStack tFluid = FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")); + int tEffectDuration = 1200; + if (tFluid != null) { + final double tFluidAmount = tFluid.amount; + final double tMiddlePoint = 4096000; + final double tSmoothingCoefficient = 2000000; + final int tMaxDuration = 12000; + final double tmp = (tFluidAmount - tMiddlePoint) / tSmoothingCoefficient; + tEffectDuration = (int) (Math.exp(tmp) / (Math.exp(tmp) + Math.exp(-tmp)) * tMaxDuration); + } + tPlayer.addPotionEffect(new PotionEffect(Potion.hunger.id, tEffectDuration, 1)); + tPlayer.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, tEffectDuration, 1)); + tPlayer.addPotionEffect(new PotionEffect(Potion.digSlowdown.id, tEffectDuration, 1)); + tPlayer.addPotionEffect(new PotionEffect(Potion.weakness.id, tEffectDuration, 1)); + } + } + } + + @Override + public FluidStack getFluid(ItemStack container) { + if (container != null) { + final NBTTagCompound tNBT = container.stackTagCompound; + if (tNBT != null && tNBT.hasKey("mFluid", 10)) { + return FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")); + } + } + return null; + } + + @Override + public int getCapacity(ItemStack container) { + if (container != null) { + final int tDamage = container.getItemDamage(); + final IMetaTileEntity tMetaTile = GregTechAPI.METATILEENTITIES[tDamage]; + if (tMetaTile != null) return tMetaTile.getCapacity(); + } + return 0; + } + + @Nullable + private Fluid getLockedFluid(@Nonnull ItemStack container) { + final NBTTagCompound tag = container.stackTagCompound; + if (tag == null) return null; + String lockedName = tag.getString("lockedFluidName"); + if (GTUtility.isStringInvalid(lockedName)) return null; + return FluidRegistry.getFluid(lockedName); + } + + @Override + public int fill(ItemStack container, FluidStack resource, boolean doFill) { + if (container != null && resource != null) { + final int tDamage = container.getItemDamage(); + final IMetaTileEntity tMetaTile = GregTechAPI.METATILEENTITIES[tDamage]; + if (!(tMetaTile instanceof MTEDigitalTankBase)) { + return 0; + } + if (container.stackTagCompound == null) container.stackTagCompound = new NBTTagCompound(); + final FluidStack tStoredFluid = getFluid(container); + final int tCapacity = getCapacity(container); + if (tCapacity <= 0) return 0; + final Fluid lockedFluid = getLockedFluid(container); + if (lockedFluid != null && resource.getFluid() != lockedFluid) { + return 0; + } + if (tStoredFluid != null && tStoredFluid.isFluidEqual(resource)) { + final int tAmount = Math.min(tCapacity - tStoredFluid.amount, resource.amount); + if (doFill) { + final FluidStack tNewFluid = new FluidStack(tStoredFluid, tAmount + tStoredFluid.amount); + container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); + } + return tAmount; + } + if (tStoredFluid == null) { + final int tAmount = Math.min(tCapacity, resource.amount); + if (doFill) { + final FluidStack tNewFluid = new FluidStack(resource, tAmount); + container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); + } + return tAmount; + } + } + return 0; + } + + @Override + public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { + if (container != null && container.hasTagCompound()) { + final int tDamage = container.getItemDamage(); + final IMetaTileEntity tMetaTile = GregTechAPI.METATILEENTITIES[tDamage]; + if (!(tMetaTile instanceof MTEDigitalTankBase)) { + return null; + } + final FluidStack tStoredFluid = getFluid(container); + if (tStoredFluid != null) { + final int tAmount = Math.min(maxDrain, tStoredFluid.amount); + final FluidStack tNewFluid = new FluidStack(tStoredFluid, tStoredFluid.amount - tAmount); + final FluidStack tOutputFluid = new FluidStack(tStoredFluid, tAmount); + if (doDrain) { + if (tNewFluid.amount <= 0) { + container.stackTagCompound.removeTag("mFluid"); + if (container.stackTagCompound.hasNoTags()) container.setTagCompound(null); + } else { + container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); + } + } + return tOutputFluid; + } + } + return null; + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemOres.java b/src/main/java/gregtech/common/blocks/ItemOres.java new file mode 100644 index 0000000000..0691142bc3 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemOres.java @@ -0,0 +1,81 @@ +package gregtech.common.blocks; + +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.util.StatCollector; +import net.minecraft.world.World; + +import org.apache.commons.lang3.StringUtils; + +import gregtech.api.GregTechAPI; +import gregtech.api.enums.Materials; + +public class ItemOres extends ItemBlock { + + public ItemOres(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + } + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, + int ordinalSide, float hitX, float hitY, float hitZ) { + return false; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + if (this.field_150939_a instanceof BlockOresAbstract) { + aName = Materials.getLocalizedNameForItem(aName, aStack.getItemDamage() % 1000); + } + return aName; + } + + @Override + public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, 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, + TileEntityOres.getHarvestData( + tDamage, + ((BlockOresAbstract) field_150939_a).getBaseBlockHarvestLevel(aMeta % 16000 / 1000)), + 3)) { + return false; + } + TileEntityOres tTileEntity = (TileEntityOres) 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; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + String formula = StatCollector + .translateToLocal(field_150939_a.getUnlocalizedName() + '.' + getDamage(aStack) + ".tooltip"); + if (!StringUtils.isBlank(formula)) aList.add(formula); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemStonesAbstract.java b/src/main/java/gregtech/common/blocks/ItemStonesAbstract.java new file mode 100644 index 0000000000..b8f924b609 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemStonesAbstract.java @@ -0,0 +1,42 @@ +package gregtech.common.blocks; + +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 gregtech.api.GregTechAPI; +import gregtech.api.util.GTLanguageManager; + +public class ItemStonesAbstract extends ItemBlock { + + private final String mNoMobsToolTip = GTLanguageManager + .addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + + public ItemStonesAbstract(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + @Override + public int getMetadata(int aMeta) { + return aMeta; + } + + @Override + 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/ItemStorage.java b/src/main/java/gregtech/common/blocks/ItemStorage.java new file mode 100644 index 0000000000..6dd0a2a6b4 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemStorage.java @@ -0,0 +1,47 @@ +package gregtech.common.blocks; + +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 gregtech.api.GregTechAPI; + +public class ItemStorage extends ItemBlock { + + public ItemStorage(Block block) { + super(block); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTechAPI.TAB_GREGTECH_MATERIALS); + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + @Override + public String getItemStackDisplayName(ItemStack aStack) { + String aName = super.getItemStackDisplayName(aStack); + if (this.field_150939_a instanceof BlockMetal) { + int aDamage = aStack.getItemDamage(); + if (aDamage >= 0 && aDamage < ((BlockMetal) this.field_150939_a).mMats.length) { + aName = ((BlockMetal) this.field_150939_a).mMats[aDamage].getLocalizedNameForItem(aName); + } + } + return aName; + } + + @Override + public int getMetadata(int aMeta) { + return aMeta; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + } +} diff --git a/src/main/java/gregtech/common/blocks/ItemTintedIndustrialGlass.java b/src/main/java/gregtech/common/blocks/ItemTintedIndustrialGlass.java new file mode 100644 index 0000000000..bba737ad15 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/ItemTintedIndustrialGlass.java @@ -0,0 +1,10 @@ +package gregtech.common.blocks; + +import net.minecraft.block.Block; + +public class ItemTintedIndustrialGlass extends ItemCasingsAbstract { + + public ItemTintedIndustrialGlass(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/MaterialCasings.java b/src/main/java/gregtech/common/blocks/MaterialCasings.java new file mode 100644 index 0000000000..cde784d137 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/MaterialCasings.java @@ -0,0 +1,19 @@ +package gregtech.common.blocks; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; + +public class MaterialCasings extends Material { + + public static final Material INSTANCE = new MaterialCasings(); + + private MaterialCasings() { + super(MapColor.ironColor); + setRequiresTool(); + } + + @Override + public boolean isOpaque() { + return true; + } +} diff --git a/src/main/java/gregtech/common/blocks/MaterialMachines.java b/src/main/java/gregtech/common/blocks/MaterialMachines.java new file mode 100644 index 0000000000..311b72c764 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/MaterialMachines.java @@ -0,0 +1,19 @@ +package gregtech.common.blocks; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; + +public class MaterialMachines extends Material { + + public MaterialMachines() { + super(MapColor.ironColor); + setRequiresTool(); + setImmovableMobility(); + setAdventureModeExempt(); + } + + @Override + public boolean isOpaque() { + return true; + } +} diff --git a/src/main/java/gregtech/common/blocks/MaterialReinforced.java b/src/main/java/gregtech/common/blocks/MaterialReinforced.java new file mode 100644 index 0000000000..b5256d306d --- /dev/null +++ b/src/main/java/gregtech/common/blocks/MaterialReinforced.java @@ -0,0 +1,18 @@ +package gregtech.common.blocks; + +import net.minecraft.block.material.MapColor; +import net.minecraft.block.material.Material; + +public class MaterialReinforced extends Material { + + public MaterialReinforced() { + super(MapColor.stoneColor); + setRequiresTool(); + setAdventureModeExempt(); + } + + @Override + public boolean isOpaque() { + return true; + } +} diff --git a/src/main/java/gregtech/common/blocks/PacketOres.java b/src/main/java/gregtech/common/blocks/PacketOres.java new file mode 100644 index 0000000000..6548f8ae66 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/PacketOres.java @@ -0,0 +1,62 @@ +package gregtech.common.blocks; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; + +import com.google.common.io.ByteArrayDataInput; + +import gregtech.api.net.GTPacketNew; +import gregtech.api.net.GTPacketTypes; +import io.netty.buffer.ByteBuf; + +public class PacketOres extends GTPacketNew { + + private int mX; + private int mZ; + private short mY; + private short mMetaData; + + public PacketOres() { + super(true); + } + + public PacketOres(int aX, short aY, int aZ, short aMetaData) { + super(false); + this.mX = aX; + this.mY = aY; + this.mZ = aZ; + this.mMetaData = aMetaData; + } + + @Override + public void encode(ByteBuf aOut) { + aOut.writeInt(this.mX); + aOut.writeShort(this.mY); + aOut.writeInt(this.mZ); + aOut.writeShort(this.mMetaData); + } + + @Override + public GTPacketNew decode(ByteArrayDataInput aData) { + return new PacketOres(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort()); + } + + @Override + public void process(IBlockAccess aWorld) { + if (aWorld != null) { + TileEntity tTileEntity = aWorld.getTileEntity(this.mX, this.mY, this.mZ); + if ((tTileEntity instanceof TileEntityOres)) { + ((TileEntityOres) tTileEntity).mMetaData = this.mMetaData; + } + if (((aWorld instanceof World)) && (((World) aWorld).isRemote)) { + ((World) aWorld).markBlockForUpdate(this.mX, this.mY, this.mZ); + } + } + } + + @Override + public byte getPacketID() { + return GTPacketTypes.ORES.id; + } +} diff --git a/src/main/java/gregtech/common/blocks/TileEntityOres.java b/src/main/java/gregtech/common/blocks/TileEntityOres.java new file mode 100644 index 0000000000..9ddcbcc19c --- /dev/null +++ b/src/main/java/gregtech/common/blocks/TileEntityOres.java @@ -0,0 +1,482 @@ +package gregtech.common.blocks; + +import static gregtech.api.enums.TextureSet.SET_NONE; + +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; + +import org.jetbrains.annotations.NotNull; + +import gregtech.GTMod; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IAllSidedTexturedTileEntity; +import gregtech.api.objects.XSTR; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public class TileEntityOres extends TileEntity implements IAllSidedTexturedTileEntity { + + public short mMetaData = 0; + protected static boolean shouldFortune = false; + protected static boolean shouldSilkTouch = false; + public boolean mNatural = false; + public boolean mBlocked = true; + public boolean mBlockedChecked = false; + private short mMetadataForCachedTexture = -1; + private ITexture[] mCachedTexture; + + public static byte getHarvestData(short aMetaData, int aBaseBlockHarvestLevel) { + Materials aMaterial = GregTechAPI.sGeneratedMaterials[(aMetaData % 1000)]; + byte tByte = aMaterial == null ? 0 + : (byte) Math + .max(aBaseBlockHarvestLevel, Math.min(7, aMaterial.mToolQuality - (aMetaData < 16000 ? 0 : 1))); + if (GTMod.gregtechproxy.mChangeHarvestLevels) { + tByte = aMaterial == null ? 0 + : (byte) Math.max( + aBaseBlockHarvestLevel, + Math.min( + GTMod.gregtechproxy.mMaxHarvestLevel, + GTMod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] - (aMetaData < 16000 ? 0 : 1))); + } + return tByte; + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre) { + return setOreBlock(aWorld, aX, aY, aZ, aMetaData, isSmallOre, true); + } + + public static boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int aMetaData, boolean isSmallOre, + boolean air) { + if (!air) { + aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1)); + } + Block tBlock = aWorld.getBlock(aX, aY, aZ); + Block tOreBlock = GregTechAPI.sBlockOres1; + int BlockMeta = aWorld.getBlockMetadata(aX, aY, aZ); + String BlockName = tBlock.getUnlocalizedName(); + aMetaData += isSmallOre ? 16000 : 0; + if ((aMetaData > 0) && ((tBlock != Blocks.air) || air)) { + if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) { + // Do nothing, stone background is default background. + // Do this comparison first since stone is most common + } else 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, GregTechAPI.sBlockGranites)) { + if (tBlock == GregTechAPI.sBlockGranites) { + if (aWorld.getBlockMetadata(aX, aY, aZ) < 8) { + aMetaData += 3000; + } else { + aMetaData += 4000; + } + } else { + aMetaData += 3000; + } + } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTechAPI.sBlockStones)) { + if (tBlock == GregTechAPI.sBlockStones) { + if (aWorld.getBlockMetadata(aX, aY, aZ) < 8) { + aMetaData += 5000; + } else { + aMetaData += 6000; + } + } else { + aMetaData += 5000; + } + } else if (BlockName.equals("tile.igneousStone")) { + if (GregTechAPI.sBlockOresUb1 != null) { + tOreBlock = GregTechAPI.sBlockOresUb1; + aMetaData += (BlockMeta * 1000); + // GT_FML_LOGGER.info("Block changed to UB1"); + } + } else if (BlockName.equals("tile.metamorphicStone")) { + if (GregTechAPI.sBlockOresUb2 != null) { + tOreBlock = GregTechAPI.sBlockOresUb2; + aMetaData += (BlockMeta * 1000); + // GT_FML_LOGGER.info("Block changed to UB2"); + } + } else if (BlockName.equals("tile.sedimentaryStone")) { + if (GregTechAPI.sBlockOresUb3 != null) { + tOreBlock = GregTechAPI.sBlockOresUb3; + aMetaData += (BlockMeta * 1000); + // GT_FML_LOGGER.info("Block changed to UB3"); + } + } else { + return false; + } + // GT_FML_LOGGER.info(tOreBlock); + aWorld.setBlock( + aX, + aY, + aZ, + tOreBlock, + getHarvestData( + (short) aMetaData, + ((BlockOresAbstract) tOreBlock).getBaseBlockHarvestLevel(aMetaData % 16000 / 1000)), + 0); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof TileEntityOres)) { + ((TileEntityOres) tTileEntity).mMetaData = ((short) aMetaData); + ((TileEntityOres) tTileEntity).mNatural = true; + } + return true; + } + return false; + } + + @Override + public void readFromNBT(NBTTagCompound aNBT) { + super.readFromNBT(aNBT); + this.mMetaData = aNBT.getShort("m"); + this.mNatural = aNBT.getBoolean("n"); + } + + @Override + 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; + GTValues.NW.sendPacketToAllPlayersInRange( + this.worldObj, + new PacketOres(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), + this.xCoord, + this.zCoord); + } + } + + @Override + public Packet getDescriptionPacket() { + if (!this.worldObj.isRemote) { + boolean sendUpdate = mBlockedChecked ? !mBlocked : checkBlocked(); + if (sendUpdate) { + GTValues.NW.sendPacketToAllPlayersInRange( + this.worldObj, + new PacketOres(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), + this.xCoord, + this.zCoord); + } + } + return null; + } + + private boolean checkBlocked() { + // this is called very frequently and is performance critical. unroll the loop. + mBlockedChecked = true; + if (!worldObj.blockExists(xCoord + 1, yCoord, zCoord)) { + mBlockedChecked = false; + } else if (!GTUtility.isOpaqueBlock(worldObj, xCoord + 1, yCoord, zCoord)) { + mBlocked = false; + return true; + } + if (!worldObj.blockExists(xCoord - 1, yCoord, zCoord)) { + mBlockedChecked = false; + } else if (!GTUtility.isOpaqueBlock(worldObj, xCoord - 1, yCoord, zCoord)) { + mBlocked = false; + return true; + } + if (!worldObj.blockExists(xCoord, yCoord + 1, zCoord)) { + mBlockedChecked = false; + } else if (!GTUtility.isOpaqueBlock(worldObj, xCoord, yCoord + 1, zCoord)) { + mBlocked = false; + return true; + } + if (!worldObj.blockExists(xCoord, yCoord - 1, zCoord)) { + mBlockedChecked = false; + } else if (!GTUtility.isOpaqueBlock(worldObj, xCoord, yCoord - 1, zCoord)) { + mBlocked = false; + return true; + } + if (!worldObj.blockExists(xCoord, yCoord, zCoord + 1)) { + mBlockedChecked = false; + } else if (!GTUtility.isOpaqueBlock(worldObj, xCoord, yCoord, zCoord + 1)) { + mBlocked = false; + return true; + } + if (!worldObj.blockExists(xCoord, yCoord, zCoord - 1)) { + mBlockedChecked = false; + } else if (!GTUtility.isOpaqueBlock(worldObj, xCoord, yCoord, zCoord - 1)) { + mBlocked = false; + return true; + } + mBlocked = true; + return false; + } + + public void overrideOreBlockMaterial(Block aOverridingStoneBlock, byte aOverridingStoneMeta) { + if (this.worldObj == null || blockType == null) return; + this.mMetaData = ((short) (int) (this.mMetaData % 1000L + this.mMetaData / 16000L * 16000L)); + if (aOverridingStoneBlock + .isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.netherrack)) { + this.mMetaData = ((short) (this.mMetaData + 1000)); + } 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, + GregTechAPI.sBlockGranites)) { + if (aOverridingStoneBlock == GregTechAPI.sBlockGranites) { + if (aOverridingStoneMeta < 8) { + this.mMetaData = ((short) (this.mMetaData + 3000)); + } else { + this.mMetaData = ((short) (this.mMetaData + 4000)); + } + } else { + this.mMetaData = ((short) (this.mMetaData + 3000)); + } + } else if (aOverridingStoneBlock.isReplaceableOreGen( + this.worldObj, + this.xCoord, + this.yCoord, + this.zCoord, + GregTechAPI.sBlockStones)) { + if (aOverridingStoneBlock == GregTechAPI.sBlockStones) { + if (aOverridingStoneMeta < 8) { + this.mMetaData = ((short) (this.mMetaData + 5000)); + } else { + this.mMetaData = ((short) (this.mMetaData + 6000)); + } + } else { + this.mMetaData = ((short) (this.mMetaData + 5000)); + } + } + this.worldObj.setBlockMetadataWithNotify( + this.xCoord, + this.yCoord, + this.zCoord, + getHarvestData( + this.mMetaData, + ((BlockOresAbstract) blockType).getBaseBlockHarvestLevel(mMetaData % 16000 / 1000)), + 0); + } + + public void convertOreBlock(World aWorld, int aX, int aY, int aZ) { + short aMeta = ((short) (this.mMetaData % 1000 + (this.mMetaData / 16000 * 16000))); + aWorld.setBlock(aX, aY, aZ, GregTechAPI.sBlockOres1); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof TileEntityOres) { + ((TileEntityOres) tTileEntity).mMetaData = aMeta; + this.worldObj.setBlockMetadataWithNotify( + this.xCoord, + this.yCoord, + this.zCoord, + getHarvestData( + aMeta, + ((BlockOresAbstract) tTileEntity.blockType).getBaseBlockHarvestLevel(aMeta % 16000 / 1000)), + 0); + } + } + + public short getMetaData() { + return this.mMetaData; + } + + @Override + public boolean canUpdate() { + return false; + } + + public ArrayList getDrops(Block aDroppedOre, int aFortune) { + ArrayList rList = new ArrayList<>(); + if (this.mMetaData <= 0) { + rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); + return rList; + } + Materials aOreMaterial = GregTechAPI.sGeneratedMaterials[(this.mMetaData % 1000)]; + if (this.mMetaData < 16000) { + boolean tIsRich = false; + + // For Sake of god of balance! + + // Dense ore + + // NetherOre + if (GTMod.gregtechproxy.mNetherOreYieldMultiplier && !tIsRich) { + tIsRich = (this.mMetaData >= 1000 && this.mMetaData < 2000); + } + // EndOre + if (GTMod.gregtechproxy.mEndOreYieldMultiplier && !tIsRich) { + tIsRich = (this.mMetaData >= 2000 && this.mMetaData < 3000); + } + + // Silk Touch + if (shouldSilkTouch) { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + + } else { + switch (GTMod.gregtechproxy.oreDropSystem) { + case Item -> { + rList.add(GTOreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, (tIsRich ? 2 : 1))); + } + // TODO: Test + case FortuneItem -> { + // if shouldFortune and isNatural then get fortune drops + // if not shouldFortune or not isNatural then get normal drops + // if not shouldFortune and isNatural then get normal drops + // if shouldFortune and not isNatural then get normal drops + if (shouldFortune && this.mNatural && aFortune > 0) { + int aMinAmount = 1; + // Max applicable fortune + if (aFortune > 3) aFortune = 3; + int amount = aMinAmount + + Math.max(worldObj.rand.nextInt(aFortune * (tIsRich ? 2 : 1) + 2) - 1, 0); + for (int i = 0; i < amount; i++) { + rList.add(GTOreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } else { + for (int i = 0; i < (tIsRich ? 2 : 1); i++) { + rList.add(GTOreDictUnificator.get(OrePrefixes.rawOre, aOreMaterial, 1)); + } + } + } + case UnifiedBlock -> { + // Unified ore + for (int i = 0; i < (tIsRich ? 2 : 1); i++) { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData % 1000)); + } + } + case PerDimBlock -> { + // Per Dimension ore + if (tIsRich) { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + } else { + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData % 1000)); + } + } + case Block -> { + // Regular ore + rList.add(new ItemStack(aDroppedOre, 1, this.mMetaData)); + } + } + } + return rList; + } + + // Everyone gets a free small fortune boost + aFortune += 1; + if (!this.mNatural) { + aFortune = 0; + } + if (aOreMaterial != null) { + Random tRandom = new XSTR(this.xCoord ^ this.yCoord ^ this.zCoord); + ArrayList tSelector = new ArrayList<>(); + + Materials aMaterial = aOreMaterial.mOreReplacement; + + ItemStack tStack = GTOreDictUnificator + .get(OrePrefixes.gemExquisite, aMaterial, GTOreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 1; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator + .get(OrePrefixes.gemFlawless, aMaterial, GTOreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 2; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 12; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator + .get(OrePrefixes.gemFlawed, aMaterial, GTOreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L), 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get(OrePrefixes.crushed, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get( + OrePrefixes.gemChipped, + aMaterial, + GTOreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L), + 1L); + if (tStack != null) { + for (int i = 0; i < 5; i++) { + tSelector.add(tStack); + } + } + tStack = GTOreDictUnificator.get(OrePrefixes.dustImpure, aMaterial, 1L); + if (tStack != null) { + for (int i = 0; i < 10; i++) { + tSelector.add(tStack); + } + } + if (!tSelector.isEmpty()) { + 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(GTUtility.copyAmount(1, tSelector.get(tRandom.nextInt(tSelector.size())))); + } + } + if (tRandom.nextInt(3 + aFortune) > 1) { + Materials dustMat = ((BlockOresAbstract) aDroppedOre).getDroppedDusts()[this.mMetaData / 1000 % 16]; + if (dustMat != null) rList.add( + GTOreDictUnificator + .get(tRandom.nextInt(3) > 0 ? OrePrefixes.dustImpure : OrePrefixes.dust, dustMat, 1L)); + } + } + return rList; + } + + @Override + public ITexture[] getTexture(Block aBlock) { + if (mMetadataForCachedTexture == mMetaData && mCachedTexture != null) return mCachedTexture; + + mMetadataForCachedTexture = mMetaData; + mCachedTexture = getTextureInternal(aBlock); + return mCachedTexture; + } + + private ITexture @NotNull [] getTextureInternal(Block aBlock) { + Materials aMaterial = GregTechAPI.sGeneratedMaterials[(this.mMetaData % 1000)]; + if ((aMaterial != null) && (this.mMetaData < 32000) && (aBlock instanceof BlockOresAbstract)) { + ITexture iTexture = TextureFactory.builder() + .addIcon( + aMaterial.mIconSet.mTextures[this.mMetaData / 16000 == 0 ? OrePrefixes.ore.mTextureIndex + : OrePrefixes.oreSmall.mTextureIndex]) + .setRGBA(aMaterial.mRGBa) + .stdOrient() + .build(); + return new ITexture[] { ((BlockOresAbstract) aBlock).getTextureSet()[((this.mMetaData / 1000) % 16)], + iTexture }; + } + return new ITexture[] { TextureFactory.of(Blocks.stone, 0), TextureFactory.builder() + .addIcon(SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex]) + .stdOrient() + .build() }; + } +} -- cgit