From d05f5bbd6d1b762db1383cb0180aac0726f4d5ed Mon Sep 17 00:00:00 2001 From: repo_alt Date: Tue, 23 Mar 2021 01:10:03 +0300 Subject: integer overflow in comparison https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/5817 --- .../api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index 9222029854..69ccd3ef48 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -159,7 +159,7 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier } } } else { - if (tFluid.isFluidEqual(getFillableStack()) && tFluid.amount + getFillableStack().amount <= getCapacity()) { + if (tFluid.isFluidEqual(getFillableStack()) && ((long)tFluid.amount + getFillableStack().amount) <= (long)getCapacity()) { if (aBaseMetaTileEntity.addStackToSlot(getOutputSlot(), GT_Utility.getContainerItem(mInventory[getInputSlot()], true), 1)) { getFillableStack().amount += tFluid.amount; aBaseMetaTileEntity.decrStackSize(getInputSlot(), 1); -- cgit From e6f726c7fa14413b8f57c2a7e2583cfd486fb8d1 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Tue, 23 Mar 2021 15:11:36 +0100 Subject: fix(rendering): brightness of no-z-fighting offset faces Ignore the z-fighting offset when detecting if a face uses the block's brightness or the brightness from the block above. --- src/main/java/gregtech/api/util/LightingHelper.java | 15 ++++++++------- .../java/gregtech/common/render/GT_Renderer_Block.java | 15 ++++++++------- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java index df70ffaeef..027fcd9c6d 100644 --- a/src/main/java/gregtech/api/util/LightingHelper.java +++ b/src/main/java/gregtech/api/util/LightingHelper.java @@ -31,6 +31,7 @@ import net.minecraft.client.renderer.Tessellator; public class LightingHelper { public static final int NORMAL_BRIGHTNESS = 0xff00ff; public static final int MAX_BRIGHTNESS = 0xf000f0; + public static final float NO_Z_FIGHT_OFFSET = 1.0F / 16384.0F; protected static final float[] LIGHTNESS = {0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F}; private final RenderBlocks renderBlocks; /** @@ -321,7 +322,7 @@ public class LightingHelper { if (renderBlocks.enableAO) { - int xOffset = renderBlocks.renderMinX > 0.0F ? x : x - 1; + int xOffset = renderBlocks.renderMinX > 0.0F + NO_Z_FIGHT_OFFSET ? x : x - 1; int mixedBrightness = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z); brightness = mixedBrightness; @@ -392,7 +393,7 @@ public class LightingHelper { if (renderBlocks.enableAO) { - int xOffset = renderBlocks.renderMaxX < 1.0F ? x : x + 1; + int xOffset = renderBlocks.renderMaxX < 1.0F - NO_Z_FIGHT_OFFSET ? x : x + 1; int mixedBrightness = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, xOffset, y, z); brightness = mixedBrightness; @@ -462,7 +463,7 @@ public class LightingHelper { if (renderBlocks.enableAO) { - int yOffset = renderBlocks.renderMinY > 0.0F ? y : y - 1; + int yOffset = renderBlocks.renderMinY > 0.0F + NO_Z_FIGHT_OFFSET ? y : y - 1; int mixedBrightness = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z); brightness = mixedBrightness; @@ -497,7 +498,7 @@ public class LightingHelper { float aoMixedXYZNNN = (renderBlocks.aoLightValueScratchXYNN + renderBlocks.aoLightValueScratchXYZNNN + aoLightValue + renderBlocks.aoLightValueScratchYZNN) / 4.0F; float aoMixedXYZNNP = (renderBlocks.aoLightValueScratchXYZNNP + renderBlocks.aoLightValueScratchXYNN + renderBlocks.aoLightValueScratchYZNP + aoLightValue) / 4.0F; - aoTopLeft = (float) (aoMixedXYZNNP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPNP * renderBlocks.renderMaxZ * renderBlocks.renderMinX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); + aoTopLeft = (float) (aoMixedXYZNNP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPNP * renderBlocks.renderMaxZ * renderBlocks.renderMinX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMinX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMinX)); aoBottomLeft = (float) (aoMixedXYZNNP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMinX) + aoMixedXYZPNP * renderBlocks.renderMinZ * renderBlocks.renderMinX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMinX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMinX)); aoBottomRight = (float) (aoMixedXYZNNP * renderBlocks.renderMinZ * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPNP * renderBlocks.renderMinZ * renderBlocks.renderMaxX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMinZ) * renderBlocks.renderMaxX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMinZ) * (1.0D - renderBlocks.renderMaxX)); aoTopRight = (float) (aoMixedXYZNNP * renderBlocks.renderMaxZ * (1.0D - renderBlocks.renderMaxX) + aoMixedXYZPNP * renderBlocks.renderMaxZ * renderBlocks.renderMaxX + aoMixedXYZPNN * (1.0D - renderBlocks.renderMaxZ) * renderBlocks.renderMaxX + aoMixedXYZNNN * (1.0D - renderBlocks.renderMaxZ) * (1.0D - renderBlocks.renderMaxX)); @@ -533,7 +534,7 @@ public class LightingHelper { if (renderBlocks.enableAO) { - int yOffset = renderBlocks.renderMaxY < 1.0F ? y : y + 1; + int yOffset = renderBlocks.renderMaxY < 1.0F - NO_Z_FIGHT_OFFSET ? y : y + 1; int mixedBrightness = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, yOffset, z); brightness = mixedBrightness; @@ -602,7 +603,7 @@ public class LightingHelper { if (renderBlocks.enableAO) { - int zOffset = renderBlocks.renderMinZ > 0.0F ? z : z - 1; + int zOffset = renderBlocks.renderMinZ > 0.0F + NO_Z_FIGHT_OFFSET ? z : z - 1; int mixedBrightness = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, zOffset); brightness = mixedBrightness; @@ -673,7 +674,7 @@ public class LightingHelper { if (renderBlocks.enableAO) { - int zOffset = renderBlocks.renderMaxZ < 1.0F ? z : z + 1; + int zOffset = renderBlocks.renderMaxZ < 1.0F - NO_Z_FIGHT_OFFSET ? z : z + 1; int mixedBrightness = block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, zOffset); brightness = mixedBrightness; diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Block.java b/src/main/java/gregtech/common/render/GT_Renderer_Block.java index e95f508d80..2f33a80dca 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -20,8 +20,9 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; +import static gregtech.api.util.LightingHelper.NO_Z_FIGHT_OFFSET; + public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { - private static final float NoZFightOffset = 1.0F / 16384.0F; public static GT_Renderer_Block INSTANCE; public final int mRenderID; @@ -305,7 +306,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); } if (tIsCovered[0]) { - aBlock.setBlockBounds(0.0F, 0.0F + NoZFightOffset, 0.0F, 1.0F, 0.125F, 1.0F); + aBlock.setBlockBounds(0.0F, 0.0F + NO_Z_FIGHT_OFFSET, 0.0F, 1.0F, 0.125F, 1.0F); aRenderer.setRenderBoundsFromBlock(aBlock); renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); @@ -323,7 +324,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { } } if (tIsCovered[1]) { - aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F - NoZFightOffset, 1.0F); + aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F - NO_Z_FIGHT_OFFSET, 1.0F); aRenderer.setRenderBoundsFromBlock(aBlock); renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); @@ -341,7 +342,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { } } if (tIsCovered[2]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F + NoZFightOffset, 1.0F, 1.0F, 0.125F); + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F + NO_Z_FIGHT_OFFSET, 1.0F, 1.0F, 0.125F); aRenderer.setRenderBoundsFromBlock(aBlock); if (!tIsCovered[0]) { renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); @@ -359,7 +360,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { } } if (tIsCovered[3]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F - NoZFightOffset); + aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F - NO_Z_FIGHT_OFFSET); aRenderer.setRenderBoundsFromBlock(aBlock); if (!tIsCovered[0]) { renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); @@ -377,7 +378,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { } } if (tIsCovered[4]) { - aBlock.setBlockBounds(0.0F + NoZFightOffset, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); + aBlock.setBlockBounds(0.0F + NO_Z_FIGHT_OFFSET, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); aRenderer.setRenderBoundsFromBlock(aBlock); if (!tIsCovered[0]) { renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); @@ -395,7 +396,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); } if (tIsCovered[5]) { - aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F - NoZFightOffset, 1.0F, 1.0F); + aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F - NO_Z_FIGHT_OFFSET, 1.0F, 1.0F); aRenderer.setRenderBoundsFromBlock(aBlock); if (!tIsCovered[0]) { renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); -- cgit From ae75be34340463832a847c9b31ef1c80d7b90550 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Wed, 24 Mar 2021 13:23:24 +0100 Subject: feat(cover): hide covers when holding a soldering-iron --- src/main/java/gregtech/api/enums/Textures.java | 6 ++++++ .../gregtech/api/metatileentity/BaseMetaPipeEntity.java | 8 ++++++++ .../gregtech/api/metatileentity/BaseMetaTileEntity.java | 7 +++++++ .../gregtech/textures/blocks/iconsets/HIDDEN_FACE.png | Bin 0 -> 118 bytes 4 files changed, 21 insertions(+) create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/HIDDEN_FACE.png (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index 3a9af71aa2..b2afa4216e 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -5,6 +5,7 @@ import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.GT_SidedTexture; +import gregtech.api.objects.GT_StdRenderedTexture; import gregtech.api.util.GT_Utility; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.util.IIcon; @@ -57,6 +58,8 @@ public class Textures { LONG_DISTANCE_PIPE_FLUID, LONG_DISTANCE_PIPE_ITEM, + HIDDEN_FACE, + MACHINE_CASING_TANK_1, MACHINE_CASING_TANK_2, MACHINE_CASING_TANK_3, @@ -1352,6 +1355,9 @@ public class Textures { BLOCK_CHARCOAL, BLOCK_BLAZE }; + public static ITexture[] HIDDEN_TEXTURE = new ITexture[]{ + new GT_StdRenderedTexture(BlockIcons.HIDDEN_FACE) + }; public static ITexture[] ERROR_RENDERING = new ITexture[]{ new GT_RenderedTexture(RENDERING_ERROR) diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 26fee68f2b..908dd88984 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -8,19 +8,23 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_StdRenderedTexture; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Client; import gregtech.common.covers.GT_Cover_Fluidfilter; import net.minecraft.block.Block; import net.minecraft.entity.Entity; @@ -484,6 +488,10 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE } public ITexture getCoverTexture(byte aSide) { + if (getCoverIDAtSide(aSide) == 0) return null; + if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) { + return BlockIcons.HIDDEN_TEXTURE[0]; // See through + } return GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide))); } diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 0781c57086..26122ae9e9 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -13,6 +13,7 @@ import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; +import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IEnergyConnected; @@ -21,11 +22,13 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachin import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.objects.GT_StdRenderedTexture; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Client; import gregtech.common.GT_Pollution; import ic2.api.Direction; import net.minecraft.block.Block; @@ -829,6 +832,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE } public ITexture getCoverTexture(byte aSide) { + if (getCoverIDAtSide(aSide) == 0) return null; + if (GT_Mod.instance.isClientSide() && (GT_Client.hideValue & 0x1) != 0) { + return BlockIcons.HIDDEN_TEXTURE[0]; // See through + } return GregTech_API.sCovers.get(new GT_ItemStack(getCoverIDAtSide(aSide))); } diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/HIDDEN_FACE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/HIDDEN_FACE.png new file mode 100644 index 0000000000..c2a9ed5cf0 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/iconsets/HIDDEN_FACE.png differ -- cgit From 93fd4f93dcb046836166c894be613b4531f80567 Mon Sep 17 00:00:00 2001 From: repo_alt Date: Thu, 25 Mar 2021 01:15:52 +0300 Subject: Enabled autoloading for oil drills Fixed chunk coordinates for self-loaded machine (in the first session) --- src/main/java/gregtech/api/objects/GT_ChunkManager.java | 2 +- .../machines/multi/GT_MetaTileEntity_DrillerBase.java | 5 ++++- .../machines/multi/GT_MetaTileEntity_OilDrillBase.java | 16 +++++++++++----- .../multi/GT_MetaTileEntity_OreDrillingPlantBase.java | 5 +---- 4 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/objects/GT_ChunkManager.java b/src/main/java/gregtech/api/objects/GT_ChunkManager.java index 0012bc78f4..ea2982e001 100644 --- a/src/main/java/gregtech/api/objects/GT_ChunkManager.java +++ b/src/main/java/gregtech/api/objects/GT_ChunkManager.java @@ -102,7 +102,7 @@ public class GT_ChunkManager implements ForgeChunkManager.OrderedLoadingCallback tag.setInteger("OwnerZ", owner.zCoord); ForgeChunkManager.forceChunk(ticket, chunkXZ); if (GT_Values.alwaysReloadChunkloaders) - ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(owner.xCoord << 4, owner.zCoord << 4)); + ForgeChunkManager.forceChunk(ticket, new ChunkCoordIntPair(owner.xCoord >> 4, owner.zCoord >> 4)); instance.registeredTickets.put(owner, ticket); } return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java index 68770644de..fdb61e1945 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java @@ -4,6 +4,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IChunkLoader; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -29,7 +30,7 @@ import java.util.ArrayList; import static gregtech.api.enums.GT_Values.W; -public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase { +public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase implements IChunkLoader { private static final ItemStack miningPipe = GT_ModHandler.getIC2Item("miningPipe", 0); private static final ItemStack miningPipeTip = GT_ModHandler.getIC2Item("miningPipeTip", 0); private static final Block miningPipeBlock = GT_Utility.getBlockFromStack(miningPipe); @@ -466,4 +467,6 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } return false; } + @Override + public ChunkCoordIntPair getActiveChunk(){return mCurrentChunk;} } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java index a7a7023d34..48e5309287 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrillBase.java @@ -2,6 +2,7 @@ package gregtech.common.tileentities.machines.multi; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.objects.GT_ChunkManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Utility; @@ -9,8 +10,10 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; @@ -25,10 +28,7 @@ import static gregtech.common.GT_UndergroundOil.undergroundOil; import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_DrillerBase { - - private boolean completedCycle = false; - - private ArrayList mOilFieldChunks = new ArrayList(); + private final ArrayList mOilFieldChunks = new ArrayList<>(); private int mOilId = 0; private int chunkRangeConfig = getRangeInChunks(); @@ -137,6 +137,11 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D } if (reachingVoidOrBedrock() && tryFillChunkList()) { + if (mWorkChunkNeedsReload) { + mCurrentChunk = new ChunkCoordIntPair(xDrill >> 4, zDrill >> 4); + GT_ChunkManager.requestChunkLoad((TileEntity) getBaseMetaTileEntity(), null); + mWorkChunkNeedsReload = false; + } float speed = .5F+(GT_Utility.getTier(getMaxInputVoltage()) - getMinTier()) *.25F; FluidStack tFluid = pumpOil(speed); if (tFluid != null && tFluid.amount > getTotalConfigValue()){ @@ -144,6 +149,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D return true; } } + GT_ChunkManager.releaseTicket((TileEntity)getBaseMetaTileEntity()); workState = STATE_UPWARD; return true; } @@ -220,7 +226,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D ); } - ArrayList emptyChunks = new ArrayList(); + ArrayList emptyChunks = new ArrayList<>(); for (Chunk tChunk : mOilFieldChunks) { tFluid = undergroundOil(tChunk,speed); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java index e34ed7466f..ea894fc725 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlantBase.java @@ -37,7 +37,7 @@ import org.lwjgl.input.Keyboard; import static gregtech.api.enums.GT_Values.VN; -public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase implements IChunkLoader { +public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTileEntity_DrillerBase { private final ArrayList oreBlockPositions = new ArrayList<>(); protected int mTier = 1; private int chunkRadiusConfig = getRadiusInChunks(); @@ -63,9 +63,6 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile chunkRadiusConfig = aNBT.getInteger("chunkRadiusConfig"); } - @Override - public ChunkCoordIntPair getActiveChunk(){return mCurrentChunk;} - @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OreDrillingPlant.png"); -- cgit From 891da876fde98a9627c16befe315a82b5f0456a3 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Thu, 25 Mar 2021 00:14:23 +0100 Subject: fix(tooltip): frameGT description Address issue: https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/7702 Remove mention of using CFoam over covers which has been replaced by chemical bath concrete based recipes since GT5.09. New Frame Box dexcription is localisable in `Gregtech.lang`: ```yaml S:gt.blockmachines.gt_frame.desc.format=Just something you can put covers on. ``` --- .../api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java index 7074d63422..455d327209 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Frame.java @@ -6,6 +6,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_ModHandler.RecipeBits; import gregtech.api.util.GT_OreDictUnificator; @@ -15,6 +16,9 @@ import net.minecraft.nbt.NBTTagCompound; import static gregtech.api.enums.GT_Values.RA; public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { + private static final String localizedDescFormat = GT_LanguageManager.addStringLocalization( + "gt.blockmachines.gt_frame.desc.format", + "Just something you can put covers on."); public final Materials mMaterial; public GT_MetaPipeEntity_Frame(int aID, String aName, String aNameRegional, Materials aMaterial) { @@ -48,7 +52,7 @@ public class GT_MetaPipeEntity_Frame extends MetaPipeEntity { @Override public String[] getDescription() { - return new String[]{"Just something you can put a Cover or CFoam on."}; + return localizedDescFormat.split("\\R"); } @Override -- cgit From 3d464a19d7c652fc64f5db7df8091479dc941932 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 28 Mar 2021 22:18:22 +0800 Subject: Reduce price of magic generators Basically make the recipes use T+1 circuits/metal instead of T+2. EV magic generator will additionally require tungsten steel plates to prevent it from becoming too cheap. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/enums/OrePrefixes.java | 2 +- .../loaders/postload/GT_MachineRecipeLoader.java | 38 ++++++++++++---------- 2 files changed, 21 insertions(+), 19 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/OrePrefixes.java b/src/main/java/gregtech/api/enums/OrePrefixes.java index 59c20d412b..ba91886c99 100644 --- a/src/main/java/gregtech/api/enums/OrePrefixes.java +++ b/src/main/java/gregtech/api/enums/OrePrefixes.java @@ -703,7 +703,7 @@ public enum OrePrefixes { if (!enableUnusedTriplePlates && !(aMaterial == Materials.Paper)) plateTriple.mDisabledItems.add(aMaterial); if (!enableUnusedQuadPlates && !(aMaterial == Materials.Paper)) plateQuadruple.mDisabledItems.add(aMaterial); if (!enableUnusedQuinPlates && !(aMaterial == Materials.Paper)) plateQuintuple.mDisabledItems.add(aMaterial); - if (!(enableUnusedDensePlates || GregTech_API.mGTPlusPlus) && !(aMaterial == Materials.Iron || aMaterial == Materials.Copper || aMaterial == Materials.Lead || aMaterial == Materials.Paper)) + if (!(enableUnusedDensePlates || GregTech_API.mGTPlusPlus) && !(aMaterial == Materials.Iron || aMaterial == Materials.Copper || aMaterial == Materials.Lead || aMaterial == Materials.Paper || aMaterial == Materials.Thaumium || aMaterial == Materials.Titanium)) plateDense.mDisabledItems.add(aMaterial); //Rotors if (!enableUnusedRotors && !(aMaterial == Materials.Titanium || aMaterial == Materials.Chrome || aMaterial == Materials.Tin || aMaterial == Materials.Osmium || diff --git a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java index ce5625fa48..d9d67aa6ea 100644 --- a/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java +++ b/src/main/java/gregtech/loaders/postload/GT_MachineRecipeLoader.java @@ -2636,10 +2636,10 @@ public class GT_MachineRecipeLoader implements Runnable { ItemList.Hull_LV.get(1L), new ItemStack[]{ new ItemStack(Blocks.beacon), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L), - GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 1L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Aluminium, 1L), ItemList.Sensor_MV.get(2L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Thaumium, 1L), ItemList.Sensor_MV.get(2L) }, @@ -2668,11 +2668,11 @@ public class GT_MachineRecipeLoader implements Runnable { ItemList.Hull_MV.get(1L), new ItemStack[]{ new ItemStack(Blocks.beacon), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 1L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L), GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Thaumium, 1L), ItemList.Sensor_HV.get(2L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 1L), - GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.Titanium, 1L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L), + GT_OreDictUnificator.get(OrePrefixes.plateDouble, Materials.StainlessSteel, 1L), ItemList.Sensor_HV.get(2L) }, ItemList.MagicEnergyConverter_MV.get(1L), @@ -2700,11 +2700,11 @@ public class GT_MachineRecipeLoader implements Runnable { ItemList.Hull_HV.get(1L), new ItemStack[]{ new ItemStack(Blocks.beacon), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 1L), GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Thaumium, 1L), ItemList.Field_Generator_MV.get(1L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1L), - GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.TungstenSteel, 1L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 1L), + GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Titanium, 1L), ItemList.Field_Generator_MV.get(1L) }, ItemList.MagicEnergyConverter_HV.get(1L), @@ -2733,7 +2733,7 @@ public class GT_MachineRecipeLoader implements Runnable { ItemList.Hull_LV.get(1L), new ItemStack[]{ ItemList.MagicEnergyConverter_LV.get(1L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 1L), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Thaumium, 1L), ItemList.Sensor_MV.get(2L) }, @@ -2785,11 +2785,11 @@ public class GT_MachineRecipeLoader implements Runnable { ItemList.Hull_HV.get(1L), new ItemStack[]{ ItemList.MagicEnergyConverter_MV.get(1L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1L), - GT_ModHandler.getModItem("Thaumcraft", "ItemResource", 1, 16), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Void, 1), ItemList.Field_Generator_MV.get(1L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1L), - GT_ModHandler.getModItem("Thaumcraft", "ItemResource", 1, 16) + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Data, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Void, 1), }, ItemList.MagicEnergyAbsorber_HV.get(1L), 8, @@ -2805,11 +2805,13 @@ public class GT_MachineRecipeLoader implements Runnable { ItemList.Hull_EV.get(1L), new ItemStack[]{ ItemList.MagicEnergyConverter_HV.get(1L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 1L), - GT_ModHandler.getModItem("Thaumcraft", "ItemResource", 1, 16), + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Void, 1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 1), ItemList.Field_Generator_HV.get(1L), - GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Master, 1L), - GT_ModHandler.getModItem("Thaumcraft", "ItemResource", 1, 16) + GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Elite, 1L), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Void, 1), + GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 1), }, ItemList.MagicEnergyAbsorber_EV.get(1L), 10, -- cgit From ae3b94a7c943aa2c393eaf82dfcff8879c0e06af Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 30 Mar 2021 02:22:23 +0800 Subject: Only update fluid display items when necessary Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/gui/GT_Container.java | 2 ++ .../implementations/GT_MetaTileEntity_BasicMachine.java | 2 +- .../implementations/GT_MetaTileEntity_BasicTank.java | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java index 4ce583cff5..671d68b917 100644 --- a/src/main/java/gregtech/api/gui/GT_Container.java +++ b/src/main/java/gregtech/api/gui/GT_Container.java @@ -26,6 +26,7 @@ public class GT_Container extends Container { mTileEntity = aTileEntityInventory; mPlayerInventory = aPlayerInventory; + mTileEntity.openInventory(); } /** @@ -468,6 +469,7 @@ public class GT_Container extends Container { public void onContainerClosed(EntityPlayer par1EntityPlayer) { try { super.onContainerClosed(par1EntityPlayer); + mTileEntity.closeInventory(); } catch (Throwable e) { e.printStackTrace(GT_Log.err); } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 4775158319..bf9303180e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -577,7 +577,7 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); } - if (displaysInputFluid()) { + if (mOpenerCount > 0 && displaysInputFluid()) { int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; if (getFillableStack() == null) { if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index 69ccd3ef48..44bae7dc98 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -21,6 +21,7 @@ import net.minecraftforge.fluids.FluidTankInfo; public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_TieredMachineBlock { public FluidStack mFluid; + protected int mOpenerCount; /** * @param aInvSlotCount should be 3 @@ -132,13 +133,25 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier return new GT_GUIContainer_BasicTank(aPlayerInventory, aBaseMetaTileEntity, getLocalName()); } + @Override + public void onOpenGUI() { + super.onOpenGUI(); + mOpenerCount++; + } + + @Override + public void onCloseGUI() { + super.onCloseGUI(); + mOpenerCount--; + } + @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) setFillableStack(null); - if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { + if (mOpenerCount > 0 && displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { if (getDisplayedFluid() == null) { if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) mInventory[getStackDisplaySlot()] = null; -- cgit From fc1d856190fb4db43995c0b3ce7f24f2dd87d44e Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 30 Mar 2021 03:24:38 +0800 Subject: Eagerly update the fluid display item upon inventory open There might be small desync for the first person to open this GUI Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_BasicMachine.java | 6 +++++- .../GT_MetaTileEntity_BasicTank.java | 23 ++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index bf9303180e..6bb335087c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -576,8 +576,12 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B mHasBeenUpdated = true; getBaseMetaTileEntity().setFrontFacing(getBaseMetaTileEntity().getBackFacing()); } + } - if (mOpenerCount > 0 && displaysInputFluid()) { + @Override + protected void updateFluidDisplayItem() { + super.updateFluidDisplayItem(); + if (displaysInputFluid()) { int tDisplayStackSlot = OTHER_SLOT_COUNT + mInputSlotCount + mOutputItems.length; if (getFillableStack() == null) { if (ItemList.Display_Fluid.isStackEqual(mInventory[tDisplayStackSlot], true, true)) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java index 44bae7dc98..219df59723 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicTank.java @@ -137,6 +137,8 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier public void onOpenGUI() { super.onOpenGUI(); mOpenerCount++; + if (mOpenerCount == 1) + updateFluidDisplayItem(); } @Override @@ -151,14 +153,8 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier if (isFluidChangingAllowed() && getFillableStack() != null && getFillableStack().amount <= 0) setFillableStack(null); - if (mOpenerCount > 0 && displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { - if (getDisplayedFluid() == null) { - if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) - mInventory[getStackDisplaySlot()] = null; - } else { - mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); - } - } + if (mOpenerCount > 0) + updateFluidDisplayItem(); if (doesEmptyContainers()) { FluidStack tFluid = GT_Utility.getFluidForFilledItem(mInventory[getInputSlot()], true); @@ -194,6 +190,17 @@ public abstract class GT_MetaTileEntity_BasicTank extends GT_MetaTileEntity_Tier } } + protected void updateFluidDisplayItem() { + if (displaysItemStack() && getStackDisplaySlot() >= 0 && getStackDisplaySlot() < mInventory.length) { + if (getDisplayedFluid() == null) { + if (ItemList.Display_Fluid.isStackEqual(mInventory[getStackDisplaySlot()], true, true)) + mInventory[getStackDisplaySlot()] = null; + } else { + mInventory[getStackDisplaySlot()] = GT_Utility.getFluidDisplayStack(getDisplayedFluid(), displaysStackSize()); + } + } + } + @Override public FluidStack getFluid() { return getDrainableStack(); -- cgit From 1dfd9dbd3498f1013f8ff84949c3b714021c90d4 Mon Sep 17 00:00:00 2001 From: charles Date: Tue, 30 Mar 2021 11:20:20 -0600 Subject: Made it so that machine control covers disable themselves when the machine runs out of energy --- .../api/interfaces/metatileentity/IMetaTileEntity.java | 1 + .../api/interfaces/tileentity/IGregTechTileEntity.java | 2 ++ .../api/interfaces/tileentity/IMachineProgress.java | 8 ++++++++ .../gregtech/api/metatileentity/BaseMetaTileEntity.java | 12 ++++++++++++ .../java/gregtech/api/metatileentity/MetaTileEntity.java | 1 + .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 7 ++++++- .../java/gregtech/common/covers/GT_Cover_ControlsWork.java | 13 +++++++++---- src/main/java/gregtech/loaders/misc/GT_Achievements.java | 4 ++-- 8 files changed, 41 insertions(+), 7 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java index f0ca426616..2bf61f6679 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IMetaTileEntity.java @@ -422,4 +422,5 @@ public interface IMetaTileEntity extends ISidedInventory, IFluidTank, IFluidHand default boolean isMachineBlockUpdateRecursive(){ return true; } + } diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java index 9ab1ac0f67..8a815556e7 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IGregTechTileEntity.java @@ -155,4 +155,6 @@ public interface IGregTechTileEntity extends ITexturedTileEntity, IGearEnergyTil getMetaTileEntity().getBaseMetaTileEntity() == this && getMetaTileEntity().isMachineBlockUpdateRecursive(); } + + default void setShutdownStatus(boolean newStatus) {return;} } \ No newline at end of file diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java b/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java index 588158d16c..bae361421c 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IMachineProgress.java @@ -66,4 +66,12 @@ public interface IMachineProgress extends IHasWorldObjectAndCoords { * sets the visible Active Status of the Machine */ void setActive(boolean aActive); + + /** + * Indicates if the object in question was forced to shut down (i.e. loss of power) + * */ + default boolean wasShutdown() { + return false; + } + } \ No newline at end of file diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 26122ae9e9..42289c9a29 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -92,6 +92,8 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE private UUID mOwnerUuid = GT_Utility.defaultUuid; private NBTTagCompound mRecipeStuff = new NBTTagCompound(); + public boolean _wasShutdown = false; + private static final Field ENTITY_ITEM_HEALTH_FIELD; static { @@ -1004,6 +1006,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public void enableWorking() { if (!mWorks) mWorkUpdate = true; mWorks = true; + _wasShutdown = false; } @Override @@ -2318,4 +2321,13 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE if (gp != null) gp.invalidate(); } + + @Override + public boolean wasShutdown() { + return _wasShutdown; + } + + public void setShutdownStatus(boolean newStatus) { + _wasShutdown = newStatus; + } } diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index 79447a96cb..c9d75dad1a 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -57,6 +57,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { */ public final ItemStack[] mInventory; public boolean doTickProfilingInThisTick = true; + /** * accessibility to this Field is no longer given, see below */ diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 3adff2fc3f..9dd8f6f975 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -341,7 +341,7 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { } if (mEUt < 0) { if (!drainEnergyInput(((long) -mEUt * 10000) / Math.max(1000, mEfficiency))) { - stopMachine(); + criticalStopMachine(); return false; } } @@ -393,6 +393,11 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { getBaseMetaTileEntity().disableWorking(); } + public void criticalStopMachine() { + stopMachine(); + getBaseMetaTileEntity().setShutdownStatus(true); + } + public int getRepairStatus() { return (mWrench ? 1 : 0) + (mScrewdriver ? 1 : 0) + (mSoftHammer ? 1 : 0) + (mHardHammer ? 1 : 0) + (mSolderingTool ? 1 : 0) + (mCrowbar ? 1 : 0); } diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java index 487d457b39..d8f2c19c37 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java @@ -16,11 +16,16 @@ import net.minecraftforge.fluids.Fluid; public class GT_Cover_ControlsWork extends GT_CoverBehavior { public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if (aTileEntity instanceof IMachineProgress) { - if ((aInputRedstone > 0) == (aCoverVariable == 0) && aCoverVariable != 2) - ((IMachineProgress) aTileEntity).enableWorking(); - else + if (!((IMachineProgress) aTileEntity).wasShutdown()) { + if ((aInputRedstone > 0) == (aCoverVariable == 0) && aCoverVariable != 2) + ((IMachineProgress) aTileEntity).enableWorking(); + else + ((IMachineProgress) aTileEntity).disableWorking(); + ((IMachineProgress) aTileEntity).setWorkDataValue(aInputRedstone); + } else { ((IMachineProgress) aTileEntity).disableWorking(); - ((IMachineProgress) aTileEntity).setWorkDataValue(aInputRedstone); + return 2; + } } return aCoverVariable; } diff --git a/src/main/java/gregtech/loaders/misc/GT_Achievements.java b/src/main/java/gregtech/loaders/misc/GT_Achievements.java index 456705eba4..c67fa69fd8 100644 --- a/src/main/java/gregtech/loaders/misc/GT_Achievements.java +++ b/src/main/java/gregtech/loaders/misc/GT_Achievements.java @@ -198,7 +198,7 @@ public class GT_Achievements { if (special) { achievement.setSpecial(); } - achievement.registerStat(); + ((StatBase)achievement).registerStat(); if (GT_Values.D2) { GT_Log.out.println("achievement." + textId + "="); GT_Log.out.println("achievement." + textId + ".desc="); @@ -216,7 +216,7 @@ public class GT_Achievements { if (special) { achievement.setSpecial(); } - achievement.registerStat(); + ((StatBase)achievement).registerStat(); if (GT_Values.D2) { GT_Log.out.println("achievement." + textId + "="); GT_Log.out.println("achievement." + textId + ".desc="); -- cgit From e2cbd4887ccdffbc02319f9c5be02f8f11048c39 Mon Sep 17 00:00:00 2001 From: charles Date: Tue, 30 Mar 2021 12:10:47 -0600 Subject: Updated to use proper naming conventions. --- src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java index 42289c9a29..262eac674c 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaTileEntity.java @@ -92,7 +92,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE private UUID mOwnerUuid = GT_Utility.defaultUuid; private NBTTagCompound mRecipeStuff = new NBTTagCompound(); - public boolean _wasShutdown = false; + public boolean mWasShutdown = false; private static final Field ENTITY_ITEM_HEALTH_FIELD; static @@ -1006,7 +1006,7 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE public void enableWorking() { if (!mWorks) mWorkUpdate = true; mWorks = true; - _wasShutdown = false; + mWasShutdown = false; } @Override @@ -2324,10 +2324,10 @@ public class BaseMetaTileEntity extends BaseTileEntity implements IGregTechTileE @Override public boolean wasShutdown() { - return _wasShutdown; + return mWasShutdown; } public void setShutdownStatus(boolean newStatus) { - _wasShutdown = newStatus; + mWasShutdown = newStatus; } } -- cgit From 320fc85f4b2856d83f98c8c58bc76853e2cea207 Mon Sep 17 00:00:00 2001 From: charles Date: Tue, 30 Mar 2021 20:23:50 -0600 Subject: Added GUI interface for cover "Safe Mode" Added tracking of last player to access a cover for future notification purposes. --- .../java/gregtech/api/util/GT_CoverBehavior.java | 3 ++ .../common/covers/GT_Cover_ControlsWork.java | 63 ++++++++++++++++++---- 2 files changed, 56 insertions(+), 10 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_CoverBehavior.java b/src/main/java/gregtech/api/util/GT_CoverBehavior.java index c0ad751add..ef332ddb01 100644 --- a/src/main/java/gregtech/api/util/GT_CoverBehavior.java +++ b/src/main/java/gregtech/api/util/GT_CoverBehavior.java @@ -15,6 +15,9 @@ import static gregtech.api.enums.GT_Values.E; * For Covers with a special behavior. */ public abstract class GT_CoverBehavior { + + public EntityPlayer lastPlayer = null; + /** * Called by updateEntity inside the covered TileEntity. aCoverVariable is the Value you returned last time. */ diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java index d8f2c19c37..dbe9f7d9c0 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java @@ -1,30 +1,45 @@ package gregtech.common.covers; +import cpw.mods.fml.client.FMLClientHandler; import gregtech.api.enums.GT_Values; import gregtech.api.gui.GT_GUICover; import gregtech.api.gui.widgets.GT_GuiIcon; import gregtech.api.gui.widgets.GT_GuiIconButton; +import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Utility; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; +import net.minecraft.world.WorldServer; + +import static gregtech.GT_Mod.GT_FML_LOGGER; public class GT_Cover_ControlsWork extends GT_CoverBehavior { public int doCoverThings(byte aSide, byte aInputRedstone, int aCoverID, int aCoverVariable, ICoverable aTileEntity, long aTimer) { if (aTileEntity instanceof IMachineProgress) { - if (!((IMachineProgress) aTileEntity).wasShutdown()) { - if ((aInputRedstone > 0) == (aCoverVariable == 0) && aCoverVariable != 2) + if (aCoverVariable < 2) { + if ((aInputRedstone > 0) == (aCoverVariable == 0)) ((IMachineProgress) aTileEntity).enableWorking(); else ((IMachineProgress) aTileEntity).disableWorking(); ((IMachineProgress) aTileEntity).setWorkDataValue(aInputRedstone); - } else { + } + else if (aCoverVariable == 2) { ((IMachineProgress) aTileEntity).disableWorking(); - return 2; + } else { + if (((IMachineProgress) aTileEntity).wasShutdown()) { + ((IMachineProgress) aTileEntity).disableWorking(); + // TODO: Notify lastPlayer the name and location of machine and that it stopped + return 2; + } else { + return 3 + doCoverThings(aSide,aInputRedstone, aCoverID, aCoverVariable - 3, aTileEntity, aTimer); + } } } return aCoverVariable; @@ -63,17 +78,24 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { } public int onCoverScrewdriverclick(byte aSide, int aCoverID, int aCoverVariable, ICoverable aTileEntity, EntityPlayer aPlayer, float aX, float aY, float aZ) { - aCoverVariable = (aCoverVariable + (aPlayer.isSneaking()? -1 : 1)) % 3; + aCoverVariable = (aCoverVariable + (aPlayer.isSneaking()? -1 : 1)) % 5; if(aCoverVariable <0){aCoverVariable = 2;} if (aCoverVariable == 0) { - GT_Utility.sendChatToPlayer(aPlayer, trans("003", "Normal")); + GT_Utility.sendChatToPlayer(aPlayer, trans("003", "Enable with Signal")); } if (aCoverVariable == 1) { - GT_Utility.sendChatToPlayer(aPlayer, trans("004", "Inverted")); + GT_Utility.sendChatToPlayer(aPlayer, trans("004", "Disable with Signal")); } if (aCoverVariable == 2) { - GT_Utility.sendChatToPlayer(aPlayer, trans("005", "No Work at all")); + GT_Utility.sendChatToPlayer(aPlayer, trans("005", "Disabled")); + } + if (aCoverVariable == 3) { + GT_Utility.sendChatToPlayer(aPlayer, trans("505", "Enable with Signal (Safe)")); + } + if (aCoverVariable == 4) { + GT_Utility.sendChatToPlayer(aPlayer, trans("506", "Disable with Signal (Safe)")); } + // TODO: Set lastPlayer return aCoverVariable; } @@ -115,6 +137,8 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { b = new GT_GuiIconButton(this, 0, startX + spaceX * 0, startY + spaceY * 0, GT_GuiIcon.REDSTONE_ON); b = new GT_GuiIconButton(this, 1, startX + spaceX * 0, startY + spaceY * 1, GT_GuiIcon.REDSTONE_OFF); b = new GT_GuiIconButton(this, 2, startX + spaceX * 0, startY + spaceY * 2, GT_GuiIcon.CROSS); + + b = new GT_GuiIconCheckButton(this, 3, startX + spaceX * 0, startY + spaceY * 3, GT_GuiIcon.CHECKMARK, GT_GuiIcon.CROSS); } @Override @@ -123,6 +147,7 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { this.fontRendererObj.drawString(trans("243", "Enable with Redstone"), 3+startX + spaceX*1, 4+startY+spaceY*0, 0xFF555555); this.fontRendererObj.drawString(trans("244", "Disable with Redstone"),3+startX + spaceX*1, 4+startY+spaceY*1, 0xFF555555); this.fontRendererObj.drawString(trans("245", "Disable machine"), 3+startX + spaceX*1, 4+startY+spaceY*2, 0xFF555555); + this.fontRendererObj.drawString(trans("507", "Safe Mode"), 3+startX + spaceX*1, 4+startY+spaceY*3, 0xFF555555); } @Override @@ -132,7 +157,14 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { public void buttonClicked(GuiButton btn) { if (getClickable(btn.id)) { - coverVariable = getNewCoverVariable(btn.id); + int bID = btn.id; + if (bID == 3) { + ((GT_GuiIconCheckButton) btn).setChecked(!((GT_GuiIconCheckButton) btn).isChecked()); + } else { + coverVariable = getNewCoverVariable(bID); + } + adjustCoverVariable(); + // TODO: Set lastPlayer; GT_Values.NW.sendToServer(new GT_Packet_TileEntityCover(side, coverID, coverVariable, tile)); } updateButtons(); @@ -151,7 +183,18 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { } private boolean getClickable(int id) { - return id != coverVariable; + return ((id != coverVariable && id != coverVariable - 3) || id == 3); + } + + private void adjustCoverVariable() { + boolean safeMode = ((GT_GuiIconCheckButton) buttonList.get(3)).isChecked(); + if (safeMode && coverVariable < 2) { + coverVariable += 3; + } + if (!safeMode && coverVariable > 2) { + coverVariable -= 3; + } } + } } -- cgit From 95fb72834838aa365afd4c418b7b70c66644ffc2 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Wed, 31 Mar 2021 22:51:34 +0200 Subject: Fix return value for addOutput(fluid) --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 3adff2fc3f..be7a3642cb 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -703,9 +703,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aLiquid == null) return false; FluidStack copiedFluidStack = aLiquid.copy(); if (!dumpFluid(copiedFluidStack, true)){ - dumpFluid(copiedFluidStack, false); + return dumpFluid(copiedFluidStack, false); } - return false; + return true; } protected void addFluidOutputs(FluidStack[] mOutputFluids2) { -- cgit From 6981d6370945d1e53c96508ddf541c6234383028 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 2 Apr 2021 00:56:35 +0800 Subject: Prevent multiple stack in input slots even if input filter is disabled (#489) Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../examples/GT_MetaTileEntity_E_Furnace.java | 4 +-- .../GT_MetaTileEntity_BasicMachine.java | 9 +++-- .../GT_MetaTileEntity_BasicMachine_GT_Recipe.java | 5 ++- .../basic/GT_MetaTileEntity_Boxinator.java | 40 ++++++++++------------ .../basic/GT_MetaTileEntity_CuringOven.java | 5 +-- .../basic/GT_MetaTileEntity_Disassembler.java | 5 +-- .../machines/basic/GT_MetaTileEntity_Miner.java | 5 +-- .../basic/GT_MetaTileEntity_PotionBrewer.java | 5 +-- .../basic/GT_MetaTileEntity_Replicator.java | 5 +-- .../basic/GT_MetaTileEntity_RockBreaker.java | 5 +-- .../machines/basic/GT_MetaTileEntity_Scanner.java | 5 +-- .../steam/GT_MetaTileEntity_Furnace_Bronze.java | 8 ++--- .../steam/GT_MetaTileEntity_Furnace_Steel.java | 8 ++--- .../steam/GT_MetaTileEntity_Macerator_Bronze.java | 8 ++--- .../steam/GT_MetaTileEntity_Macerator_Steel.java | 8 ++--- 15 files changed, 62 insertions(+), 63 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java index d0f3074af1..01f11142ac 100644 --- a/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java +++ b/src/main/java/gregtech/api/metatileentity/examples/GT_MetaTileEntity_E_Furnace.java @@ -43,8 +43,8 @@ public class GT_MetaTileEntity_E_Furnace extends GT_MetaTileEntity_BasicMachine } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (mDisableFilter || GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null); + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64, aStack), false, null) != null; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index 6bb335087c..d940ff6602 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -828,14 +828,17 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { if (aSide == mMainFacing || aIndex < getInputSlot() || aIndex >= getInputSlot() + mInputSlotCount || (!mAllowInputFromOutputSide && aSide == aBaseMetaTileEntity.getFrontFacing())) return false; - if (mDisableFilter) return true; for (int i = getInputSlot(), j = i + mInputSlotCount; i < j; i++) if (GT_Utility.areStacksEqual(GT_OreDictUnificator.get(aStack), mInventory[i])) return i == aIndex; - return true; + return mDisableFilter || allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack); } + /** + * Test if given stack can be inserted into specified slot. + * Before execution of this method it is ensured there is no such kind of item inside any input slots already. + */ protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return true; + return mInventory[aIndex] == null; } /** diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index 84b9fd9d5f..00ce4051ec 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -738,9 +738,8 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ } @Override - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; - if (this.mInventory[aIndex] != null || mDisableFilter) return true; + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) return false; switch (this.mInputSlotCount) { case 0: return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java index d892adabfb..aabce730d0 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Boxinator.java @@ -122,28 +122,26 @@ public class GT_MetaTileEntity_Boxinator extends GT_MetaTileEntity_BasicMachine return DID_NOT_FIND_RECIPE; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) { - if (mDisableFilter) return true; - ItemStack tInput1 = getInputAt(1); - if ((ItemList.Schematic_1by1.isStackEqual(tInput1)) || (ItemList.Schematic_2by2.isStackEqual(tInput1)) || (ItemList.Schematic_3by3.isStackEqual(tInput1))) { - if (hasValidCache(aStack,aTypeCache,false)) - return true; - if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe(getBaseMetaTileEntity(), true, gregtech.api.enums.GT_Values.V[mTier], null, new ItemStack[]{GT_Utility.copyAmount(64L, new Object[]{aStack}), tInput1}) != null) { - return true; - } - if (ItemList.Schematic_1by1.isStackEqual(getInputAt(1)) && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack}) != null) - return true; - if (ItemList.Schematic_2by2.isStackEqual(getInputAt(1)) && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack, aStack, null, aStack, aStack}) != null) { - return true; - } - if (ItemList.Schematic_3by3.isStackEqual(getInputAt(1)) && (GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack}) != null)) { - return true; - } - } else { - return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + if (!super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) { + return false; + } + ItemStack tInput1 = getInputAt(1); + if ((ItemList.Schematic_1by1.isStackEqual(tInput1)) || (ItemList.Schematic_2by2.isStackEqual(tInput1)) || (ItemList.Schematic_3by3.isStackEqual(tInput1))) { + if (hasValidCache(aStack,aTypeCache,false)) + return true; + if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe(getBaseMetaTileEntity(), true, gregtech.api.enums.GT_Values.V[mTier], null, new ItemStack[]{GT_Utility.copyAmount(64L, new Object[]{aStack}), tInput1}) != null) { + return true; + } + if (ItemList.Schematic_1by1.isStackEqual(getInputAt(1)) && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack}) != null) + return true; + if (ItemList.Schematic_2by2.isStackEqual(getInputAt(1)) && GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack, aStack, null, aStack, aStack}) != null) { + return true; } + return ItemList.Schematic_3by3.isStackEqual(getInputAt(1)) && (GT_ModHandler.getRecipeOutput(new ItemStack[]{aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack}) != null); + } else { + return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); } - return false; } } diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java index 11f653f085..2772d15386 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_CuringOven.java @@ -34,8 +34,9 @@ public class GT_MetaTileEntity_CuringOven extends GT_MetaTileEntity_BasicMachine return new GT_MetaTileEntity_CuringOven(this.mName, this.mTier, this.mDescriptionArray, this.mTextures, this.mGUIName, this.mNEIName); } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (mDisableFilter || (ItemList.Cell_Empty.isStackEqual(aStack))); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return (super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack)) && ItemList.Cell_Empty.isStackEqual(aStack); } public boolean isFluidInputAllowed(FluidStack aFluid) { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java index c8276f8747..2260949ff1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Disassembler.java @@ -493,7 +493,8 @@ public class GT_MetaTileEntity_Disassembler extends GT_MetaTileEntity_BasicMachi return inputValue / outputValue; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (mDisableFilter || (aStack.getTagCompound() != null) && (aStack.getTagCompound().getCompoundTag("GT.CraftingComponents") != null)); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && aStack.getTagCompound() != null && aStack.getTagCompound().getCompoundTag("GT.CraftingComponents") != null; } } \ No newline at end of file diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java index 35cc78d162..2acad0edfa 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Miner.java @@ -79,8 +79,9 @@ public class GT_MetaTileEntity_Miner extends GT_MetaTileEntity_BasicMachine { return new GT_MetaTileEntity_Miner(mName, mTier, mDescriptionArray, mTextures, mGUIName, mNEIName); } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (mDisableFilter || aStack.getItem() == MINING_PIPE.getItem()); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && aStack.getItem() == MINING_PIPE.getItem(); } public boolean hasFreeSpace() { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java index 7341d3cd78..67db36d6e2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_PotionBrewer.java @@ -130,8 +130,9 @@ public class GT_MetaTileEntity_PotionBrewer extends GT_MetaTileEntity_BasicMachi return 2; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (mDisableFilter || getRecipeList().containsInput(aStack)); + @Override + public boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && getRecipeList().containsInput(aStack); } public boolean isFluidInputAllowed(FluidStack aFluid) { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java index 151a2cf25b..3df33fc6c4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Replicator.java @@ -101,8 +101,9 @@ public class GT_MetaTileEntity_Replicator return GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && (mDisableFilter || ItemList.Cell_Empty.isStackEqual(aStack)); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && ItemList.Cell_Empty.isStackEqual(aStack); } public boolean isFluidInputAllowed(FluidStack aFluid) { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java index 932c7a14ec..37113e0f9a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_RockBreaker.java @@ -35,8 +35,9 @@ public class GT_MetaTileEntity_RockBreaker extends GT_MetaTileEntity_BasicMachin return GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (mDisableFilter || getRecipeList().containsInput(aStack)); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack) && getRecipeList().containsInput(aStack); } public int checkRecipe() { diff --git a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java index 3e4a0846b5..2fcecc41ad 100644 --- a/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java +++ b/src/main/java/gregtech/common/tileentities/machines/basic/GT_MetaTileEntity_Scanner.java @@ -348,8 +348,9 @@ public class GT_MetaTileEntity_Scanner extends GT_MetaTileEntity_BasicMachine { return 1000; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - return (super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) && (mDisableFilter || getRecipeList().containsInput(aStack)); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && getRecipeList().containsInput(aStack); } public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java index e7a83eda38..de8dd8aa64 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Bronze.java @@ -43,11 +43,9 @@ public class GT_MetaTileEntity_Furnace_Bronze extends GT_MetaTileEntity_BasicMac return 0; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) { - return false; - } - return mDisableFilter || GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64L, aStack), false, null) != null; + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64L, aStack), false, null) != null; } public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java index 9d0fb8309e..095328eb95 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Furnace_Steel.java @@ -43,11 +43,9 @@ public class GT_MetaTileEntity_Furnace_Steel extends GT_MetaTileEntity_BasicMach return 0; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) { - return false; - } - return mDisableFilter || GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64L, aStack), false, null) != null; + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_ModHandler.getSmeltingOutput(GT_Utility.copyAmount(64L, aStack), false, null) != null; } public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java index 758d206755..7460b874df 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Bronze.java @@ -77,11 +77,9 @@ public class GT_MetaTileEntity_Macerator_Bronze extends GT_MetaTileEntity_BasicM return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) { - return false; - } - return mDisableFilter || GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.containsInput(GT_Utility.copyAmount(64L, aStack)); + @Override + protected boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_Recipe_Map.sMaceratorRecipes.containsInput(GT_Utility.copyAmount(64L, aStack)); } public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { diff --git a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java index 235b341210..2af1ae0793 100644 --- a/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java +++ b/src/main/java/gregtech/common/tileentities/machines/steam/GT_MetaTileEntity_Macerator_Steel.java @@ -77,11 +77,9 @@ public class GT_MetaTileEntity_Macerator_Steel extends GT_MetaTileEntity_BasicMa return FOUND_AND_SUCCESSFULLY_USED_RECIPE; } - public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (!super.allowPutStack(aBaseMetaTileEntity, aIndex, aSide, aStack)) { - return false; - } - return mDisableFilter || GT_Recipe.GT_Recipe_Map.sMaceratorRecipes.containsInput(GT_Utility.copyAmount(64L, aStack)); + @Override + public boolean allowPutStackValidated(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return super.allowPutStackValidated(aBaseMetaTileEntity, aIndex, aSide, aStack) && GT_Recipe_Map.sMaceratorRecipes.containsInput(GT_Utility.copyAmount(64L, aStack)); } public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { -- cgit From 3d47955e536152651d17babc0f4243b52f2b62d2 Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 2 Apr 2021 08:13:09 -0600 Subject: Added sorting of buffer inventories using code from the input bus class. --- .../implementations/GT_MetaTileEntity_Buffer.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 7c57076ae9..a8d0dbaa0e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -250,6 +250,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { if (aBaseMetaTileEntity.isAllowedToWork() && aBaseMetaTileEntity.isServerSide() && (aBaseMetaTileEntity.hasWorkJustBeenEnabled() || aBaseMetaTileEntity.hasInventoryBeenModified() || aTimer % 200 == 0 || mSuccess > 0)) { mSuccess--; + updateSlots(); moveItems(aBaseMetaTileEntity, aTimer); for(byte b = 0;b<6;b++) aBaseMetaTileEntity.setInternalOutputRedstoneSignal(b,bInvert ? (byte)15 : (byte)0); @@ -300,4 +301,18 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM public boolean allowGeneralRedstoneOutput(){ return true; } + + public void updateSlots() { + for (int i = 0; i < mInventory.length; i++) + if (mInventory[i] != null && mInventory[i].stackSize <= 0) mInventory[i] = null; + fillStacksIntoFirstSlots(); + } + + protected void fillStacksIntoFirstSlots() { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null && mInventory[j].stackSize <= 0 && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } -- cgit From cedb62f4d95c1f7259a7ef1c428839ba138ddcba Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 2 Apr 2021 11:12:57 -0600 Subject: Fixed stupid error I made Set groundwork for configuring with soldering iron. --- .../implementations/GT_MetaTileEntity_Buffer.java | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index a8d0dbaa0e..9694db70a4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -20,7 +20,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM private static final int ARROW_UP_INDEX = 4; private static final int FRONT_INDEX = 5; - public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false; + public boolean bOutput = false, bRedstoneIfFull = false, bInvert = false, bStockingMode = false, bSortStacks = false; public int mSuccess = 0, mTargetStackSize = 0; public GT_MetaTileEntity_Buffer(int aID, String aName, String aNameRegional, int aTier, int aInvSlotCount, String aDescription) { @@ -213,6 +213,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM aNBT.setBoolean("bRedstoneIfFull", bRedstoneIfFull); aNBT.setBoolean("bStockingMode", bStockingMode); aNBT.setInteger("mTargetStackSize", mTargetStackSize); + aNBT.setBoolean("bSortStacks", bSortStacks); } @Override @@ -309,10 +310,23 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM } protected void fillStacksIntoFirstSlots() { - for (int i = 0; i < mInventory.length; i++) - for (int j = i + 1; j < mInventory.length; j++) - if (mInventory[j] != null && mInventory[j].stackSize <= 0 && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + if (bSortStacks) { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + else { + for (int i = 0; i < mInventory.length; i++) + for (int j = i + 1; j < mInventory.length; j++) + if (mInventory[j] != null && mInventory[j].stackSize <= 0 && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) + GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); + } + } + + @Override + public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + return super().onSolderingToolRightClick(aSide,aWrenchingSide,aPlayer,aX,aY,aZ); } } -- cgit From fc0da2e3edd0893b307c43ee1369a5bf19acd7ba Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 2 Apr 2021 11:31:28 -0600 Subject: Added Soldering Iron toggle behavior for sorting using shift+right-click. Sorting defaults to disabled in order to not break existing builds. --- .../implementations/GT_MetaTileEntity_Buffer.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 9694db70a4..e280f626d1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -221,6 +221,7 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM bInvert = aNBT.getBoolean("bInvert"); bOutput = aNBT.getBoolean("bOutput"); bRedstoneIfFull = aNBT.getBoolean("bRedstoneIfFull"); + bSortStacks = aNBT.getBoolean("bSortStacks"); if (aNBT.hasKey("bStockingMode")) { // Adding new key to existing NBT, need to protect if it is not there. bStockingMode = aNBT.getBoolean("bStockingMode"); } @@ -326,7 +327,15 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - return super().onSolderingToolRightClick(aSide,aWrenchingSide,aPlayer,aX,aY,aZ); + if (aPlayer.isSneaking()) { + if (bSortStacks = !bSortStacks) { + GT_Utility.sendChatToPlayer(aPlayer, "Auto-Sort Enabled"); + } else { + GT_Utility.sendChatToPlayer(aPlayer, "Auto-Sort Disabled"); + } + return true; + } + return super.onSolderingToolRightClick(aSide,aWrenchingSide,aPlayer,aX,aY,aZ); } } -- cgit From 5ef5126a0e4ec79159ca15ad300b03c37f4ce2a3 Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 2 Apr 2021 13:43:32 -0600 Subject: Removed unecessary else branch. --- .../metatileentity/implementations/GT_MetaTileEntity_Buffer.java | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index e280f626d1..a2cd8592ce 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -317,12 +317,6 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (mInventory[j] != null && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); } - else { - for (int i = 0; i < mInventory.length; i++) - for (int j = i + 1; j < mInventory.length; j++) - if (mInventory[j] != null && mInventory[j].stackSize <= 0 && (mInventory[i] == null || GT_Utility.areStacksEqual(mInventory[i], mInventory[j]))) - GT_Utility.moveStackFromSlotAToSlotB(getBaseMetaTileEntity(), getBaseMetaTileEntity(), j, i, (byte) 64, (byte) 1, (byte) 64, (byte) 1); - } } @Override -- cgit From ee790c8e492e0b5dbc48811542240a73fdd6de00 Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 2 Apr 2021 16:15:27 -0600 Subject: Cleaned up some code and fixed translation issue. --- .../metatileentity/implementations/GT_MetaTileEntity_Buffer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index a2cd8592ce..39fc12eea0 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -322,11 +322,9 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM @Override public boolean onSolderingToolRightClick(byte aSide, byte aWrenchingSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (aPlayer.isSneaking()) { - if (bSortStacks = !bSortStacks) { - GT_Utility.sendChatToPlayer(aPlayer, "Auto-Sort Enabled"); - } else { - GT_Utility.sendChatToPlayer(aPlayer, "Auto-Sort Disabled"); - } + // I was so proud of all this but I literally just copied code from OutputBus + bSortStacks = !bSortStacks; + GT_Utility.sendChatToPlayer(aPlayer, trans("200", "Sort mode: " + (bSortStacks ? "Disabled" : "Enabled"))); return true; } return super.onSolderingToolRightClick(aSide,aWrenchingSide,aPlayer,aX,aY,aZ); -- cgit From 486dacc5d03c2d2c89297ab673479d2c17085d0e Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 2 Apr 2021 16:53:33 -0600 Subject: Added scanning data reflecting if device shut down. Added notification to player that device shut down. Added scanning data reflecting if the device was disabled by soft mallet, cover, etc. --- src/main/java/gregtech/api/util/GT_Utility.java | 6 ++++++ src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index a9ba9b9bbc..9558df4608 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -1981,6 +1981,12 @@ public class GT_Utility { } try { if (tTileEntity instanceof IMachineProgress) { + if (((IMachineProgress) tTileEntity).isAllowedToWork()) { + tList.add("Disabled." + EnumChatFormatting.RED + EnumChatFormatting.RESET); + } + if (((IMachineProgress) tTileEntity).wasShutdown()) { + tList.add("Shut down due to power loss." + EnumChatFormatting.RED + EnumChatFormatting.RESET); + } rEUAmount += 400; int tValue = 0; if (0 < (tValue = ((IMachineProgress) tTileEntity).getMaxProgress())) diff --git a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java index dbe9f7d9c0..ba943e4286 100644 --- a/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java +++ b/src/main/java/gregtech/common/covers/GT_Cover_ControlsWork.java @@ -8,6 +8,7 @@ import gregtech.api.gui.widgets.GT_GuiIconButton; import gregtech.api.gui.widgets.GT_GuiIconCheckButton; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IMachineProgress; +import gregtech.api.metatileentity.BaseTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.net.GT_Packet_TileEntityCover; import gregtech.api.util.GT_CoverBehavior; @@ -35,7 +36,7 @@ public class GT_Cover_ControlsWork extends GT_CoverBehavior { } else { if (((IMachineProgress) aTileEntity).wasShutdown()) { ((IMachineProgress) aTileEntity).disableWorking(); - // TODO: Notify lastPlayer the name and location of machine and that it stopped + GT_Utility.sendChatToPlayer(lastPlayer, aTileEntity.getInventoryName() + "at " + String.format("(%d,%d,%d)", aTileEntity.getXCoord(), aTileEntity.getYCoord(), aTileEntity.getZCoord()) + " shut down."); return 2; } else { return 3 + doCoverThings(aSide,aInputRedstone, aCoverID, aCoverVariable - 3, aTileEntity, aTimer); -- cgit From 0f6f89f7bbfd35628fa07f42ac3af8a29b88cfd8 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 1 Apr 2021 02:01:21 +0800 Subject: Ensure conservation of masses in boilers Unified single block boiler logic Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/api/enums/GT_Values.java | 1 + .../boilers/GT_MetaTileEntity_Boiler.java | 100 +++++----- .../boilers/GT_MetaTileEntity_Boiler_Bronze.java | 209 +++++++++------------ .../boilers/GT_MetaTileEntity_Boiler_Lava.java | 100 +++------- .../boilers/GT_MetaTileEntity_Boiler_Solar.java | 117 +++++------- .../boilers/GT_MetaTileEntity_Boiler_Steel.java | 30 ++- .../multi/GT_MetaTileEntity_LargeBoiler.java | 25 ++- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 18 +- 8 files changed, 273 insertions(+), 327 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index d2b391edcb..a0ccd107a6 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -300,4 +300,5 @@ public class GT_Values { public static boolean cls_enabled; public static boolean hideAssLineRecipes = false; + public static final int STEAM_PER_WATER = 160; } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java index af7b2e2441..a65c9dde69 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler.java @@ -2,13 +2,14 @@ package gregtech.common.tileentities.boilers; import gregtech.GT_Mod; import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.*; +import gregtech.common.GT_Pollution; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; @@ -25,6 +26,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa public int mLossTimer = 0; public FluidStack mSteam = null; public boolean mHadNoWater = false; + private int mExcessWater = 0; public GT_MetaTileEntity_Boiler(int aID, String aName, String aNameRegional, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, 0, 4, aDescription, aTextures); @@ -152,6 +154,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa aNBT.setInteger("mLossTimer", this.mLossTimer); aNBT.setInteger("mTemperature", this.mTemperature); aNBT.setInteger("mProcessingEnergy", this.mProcessingEnergy); + aNBT.setInteger("mExcessWater", this.mExcessWater); if (this.mSteam != null) { try { aNBT.setTag("mSteam", this.mSteam.writeToNBT(new NBTTagCompound())); @@ -165,22 +168,40 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa this.mLossTimer = aNBT.getInteger("mLossTimer"); this.mTemperature = aNBT.getInteger("mTemperature"); this.mProcessingEnergy = aNBT.getInteger("mProcessingEnergy"); + this.mExcessWater = aNBT.getInteger("mExcessWater"); this.mSteam = FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag("mSteam")); } + /** + * Produce some steam. Assume water is present. + */ + protected void produceSteam(int aAmount) { + mExcessWater -= aAmount; + if (mExcessWater < 0) { + int tWaterToConsume = -mExcessWater / GT_Values.STEAM_PER_WATER + 1; + mFluid.amount -= tWaterToConsume; + mExcessWater += GT_Values.STEAM_PER_WATER * tWaterToConsume; + } + if (GT_ModHandler.isSteam(this.mSteam)) { + this.mSteam.amount += aAmount; + } else { + this.mSteam = GT_ModHandler.getSteam(aAmount); + } + } + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { if (this.mTemperature <= 20) { this.mTemperature = 20; this.mLossTimer = 0; - } - if (++this.mLossTimer > 40) { + } else if (++this.mLossTimer > getCooldownInterval()) { + // only loss temperature if hot this.mTemperature -= 1; this.mLossTimer = 0; } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte) (i + 1)) { + for (int i = 1; (this.mSteam != null) && (i < 6); i++) { if (i != aBaseMetaTileEntity.getFrontFacing()) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); + IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide((byte) i); if (tTileEntity != null) { FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); if (tDrained != null) { @@ -194,7 +215,7 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa } if (aTick % 10L == 0L) { if (this.mTemperature > 100) { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { + if ((!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { this.mHadNoWater = true; } else { if (this.mHadNoWater) { @@ -202,58 +223,28 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa aBaseMetaTileEntity.doExplosion(2048L); return; } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(150L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 150; - } else { - this.mSteam = GT_ModHandler.getSteam(150L); - } + produceSteam(getProductionPerSecond() / 2); } } else { this.mHadNoWater = false; } } if ((this.mSteam != null) && - (this.mSteam.amount > 32000)) { + (this.mSteam.amount > getCapacity())) { sendSound((byte) 1); - this.mSteam.amount = 24000; - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (this.mInventory[2] != null)) { - if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Coal))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Coal)))) { - this.mProcessingEnergy += 160; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Charcoal))) { - this.mProcessingEnergy += 160; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(3) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } - } else if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke")) { - this.mProcessingEnergy += 640; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(2) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.Ash, 1L)); - } - } else if ((GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.gem.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dust.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.dustImpure.get(Materials.Lignite))) || (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.crushed.get(Materials.Lignite)))) { - this.mProcessingEnergy += 120; - aBaseMetaTileEntity.decrStackSize(2, 1); - if (aBaseMetaTileEntity.getRandomNumber(8) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, Materials.DarkAsh, 1L)); - } - } + this.mSteam.amount = getCapacity() * 3 / 4; } - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) { - this.mProcessingEnergy -= 2; + if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork())) + updateFuel(aBaseMetaTileEntity, aTick); + if ((this.mTemperature < getMaxTemperature()) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) { + this.mProcessingEnergy -= getEnergyConsumption(); this.mTemperature += 1; } aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); } + if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) { + GT_Pollution.addPollution(getBaseMetaTileEntity(), getPollution()); + } } public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { @@ -282,12 +273,23 @@ public abstract class GT_MetaTileEntity_Boiler extends GT_MetaTileEntity_BasicTa ); } } + public int getTankPressure() { + return 100; + } + + protected abstract int getPollution(); public int getCapacity() { return 16000; } - public int getTankPressure() { - return 100; - } + protected abstract int getProductionPerSecond(); + + protected abstract int getMaxTemperature(); + + protected abstract int getEnergyConsumption(); + + protected abstract int getCooldownInterval(); + + protected abstract void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick); } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java index 2662d18276..d218266fa1 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Bronze.java @@ -9,8 +9,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.XSTR; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; @@ -19,9 +17,6 @@ import gregtech.common.gui.GT_GUIContainer_Boiler; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.tileentity.TileEntityFurnace; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; public class GT_MetaTileEntity_Boiler_Bronze extends GT_MetaTileEntity_Boiler { public GT_MetaTileEntity_Boiler_Bronze(int aID, String aName, String aNameRegional) { @@ -72,130 +67,98 @@ public class GT_MetaTileEntity_Boiler_Bronze extends GT_MetaTileEntity_Boiler { } public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - singleBlockBoilerLogic(aBaseMetaTileEntity,aTick,1,45,25L,20); + super.onPostTick(aBaseMetaTileEntity, aTick); + if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L) && this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) { + GT_Pollution.addPollution(getBaseMetaTileEntity(), getPollution()); + } } - protected void singleBlockBoilerLogic(IGregTechTileEntity aBaseMetaTileEntity, long aTick, int aMultiplier, int aTimer, long aTickDivider, int aPollution){ - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { - if (this.mTemperature <= 20) { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > aTimer) { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte) (i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if (aTick % aTickDivider == 0L) { - if (this.mTemperature > 100) { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { - this.mHadNoWater = true; - } else { - if (this.mHadNoWater) { - GT_Log.exp.println("Boiler "+this.mName+" had no Water!"); - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(150L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 150; - } else { - this.mSteam = GT_ModHandler.getSteam(150L); - } - } - } else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > (16000*aMultiplier))) { - sendSound((byte) 1); - this.mSteam.amount = (12000*aMultiplier); - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (this.mInventory[2] != null)) { - if ( - (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || - (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Charcoal) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || - (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || - (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Diamond) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke") || - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCactusCharcoal") || - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCactusCoke") || - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelSugarCharcoal") || - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelSugarCoke") - ) { - if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2])/10) > 0) { - this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2])/10); - aBaseMetaTileEntity.decrStackSize(2, 1); - if (XSTR.XSTR_INSTANCE.nextInt(GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal) || GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Charcoal) ? 3 : GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) ? 8 : 2 ) == 0) { - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) || GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal)) ? Materials.DarkAsh : Materials.Ash, 1L)); - } - } - } - else if ( - //If its a block of the following materials - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Coal)) || - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Lignite)) || - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Charcoal))|| - GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Diamond)) || - - //if its either a Railcraft Coke Block or a custom GTNH compressed Coal/charcoal/lignite/coke block - ( - Block.getBlockFromItem(this.mInventory[2].getItem()) != null && //check if the block exists - ( - Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("tile") && //check if the block is a tile -> block - ( - //If the name of the block contains these names - Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("charcoal") || - Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("coal") || - Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("diamond") || - Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("coke") || - Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("railcraft.cube") || - Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("lignite") - ) - ) - ) - ){ - //try to add 10% of the burnvalue as Processing energy, no boost for coal coke here - if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2])/10) > 0) { - this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10); - aBaseMetaTileEntity.decrStackSize(2, 1); - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dust, (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) || GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal) || Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("coal") || Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("lignite") ) ? Materials.DarkAsh : Materials.Ash, 1L)); - } - //enables every other fuel with at least 2000 burntime as a fuel, i.e. peat, Magic/Solid Super Fuel, Coal Singularities, Nitor, while bucket of creosite should be blocked same goes for lava - }else if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2])) >= 2000 && !(this.mInventory[2].getUnlocalizedName().toLowerCase().contains("bucket") || this.mInventory[2].getUnlocalizedName().toLowerCase().contains("cell"))){ - this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10); - aBaseMetaTileEntity.decrStackSize(2, 1); - //adds tiny pile of ash for burntime under 10k, small pile for under 100k and pile for bigger values - if (XSTR.XSTR_INSTANCE.nextInt(2) == 0) - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get( (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) >= 10000 ? TileEntityFurnace.getItemBurnTime(this.mInventory[2]) >= 100000 ? OrePrefixes.dust : OrePrefixes.dustSmall : OrePrefixes.dustTiny), Materials.Ash, 1L)); + @Override + protected int getPollution() { + return 20; + } + + @Override + protected int getProductionPerSecond() { + return 120; + } + + @Override + protected int getMaxTemperature() { + return 500; + } + + @Override + protected int getEnergyConsumption() { + return 1; + } + + @Override + protected int getCooldownInterval() { + return 45; + } + + @Override + protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (this.mInventory[2] == null) return; + if ( + (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || + (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Charcoal) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || + (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || + (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Diamond) && !GT_Utility.isPartOfOrePrefix(this.mInventory[2],OrePrefixes.block)) || + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCoke") || + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCactusCharcoal") || + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelCactusCoke") || + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelSugarCharcoal") || + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], "fuelSugarCoke") + ) { + if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2])/10) > 0) { + this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2])/10); + aBaseMetaTileEntity.decrStackSize(2, 1); + if (XSTR.XSTR_INSTANCE.nextInt(GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal) || GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Charcoal) ? 3 : GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) ? 8 : 2 ) == 0) { + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dustTiny, (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) || GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal)) ? Materials.DarkAsh : Materials.Ash, 1L)); } } - if ((this.mTemperature < (500*aMultiplier)) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) { - this.mProcessingEnergy -= aMultiplier; - this.mTemperature += 1; - } - if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) { - GT_Pollution.addPollution(getBaseMetaTileEntity(), aPollution); + } + else if ( + //If its a block of the following materials + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Coal)) || + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Lignite)) || + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Charcoal))|| + GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.block.get(Materials.Diamond)) || + + //if its either a Railcraft Coke Block or a custom GTNH compressed Coal/charcoal/lignite/coke block + ( + Block.getBlockFromItem(this.mInventory[2].getItem()) != null && //check if the block exists + ( + Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("tile") && //check if the block is a tile -> block + ( + //If the name of the block contains these names + Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("charcoal") || + Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("coal") || + Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("diamond") || + Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("coke") || + Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("railcraft.cube") || + Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("lignite") + ) + ) + ) + ){ + //try to add 10% of the burnvalue as Processing energy, no boost for coal coke here + if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2])/10) > 0) { + this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10); + aBaseMetaTileEntity.decrStackSize(2, 1); + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.dust, (GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Lignite) || GT_Utility.isPartOfMaterials(this.mInventory[2],Materials.Coal) || Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("coal") || Block.getBlockFromItem(this.mInventory[2].getItem()).getUnlocalizedName().toLowerCase().contains("lignite") ) ? Materials.DarkAsh : Materials.Ash, 1L)); } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + //enables every other fuel with at least 2000 burntime as a fuel, i.e. peat, Magic/Solid Super Fuel, Coal Singularities, Nitor, while bucket of creosite should be blocked same goes for lava + }else if ((TileEntityFurnace.getItemBurnTime(this.mInventory[2])) >= 2000 && !(this.mInventory[2].getUnlocalizedName().toLowerCase().contains("bucket") || this.mInventory[2].getUnlocalizedName().toLowerCase().contains("cell"))){ + this.mProcessingEnergy += (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) / 10); + aBaseMetaTileEntity.decrStackSize(2, 1); + //adds tiny pile of ash for burntime under 10k, small pile for under 100k and pile for bigger values + if (XSTR.XSTR_INSTANCE.nextInt(2) == 0) + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get( (TileEntityFurnace.getItemBurnTime(this.mInventory[2]) >= 10000 ? TileEntityFurnace.getItemBurnTime(this.mInventory[2]) >= 100000 ? OrePrefixes.dust : OrePrefixes.dustSmall : OrePrefixes.dustTiny), Materials.Ash, 1L)); } + } } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java index 66b93ea16a..14330f24e7 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Lava.java @@ -8,16 +8,12 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; -import gregtech.common.GT_Pollution; import gregtech.common.gui.GT_Container_Boiler; import gregtech.common.gui.GT_GUIContainer_Boiler; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler { public GT_MetaTileEntity_Boiler_Lava(int aID, String aName, String aNameRegional) { @@ -63,73 +59,37 @@ public class GT_MetaTileEntity_Boiler_Lava extends GT_MetaTileEntity_Boiler { return new GT_MetaTileEntity_Boiler_Lava(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); } - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { - if (this.mTemperature <= 20) { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > 20) { - this.mTemperature -= 1; - this.mLossTimer = 0; - } - for (byte i = 1; (this.mSteam != null) && (i < 6); i = (byte) (i + 1)) { - if (i != aBaseMetaTileEntity.getFrontFacing()) { - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - } - if (aTick % 10L == 0L) { - if (this.mTemperature > 100) { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { - this.mHadNoWater = true; - } else { - if (this.mHadNoWater) { - GT_Log.exp.println("Boiler "+this.mName+" had no Water!"); - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= 1; - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(300L); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += 300; - } else { - this.mSteam = GT_ModHandler.getSteam(300L); - } - } - } else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > 32000)) { - sendSound((byte) 1); - this.mSteam.amount = 24000; - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && - (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(Materials.Lava)))) { - this.mProcessingEnergy += 1000; - aBaseMetaTileEntity.decrStackSize(2, 1); - aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); - } - if ((this.mTemperature < 1000) && (this.mProcessingEnergy > 0) && (aTick % 8L == 0L)) { - this.mProcessingEnergy -= 3; - this.mTemperature += 1; - } + @Override + protected int getPollution() { + return 20; + } - if (this.mProcessingEnergy > 0 && (aTick % 20L == 0L)) { - GT_Pollution.addPollution(getBaseMetaTileEntity(), 20); - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + @Override + protected int getProductionPerSecond() { + return 600; + } + + @Override + protected int getMaxTemperature() { + return 1000; + } + + @Override + protected int getEnergyConsumption() { + return 3; + } + + @Override + protected int getCooldownInterval() { + return 20; + } + + @Override + protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (GT_OreDictUnificator.isItemStackInstanceOf(this.mInventory[2], OrePrefixes.bucket.get(Materials.Lava))) { + this.mProcessingEnergy += 1000; + aBaseMetaTileEntity.decrStackSize(2, 1); + aBaseMetaTileEntity.addStackToSlot(3, GT_OreDictUnificator.get(OrePrefixes.bucket, Materials.Empty, 1L)); } } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java index 2c79d507eb..e7b318d27d 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Solar.java @@ -6,17 +6,12 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Utility; import gregtech.common.gui.GT_Container_Boiler; import gregtech.common.gui.GT_GUIContainer_Boiler; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidHandler; public class GT_MetaTileEntity_Boiler_Solar extends GT_MetaTileEntity_Boiler { @@ -126,74 +121,50 @@ public class GT_MetaTileEntity_Boiler_Solar extends GT_MetaTileEntity_Boiler { } } - public int getBasicOutput() { - return this.basicOutput; - } - - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if ((aBaseMetaTileEntity.isServerSide()) && (aTick > 20L)) { - if (this.mTemperature <= 20) { - this.mTemperature = 20; - this.mLossTimer = 0; - } - if (++this.mLossTimer > basicLossTimerLimit) { - this.mTemperature -= basicTemperatureMod; - this.mLossTimer = 0; - } - if (this.mSteam != null) { - byte i = aBaseMetaTileEntity.getFrontFacing(); - IFluidHandler tTileEntity = aBaseMetaTileEntity.getITankContainerAtSide(i); - if (tTileEntity != null) { - FluidStack tDrained = aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), Math.max(1, this.mSteam.amount / 2), false); - if (tDrained != null) { - int tFilledAmount = tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), tDrained, false); - if (tFilledAmount > 0) { - tTileEntity.fill(ForgeDirection.getOrientation(i).getOpposite(), aBaseMetaTileEntity.drain(ForgeDirection.getOrientation(i), tFilledAmount, true), true); - } - } - } - } - if (aTick % 25L == 0L) { // Every 25 ticks since 1L of water = 150L of steam. So for 120L, have to use 25 instead of 20. - if (this.mTemperature > 100) { - if ((this.mFluid == null) || (!GT_ModHandler.isWater(this.mFluid)) || (this.mFluid.amount <= 0)) { - this.mHadNoWater = true; - } else { - if (this.mHadNoWater) { - GT_Log.exp.println("Boiler "+this.mName+" had no Water!"); - aBaseMetaTileEntity.doExplosion(2048L); - return; - } - this.mFluid.amount -= (basicOutput/150); - mRunTime += 1; - - int tOutput = getCalcificationOutput(); - - if (this.mSteam == null) { - this.mSteam = GT_ModHandler.getSteam(tOutput); - } else if (GT_ModHandler.isSteam(this.mSteam)) { - this.mSteam.amount += tOutput; - } else { - this.mSteam = GT_ModHandler.getSteam(tOutput); - } - } - } else { - this.mHadNoWater = false; - } - } - if ((this.mSteam != null) && - (this.mSteam.amount > this.getCapacity())) { - sendSound((byte) 1); - this.mSteam.amount = 3*(this.getCapacity()/4); - } - if ((this.mProcessingEnergy <= 0) && (aBaseMetaTileEntity.isAllowedToWork()) && (aTick % 256L == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { - boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && aBaseMetaTileEntity.getBiome().rainfall > 0.0F; - mProcessingEnergy += bRain && aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4 || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8*basicTemperatureMod : basicTemperatureMod; - } - if ((this.mTemperature < maxProgresstime()) && (this.mProcessingEnergy > 0) && (aTick % 12L == 0L)) { - this.mProcessingEnergy -= basicTemperatureMod; - this.mTemperature += basicTemperatureMod; - } - aBaseMetaTileEntity.setActive(this.mProcessingEnergy > 0); + @Override + protected void produceSteam(int aAmount) { + super.produceSteam(aAmount); + mRunTime++; + } + + @Override + protected int getPollution() { + return 0; + } + + @Override + protected int getProductionPerSecond() { + if (this.mTemperature < 100 ) { + return 0; + } + if (this.mRunTime > CALCIFICATION_TIME) { + // Calcification takes about 2/3 CALCIFICATION_TIME to completely calcify on basic solar. For HP solar, it takes about 2x CALCIFICATION_TIME + return Math.max(this.basicMaxOuput, this.basicOutput - ((this.mRunTime - CALCIFICATION_TIME) / (CALCIFICATION_TIME/150))); // Every 288*25 ticks, or 6 minutes, lose 1 L output. + } else { + return this.basicOutput; + } + } + + @Override + protected int getMaxTemperature() { + return 500; + } + + @Override + protected int getEnergyConsumption() { + return 1; + } + + @Override + protected int getCooldownInterval() { + return basicLossTimerLimit / basicTemperatureMod; + } + + @Override + protected void updateFuel(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((aTick % 256L == 0L) && (!aBaseMetaTileEntity.getWorld().isThundering())) { + boolean bRain = aBaseMetaTileEntity.getWorld().isRaining() && aBaseMetaTileEntity.getBiome().rainfall > 0.0F; + mProcessingEnergy += bRain && aBaseMetaTileEntity.getWorld().skylightSubtracted >= 4 || !aBaseMetaTileEntity.getSkyAtSide((byte) 1) ? 0 : !bRain && aBaseMetaTileEntity.getWorld().isDaytime() ? 8 * basicTemperatureMod : basicTemperatureMod; } } } diff --git a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java index 068e7fd82b..0f5dee8eb2 100644 --- a/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java +++ b/src/main/java/gregtech/common/tileentities/boilers/GT_MetaTileEntity_Boiler_Steel.java @@ -61,7 +61,33 @@ public class GT_MetaTileEntity_Boiler_Steel extends GT_MetaTileEntity_Boiler_Bro return new GT_MetaTileEntity_Boiler_Steel(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); } - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - super.singleBlockBoilerLogic(aBaseMetaTileEntity,aTick,2,40,10L,30); + @Override + protected int getPollution() { + return 30; + } + + @Override + public int getCapacity() { + return 32000; + } + + @Override + protected int getProductionPerSecond() { + return 300; + } + + @Override + protected int getMaxTemperature() { + return 1000; + } + + @Override + protected int getEnergyConsumption() { + return 2; + } + + @Override + protected int getCooldownInterval() { + return 40; } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java index e80f3dfb39..2d8ae1f144 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -18,16 +18,20 @@ import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import static gregtech.api.enums.GT_Values.STEAM_PER_WATER; + public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_MultiBlockBase { private boolean firstRun = true; private int mSuperEfficencyIncrease = 0; private int integratedCircuitConfig = 0; //Steam output is reduced by 1000L per config + private int excessWater = 0; //Eliminate rounding errors for water private int excessFuel = 0; //Eliminate rounding errors for fuels that burn half items private int excessProjectedEU = 0; //Eliminate rounding errors from throttling the boiler @@ -185,7 +189,10 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu mEfficiency = Math.max(0, Math.min(mEfficiency + mSuperEfficencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); if (tGeneratedEU > 0) { - long amount = (tGeneratedEU + 160) / 160; + long amount = (tGeneratedEU + STEAM_PER_WATER) / STEAM_PER_WATER; + excessWater += amount * STEAM_PER_WATER - tGeneratedEU; + amount -= excessWater / STEAM_PER_WATER; + excessWater %= STEAM_PER_WATER; if (depleteInput(Materials.Water.getFluid(amount)) || depleteInput(GT_ModHandler.getDistilledWater(amount))) { addOutput(GT_ModHandler.getSteam(tGeneratedEU)); } else { @@ -198,6 +205,22 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu return true; } + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("excessFuel", excessFuel); + aNBT.setInteger("excessWater", excessWater); + aNBT.setInteger("excessProjectedEU", excessProjectedEU); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + excessFuel = aNBT.getInteger("excessFuel"); + excessWater = aNBT.getInteger("excessWater"); + excessProjectedEU = aNBT.getInteger("excessProjectedEU"); + } + @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (mProgresstime > 0 && firstRun) { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 306dfe734d..baa63a3e84 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -19,11 +19,12 @@ import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import static gregtech.api.enums.GT_Values.STEAM_PER_WATER; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_LargeTurbine { - private float water; + private int excessWater; private boolean achievement = false; private boolean looseFit=false; @@ -90,11 +91,11 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg return 0; } - private int useWater(float input) { - water = water + input; - int usage = (int) water; - water = water - usage; - return usage; + private int condenseSteam(int steam) { + excessWater += steam; + int water = excessWater / STEAM_PER_WATER; + excessWater %= STEAM_PER_WATER; + return water; } @Override @@ -127,7 +128,7 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches totalFlow += flow; // track total input used if (!achievement) { - GT_Mod.instance.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam"); + GT_Mod.achievements.issueAchievement(this.getBaseMetaTileEntity().getWorld().getPlayerEntityByName(this.getBaseMetaTileEntity().getOwnerName()), "muchsteam"); achievement = true; } }else if(GT_ModHandler.isSuperHeatedSteam(aFluidStack)) { @@ -136,11 +137,10 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg } if(totalFlow<=0)return 0; tEU = totalFlow; - int waterToOutput = useWater(totalFlow / 160.0f); + int waterToOutput = condenseSteam(totalFlow); addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); if (totalFlow != aOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float)aOptFlow); - //if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; tEU = Math.max(1, GT_Utility.safeInt((long)tEU * (long)aBaseEff / 20000L)); } else { -- cgit From ef3af39da75bb4d4be0d858eea04cd0280603dca Mon Sep 17 00:00:00 2001 From: charles Date: Fri, 2 Apr 2021 22:43:45 -0600 Subject: Fixed improper loading of bSortStacks from NBT, *should* fix backwards compat issue. --- .../api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java index 39fc12eea0..d462e8adb9 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Buffer.java @@ -225,6 +225,9 @@ public abstract class GT_MetaTileEntity_Buffer extends GT_MetaTileEntity_TieredM if (aNBT.hasKey("bStockingMode")) { // Adding new key to existing NBT, need to protect if it is not there. bStockingMode = aNBT.getBoolean("bStockingMode"); } + if (aNBT.hasKey("bSortStacks")) { + bSortStacks = aNBT.getBoolean("bSortStacks"); + } mTargetStackSize = aNBT.getInteger("mTargetStackSize"); } -- cgit From 4fb771c07cefad013da8588db27a46ed0311e367 Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Sun, 4 Apr 2021 22:01:11 +0200 Subject: fix(rendering): multiple rendering fixes and refactor (#494) * fix(rendering): multiple rendering fixes and refactor - Fix rendering gregtech machines in inventory with correct orientation and lighting. - Fix rendering of pipes connected through covers, no longer z-fight at a distance. - Fix updating of textures when un/holding a soldering-iron. - Refactor of the GT_Renderer_Block class with properly named constants replacing raw literals. --- .../interfaces/metatileentity/IConnectable.java | 12 + .../tileentity/IPipeRenderedTileEntity.java | 3 +- .../api/metatileentity/BaseMetaPipeEntity.java | 30 +- .../api/metatileentity/MetaPipeEntity.java | 13 +- .../api/metatileentity/MetaTileEntity.java | 25 +- .../implementations/GT_MetaPipeEntity_Cable.java | 2 +- .../implementations/GT_MetaPipeEntity_Fluid.java | 2 +- .../implementations/GT_MetaPipeEntity_Item.java | 2 +- .../java/gregtech/api/util/LightingHelper.java | 2 +- src/main/java/gregtech/common/GT_Client.java | 5 + .../gregtech/common/render/GT_Renderer_Block.java | 864 ++++++++++++--------- 11 files changed, 558 insertions(+), 402 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java b/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java index bc822250fd..cffcb4c4ab 100644 --- a/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java +++ b/src/main/java/gregtech/api/interfaces/metatileentity/IConnectable.java @@ -4,6 +4,18 @@ package gregtech.api.interfaces.metatileentity; * For pipes, wires, and other MetaTiles which need to be decided whether they should connect to the block at each side. */ public interface IConnectable { + int NO_CONNECTION = 0b00000000; + int CONNECTED_DOWN = 0b00000001; + int CONNECTED_UP = 0b00000010; + int CONNECTED_NORTH = 0b00000100; + int CONNECTED_SOUTH = 0b00001000; + int CONNECTED_WEST = 0b00010000; + int CONNECTED_EAST = 0b00100000; + int CONNECTED_ALL = 0b00111111; + int HAS_FRESHFOAM = 0b01000000; + int HAS_HARDENEDFOAM = 0b10000000; + int HAS_FOAM = 0b11000000; + /** * Try to connect to the Block at the specified side * returns the connection state. Non-positive values for failed, others for succeeded. diff --git a/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java b/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java index 8392616f34..de3cf3ec99 100644 --- a/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java +++ b/src/main/java/gregtech/api/interfaces/tileentity/IPipeRenderedTileEntity.java @@ -1,7 +1,6 @@ package gregtech.api.interfaces.tileentity; import gregtech.api.interfaces.ITexture; -import net.minecraft.block.Block; public interface IPipeRenderedTileEntity extends ICoverable, ITexturedTileEntity { float getThickNess(); @@ -12,5 +11,5 @@ public interface IPipeRenderedTileEntity extends ICoverable, ITexturedTileEntity default ITexture[] getTextureCovered(byte aSide) { return getTextureUncovered(aSide); - }; + } } \ No newline at end of file diff --git a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java index 908dd88984..0fd8779244 100644 --- a/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/BaseMetaPipeEntity.java @@ -13,12 +13,12 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IConnectable; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; import gregtech.api.net.GT_Packet_TileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.objects.GT_StdRenderedTexture; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; @@ -52,7 +52,7 @@ import net.minecraftforge.fluids.IFluidHandler; */ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileEntity, IPipeRenderedTileEntity { private final GT_CoverBehavior[] mCoverBehaviors = new GT_CoverBehavior[]{GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior, GregTech_API.sNoBehavior}; - public byte mConnections = 0; + public byte mConnections = IConnectable.NO_CONNECTION; protected MetaPipeEntity mMetaTileEntity; private byte[] mSidedRedstone = new byte[]{0, 0, 0, 0, 0, 0}; private int[] mCoverSides = new int[]{0, 0, 0, 0, 0, 0}, mCoverData = new int[]{0, 0, 0, 0, 0, 0}, mTimeStatistics = new int[GregTech_API.TICKS_FOR_LAG_AVERAGING]; @@ -262,9 +262,11 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE if (!hasValidMetaTileEntity()) return; } } - mConnections = (byte) (mMetaTileEntity.mConnections | (mConnections & ~63)); - if ((mConnections & -64) == 64 && getRandomNumber(1000) == 0) { - mConnections = (byte) ((mConnections & ~64) | -128); + // Mask-out Connection direction bits to keep only Foam related connections + mConnections = (byte) (mMetaTileEntity.mConnections | (mConnections & ~IConnectable.CONNECTED_ALL)); + // If foam not hardened, tries roll chance to harden + if ((mConnections & IConnectable.HAS_FOAM) == IConnectable.HAS_FRESHFOAM && getRandomNumber(1000) == 0) { + mConnections = (byte) ((mConnections & ~IConnectable.HAS_FRESHFOAM) | IConnectable.HAS_HARDENEDFOAM); } } case 8: @@ -807,15 +809,17 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE @Override public ITexture[] getTextureUncovered(byte aSide) { - if ((mConnections & 64) != 0) return Textures.BlockIcons.FRESHFOAM; - if ((mConnections & -128) != 0) return Textures.BlockIcons.HARDENEDFOAMS[mColor]; - if ((mConnections & -64) != 0) return Textures.BlockIcons.ERROR_RENDERING; + if ((mConnections & IConnectable.HAS_FRESHFOAM) != 0) return Textures.BlockIcons.FRESHFOAM; + if ((mConnections & IConnectable.HAS_HARDENEDFOAM) != 0) return Textures.BlockIcons.HARDENEDFOAMS[mColor]; + if ((mConnections & IConnectable.HAS_FOAM) != 0) return Textures.BlockIcons.ERROR_RENDERING; byte tConnections = mConnections; - if (tConnections == 1 || tConnections == 2) tConnections = 3; - else if (tConnections == 4 || tConnections == 8) tConnections = 12; - else if (tConnections == 16 || tConnections == 32) tConnections = 48; + if (tConnections == IConnectable.CONNECTED_WEST || tConnections == IConnectable.CONNECTED_EAST) tConnections = (byte) (IConnectable.CONNECTED_WEST | IConnectable.CONNECTED_EAST); + else if (tConnections == IConnectable.CONNECTED_DOWN || tConnections == IConnectable.CONNECTED_UP) tConnections = (byte) (IConnectable.CONNECTED_DOWN | IConnectable.CONNECTED_UP); + else if (tConnections == IConnectable.CONNECTED_NORTH || tConnections == IConnectable.CONNECTED_SOUTH) tConnections = (byte) (IConnectable.CONNECTED_NORTH | IConnectable.CONNECTED_SOUTH); if (hasValidMetaTileEntity()) - return mMetaTileEntity.getTexture(this, aSide, tConnections, (byte) (mColor - 1), tConnections == 0 || (tConnections & (1 << aSide)) != 0, getOutputRedstoneSignal(aSide) > 0); + return mMetaTileEntity.getTexture(this, aSide, tConnections, (byte) (mColor - 1), + tConnections == 0 || (tConnections & (1 << aSide)) != 0, + getOutputRedstoneSignal(aSide) > 0); return Textures.BlockIcons.ERROR_RENDERING; } @@ -1409,7 +1413,7 @@ public class BaseMetaPipeEntity extends BaseTileEntity implements IGregTechTileE @Override public float getBlastResistance(byte aSide) { - return (mConnections & 192) != 0 ? 50.0F : 5.0F; + return (mConnections & IConnectable.HAS_FOAM) != 0 ? 50.0F : 5.0F; } @Override diff --git a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java index 0716d84bd6..8fe4c93639 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaPipeEntity.java @@ -9,11 +9,12 @@ import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.api.util.GT_Config; import gregtech.api.util.GT_CoverBehavior; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; +import gregtech.common.GT_Client; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.texture.IIconRegister; @@ -244,7 +245,15 @@ public abstract class MetaPipeEntity implements IMetaTileEntity, IConnectable { public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { + /* Client tick counter that is set to 5 on hiding pipes and covers. + * It triggers a texture update next client tick when reaching 4, with provision for 3 more update tasks, + * spreading client change detection related work and network traffic on different ticks, until it reaches 0. + */ + aBaseMetaTileEntity.issueTextureUpdate(); + } + } @Override public void inValidate() {/*Do nothing*/} diff --git a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java index c9d75dad1a..730ec264f3 100644 --- a/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/MetaTileEntity.java @@ -2,7 +2,6 @@ package gregtech.api.metatileentity; import appeng.api.util.AECableType; import appeng.me.helpers.AENetworkProxy; -import appeng.me.helpers.IGridProxyable; import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -11,7 +10,12 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Cable; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_Config; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Client; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.texture.IIconRegister; @@ -47,6 +51,7 @@ import static gregtech.api.enums.GT_Values.V; * Call the Constructor like the following example inside the Load Phase, to register it. * "new GT_MetaTileEntity_E_Furnace(54, "GT_E_Furnace", "Automatic E-Furnace");" */ +@SuppressWarnings("unused") public abstract class MetaTileEntity implements IMetaTileEntity { /** * Only assigned for the MetaTileEntity in the List! Also only used to get the localized Name for the ItemStack and for getInvName. @@ -85,7 +90,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { } else { throw new IllegalArgumentException("MetaMachine-Slot Nr. " + aID + " is already occupied!"); } - mName = aBasicName.replaceAll(" ", "_").toLowerCase(Locale.ENGLISH); + mName = aBasicName.replace(" ", "_").toLowerCase(Locale.ENGLISH); setBaseMetaTileEntity(GregTech_API.constructBaseMetaTileEntity()); getBaseMetaTileEntity().setMetaTileID((short) aID); GT_LanguageManager.addStringLocalization("gt.blockmachines." + mName + ".name", aRegionalName); @@ -175,7 +180,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { if(!aPlayer.isSneaking()) return false; byte tSide = GT_Utility.getOppositeSide(aWrenchingSide); TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(aWrenchingSide); - if (tTileEntity != null && (tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { + if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { // The tile entity we're facing is a cable, let's try to connect to it return ((IGregTechTileEntity) tTileEntity).getMetaTileEntity().onWireCutterRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); } @@ -187,7 +192,7 @@ public abstract class MetaTileEntity implements IMetaTileEntity { if(!aPlayer.isSneaking()) return false; byte tSide = GT_Utility.getOppositeSide(aWrenchingSide); TileEntity tTileEntity = getBaseMetaTileEntity().getTileEntityAtSide(aWrenchingSide); - if (tTileEntity != null && (tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { + if ((tTileEntity instanceof IGregTechTileEntity) && (((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable)) { // The tile entity we're facing is a cable, let's try to connect to it return ((IGregTechTileEntity) tTileEntity).getMetaTileEntity().onSolderingToolRightClick(aWrenchingSide, tSide, aPlayer, aX, aY, aZ); } @@ -206,7 +211,15 @@ public abstract class MetaTileEntity implements IMetaTileEntity { public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {/*Do nothing*/} + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected == 4) { + /* Client tick counter that is set to 5 on hiding pipes and covers. + * It triggers a texture update next client tick when reaching 4, with provision for 3 more update tasks, + * spreading client change detection related work and network traffic on different ticks, until it reaches 0. + */ + aBaseMetaTileEntity.issueTextureUpdate(); + } + } @Override public void inValidate() {/*Do nothing*/} diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index 02d6752bdd..e69e13b67a 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -358,7 +358,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile mTransferredAmperageLast20 = 0; if (!GT_Mod.gregtechproxy.gt6Cable || mCheckConnections) checkConnections(); } - } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate(); + } } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index e6c24ec4b1..8c88f0e3bd 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -256,7 +256,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { oLastReceivedFrom = mLastReceivedFrom; - } else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate(); + } } private boolean checkEnvironment(int index, IGregTechTileEntity aBaseMetaTileEntity) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index 6ed5a9edd0..64064875ab 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -181,7 +181,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE if (isInventoryEmpty()) mLastReceivedFrom = 6; oLastReceivedFrom = mLastReceivedFrom; - }else if(aBaseMetaTileEntity.isClientSide() && GT_Client.changeDetected==4) aBaseMetaTileEntity.issueTextureUpdate(); + } } @Override diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java index 027fcd9c6d..48c316d0cc 100644 --- a/src/main/java/gregtech/api/util/LightingHelper.java +++ b/src/main/java/gregtech/api/util/LightingHelper.java @@ -31,7 +31,7 @@ import net.minecraft.client.renderer.Tessellator; public class LightingHelper { public static final int NORMAL_BRIGHTNESS = 0xff00ff; public static final int MAX_BRIGHTNESS = 0xf000f0; - public static final float NO_Z_FIGHT_OFFSET = 1.0F / 16384.0F; + public static final float NO_Z_FIGHT_OFFSET = 1.0F / 1024.0F; protected static final float[] LIGHTNESS = {0.5F, 1.0F, 0.8F, 0.8F, 0.6F, 0.6F}; private final RenderBlocks renderBlocks; /** diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index b820c3b53a..6ce360c017 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -649,6 +649,11 @@ public class GT_Client extends GT_Proxy } public static int hideValue=0; + + /**

Client tick counter that is set to 5 on hiding pipes and covers.

+ *

It triggers a texture update next client tick when reaching 4, with provision for 3 more update tasks, + * spreading client change detection related work and network traffic on different ticks, until it reaches 0.

+ */ public static int changeDetected=0; private static int shouldHeldItemHideThings() { diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Block.java b/src/main/java/gregtech/common/render/GT_Renderer_Block.java index 2f33a80dca..51e0b8fd6f 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -20,9 +20,29 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; -import static gregtech.api.util.LightingHelper.NO_Z_FIGHT_OFFSET; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_DOWN; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_EAST; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_NORTH; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_SOUTH; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_UP; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_WEST; +import static gregtech.api.interfaces.metatileentity.IConnectable.HAS_FRESHFOAM; +import static gregtech.api.interfaces.metatileentity.IConnectable.HAS_HARDENEDFOAM; +import static gregtech.api.interfaces.metatileentity.IConnectable.NO_CONNECTION; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.VALID_DIRECTIONS; +import static net.minecraftforge.common.util.ForgeDirection.WEST; public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { + public static final float blockMin = 0.0F; + public static final float blockMax = 1.0F; + private static final float coverThickness = blockMax / 8.0F; + private static final float coverInnerMin = blockMin + coverThickness; + private static final float coverInnerMax = blockMax - coverThickness; public static GT_Renderer_Block INSTANCE; public final int mRenderID; @@ -32,6 +52,453 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { RenderingRegistry.registerBlockHandler(this); } + public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof IPipeRenderedTileEntity)) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{ + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) DOWN.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) UP.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) NORTH.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) SOUTH.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) WEST.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) EAST.ordinal())}); + } + if ((tTileEntity instanceof ITexturedTileEntity)) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{ + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) DOWN.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) UP.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) NORTH.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) SOUTH.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) WEST.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) EAST.ordinal())}); + } + return false; + } + + public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer, ITexture[][] aTextures) { + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[DOWN.ordinal()], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[UP.ordinal()], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[NORTH.ordinal()], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SOUTH.ordinal()], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[WEST.ordinal()], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[EAST.ordinal()], true); + return true; + } + + public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { + final byte aConnections = aTileEntity.getConnections(); + if ((aConnections & (HAS_FRESHFOAM | HAS_HARDENEDFOAM)) != 0) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } + final float thickness = aTileEntity.getThickNess(); + if (thickness >= 0.99F) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } + // Range of block occupied by pipe + final float pipeMin = (blockMax - thickness) / 2.0F; + final float pipeMax = blockMax - pipeMin; + final boolean[] tIsCovered = new boolean[VALID_DIRECTIONS.length]; + for (int i = 0; i < VALID_DIRECTIONS.length; i++) { + tIsCovered[i] = (aTileEntity.getCoverIDAtSide((byte) i) != 0); + } + + final ITexture[][] tIcons = new ITexture[VALID_DIRECTIONS.length][]; + final ITexture[][] tCovers = new ITexture[VALID_DIRECTIONS.length][]; + for (int i = 0; i < VALID_DIRECTIONS.length; i++) { + tCovers[i] = aTileEntity.getTexture(aBlock, (byte) i); + tIcons[i] = aTileEntity.getTextureUncovered((byte) i); + } + + switch (aConnections) { + case NO_CONNECTION: + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + break; + case CONNECTED_EAST | CONNECTED_WEST: + // EAST - WEST Pipe Sides + aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + + // EAST - WEST Pipe Ends + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + break; + case CONNECTED_DOWN | CONNECTED_UP: + // UP - DOWN Pipe Sides + aBlock.setBlockBounds(pipeMin, blockMin, pipeMin, pipeMax, blockMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + + // UP - DOWN Pipe Ends + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + break; + case CONNECTED_NORTH | CONNECTED_SOUTH: + // NORTH - SOUTH Pipe Sides + aBlock.setBlockBounds(pipeMin, pipeMin, blockMin, pipeMax, pipeMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + + // NORTH - SOUTH Pipe Ends + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + break; + default: + if ((aConnections & CONNECTED_WEST) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, pipeMin, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + } + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + + if ((aConnections & CONNECTED_EAST) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMax, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + } + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + + if ((aConnections & CONNECTED_DOWN) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, blockMin, pipeMin, pipeMax, pipeMin, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + } + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + + if ((aConnections & CONNECTED_UP) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, pipeMax, pipeMin, pipeMax, blockMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + } + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + + if ((aConnections & CONNECTED_NORTH) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, pipeMin, blockMin, pipeMax, pipeMax, pipeMin); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + } + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + + if ((aConnections & CONNECTED_SOUTH) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMax, pipeMax, pipeMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + } + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + break; + } + + // Render covers on pipes + if (tIsCovered[DOWN.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, coverInnerMin, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + if ((aConnections & CONNECTED_DOWN) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMax, blockMin, pipeMin); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, blockMin, pipeMax, blockMax, blockMin, blockMax); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, blockMin, pipeMin, pipeMin, blockMin, pipeMax); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, blockMin, pipeMin, blockMax, blockMin, pipeMax); + } + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + + if (tIsCovered[UP.ordinal()]) { + aBlock.setBlockBounds(blockMin, coverInnerMax, blockMin, blockMax, blockMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + if ((aConnections & CONNECTED_UP) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMax, blockMin, blockMax, blockMax, pipeMin); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, blockMax, pipeMax, blockMax, blockMax, blockMax); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, blockMax, pipeMin, pipeMin, blockMax, pipeMax); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, blockMax, pipeMin, blockMax, blockMax, pipeMax); + } + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + + if (tIsCovered[NORTH.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, coverInnerMin); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + if ((aConnections & CONNECTED_NORTH) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMax, pipeMin, blockMin); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, pipeMax, blockMin, blockMax, blockMax, blockMin); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, pipeMin, blockMin, pipeMin, pipeMax, blockMin); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, pipeMin, blockMin, blockMax, pipeMax, blockMin); + } + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + + if (tIsCovered[SOUTH.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, coverInnerMax, blockMax, blockMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + if ((aConnections & CONNECTED_SOUTH) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMax, blockMax, pipeMin, blockMax); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, pipeMax, blockMax, blockMax, blockMax, blockMax); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, pipeMin, blockMax, pipeMin, pipeMax, blockMax); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, pipeMin, blockMax, blockMax, pipeMax, blockMax); + } + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + + if (tIsCovered[WEST.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, blockMin, coverInnerMin, blockMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + if ((aConnections & CONNECTED_WEST) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMin, pipeMin, blockMax); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, pipeMax, blockMin, blockMin, blockMax, blockMax); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, pipeMin, blockMin, blockMin, pipeMax, pipeMin); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(blockMin, pipeMin, pipeMax, blockMin, pipeMax, blockMax); + } + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + + if (tIsCovered[EAST.ordinal()]) { + aBlock.setBlockBounds(coverInnerMax, blockMin, blockMin, blockMax, blockMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + } + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + } + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + } + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + + if ((aConnections & CONNECTED_EAST) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMax, blockMin, blockMin, blockMax, pipeMin, blockMax); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMax, pipeMax, blockMin, blockMax, blockMax, blockMax); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMax, pipeMin, blockMin, blockMax, pipeMax, pipeMin); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(blockMax, pipeMin, pipeMax, blockMax, pipeMax, blockMax); + } + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + } + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + + return true; + } + + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aRenderer.enableAO = false; + if ((aBlock instanceof GT_Block_Machines)) { + if ((aMeta > 0) && (aMeta < GregTech_API.METATILEENTITIES.length) && (GregTech_API.METATILEENTITIES[aMeta] != null) && + (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { + renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); + } + } else if ((aBlock instanceof GT_Block_Ores_Abstract)) { + GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores(); + tTileEntity.mMetaData = ((short) aMeta); + + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 0), true); + Tessellator.instance.draw(); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 1), true); + Tessellator.instance.draw(); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 2), true); + Tessellator.instance.draw(); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 3), true); + Tessellator.instance.draw(); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 4), true); + Tessellator.instance.draw(); + + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 5), true); + Tessellator.instance.draw(); + } + aBlock.setBlockBounds(blockMin, blockMin, blockMin, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { if ((aMeta <= 0) || (aMeta >= GregTech_API.METATILEENTITIES.length)) { return; @@ -43,382 +510,81 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { aBlock.setBlockBoundsForItemRender(); aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + final IGregTechTileEntity iGregTechTileEntity = tMetaTileEntity.getBaseMetaTileEntity(); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - if ((tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity)) { - float tThickness = ((IPipeRenderedTileEntity) tMetaTileEntity.getBaseMetaTileEntity()).getThickNess(); - float sp = (1.0F - tThickness) / 2.0F; + if ((iGregTechTileEntity instanceof IPipeRenderedTileEntity)) { + final float tThickness = ((IPipeRenderedTileEntity) iGregTechTileEntity).getThickNess(); + final float pipeMin = (blockMax - tThickness) / 2.0F; + final float pipeMax = blockMax - pipeMin; - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 0, (byte) 9, (byte) -1, false, false), true); + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) DOWN.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 1, (byte) 9, (byte) -1, false, false), true); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) UP.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 2, (byte) 9, (byte) -1, false, false), true); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) NORTH.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 3, (byte) 9, (byte) -1, false, false), true); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) SOUTH.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 4, (byte) 9, (byte) -1, true, false), true); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) WEST.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, true, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 5, (byte) 9, (byte) -1, true, false), true); - Tessellator.instance.draw(); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) EAST.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, true, false), true); } else { Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 0, (byte) 4, (byte) -1, true, false), true); + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) DOWN.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 1, (byte) 4, (byte) -1, true, false), true); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) UP.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 2, (byte) 4, (byte) -1, true, false), true); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) NORTH.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 3, (byte) 4, (byte) -1, true, false), true); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) SOUTH.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 4, (byte) 4, (byte) -1, true, false), true); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) WEST.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 5, (byte) 4, (byte) -1, true, false), true); - Tessellator.instance.draw(); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) EAST.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); } - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + Tessellator.instance.draw(); + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); GL11.glTranslatef(0.5F, 0.5F, 0.5F); } - public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IPipeRenderedTileEntity)) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{ - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) 0), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) 1), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) 2), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) 3), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) 4), - ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) 5)}); - } - if ((tTileEntity instanceof ITexturedTileEntity)) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{ - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 0), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 1), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 2), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 3), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 4), - ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 5)}); - } - return false; - } - - public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer, ITexture[][] aTextures) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); - return true; - } - - public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { - byte aConnections = aTileEntity.getConnections(); - if ((aConnections & 0xC0) != 0) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } - float tThickness = aTileEntity.getThickNess(); - if (tThickness >= 0.99F) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } - float sp = (1.0F - tThickness) / 2.0F; - - byte tConnections = 0; - for (byte i = 0; i < 6; i = (byte) (i + 1)) { - if ((aConnections & 1 << i) != 0) { - tConnections = (byte) (tConnections | 1 << (i + 2) % 6); - } - } - boolean[] tIsCovered = new boolean[6]; - for (byte i = 0; i < 6; i = (byte) (i + 1)) { - tIsCovered[i] = (aTileEntity.getCoverIDAtSide(i) != 0); - } - if ((tIsCovered[0]) && (tIsCovered[1]) && (tIsCovered[2]) && (tIsCovered[3]) && (tIsCovered[4]) && (tIsCovered[5])) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } - ITexture[][] tIcons = new ITexture[6][]; - ITexture[][] tCovers = new ITexture[6][]; - for (byte i = 0; i < 6; i = (byte) (i + 1)) { - tCovers[i] = aTileEntity.getTexture(aBlock, i); - tIcons[i] = aTileEntity.getTextureUncovered(i); - } - if (tConnections == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - } else if (tConnections == 3) { - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - - } else if (tConnections == 12) { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - - } else if (tConnections == 48) { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - - } else { - if ((tConnections & 0x1) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - - } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - if ((tConnections & 0x2) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - - } - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - if ((tConnections & 0x4) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - - } - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - if ((tConnections & 0x8) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - - } - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - if ((tConnections & 0x10) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - - } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - if ((tConnections & 0x20) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - - } - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - } - if (tIsCovered[0]) { - aBlock.setBlockBounds(0.0F, 0.0F + NO_Z_FIGHT_OFFSET, 0.0F, 1.0F, 0.125F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - } - if (tIsCovered[1]) { - aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F - NO_Z_FIGHT_OFFSET, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - } - if (tIsCovered[2]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F + NO_Z_FIGHT_OFFSET, 1.0F, 1.0F, 0.125F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - } - if (tIsCovered[3]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F - NO_Z_FIGHT_OFFSET); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - } - if (tIsCovered[4]) { - aBlock.setBlockBounds(0.0F + NO_Z_FIGHT_OFFSET, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (tIsCovered[5]) { - aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F - NO_Z_FIGHT_OFFSET, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - } - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - - return true; - } - public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { if (aWorld != null) { if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0))) return; @@ -497,58 +663,6 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { } } - public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { - aRenderer.enableAO = false; - if ((aBlock instanceof GT_Block_Machines)) { - if ((aMeta > 0) && (aMeta < GregTech_API.METATILEENTITIES.length) && (GregTech_API.METATILEENTITIES[aMeta] != null) && - (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { - renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); - } - } else if ((aBlock instanceof GT_Block_Ores_Abstract)) { - GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores(); - tTileEntity.mMetaData = ((short) aMeta); - - aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 0), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 1), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 2), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 3), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 4), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 5), true); - Tessellator.instance.draw(); - } - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, RenderBlocks aRenderer) { aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion; TileEntity tileEntity = aWorld.getTileEntity(aX, aY, aZ); -- cgit From 3c5e8ae8274dbafc5a464437f1e910984e4e03f2 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 10 Apr 2021 04:40:15 +0800 Subject: Optimize addOutput Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../GT_MetaTileEntity_Hatch_OutputBus.java | 38 +++++++++++++++++++++- .../GT_MetaTileEntity_MultiBlockBase.java | 28 +++------------- .../GT_MetaTileEntity_Hatch_OutputBus_ME.java | 11 +++++++ 3 files changed, 53 insertions(+), 24 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java index 9c227b8da7..57cfc44ff6 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_OutputBus.java @@ -12,7 +12,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import static gregtech.api.util.GT_Utility.*; +import static gregtech.api.util.GT_Utility.moveMultipleItemStacks; public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_OutputBus(int aID, String aName, String aNameRegional, int aTier) { @@ -110,6 +110,42 @@ public class GT_MetaTileEntity_Hatch_OutputBus extends GT_MetaTileEntity_Hatch { } } + /** + * Attempt to store as many items as possible into the internal inventory of this output bus. + * If you need atomicity you should use {@link gregtech.api.interfaces.tileentity.IHasInventory#addStackToSlot(int, ItemStack)} + * @param aStack Assume valid. + * Will be mutated. + * Take over the ownership. Caller should not retain a reference to this stack if the call returns true. + * @return true if stack is fully accepted. false is stack is partially accepted or nothing is accepted + */ + public boolean storeAll(ItemStack aStack) { + for (int i = 0, mInventoryLength = mInventory.length; i < mInventoryLength; i++) { + ItemStack tSlot = mInventory[i]; + if (GT_Utility.isStackInvalid(tSlot)) { + if (aStack.stackSize <= getInventoryStackLimit()) { + mInventory[i] = aStack; + return true; + } + mInventory[i] = aStack.splitStack(getInventoryStackLimit()); + } else { + int tRealStackLimit = Math.min(getInventoryStackLimit(), tSlot.getMaxStackSize()); + if (tSlot.stackSize < tRealStackLimit && + tSlot.isItemEqual(aStack) && + ItemStack.areItemStackTagsEqual(tSlot, aStack)) { + if (aStack.stackSize + tSlot.stackSize <= tRealStackLimit) { + mInventory[i].stackSize += aStack.stackSize; + return true; + } else { + // more to serve + aStack.stackSize -= tRealStackLimit - tSlot.stackSize; + mInventory[i].stackSize = tRealStackLimit; + } + } + } + } + return false; + } + @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { return aSide == aBaseMetaTileEntity.getFrontFacing(); diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index d4a32d20cc..6a5da54718 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -740,33 +740,15 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { public boolean addOutput(ItemStack aStack) { if (GT_Utility.isStackInvalid(aStack)) return false; aStack = GT_Utility.copy(aStack); + for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { + if (isValidMetaTileEntity(tHatch) && tHatch.storeAll(aStack)) { + return true; + } + } boolean outputSuccess = true; while (outputSuccess && aStack.stackSize > 0) { outputSuccess = false; - - if (GregTech_API.mAE2) { - // this separate cycle may be refactored out, after this function will hopefully be totally refactored - // for now it is here to avoid splitting stack when we have ME output bus - for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { - // TODO: If ever there will be another hatch storing in some external storage, here should be an interface check - if (tHatch instanceof GT_MetaTileEntity_Hatch_OutputBus_ME && isValidMetaTileEntity(tHatch)) { - int rest = ((GT_MetaTileEntity_Hatch_OutputBus_ME) tHatch).store(aStack); - if (rest != aStack.stackSize) - outputSuccess = true; - aStack.stackSize = rest; - if (rest == 0) - return true; - } - } - } ItemStack single = aStack.splitStack(1); - for (GT_MetaTileEntity_Hatch_OutputBus tHatch : mOutputBusses) { - if (!outputSuccess && isValidMetaTileEntity(tHatch)) { - for (int i = tHatch.getSizeInventory() - 1; i >= 0 && !outputSuccess; i--) { - if (tHatch.getBaseMetaTileEntity().addStackToSlot(i, single)) outputSuccess = true; - } - } - } for (GT_MetaTileEntity_Hatch_Output tHatch : mOutputHatches) { if (!outputSuccess && isValidMetaTileEntity(tHatch) && tHatch.outputsItems()) { if (tHatch.getBaseMetaTileEntity().addStackToSlot(1, single)) outputSuccess = true; diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java index 910ad73d65..4d70dd0bdf 100644 --- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java +++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_OutputBus_ME.java @@ -18,6 +18,7 @@ import appeng.me.helpers.AENetworkProxy; import appeng.me.helpers.IGridProxyable; import appeng.util.Platform; import cpw.mods.fml.common.Optional; +import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -60,6 +61,16 @@ public class GT_MetaTileEntity_Hatch_OutputBus_ME extends GT_MetaTileEntity_Hatc getProxy(); } + @Override + public boolean storeAll(ItemStack aStack) { + if (!GregTech_API.mAE2) + return false; + int tTotal = aStack.stackSize; + int tStored = store(aStack); + aStack.stackSize -= tStored; + return tTotal < tStored; + } + @Optional.Method(modid = "appliedenergistics2") public int store(final ItemStack stack) { if (stack == null) -- cgit From beb5e6daf243c1f2d38d9264378fff41c228a959 Mon Sep 17 00:00:00 2001 From: Johann Bernhardt Date: Sat, 10 Apr 2021 11:51:03 +0200 Subject: Revert "Fix return value for addOutput(fluid)" This reverts commit 95fb72834838aa365afd4c418b7b70c66644ffc2. --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index be7a3642cb..3adff2fc3f 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -703,9 +703,9 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { if (aLiquid == null) return false; FluidStack copiedFluidStack = aLiquid.copy(); if (!dumpFluid(copiedFluidStack, true)){ - return dumpFluid(copiedFluidStack, false); + dumpFluid(copiedFluidStack, false); } - return true; + return false; } protected void addFluidOutputs(FluidStack[] mOutputFluids2) { -- cgit From 8217982caf5d94cf5ea003bc06c8eb26eec48eef Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Wed, 21 Apr 2021 01:32:43 +0200 Subject: fix(rendering): itemblocks inventory brightness and orientation - Fix itemblock brightness and orientation to be exactly same as vanilla blocks in inventory. - Revert machine front facing to the brighter left side as it eases differentiating them. - Optimise inventory itemblock rendering to issue a draw quads only once for the entire block, rather than for each side. --- .../java/gregtech/api/util/LightingHelper.java | 4 + .../gregtech/common/render/GT_Renderer_Block.java | 86 ++++++++-------------- 2 files changed, 34 insertions(+), 56 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/util/LightingHelper.java b/src/main/java/gregtech/api/util/LightingHelper.java index 48c316d0cc..598253b7d7 100644 --- a/src/main/java/gregtech/api/util/LightingHelper.java +++ b/src/main/java/gregtech/api/util/LightingHelper.java @@ -56,6 +56,10 @@ public class LightingHelper { */ public LightingHelper(RenderBlocks renderBlocks) { this.renderBlocks = renderBlocks; + if (renderBlocks.useInventoryTint) { + // Block will be rendered in an inventory, so it needs its lightness maxed + setLightnessOverride(1.0F); + } } /** diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Block.java b/src/main/java/gregtech/common/render/GT_Renderer_Block.java index 51e0b8fd6f..1055991cad 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -450,9 +450,18 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { aRenderer.enableAO = false; + aRenderer.useInventoryTint = true; + + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + Tessellator.instance.startDrawingQuads(); + if ((aBlock instanceof GT_Block_Machines)) { - if ((aMeta > 0) && (aMeta < GregTech_API.METATILEENTITIES.length) && (GregTech_API.METATILEENTITIES[aMeta] != null) && - (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { + if ((aMeta > 0) + && (aMeta < GregTech_API.METATILEENTITIES.length) + && (GregTech_API.METATILEENTITIES[aMeta] != null) + && (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); } } else if ((aBlock instanceof GT_Block_Ores_Abstract)) { @@ -462,41 +471,32 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { aBlock.setBlockBoundsForItemRender(); aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 0), true); - Tessellator.instance.draw(); + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) DOWN.ordinal()), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 1), true); - Tessellator.instance.draw(); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) UP.ordinal()), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 2), true); - Tessellator.instance.draw(); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) NORTH.ordinal()), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 3), true); - Tessellator.instance.draw(); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) SOUTH.ordinal()), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 4), true); - Tessellator.instance.draw(); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) WEST.ordinal()), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 5), true); - Tessellator.instance.draw(); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) EAST.ordinal()), true); + } - aBlock.setBlockBounds(blockMin, blockMin, blockMin, 1.0F, 1.0F, 1.0F); + Tessellator.instance.draw(); + + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + aRenderer.useInventoryTint = false; } private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { @@ -512,7 +512,6 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { final IGregTechTileEntity iGregTechTileEntity = tMetaTileEntity.getBaseMetaTileEntity(); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); if ((iGregTechTileEntity instanceof IPipeRenderedTileEntity)) { final float tThickness = ((IPipeRenderedTileEntity) iGregTechTileEntity).getThickNess(); final float pipeMin = (blockMax - tThickness) / 2.0F; @@ -521,68 +520,42 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) DOWN.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) UP.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) NORTH.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) SOUTH.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) WEST.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, true, false), true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) EAST.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, true, false), true); } else { - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) DOWN.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.draw(); + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) DOWN.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) UP.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.draw(); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) UP.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) NORTH.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.draw(); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) NORTH.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) SOUTH.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.draw(); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) SOUTH.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) WEST.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.draw(); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) WEST.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); - Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) EAST.ordinal(), (byte) EAST.ordinal(), (byte) -1, true, false), true); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) EAST.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); } - Tessellator.instance.draw(); - aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); } public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { @@ -665,6 +638,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, RenderBlocks aRenderer) { aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion; + aRenderer.useInventoryTint = false; TileEntity tileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tileEntity == null) return false; if (tileEntity instanceof IGregTechTileEntity) { -- cgit From 47d60d6166bd9f7b518501596f3727ff32102a1b Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Mon, 26 Apr 2021 01:14:49 +0200 Subject: fix(hidecover) unchained posttick caused missed texture and size change Add missing chaining of the `onPostTick` event handler to parent class. `GT_MetaPipeEntity_(Cable|Pipe|Fluid)` classes were not forwarding the `onPostTick` event handler to their parent `MetaPipeEntity` class, so pipes were not rendering the change unless another machine tile which did properly chain the event handler to its parent (like `GT_MetaTileEntity_TieredMachineBlock`) was present in same chunk. --- .../api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java | 1 + .../api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java | 1 + .../api/metatileentity/implementations/GT_MetaPipeEntity_Item.java | 1 + 3 files changed, 3 insertions(+) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index e69e13b67a..19b6d26237 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -294,6 +294,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()) { { //amp handler diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index 8c88f0e3bd..708bbf2ca8 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -232,6 +232,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide() && aTick % 5 == 0) { mLastReceivedFrom &= 63; if (mLastReceivedFrom == 63) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index 64064875ab..1bbae2821b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -156,6 +156,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide() && aTick % 10 == 0) { if (aTick % mTickTime == 0) mTransferredItems = 0; -- cgit From 6221db0fcc477d038da3275a8607859034103d8b Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Mon, 26 Apr 2021 19:45:58 +0200 Subject: fix(multiblockbase): until the muffler has a valid tile address issue [NPE in GT_MetaTileEntity_MultiBlockBase.java:314 until the muffler has a valid tile #7454](https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/7454) --- .../implementations/GT_MetaTileEntity_MultiBlockBase.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java index 48816d1533..193b9d482c 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_MultiBlockBase.java @@ -16,8 +16,6 @@ import gregtech.api.util.GT_Recipe.GT_Recipe_Map; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import gregtech.common.items.GT_MetaGenerated_Tool_01; -import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_OutputBus_ME; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -310,8 +308,12 @@ public abstract class GT_MetaTileEntity_MultiBlockBase extends MetaTileEntity { aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & ~127) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64)); aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); boolean active=aBaseMetaTileEntity.isActive() && mPollution>0; - for(GT_MetaTileEntity_Hatch_Muffler aMuffler:mMufflerHatches) - aMuffler.getBaseMetaTileEntity().setActive(active); + for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) { + IGregTechTileEntity iGTTileEntity = aMuffler.getBaseMetaTileEntity(); + if (iGTTileEntity != null && !iGTTileEntity.isDead()) { + iGTTileEntity.setActive(active); + } + } } } -- cgit