diff options
Diffstat (limited to 'src/main/java/gregtech/common')
12 files changed, 212 insertions, 274 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 9a9fb9c17e..92f4f2de59 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -1,6 +1,6 @@ // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.kpdus.com/jad.html -// Decompiler options: packimports(3) +// Decompiler options: packimports(3) // Source File Name: GT_Client.java package gregtech.common; @@ -181,21 +181,14 @@ public class GT_Client extends GT_Proxy private static void drawGrid(DrawBlockHighlightEvent aEvent, boolean showCoverConnections, boolean aIsWrench, boolean aIsSneaking) { if (!checkedForChicken) { - try { - Class.forName("codechicken.lib.vec.Rotation"); - } catch (Throwable e) { - if (GT_Values.D1) { - e.printStackTrace(GT_Log.err); - } - return; - } + try {Class.forName("codechicken.lib.vec.Rotation");} catch (ClassNotFoundException e) {return;} checkedForChicken = true; } GL11.glPushMatrix(); GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks)); GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F); - int tSideHit = aEvent.target.sideHit; + final int tSideHit = aEvent.target.sideHit; Rotation.sideRotations[tSideHit].glApply(); // draw grid GL11.glTranslated(0.0D, -0.501D, 0.0D); @@ -210,7 +203,7 @@ public class GT_Client extends GT_Proxy GL11.glVertex3d(+.25D, .0D, +.50D); GL11.glVertex3d(-.25D, .0D, -.50D); GL11.glVertex3d(-.25D, .0D, +.50D); - TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); + final TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); // draw connection indicators byte tConnections = 0; @@ -282,11 +275,10 @@ public class GT_Client extends GT_Proxy } GL11.glEnd(); // draw turning indicator - if (aIsWrench && tTile instanceof IGregTechTileEntity && - ((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof IAlignmentProvider) { - IAlignment tAlignment = ((IAlignmentProvider) ((IGregTechTileEntity) tTile).getMetaTileEntity()).getAlignment(); + if (aIsWrench && tTile instanceof IAlignmentProvider) { + final IAlignment tAlignment = ((IAlignmentProvider)(tTile)).getAlignment(); if (tAlignment != null) { - ForgeDirection direction = tAlignment.getDirection(); + final ForgeDirection direction = tAlignment.getDirection(); if (direction.ordinal() == tSideHit) drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER, aIsSneaking, false); else if (direction.getOpposite().ordinal() == tSideHit) { @@ -339,7 +331,7 @@ public class GT_Client extends GT_Proxy private static void drawFlipMarker(Transformation transform) { GL11.glPushMatrix(); transform.glApply(); - Tessellator t = Tessellator.instance; + final Tessellator t = Tessellator.instance; // right shape GL11.glLineStipple(4, (short) 0xAAAA); GL11.glEnable(GL11.GL_LINE_STIPPLE); @@ -405,7 +397,7 @@ public class GT_Client extends GT_Proxy @Override public void onPreLoad() { super.onPreLoad(); - String[] arr = { + final String[] arr = { "renadi", "hanakocz", "MysteryDump", "Flaver4", "x_Fame", "Peluche321", "Goshen_Ithilien", "manf", "Bimgo", "leagris", "IAmMinecrafter02", "Cerous", "Devilin_Pixy", "Bkarlsson87", "BadAlchemy", "CaballoCraft", "melanclock", "Resursator", "demanzke", "AndrewAmmerlaan", "Deathlycraft", "Jirajha", "Axlegear", "kei_kouma", "Dracion", "dungi", "Dorfschwein", "Zero Tw0", "mattiagraz85", "sebastiank30", @@ -445,7 +437,7 @@ public class GT_Client extends GT_Proxy @Override public void onPostLoad() { super.onPostLoad(); - + try { for (int i = 1; i < GregTech_API.METATILEENTITIES.length; i++) { try { @@ -472,7 +464,7 @@ public class GT_Client extends GT_Proxy @Override public void run() { GT_Log.out.println("GT_Mod: Downloading Cape List."); - try (Scanner tScanner = new Scanner(new URL(GT_CAPE_LIST_URL).openStream())) { + try (final Scanner tScanner = new Scanner(new URL(GT_CAPE_LIST_URL).openStream())) { while (tScanner.hasNextLine()) { this.mCapeList.add(tScanner.nextLine().toLowerCase()); } @@ -480,9 +472,9 @@ public class GT_Client extends GT_Proxy e.printStackTrace(GT_Log.err); } GT_Log.out.println("GT New Horizons: Downloading Cape List."); - try (Scanner tScanner = new Scanner(new URL(GTNH_CAPE_LIST_URL).openStream())) { + try (final Scanner tScanner = new Scanner(new URL(GTNH_CAPE_LIST_URL).openStream())) { while (tScanner.hasNextLine()) { - String tName = tScanner.nextLine().toLowerCase(); + final String tName = tScanner.nextLine().toLowerCase(); if (tName.contains(":")) { if (!this.mCapeList.contains(tName.substring(0, tName.indexOf(":")))) { this.mCapeList.add(tName); @@ -541,7 +533,7 @@ public class GT_Client extends GT_Proxy } if (!GregTech_API.mServerStarted) GregTech_API.mServerStarted = true; if (GT_Values.updateFluidDisplayItems) { - MovingObjectPosition trace = Minecraft.getMinecraft().objectMouseOver; + final MovingObjectPosition trace = Minecraft.getMinecraft().objectMouseOver; if (trace != null && trace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && (mLastUpdatedBlockX != trace.blockX && mLastUpdatedBlockY != trace.blockY && @@ -549,9 +541,9 @@ public class GT_Client extends GT_Proxy mLastUpdatedBlockX = trace.blockX; mLastUpdatedBlockY = trace.blockY; mLastUpdatedBlockZ = trace.blockZ; - TileEntity tileEntity = aEvent.player.worldObj.getTileEntity(trace.blockX, trace.blockY, trace.blockZ); + final TileEntity tileEntity = aEvent.player.worldObj.getTileEntity(trace.blockX, trace.blockY, trace.blockZ); if (tileEntity instanceof IGregTechTileEntity) { - IGregTechTileEntity gtTile = (IGregTechTileEntity) tileEntity; + final IGregTechTileEntity gtTile = (IGregTechTileEntity) tileEntity; if (gtTile.getMetaTileEntity() instanceof IHasFluidDisplayItem) { GT_Values.NW.sendToServer(new MessageUpdateFluidDisplayItem(trace.blockX, trace.blockY, trace.blockZ, gtTile.getWorld().provider.dimensionId)); } @@ -575,11 +567,10 @@ public class GT_Client extends GT_Proxy @SubscribeEvent public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) { - Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); + final Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); + final TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) - { + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) { if (aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable) drawGrid(aEvent, false, true, aEvent.player.isSneaking()); return; @@ -629,7 +620,7 @@ public class GT_Client extends GT_Proxy public void onClientTickEvent(cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent aEvent) { if (aEvent.phase == cpw.mods.fml.common.gameevent.TickEvent.Phase.END) { if (changeDetected > 0) changeDetected--; - int newHideValue = shouldHeldItemHideThings(); + final int newHideValue = shouldHeldItemHideThings(); if (newHideValue != hideValue) { hideValue = newHideValue; changeDetected = 5; @@ -638,9 +629,8 @@ public class GT_Client extends GT_Proxy if (mAnimationTick % 50L == 0L) { mAnimationDirection = !mAnimationDirection; } - int tDirection = mAnimationDirection ? 1 : -1; - for (Object o : mPosR) { - Materials tMaterial = (Materials) o; + final int tDirection = mAnimationDirection ? 1 : -1; + for (Materials tMaterial : mPosR) { tMaterial.mRGBa[0] = getSafeRGBValue(tMaterial.mRGBa[0], tDirection); } @@ -738,55 +728,55 @@ public class GT_Client extends GT_Proxy if (tString.startsWith("streaming.")) switch (aStack.stackSize) { case 1: // '\001' - tString = (new StringBuilder()).append(tString).append("13").toString(); + tString = tString + "13"; break; case 2: // '\002' - tString = (new StringBuilder()).append(tString).append("cat").toString(); + tString = tString + "cat"; break; case 3: // '\003' - tString = (new StringBuilder()).append(tString).append("blocks").toString(); + tString = tString + "blocks"; break; case 4: // '\004' - tString = (new StringBuilder()).append(tString).append("chirp").toString(); + tString = tString + "chirp"; break; case 5: // '\005' - tString = (new StringBuilder()).append(tString).append("far").toString(); + tString = tString + "far"; break; case 6: // '\006' - tString = (new StringBuilder()).append(tString).append("mall").toString(); + tString = tString + "mall"; break; case 7: // '\007' - tString = (new StringBuilder()).append(tString).append("mellohi").toString(); + tString = tString + "mellohi"; break; case 8: // '\b' - tString = (new StringBuilder()).append(tString).append("stal").toString(); + tString = tString + "stal"; break; case 9: // '\t' - tString = (new StringBuilder()).append(tString).append("strad").toString(); + tString = tString + "strad"; break; case 10: // '\n' - tString = (new StringBuilder()).append(tString).append("ward").toString(); + tString = tString + "ward"; break; case 11: // '\013' - tString = (new StringBuilder()).append(tString).append("11").toString(); + tString = tString + "11"; break; case 12: // '\f' - tString = (new StringBuilder()).append(tString).append("wait").toString(); + tString = tString + "wait"; break; default: - tString = (new StringBuilder()).append(tString).append("wherearewenow").toString(); + tString = tString + "wherearewenow"; break; } if (tString.startsWith("streaming.")) { @@ -815,11 +805,11 @@ public class GT_Client extends GT_Proxy private static int shouldHeldItemHideThings() { try { - EntityPlayer player = Minecraft.getMinecraft().thePlayer; + final EntityPlayer player = Minecraft.getMinecraft().thePlayer; if (player == null) return 0; - ItemStack tCurrentItem = player.getCurrentEquippedItem(); + final ItemStack tCurrentItem = player.getCurrentEquippedItem(); if (tCurrentItem == null) return 0; - int[] ids = OreDictionary.getOreIDs(tCurrentItem); + final int[] ids = OreDictionary.getOreIDs(tCurrentItem); int hide = 0; for (int i : ids) { if (OreDictionary.getOreName(i).equals("craftingToolSolderingIron")) { diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 40b7381e48..34c1cc3a41 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -406,6 +406,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler { ItemList.RC_Bed_Wood.set(GT_ModHandler.getModItem(MOD_ID_RC, "part.railbed", 1L, 0)); ItemList.RC_Bed_Stone.set(GT_ModHandler.getModItem(MOD_ID_RC, "part.railbed", 1L, 1)); ItemList.RC_Rebar.set(GT_ModHandler.getModItem(MOD_ID_RC, "part.rebar", 1L)); + ItemList.TC_Thaumometer.set(GT_ModHandler.getModItem(MOD_ID_TC, "ItemThaumometer", 1L, 0)); ItemList.Tool_Sword_Steel.set(GT_ModHandler.getModItem(MOD_ID_RC, "tool.steel.sword", 1L)); ItemList.Tool_Pickaxe_Steel.set(GT_ModHandler.getModItem(MOD_ID_RC, "tool.steel.pickaxe", 1L)); ItemList.Tool_Shovel_Steel.set(GT_ModHandler.getModItem(MOD_ID_RC, "tool.steel.shovel", 1L)); 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 ad97bb9572..851b84b5c3 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -9,11 +9,13 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IDebugableBlock; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IDebugableTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_Generic_Block; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.metatileentity.CoverableTileEntity; import gregtech.api.util.GT_BaseCrop; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; @@ -48,6 +50,7 @@ import java.util.Collections; import java.util.List; import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.GT_Values.SIDE_UP; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; @Optional.Interface(iface = "com.cricketcraft.chisel.api.IFacade", modid = "ChiselAPI") @@ -87,7 +90,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @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); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof BaseTileEntity)) { ((BaseTileEntity) tTileEntity).onAdjacentBlockChange(aTileX, aTileY, aTileZ); } @@ -95,7 +98,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block aBlock) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof BaseMetaPipeEntity)) { ((BaseMetaPipeEntity) tTileEntity).onNeighborBlockChange(aX, aY, aZ); } @@ -217,7 +220,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @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); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); return tTileEntity != null && tTileEntity.receiveClientEvent(aData1, aData2); } @@ -225,7 +228,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @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); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { ((IGregTechTileEntity) tTileEntity) @@ -237,7 +240,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -248,7 +251,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override @SideOnly(Side.CLIENT) public AxisAlignedBB getSelectedBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { return ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(aWorld, aX, aY, aZ); @@ -258,12 +261,9 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @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); + final TileEntity tTileEntity = blockAccess.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IGregTechTileEntity && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null)) { + final AxisAlignedBB bbb = ((IGregTechTileEntity) tTileEntity).getCollisionBoundingBoxFromPool(((IGregTechTileEntity) tTileEntity).getWorld(), 0, 0, 0); minX = bbb.minX; //This essentially sets block bounds minY = bbb.minY; minZ = bbb.minZ; @@ -282,7 +282,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public void onEntityCollidedWithBlock(World aWorld, int aX, int aY, int aZ, Entity collider) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() != null) { ((IGregTechTileEntity) tTileEntity).onEntityCollidedWithBlock(aWorld, aX, aY, aZ, collider); @@ -331,7 +331,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public float getPlayerRelativeBlockHardness(EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); return tTileEntity instanceof BaseMetaTileEntity && ((BaseMetaTileEntity) tTileEntity).privateAccess() && !((BaseMetaTileEntity) tTileEntity).playerOwnsThis(aPlayer, true) ? @@ -339,14 +339,13 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo } @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); + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, float par1, float par2, float par3) { + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity == null) { return false; } if (aPlayer.isSneaking()) { - ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); + final ItemStack tCurrentItem = aPlayer.inventory.getCurrentItem(); if ( tCurrentItem != null && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) && @@ -369,7 +368,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); } @@ -377,7 +376,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public int getDamageValue(World aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getMetaTileID(); } @@ -386,10 +385,9 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); 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); + 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); @@ -398,19 +396,20 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @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); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { - IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; + final IGregTechTileEntity tGregTechTileEntity = (IGregTechTileEntity) tTileEntity; mTemporaryTileEntity.set(tGregTechTileEntity); if (!(tGregTechTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_SuperChest || tGregTechTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) { for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { - ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); + final 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())); + final EntityItem tItemEntity = new EntityItem( + aWorld, + aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + aY + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + aZ + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, + new ItemStack(tItem.getItem(), tItem.stackSize, tItem.getItemDamage())); if (tItem.hasTagCompound()) { tItemEntity.getEntityItem().setTagCompound((NBTTagCompound) tItem.getTagCompound().copy()); } @@ -430,12 +429,12 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if ((tTileEntity instanceof IGregTechTileEntity)) { return ((IGregTechTileEntity) tTileEntity).getDrops(); } - IGregTechTileEntity tGregTechTileEntity = mTemporaryTileEntity.get(); - ArrayList<ItemStack> tDrops; + final IGregTechTileEntity tGregTechTileEntity = mTemporaryTileEntity.get(); + final ArrayList<ItemStack> tDrops; if (tGregTechTileEntity == null) { tDrops = (ArrayList<ItemStack>) Collections.<ItemStack>emptyList(); } else { @@ -459,7 +458,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide); } @@ -471,7 +470,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo if (aSide < 0 || aSide > 5) { return 0; } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); } @@ -483,7 +482,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo if (aSide < 0 || aSide > 5) { return 0; } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); } @@ -493,7 +492,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @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); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); 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", @@ -511,7 +510,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { return true; } - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null) { if (tTileEntity instanceof BaseMetaTileEntity) { return true; @@ -543,7 +542,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public int getLightOpacity(IBlockAccess aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getLightOpacity(); } @@ -552,7 +551,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public int getLightValue(IBlockAccess aWorld, int aX, int aY, int aZ) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof BaseMetaTileEntity) { return ((BaseMetaTileEntity) tTileEntity).getLightValue(); } @@ -571,7 +570,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo 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); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { return ((IGregTechTileEntity) tTileEntity).getBlastResistance((byte) 6); } @@ -591,58 +590,24 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @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 instanceof IGregTechTileEntity)) { - return; - } - 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; - } + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity)) return; + final IGregTechTileEntity iGregTechTileEntity = (IGregTechTileEntity) tTileEntity; + iGregTechTileEntity.setFrontFacing(BaseTileEntity.getSideForPlayerPlacing(aPlayer, SIDE_UP, iGregTechTileEntity.getValidFacings())); } @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) { - return ((BaseMetaTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); - } - if (tTileEntity instanceof BaseMetaPipeEntity) { - return ((BaseMetaPipeEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); + public ArrayList<String> getDebugInfo(EntityPlayer aPlayer, int aX, int aY, int aZ, int aLogLevel) { + final TileEntity tTileEntity = aPlayer.worldObj.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof IDebugableTileEntity) { + return ((IDebugableTileEntity) tTileEntity).getDebugInfo(aPlayer, aLogLevel); } return (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); + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity instanceof IGregTechTileEntity) { if (((IGregTechTileEntity) tTileEntity).getColorization() == (byte) ((~aColor) & 0xF)) { return false; @@ -655,18 +620,18 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public Block getFacade(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - byte aSide = (byte) side; - IGregTechTileEntity tile = (IGregTechTileEntity) tTileEntity; + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof CoverableTileEntity) { + final byte aSide = (byte) side; + final CoverableTileEntity tile = (CoverableTileEntity) tTileEntity; if (side != -1) { - Block facadeBlock = tile.getCoverBehaviorAtSideNew(aSide).getFacadeBlock(aSide, tile.getCoverIDAtSide(aSide), tile.getComplexCoverDataAtSide(aSide), tile); + final Block facadeBlock = tile.getCoverBehaviorAtSideNew(aSide).getFacadeBlock(aSide, tile.getCoverIDAtSide(aSide), tile.getComplexCoverDataAtSide(aSide), tile); if (facadeBlock != null) return facadeBlock; } else { // we do not allow more than one type of facade per block, so no need to check every side // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable for (byte i = 0; i < 6; i++) { - Block facadeBlock = tile.getCoverBehaviorAtSideNew(i).getFacadeBlock(i, tile.getCoverIDAtSide(i), tile.getComplexCoverDataAtSide(i), tile); + final Block facadeBlock = tile.getCoverBehaviorAtSideNew(i).getFacadeBlock(i, tile.getCoverIDAtSide(i), tile.getComplexCoverDataAtSide(i), tile); if (facadeBlock != null) { return facadeBlock; } @@ -678,19 +643,19 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public int getFacadeMetadata(IBlockAccess aWorld, int aX, int aY, int aZ, int side) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - byte aSide = (byte) side; - IGregTechTileEntity tile = (IGregTechTileEntity) tTileEntity; + final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity instanceof CoverableTileEntity) { + final byte aSide = (byte) side; + final CoverableTileEntity tile = (CoverableTileEntity) tTileEntity; if (side != -1) { - Block facadeBlock = tile.getCoverBehaviorAtSideNew(aSide).getFacadeBlock(aSide, tile.getCoverIDAtSide(aSide), tile.getComplexCoverDataAtSide(aSide), tile); + final Block facadeBlock = tile.getCoverBehaviorAtSideNew(aSide).getFacadeBlock(aSide, tile.getCoverIDAtSide(aSide), tile.getComplexCoverDataAtSide(aSide), tile); if (facadeBlock != null) return tile.getCoverBehaviorAtSideNew(aSide).getFacadeMeta(aSide, tile.getCoverIDAtSide(aSide), tile.getComplexCoverDataAtSide(aSide), tile); } else { // we do not allow more than one type of facade per block, so no need to check every side // see comment in gregtech.common.covers.GT_Cover_FacadeBase.isCoverPlaceable for (byte i = 0; i < 6; i++) { - Block facadeBlock = tile.getCoverBehaviorAtSideNew(i).getFacadeBlock(i, tile.getCoverIDAtSide(i), tile.getComplexCoverDataAtSide(i), tile); + final Block facadeBlock = tile.getCoverBehaviorAtSideNew(i).getFacadeBlock(i, tile.getCoverIDAtSide(i), tile.getComplexCoverDataAtSide(i), tile); if (facadeBlock != null) { return tile.getCoverBehaviorAtSideNew(i).getFacadeMeta(i, tile.getCoverIDAtSide(i), tile.getComplexCoverDataAtSide(i), tile); } 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 cc49cefa2b..c98b37085e 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -7,7 +7,7 @@ import gregtech.api.interfaces.ISecondaryDescribable; import gregtech.api.interfaces.metatileentity.IConnectable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.CoverableGregTechTileEntity; +import gregtech.api.metatileentity.CoverableTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; @@ -36,10 +36,9 @@ import net.minecraftforge.fluids.IFluidContainerItem; import java.util.List; -public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { - - private static final String[] directionNames = {"Bottom", "Top", "North", "South", "West", "East"}; +import static gregtech.GT_Mod.GT_FML_LOGGER; +public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { public GT_Item_Machines(Block par1) { super(par1); setMaxDamage(0); @@ -58,15 +57,16 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { } @Override + @SuppressWarnings("unchecked") public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean par4) { try { - int tDamage = getDamage(aStack); + final int tDamage = getDamage(aStack); if ((tDamage <= 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { return; } if (GregTech_API.METATILEENTITIES[tDamage] != null) { - IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); + final IGregTechTileEntity tTileEntity = GregTech_API.METATILEENTITIES[tDamage].getBaseMetaTileEntity(); if (!GregTech_API.sPostloadFinished && tTileEntity.getMetaTileEntity() instanceof ISecondaryDescribable) { final String[] secondaryDescription = ((ISecondaryDescribable) tTileEntity.getMetaTileEntity()).getSecondaryDescription(); if (secondaryDescription != null) { @@ -93,32 +93,33 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { } if (tTileEntity.getDescription() != null) { int i = 0; - IMetaTileEntity metaTileEntity = tTileEntity.getMetaTileEntity(); - String suffix = (metaTileEntity instanceof ISecondaryDescribable && ((ISecondaryDescribable) metaTileEntity).isDisplaySecondaryDescription()) ? "_Secondary" : ""; + final IMetaTileEntity metaTileEntity = tTileEntity.getMetaTileEntity(); + final String suffix = (metaTileEntity instanceof ISecondaryDescribable && ((ISecondaryDescribable) metaTileEntity).isDisplaySecondaryDescription()) ? "_Secondary" : ""; for (String tDescription : tTileEntity.getDescription()) { if (GT_Utility.isStringValid(tDescription)) { if(tDescription.contains("%%%")){ - String[] tString = tDescription.split("%%%"); + final String[] tString = tDescription.split("%%%"); if(tString.length>=2){ - StringBuilder tBuffer = new StringBuilder(); - String[] tRep = new String[tString.length / 2]; + final StringBuilder tBuffer = new StringBuilder(); + final String[] 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 + suffix + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished ), (Object[]) tRep)); } - }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + suffix + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); + }else{ + String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_DESCRIPTION_" + tDamage + suffix + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); aList.add(tTranslated.equals("") ? tDescription : tTranslated);} }else i++; } } if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { - int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); + final int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tTileEntity.getInputVoltage()) + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputVoltage() > 0L) { - int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); + final int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tTileEntity.getOutputVoltage()) + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputAmperage() > 1L) { @@ -128,7 +129,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { } if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_QuantumTank || GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_SuperTank) { if (aStack.hasTagCompound() && aStack.stackTagCompound.hasKey("mFluid")) { - FluidStack tContents = FluidStack.loadFluidStackFromNBT(aStack.stackTagCompound.getCompoundTag("mFluid")); + final FluidStack tContents = FluidStack.loadFluidStackFromNBT(aStack.stackTagCompound.getCompoundTag("mFluid")); if (tContents != null && tContents.amount > 0) { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_TANK_INFO", "Contains Fluid: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tContents.getLocalizedName() + EnumChatFormatting.GRAY); aList.add(GT_LanguageManager.addStringLocalization("TileEntity_TANK_AMOUNT", "Fluid Amount: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tContents.amount) + " L" + EnumChatFormatting.GRAY); @@ -137,8 +138,8 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { } if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_DigitalChestBase) { if (aStack.hasTagCompound() && aStack.stackTagCompound.hasKey("mItemStack")) { - ItemStack tContents = ItemStack.loadItemStackFromNBT(aStack.stackTagCompound.getCompoundTag("mItemStack")); - int tSize = aStack.stackTagCompound.getInteger("mItemCount"); + final ItemStack tContents = ItemStack.loadItemStackFromNBT(aStack.stackTagCompound.getCompoundTag("mItemStack")); + final int tSize = aStack.stackTagCompound.getInteger("mItemCount"); if (tContents != null && tSize > 0) { aList.add(GT_LanguageManager.addStringLocalization("TileEntity_CHEST_INFO", "Contains Item: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tContents.getDisplayName() + EnumChatFormatting.GRAY); aList.add(GT_LanguageManager.addStringLocalization("TileEntity_CHEST_AMOUNT", "Item Amount: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tSize) + EnumChatFormatting.GRAY); @@ -146,7 +147,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { } } } - NBTTagCompound aNBT = aStack.getTagCompound(); + final NBTTagCompound aNBT = aStack.getTagCompound(); if (aNBT != null) { if (aNBT.getBoolean("mMuffler")) { aList.add(GT_LanguageManager.addStringLocalization("GT_TileEntity_MUFFLER", "has Muffler Upgrade", !GregTech_API.sPostloadFinished )); @@ -159,30 +160,10 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { aList.add(tAmount + " " + GT_LanguageManager.addStringLocalization("GT_TileEntity_STEAMTANKS", "Steam Tank Upgrades", !GregTech_API.sPostloadFinished )); } - addInstalledCoversInformation(aNBT, aList); + CoverableTileEntity.addInstalledCoversInformation(aNBT, aList); } } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - private void addInstalledCoversInformation(NBTTagCompound aNBT, List<String> aList) { - if (aNBT.hasKey("mCoverSides")){ - int[] mCoverSides = aNBT.getIntArray("mCoverSides"); - if (mCoverSides != null && mCoverSides.length == 6) { - for (byte i = 0; i < 6; i++) { - int coverId = mCoverSides[i]; - if (coverId == 0) continue; - GT_CoverBehaviorBase<?> behavior = GregTech_API.getCoverBehaviorNew(coverId); - if (behavior == null || behavior == GregTech_API.sNoBehavior) continue; - if (!aNBT.hasKey(CoverableGregTechTileEntity.COVER_DATA_NBT_KEYS[i])) continue; - ISerializableObject dataObject = behavior.createDataObject(aNBT.getTag(CoverableGregTechTileEntity.COVER_DATA_NBT_KEYS[i])); - ItemStack itemStack = behavior.getDisplayStack(coverId, dataObject); - if (itemStack != null) { - aList.add(String.format("Cover on %s side: %s", directionNames[i], itemStack.getDisplayName())); - } - } - } + GT_FML_LOGGER.error("addInformation", e); } } @@ -193,7 +174,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public String getUnlocalizedName(ItemStack aStack) { - short tDamage = (short) getDamage(aStack); + final short tDamage = (short) getDamage(aStack); if ((tDamage < 0) || (tDamage >= GregTech_API.METATILEENTITIES.length)) { return ""; } @@ -206,7 +187,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public String getItemStackDisplayName(ItemStack aStack) { String aName = super.getItemStackDisplayName(aStack); - short aDamage = (short) getDamage(aStack); + final short aDamage = (short) getDamage(aStack); if (aDamage >= 0 && aDamage < GregTech_API.METATILEENTITIES.length && GregTech_API.METATILEENTITIES[aDamage] != null) { Materials aMaterial = null; if (GregTech_API.METATILEENTITIES[aDamage] instanceof GT_MetaPipeEntity_Item) { @@ -228,7 +209,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public void onCreated(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { super.onCreated(aStack, aWorld, aPlayer); - short tDamage = (short) getDamage(aStack); + final short tDamage = (short) getDamage(aStack); if ((tDamage < 0) || ((tDamage >= GregTech_API.METATILEENTITIES.length) && (GregTech_API.METATILEENTITIES[tDamage] != null))) { GregTech_API.METATILEENTITIES[tDamage].onCreated(aStack, aWorld, aPlayer); } @@ -236,12 +217,12 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @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); + final short tDamage = (short) getDamage(aStack); if (tDamage > 0) { if (GregTech_API.METATILEENTITIES[tDamage] == null) { return false; } - int tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType(); + final int tMetaData = GregTech_API.METATILEENTITIES[tDamage].getTileEntityBaseType(); if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tMetaData, 3)) { return false; } @@ -251,7 +232,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { if (aWorld.getBlockMetadata(aX, aY, aZ) != tMetaData) { throw new GT_ItsNotMyFaultException("Failed to set the MetaValue of the Block even though World.setBlock returned true. It COULD be MCPC/Bukkit causing that. In case you really have that installed, don't report this Bug to me, I don't know how to fix it."); } - IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aWorld.getTileEntity(aX, aY, aZ); + final IGregTechTileEntity tTileEntity = (IGregTechTileEntity) aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null) { tTileEntity.setInitialValuesAsNBT(tTileEntity.isServerSide() ? aStack.getTagCompound() : null, tDamage); if (aPlayer != null) { @@ -265,7 +246,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { ((IConnectable) tTileEntity.getMetaTileEntity()).connect(aSide); } else if (aPlayer != null && aPlayer.isSneaking()) { // If we're being placed against something that is connectable, try telling it to connect to us - IGregTechTileEntity aTileEntity = tTileEntity.getIGregTechTileEntityAtSide(aSide); + final IGregTechTileEntity aTileEntity = tTileEntity.getIGregTechTileEntityAtSide(aSide); if (aTileEntity != null && aTileEntity.getMetaTileEntity() instanceof IConnectable) { ((IConnectable) aTileEntity.getMetaTileEntity()).connect((byte)side); } @@ -284,13 +265,13 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public void onUpdate(ItemStack aStack, World aWorld, Entity aPlayer, int aTimer, boolean aIsInHand) { super.onUpdate(aStack, aWorld, aPlayer, aTimer, aIsInHand); - short tDamage = (short) getDamage(aStack); - EntityLivingBase tPlayer = (EntityPlayer) aPlayer; + final short tDamage = (short) getDamage(aStack); + final EntityLivingBase tPlayer = (EntityPlayer) aPlayer; if (GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_SuperChest || GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_QuantumChest || GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_SuperTank || GregTech_API.METATILEENTITIES[tDamage] instanceof GT_MetaTileEntity_QuantumTank) { - NBTTagCompound tNBT = aStack.stackTagCompound; + final NBTTagCompound tNBT = aStack.stackTagCompound; if (tNBT == null) return; if (tNBT.hasNoTags()) { aStack.setTagCompound(null); @@ -298,14 +279,14 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { } if ((tNBT.hasKey("mItemCount") && tNBT.getInteger("mItemCount") > 0) || (tNBT.hasKey("mFluid") && FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")).amount > 64000)) { - FluidStack tFluid = FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")); + final FluidStack tFluid = FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")); int tLasing = 1200; if (tFluid != null) { - double tFluidAmount = tFluid.amount; - double tMiddlePoint = 4096000; - double tSmoothingCoefficient = 2000000; - int tMaxLastingTime = 12000; - double tmp = (tFluidAmount - tMiddlePoint) / tSmoothingCoefficient; + final double tFluidAmount = tFluid.amount; + final double tMiddlePoint = 4096000; + final double tSmoothingCoefficient = 2000000; + final int tMaxLastingTime = 12000; + final double tmp = (tFluidAmount - tMiddlePoint) / tSmoothingCoefficient; tLasing = (int) (Math.exp(tmp) / (Math.exp(tmp) + Math.exp(-tmp)) * tMaxLastingTime); } tPlayer.addPotionEffect(new PotionEffect(Potion.hunger.id, tLasing, 1)); @@ -319,7 +300,7 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public FluidStack getFluid(ItemStack container) { if (container != null) { - NBTTagCompound tNBT = container.stackTagCompound; + final NBTTagCompound tNBT = container.stackTagCompound; if (tNBT != null && tNBT.hasKey("mFluid", 10)) { return FluidStack.loadFluidStackFromNBT(tNBT.getCompoundTag("mFluid")); } @@ -330,8 +311,8 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public int getCapacity(ItemStack container) { if (container != null) { - int tDamage = container.getItemDamage(); - IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; + final int tDamage = container.getItemDamage(); + final IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; if (tMetaTile != null) return tMetaTile.getCapacity(); } @@ -341,27 +322,27 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public int fill(ItemStack container, FluidStack resource, boolean doFill) { if (container != null && resource != null) { - int tDamage = container.getItemDamage(); - IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; + final int tDamage = container.getItemDamage(); + final IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; if (!(tMetaTile instanceof GT_MetaTileEntity_QuantumTank || tMetaTile instanceof GT_MetaTileEntity_SuperTank)) { return 0; } if (container.stackTagCompound == null) container.stackTagCompound = new NBTTagCompound(); - FluidStack tStoredFluid = getFluid(container); - int tCapacity = getCapacity(container); + final FluidStack tStoredFluid = getFluid(container); + final int tCapacity = getCapacity(container); if (tCapacity <= 0) return 0; if (tStoredFluid != null && tStoredFluid.isFluidEqual(resource)) { - int tAmount = Math.min(tCapacity - tStoredFluid.amount, resource.amount); + final int tAmount = Math.min(tCapacity - tStoredFluid.amount, resource.amount); if (doFill) { - FluidStack tNewFluid = new FluidStack(tStoredFluid, tAmount + tStoredFluid.amount); + final FluidStack tNewFluid = new FluidStack(tStoredFluid, tAmount + tStoredFluid.amount); container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); } return tAmount; } if (tStoredFluid == null) { - int tAmount = Math.min(tCapacity, resource.amount); + final int tAmount = Math.min(tCapacity, resource.amount); if (doFill) { - FluidStack tNewFluid = new FluidStack(resource, tAmount); + final FluidStack tNewFluid = new FluidStack(resource, tAmount); container.stackTagCompound.setTag("mFluid", tNewFluid.writeToNBT(new NBTTagCompound())); } return tAmount; @@ -373,16 +354,16 @@ public class GT_Item_Machines extends ItemBlock implements IFluidContainerItem { @Override public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { if (container != null && container.hasTagCompound()) { - int tDamage = container.getItemDamage(); - IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; + final int tDamage = container.getItemDamage(); + final IMetaTileEntity tMetaTile = GregTech_API.METATILEENTITIES[tDamage]; if (!(tMetaTile instanceof GT_MetaTileEntity_QuantumTank || tMetaTile instanceof GT_MetaTileEntity_SuperTank)) { return null; } - FluidStack tStoredFluid = getFluid(container); + final FluidStack tStoredFluid = getFluid(container); if (tStoredFluid != null) { - int tAmount = Math.min(maxDrain, tStoredFluid.amount); - FluidStack tNewFluid = new FluidStack(tStoredFluid, tStoredFluid.amount - tAmount); - FluidStack tOutputFluid = new FluidStack(tStoredFluid, tAmount); + final int tAmount = Math.min(maxDrain, tStoredFluid.amount); + final FluidStack tNewFluid = new FluidStack(tStoredFluid, tStoredFluid.amount - tAmount); + final FluidStack tOutputFluid = new FluidStack(tStoredFluid, tAmount); if (doDrain) { if (tNewFluid.amount <= 0) { container.stackTagCompound.removeTag("mFluid"); diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FacadeAE.java b/src/main/java/gregtech/common/covers/GT_Cover_FacadeAE.java index 592b6f322d..a227d3f530 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FacadeAE.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FacadeAE.java @@ -8,14 +8,16 @@ import net.minecraft.item.ItemStack; public class GT_Cover_FacadeAE extends GT_Cover_FacadeBase { @Override protected Block getTargetBlock(ItemStack aFacadeStack) { - Item item = aFacadeStack.getItem(); + if(aFacadeStack == null) return null; + final Item item = aFacadeStack.getItem(); if (!(item instanceof IFacadeItem)) return null; return ((IFacadeItem) item).getBlock(aFacadeStack); } @Override protected int getTargetMeta(ItemStack aFacadeStack) { - Item item = aFacadeStack.getItem(); + if(aFacadeStack == null) return 0; + final Item item = aFacadeStack.getItem(); if (!(item instanceof IFacadeItem)) return 0; return ((IFacadeItem) item).getMeta(aFacadeStack); } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java b/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java index fa3c6624f8..17aafef79e 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_FacadeBase.java @@ -94,8 +94,7 @@ public abstract class GT_Cover_FacadeBase extends GT_CoverBehaviorBase<GT_Cover_ @Override public void placeCover(byte aSide, ItemStack aCover, ICoverable aTileEntity) { - aTileEntity.setCoverIDAtSide(aSide, GT_Utility.stackToInt(aCover)); - aTileEntity.setCoverDataAtSide(aSide, new FacadeData(GT_Utility.copyAmount(1, aCover), 0)); + aTileEntity.setCoverIdAndDataAtSide(aSide, GT_Utility.stackToInt(aCover), new FacadeData(GT_Utility.copyAmount(1, aCover), 0)); if (aTileEntity.isClientSide()) GT_RenderingWorld.getInstance().register(aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord(), getTargetBlock(aCover), getTargetMeta(aCover)); } @@ -111,7 +110,8 @@ public abstract class GT_Cover_FacadeBase extends GT_CoverBehaviorBase<GT_Cover_ Block block = getTargetBlock(aCoverVariable.mStack); if (block == null) return Textures.BlockIcons.ERROR_RENDERING[0]; // TODO: change this when *someone* made the block render in both pass - if (block.getRenderBlockPass() != 0) return Textures.BlockIcons.ERROR_RENDERING[0]; + if (block.getRenderBlockPass() != 0) + return Textures.BlockIcons.ERROR_RENDERING[0]; return TextureFactory.builder().setFromBlock(block, getTargetMeta(aCoverVariable.mStack)).useWorldCoord().setFromSide(ForgeDirection.getOrientation(aSide)).build(); } @@ -207,7 +207,7 @@ public abstract class GT_Cover_FacadeBase extends GT_CoverBehaviorBase<GT_Cover_ @Override public NBTBase saveDataToNBT() { NBTTagCompound tag = new NBTTagCompound(); - tag.setTag("mStack", mStack.writeToNBT(new NBTTagCompound())); + if(mStack != null) tag.setTag("mStack", mStack.writeToNBT(new NBTTagCompound())); tag.setByte("mFlags", (byte) mFlags); return tag; } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java index 9492c8533d..457f27ae20 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_Fluidfilter.java @@ -60,7 +60,7 @@ public class GT_Cover_Fluidfilter extends GT_CoverBehaviorBase<GT_Cover_Fluidfil if (fluid == null) return E; final FluidStack sFluid = new FluidStack(fluid, 1000); - return (String.format("Filtering Fluid: %s Mode: %s", sFluid.getLocalizedName(), getFilterMode(aCoverVariable.mFilterMode))); + return (String.format("Filtering Fluid: %s - %s", sFluid.getLocalizedName(), getFilterMode(aCoverVariable.mFilterMode))); } @Override diff --git a/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java index 60e5d69fb9..ce089091d3 100644 --- a/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java +++ b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java @@ -23,7 +23,7 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I public boolean isOldTexture() { return false; } - + private IIcon getIcon(int aSide) { if (mSide == 6) return mBlock.getIcon(aSide, mMeta); return mBlock.getIcon(mSide, mMeta); @@ -31,7 +31,7 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I @Override public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - IIcon aIcon = getIcon(ForgeDirection.EAST.ordinal()); + final IIcon aIcon = getIcon(ForgeDirection.EAST.ordinal()); aRenderer.field_152631_f = true; startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); new LightingHelper(aRenderer) @@ -45,7 +45,7 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I @Override public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); - IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal()); + final IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal()); new LightingHelper(aRenderer) .setupLightingXNeg(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); @@ -56,7 +56,7 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I @Override public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); - IIcon aIcon = getIcon(ForgeDirection.UP.ordinal()); + final IIcon aIcon = getIcon(ForgeDirection.UP.ordinal()); new LightingHelper(aRenderer) .setupLightingYPos(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.UP.ordinal(), 0xffffff); @@ -67,7 +67,7 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I @Override public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); - IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal()); + final IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal()); new LightingHelper(aRenderer) .setupLightingYNeg(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); @@ -78,7 +78,7 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I @Override public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); - IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal()); + final IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal()); new LightingHelper(aRenderer) .setupLightingZPos(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); @@ -89,7 +89,7 @@ public class GT_CopiedBlockTexture extends GT_TextureBase implements ITexture, I @Override public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); - IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal()); + final IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal()); aRenderer.field_152631_f = true; new LightingHelper(aRenderer) .setupLightingZNeg(aBlock, aX, aY, aZ) diff --git a/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java b/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java index a405649c33..366da77420 100644 --- a/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java +++ b/src/main/java/gregtech/common/render/GT_CopiedCTMBlockTexture.java @@ -24,9 +24,9 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc public boolean isOldTexture() { return false; } - + private IIcon getIcon(int aSide, int aX, int aY, int aZ, RenderBlocks aRenderer) { - int tSide = mSide == 6 ? aSide : mSide; + final int tSide = mSide == 6 ? aSide : mSide; return mBlock.getIcon(getBlockAccess(aRenderer), aX, aY, aZ, tSide); } @@ -36,7 +36,7 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc @Override public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { - IIcon aIcon = getIcon(ForgeDirection.EAST.ordinal(), aX, aY, aZ, aRenderer); + final IIcon aIcon = getIcon(ForgeDirection.EAST.ordinal(), aX, aY, aZ, aRenderer); aRenderer.field_152631_f = true; startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); new LightingHelper(aRenderer) @@ -50,7 +50,7 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc @Override public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); - IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal(), aX, aY, aZ, aRenderer); + final IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer) .setupLightingXNeg(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.WEST.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); @@ -61,7 +61,7 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc @Override public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); - IIcon aIcon = getIcon(ForgeDirection.UP.ordinal(), aX, aY, aZ, aRenderer); + final IIcon aIcon = getIcon(ForgeDirection.UP.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer) .setupLightingYPos(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.UP.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); @@ -72,7 +72,7 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc @Override public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); - IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal(), aX, aY, aZ, aRenderer); + final IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer) .setupLightingYNeg(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.DOWN.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); @@ -83,7 +83,7 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc @Override public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); - IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal(), aX, aY, aZ, aRenderer); + final IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal(), aX, aY, aZ, aRenderer); new LightingHelper(aRenderer) .setupLightingZPos(aBlock, aX, aY, aZ) .setupColor(ForgeDirection.SOUTH.ordinal(), mBlock.colorMultiplier(getBlockAccess(aRenderer), aX, aY, aZ)); @@ -94,7 +94,7 @@ class GT_CopiedCTMBlockTexture extends GT_TextureBase implements ITexture, IBloc @Override public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); - IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal(), aX, aY, aZ, aRenderer); + final IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal(), aX, aY, aZ, aRenderer); aRenderer.field_152631_f = true; new LightingHelper(aRenderer) .setupLightingZNeg(aBlock, aX, aY, aZ) diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index ca9d47bc67..e16bb55b12 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -48,7 +48,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); final boolean enableAO = aRenderer.enableAO; - LightingHelper lighting = new LightingHelper(aRenderer); + final LightingHelper lighting = new LightingHelper(aRenderer); if (glow) { if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; aRenderer.enableAO = false; @@ -56,7 +56,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol if (enableAO) lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingXPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.EAST.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceXPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.EAST.ordinal(), 0xffffff); @@ -70,7 +70,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); final boolean enableAO = aRenderer.enableAO; - LightingHelper lighting = new LightingHelper(aRenderer); + final LightingHelper lighting = new LightingHelper(aRenderer); if (glow) { if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; aRenderer.enableAO = false; @@ -78,7 +78,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingXNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.WEST.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceXNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); @@ -92,7 +92,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); final boolean enableAO = aRenderer.enableAO; - LightingHelper lighting = new LightingHelper(aRenderer); + final LightingHelper lighting = new LightingHelper(aRenderer); if (glow) { if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; aRenderer.enableAO = false; @@ -100,7 +100,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingYPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.UP.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceYPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.UP.ordinal(), 0xffffff); @@ -114,7 +114,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); final boolean enableAO = aRenderer.enableAO; - LightingHelper lighting = new LightingHelper(aRenderer); + final LightingHelper lighting = new LightingHelper(aRenderer); if (glow) { if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; aRenderer.enableAO = false; @@ -122,7 +122,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingYNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.DOWN.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceYNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { Tessellator.instance.setColorRGBA(255, 255, 255, 255); @@ -136,7 +136,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); final boolean enableAO = aRenderer.enableAO; - LightingHelper lighting = new LightingHelper(aRenderer); + final LightingHelper lighting = new LightingHelper(aRenderer); if (glow) { if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; aRenderer.enableAO = false; @@ -144,7 +144,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingZPos(aBlock, aX, aY, aZ).setupColor(ForgeDirection.SOUTH.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceZPos(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); @@ -158,7 +158,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); final boolean enableAO = aRenderer.enableAO; - LightingHelper lighting = new LightingHelper(aRenderer); + final LightingHelper lighting = new LightingHelper(aRenderer); if (glow) { if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; aRenderer.enableAO = false; @@ -166,7 +166,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol lighting.setBrightnessOverride(MAX_BRIGHTNESS); } lighting.setupLightingZNeg(aBlock, aX, aY, aZ).setupColor(ForgeDirection.NORTH.ordinal(), mRGBa); - ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); + final ExtendedFacing rotation = getExtendedFacing(aX, aY, aZ); renderFaceZNeg(aRenderer, aX, aY, aZ, mIconContainer.getIcon(), rotation); if (mIconContainer.getOverlayIcon() != null) { lighting.setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff); @@ -206,7 +206,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol break; } - Flip aFlip = extendedFacing.getFlip(); + final Flip aFlip = extendedFacing.getFlip(); aRenderer.renderFaceYNeg(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped() ^ !stdOrient, aFlip.isVerticallyFliped()) : new GT_IconFlipped(icon, !stdOrient, false)); aRenderer.uvRotateBottom = 0; } @@ -231,7 +231,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol break; } - Flip aFlip = extendedFacing.getFlip(); + final Flip aFlip = extendedFacing.getFlip(); aRenderer.renderFaceYPos(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateTop = 0; } @@ -257,7 +257,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol break; } - Flip aFlip = extendedFacing.getFlip(); + final Flip aFlip = extendedFacing.getFlip(); aRenderer.renderFaceZNeg(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateEast = 0; aRenderer.field_152631_f = false; @@ -283,7 +283,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol break; } - Flip aFlip = extendedFacing.getFlip(); + final Flip aFlip = extendedFacing.getFlip(); aRenderer.renderFaceZPos(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateWest = 0; } @@ -308,7 +308,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol break; } - Flip aFlip = extendedFacing.getFlip(); + final Flip aFlip = extendedFacing.getFlip(); aRenderer.renderFaceXNeg(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateNorth = 0; } @@ -334,7 +334,7 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol break; } - Flip aFlip = extendedFacing.getFlip(); + final Flip aFlip = extendedFacing.getFlip(); aRenderer.renderFaceXPos(Blocks.air, x, y, z, useExtFacing && GT_Mod.gregtechproxy.mRenderFlippedMachinesFlipped ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateSouth = 0; aRenderer.field_152631_f = false; @@ -342,13 +342,13 @@ public class GT_RenderedTexture extends GT_TextureBase implements ITexture, ICol private ExtendedFacing getExtendedFacing(int x, int y, int z) { if (stdOrient) return ExtendedFacing.DEFAULT; - EntityPlayer player = GT_Mod.gregtechproxy.getThePlayer(); + final EntityPlayer player = GT_Mod.gregtechproxy.getThePlayer(); if (player == null) return ExtendedFacing.DEFAULT; - World w = player.getEntityWorld(); + final World w = player.getEntityWorld(); if (w == null) return ExtendedFacing.DEFAULT; - TileEntity te = w.getTileEntity(x, y, z); + final TileEntity te = w.getTileEntity(x, y, z); if (te instanceof IGregTechTileEntity) { - IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); + final IMetaTileEntity meta = ((IGregTechTileEntity) te).getMetaTileEntity(); if (meta instanceof IAlignmentProvider) { return ((IAlignmentProvider) meta).getAlignment().getExtendedFacing(); } else if (meta != null) { diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java index 2c8ac45719..fe0a8527ab 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java @@ -41,11 +41,11 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_SIDE public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEntity_LongDistancePipelineBase { static final FluidTankInfo[] emptyTank = {new FluidTankInfo(null, Integer.MAX_VALUE)}; - + public GT_MetaTileEntity_LongDistancePipelineFluid(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, "Sends fluids over long distances"); } - + public GT_MetaTileEntity_LongDistancePipelineFluid(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, aDescription, aTextures); } @@ -57,16 +57,16 @@ public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEnti @Override public int getPipeMeta() { - return 0; + return 0; } - + public IFluidHandler getTank() { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); TileEntity tankTile = tTile.getTileEntityAtSide(tTile.getBackFacing()); if (tankTile instanceof IFluidHandler) return (IFluidHandler)tankTile; else return null; } - + @Override public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { if (checkTarget()) { @@ -106,7 +106,7 @@ public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEnti @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) + if (aSide == aFacing) return new ITexture[]{ MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_FRONT)}; @@ -114,7 +114,7 @@ public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEnti return new ITexture[]{ MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_BACK)}; - else + else return new ITexture[]{ MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_SIDE), diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java index 417e70891b..b6b3636ab0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java @@ -22,6 +22,7 @@ package gregtech.common.tileentities.machines.long_distance; +import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -39,8 +40,6 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE_GLOW; public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntity_LongDistancePipelineBase { - static final int[] emptyIntArray = new int[0]; - public GT_MetaTileEntity_LongDistancePipelineItem(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, "Sends Items over long distances"); } @@ -145,16 +144,16 @@ public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntit public int[] getAccessibleSlotsFromSide(int aSide) { if (checkTarget()) { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); - IInventory iInventory = getInventory(); + final IInventory iInventory = getInventory(); if (iInventory instanceof ISidedInventory) return ((ISidedInventory)iInventory).getAccessibleSlotsFromSide(tTile.getFrontFacing()); if (iInventory != null) { - int[] tReturn = new int[iInventory.getSizeInventory()]; + final int[] tReturn = new int[iInventory.getSizeInventory()]; for (int i = 0; i < tReturn.length; i++) tReturn[i] = i; return tReturn; } } - return emptyIntArray; + return GT_Values.emptyIntArray; } @Override |