diff options
author | Kiwi <42833050+Kiwi233@users.noreply.github.com> | 2021-07-05 22:06:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-05 22:06:44 +0800 |
commit | 4eaefbb5455dc3402b43dcbf6cba208cea4e301a (patch) | |
tree | b7e34b2e20af663cdd72c616fd7424301304e3e4 /src/main/java/gregtech/common/blocks | |
parent | 36406947fc5c0de1ee71da2644ec057b5fbc8d25 (diff) | |
parent | 703a8930bee25b1f908e9c4ea4f52cef24337d03 (diff) | |
download | GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.tar.gz GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.tar.bz2 GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.zip |
Merge pull request #3 from GTNewHorizons/experimental
gregtech-5.09.35.00
Diffstat (limited to 'src/main/java/gregtech/common/blocks')
41 files changed, 683 insertions, 374 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 index eb7c399eb0..2f8e248117 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java @@ -2,14 +2,13 @@ package gregtech.common.blocks; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -public class GT_Block_Casings1 - extends GT_Block_Casings_Abstract { +public class GT_Block_Casings1 extends GT_Block_Casings_Abstract { /** * Texture Index Information @@ -28,8 +27,8 @@ public class GT_Block_Casings1 public GT_Block_Casings1() { super(GT_Item_Casings1.class, "gt.blockcasings", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[0][i] = new GT_CopiedBlockTexture(this, 6, i); + for (int i = 0; i < 16; i++) { + Textures.BlockIcons.casingTexturePages[0][i] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "ULV Machine Casing"); @@ -66,6 +65,7 @@ public class GT_Block_Casings1 ItemList.Casing_Coil_Superconductor.set(new ItemStack(this, 1, 15)); } + @Override public IIcon getIcon(int aSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { @@ -93,6 +93,7 @@ public class GT_Block_Casings1 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 index 6da2195921..f4f478b7be 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java @@ -3,7 +3,7 @@ package gregtech.common.blocks; import gregtech.api.enums.Dyes; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import net.minecraft.block.Block; import net.minecraft.entity.Entity; @@ -11,18 +11,18 @@ 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; -public class GT_Block_Casings2 - extends GT_Block_Casings_Abstract { +public class GT_Block_Casings2 extends GT_Block_Casings_Abstract { public GT_Block_Casings2() { super(GT_Item_Casings2.class, "gt.blockcasings2", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - if (i != 6){ - Textures.BlockIcons.casingTexturePages[0][(i + 16)] = new GT_CopiedBlockTexture(this, 6, i); - } - } + for (int i = 0; i < 16; i++) { + if (i != 6) { + Textures.BlockIcons.casingTexturePages[0][(i + 16)] = TextureFactory.of(this, i); + } + } //Special handler for Pyrolyse Oven Casing on hatches... - Textures.BlockIcons.casingTexturePages[0][22] = new GT_CopiedBlockTexture(Block.getBlockFromItem(ItemList.Casing_ULV.get(1).getItem()), 6, 0,Dyes.MACHINE_METAL.mRGBa); + 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"); @@ -59,6 +59,7 @@ public class GT_Block_Casings2 } + @Override public IIcon getIcon(int aSide, int aMeta) { switch (aMeta) { case 0: @@ -97,6 +98,7 @@ public class GT_Block_Casings2 return 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 index fde793522a..81be342822 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java @@ -2,17 +2,16 @@ package gregtech.common.blocks; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class GT_Block_Casings3 - extends GT_Block_Casings_Abstract { +public class GT_Block_Casings3 extends GT_Block_Casings_Abstract { public GT_Block_Casings3() { super(GT_Item_Casings3.class, "gt.blockcasings3", GT_Material_Casings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[0][(i + 32)] = new GT_CopiedBlockTexture(this, 6, i); + Textures.BlockIcons.casingTexturePages[0][(i + 32)] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Yellow Stripes Block"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Yellow Stripes Block"); @@ -48,6 +47,7 @@ public class GT_Block_Casings3 ItemList.Casing_Firebox_TungstenSteel.set(new ItemStack(this, 1, 15)); } + @Override public IIcon getIcon(int aSide, int aMeta) { switch (aMeta) { case 0: diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java index 0dbf5e9f54..6fb40784c1 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -6,7 +6,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_LargeTurbine; import net.minecraft.item.ItemStack; @@ -14,14 +14,13 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -public class GT_Block_Casings4 - extends GT_Block_Casings_Abstract { +public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { public static boolean mConnectedMachineTextures = true; public GT_Block_Casings4() { super(GT_Item_Casings4.class, "gt.blockcasings4", GT_Material_Casings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[0][(i + 48)] = new GT_CopiedBlockTexture(this, 6, i); + Textures.BlockIcons.casingTexturePages[0][(i + 48)] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Robust Tungstensteel Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Machine Casing"); @@ -56,6 +55,7 @@ public class GT_Block_Casings4 ItemList.Casing_Firebricks.set(new ItemStack(this, 1, 15)); } + @Override public IIcon getIcon(int aSide, int aMeta) { switch (aMeta) { case 0: @@ -111,6 +111,7 @@ public class GT_Block_Casings4 } } + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java index 55492c961c..296bf765b0 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -2,20 +2,25 @@ package gregtech.common.blocks; 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.objects.GT_CopiedBlockTexture; +import gregtech.api.interfaces.IHeatingCoil; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_Utility; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class GT_Block_Casings5 - extends GT_Block_Casings_Abstract { +import java.util.function.Consumer; + +import static gregtech.api.enums.HeatingCoilLevel.*; + +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); for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[1][i] = new GT_CopiedBlockTexture(this, 6, i); + Textures.BlockIcons.casingTexturePages[1][i] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Cupronickel Coil Block"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Kanthal Coil Block"); @@ -26,6 +31,8 @@ public class GT_Block_Casings5 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"); ItemList.Casing_Coil_Cupronickel.set(new ItemStack(this, 1, 0)); ItemList.Casing_Coil_Kanthal.set(new ItemStack(this, 1, 1)); @@ -36,7 +43,10 @@ public class GT_Block_Casings5 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)); } + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int aSide, int aMeta) { @@ -59,7 +69,62 @@ public class GT_Block_Casings5 return Textures.BlockIcons.MACHINE_COIL_ELECTRUMFLUX.getIcon(); case 8: return Textures.BlockIcons.MACHINE_COIL_AWAKENEDDRACONIUM.getIcon(); + case 9: + return Textures.BlockIcons.MACHINE_COIL_HSSS.getIcon(); + case 10: + return Textures.BlockIcons.MACHINE_COIL_TRINIUM.getIcon(); } return Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); } + + /*--------------- COIL CHECK IMPL. ------------*/ + + public static HeatingCoilLevel getCoilHeatFromDamage(int meta) { + switch (meta) { + case 0: + return LV; + case 1: + return MV; + case 2: + return HV; + case 3: + return EV; + case 4: + return IV; + case 5: + return ZPM; + case 6: + return UV; + case 7: + return UEV; + case 8: + return UIV; + case 9: + return LuV; + case 10: + return UHV; + default: + return None; + } + } + + @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 index d7e8ad23f0..96b7890fd7 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java @@ -4,18 +4,17 @@ 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.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; -public class GT_Block_Casings6 - extends GT_Block_Casings_Abstract { +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); for (int i = 0; i < 16; i = (i + 1)) { - Textures.BlockIcons.casingTexturePages[8][i + 112] = new GT_CopiedBlockTexture(this, 6, i); + Textures.BlockIcons.casingTexturePages[8][i + 112] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Hermetic Casing"); @@ -97,6 +96,7 @@ public class GT_Block_Casings6 } } + @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 index 0f3aac4518..bb151afafa 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java @@ -4,19 +4,18 @@ 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.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class GT_Block_Casings8 - extends GT_Block_Casings_Abstract { +public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { //WATCH OUT FOR TEXTURE ID's public GT_Block_Casings8() { super(GT_Item_Casings8.class, "gt.blockcasings8", GT_Material_Casings.INSTANCE); for (int i = 0; i < 5; i = (i + 1)) { - Textures.BlockIcons.casingTexturePages[1][i+48] = new GT_CopiedBlockTexture(this, 6, i); + Textures.BlockIcons.casingTexturePages[1][i+48] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Chemically Inert Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "PTFE Pipe Casing"); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java index 830a407777..49f15e328c 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings_Abstract.java @@ -22,8 +22,7 @@ import net.minecraft.world.World; import java.util.List; import java.util.Random; -public abstract class GT_Block_Casings_Abstract - extends GT_Generic_Block { +public abstract class GT_Block_Casings_Abstract extends GT_Generic_Block { public GT_Block_Casings_Abstract(Class<? extends ItemBlock> aItemClass, String aName, Material aMaterial) { super(aItemClass, aName, aMaterial); setStepSound(soundTypeMetal); @@ -32,86 +31,106 @@ public abstract class GT_Block_Casings_Abstract GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + 32767 + ".name", "Any Sub Block of this"); } + @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 boolean renderAsNormalBlock() { return true; } + @Override public boolean isOpaqueCube() { 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 par1) { return par1; } + @Override public int getDamageValue(World par1World, int par2, int par3, int par4) { return par1World.getBlockMetadata(par2, par3, par4); } + @Override public int quantityDropped(Random par1Random) { return 1; } + @Override public Item getItemDropped(int par1, Random par2Random, int par3) { return Item.getItemFromBlock(this); } + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister aIconRegister) { } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { for (int i = 0; i < 16; i++) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java index 7bd4398ed7..0c98bab9c0 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java @@ -11,8 +11,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class GT_Block_Concretes - extends GT_Block_Stones_Abstract implements IBlockOnWalkOver{ +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); @@ -51,14 +50,17 @@ public class GT_Block_Concretes 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 aSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.CONCRETES[aMeta].getIcon(); @@ -73,29 +75,4 @@ public class GT_Block_Concretes aEntity.motionX *= tSpeed; aEntity.motionZ *= tSpeed; } } - - /** - public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity aEntity) { - Block tBlock = aWorld.getBlock(aX, aY + 1, aZ); - if (((aEntity instanceof EntityLivingBase)) && (!(tBlock instanceof IFluidBlock)) && (!(tBlock instanceof BlockLiquid)) && (aEntity.onGround) && (!aEntity.isInWater()) && (!aEntity.isWet())) { - if (aEntity.isSneaking()) { - aEntity.motionX *= 0.8999999761581421D; - aEntity.motionZ *= 0.8999999761581421D; - } else { - if (aEntity.motionX < 6.0 && aEntity.motionZ < 6.0) { - aEntity.motionX *= 1.100000023841858D; - aEntity.motionZ *= 1.100000023841858D; - } - } - } - } - - public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - Block tBlock = aWorld.getBlock(aX, aY + 1, aZ); - if (((tBlock instanceof IFluidBlock)) || ((tBlock instanceof BlockLiquid))) { - return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); - } - return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 0.875D, aZ + 1); - } - **/ } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java index 39d68ce933..5c98c18920 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java @@ -12,8 +12,7 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class GT_Block_Granites - extends GT_Block_Stones_Abstract { +public class GT_Block_Granites extends GT_Block_Stones_Abstract { public GT_Block_Granites() { super(GT_Item_Granites.class, "gt.blockgranites"); setResistance(60.0F); @@ -51,14 +50,17 @@ public class GT_Block_Granites 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 aSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); @@ -66,6 +68,7 @@ public class GT_Block_Granites 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 index 0b0d065789..0d673a020e 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -39,15 +39,15 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; -public class GT_Block_Machines - extends GT_Generic_Block - implements IDebugableBlock, ITileEntityProvider { - public static ThreadLocal<IGregTechTileEntity> mTemporaryTileEntity = new ThreadLocal(); +public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlock, ITileEntityProvider { + 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()); @@ -57,8 +57,11 @@ public class GT_Block_Machines 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"; @@ -66,14 +69,17 @@ public class GT_Block_Machines 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) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof BaseTileEntity)) { @@ -81,6 +87,7 @@ public class GT_Block_Machines } } + @Override public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof BaseMetaPipeEntity)) { @@ -88,6 +95,7 @@ public class GT_Block_Machines } } + @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))) { @@ -95,22 +103,27 @@ public class GT_Block_Machines } } + @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; + 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(); @@ -118,80 +131,109 @@ public class GT_Block_Machines 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); + 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); + 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 var1, int var2, int var3, int var4, int var5) { return true; } + @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 false; + 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 aSide) { return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); } + @SideOnly(Side.CLIENT) + @Override public IIcon getIcon(int aSide, 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); TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return tTileEntity != null ? tTileEntity.receiveClientEvent(aData1, aData2) : false; + return tTileEntity != null && tTileEntity.receiveClientEvent(aData1, aData2); } - public void addCollisionBoxesToList(World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { + @SuppressWarnings("unchecked") // Old API uses raw List type + @Override + public void addCollisionBoxesToList( + World aWorld, int aX, int aY, int aZ, AxisAlignedBB inputAABB, List outputAABB, Entity collider) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - ((IGregTechTileEntity) tTileEntity).addCollisionBoxesToList(aWorld, aX, aY, aZ, inputAABB, outputAABB, collider); + 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) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { + if (tTileEntity instanceof IGregTechTileEntity && + ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } return super.getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -199,10 +241,10 @@ public class GT_Block_Machines @Override @SideOnly(Side.CLIENT) - public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) - { + public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { + if (tTileEntity instanceof IGregTechTileEntity && + ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); } return super.getSelectedBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -211,27 +253,32 @@ public class GT_Block_Machines @Override //THIS public void setBlockBoundsBasedOnState(IBlockAccess blockAccess, int aX, int aY, int aZ) { TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { - AxisAlignedBB bbb=((IGregTechTileEntity)tTileEntity).getCollisionBoundingBoxFromPool(((IGregTechTileEntity)tTileEntity).getWorld(), 0, 0, 0); - minX=bbb.minX;//This essentially sets block bounds - minY=bbb.minY; - minZ=bbb.minZ; - maxX=bbb.maxX; - maxY=bbb.maxY; - maxZ=bbb.maxZ; + if (tTileEntity instanceof IGregTechTileEntity && + (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { + 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); + super.setBlockBoundsBasedOnState(blockAccess, aX, aY, aZ); } @Override public void setBlockBoundsForItemRender() { - super.setBlockBounds(0,0,0,1,1,1); + super.setBlockBounds(0, 0, 0, 1, 1, 1); } + @Override public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { + if (tTileEntity instanceof IGregTechTileEntity && + ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); return; } @@ -239,69 +286,74 @@ public class GT_Block_Machines } @SideOnly(Side.CLIENT) + @Override public void registerBlockIcons(IIconRegister aIconRegister) { - if (GregTech_API.sPostloadFinished) { - GT_Log.out.println("GT_Mod: Setting up Icon Register for Blocks"); - GregTech_API.sBlockIcons = aIconRegister; - - GT_Log.out.println("GT_Mod: Registering MetaTileEntity specific Textures"); - try { - for (IMetaTileEntity tMetaTileEntity : GregTech_API.METATILEENTITIES) { - if (tMetaTileEntity != null) { - tMetaTileEntity.registerIcons(aIconRegister); - } - } - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} - GT_Log.out.println("GT_Mod: Registering Crop specific Textures"); - try { - for (GT_BaseCrop tCrop : GT_BaseCrop.sCropList) { - tCrop.registerSprites(aIconRegister); + 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 (Throwable 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 (Throwable 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"); + } 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"); } - public float getBlockHardness(World aWorld, int aX, int aY, int aZ) { - return super.getBlockHardness(aWorld, aX, aY, aZ); - } - + @Override public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof BaseMetaTileEntity)) && (((BaseMetaTileEntity) tTileEntity).privateAccess()) && (!((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true))) { - return -1.0F; - } - return super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); + return tTileEntity instanceof BaseMetaTileEntity && + ((BaseMetaTileEntity) tTileEntity).privateAccess() && + !((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true) ? + -1.0F : super.getPlayerRelativeBlockHardness(aPlayer, aWorld, aX, aY, aZ); } - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, float par2, float par3) { + @Override + public boolean onBlockActivated( + World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, float par2, float par3) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity == null) { return false; } - if(aPlayer.isSneaking()){ - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); - if(tCurrentItem!=null){ - if(!GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList) && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)){ - return false; - } - } + if (aPlayer.isSneaking()) { + 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) + ) return false; } if ((tTileEntity instanceof IGregTechTileEntity)) { if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { return false; } - if ((!aWorld.isRemote) && (!((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer))) { + if ((!aWorld.isRemote) && !((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer)) { return true; } return ((IGregTechTileEntity) tTileEntity).onRightclick(aPlayer, (byte) aSide, par1, par2, par3); @@ -309,46 +361,55 @@ public class GT_Block_Machines return false; } + @Override public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { + if (tTileEntity instanceof IGregTechTileEntity) { ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); } } + @Override public int getDamageValue(World aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { + if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getMetaTileID(); } return 0; } + @Override public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { - GT_Log.exp.println("Explosion at :"+aX + " | " + aY+ " | " + aZ +" DIMID: " + aWorld.provider.dimensionId+ " due to near explosion!"); + if (tTileEntity instanceof BaseMetaTileEntity) { + GT_Log.exp.printf("Explosion at : %d | %d | %d DIMID: %s due to near explosion!%n", + aX, aY, aZ, aWorld.provider.dimensionId); ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); } super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); } + @Override public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { + if (tTileEntity instanceof IGregTechTileEntity) { IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; mTemporaryTileEntity.set(tGregTechTileEntity); for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); if ((tItem != null) && (tItem.stackSize > 0) && (tGregTechTileEntity.isValidSlot(i))) { - EntityItem tItemEntity = new EntityItem(aWorld, aX + 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())); + 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.0500000007450581D); - tItemEntity.motionY = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D + 0.2000000029802322D); - tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.0500000007450581D); + 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; tGregTechTileEntity.setInventorySlotContents(i, null); @@ -359,65 +420,76 @@ public class GT_Block_Machines aWorld.removeTileEntity(aX, aY, aZ); } + @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 IGregTechTileEntity)) { return ((IGregTechTileEntity) tTileEntity).getDrops(); } - return mTemporaryTileEntity.get() == null ? new ArrayList() : ((IGregTechTileEntity) mTemporaryTileEntity.get()).getDrops(); + IGregTechTileEntity tGregTechTileEntity = mTemporaryTileEntity.get(); + ArrayList<ItemStack> tDrops; + if (tGregTechTileEntity == null) { + tDrops = (ArrayList<ItemStack>) Collections.<ItemStack>emptyList(); + } else { + tDrops = tGregTechTileEntity.getDrops(); + mTemporaryTileEntity.remove(); + } + return tDrops; } + @Override public boolean removedByPlayer(World aWorld, EntityPlayer aPlayer, int aX, int aY, int aZ, boolean aWillHarvest) { - if (aWillHarvest) { - return true; // This delays deletion of the block until after getDrops - } else { - return super.removedByPlayer(aWorld, aPlayer, aX, aY, aZ, false); - } + // 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) - { + 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 aSide) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { + if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide); } return 0; } + @Override public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if ((aSide < 0) || (aSide > 5)) { + if (aSide < 0 || aSide > 5) { return 0; } TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { + if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); } return 0; } + @Override public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if ((aSide < 0) || (aSide > 5)) { + if (aSide < 0 || aSide > 5) { return 0; } TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { + if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); } return 0; } + @Override public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { if (!aWorld.isRemote) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity != null) && (chance < 1.0F)) { - if (((tTileEntity instanceof BaseMetaTileEntity)) && (GregTech_API.sMachineNonWrenchExplosions)) { - GT_Log.exp.println("Explosion at :"+aX + " | " + aY+ " | " + aZ +" DIMID: "+ aWorld.provider.dimensionId+ " due to NonWrench picking/Rain!"); + if (tTileEntity != null && (chance < 1.0F)) { + if (tTileEntity instanceof BaseMetaTileEntity && (GregTech_API.sMachineNonWrenchExplosions)) { + GT_Log.exp.printf("Explosion at : %d | %d | %d DIMID: %s NonWrench picking/Rain!%n", + aX, aY, aZ, aWorld.provider.dimensionId); ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); } } else { @@ -426,44 +498,60 @@ public class GT_Block_Machines } } + @Override public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { return true; } TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null) { - if ((tTileEntity instanceof BaseMetaTileEntity)) { - return true; - } - if (((tTileEntity instanceof BaseMetaPipeEntity)) && ((((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0)) { + if (tTileEntity instanceof BaseMetaTileEntity) { return true; } - if (((tTileEntity instanceof ICoverable)) && (((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 0)) { + if (tTileEntity instanceof BaseMetaPipeEntity && + (((BaseMetaPipeEntity) tTileEntity).mConnections & 0xFFFFFFC0) != 0) { return true; } + return tTileEntity instanceof ICoverable && + ((ICoverable) tTileEntity).getCoverIDAtSide((byte) aSide.ordinal()) != 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; + } + + @Override public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { - return 0; - } - if ((tTileEntity instanceof IGregTechTileEntity)) { + 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) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { + if (tTileEntity instanceof BaseMetaTileEntity) { return ((BaseMetaTileEntity) tTileEntity).getLightValue(); } return 0; } + @Override public TileEntity createTileEntity(World aWorld, int aMeta) { if (aMeta < 4) { return GregTech_API.constructBaseMetaTileEntity(); @@ -471,76 +559,87 @@ public class GT_Block_Machines return new BaseMetaPipeEntity(); } - public float getExplosionResistance(Entity par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) { + @Override + public float getExplosionResistance( + Entity par1Entity, World aWorld, int aX, int aY, int aZ, + double explosionX, double explosionY, double explosionZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (((tTileEntity instanceof IGregTechTileEntity))) { + if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6); } return 10.0F; } @SideOnly(Side.CLIENT) - public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List) { + @Override + @SuppressWarnings("unchecked") // Old API uses raw List type + public void getSubBlocks(Item par1Item, CreativeTabs par2CreativeTabs, List par3List) { for (int i = 1; i < GregTech_API.METATILEENTITIES.length; i++) { if (GregTech_API.METATILEENTITIES[i] != null) { - par3List.add(new ItemStack(par1, 1, i)); + par3List.add(new ItemStack(par1Item, 1, i)); } } } + @Override public void onBlockPlacedBy(World aWorld, int aX, int aY, int aZ, EntityLivingBase aPlayer, ItemStack aStack) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity == null) { + if (!(tTileEntity instanceof IGregTechTileEntity)) { return; } - if ((tTileEntity instanceof IGregTechTileEntity)) { - IGregTechTileEntity var6 = (IGregTechTileEntity) tTileEntity; - if (aPlayer == null) { - var6.setFrontFacing((byte) 1); - } else { - int var7 = MathHelper.floor_double(aPlayer.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3; - int var8 = Math.round(aPlayer.rotationPitch); - if ((var8 >= 65) && (var6.isValidFacing((byte) 1))) { - var6.setFrontFacing((byte) 1); - } else if ((var8 <= -65) && (var6.isValidFacing((byte) 0))) { - var6.setFrontFacing((byte) 0); - } else { - switch (var7) { - case 0: - var6.setFrontFacing((byte) 2); - break; - case 1: - var6.setFrontFacing((byte) 5); - break; - case 2: - var6.setFrontFacing((byte) 3); - break; - case 3: - var6.setFrontFacing((byte) 4); - } - } - } + IGregTechTileEntity iGregTechTileEntity = (IGregTechTileEntity) tTileEntity; + if (aPlayer == null) { + iGregTechTileEntity.setFrontFacing((byte) ForgeDirection.UP.ordinal()); + return; + } + int yawQuadrant = MathHelper.floor_double(aPlayer.rotationYaw * 4.0F / 360.0F + 0.5D) & 0x3; + int pitch = Math.round(aPlayer.rotationPitch); + if (pitch >= 65 && iGregTechTileEntity.isValidFacing((byte) ForgeDirection.UP.ordinal())) { + iGregTechTileEntity.setFrontFacing((byte) ForgeDirection.UP.ordinal()); + return; + } + if (pitch <= -65 && iGregTechTileEntity.isValidFacing((byte) ForgeDirection.DOWN.ordinal())) { + iGregTechTileEntity.setFrontFacing((byte) ForgeDirection.DOWN.ordinal()); + return; + } + switch (yawQuadrant) { + case 0: + iGregTechTileEntity.setFrontFacing((byte) ForgeDirection.NORTH.ordinal()); + break; + case 1: + iGregTechTileEntity.setFrontFacing((byte) ForgeDirection.EAST.ordinal()); + break; + case 2: + iGregTechTileEntity.setFrontFacing((byte) ForgeDirection.SOUTH.ordinal()); + break; + case 3: + iGregTechTileEntity.setFrontFacing((byte) ForgeDirection.WEST.ordinal()); + break; + default: + break; } } - public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { + @Override + public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof BaseMetaTileEntity)) { + if (tTileEntity instanceof BaseMetaTileEntity) { return ((BaseMetaTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); } - if ((tTileEntity instanceof BaseMetaPipeEntity)) { + if (tTileEntity instanceof BaseMetaPipeEntity) { return ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); } - return null; + return (ArrayList<String>) Collections.<String>emptyList(); } + @Override public boolean recolourBlock(World aWorld, int aX, int aY, int aZ, ForgeDirection aSide, int aColor) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) ((aColor ^ 0xFFFFFFFF) & 0xF)) { + if (tTileEntity instanceof IGregTechTileEntity) { + if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) ((~aColor) & 0xF)) { return false; } - ((IGregTechTileEntity) tTileEntity).setColorization((byte) ((aColor ^ 0xFFFFFFFF) & 0xF)); + ((IGregTechTileEntity) tTileEntity).setColorization((byte) ((~aColor) & 0xF)); return true; } return false; diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java index abcc92a795..7fcfd7a29a 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Metal.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Metal.java @@ -15,13 +15,14 @@ public class GT_Block_Metal extends GT_Block_Storage { public OrePrefixes mPrefix; public IIconContainer[] mBlockIcons; public boolean mHideBlocks; + public static boolean mNEIisLoaded = Loader.isModLoaded("NotEnoughItems"); public GT_Block_Metal(String aName, Materials[] aMats, OrePrefixes aPrefix, IIconContainer[] aBlockIcons) { super(GT_Item_Storage.class, aName, Material.iron); mMats = aMats; mPrefix = aPrefix; mBlockIcons = aBlockIcons; - mHideBlocks = Loader.isModLoaded("NotEnoughItems"); + mHideBlocks = mNEIisLoaded; for (int i = 0; i < aMats.length; i++) { if (aMats[i].mMetaItemSubID > 0 && aMats[i].mHasParentMod) { @@ -29,11 +30,12 @@ public class GT_Block_Metal extends GT_Block_Storage { GT_OreDictUnificator.registerOre(aPrefix, aMats[i], new ItemStack(this, 1, i)); } } - if (aMats.length<16 && Loader.isModLoaded("NotEnoughItems")) { + 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 aSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16) && aMeta < mMats.length) { return mBlockIcons[aMeta].getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java index bab31d85ed..c3f53a7bc5 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores.java @@ -4,14 +4,19 @@ import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; -import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_CopiedBlockTexture; -import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.render.TextureFactory; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; +import java.util.Arrays; + +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; + public class GT_Block_Ores extends GT_Block_Ores_Abstract { public GT_Block_Ores() { super("gt.blockores", 7, false, Material.rock); @@ -57,7 +62,15 @@ public class GT_Block_Ores extends GT_Block_Ores_Abstract { } @Override - public ITexture[] getTextureSet() { //Must have 16 entries. - return new ITexture[]{new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.netherrack, 0, 0), new GT_CopiedBlockTexture(Blocks.end_stone, 0, 0), new GT_RenderedTexture(Textures.BlockIcons.GRANITE_BLACK_STONE), new GT_RenderedTexture(Textures.BlockIcons.GRANITE_RED_STONE), new GT_RenderedTexture(Textures.BlockIcons.MARBLE_STONE), new GT_RenderedTexture(Textures.BlockIcons.BASALT_STONE), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_CopiedBlockTexture(Blocks.stone, 0, 0)}; + 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; } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java index 512136f1f8..48cd41187d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_Abstract.java @@ -77,6 +77,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements 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; @@ -88,6 +89,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements FUCKING_LOCK = false; } + @Override public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { if (!FUCKING_LOCK) { FUCKING_LOCK = true; @@ -132,42 +134,52 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements return aMaterial.getDefaultLocalizedNameForItem(getLocalizedNameFormat(aMaterial)); } + @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_) : false; } + @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 par1Entity, World aWorld, int aX, int aY, int aZ, double explosionX, double explosionY, double explosionZ) { return 1.0F + getHarvestLevel(aWorld.getBlockMetadata(aX, aY, aZ)) * 1.0F; } + @Override protected boolean canSilkHarvest() { return false; } + @Override public abstract String getUnlocalizedName(); + @Override public String getLocalizedName() { return StatCollector.translateToLocal(getUnlocalizedName() + aTextName); } + @Override public int getRenderType() { if (GT_Renderer_Block.INSTANCE == null) { return super.getRenderType(); @@ -175,42 +187,52 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements 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 boolean renderAsNormalBlock() { return true; } + @Override public boolean isOpaqueCube() { return true; } + @Override public TileEntity createNewTileEntity(World aWorld, int aMeta) { return createTileEntity(aWorld, aMeta); } + @Override public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { return Blocks.stone.getIcon(0, 0); } + @Override public IIcon getIcon(int aSide, int aMeta) { return Blocks.stone.getIcon(0, 0); } + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister aIconRegister) { } + @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))) { @@ -219,6 +241,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements return 0; } + @Override public void breakBlock(World aWorld, int aX, int aY, int aZ, Block par5, int par6) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof GT_TileEntity_Ores)) { @@ -236,6 +259,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements 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)) { @@ -244,6 +268,7 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements return mTemporaryTileEntity.get() == null ? new ArrayList() : ((GT_TileEntity_Ores) mTemporaryTileEntity.get()).getDrops(getDroppedBlock(), aFortune); } + @Override public TileEntity createTileEntity(World aWorld, int aMeta) { return new GT_TileEntity_Ores(); } @@ -274,4 +299,4 @@ public abstract class GT_Block_Ores_Abstract extends GT_Generic_Block implements } } } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java index bea2320f01..6749f8d136 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB1.java @@ -5,7 +5,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -50,6 +50,6 @@ public class GT_Block_Ores_UB1 extends GT_Block_Ores_Abstract { @Override public ITexture[] getTextureSet() { //Must have 16 entries. - return new ITexture[]{new GT_CopiedBlockTexture(aUBBlock, 0, 0), new GT_CopiedBlockTexture(aUBBlock, 0, 1), new GT_CopiedBlockTexture(aUBBlock, 0, 2), new GT_CopiedBlockTexture(aUBBlock, 0, 3), new GT_CopiedBlockTexture(aUBBlock, 0, 4), new GT_CopiedBlockTexture(aUBBlock, 0, 5), new GT_CopiedBlockTexture(aUBBlock, 0, 6), new GT_CopiedBlockTexture(aUBBlock, 0, 7), new GT_CopiedBlockTexture(aUBBlock, 0, 0), new GT_CopiedBlockTexture(aUBBlock, 0, 1), new GT_CopiedBlockTexture(aUBBlock, 0, 2), new GT_CopiedBlockTexture(aUBBlock, 0, 3), new GT_CopiedBlockTexture(aUBBlock, 0, 4), new GT_CopiedBlockTexture(aUBBlock, 0, 5), new GT_CopiedBlockTexture(aUBBlock, 0, 6), new GT_CopiedBlockTexture(aUBBlock, 0, 7)}; + return new ITexture[]{TextureFactory.of(aUBBlock, 0), TextureFactory.of(aUBBlock, 1), TextureFactory.of(aUBBlock, 2), TextureFactory.of(aUBBlock, 3), TextureFactory.of(aUBBlock, 4), TextureFactory.of(aUBBlock, 5), TextureFactory.of(aUBBlock, 6), TextureFactory.of(aUBBlock, 7), TextureFactory.of(aUBBlock, 0), TextureFactory.of(aUBBlock, 1), TextureFactory.of(aUBBlock, 2), TextureFactory.of(aUBBlock, 3), TextureFactory.of(aUBBlock, 4), TextureFactory.of(aUBBlock, 5), TextureFactory.of(aUBBlock, 6), TextureFactory.of(aUBBlock, 7)}; } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java index d3278f0cb4..5d78ab0aa3 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB2.java @@ -5,7 +5,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -50,6 +50,6 @@ public class GT_Block_Ores_UB2 extends GT_Block_Ores_Abstract { @Override public ITexture[] getTextureSet() { //Must have 16 entries. - return new ITexture[]{new GT_CopiedBlockTexture(aUBBlock, 0, 0), new GT_CopiedBlockTexture(aUBBlock, 0, 1), new GT_CopiedBlockTexture(aUBBlock, 0, 2), new GT_CopiedBlockTexture(aUBBlock, 0, 3), new GT_CopiedBlockTexture(aUBBlock, 0, 4), new GT_CopiedBlockTexture(aUBBlock, 0, 5), new GT_CopiedBlockTexture(aUBBlock, 0, 6), new GT_CopiedBlockTexture(aUBBlock, 0, 7), new GT_CopiedBlockTexture(aUBBlock, 0, 0), new GT_CopiedBlockTexture(aUBBlock, 0, 1), new GT_CopiedBlockTexture(aUBBlock, 0, 2), new GT_CopiedBlockTexture(aUBBlock, 0, 3), new GT_CopiedBlockTexture(aUBBlock, 0, 4), new GT_CopiedBlockTexture(aUBBlock, 0, 5), new GT_CopiedBlockTexture(aUBBlock, 0, 6), new GT_CopiedBlockTexture(aUBBlock, 0, 7)}; + return new ITexture[]{TextureFactory.of(aUBBlock, 0), TextureFactory.of(aUBBlock, 1), TextureFactory.of(aUBBlock, 2), TextureFactory.of(aUBBlock, 3), TextureFactory.of(aUBBlock, 4), TextureFactory.of(aUBBlock, 5), TextureFactory.of(aUBBlock, 6), TextureFactory.of(aUBBlock, 7), TextureFactory.of(aUBBlock, 0), TextureFactory.of(aUBBlock, 1), TextureFactory.of(aUBBlock, 2), TextureFactory.of(aUBBlock, 3), TextureFactory.of(aUBBlock, 4), TextureFactory.of(aUBBlock, 5), TextureFactory.of(aUBBlock, 6), TextureFactory.of(aUBBlock, 7)}; } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java index 7942d80b22..e4111af1c5 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Ores_UB3.java @@ -5,7 +5,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ITexture; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; @@ -50,6 +50,6 @@ public class GT_Block_Ores_UB3 extends GT_Block_Ores_Abstract { @Override public ITexture[] getTextureSet() { //Must have 16 entries. - return new ITexture[]{new GT_CopiedBlockTexture(aUBBlock, 0, 0), new GT_CopiedBlockTexture(aUBBlock, 0, 1), new GT_CopiedBlockTexture(aUBBlock, 0, 2), new GT_CopiedBlockTexture(aUBBlock, 0, 3), new GT_CopiedBlockTexture(aUBBlock, 0, 4), new GT_CopiedBlockTexture(aUBBlock, 0, 5), new GT_CopiedBlockTexture(aUBBlock, 0, 6), new GT_CopiedBlockTexture(aUBBlock, 0, 7), new GT_CopiedBlockTexture(aUBBlock, 0, 0), new GT_CopiedBlockTexture(aUBBlock, 0, 1), new GT_CopiedBlockTexture(aUBBlock, 0, 2), new GT_CopiedBlockTexture(aUBBlock, 0, 3), new GT_CopiedBlockTexture(aUBBlock, 0, 4), new GT_CopiedBlockTexture(aUBBlock, 0, 5), new GT_CopiedBlockTexture(aUBBlock, 0, 6), new GT_CopiedBlockTexture(aUBBlock, 0, 7)}; + return new ITexture[]{TextureFactory.of(aUBBlock, 0), TextureFactory.of(aUBBlock, 1), TextureFactory.of(aUBBlock, 2), TextureFactory.of(aUBBlock, 3), TextureFactory.of(aUBBlock, 4), TextureFactory.of(aUBBlock, 5), TextureFactory.of(aUBBlock, 6), TextureFactory.of(aUBBlock, 7), TextureFactory.of(aUBBlock, 0), TextureFactory.of(aUBBlock, 1), TextureFactory.of(aUBBlock, 2), TextureFactory.of(aUBBlock, 3), TextureFactory.of(aUBBlock, 4), TextureFactory.of(aUBBlock, 5), TextureFactory.of(aUBBlock, 6), TextureFactory.of(aUBBlock, 7)}; } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java index ec31cb212c..fc49ecc597 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Reinforced.java @@ -8,9 +8,10 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.Textures; import gregtech.api.items.GT_Generic_Block; -import gregtech.api.objects.GT_CopiedBlockTexture; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.WorldSpawnedEventBuilder; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -38,8 +39,8 @@ public class GT_Block_Reinforced extends GT_Generic_Block { public GT_Block_Reinforced(String aName) { super(GT_Item_Storage.class, aName, new GT_Material_Reinforced()); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[1][i + 80] = new GT_CopiedBlockTexture(this, 6, i); + for (int i = 0; i < 16; i++) { + Textures.BlockIcons.casingTexturePages[1][i + 80] = TextureFactory.of(this, i); } setStepSound(soundTypeStone); setCreativeTab(GregTech_API.TAB_GREGTECH); @@ -58,7 +59,7 @@ public class GT_Block_Reinforced extends GT_Generic_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(40.0f).setResistance(100.0f), 1, 2)); + 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)); @@ -69,20 +70,19 @@ public class GT_Block_Reinforced extends GT_Generic_Block { 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.addCraftingRecipe(ItemList.Block_BronzePlate.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hP ", "PBP", " P ", 'P', OrePrefixes.plate.get(Materials.Bronze), 'B', OrePrefixes.stone.get(Materials.GraniteBlack)}); - //GT_ModHandler.addCraftingRecipe(ItemList.Block_BronzePlate.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hP ", "PBP", " P ", 'P', OrePrefixes.plate.get(Materials.Bronze), 'B', OrePrefixes.stone.get(Materials.GraniteRed)}); - //GT_ModHandler.addCraftingRecipe(ItemList.Block_IridiumTungstensteel.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"hBP", 'P', OrePrefixes.plate.get(Materials.Iridium), 'B', ItemList.Block_TungstenSteelReinforced.get(1L, new Object[0])}); - //GT_OreDictUnificator.setItemData(ItemList.Block_IridiumTungstensteel.get(1, new Object[0]), new ItemData(new MaterialStack(Materials.Iridium, OrePrefixes.plate.mMaterialAmount), new MaterialStack(Materials.TungstenSteel, 2*OrePrefixes.plate.mMaterialAmount),new MaterialStack(Materials.Concrete, OrePrefixes.dust.mMaterialAmount))); - GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(Items.coal, 1, 1), new Object[]{ItemList.Block_BrittleCharcoal.get(1, new Object[0])}); - GT_ModHandler.addCraftingRecipe(ItemList.Block_Powderbarrel.get(1L, new Object[0]),GT_ModHandler.RecipeBits.REVERSIBLE, new Object[]{"WSW","GGG","WGW", 'W', OrePrefixes.plate.get(Materials.Wood), 'G', new ItemStack(Items.gunpowder,1),'S',new ItemStack(Items.string,1)}); + 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; @@ -91,6 +91,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return 4; } + @Override public IIcon getIcon(int aSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { @@ -125,6 +126,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { 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; @@ -140,7 +142,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return 400.0F; } if (tMeta == 2) { - return 40.0F; + return 5.0F; } if (tMeta == 3) { return 250.0F; @@ -163,6 +165,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return Blocks.iron_block.getBlockHardness(aWorld, aX, aY, aZ); } + @Override public float getExplosionResistance(Entity par1Entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) { if (world == null) { return 0.0F; @@ -175,7 +178,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return 600.0F; } if (tMeta == 2) { - return 100.0F; + return 6.0F; } if (tMeta == 3) { return 400.0F; @@ -202,50 +205,62 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return super.getExplosionResistance(par1Entity, 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 renderAsNormalBlock() { return true; } + @Override public boolean isOpaqueCube() { return true; } + @Override public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { return false; } + @Override public int damageDropped(int par1) { return par1; } + @Override public int getDamageValue(World par1World, int par2, int par3, int par4) { return par1World.getBlockMetadata(par2, par3, par4); } + @Override public int quantityDropped(Random par1Random) { return 1; } + @Override public Item getItemDropped(int par1, Random par2Random, int par3) { return Item.getItemFromBlock(this); } + @Override public void dropBlockAsItemWithChance(World aWorld, int aX, int aY, int aZ, int par5, float chance, int par7) { if (par5 == 4) { this.dropBlockAsItem(aWorld, aX, aY, aZ, new ItemStack(Items.coal, XSTR_INSTANCE.nextInt(2) + 1, 1)); @@ -254,19 +269,26 @@ public class GT_Block_Reinforced extends GT_Generic_Block { } } + @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); - world.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F); - + new WorldSpawnedEventBuilder.SoundAtEntityEventBuilder() + .setPitch(1f) + .setVolume(1f) + .setIdentifier("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); @@ -275,6 +297,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { } } + @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) { @@ -282,6 +305,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { } } + @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()); @@ -291,6 +315,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { super.onBlockExploded(world, x, y, z, explosion); } + @Override public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset) { if ((player.getCurrentEquippedItem() != null) && (player.getCurrentEquippedItem().getItem() == Items.flint_and_steel)&&par1World.getBlockMetadata(x, y, z)==5) @@ -302,10 +327,12 @@ public class GT_Block_Reinforced extends GT_Generic_Block { return super.onBlockActivated(par1World, x, y, z, player, side, xOffset, yOffset, zOffset); } + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister aIconRegister) { } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { for (int i = 0; i < 16; i++) { @@ -314,6 +341,7 @@ public class GT_Block_Reinforced extends GT_Generic_Block { } } + @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 index efac529b18..3838f30f0b 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones.java @@ -36,14 +36,17 @@ public class GT_Block_Stones extends GT_Block_Stones_Abstract { } } + @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 aSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.STONES[aMeta].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 index c9c31dae54..2f816b93c0 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Stones_Abstract.java @@ -24,9 +24,7 @@ import net.minecraft.world.World; import java.util.List; import java.util.Random; -public class GT_Block_Stones_Abstract - extends GT_Generic_Block - implements IOreRecipeRegistrator { +public 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); @@ -66,6 +64,7 @@ public class GT_Block_Stones_Abstract GT_ModHandler.addCraftingRecipe(new ItemStack(this, 4, 11), GT_ModHandler.RecipeBits.NOT_REMOVABLE, new Object[]{"XX", "XX", 'X', new ItemStack(this, 4, 15)}); } + @Override public void registerOre(OrePrefixes aPrefix, Materials aMaterial, String aOreDictName, String aModName, ItemStack aStack) { if (aOreDictName.equals(OreDictNames.craftingLensWhite.toString())) { GT_Values.RA.addLaserEngraverRecipe(new ItemStack(this, 1, 7), GT_Utility.copyAmount(0L, new Object[]{aStack}), new ItemStack(this, 1, 6), 50, 16); @@ -133,14 +132,17 @@ public class GT_Block_Stones_Abstract return 1; } + @Override public Item getItemDropped(int par1, Random par2Random, int par3) { return Item.getItemFromBlock(this); } + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister aIconRegister) { } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { for (int i = 0; i < 16; i++) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java b/src/main/java/gregtech/common/blocks/GT_Block_Storage.java index 768fed6619..0a05ab300c 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Storage.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Storage.java @@ -28,70 +28,87 @@ public class GT_Block_Storage extends GT_Generic_Block { setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); } + @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 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 renderAsNormalBlock() { return true; } + @Override public boolean isOpaqueCube() { return true; } + @Override public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { return true; } + @Override public int damageDropped(int par1) { return par1; } + @Override public int getDamageValue(World par1World, int par2, int par3, int par4) { return par1World.getBlockMetadata(par2, par3, par4); } + @Override public int quantityDropped(Random par1Random) { return 1; } + @Override public Item getItemDropped(int par1, Random par2Random, int par3) { return Item.getItemFromBlock(this); } + @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister aIconRegister) { } + @Override @SideOnly(Side.CLIENT) public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { for (int i = 0; i < 16; i++) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java index 680942d9fd..bcb50b2176 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings1.java @@ -9,8 +9,7 @@ import net.minecraft.util.EnumChatFormatting; import java.util.List; -public class GT_Item_Casings1 - extends GT_Item_Casings_Abstract { +public class GT_Item_Casings1 extends GT_Item_Casings_Abstract { public GT_Item_Casings1(Block par1) { super(par1); } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java index 1d069d94f7..ed705d0c57 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings2.java @@ -6,12 +6,12 @@ import net.minecraft.item.ItemStack; import java.util.List; -public class GT_Item_Casings2 - extends GT_Item_Casings_Abstract { +public class GT_Item_Casings2 extends GT_Item_Casings_Abstract { public GT_Item_Casings2(Block par1) { super(par1); } + @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); switch (getDamage(aStack)) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java index 5ecf0a9da6..b9eac8252a 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings3.java @@ -2,8 +2,7 @@ package gregtech.common.blocks; import net.minecraft.block.Block; -public class GT_Item_Casings3 - extends GT_Item_Casings_Abstract { +public class GT_Item_Casings3 extends GT_Item_Casings_Abstract { public GT_Item_Casings3(Block par1) { super(par1); } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java index 05da650a51..10b39e3ea8 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings4.java @@ -2,8 +2,7 @@ package gregtech.common.blocks; import net.minecraft.block.Block; -public class GT_Item_Casings4 - extends GT_Item_Casings_Abstract { +public class GT_Item_Casings4 extends GT_Item_Casings_Abstract { public GT_Item_Casings4(Block par1) { super(par1); } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java index 759fcafb5e..f3e58d2acc 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings5.java @@ -2,48 +2,30 @@ package gregtech.common.blocks; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.util.GT_LanguageManager; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import java.util.List; -public class GT_Item_Casings5 - extends GT_Item_Casings_Abstract { +public class GT_Item_Casings5 extends GT_Item_Casings_Abstract { public GT_Item_Casings5(Block par1) { super(par1); } + + protected static final String mCoilHeatTooltip = GT_LanguageManager.addStringLocalization("gt.coilheattooltip", "Base Heating Capacity = "); + protected static final String mCoilUnitTooltip = GT_LanguageManager.addStringLocalization("gt.coilunittooltip", " Kelvin"); + protected static final String mCoilTierTooltip = GT_LanguageManager.addStringLocalization("gt.coiltiertooltip", "Coil Tier = "); + @Override @SideOnly(Side.CLIENT) + @SuppressWarnings("unchecked") public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); - switch (getDamage(aStack)) { - case 0: - aList.add(this.mCoil01Tooltip); - break; - case 1: - aList.add(this.mCoil02Tooltip); - break; - case 2: - aList.add(this.mCoil03Tooltip); - break; - case 3: - aList.add(this.mCoil04Tooltip); - break; - case 4: - aList.add(this.mCoil05Tooltip); - break; - case 5: - aList.add(this.mCoil06Tooltip); - break; - case 6: - aList.add(this.mCoil07Tooltip); - break; - case 7: - aList.add(this.mCoil08Tooltip); - break; - case 8: - aList.add(this.mCoil09Tooltip); - } + HeatingCoilLevel coilLevel = GT_Block_Casings5.getCoilHeatFromDamage(aStack.getItemDamage()); + aList.add(mCoilHeatTooltip + coilLevel.getHeat() + mCoilUnitTooltip); + aList.add(mCoilTierTooltip + coilLevel.getTierName()); } } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java index f29e907827..ebeab2f0aa 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings6.java @@ -2,9 +2,8 @@ package gregtech.common.blocks; import net.minecraft.block.Block; -public class GT_Item_Casings6 - extends GT_Item_Casings_Abstract { +public class GT_Item_Casings6 extends GT_Item_Casings_Abstract { public GT_Item_Casings6(Block par1) { super(par1); } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java index f1609ef684..19ca06d5ac 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings8.java @@ -2,8 +2,7 @@ package gregtech.common.blocks; import net.minecraft.block.Block; -public class GT_Item_Casings8 - extends GT_Item_Casings_Abstract { +public class GT_Item_Casings8 extends GT_Item_Casings_Abstract { public GT_Item_Casings8(Block par1) { super(par1); } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java b/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java index 1ca55d499f..0468da20d8 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Casings_Abstract.java @@ -9,8 +9,7 @@ import net.minecraft.item.ItemStack; import java.util.List; -public abstract class GT_Item_Casings_Abstract - extends ItemBlock { +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"); @@ -25,6 +24,7 @@ public abstract class GT_Item_Casings_Abstract protected final String mCoilOverheated1Tooltip = GT_LanguageManager.addStringLocalization("gt.coil.overheated1.tooltip", "These coils are deprecated"); protected final String mCoilOverheated2Tooltip = GT_LanguageManager.addStringLocalization("gt.coil.overheated2.tooltip", "Place in crafting grid to get regular coils"); protected final String mBlastProofTooltip = GT_LanguageManager.addStringLocalization("gt.blastprooftooltip", "This Block is Blast Proof"); + public GT_Item_Casings_Abstract(Block par1) { super(par1); setMaxDamage(0); @@ -32,14 +32,17 @@ public abstract class GT_Item_Casings_Abstract setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); } + @Override public int getMetadata(int aMeta) { return aMeta; } + @Override public String getUnlocalizedName(ItemStack aStack) { return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); } + @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); aList.add(this.mNoMobsToolTip); diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java index 22a732a507..bf8957afb4 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Concretes.java @@ -7,14 +7,14 @@ import net.minecraft.item.ItemStack; import java.util.List; -public class GT_Item_Concretes - extends GT_Item_Stones_Abstract { +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 par1) { super(par1); } + @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); aList.add(this.mRunFasterToolTip); diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Granites.java b/src/main/java/gregtech/common/blocks/GT_Item_Granites.java index 71faf3b759..d14474c17f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Granites.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Granites.java @@ -2,8 +2,7 @@ package gregtech.common.blocks; import net.minecraft.block.Block; -public class GT_Item_Granites - extends GT_Item_Stones_Abstract { +public class GT_Item_Granites extends GT_Item_Stones_Abstract { public GT_Item_Granites(Block par1) { super(par1); } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.java b/src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.java new file mode 100644 index 0000000000..e376933623 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/GT_Item_LongDistancePipe.java @@ -0,0 +1,39 @@ +package gregtech.common.blocks; + +import gregtech.api.GregTech_API; +import gregtech.api.util.GT_LanguageManager; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; + +import java.util.List; + +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 par1) { + super(par1); + setMaxDamage(0); + setHasSubtypes(true); + setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); + } + + @Override + public int getMetadata(int aMeta) { + return aMeta; + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + super.addInformation(aStack, aPlayer, aList, aF3_H); + aList.add(this.mNoMobsToolTip); + aList.add(this.mNoTileEntityToolTip); + } +} diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index bf6b12b5cd..39eecdd5e4 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -4,7 +4,9 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IConnectable; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Frame; @@ -23,8 +25,7 @@ import net.minecraft.world.World; import java.util.List; -public class GT_Item_Machines - extends ItemBlock { +public class GT_Item_Machines extends ItemBlock { private static final String[] directionNames = {"Bottom", "Top", "North", "South", "West", "East"}; @@ -35,6 +36,7 @@ public class GT_Item_Machines setCreativeTab(GregTech_API.TAB_GREGTECH); } + @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { try { int tDamage = getDamage(aStack); @@ -46,29 +48,33 @@ public class GT_Item_Machines IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); if (tTileEntity.getDescription() != null) { int i = 0; + IMetaTileEntity metaTileEntity = tTileEntity.getMetaTileEntity(); + String suffix = (metaTileEntity instanceof MetaTileEntity && ((MetaTileEntity) metaTileEntity).isDisplaySecondaryDescription()) ? "Secondary_" : ""; for (String tDescription : tTileEntity.getDescription()) { if (GT_Utility.isStringValid(tDescription)) { - if(tDescription.contains("%%%")){ - String[] tString = tDescription.split("%%%"); - if(tString.length>=2){ - StringBuffer tBuffer = new StringBuffer(); - Object tRep[] = new String[tString.length / 2]; - for (int j = 0; j < tString.length; j++) - if (j % 2 == 0) tBuffer.append(tString[j]); - else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} - aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished), tRep)); - } - }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); - aList.add(tTranslated.equals("") ? tDescription : tTranslated);} + if(tDescription.contains("%%%")){ + String[] tString = tDescription.split("%%%"); + if(tString.length>=2){ + StringBuffer tBuffer = new StringBuffer(); + Object tRep[] = new String[tString.length / 2]; + for (int j = 0; j < tString.length; j++) + if (j % 2 == 0) tBuffer.append(tString[j]); + else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} + aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished ), tRep)); + } + }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); + aList.add(tTranslated.equals("") ? tDescription : tTranslated);} }else i++; } } if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getInputVoltage())] + ")" + EnumChatFormatting.GRAY); + int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputVoltage() > 0L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.VN[GT_Utility.getTier(tTileEntity.getOutputVoltage())] + ")" + EnumChatFormatting.GRAY); + int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputAmperage() > 1L) { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY); @@ -111,10 +117,12 @@ public class GT_Item_Machines } } + @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { return false; } + @Override public String getUnlocalizedName(ItemStack aStack) { short tDamage = (short) getDamage(aStack); if ((tDamage < 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { @@ -126,6 +134,7 @@ public class GT_Item_Machines return ""; } + @Override public String getItemStackDisplayName(ItemStack aStack) { String aName = super.getItemStackDisplayName(aStack); short aDamage = (short) getDamage(aStack); @@ -147,6 +156,7 @@ public class GT_Item_Machines return aName; } + @Override public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { super.onCreated(aStack, aWorld, aPlayer); short tDamage = (short) getDamage(aStack); @@ -155,6 +165,7 @@ public class GT_Item_Machines } } + @Override public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { short tDamage = (short) getDamage(aStack); if (tDamage > 0) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java index 8d53cfe513..ab31233abc 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Ores.java @@ -8,8 +8,7 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -public class GT_Item_Ores - extends ItemBlock { +public class GT_Item_Ores extends ItemBlock { public GT_Item_Ores(Block par1) { super(par1); setMaxDamage(0); @@ -17,14 +16,17 @@ public class GT_Item_Ores setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); } + @Override public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { return false; } + @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) { @@ -33,6 +35,7 @@ public class GT_Item_Ores return aName; } + @Override public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { short tDamage = (short) getDamage(aStack); if (tDamage > 0) { 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 index 6e42569e6f..5170b1cbeb 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Stones_Abstract.java @@ -9,8 +9,7 @@ import net.minecraft.item.ItemStack; import java.util.List; -public class GT_Item_Stones_Abstract - extends ItemBlock { +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 par1) { @@ -20,14 +19,17 @@ public class GT_Item_Stones_Abstract setCreativeTab(GregTech_API.TAB_GREGTECH_MATERIALS); } + @Override public String getUnlocalizedName(ItemStack aStack) { return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); } + @Override public int getMetadata(int aMeta) { return aMeta; } + @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); if (aStack.getItemDamage() % 8 >= 3) { diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Storage.java b/src/main/java/gregtech/common/blocks/GT_Item_Storage.java index 8cf838f538..3696cd4fc2 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Storage.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Storage.java @@ -16,10 +16,12 @@ public class GT_Item_Storage extends ItemBlock { 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) { @@ -31,11 +33,13 @@ public class GT_Item_Storage extends ItemBlock { return aName; } + @Override public int getMetadata(int aMeta) { return aMeta; } + @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { super.addInformation(aStack, aPlayer, aList, aF3_H); } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Casings.java b/src/main/java/gregtech/common/blocks/GT_Material_Casings.java index c81f382f5d..3b6cd37f9c 100644 --- a/src/main/java/gregtech/common/blocks/GT_Material_Casings.java +++ b/src/main/java/gregtech/common/blocks/GT_Material_Casings.java @@ -3,8 +3,7 @@ package gregtech.common.blocks; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; -public class GT_Material_Casings - extends Material { +public class GT_Material_Casings extends Material { public static final Material INSTANCE = new GT_Material_Casings(); private GT_Material_Casings() { @@ -12,6 +11,7 @@ public class GT_Material_Casings 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 index e55720f9fa..d51e588522 100644 --- a/src/main/java/gregtech/common/blocks/GT_Material_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Material_Machines.java @@ -3,8 +3,7 @@ package gregtech.common.blocks; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; -public class GT_Material_Machines - extends Material { +public class GT_Material_Machines extends Material { public GT_Material_Machines() { super(MapColor.ironColor); setRequiresTool(); @@ -12,7 +11,8 @@ public class GT_Material_Machines setAdventureModeExempt(); } + @Override public boolean isOpaque() { - return false; + return true; } } diff --git a/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java b/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java index 4aa9ba6931..38de5dbee7 100644 --- a/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java +++ b/src/main/java/gregtech/common/blocks/GT_Material_Reinforced.java @@ -3,14 +3,14 @@ package gregtech.common.blocks; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; -public class GT_Material_Reinforced - extends 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 index b026e60dac..657ac9b934 100644 --- a/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_Packet_Ores.java @@ -1,15 +1,13 @@ package gregtech.common.blocks; import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; -import gregtech.api.net.GT_Packet; +import gregtech.api.net.GT_Packet_New; +import io.netty.buffer.ByteBuf; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -public class GT_Packet_Ores - extends GT_Packet { +public class GT_Packet_Ores extends GT_Packet_New { private int mX; private int mZ; private short mY; @@ -27,21 +25,20 @@ public class GT_Packet_Ores this.mMetaData = aMetaData; } - public byte[] encode() { - ByteArrayDataOutput tOut = ByteStreams.newDataOutput(12); - - tOut.writeInt(this.mX); - tOut.writeShort(this.mY); - tOut.writeInt(this.mZ); - tOut.writeShort(this.mMetaData); - - return tOut.toByteArray(); + @Override + public void encode(ByteBuf aOut) { + aOut.writeInt(this.mX); + aOut.writeShort(this.mY); + aOut.writeInt(this.mZ); + aOut.writeShort(this.mMetaData); } - public GT_Packet decode(ByteArrayDataInput aData) { + @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); @@ -54,6 +51,7 @@ public class GT_Packet_Ores } } + @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 index 2eb100599b..66dd4b7277 100644 --- a/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java +++ b/src/main/java/gregtech/common/blocks/GT_TileEntity_Ores.java @@ -7,9 +7,8 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; -import gregtech.api.objects.GT_CopiedBlockTexture; -import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.XSTR; +import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; @@ -23,6 +22,8 @@ import net.minecraft.world.World; import java.util.ArrayList; import java.util.Random; +import static gregtech.api.enums.TextureSet.SET_NONE; + public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntity { public short mMetaData = 0; public boolean mNatural = false; @@ -31,7 +32,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit 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 ) { + 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; @@ -111,12 +112,14 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit 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); @@ -130,6 +133,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit } } + @Override public Packet getDescriptionPacket() { if (!this.worldObj.isRemote) { if (!(this.mBlocked = ( @@ -147,38 +151,38 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit } public void overrideOreBlockMaterial(Block aOverridingStoneBlock, byte aOverridingStoneMeta) { - if(this.worldObj == null || blockType==null)return; - this.mMetaData = ((short) (int) (this.mMetaData % 1000L + this.mMetaData / 16000L * 16000L)); - if (aOverridingStoneBlock.isReplaceableOreGen(this.worldObj, this.xCoord, this.yCoord, this.zCoord, Blocks.netherrack)) { - this.mMetaData = ((short) (this.mMetaData + 1000)); - } 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 { + 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 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 + 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); + } + 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) (int) (this.mMetaData % 1000 + (this.mMetaData / 16000 * 16000))); + 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) { @@ -191,12 +195,13 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit return this.mMetaData; } + @Override public boolean canUpdate() { return false; } public ArrayList<ItemStack> getDrops(Block aDroppedOre, int aFortune) { - ArrayList<ItemStack> rList = new ArrayList(); + ArrayList<ItemStack> rList = new ArrayList<>(); if (this.mMetaData <= 0) { rList.add(new ItemStack(Blocks.cobblestone, 1, 0)); return rList; @@ -214,7 +219,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit } if (aMaterial != null) { Random tRandom = new XSTR(this.xCoord ^ this.yCoord ^ this.zCoord); - ArrayList<ItemStack> tSelector = new ArrayList(); + ArrayList<ItemStack> tSelector = new ArrayList<>(); ItemStack tStack = GT_OreDictUnificator.get(OrePrefixes.gemExquisite, aMaterial, GT_OreDictUnificator.get(OrePrefixes.gem, aMaterial, 1L), 1L); @@ -259,28 +264,40 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit tSelector.add(tStack); } } - if (tSelector.size() > 0) { + 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(1L, new Object[]{tSelector.get(tRandom.nextInt(tSelector.size()))})); + rList.add(GT_Utility.copyAmount(1L, 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)); + 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, byte aSide) { Materials aMaterial = GregTech_API.sGeneratedMaterials[(this.mMetaData % 1000)]; if ((aMaterial != null) && (this.mMetaData < 32000)) { - GT_RenderedTexture aIconSet = new GT_RenderedTexture(aMaterial.mIconSet.mTextures[this.mMetaData / 16000 == 0 ? OrePrefixes.ore.mTextureIndex : OrePrefixes.oreSmall.mTextureIndex], aMaterial.mRGBa); + ITexture iTexture = TextureFactory.builder() + .addIcon(aMaterial.mIconSet.mTextures[this.mMetaData / 16000 == 0 ? + OrePrefixes.ore.mTextureIndex : + OrePrefixes.oreSmall.mTextureIndex]) + .setRGBA(aMaterial.mRGBa) + .stdOrient() + .build(); if (aBlock instanceof GT_Block_Ores_Abstract) { - return new ITexture[]{((GT_Block_Ores_Abstract) aBlock).getTextureSet()[((this.mMetaData / 1000) % 16)], aIconSet}; + return new ITexture[]{ + ((GT_Block_Ores_Abstract) aBlock).getTextureSet()[((this.mMetaData / 1000) % 16)], iTexture}; } } - return new ITexture[]{new GT_CopiedBlockTexture(Blocks.stone, 0, 0), new GT_RenderedTexture(gregtech.api.enums.TextureSet.SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex])}; + return new ITexture[]{ + TextureFactory.of(Blocks.stone, 0), + TextureFactory.builder().addIcon(SET_NONE.mTextures[OrePrefixes.ore.mTextureIndex]).stdOrient().build() + }; } } |