diff options
Diffstat (limited to 'src/main/java/gregtech/common/blocks')
43 files changed, 5105 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java new file mode 100644 index 0000000000..897011eba9 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java @@ -0,0 +1,108 @@ +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_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java new file mode 100644 index 0000000000..f1fbc30236 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.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.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 new file mode 100644 index 0000000000..ada77814c8 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.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.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 new file mode 100644 index 0000000000..49c9c6c992 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -0,0 +1,250 @@ +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. + * <p> + * 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, 12 -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); + case 1, 10 -> Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); + case 2, 11 -> 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 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) { + return switch (meta) { + case 10 -> active ? Textures.BlockIcons.TURBINE_ACTIVE1[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE1[iconIndex].getIcon(); + case 11 -> active ? Textures.BlockIcons.TURBINE_ACTIVE2[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE2[iconIndex].getIcon(); + case 12 -> active ? Textures.BlockIcons.TURBINE_ACTIVE3[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE3[iconIndex].getIcon(); + default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE[iconIndex].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_CLEAN_STAINLESSSTEEL.getIcon(); + case 11 -> Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); + case 12 -> Textures.BlockIcons.MACHINE_CASING_ROBUST_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 new file mode 100644 index 0000000000..3a9efdbe71 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -0,0 +1,159 @@ +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)); + } + + @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(); + 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<IHeatingCoil> callback = coil -> {}; + + @Override + public void setOnCoilCheck(Consumer<IHeatingCoil> callback) { + this.callback = callback; + } + + @Override + public Consumer<IHeatingCoil> 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 new file mode 100644 index 0000000000..9bdbf256cc --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.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.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 new file mode 100644 index 0000000000..fdef0def82 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java @@ -0,0 +1,199 @@ +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(); + }; + } + + @Deprecated + public IIcon getTurbineCasing(int meta, int iconIndex, boolean active) { + // noinspection SwitchStatementWithTooFewBranches // "if" is harder to edit + return switch (meta) { + case 9 -> active ? Textures.BlockIcons.TURBINE_ADVGASACTIVE[iconIndex].getIcon() + : Textures.BlockIcons.TURBINEADVGAS[iconIndex].getIcon(); + default -> active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() + : Textures.BlockIcons.TURBINE[iconIndex].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 new file mode 100644 index 0000000000..bc6aca6255 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java @@ -0,0 +1,43 @@ +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, 2); + 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"); + + ItemList.Casing_Pipe_Polybenzimidazole.set(new ItemStack(this, 1, 0)); + ItemList.Casing_Vent_T2.set(new ItemStack(this, 1, 1)); + } + + @Override + public int getTextureIndex(int aMeta) { + return (1 << 7) | (aMeta + 64); + } + + @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(); + 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 new file mode 100644 index 0000000000..59144666df --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java @@ -0,0 +1,144 @@ +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<? extends ItemBlock> aItemClass, String aName, Material aMaterial) { + super(aItemClass, aName, aMaterial); + setStepSound(soundTypeMetal); + setCreativeTab(GregTech_API.TAB_GREGTECH); + GregTech_API.registerMachineBlock(this, -1); + GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); + } + + public GT_Block_Casings_Abstract(Class<? extends ItemBlock> 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, aWorld.getBlockMetadata(aX, aY, aZ))) { + 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<ItemStack> 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 new file mode 100644 index 0000000000..c7b7e2bb04 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.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.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 new file mode 100644 index 0000000000..81d1acc228 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Drone.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.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<ItemStack> 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_Granites.java b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java new file mode 100644 index 0000000000..69ebc2e733 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Granites.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.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_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java new file mode 100644 index 0000000000..3d24799746 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -0,0 +1,703 @@ +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.metatileentity.IMetaTileEntity; +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; + +@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<IGregTechTileEntity> 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 CoverableTileEntity cte && cte.getCoverInfoAtSide(forgeSide) + .getCoverID() != 0; + } + + @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<AxisAlignedBB> 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 (IMetaTileEntity tMetaTileEntity : GregTech_API.METATILEENTITIES) { + if (tMetaTileEntity != null) { + tMetaTileEntity.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<ItemStack> 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<ItemStack> 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<ItemStack> 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<String> 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 new file mode 100644 index 0000000000..753c590e51 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Metal.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.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 new file mode 100644 index 0000000000..015baa2319 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.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.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 new file mode 100644 index 0000000000..8e68c5c39a --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.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.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<GT_TileEntity_Ores> mTemporaryTileEntity = new ThreadLocal<>(); + public static boolean FUCKING_LOCK = false; + public static boolean tHideOres; + public static Set<Materials> 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<ItemStack> 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<ItemStack> 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 new file mode 100644 index 0000000000..a78fe5b70d --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.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.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<ItemStack> 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 new file mode 100644 index 0000000000..4ca52aee56 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones.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.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 new file mode 100644 index 0000000000..4a5bb9456e --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.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.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<? extends ItemBlock> 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<ItemStack> 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 new file mode 100644 index 0000000000..ada3f01cde --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Block_Storage.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.GregTech_API; +import gregtech.api.items.GT_Generic_Block; + +public class GT_Block_Storage extends GT_Generic_Block { + + protected GT_Block_Storage(Class<? extends ItemBlock> 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<ItemStack> 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_Cyclotron_Coils.java b/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java new file mode 100644 index 0000000000..1a544f027f --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Cyclotron_Coils.java @@ -0,0 +1,127 @@ +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 // Magic numbers... + public int getTextureIndex(int aMeta) { + return 192 + 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(); + } + + @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 new file mode 100644 index 0000000000..f1ca45a805 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Cyclotron_Item_Casings.java @@ -0,0 +1,10 @@ +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_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java new file mode 100644 index 0000000000..1a86a2e534 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.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 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_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java new file mode 100644 index 0000000000..f98c169c7f --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.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 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<String> 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 new file mode 100644 index 0000000000..861774d96f --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings3.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 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 new file mode 100644 index 0000000000..e2badca2cb --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.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 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 new file mode 100644 index 0000000000..3b3ab68cb1 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.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.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<String> 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 new file mode 100644 index 0000000000..af533acfa8 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings6.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 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 new file mode 100644 index 0000000000..e3f3bbdf97 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings8.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 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 new file mode 100644 index 0000000000..678a2424be --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings9.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 GT_Item_Casings9 extends GT_Item_Casings_Abstract { + + public GT_Item_Casings9(Block block) { + super(block); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java new file mode 100644 index 0000000000..46b0aba237 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.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.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<String> aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + aList.add(this.mNoMobsToolTip); + aList.add(this.mNoTileEntityToolTip); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java new file mode 100644 index 0000000000..44c094aa41 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Concretes.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.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<String> aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + aList.add(this.mRunFasterToolTip); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Granites.java b/src/main/java/gregtech/common/blocks/GT_Item_Granites.java new file mode 100644 index 0000000000..6e3eb8f12c --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Granites.java @@ -0,0 +1,10 @@ +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 new file mode 100644 index 0000000000..52d0db5165 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.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.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<String> 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 new file mode 100644 index 0000000000..059a3fda94 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -0,0 +1,430 @@ +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<String> 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<String> 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 new file mode 100644 index 0000000000..2ba78572b3 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Ores.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.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<String> 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 new file mode 100644 index 0000000000..5b73108301 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.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.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<String> 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 new file mode 100644 index 0000000000..4ac1b9cdfd --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_Storage.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.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<String> aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Casings.java b/src/main/java/gregtech/common/blocks/GT_Material_Casings.java new file mode 100644 index 0000000000..2fc839768f --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Material_Casings.java @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000..df8b57226c --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Material_Machines.java @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000..2e3301bb60 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java @@ -0,0 +1,18 @@ +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 new file mode 100644 index 0000000000..d7ab28a19e --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java @@ -0,0 +1,61 @@ +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_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 3; + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java new file mode 100644 index 0000000000..f3d247a265 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java @@ -0,0 +1,485 @@ +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<ItemStack> getDrops(Block aDroppedOre, int aFortune) { + ArrayList<ItemStack> 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; + long amount = (long) new Random().nextInt(aFortune * (tIsRich ? 2 : 1)) + aMinAmount; + 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<ItemStack> 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() }; + } +} |