diff options
author | Maxim <maxim235@gmx.de> | 2023-04-22 17:38:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-22 08:38:49 -0700 |
commit | fdde96ab6fef30064b67e28390008ee4ba455655 (patch) | |
tree | ee169d0d4a8432433c4ec01eada1e24049a0e47a /src/main/java/gregtech/common | |
parent | de864236f83dc31c53ca77a6939357a0959bca75 (diff) | |
download | GT5-Unofficial-fdde96ab6fef30064b67e28390008ee4ba455655.tar.gz GT5-Unofficial-fdde96ab6fef30064b67e28390008ee4ba455655.tar.bz2 GT5-Unofficial-fdde96ab6fef30064b67e28390008ee4ba455655.zip |
MuTE overhaul and ACR (#1883)
* complex controller start
* Added methods to get input fluids and items
* Added logic to complex parallel mute
* Added ACR and fixed many, many, many, many bugs
* Added void protection setting to checkRecipe
* do not init nbt, if mteID and mteRegistry are the same
* Improved GUI design
* Force structure check when pressing power switch
* ACR Textures
* Added T1 structure
* Added perfect OC
* Added WAILA
* fix mutes resetting their nbt
* Fix ACR GUI
* fix npe
* Added void protection for MuTEs
* Fixed ACR starting recipe while another one is ongoing
* nbt saving
* maybe fix structure breaking
* Fix complex machine disabling on startup
* correctly update input tanks
* move casings over
* Changed logic of casings to change mode and facing in one go by sneaking
* Fixed the casing target not resetting
* Added side only annotations
* don't leave it empty
* Added power logic and tiered blocks to ACR
* Change facing to wrench side if casing mode is currently none
* lasers anyone?
* Added ACR item chaining
* Remove unncessary item lists
* Use HashSet for process whitelists
* Optimize list capacities
* Fix potential recipe voiding bug
* Rename methods for consistancy
* Fix NPE
* Duct tape fix structure check
* allow MuTEs to connect to cables
* Added separate tank inventories for input separation (#1887)
* Fixed unregistering tank function
* Fixed input busses not being automatable
* Added fluid chaining
* Fixed saving of input tanks
* Forbid inventory registering with empty name
* Display all input tanks in controller GUI
* Fixed fluid hatch GUI height
* Reset casing lists when checking the structure
* Make inventory GUI size consistant
* Make use of the tooltip cache
* rename thing clean up
* Forgot to put tooltip into map
* Added tooltip to ACR
* Reset whitelists when one whitelist window was opened
* Refined scanner string
* Fixed progress times
* Fixed MuTE not consuming fluids
* Properly register controller inventories
* switch to ForgeDirection
* switch to new Renderer
* Added missing contains check on registerInventory
* Fixed output tanks not registering
* Fixed upgrade tank loading
* fix machines not having active/inactive textures
* fix overlays not loading correctly
* Don't register controller directly
* Remove magic strings all
* fix active not setting to inactive
* allow glow
* item renderer
* fix glow
* MuTE improved hatch GUI and fluid output locking (#1889)
* Allow output hatches to be fluid locked
* Reworked hatch GUI
* Check target before trying to open GUI
* Make ACR GUI easier to look at
* fix covers not rendering on mutes
* fix covers not displaying above the item/fluid in/out
* new folder texture structure
* Reduce network traffic caused by covers
* Fixed WAILA fluid locking display
* Don't save everything to the itemstack NBT
* Added possibility to save NBT of MuTE to its itemstack
* fix textures, but make sacrifices
* mah textures
* Removed the need for all textures to be present
* Added glow texture for active coke oven
* Removed unncesssary upgrade casing textures
* shorten nbt tags
---------
Co-authored-by: BlueWeabo <76872108+BlueWeabo@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common')
16 files changed, 831 insertions, 299 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 2874bde726..4ae0204636 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -64,6 +64,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.interfaces.tileentity.ITurnable; import gregtech.api.items.GT_MetaGenerated_Item; import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.multitileentity.multiblock.base.MultiBlockPart; import gregtech.api.net.GT_Packet_ClientPreference; import gregtech.api.objects.GT_ItemStack; import gregtech.api.util.ColorsMetadataSection; @@ -567,6 +568,7 @@ public class GT_Client extends GT_Proxy implements Runnable { public void onLoad() { super.onLoad(); new GT_Renderer_Block(); + new GT_MultiTile_Renderer(); metaGeneratedItemRenderer = new GT_MetaGenerated_Item_Renderer(); for (GT_MetaGenerated_Item item : GT_MetaGenerated_Item.sInstances.values()) { metaGeneratedItemRenderer.registerItem(item); @@ -778,7 +780,9 @@ public class GT_Client extends GT_Proxy implements Runnable { if (!(aTileEntity instanceof ICoverable)) return; if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList) - || GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList)) { + || GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList) + || (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSoftHammerList) + && aTileEntity instanceof MultiBlockPart) && aEvent.player.isSneaking()) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) drawGrid(aEvent, false, false, aEvent.player.isSneaking()); return; diff --git a/src/main/java/gregtech/common/render/GT_MultiTile_Renderer.java b/src/main/java/gregtech/common/render/GT_MultiTile_Renderer.java new file mode 100644 index 0000000000..4d55979658 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_MultiTile_Renderer.java @@ -0,0 +1,181 @@ +package gregtech.common.render; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.GT_Mod; +import gregtech.api.interfaces.ITexture; +import gregtech.api.logic.ModelRenderLogic; +import gregtech.api.logic.interfaces.ModelRenderLogicHost; +import gregtech.api.multitileentity.MultiTileEntityBlockInternal; +import gregtech.api.multitileentity.MultiTileEntityClassContainer; +import gregtech.api.multitileentity.MultiTileEntityRegistry; +import gregtech.api.multitileentity.interfaces.IMultiBlockController; +import gregtech.api.multitileentity.multiblock.base.MultiBlockPart; + +public class GT_MultiTile_Renderer implements ISimpleBlockRenderingHandler { + + private final int renderID; + public static GT_MultiTile_Renderer INSTANCE; + + public GT_MultiTile_Renderer() { + this.renderID = RenderingRegistry.getNextAvailableRenderId(); + INSTANCE = this; + RenderingRegistry.registerBlockHandler(this); + } + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + if (!(block instanceof MultiTileEntityBlockInternal)) { + return; + } + + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + MultiTileEntityBlockInternal mteBlock = (MultiTileEntityBlockInternal) block; + MultiTileEntityRegistry registry = mteBlock.getRegistry(); + if (registry == null) return; + MultiTileEntityClassContainer classContainer = registry.getClassContainer(metadata); + if (classContainer == null) return; + renderer.setRenderBoundsFromBlock(mteBlock); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + ITexture texture = classContainer.mCanonicalTileEntity.getTexture(side); + if (texture == null) continue; + switch (side) { + case DOWN -> renderYNegative(null, renderer, 0, 0, 0, block, texture, side); + case UP -> renderYPositive(null, renderer, 0, 0, 0, block, texture, side); + case WEST -> renderXNegative(null, renderer, 0, 0, 0, block, texture, side); + case EAST -> renderXPositive(null, renderer, 0, 0, 0, block, texture, side); + case NORTH -> renderZNegative(null, renderer, 0, 0, 0, block, texture, side); + case SOUTH -> renderZPositive(null, renderer, 0, 0, 0, block, texture, side); + default -> { + // Do nothing + } + } + } + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + TileEntity entity = world.getTileEntity(x, y, z); + if (entity == null) { + return false; + } + + renderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion; + renderer.useInventoryTint = false; + + if (entity instanceof ModelRenderLogicHost modelEntity && modelEntity.shouldRenderModel()) { + ModelRenderLogic renderLogic = modelEntity.getRenderLogic(); + return true; + } + + if (!(entity instanceof MultiTileBasicRender)) { + return false; + } + + if (entity instanceof MultiBlockPart) { + IMultiBlockController controller = ((MultiBlockPart) entity).getTarget(false); + if (controller instanceof ModelRenderLogicHost && ((ModelRenderLogicHost) controller).shouldRenderModel()) { + return false; + } + } + + MultiTileBasicRender renderedEntity = (MultiTileBasicRender) entity; + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + ITexture texture = renderedEntity.getTexture(side); + if (texture == null) continue; + switch (side) { + case DOWN -> renderYNegative(world, renderer, x, y, z, block, texture, side); + case UP -> renderYPositive(world, renderer, x, y, z, block, texture, side); + case WEST -> renderXNegative(world, renderer, x, y, z, block, texture, side); + case EAST -> renderXPositive(world, renderer, x, y, z, block, texture, side); + case NORTH -> renderZNegative(world, renderer, x, y, z, block, texture, side); + case SOUTH -> renderZPositive(world, renderer, x, y, z, block, texture, side); + default -> { + // Do nothing + } + } + } + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return renderID; + } + + private static void renderYNegative(IBlockAccess world, RenderBlocks renderer, int x, int y, int z, Block block, + ITexture texture, ForgeDirection side) { + if (world != null) { + if (!block.shouldSideBeRendered(world, x, y - 1, z, side.ordinal())) return; + Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x, y - 1, z)); + } + texture.renderYNeg(renderer, block, x, y, z); + } + + private static void renderZNegative(IBlockAccess world, RenderBlocks renderer, int x, int y, int z, Block block, + ITexture texture, ForgeDirection side) { + if (world != null) { + if (!block.shouldSideBeRendered(world, x, y, z - 1, side.ordinal())) return; + Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z - 1)); + } + texture.renderZNeg(renderer, block, x, y, z); + } + + private static void renderXNegative(IBlockAccess world, RenderBlocks renderer, int x, int y, int z, Block block, + ITexture texture, ForgeDirection side) { + if (world != null) { + if (!block.shouldSideBeRendered(world, x - 1, y, z, side.ordinal())) return; + Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x - 1, y, z)); + } + texture.renderXNeg(renderer, block, x, y, z); + } + + private static void renderYPositive(IBlockAccess world, RenderBlocks renderer, int x, int y, int z, Block block, + ITexture texture, ForgeDirection side) { + if (world != null) { + if (!block.shouldSideBeRendered(world, x, y + 1, z, side.ordinal())) return; + Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x, y + 1, z)); + } + texture.renderYPos(renderer, block, x, y, z); + } + + private static void renderXPositive(IBlockAccess world, RenderBlocks renderer, int x, int y, int z, Block block, + ITexture texture, ForgeDirection side) { + if (world != null) { + if (!block.shouldSideBeRendered(world, x + 1, y, z, side.ordinal())) return; + Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x + 1, y, z)); + } + texture.renderXPos(renderer, block, x, y, z); + } + + private static void renderZPositive(IBlockAccess world, RenderBlocks renderer, int x, int y, int z, Block block, + ITexture texture, ForgeDirection side) { + if (world != null) { + if (!block.shouldSideBeRendered(world, x, y, z + 1, side.ordinal())) return; + Tessellator.instance.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z + 1)); + } + texture.renderZPos(renderer, block, x, y, z); + } +} 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 7646ee31fa..012115efa3 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -1,9 +1,5 @@ package gregtech.common.render; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; -import static gregtech.api.enums.GT_Values.OFFX; -import static gregtech.api.enums.GT_Values.OFFY; -import static gregtech.api.enums.GT_Values.OFFZ; 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; @@ -27,7 +23,6 @@ import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EntityDiggingFX; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; @@ -529,150 +524,73 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - if (aBlock instanceof IRenderedBlock) { - boolean tNeedsToSetBounds = true; - final ItemStack aStack = new ItemStack(aBlock, 1, aMeta); - IRenderedBlock tRenderer = ((IRenderedBlock) aBlock).passRenderingToObject(aStack); - if (tRenderer != null) tRenderer = tRenderer.passRenderingToObject(aStack); - if (tRenderer == null) tRenderer = IRenderedBlock.ErrorRenderer.INSTANCE; - for (int i = 0, j = tRenderer.getRenderPasses(aBlock); i < j; i++) { - if (tRenderer.usesRenderPass(i)) { - if (tRenderer.setBlockBounds(aBlock, i)) { - tNeedsToSetBounds = true; - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - if (tNeedsToSetBounds) aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - tNeedsToSetBounds = false; - } + if (aBlock instanceof GT_Block_Ores_Abstract) { + final GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores(); + tTileEntity.mMetaData = ((short) aMeta); - renderNegativeYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tRenderer.getTexture(aBlock, (byte) DOWN.ordinal(), true, i), - !tNeedsToSetBounds); - renderPositiveYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tRenderer.getTexture(aBlock, (byte) UP.ordinal(), true, i), - !tNeedsToSetBounds); - renderNegativeZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tRenderer.getTexture(aBlock, (byte) NORTH.ordinal(), true, i), - !tNeedsToSetBounds); - renderPositiveZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tRenderer.getTexture(aBlock, (byte) SOUTH.ordinal(), true, i), - !tNeedsToSetBounds); - renderNegativeXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tRenderer.getTexture(aBlock, (byte) WEST.ordinal(), true, i), - !tNeedsToSetBounds); - renderPositiveXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tRenderer.getTexture(aBlock, (byte) EAST.ordinal(), true, i), - !tNeedsToSetBounds); - } + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, (byte) DOWN.ordinal()), + true); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, (byte) UP.ordinal()), + true); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, (byte) NORTH.ordinal()), + true); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, (byte) SOUTH.ordinal()), + true); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, (byte) WEST.ordinal()), + true); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + tTileEntity.getTexture(aBlock, (byte) EAST.ordinal()), + true); + } else if (aMeta > 0 && (aMeta < GregTech_API.METATILEENTITIES.length) + && aBlock instanceof GT_Block_Machines + && (GregTech_API.METATILEENTITIES[aMeta] != null) + && (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { + renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); } - if (tNeedsToSetBounds) aBlock.setBlockBounds(0, 0, 0, 1, 1, 1); - - } else { - if (aBlock instanceof GT_Block_Ores_Abstract) { - final GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores(); - tTileEntity.mMetaData = ((short) aMeta); - - aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tTileEntity.getTexture(aBlock, (byte) DOWN.ordinal()), - true); - renderPositiveYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tTileEntity.getTexture(aBlock, (byte) UP.ordinal()), - true); - renderNegativeZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tTileEntity.getTexture(aBlock, (byte) NORTH.ordinal()), - true); - renderPositiveZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tTileEntity.getTexture(aBlock, (byte) SOUTH.ordinal()), - true); - renderNegativeXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tTileEntity.getTexture(aBlock, (byte) WEST.ordinal()), - true); - renderPositiveXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - tTileEntity.getTexture(aBlock, (byte) EAST.ordinal()), - true); - } else if (aMeta > 0 && (aMeta < GregTech_API.METATILEENTITIES.length) - && aBlock instanceof GT_Block_Machines - && (GregTech_API.METATILEENTITIES[aMeta] != null) - && (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { - renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); - } - aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); - } + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); @@ -979,94 +897,6 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { RenderBlocks aRenderer) { aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion; aRenderer.useInventoryTint = false; - if (aBlock instanceof IRenderedBlock) { - IRenderedBlock tRenderer = ((IRenderedBlock) aBlock).passRenderingToObject(aWorld, aX, aY, aZ); - if (tRenderer != null) tRenderer = tRenderer.passRenderingToObject(aWorld, aX, aY, aZ); - if (tRenderer == null) tRenderer = IRenderedBlock.ErrorRenderer.INSTANCE; - boolean tNeedsToSetBounds = true; - boolean rReturn = false; - if (tRenderer.renderBlock(aBlock, aRenderer, aWorld, aX, aY, aZ)) { - rReturn = true; - } else { - final boolean[] tSides = new boolean[6]; - if (tRenderer instanceof IRenderedBlockSideCheck) { - for (byte tSide : ALL_VALID_SIDES) rReturn |= (tSides[tSide] = ((IRenderedBlockSideCheck) tRenderer) - .renderFullBlockSide(aBlock, aRenderer, tSide)); - } else { - for (byte tSide : ALL_VALID_SIDES) rReturn |= (tSides[tSide] = aBlock - .shouldSideBeRendered(aWorld, aX + OFFX[tSide], aY + OFFY[tSide], aZ + OFFZ[tSide], tSide)); - } - for (int i = 0, j = tRenderer.getRenderPasses(aBlock); i < j; i++) { - if (tRenderer.usesRenderPass(i)) { - if (tRenderer.setBlockBounds(aBlock, i)) { - tNeedsToSetBounds = true; - aRenderer.setRenderBoundsFromBlock(aBlock); - } else { - if (tNeedsToSetBounds) aBlock.setBlockBounds(0, 0, 0, 1, 1, 1); - aRenderer.setRenderBoundsFromBlock(aBlock); - tNeedsToSetBounds = false; - } - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - tRenderer.getTexture(aBlock, (byte) DOWN.ordinal(), i, tSides), - tSides[DOWN.ordinal()]); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - tRenderer.getTexture(aBlock, (byte) UP.ordinal(), i, tSides), - tSides[UP.ordinal()]); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - tRenderer.getTexture(aBlock, (byte) NORTH.ordinal(), i, tSides), - tSides[NORTH.ordinal()]); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - tRenderer.getTexture(aBlock, (byte) SOUTH.ordinal(), i, tSides), - tSides[SOUTH.ordinal()]); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - tRenderer.getTexture(aBlock, (byte) WEST.ordinal(), i, tSides), - tSides[WEST.ordinal()]); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - tRenderer.getTexture(aBlock, (byte) EAST.ordinal(), i, tSides), - tSides[EAST.ordinal()]); - } - } - if (tNeedsToSetBounds) aBlock.setBlockBounds(0, 0, 0, 1, 1, 1); - } - - return rReturn; - } final TileEntity tileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tileEntity == null) return false; diff --git a/src/main/java/gregtech/common/render/MultiTileBasicRender.java b/src/main/java/gregtech/common/render/MultiTileBasicRender.java new file mode 100644 index 0000000000..be41739401 --- /dev/null +++ b/src/main/java/gregtech/common/render/MultiTileBasicRender.java @@ -0,0 +1,10 @@ +package gregtech.common.render; + +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; + +public interface MultiTileBasicRender { + + ITexture getTexture(ForgeDirection side); +} diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/Conveyor.java b/src/main/java/gregtech/common/tileentities/casings/functional/Conveyor.java new file mode 100644 index 0000000000..31dea4cf38 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/functional/Conveyor.java @@ -0,0 +1,16 @@ +package gregtech.common.tileentities.casings.functional; + +import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; + +public class Conveyor extends FunctionalCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.conveyor"; + } + + @Override + public float getPartModifier() { + return 1.1f; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/Emitter.java b/src/main/java/gregtech/common/tileentities/casings/functional/Emitter.java new file mode 100644 index 0000000000..cce660ace4 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/functional/Emitter.java @@ -0,0 +1,16 @@ +package gregtech.common.tileentities.casings.functional; + +import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; + +public class Emitter extends FunctionalCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.emitter"; + } + + @Override + public float getPartModifier() { + return 1.3f; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/FieldGenerator.java b/src/main/java/gregtech/common/tileentities/casings/functional/FieldGenerator.java new file mode 100644 index 0000000000..3787d45af8 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/functional/FieldGenerator.java @@ -0,0 +1,16 @@ +package gregtech.common.tileentities.casings.functional; + +import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; + +public class FieldGenerator extends FunctionalCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.field.generator"; + } + + @Override + public float getPartModifier() { + return 2f; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/MotorCasing.java b/src/main/java/gregtech/common/tileentities/casings/functional/Motor.java index 32a53d418a..cddb293cc2 100644 --- a/src/main/java/gregtech/common/tileentities/casings/functional/MotorCasing.java +++ b/src/main/java/gregtech/common/tileentities/casings/functional/Motor.java @@ -2,10 +2,15 @@ package gregtech.common.tileentities.casings.functional; import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; -public class MotorCasing extends FunctionalCasing { +public class Motor extends FunctionalCasing { @Override public String getTileEntityName() { return "gt.multitileentity.multiblock.functional.motor"; } + + @Override + public float getPartModifier() { + return 1; + } } diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/Piston.java b/src/main/java/gregtech/common/tileentities/casings/functional/Piston.java new file mode 100644 index 0000000000..2255fbf8a2 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/functional/Piston.java @@ -0,0 +1,16 @@ +package gregtech.common.tileentities.casings.functional; + +import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; + +public class Piston extends FunctionalCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.piston"; + } + + @Override + public float getPartModifier() { + return 1.1f; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/Pump.java b/src/main/java/gregtech/common/tileentities/casings/functional/Pump.java new file mode 100644 index 0000000000..3acddbe9dc --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/functional/Pump.java @@ -0,0 +1,16 @@ +package gregtech.common.tileentities.casings.functional; + +import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; + +public class Pump extends FunctionalCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.pump"; + } + + @Override + public float getPartModifier() { + return 1.1f; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/RobotArm.java b/src/main/java/gregtech/common/tileentities/casings/functional/RobotArm.java new file mode 100644 index 0000000000..2273705397 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/functional/RobotArm.java @@ -0,0 +1,16 @@ +package gregtech.common.tileentities.casings.functional; + +import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; + +public class RobotArm extends FunctionalCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.robot.arm"; + } + + @Override + public float getPartModifier() { + return 1.5f; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/functional/Sensor.java b/src/main/java/gregtech/common/tileentities/casings/functional/Sensor.java new file mode 100644 index 0000000000..e88060e902 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/casings/functional/Sensor.java @@ -0,0 +1,16 @@ +package gregtech.common.tileentities.casings.functional; + +import gregtech.api.multitileentity.multiblock.casing.FunctionalCasing; + +public class Sensor extends FunctionalCasing { + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.functional.sensor"; + } + + @Override + public float getPartModifier() { + return 1.3f; + } +} diff --git a/src/main/java/gregtech/common/tileentities/casings/upgrade/InventoryUpgrade.java b/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java index 06bb75c62f..c153e6c1c5 100644 --- a/src/main/java/gregtech/common/tileentities/casings/upgrade/InventoryUpgrade.java +++ b/src/main/java/gregtech/common/tileentities/casings/upgrade/Inventory.java @@ -13,7 +13,7 @@ import gregtech.api.multitileentity.interfaces.IMultiBlockController; import gregtech.api.multitileentity.multiblock.casing.UpgradeCasing; import gregtech.api.net.GT_Packet_MultiTileEntity; -public class InventoryUpgrade extends UpgradeCasing { +public class Inventory extends UpgradeCasing { public UUID mInventoryID; public static final int INPUT = 0; diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalReactor.java new file mode 100644 index 0000000000..ca8cc6332b --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/AdvChemicalReactor.java @@ -0,0 +1,432 @@ +package gregtech.common.tileentities.machines.multiblock; + +import static com.google.common.primitives.Ints.saturatedCast; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; +import static gregtech.api.enums.Mods.*; +import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.stream.Collectors; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.Constants; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidTank; + +import org.apache.commons.lang3.ArrayUtils; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.HeatingCoilLevel; +import gregtech.api.fluid.FluidTankGT; +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.logic.ComplexParallelProcessingLogic; +import gregtech.api.multitileentity.enums.GT_MultiTileCasing; +import gregtech.api.multitileentity.multiblock.base.ComplexParallelController; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_StructureUtility; +import gregtech.common.tileentities.casings.upgrade.Inventory; + +public class AdvChemicalReactor extends ComplexParallelController<AdvChemicalReactor> { + + private static IStructureDefinition<AdvChemicalReactor> STRUCTURE_DEFINITION = null; + protected static final String STRUCTURE_PIECE_T1 = "T1"; + protected static final Vec3Impl STRUCTURE_OFFSET = new Vec3Impl(3, 1, 0); + protected static final int PROCESS_WINDOW_BASE_ID = 100; + protected static final int ITEM_WHITELIST_SLOTS = 8; + protected static final int FLUID_WHITELIST_SLOTS = 8; + protected static final int MAX_PROCESSES = 4; + protected int numberOfProcessors = MAX_PROCESSES; // TODO: Set this value depending on structure + protected HeatingCoilLevel coilTier; + protected final ArrayList<HashSet<String>> processWhitelists = new ArrayList<>(MAX_PROCESSES); + protected final ArrayList<ItemStackHandler> processWhitelistInventoryHandlers = new ArrayList<>(MAX_PROCESSES); + protected final ArrayList<ArrayList<IFluidTank>> processFluidWhiteLists = new ArrayList<>(MAX_PROCESSES); + protected boolean wasWhitelistOpened = false; + + public AdvChemicalReactor() { + super(); + for (int i = 0; i < MAX_PROCESSES; i++) { + processWhitelists.add(null); + processWhitelistInventoryHandlers.add(new ItemStackHandler(ITEM_WHITELIST_SLOTS)); + ArrayList<IFluidTank> processFluidTanks = new ArrayList<>(FLUID_WHITELIST_SLOTS); + for (int j = 0; j < FLUID_WHITELIST_SLOTS; j++) { + processFluidTanks.add(new FluidTankGT()); + } + processFluidWhiteLists.add(processFluidTanks); + } + processingLogic = new ComplexParallelProcessingLogic( + GT_Recipe.GT_Recipe_Map_LargeChemicalReactor.sChemicalRecipes, + MAX_PROCESSES); + } + + @Override + public void readMultiTileNBT(NBTTagCompound nbt) { + super.readMultiTileNBT(nbt); + final NBTTagCompound processWhiteLists = nbt.getCompoundTag("whiteLists"); + long capacity = 1000; + if (nbt.hasKey(GT_Values.NBT.TANK_CAPACITY)) { + capacity = saturatedCast(nbt.getLong(GT_Values.NBT.TANK_CAPACITY)); + } + for (int i = 0; i < MAX_PROCESSES; i++) { + registerInventory("processInventory" + i, "processInventory" + i, 8, Inventory.INPUT); + registerFluidInventory( + "processInventory" + i, + "processInventory" + i, + 8, + capacity, + maxParallel * 2L, + Inventory.INPUT); + if (processWhiteLists != null) { + final NBTTagCompound itemList = processWhiteLists.getCompoundTag("items" + i); + if (itemList != null) { + processWhitelistInventoryHandlers.get(i) + .deserializeNBT(itemList); + } + final NBTTagList fluidList = processWhiteLists.getTagList("fluids" + i, Constants.NBT.TAG_COMPOUND); + if (fluidList != null) { + for (int j = 0; j < fluidList.tagCount(); j++) { + final NBTTagCompound fluid = fluidList.getCompoundTagAt(j); + if (fluid != null) { + short index = fluid.getShort("s"); + FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(fluid); + if (fluidStack != null) { + processFluidWhiteLists.get(i) + .get(index) + .fill(fluidStack, true); + } + } + } + } + } + } + } + + @Override + public void writeMultiTileNBT(NBTTagCompound nbt) { + super.writeMultiTileNBT(nbt); + final NBTTagCompound processWhiteLists = new NBTTagCompound(); + for (int i = 0; i < MAX_PROCESSES; i++) { + processWhiteLists.setTag( + "items" + i, + processWhitelistInventoryHandlers.get(i) + .serializeNBT()); + final NBTTagList fluidList = new NBTTagList(); + for (int j = 0; j < FLUID_WHITELIST_SLOTS; j++) { + final FluidStack fluidStack = processFluidWhiteLists.get(i) + .get(j) + .getFluid(); + if (fluidStack != null) { + final NBTTagCompound tag = new NBTTagCompound(); + tag.setByte("s", (byte) j); + fluidStack.writeToNBT(tag); + fluidList.appendTag(tag); + } + } + processWhiteLists.setTag("fluids" + i, fluidList); + } + nbt.setTag("whiteLists", processWhiteLists); + } + + @Override + public short getCasingRegistryID() { + return 0; + } + + @Override + public int getCasingMeta() { + return GT_MultiTileCasing.Chemical.getId(); + } + + @Override + public GT_Multiblock_Tooltip_Builder createTooltip() { + final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); + tt.addMachineType("Chemical Reactor") + .addInfo("Controller block for the Advanced Chemical Reactor") + .addInfo("Does not lose efficiency when overclocked") + .addInfo("Accepts fluids instead of fluid cells") + .addInfo("Can do multiple different recipes at once") + .addInfo("By using the whitelist filter a recipe can push its output") + .addInfo("to a different recipes input to chain them") + .addInfo(GT_Values.Authorminecraft7771) + .addSeparator() + .beginStructureBlock(5, 3, 3, false) + .addController("Front center") + .addCasingInfoExactly("PTFE Pipe Machine Casing", 8, false) + .addCasingInfoExactly("Heating Coils", 3, true) + .addCasingInfoExactly("EV+ Glass", 3, true) + .addCasingInfoExactly("Motor Casing", 3, true) + .addCasingInfoExactly("Chemical Casing", 27, false) + .toolTipFinisher("Gregtech"); + return tt; + } + + @Override + public Vec3Impl getStartingStructureOffset() { + return STRUCTURE_OFFSET; + } + + @Override + public boolean checkMachine() { + setCoilTier(HeatingCoilLevel.None); + setMaxComplexParallels(MAX_PROCESSES); + buildState.startBuilding(getStartingStructureOffset()); + boolean result = checkPiece(STRUCTURE_PIECE_T1, buildState.stopBuilding()); + return result && super.checkMachine(); + } + + @Override + public void construct(ItemStack trigger, boolean hintsOnly) { + buildState.startBuilding(getStartingStructureOffset()); + buildPiece(STRUCTURE_PIECE_T1, trigger, hintsOnly, buildState.stopBuilding()); + } + + @Override + public IStructureDefinition<AdvChemicalReactor> getStructureDefinition() { + if (STRUCTURE_DEFINITION == null) { + STRUCTURE_DEFINITION = StructureDefinition.<AdvChemicalReactor>builder() + .addShape( + STRUCTURE_PIECE_T1, + transpose( + new String[][] { { "CPCPC", "CCCCC", "CPCPC" }, { "CGC~C", "GWWWC", "CGCCC" }, + { "CPCPC", "CTTTC", "CPCPC" } })) + .addElement( + 'C', + addMultiTileCasing( + "gt.multitileentity.casings", + getCasingMeta(), + FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT | ENERGY_IN)) + .addElement('P', ofBlock(GregTech_API.sBlockCasings8, 1)) + .addElement('T', addMotorCasings(NOTHING)) + .addElement( + 'W', + GT_StructureUtility.ofCoil(AdvChemicalReactor::setCoilTier, AdvChemicalReactor::getCoilTier)) + .addElement( + 'G', + ofChain( + ofBlockUnlocalizedName(IndustrialCraft2.ID, "blockAlloyGlass", 0, true), + ofBlockUnlocalizedName(BartWorks.ID, "BW_GlasBlocks", 0, true), + ofBlockUnlocalizedName(BartWorks.ID, "BW_GlasBlocks2", 0, true), + ofBlockUnlocalizedName(Thaumcraft.ID, "blockCosmeticOpaque", 2, false))) + .build(); + } + return STRUCTURE_DEFINITION; + } + + @Override + protected FluidStack[] getInputFluids(int index) { + if (index < 0 || index >= MAX_PROCESSES) { + return null; + } + if (separateInputs) { + return ArrayUtils.addAll( + getFluidInputsForTankArray("processInventory" + index), + FluidTankGT.getFluidsFromTanks(inputTanks)); + } else { + return super.getInputFluids(index); + } + } + + @Override + protected ItemStack[] getInputItems(int index) { + if (index < 0 || index >= MAX_PROCESSES) { + return null; + } + if (separateInputs) { + return ArrayUtils.addAll( + getItemInputsForInventory("processInventory" + index), + inputInventory.getStacks() + .toArray(new ItemStack[0])); + } else { + return super.getInputItems(index); + } + } + + @Override + protected void outputItems(int index) { + ComplexParallelProcessingLogic processingLogic = getComplexProcessingLogic(); + if (processingLogic != null && index >= 0 && index < maxComplexParallels) { + for (int i = 0; i < MAX_PROCESSES; i++) { + // Regenerate whitelist, if it has been reset + if (processWhitelists.get(i) == null) { + generateWhitelist(i); + } + int outputIndex = i; + // Output items that are on the whitelist of this process + outputItems( + multiBlockInputInventory.get("processInventory" + i), + Arrays.stream(processingLogic.getOutputItems(index)) + .filter( + itemStack -> processWhitelists.get(outputIndex) + .contains(getWhitelistString(itemStack))) + .collect(Collectors.toList()) + .toArray(new ItemStack[0])); + } + // Output remaining items + if (processingLogic.getOutputItems(index) != null && processingLogic.getOutputItems(index).length > 0) { + outputItems(processingLogic.getOutputItems(index)); + } + } + } + + @Override + protected void outputFluids(int index) { + ComplexParallelProcessingLogic processingLogic = getComplexProcessingLogic(); + if (processingLogic != null && index >= 0 && index < maxComplexParallels) { + for (int i = 0; i < MAX_PROCESSES; i++) { + // Regenerate whitelist, if it has been reset + if (processWhitelists.get(i) == null) { + generateWhitelist(i); + } + int outputIndex = i; + // Output fluids that are on the whitelist of this process + outputFluids( + multiBlockInputTank.get("processInventory" + i), + Arrays.stream(processingLogic.getOutputFluids(index)) + .filter( + fluidStack -> processWhitelists.get(outputIndex) + .contains(getWhitelistString(fluidStack))) + .collect(Collectors.toList()) + .toArray(new FluidStack[0])); + } + // Output remaining fluids + if (processingLogic.getOutputFluids(index) != null && processingLogic.getOutputFluids(index).length > 0) { + outputFluids(processingLogic.getOutputFluids(index)); + } + } + } + + @Override + protected MultiChildWidget createMainPage() { + MultiChildWidget child = super.createMainPage(); + for (int i = 0; i < MAX_PROCESSES; i++) { + final int processIndex = i; + child.addChild( + new ButtonWidget().setPlayClickSound(true) + .setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(PROCESS_WINDOW_BASE_ID + processIndex); + }) + .setBackground(GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_WHITELIST) + .setSize(18, 18) + .setPos(20 * i + 18, 18)); + } + return child; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + for (int i = 0; i < MAX_PROCESSES; i++) { + final int processIndex = i; + buildContext.addSyncedWindow( + PROCESS_WINDOW_BASE_ID + i, + (player) -> createProcessConfigWindow(player, processIndex)); + } + buildContext.addCloseListener(() -> { + // Reset HashSet, we will let it re-generate on next item output + if (wasWhitelistOpened) { + for (int i = 0; i < MAX_PROCESSES; i++) { + processWhitelists.set(i, null); + } + wasWhitelistOpened = false; + } + }); + } + + protected ModularWindow createProcessConfigWindow(final EntityPlayer player, final int processIndex) { + wasWhitelistOpened = true; + ModularWindow.Builder builder = ModularWindow.builder(86, 100); + builder.widget( + new TextWidget("Process " + processIndex).setTextAlignment(Alignment.Center) + .setPos(13, 7)); + builder.setBackground(GT_UITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.widget( + SlotGroup.ofItemHandler(processWhitelistInventoryHandlers.get(processIndex), 4) + .startFromSlot(0) + .endAtSlot(ITEM_WHITELIST_SLOTS - 1) + .phantom(true) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(7, 19)); + builder.widget( + SlotGroup.ofFluidTanks(processFluidWhiteLists.get(processIndex), 4) + .startFromSlot(0) + .endAtSlot(FLUID_WHITELIST_SLOTS - 1) + .phantom(true) + .build() + .setPos(7, 55)); + return builder.build(); + } + + @Override + public String getTileEntityName() { + return "gt.multitileentity.multiblock.advchemicalreactor"; + } + + @Override + public String getLocalName() { + return "Advanced Chemical Reactor"; + } + + public void setCoilTier(HeatingCoilLevel coilTier) { + this.coilTier = coilTier; + } + + public HeatingCoilLevel getCoilTier() { + return coilTier; + } + + @Override + protected boolean hasPerfectOverclock() { + return true; + } + + protected void generateWhitelist(int processIndex) { + HashSet<String> whitelist = new HashSet<>(); + for (ItemStack itemStack : processWhitelistInventoryHandlers.get(processIndex) + .getStacks()) { + if (itemStack != null) { + whitelist.add(getWhitelistString(itemStack)); + } + } + for (IFluidTank tank : processFluidWhiteLists.get(processIndex)) { + if (tank.getFluid() != null) { + whitelist.add(getWhitelistString(tank.getFluid())); + } + } + processWhitelists.set(processIndex, whitelist); + } + + protected String getWhitelistString(ItemStack itemStack) { + if (itemStack != null) { + return itemStack.getUnlocalizedName(); + } + return null; + } + + protected String getWhitelistString(FluidStack fluidStack) { + if (fluidStack != null) { + return fluidStack.getUnlocalizedName(); + } + return null; + } +} diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/MultiBlock_CokeOven.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java index 66e9333961..3e465bb6ae 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/MultiBlock_CokeOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/CokeOven.java @@ -29,20 +29,19 @@ import gregtech.api.logic.ProcessingLogic; import gregtech.api.logic.interfaces.PollutionLogicHost; import gregtech.api.logic.interfaces.ProcessingLogicHost; import gregtech.api.multitileentity.enums.GT_MultiTileCasing; -import gregtech.api.multitileentity.multiblock.base.MultiBlockController; +import gregtech.api.multitileentity.multiblock.base.Controller; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.common.tileentities.machines.multiblock.logic.CokeOvenProcessingLogic; -public class MultiBlock_CokeOven extends MultiBlockController<MultiBlock_CokeOven> - implements PollutionLogicHost, ProcessingLogicHost { +public class CokeOven extends Controller<CokeOven> implements PollutionLogicHost, ProcessingLogicHost { - private static IStructureDefinition<MultiBlock_CokeOven> STRUCTURE_DEFINITION = null; + private static IStructureDefinition<CokeOven> STRUCTURE_DEFINITION = null; private static final Vec3Impl OFFSET = new Vec3Impl(1, 1, 0); private static final String MAIN = "Main"; private static final PollutionLogic POLLUTION_LOGIC = new PollutionLogic().setPollutionAmount(10); private final ProcessingLogic PROCESSING_LOGIC = new CokeOvenProcessingLogic(); - public MultiBlock_CokeOven() { + public CokeOven() { super(); setElectric(false); } @@ -71,7 +70,7 @@ public class MultiBlock_CokeOven extends MultiBlockController<MultiBlock_CokeOve } @Override - public short getCasingMeta() { + public int getCasingMeta() { return GT_MultiTileCasing.CokeOven.getId(); } @@ -93,9 +92,9 @@ public class MultiBlock_CokeOven extends MultiBlockController<MultiBlock_CokeOve } @Override - public IStructureDefinition<MultiBlock_CokeOven> getStructureDefinition() { + public IStructureDefinition<CokeOven> getStructureDefinition() { if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.<MultiBlock_CokeOven>builder() + STRUCTURE_DEFINITION = StructureDefinition.<CokeOven>builder() .addShape( MAIN, new String[][] { { "AAA", "A~A", "AAA" }, { "AAA", "A-A", "AAA" }, { "AAA", "AAA", "AAA" } }) diff --git a/src/main/java/gregtech/common/tileentities/machines/multiblock/MultiBlock_Macerator.java b/src/main/java/gregtech/common/tileentities/machines/multiblock/Macerator.java index c2bf782d40..5d837f1150 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multiblock/MultiBlock_Macerator.java +++ b/src/main/java/gregtech/common/tileentities/machines/multiblock/Macerator.java @@ -2,11 +2,6 @@ package gregtech.common.tileentities.machines.multiblock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ENERGY_IN; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_IN; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.FLUID_OUT; @@ -14,7 +9,6 @@ import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_I import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.ITEM_OUT; import static gregtech.api.multitileentity.multiblock.base.MultiBlockPart.NOTHING; -import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -24,20 +18,20 @@ import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import com.gtnewhorizon.structurelib.util.Vec3Impl; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.SoundResource; import gregtech.api.enums.TierEU; -import gregtech.api.interfaces.ITexture; -import gregtech.api.multitileentity.multiblock.base.MultiBlock_Stackable; -import gregtech.api.render.TextureFactory; +import gregtech.api.multitileentity.multiblock.base.StackableController; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Recipe.GT_Recipe_Map; -public class MultiBlock_Macerator extends MultiBlock_Stackable<MultiBlock_Macerator> { +public class Macerator extends StackableController<Macerator> { - private static IStructureDefinition<MultiBlock_Macerator> STRUCTURE_DEFINITION = null; + private static IStructureDefinition<Macerator> STRUCTURE_DEFINITION = null; - public MultiBlock_Macerator() { + public Macerator() { super(); } @@ -47,9 +41,9 @@ public class MultiBlock_Macerator extends MultiBlock_Stackable<MultiBlock_Macera } @Override - public IStructureDefinition<MultiBlock_Macerator> getStructureDefinition() { + public IStructureDefinition<Macerator> getStructureDefinition() { if (STRUCTURE_DEFINITION == null) { - STRUCTURE_DEFINITION = StructureDefinition.<MultiBlock_Macerator>builder() + STRUCTURE_DEFINITION = StructureDefinition.<Macerator>builder() .addShape(STACKABLE_TOP, transpose(new String[][] { { " CCC ", "CCCCC", "CCCCC", "CCCCC", " CCC " }, })) .addShape( STACKABLE_MIDDLE, @@ -67,12 +61,8 @@ public class MultiBlock_Macerator extends MultiBlock_Stackable<MultiBlock_Macera FLUID_IN | ITEM_IN | FLUID_OUT | ITEM_OUT))) .addElement('C', addMultiTileCasing("gt.multitileentity.casings", getCasingMeta(), NOTHING)) .addElement('D', addMultiTileCasing("gt.multitileentity.casings", getCasingMeta(), NOTHING)) - .addElement( - 'F', - ofChain( - addMultiTileCasing("gt.multitileentity.casings", 20001, NOTHING), - addMultiTileCasing("gt.multitileentity.casings", 20002, NOTHING))) - .addElement('G', addMultiTileCasing("gt.multitileentity.casings", 10000, NOTHING)) + .addElement('F', addMotorCasings(NOTHING)) + .addElement('G', addMultiTileCasing("gt.multitileentity.component.casings", 10000, NOTHING)) .build(); } return STRUCTURE_DEFINITION; @@ -84,7 +74,7 @@ public class MultiBlock_Macerator extends MultiBlock_Stackable<MultiBlock_Macera } @Override - public short getCasingMeta() { + public int getCasingMeta() { return 18000; } @@ -144,38 +134,6 @@ public class MultiBlock_Macerator extends MultiBlock_Stackable<MultiBlock_Macera } @Override - public ITexture[] getTexture(Block aBlock, byte aSide, boolean isActive, int aRenderPass) { - // TODO: MTE(Texture) - if (facing == aSide) { - return new ITexture[] { - // Base Texture - MACHINE_CASINGS[1][0], - // Active - isActive() ? TextureFactory.builder() - .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE) - .extFacing() - .build() - : TextureFactory.builder() - .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) - .extFacing() - .build(), - // Active Glow - isActive() ? TextureFactory.builder() - .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE_GLOW) - .extFacing() - .glow() - .build() - : TextureFactory.builder() - .addIcon(OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_GLOW) - .extFacing() - .glow() - .build() }; - } - // Base Texture - return new ITexture[] { MACHINE_CASINGS[1][0] }; - } - - @Override protected boolean checkRecipe() { if (isSeparateInputs()) { for (Pair<ItemStack[], String> tItemInputs : getItemInputsForEachInventory()) { @@ -209,6 +167,7 @@ public class MultiBlock_Macerator extends MultiBlock_Stackable<MultiBlock_Macera return true; } + @SideOnly(Side.CLIENT) @Override protected ResourceLocation getActivitySoundLoop() { return SoundResource.IC2_MACHINES_MACERATOR_OP.resourceLocation; |