From d736caaf43e43c2bd250f1b5d9a91c8dd06a6147 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Tue, 8 Jun 2021 06:31:42 +0800 Subject: allow gt wrench to rotate the front of controller also cleaned up GT_Client.java a little bit. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 475 ++++++++++++++------------- 1 file changed, 238 insertions(+), 237 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index d66972e882..4ff9e69a2a 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -6,6 +6,11 @@ package gregtech.common; import codechicken.lib.vec.Rotation; +import codechicken.lib.vec.Scale; +import codechicken.lib.vec.Transformation; +import codechicken.lib.vec.Translation; +import com.gtnewhorizon.structurelib.alignment.IAlignment; +import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; @@ -29,6 +34,7 @@ import gregtech.common.render.*; import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -40,6 +46,7 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.event.world.WorldEvent; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; @@ -52,36 +59,61 @@ import java.util.*; public class GT_Client extends GT_Proxy implements Runnable { - private static List ROTATABLE_VANILLA_BLOCKS; + public static final String GTNH_CAPE_LIST_URL = "https://raw.githubusercontent.com/GTNewHorizons/CustomGTCapeHook-Cape-List/master/capes.txt"; + public static final String GT_CAPE_LIST_URL = "http://gregtech.overminddl1.com/com/gregoriust/gregtech/supporterlist.txt"; + private static final List ROTATABLE_VANILLA_BLOCKS; + + private static final int[][] GRID_SWITCH_ARR = new int[][]{ + {0, 5, 3, 1, 2, 4}, + {5, 0, 1, 3, 2, 4}, + {1, 3, 0, 5, 2, 4}, + {3, 1, 5, 0, 2, 4}, + {4, 2, 3, 1, 0, 5}, + {2, 4, 3, 1, 5, 0}, + }; + + public static final Transformation ROTATION_MARKER_TRANSFORM_CENTER = new Scale(0.5); + private static final Transformation[] ROTATION_MARKER_TRANSFORMS_SIDES = { + new Scale(0.25).with(new Translation(0, 0, 0.375)), + new Scale(0.25).with(new Translation(0.375, 0, 0)), + new Scale(0.25).with(new Translation(0, 0, -0.375)), + new Scale(0.25).with(new Translation(-0.375, 0, 0)), + }; + private static final Transformation[] ROTATION_MARKER_TRANSFORMS_CORNER = { + new Scale(0.25).with(new Translation(0.375, 0, 0.375)), + new Scale(0.25).with(new Translation(-0.375, 0, 0.375)), + new Scale(0.25).with(new Translation(0.375, 0, -0.375)), + new Scale(0.25).with(new Translation(-0.375, 0, -0.375)), + }; static { - ROTATABLE_VANILLA_BLOCKS = Arrays.asList(new Block[]{ - Blocks.piston, Blocks.sticky_piston, Blocks.furnace, Blocks.lit_furnace, Blocks.dropper, Blocks.dispenser, Blocks.chest, Blocks.trapped_chest, Blocks.ender_chest, Blocks.hopper, - Blocks.pumpkin, Blocks.lit_pumpkin - }); + ROTATABLE_VANILLA_BLOCKS = Arrays.asList(Blocks.piston, Blocks.sticky_piston, Blocks.furnace, Blocks.lit_furnace, Blocks.dropper, Blocks.dispenser, Blocks.chest, Blocks.trapped_chest, Blocks.ender_chest, Blocks.hopper, + Blocks.pumpkin, Blocks.lit_pumpkin); } private final HashSet mCapeList = new HashSet<>(); public static final GT_PollutionRenderer mPollutionRenderer = new GT_PollutionRenderer(); private final GT_CapeRenderer mCapeRenderer; - private final List mPosR; - private final List mPosG; - private final List mPosB; - private final List mPosA = Arrays.asList(new Object[0]); - private final List mNegR; - private final List mNegG; - private final List mNegB; - private final List mNegA = Arrays.asList(new Object[0]); - private final List mMoltenPosR; - private final List mMoltenPosG; - private final List mMoltenPosB; - private final List mMoltenPosA = Arrays.asList(new Object[0]); - private final List mMoltenNegR; - private final List mMoltenNegG; - private final List mMoltenNegB; - private final List mMoltenNegA = Arrays.asList(new Object[0]); + private final List mPosR; + private final List mPosG; + private final List mPosB; + private final List mPosA = Collections.emptyList(); + private final List mNegR; + private final List mNegG; + private final List mNegB; + private final List mNegA = Collections.emptyList(); + private final List mMoltenPosR; + private final List mMoltenPosG; + private final List mMoltenPosB; + private final List mMoltenPosA = Collections.emptyList(); + private final List mMoltenNegR; + private final List mMoltenNegG; + private final List mMoltenNegB; + private final List mMoltenNegA = Collections.emptyList(); private long mAnimationTick; - /**This is the place to def the value used below**/ + /** + * This is the place to def the value used below + **/ private long afterSomeTime; private boolean mAnimationDirection; private int mLastUpdatedBlockX; @@ -92,57 +124,34 @@ public class GT_Client extends GT_Proxy private GT_ClientPreference mPreference; private boolean mFirstTick = false; public GT_Client() { - mCapeRenderer = new GT_CapeRenderer(mCapeList); + mCapeRenderer = new GT_CapeRenderer(mCapeList); mAnimationTick = 0L; mAnimationDirection = false; isFirstClientPlayerTick = true; mMessage = ""; - mPosR = Arrays.asList(new Materials[]{ - /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone - }); - mPosG = Arrays.asList(new Materials[]{ - /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth - }); - mPosB = Arrays.asList(new Materials[]{ - /**Materials.ChargedCertusQuartz, **/Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, - Materials.InfusedWater, Materials.Thaumium - }); - mNegR = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy, Materials.NetherStar - }); - mNegG = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy, Materials.NetherStar - }); - mNegB = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy, Materials.NetherStar - }); - mMoltenPosR = Arrays.asList(new Materials[]{ - Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone - }); - mMoltenPosG = Arrays.asList(new Materials[]{ - Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, - Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth - }); - mMoltenPosB = Arrays.asList(new Materials[]{ - Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, - Materials.InfusedWater, Materials.Thaumium - }); - mMoltenNegR = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy - }); - mMoltenNegG = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy - }); - mMoltenNegB = Arrays.asList(new Materials[]{ - Materials.InfusedEntropy - }); + mPosR = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone); + mPosG = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth); + mPosB = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, + Materials.InfusedWater, Materials.Thaumium); + mNegR = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar); + mNegG = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar); + mNegB = Arrays.asList(Materials.InfusedEntropy, Materials.NetherStar); + mMoltenPosR = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone); + mMoltenPosG = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, + Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.InfusedAir, Materials.InfusedEarth); + mMoltenPosB = Arrays.asList(Materials.Enderium, Materials.NetherStar, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.InfusedVis, + Materials.InfusedWater, Materials.Thaumium); + mMoltenNegR = Collections.singletonList(Materials.InfusedEntropy); + mMoltenNegG = Collections.singletonList(Materials.InfusedEntropy); + mMoltenNegB = Collections.singletonList(Materials.InfusedEntropy); } private static boolean checkedForChicken = false; + private static void drawGrid(DrawBlockHighlightEvent aEvent, boolean showCoverConnections) { if (!checkedForChicken) { try { @@ -159,11 +168,13 @@ public class GT_Client extends GT_Proxy GL11.glPushMatrix(); GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks)); GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F); - Rotation.sideRotations[aEvent.target.sideHit].glApply(); + int tSideHit = aEvent.target.sideHit; + Rotation.sideRotations[tSideHit].glApply(); + // draw grid GL11.glTranslated(0.0D, -0.501D, 0.0D); GL11.glLineWidth(2.0F); GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F); - GL11.glBegin(1); + GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(+.50D, .0D, -.25D); GL11.glVertex3d(-.50D, .0D, -.25D); GL11.glVertex3d(+.50D, .0D, +.25D); @@ -174,88 +185,118 @@ public class GT_Client extends GT_Proxy GL11.glVertex3d(-.25D, .0D, +.50D); TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); + // draw turning indicator + if (tTile instanceof IGregTechTileEntity && + ((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof IAlignmentProvider) { + IAlignment tAlignment = ((IAlignmentProvider) ((IGregTechTileEntity) tTile).getMetaTileEntity()).getAlignment(); + if (tAlignment != null) { + ForgeDirection direction = tAlignment.getDirection(); + + GL11.glEnd(); + if (direction.ordinal() == tSideHit) + drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); + else if (direction.getOpposite().ordinal() == tSideHit) { + for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { + drawRotationMarker(t); + } + } else { + drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES[Rotation.rotationTo(direction.ordinal(), tSideHit)]); + } + // resume glBegin + GL11.glBegin(GL11.GL_LINES); + } + } + + // draw connection indicators byte tConnections = 0; - if (tTile instanceof ICoverable){ + if (tTile instanceof ICoverable) { if (showCoverConnections) { for (byte i = 0; i < 6; i++) { - if ( ((ICoverable) tTile).getCoverIDAtSide(i) > 0) - tConnections = (byte)(tConnections + (1 << i)); + if (((ICoverable) tTile).getCoverIDAtSide(i) > 0) + tConnections = (byte) (tConnections + (1 << i)); } - } - else if (tTile instanceof BaseMetaPipeEntity) + } else if (tTile instanceof BaseMetaPipeEntity) tConnections = ((BaseMetaPipeEntity) tTile).mConnections; } if (tConnections>0) { - int[][] GridSwitchArr = new int[][]{ - {0, 5, 3, 1, 2, 4}, - {5, 0, 1, 3, 2, 4}, - {1, 3, 0, 5, 2, 4}, - {3, 1, 5, 0, 2, 4}, - {4, 2, 3, 1, 0, 5}, - {2, 4, 3, 1, 5, 0}, - }; - for (byte i = 0; i < 6; i++) { - if ((tConnections & (1 << i)) != 0) { - switch (GridSwitchArr[aEvent.target.sideHit][i]) { - case 0: - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, -.25D); - break; - case 1: - GL11.glVertex3d(-.25D, .0D, +.50D); - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, +.50D); - break; - case 2: - GL11.glVertex3d(-.50D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(-.50D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, -.25D); - break; - case 3: - GL11.glVertex3d(-.25D, .0D, -.50D); - GL11.glVertex3d(+.25D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, -.25D); - GL11.glVertex3d(+.25D, .0D, -.50D); - break; - case 4: - GL11.glVertex3d(+.50D, .0D, -.25D); - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(+.50D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, -.25D); - break; - case 5: - GL11.glVertex3d(+.50D, .0D, +.50D); - GL11.glVertex3d(+.25D, .0D, +.25D); - GL11.glVertex3d(+.50D, .0D, +.25D); - GL11.glVertex3d(+.25D, .0D, +.50D); - GL11.glVertex3d(+.50D, .0D, -.50D); - GL11.glVertex3d(+.25D, .0D, -.25D); - GL11.glVertex3d(+.50D, .0D, -.25D); - GL11.glVertex3d(+.25D, .0D, -.50D); - GL11.glVertex3d(-.50D, .0D, +.50D); - GL11.glVertex3d(-.25D, .0D, +.25D); - GL11.glVertex3d(-.50D, .0D, +.25D); - GL11.glVertex3d(-.25D, .0D, +.50D); - GL11.glVertex3d(-.50D, .0D, -.50D); - GL11.glVertex3d(-.25D, .0D, -.25D); - GL11.glVertex3d(-.50D, .0D, -.25D); - GL11.glVertex3d(-.25D, .0D, -.50D); - break; - } - } - } + for (byte i = 0; i < 6; i++) { + if ((tConnections & (1 << i)) != 0) { + switch (GRID_SWITCH_ARR[aEvent.target.sideHit][i]) { + case 0: + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, -.25D); + break; + case 1: + GL11.glVertex3d(-.25D, .0D, +.50D); + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, +.50D); + break; + case 2: + GL11.glVertex3d(-.50D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(-.50D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, -.25D); + break; + case 3: + GL11.glVertex3d(-.25D, .0D, -.50D); + GL11.glVertex3d(+.25D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, -.25D); + GL11.glVertex3d(+.25D, .0D, -.50D); + break; + case 4: + GL11.glVertex3d(+.50D, .0D, -.25D); + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(+.50D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, -.25D); + break; + case 5: + GL11.glVertex3d(+.50D, .0D, +.50D); + GL11.glVertex3d(+.25D, .0D, +.25D); + GL11.glVertex3d(+.50D, .0D, +.25D); + GL11.glVertex3d(+.25D, .0D, +.50D); + GL11.glVertex3d(+.50D, .0D, -.50D); + GL11.glVertex3d(+.25D, .0D, -.25D); + GL11.glVertex3d(+.50D, .0D, -.25D); + GL11.glVertex3d(+.25D, .0D, -.50D); + GL11.glVertex3d(-.50D, .0D, +.50D); + GL11.glVertex3d(-.25D, .0D, +.25D); + GL11.glVertex3d(-.50D, .0D, +.25D); + GL11.glVertex3d(-.25D, .0D, +.50D); + GL11.glVertex3d(-.50D, .0D, -.50D); + GL11.glVertex3d(-.25D, .0D, -.25D); + GL11.glVertex3d(-.50D, .0D, -.25D); + GL11.glVertex3d(-.25D, .0D, -.50D); + break; + } + } + } } GL11.glEnd(); GL11.glPopMatrix(); } - private static void drawGrid(DrawBlockHighlightEvent aEvent) { - drawGrid(aEvent, false); + private static void drawRotationMarker(Transformation transform) { + GL11.glPushMatrix(); + transform.glApply(); + Tessellator t = Tessellator.instance; + t.startDrawing(GL11.GL_LINE_LOOP); + t.addVertex(-0.4d, 0d, -0.4d); + t.addVertex(-0.4d, 0d, 0.4d); + t.addVertex(0.4d, 0d, 0.4d); + t.addVertex(0.4d, 0d, -0.325d); + t.addVertex(0.45d, 0d, -0.325d); + t.addVertex(0.35d, 0d, -0.425d); + t.addVertex(0.25d, 0d, -0.325d); + t.addVertex(0.3d, 0d, -0.325d); + t.addVertex(0.3d, 0d, 0.3d); + t.addVertex(-0.3d, 0d, 0.3d); + t.addVertex(-0.3d, 0d, -0.4d); + t.draw(); + GL11.glPopMatrix(); } @Override @@ -286,7 +327,7 @@ public class GT_Client extends GT_Proxy @Override public void onPreLoad() { super.onPreLoad(); - String arr$[] = { + String[] arr = { "renadi", "hanakocz", "MysteryDump", "Flaver4", "x_Fame", "Peluche321", "Goshen_Ithilien", "manf", "Bimgo", "leagris", "IAmMinecrafter02", "Cerous", "Devilin_Pixy", "Bkarlsson87", "BadAlchemy", "CaballoCraft", "melanclock", "Resursator", "demanzke", "AndrewAmmerlaan", "Deathlycraft", "Jirajha", "Axlegear", "kei_kouma", "Dracion", "dungi", "Dorfschwein", "Zero Tw0", "mattiagraz85", "sebastiank30", @@ -301,12 +342,10 @@ public class GT_Client extends GT_Proxy "25FiveDetail", "AntiCivilBoy", "michaelbrady", "xXxIceFirexXx", "Speedynutty68", "GarretSidzaka", "HallowCharm977", "mastermind1919", "The_Hypersonic", "diamondguy2798", "zF4ll3nPr3d4t0r", "CrafterOfMines57", "XxELIT3xSNIP3RxX", "SuterusuKusanagi", "xavier0014", "adamros", "alexbegt" }; - int len$ = arr$.length; - for (int i$ = 0; i$ < len$; i$++) { - String tName = arr$[i$]; + for (String tName : arr) { mCapeList.add(tName.toLowerCase()); } - (new Thread(this)).start(); + new Thread(this).start(); mPollutionRenderer.preLoad(); @@ -356,47 +395,29 @@ public class GT_Client extends GT_Proxy @Override public void run() { - try { - GT_Log.out.println("GT_Mod: Downloading Cape List."); - @SuppressWarnings("resource") - Scanner tScanner = new Scanner(new URL("http://gregtech.overminddl1.com/com/gregoriust/gregtech/supporterlist.txt").openStream()); + GT_Log.out.println("GT_Mod: Downloading Cape List."); + try (Scanner tScanner = new Scanner(new URL(GT_CAPE_LIST_URL).openStream())) { while (tScanner.hasNextLine()) { - String tName = tScanner.nextLine(); - if (!this.mCapeList.contains(tName.toLowerCase())) { - this.mCapeList.add(tName.toLowerCase()); - } + this.mCapeList.add(tScanner.nextLine().toLowerCase()); } } catch (Throwable e) { + e.printStackTrace(GT_Log.err); } - try { - GT_Log.out.println("GT New Horizons: Downloading Cape List."); - @SuppressWarnings("resource") - Scanner tScanner = new Scanner(new URL("https://raw.githubusercontent.com/GTNewHorizons/CustomGTCapeHook-Cape-List/master/capes.txt").openStream()); - while (tScanner.hasNextLine()) { - String tName = tScanner.nextLine(); - if (tName.contains(":")) { - int splitLocation = tName.indexOf(":"); - String username = tName.substring(0, splitLocation); - if (!this.mCapeList.contains(username.toLowerCase()) && !this.mCapeList.contains(tName.toLowerCase())) { - this.mCapeList.add(tName.toLowerCase()); - } - } else { - if (!this.mCapeList.contains(tName.toLowerCase())) { - this.mCapeList.add(tName.toLowerCase()); - } - } - } - } catch (Throwable e) { - } - /**try { - GT_Log.out.println("GT_Mod: Downloading News."); - @SuppressWarnings("resource") - Scanner tScanner = new Scanner(new URL("http://files.minecraftforge.net/maven/com/gregoriust/gregtech/message.txt").openStream()); + GT_Log.out.println("GT New Horizons: Downloading Cape List."); + try (Scanner tScanner = new Scanner(new URL(GTNH_CAPE_LIST_URL).openStream())) { while (tScanner.hasNextLine()) { - this.mMessage = (this.mMessage + tScanner.nextLine() + " "); + String tName = tScanner.nextLine().toLowerCase(); + if (tName.contains(":")) { + if (!this.mCapeList.contains(tName.substring(0, tName.indexOf(":")))) { + this.mCapeList.add(tName); + } + } else { + this.mCapeList.add(tName); + } } } catch (Throwable e) { - }**/ + e.printStackTrace(GT_Log.err); + } } @Override @@ -418,34 +439,31 @@ public class GT_Client extends GT_Proxy GT_Values.NW.sendToServer(new GT_Packet_ClientPreference(mPreference)); } afterSomeTime++; - if(afterSomeTime>=100L) { - afterSomeTime=0; - StatFileWriter sfw= Minecraft.getMinecraft().thePlayer.getStatFileWriter(); + if (afterSomeTime >= 100L) { + afterSomeTime = 0; + StatFileWriter sfw = Minecraft.getMinecraft().thePlayer.getStatFileWriter(); try { - for(GT_Recipe recipe:GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { - recipe.mHidden=GT_Values.hideAssLineRecipes && !sfw.hasAchievementUnlocked(GT_Mod.achievements.getAchievement(recipe.getOutput(0).getUnlocalizedName())); + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.mRecipeList) { + recipe.mHidden = GT_Values.hideAssLineRecipes && !sfw.hasAchievementUnlocked(GT_Mod.achievements.getAchievement(recipe.getOutput(0).getUnlocalizedName())); } - } catch (Exception ignored){} + } catch (Exception ignored) { + } } - ArrayList tList = new ArrayList(); - for (Map.Entry tEntry : GT_Utility.sPlayedSoundMap.entrySet()) { - if (tEntry.getValue().intValue() < 0) {//Integer -> Integer -> int? >_<, fix - tList.add(tEntry.getKey()); + for (Iterator> iterator = GT_Utility.sPlayedSoundMap.entrySet().iterator(); iterator.hasNext(); ) { + Map.Entry tEntry = iterator.next(); + if (tEntry.getValue() < 0) { + iterator.remove(); } else { - tEntry.setValue(Integer.valueOf(tEntry.getValue().intValue() - 1)); + tEntry.setValue(tEntry.getValue() - 1); } } - GT_PlayedSound tKey; - for (Iterator i$ = tList.iterator(); i$.hasNext(); GT_Utility.sPlayedSoundMap.remove(tKey)) { - tKey = (GT_PlayedSound) i$.next(); - } - if(!GregTech_API.mServerStarted) GregTech_API.mServerStarted = true; + if (!GregTech_API.mServerStarted) GregTech_API.mServerStarted = true; if (GT_Values.updateFluidDisplayItems) { MovingObjectPosition trace = Minecraft.getMinecraft().objectMouseOver; if (trace != null && trace.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && (mLastUpdatedBlockX != trace.blockX && - mLastUpdatedBlockY != trace.blockY && - mLastUpdatedBlockZ != trace.blockZ || afterSomeTime % 10 == 0)) { + mLastUpdatedBlockY != trace.blockY && + mLastUpdatedBlockZ != trace.blockZ || afterSomeTime % 10 == 0)) { mLastUpdatedBlockX = trace.blockX; mLastUpdatedBlockY = trace.blockY; mLastUpdatedBlockZ = trace.blockZ; @@ -508,102 +526,85 @@ public class GT_Client extends GT_Proxy public void receiveRenderEvent(net.minecraftforge.client.event.RenderPlayerEvent.Pre aEvent) { if (GT_Utility.getFullInvisibility(aEvent.entityPlayer)) { aEvent.setCanceled(true); - return; - } else { - return; } } @SubscribeEvent public void onClientTickEvent(cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent aEvent) { if (aEvent.phase == cpw.mods.fml.common.gameevent.TickEvent.Phase.END) { - if(changeDetected>0)changeDetected--; - int newHideValue=shouldHeldItemHideThings(); - if(newHideValue!=hideValue){ - hideValue=newHideValue; - changeDetected=5; + if (changeDetected > 0) changeDetected--; + int newHideValue = shouldHeldItemHideThings(); + if (newHideValue != hideValue) { + hideValue = newHideValue; + changeDetected = 5; } mAnimationTick++; - if (mAnimationTick % 50L == 0L) - {mAnimationDirection = !mAnimationDirection;} + if (mAnimationTick % 50L == 0L) { + mAnimationDirection = !mAnimationDirection; + } int tDirection = mAnimationDirection ? 1 : -1; - for (Iterator i$ = mPosR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Object o : mPosR) { + Materials tMaterial = (Materials) o; tMaterial.mRGBa[0] += tDirection; } - for (Iterator i$ = mPosG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mPosG) { tMaterial.mRGBa[1] += tDirection; } - for (Iterator i$ = mPosB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mPosB) { tMaterial.mRGBa[2] += tDirection; } - for (Iterator i$ = mPosA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mPosA) { tMaterial.mRGBa[3] += tDirection; } - for (Iterator i$ = mNegR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegR) { tMaterial.mRGBa[0] -= tDirection; } - for (Iterator i$ = mNegG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegG) { tMaterial.mRGBa[1] -= tDirection; } - for (Iterator i$ = mNegB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegB) { tMaterial.mRGBa[2] -= tDirection; } - for (Iterator i$ = mNegA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mNegA) { tMaterial.mRGBa[3] -= tDirection; } - for (Iterator i$ = mMoltenPosR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosR) { tMaterial.mMoltenRGBa[0] += tDirection; } - for (Iterator i$ = mMoltenPosG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosG) { tMaterial.mMoltenRGBa[1] += tDirection; } - for (Iterator i$ = mMoltenPosB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosB) { tMaterial.mMoltenRGBa[2] += tDirection; } - for (Iterator i$ = mMoltenPosA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenPosA) { tMaterial.mMoltenRGBa[3] += tDirection; } - for (Iterator i$ = mMoltenNegR.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegR) { tMaterial.mMoltenRGBa[0] -= tDirection; } - for (Iterator i$ = mMoltenNegG.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegG) { tMaterial.mMoltenRGBa[1] -= tDirection; } - for (Iterator i$ = mMoltenNegB.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegB) { tMaterial.mMoltenRGBa[2] -= tDirection; } - for (Iterator i$ = mMoltenNegA.iterator(); i$.hasNext(); ) { - Materials tMaterial = (Materials) i$.next(); + for (Materials tMaterial : mMoltenNegA) { tMaterial.mMoltenRGBa[3] -= tDirection; } @@ -620,8 +621,8 @@ public class GT_Client extends GT_Proxy do { if (i >= j) break; - if (GT_Utility.areStacksEqual((ItemStack) mSoundItems.get(i), aStack)) { - tString = (String) mSoundNames.get(i); + if (GT_Utility.areStacksEqual(mSoundItems.get(i), aStack)) { + tString = mSoundNames.get(i); break; } i++; -- cgit From 2085a8654580f2b1b457343cf5c225ecb1800dd6 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 9 Jun 2021 06:51:47 +0800 Subject: Fix rotate front face highlight Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 93 +++++++++++++++++----------- 1 file changed, 57 insertions(+), 36 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 4ff9e69a2a..154b8d7308 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -26,11 +26,22 @@ import gregtech.api.interfaces.tileentity.ITurnable; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.net.GT_Packet_ClientPreference; import gregtech.api.objects.GT_ItemStack; -import gregtech.api.util.*; +import gregtech.api.util.GT_Log; +import gregtech.api.util.GT_PlayedSound; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.common.entities.GT_Entity_Arrow; import gregtech.common.entities.GT_Entity_Arrow_Potion; import gregtech.common.net.MessageUpdateFluidDisplayItem; -import gregtech.common.render.*; +import gregtech.common.render.GT_CapeRenderer; +import gregtech.common.render.GT_FlaskRenderer; +import gregtech.common.render.GT_FluidDisplayStackRenderer; +import gregtech.common.render.GT_MetaGenerated_Item_Renderer; +import gregtech.common.render.GT_MetaGenerated_Tool_Renderer; +import gregtech.common.render.GT_PollutionRenderer; +import gregtech.common.render.GT_Renderer_Block; +import gregtech.common.render.GT_Renderer_Entity_Arrow; import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -51,7 +62,13 @@ import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; import java.net.URL; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Scanner; // Referenced classes of package gregtech.common: // GT_Proxy @@ -72,18 +89,27 @@ public class GT_Client extends GT_Proxy {2, 4, 3, 1, 5, 0}, }; - public static final Transformation ROTATION_MARKER_TRANSFORM_CENTER = new Scale(0.5); - private static final Transformation[] ROTATION_MARKER_TRANSFORMS_SIDES = { - new Scale(0.25).with(new Translation(0, 0, 0.375)), - new Scale(0.25).with(new Translation(0.375, 0, 0)), - new Scale(0.25).with(new Translation(0, 0, -0.375)), - new Scale(0.25).with(new Translation(-0.375, 0, 0)), + // don't ask. these "just works" + private static final Transformation ROTATION_MARKER_TRANSFORM_CENTER = new Scale(0.5); + private static final Transformation[] ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS = { + new Scale(0.25).with(new Translation(0, 0, 0.375)).compile(), + new Scale(0.25).with(new Translation(0.375, 0, 0)).compile(), + new Scale(0.25).with(new Translation(0, 0, -0.375)).compile(), + new Scale(0.25).with(new Translation(-0.375, 0, 0)).compile(), + }; + private static final int[] ROTATION_MARKER_TRANSFORMS_SIDES = { + -1, -1, 2, 0, 3, 1, + -1, -1, 0, 2, 3, 1, + 0, 2, -1, -1, 3, 1, + 2, 0, -1, -1, 3, 1, + 1, 3, 2, 0, -1, -1, + 3, 1, 2, 0, -1, -1 }; private static final Transformation[] ROTATION_MARKER_TRANSFORMS_CORNER = { - new Scale(0.25).with(new Translation(0.375, 0, 0.375)), - new Scale(0.25).with(new Translation(-0.375, 0, 0.375)), - new Scale(0.25).with(new Translation(0.375, 0, -0.375)), - new Scale(0.25).with(new Translation(-0.375, 0, -0.375)), + new Scale(0.25).with(new Translation(0.375, 0, 0.375)).compile(), + new Scale(0.25).with(new Translation(-0.375, 0, 0.375)).compile(), + new Scale(0.25).with(new Translation(0.375, 0, -0.375)).compile(), + new Scale(0.25).with(new Translation(-0.375, 0, -0.375)).compile(), }; static { @@ -185,28 +211,6 @@ public class GT_Client extends GT_Proxy GL11.glVertex3d(-.25D, .0D, +.50D); TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - // draw turning indicator - if (tTile instanceof IGregTechTileEntity && - ((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof IAlignmentProvider) { - IAlignment tAlignment = ((IAlignmentProvider) ((IGregTechTileEntity) tTile).getMetaTileEntity()).getAlignment(); - if (tAlignment != null) { - ForgeDirection direction = tAlignment.getDirection(); - - GL11.glEnd(); - if (direction.ordinal() == tSideHit) - drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); - else if (direction.getOpposite().ordinal() == tSideHit) { - for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { - drawRotationMarker(t); - } - } else { - drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES[Rotation.rotationTo(direction.ordinal(), tSideHit)]); - } - // resume glBegin - GL11.glBegin(GL11.GL_LINES); - } - } - // draw connection indicators byte tConnections = 0; if (tTile instanceof ICoverable) { @@ -276,7 +280,24 @@ public class GT_Client extends GT_Proxy } } GL11.glEnd(); - GL11.glPopMatrix(); + // draw turning indicator + if (tTile instanceof IGregTechTileEntity && + ((IGregTechTileEntity) tTile).getMetaTileEntity() instanceof IAlignmentProvider) { + IAlignment tAlignment = ((IAlignmentProvider) ((IGregTechTileEntity) tTile).getMetaTileEntity()).getAlignment(); + if (tAlignment != null) { + ForgeDirection direction = tAlignment.getDirection(); + if (direction.ordinal() == tSideHit) + drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); + else if (direction.getOpposite().ordinal() == tSideHit) { + for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { + drawRotationMarker(t); + } + } else { + drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit*6+direction.ordinal()]]); + } + } + } + GL11.glPopMatrix(); // get back to player center } private static void drawRotationMarker(Transformation transform) { -- cgit From 3a472099af01778f5b62cc4ab2aaf6dc5cfff299 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Thu, 10 Jun 2021 05:23:15 +0800 Subject: migrate even more multis over Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 2 +- .../GT_MetaTileEntity_ConcreteBackfiller1.java | 5 +- .../GT_MetaTileEntity_ConcreteBackfiller2.java | 35 +-- .../GT_MetaTileEntity_ConcreteBackfillerBase.java | 12 +- .../multi/GT_MetaTileEntity_DrillerBase.java | 89 ++++--- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 8 +- .../multi/GT_MetaTileEntity_HeatExchanger.java | 149 +++++------ .../multi/GT_MetaTileEntity_LargeBoiler.java | 139 +++++------ .../GT_MetaTileEntity_LargeChemicalReactor.java | 131 +++++----- .../multi/GT_MetaTileEntity_LargeTurbine_Gas.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_HPSteam.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_Plasma.java | 2 +- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 2 +- .../multi/GT_MetaTileEntity_MultiFurnace.java | 3 +- .../multi/GT_MetaTileEntity_OilCracker.java | 276 ++++++++++----------- .../multi/GT_MetaTileEntity_OilDrill1.java | 5 +- .../multi/GT_MetaTileEntity_OilDrill2.java | 5 +- .../multi/GT_MetaTileEntity_OilDrill3.java | 5 +- .../multi/GT_MetaTileEntity_OilDrillBase.java | 17 +- .../multi/GT_MetaTileEntity_OreDrillingPlant1.java | 5 +- .../multi/GT_MetaTileEntity_OreDrillingPlant2.java | 5 +- .../multi/GT_MetaTileEntity_OreDrillingPlant3.java | 5 +- .../multi/GT_MetaTileEntity_OreDrillingPlant4.java | 5 +- .../GT_MetaTileEntity_OreDrillingPlantBase.java | 8 +- 24 files changed, 423 insertions(+), 494 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 154b8d7308..8e06207267 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -293,7 +293,7 @@ public class GT_Client extends GT_Proxy drawRotationMarker(t); } } else { - drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit*6+direction.ordinal()]]); + drawRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit * 6 + direction.ordinal()]]); } } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java index a509d35ad3..af1468396b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller1.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_ConcreteBackfiller1 extends GT_MetaTileEntity_ConcreteBackfillerBase { public GT_MetaTileEntity_ConcreteBackfiller1(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_ConcreteBackfiller1 extends GT_MetaTileEntity_Con } @Override - public String[] getDescription() { - return getDescriptionInternal(""); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("Concrete Backfiller"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java index d1f44580c6..05646676e7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfiller2.java @@ -6,10 +6,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import static gregtech.api.enums.GT_Values.VN; - -import org.lwjgl.input.Keyboard; - public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_ConcreteBackfillerBase { public GT_MetaTileEntity_ConcreteBackfiller2(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -20,35 +16,8 @@ public class GT_MetaTileEntity_ConcreteBackfiller2 extends GT_MetaTileEntity_Con } @Override - public String[] getDescription() { - String casings = getCasingBlockItem().get(0).getDisplayName(); - - final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType("Concrete Backfiller") - .addInfo("Controller Block for the Advanced Concrete Backfiller") - .addInfo("Will fill in areas below it with light concrete. This goes through walls") - .addInfo("Use it to remove any spawning locations beneath your base to reduce lag") - .addInfo("Will pull back the pipes after it finishes that layer") - .addInfo("Put Programmed Circuits into a Data Access Hatch to config radius. Buggy") - .addInfo("Radius = (total config value)x2 blocks. Default 64, Maximum 128")//broken - .addSeparator() - .beginStructureBlock(3, 7, 3, false) - .addController("Front bottom") - .addStructureInfo(casings + " form the 3x1x3 Base") - .addOtherStructurePart(casings, " 1x3x1 pillar above the center of the base (2 minimum total)") - .addOtherStructurePart(getFrameMaterial().mName + " Frame Boxes", "Each pillar's side and 1x3x1 on top") - .addEnergyHatch(VN[getMinTier()] + "+, Any base casing") - .addMaintenanceHatch("Any base casing") - .addStructureInfo("Data Access Hatch: Any base casing") - .addInputBus("Mining Pipes, optional, any base casing") - .addInputHatch("GT Concrete, any base casing") - .addOutputBus("Mining Pipes, optional, any base casing") - .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("Advanced Concrete Backfiller"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java index a64fea5ab0..2341452ebe 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ConcreteBackfillerBase.java @@ -11,8 +11,6 @@ import net.minecraft.item.ItemStack; import static gregtech.api.enums.GT_Values.VN; -import org.lwjgl.input.Keyboard; - public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTileEntity_DrillerBase { private int mLastXOff = 0, mLastZOff = 0; @@ -25,12 +23,12 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi super(aName); } - protected String[] getDescriptionInternal(String tierSuffix) { + protected GT_Multiblock_Tooltip_Builder createTooltip(String aStructureName) { String casings = getCasingBlockItem().get(0).getDisplayName(); final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Concrete Backfiller") - .addInfo("Controller Block for the Concrete Backfiller " + (tierSuffix != null ? tierSuffix : ""))//Unused? + .addInfo("Controller Block for the " + aStructureName) .addInfo("Will fill in areas below it with light concrete. This goes through walls") .addInfo("Use it to remove any spawning locations beneath your base to reduce lag") .addInfo("Will pull back the pipes after it finishes that layer") @@ -47,11 +45,7 @@ public abstract class GT_MetaTileEntity_ConcreteBackfillerBase extends GT_MetaTi .addInputHatch("GT Concrete, any base casing") .addOutputBus("Mining Pipes, optional, any base casing") .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + return tt; } @Override 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 a57a237060..8916c9f42a 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 @@ -1,5 +1,8 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -7,10 +10,10 @@ import gregtech.api.interfaces.IChunkLoader; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_DataAccess; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_ChunkManager; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; @@ -27,18 +30,45 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.W; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ORE_DRILL_GLOW; import static gregtech.api.enums.Textures.BlockIcons.getCasingTextureForId; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_MultiBlockBase implements IChunkLoader { +public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_EnhancedMultiBlockBase 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); private static final Block miningPipeTipBlock = GT_Utility.getBlockFromStack(miningPipeTip); + protected static final String STRUCTURE_PIECE_MAIN = "main"; + protected static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {" ", " f ", " "}, + {" ", " f ", " "}, + {" ", " f ", " "}, + {" f ", "fcf", " f "}, + {" f ", "fcf", " f "}, + {" f ", "fcf", " f "}, + {"b~b", "bbb", "bbb"}, + })) + .addElement('f', defer(t -> ofBlock(GregTech_API.sBlockMachines, t.frameMeta))) + .addElement('c', defer(t -> ofBlock(t.casingBlock, t.casingMeta))) + .addElement('b', defer(t -> ofChain( + ofBlock(t.casingBlock, t.casingMeta), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addMaintenanceToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addInputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addOutputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addEnergyInputToMachineList, t.casingTextureIndex, 1), + ofHatchAdder(GT_MetaTileEntity_DrillerBase::addDataAccessToMachineList, t.casingTextureIndex, 1) + ))) + .build(); private Block casingBlock; private int casingMeta; @@ -82,12 +112,12 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu if (aSide == aFacing) { if (aActive) return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_ORE_DRILL_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_ORE_DRILL), - TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_ORE_DRILL_GLOW).extFacing().glow().build()}; } return new ITexture[]{getCasingTextureForId(casingTextureIndex)}; } @@ -318,37 +348,20 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } } + @Override + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> d.offsetY == 0 && r.isNotRotated(); + } + + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { updateCoordinates(); - //check base layer - for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { - for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { - if (xOff == 0 && zOff == 0) continue; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); - if (!checkCasingBlock(xOff, 0, zOff) - && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) - && !addInputToMachineList(tTileEntity, casingTextureIndex) - && !addOutputToMachineList(tTileEntity, casingTextureIndex) - && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex) - && !addDataAccessToMachineList(tTileEntity, casingTextureIndex)) - return false; - } - } - if(!checkHatches()) return false; - if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) return false; - //check tower - for (int yOff = 1; yOff < 4; yOff++) { - if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) - || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)) - return false; - } - return true; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0) && checkHatches() && GT_Utility.getTier(getMaxInputVoltage()) >= getMinTier(); } private void updateCoordinates() { @@ -370,14 +383,17 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu return true; } + @Deprecated protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); } //meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight operation) + @Deprecated protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); } + @Deprecated protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { return checkBlockAndMeta(xDrill + xOff, yDrill + yOff, zDrill + zOff, block, meta); } @@ -484,4 +500,9 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_Mu } @Override public ChunkCoordIntPair getActiveChunk(){return mCurrentChunk;} + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 6, 0); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 010a73f777..22171e6e04 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -4,6 +4,7 @@ import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; @@ -35,6 +36,7 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAS 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.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.ofCoil; import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofHatchAdderOptional; @@ -55,7 +57,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab })) .addElement('t', ofHatchAdderOptional(GT_MetaTileEntity_ElectricBlastFurnace::addOutputHatchToTopList, CASING_INDEX, 1, GregTech_API.sBlockCasings1, CASING_INDEX)) .addElement('m', ofHatchAdder(GT_MetaTileEntity_ElectricBlastFurnace::addMufflerToMachineList, CASING_INDEX, 2)) - .addElement('C', GT_StructureUtility.ofCoil(GT_MetaTileEntity_ElectricBlastFurnace::setCoilLevel, GT_MetaTileEntity_ElectricBlastFurnace::getCoilLevel)) + .addElement('C', ofCoil(GT_MetaTileEntity_ElectricBlastFurnace::setCoilLevel, GT_MetaTileEntity_ElectricBlastFurnace::getCoilLevel)) .addElement('b', ofHatchAdderOptional(GT_MetaTileEntity_ElectricBlastFurnace::addBottomHatch, CASING_INDEX, 3, GregTech_API.sBlockCasings1, CASING_INDEX)) .build(); @@ -256,7 +258,9 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab replaceDeprecatedCoils(aBaseMetaTileEntity); - setCoilLevel(null); + setCoilLevel(HeatingCoilLevel.None); + + mPollutionOutputHatches.clear(); if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0)) return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 9ce1de3fec..0579c4871b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -1,44 +1,69 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; - -public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBlockBase { +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final int CASING_INDEX = 50; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ccc", "cCc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"c~c", "cHc", "ccc"}, + })) + .addElement('P', ofBlock(GregTech_API.sBlockCasings2, 14)) + .addElement('C', ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addColdFluidOutputToMachineList, CASING_INDEX, 2)) + .addElement('H', ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addHotFluidInputToMachineList, CASING_INDEX, 3)) + .addElement('c', ofChain( + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_HeatExchanger::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_HeatExchanger::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, (byte) 2)) + )) + .build(); public static float penalty_per_config = 0.015f; // penalize 1.5% efficiency per circuitry level (1-25) - private static boolean controller; private GT_MetaTileEntity_Hatch_Input mInputHotFluidHatch; private GT_MetaTileEntity_Hatch_Output mOutputColdFluidHatch; private boolean superheated = false; private int superheated_threshold=0; private float water; + private int mCasingAmount; public GT_MetaTileEntity_HeatExchanger(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -48,7 +73,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Heat Exchanger") .addInfo("Controller Block for the Large Heat Exchanger") @@ -68,11 +93,7 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc .addOutputHatch("Cold fluid, top center") .addOutputHatch("Steam/SH Steam, any casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -92,15 +113,15 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc if (aSide == aFacing) { if (aActive) return new ITexture[]{ - casingTexturePages[0][50], - TextureFactory.of(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW).glow().build()}; + casingTexturePages[0][CASING_INDEX], + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ - casingTexturePages[0][50], - TextureFactory.of(OVERLAY_FRONT_HEAT_EXCHANGER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_GLOW).glow().build()}; + casingTexturePages[0][CASING_INDEX], + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_HEAT_EXCHANGER_GLOW).extFacing().glow().build()}; } - return new ITexture[]{casingTexturePages[0][50]}; + return new ITexture[]{casingTexturePages[0][CASING_INDEX]}; } @Override @@ -114,8 +135,8 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc } @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; + protected IAlignmentLimits getInitialAlignmentLimits() { + return (d, r, f) -> !r.isUpsideDown(); } @Override @@ -208,57 +229,20 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - - int tCasingAmount = 0; - controller = false; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if ((i != 0) || (j != 0)) { - for (int k = 0; k <= 3; k++) { - if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && - !addInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && - !addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), 50) && - !ignoreController(aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j))) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getCasingBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getCasingMeta()) { - return false; - } - tCasingAmount++; - } - } - } else { - if (!addHotFluidInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j), 50)) { - return false; - } - if (!addColdFluidOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j), 50)) { - return false; - } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 1, zDir + j) != getPipeBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 1, zDir + j) != getPipeMeta()) { - return false; - } + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j) != getPipeBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j) != getPipeMeta()) { - return false; - } - } - } - } - return tCasingAmount >= 20; + private void onCasingAdded() { + mCasingAmount++; } - public boolean ignoreController(Block tTileEntity) { - return !controller && tTileEntity == GregTech_API.sBlockMachines; + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mOutputColdFluidHatch = null; + mInputHotFluidHatch = null; + mCasingAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 3, 0) && mCasingAmount >= 20 && mMaintenanceHatches.size() == 1; } public boolean addColdFluidOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -286,26 +270,6 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc return false; } - public Block getCasingBlock() { - return GregTech_API.sBlockCasings4; - } - - public byte getCasingMeta() { - return 2; - } - - public byte getCasingTextureIndex() { - return 50; - } - - public Block getPipeBlock() { - return GregTech_API.sBlockCasings2; - } - - public byte getPipeMeta() { - return 14; - } - @Override public int getMaxEfficiency(ItemStack aStack) { return 10000; @@ -351,4 +315,9 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc StatCollector.translateToLocal("GT5U.LHE.superheated") + " " + StatCollector.translateToLocal("GT5U.LHE.threshold") + ": " + EnumChatFormatting.GREEN + superheated_threshold + EnumChatFormatting.RESET }; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 3, 0); + } } 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 841a4fb57c..7f409f38f4 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 @@ -1,5 +1,7 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.GT_Mod; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -8,7 +10,7 @@ import gregtech.api.enums.Textures.BlockIcons; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; @@ -20,25 +22,52 @@ 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 com.gtnewhorizon.structurelib.structure.StructureUtility.defer; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_Values.STEAM_PER_WATER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_BOILER_GLOW; - -public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_MultiBlockBase { +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ccc", "ccc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"ccc", "cPc", "ccc"}, + {"f~f", "fff", "fff"}, + })) + .addElement('P', defer(t -> ofBlock(t.getPipeBlock(), t.getPipeMeta()))) + .addElement('c', defer(t -> ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addOutputToMachineList, t.getCasingTextureIndex(), 2), + onElementPass(GT_MetaTileEntity_LargeBoiler::onCasingAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ))) + .addElement('f', defer(t -> ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMaintenanceToMachineList, t.getCasingTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addInputToMachineList, t.getCasingTextureIndex(), 1), + ofHatchAdder(GT_MetaTileEntity_LargeBoiler::addMufflerToMachineList, t.getCasingTextureIndex(), 1), + onElementPass(GT_MetaTileEntity_LargeBoiler::onFireboxAdded, ofBlock(t.getCasingBlock(), t.getCasingMeta())) + ))) + .build(); 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 + private int mCasingAmount; + private int mFireboxAmount; public GT_MetaTileEntity_LargeBoiler(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -49,7 +78,7 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Boiler") .addInfo("Controller block for the Large " + getCasingMaterial() + " Boiler") @@ -71,11 +100,7 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu .addInputHatch("Water, Any firebox") .addOutputHatch("Steam, any casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } public abstract String getCasingMaterial(); @@ -107,12 +132,12 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu if (aSide == aFacing) { if (aActive) return new ITexture[]{ BlockIcons.getCasingTextureForId(getCasingTextureIndex()), - TextureFactory.of(OVERLAY_FRONT_LARGE_BOILER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ BlockIcons.getCasingTextureForId(getCasingTextureIndex()), - TextureFactory.of(OVERLAY_FRONT_LARGE_BOILER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_BOILER_GLOW).extFacing().glow().build()}; } return new ITexture[]{Textures.BlockIcons.getCasingTextureForId(getCasingTextureIndex())}; } @@ -127,11 +152,6 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu return true; } - @Override - public boolean isFacingValid(byte aFacing) { - return aFacing > 1; - } - @Override public boolean checkRecipe(ItemStack aStack) { //Do we have an integrated circuit with a valid configuration? @@ -249,65 +269,25 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu super.onPostTick(aBaseMetaTileEntity, aTick); } + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } + + private void onCasingAdded() { + mCasingAmount++; + } + + private void onFireboxAdded() { + mFireboxAmount++; + } + @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - - int tCasingAmount = 0; - int tFireboxAmount = 0; - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (i != 0 || j != 0) { - for (int k = 1; k <= 4; k++) { - if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, k, zDir + j), getCasingTextureIndex())) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getCasingBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getCasingMeta()) { - return false; - } - tCasingAmount++; - } - } - } else { - for (int k = 1; k <= 3; k++) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, k, zDir + j) != getPipeBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, k, zDir + j) != getPipeMeta()) { - return false; - } - } - if (!addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 4, zDir + j), getCasingTextureIndex())) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 4, zDir + j) != getCasingBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 4, zDir + j) != getCasingMeta()) { - return false; - } - tCasingAmount++; - } - } - } - } - for (int i = -1; i < 2; i++) { - for (int j = -1; j < 2; j++) { - if (xDir + i != 0 || zDir + j != 0) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 0, zDir + j); - if (!addMaintenanceToMachineList(tTileEntity, getFireboxTextureIndex()) && !addInputToMachineList(tTileEntity, getFireboxTextureIndex()) && !addMufflerToMachineList(tTileEntity, getFireboxTextureIndex())) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + i, 0, zDir + j) != getFireboxBlock()) { - return false; - } - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 0, zDir + j) != getFireboxMeta()) { - return false; - } - tFireboxAmount++; - } - } - } - } - return tCasingAmount >= 24 && tFireboxAmount >= 3; + mCasingAmount = 0; + mFireboxAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 4, 0) && mCasingAmount >= 24 && mFireboxAmount >= 3 && + mMaintenanceHatches.size() == 1 && !mMufflerHatches.isEmpty(); } @Override @@ -347,4 +327,9 @@ public abstract class GT_MetaTileEntity_LargeBoiler extends GT_MetaTileEntity_Mu this.excessProjectedEU %= adjustedEUt; return adjustedBurnTime; } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 4, 0); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java index c9de809b58..072f54e4af 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java @@ -1,33 +1,63 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; - -public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_MultiBlockBase { - - private final int CASING_INDEX = 176; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; + +public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_EnhancedMultiBlockBase { + private static final int CASING_INDEX = 176; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"ccc", "cxc", "ccc"}, + {"c~c", "xPx", "cxc"}, + {"ccc", "cxc", "ccc"}, + })) + .addElement('P', ofBlock(GregTech_API.sBlockCasings8, 1)) + .addElement('c', ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) + )) + .addElement('x', ofChain( + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addOutputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addMaintenanceToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_LargeChemicalReactor::addEnergyInputToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCoilAdded, ofBlock(GregTech_API.sBlockCasings5, 0)), + onElementPass(GT_MetaTileEntity_LargeChemicalReactor::onCasingAdded, ofBlock(GregTech_API.sBlockCasings8, 0)) + )) + .build(); + + private int mCasingAmount; + private int mCoilAmount; public GT_MetaTileEntity_LargeChemicalReactor(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -43,7 +73,7 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu } @Override - public String[] getDescription() { + 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 Large Chemical Reactor") @@ -63,11 +93,7 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu .addOutputHatch("Any casing") .addStructureInfo("You can have multiple hatches/busses") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } @Override @@ -76,12 +102,12 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu if (aSide == aFacing) { if (aActive) return new ITexture[]{ casingTexturePages[1][48], - TextureFactory.of(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ casingTexturePages[1][48], - TextureFactory.of(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR), - TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_LARGE_CHEMICAL_REACTOR_GLOW).extFacing().glow().build()}; } return new ITexture[]{casingTexturePages[1][48]}; } @@ -162,56 +188,25 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu } @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; - int casingAmount = 0; - boolean hasHeatingCoil = false; - // x=width, z=depth, y=height - for (int x = -1 + xDir; x <= xDir + 1; x++) { - for (int z = -1 + zDir; z <= zDir + 1; z++) { - for (int y = -1; y <= 1; y++) { - if (x == 0 && y == 0 && z == 0) { - continue; - } - IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(x, y, z); - Block block = aBaseMetaTileEntity.getBlockOffset(x, y, z); - int centerCoords = 0; - if (x == xDir) { - centerCoords++; - } - if (y == 0) { - centerCoords++; - } - if (z == zDir) { - centerCoords++; - } - if (centerCoords == 3) { - if (block == GregTech_API.sBlockCasings8 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 1) { - continue; - } else { - return false; - } - } - if (centerCoords == 2 && block == GregTech_API.sBlockCasings5 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 0) { - hasHeatingCoil = true; - continue; - } - if (!addInputToMachineList(tileEntity, CASING_INDEX) && !addOutputToMachineList(tileEntity, CASING_INDEX) - && !addMaintenanceToMachineList(tileEntity, CASING_INDEX) - && !addEnergyInputToMachineList(tileEntity, CASING_INDEX)) { - if (block == GregTech_API.sBlockCasings8 && aBaseMetaTileEntity.getMetaIDOffset(x, y, z) == 0) { - casingAmount++; - } else { - return false; - } - } + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; + } - } - } + private void onCasingAdded() { + mCasingAmount++; + } - } - return casingAmount >= 8 && hasHeatingCoil && !mEnergyHatches.isEmpty() && !mMaintenanceHatches.isEmpty(); + private void onCoilAdded() { + mCoilAmount++; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + mCasingAmount = 0; + mCoilAmount = 0; + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) && + mCasingAmount >= 8 && mCoilAmount == 1 && + !mEnergyHatches.isEmpty() && mMaintenanceHatches.size() == 1; } @Override @@ -234,4 +229,8 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu return false; } + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 1, 0); + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 88a01dc310..214e0648c2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -33,7 +33,7 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_SS_ACTIVE5) : TextureFactory.of(LARGETURBINE_SS5) : casingTexturePages[0][58]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_SS_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(LARGETURBINE_SS5).extFacing().build() : casingTexturePages[0][58]}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index 6a0074539d..0d22271a34 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -38,7 +38,7 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_TI_ACTIVE5) : TextureFactory.of(LARGETURBINE_TI5) : casingTexturePages[0][59]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_TI_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(LARGETURBINE_TI5).extFacing().build() : casingTexturePages[0][59]}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index 094e7c20f9..efc3ecaea3 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -40,7 +40,7 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_TU_ACTIVE5) : TextureFactory.of(Textures.BlockIcons.LARGETURBINE_TU5) : casingTexturePages[0][60]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_TU_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(Textures.BlockIcons.LARGETURBINE_TU5).extFacing().build() : casingTexturePages[0][60]}; } @Override 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 49bffa1e7e..8990ad3324 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 @@ -41,7 +41,7 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.of(LARGETURBINE_ST_ACTIVE5) : TextureFactory.of(LARGETURBINE_ST5) : casingTexturePages[0][57]}; + return new ITexture[]{MACHINE_CASINGS[1][aColorIndex + 1], aFacing == aSide ? aActive ? TextureFactory.builder().addIcon(LARGETURBINE_ST_ACTIVE5).extFacing().build() : TextureFactory.builder().addIcon(LARGETURBINE_ST5).extFacing().build() : casingTexturePages[0][57]}; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index 58d9a24f80..20ef0fa6e7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -4,6 +4,7 @@ import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; +import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.gui.GT_GUIContainer_MultiMachine; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -175,7 +176,7 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu replaceDeprecatedCoils(aBaseMetaTileEntity); - setCoilLevel(null); + setCoilLevel(HeatingCoilLevel.None); if (!checkPiece(STRUCTURE_PIECE_MAIN, 1, 2, 0)) return false; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index 0a0088246b..e4f96db248 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -1,43 +1,73 @@ package gregtech.common.tileentities.machines.multi; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.enums.Materials; import gregtech.api.gui.GT_GUIContainer_MultiMachine; -import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -import org.apache.commons.lang3.mutable.MutableInt; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; -import java.util.BitSet; +import java.util.List; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofChain; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_OIL_CRACKER_GLOW; import static gregtech.api.enums.Textures.BlockIcons.casingTexturePages; +import static gregtech.api.util.GT_StructureUtility.ofCoil; +import static gregtech.api.util.GT_StructureUtility.ofHatchAdder; -public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBase { - private ForgeDirection orientation; - private int controllerX, controllerZ; - +public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMultiBlockBase { private static final byte CASING_INDEX = 49; + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition.builder() + .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][]{ + {"lcmcr", "lcmcr", "lcmcr"}, + {"lc~cr", "l---r", "lcmcr"}, + {"lcmcr", "lcmcr", "lcmcr"}, + })) + .addElement('c', ofCoil(GT_MetaTileEntity_OilCracker::setCoilLevel, GT_MetaTileEntity_OilCracker::getCoilLevel)) + .addElement('l', ofChain( + ofHatchAdder(GT_MetaTileEntity_OilCracker::addLeftHatchToMachineList, CASING_INDEX, 2), + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 2)) + )) + .addElement('r', ofChain( + ofHatchAdder(GT_MetaTileEntity_OilCracker::addRightHatchToMachineList, CASING_INDEX, 2), + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 3)) + )) + .addElement('m', ofChain( + ofHatchAdder(GT_MetaTileEntity_OilCracker::addMiddleInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addEnergyInputToMachineList, CASING_INDEX, 1), + ofHatchAdder(GT_MetaTileEntity_OilCracker::addMaintenanceToMachineList, CASING_INDEX, 1), + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) + )) + .build(); private HeatingCoilLevel heatLevel; + protected final List mMiddleInputHatches = new ArrayList<>(); + // 0 -> left, 1 -> right, any other -> not found + protected int mInputOnSide; + protected int mOutputOnSide; + protected int mCasingAmount; public GT_MetaTileEntity_OilCracker(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -48,7 +78,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa } @Override - public String[] getDescription() { + protected GT_Multiblock_Tooltip_Builder createTooltip() { final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); tt.addMachineType("Cracker") .addInfo("Controller block for the Oil Cracking Unit") @@ -68,19 +98,18 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa .addOutputHatch("Any left/right side casing") .addStructureInfo("Input/Output Hatches must be on opposite sides!") .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) return tt.getInformation(); - return tt.getStructureInformation(); + return tt; } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { if (aActive) return new ITexture[]{casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_OIL_CRACKER_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{casingTexturePages[0][CASING_INDEX], - TextureFactory.of(OVERLAY_FRONT_OIL_CRACKER), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_CRACKER_GLOW).extFacing().glow().build()}; } return new ITexture[]{casingTexturePages[0][CASING_INDEX]}; } @@ -129,141 +158,97 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa return false; } - private boolean coilsNotPresent(IGregTechTileEntity aBaseMetaTileEntity, int x , int y, int z) { - - Block coil = aBaseMetaTileEntity.getBlockOffset(x, y, z); - - if (!(coil instanceof IHeatingCoil)) - return true; - - IHeatingCoil heatingCoil = (IHeatingCoil) coil; - byte meta = aBaseMetaTileEntity.getMetaIDOffset(x, y, z); - HeatingCoilLevel heatLevel = heatingCoil.getCoilHeat(meta); - if (heatLevel == HeatingCoilLevel.None) - return true; - - if (this.heatLevel == HeatingCoilLevel.None) - this.heatLevel = heatLevel; - - return this.heatLevel != heatLevel; + @Override + public IStructureDefinition getStructureDefinition() { + return STRUCTURE_DEFINITION; } - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - this.heatLevel = HeatingCoilLevel.None; - this.orientation = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); - this.controllerX = aBaseMetaTileEntity.getXCoord(); - this.controllerZ = aBaseMetaTileEntity.getZCoord(); - int xDir = this.orientation.offsetX; - int zDir = this.orientation.offsetZ; - MutableInt amount = new MutableInt(0); - replaceDeprecatedCoils(aBaseMetaTileEntity); - BitSet flags = new BitSet(4); - - for (int depth = -1; depth < 2; depth++) - for (int height = -1; height < 2; height++) - for (int slice = -2; slice < 3; slice++) - if (xDir == 0) { - if (isStructureBroken(xDir, zDir, slice, height, depth, aBaseMetaTileEntity, amount, flags)) - return false; - } else { - if (isStructureBroken(xDir, zDir, depth, height, slice, aBaseMetaTileEntity, amount, flags)) - return false; - } - - if(checkInputOutputBroken(flags)) - return false; + public HeatingCoilLevel getCoilLevel() { + return heatLevel; + } - return amount.intValue() >= 18; + public void setCoilLevel(HeatingCoilLevel aCoilLevel) { + heatLevel = aCoilLevel; } - private boolean checkInputOutputBroken(BitSet flags){ - if (flags.get(0) && flags.get(2)) //input and output on side 1 - return true; - if (flags.get(1) && flags.get(3)) //input and output on side 2 - return true; - if (flags.get(1) && flags.get(2)) //input on both sides - return true; - return flags.get(2) && flags.get(3); //output on both sides + private boolean addMiddleInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = getRecipeMap(); + return mMiddleInputHatches.add(tHatch); + } + return false; } - private boolean isStructureBroken( - int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - MutableInt amount, - BitSet flags) { - if (b == 0 && c == 0 && (a == -1 || a == 0 || a == 1)) - return false; - if (a == 1 || a == -1) { - return coilsNotPresent(aBaseMetaTileEntity, xDir + a, b, c + zDir); + private boolean addLeftHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + if (mInputOnSide == 1) + return false; + mInputOnSide = 0; + mOutputOnSide = 1; + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = getRecipeMap(); + return mInputHatches.add(tHatch); } - else if (a == 2 || a == -2) { - return checkEndsBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount, flags); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + if (mOutputOnSide == 1) + return false; + mInputOnSide = 1; + mOutputOnSide = 0; + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatches.add(tHatch); } - else if (a == 0) - return checkMiddleBroken(xDir, zDir, a, b, c, aBaseMetaTileEntity, amount); - return false; } - private boolean checkEndsBroken( - int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - MutableInt amount, - BitSet flags - ){ - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir); - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - if (a == -2) - flags.set(0); //input on side 1 - else - flags.set(1); //input on side 2 - else if (addOutputToMachineList(tTileEntity, CASING_INDEX)) - if (a == -2) - flags.set(2); //output on side 1 - else - flags.set(3); //output on side 2 - else if (!addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - if (!addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4) - return true; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1) - return true; - amount.increment(); - } + private boolean addRightHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) return false; + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) return false; + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + if (mInputOnSide == 0) + return false; + mInputOnSide = 1; + mOutputOnSide = 0; + GT_MetaTileEntity_Hatch_Input tHatch = (GT_MetaTileEntity_Hatch_Input) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + tHatch.mRecipeMap = getRecipeMap(); + return mInputHatches.add(tHatch); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { + if (mOutputOnSide == 0) + return false; + mInputOnSide = 0; + mOutputOnSide = 1; + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) aMetaTileEntity; + tHatch.updateTexture(aBaseCasingIndex); + return mOutputHatches.add(tHatch); + } return false; } - private boolean checkMiddleBroken( int xDir, - int zDir, - int a, - int b, - int c, - IGregTechTileEntity aBaseMetaTileEntity, - MutableInt amount){ - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + c, b, a + zDir); - if (addMaintenanceToMachineList(tTileEntity, CASING_INDEX)) - return false; - if (addInputToMachineList(tTileEntity, CASING_INDEX)) - return false; - if (addEnergyInputToMachineList(tTileEntity, CASING_INDEX)) - return false; - if ((xDir + c) == 0 && b == 0 && (a + zDir) == 0) - return false; - if (aBaseMetaTileEntity.getBlockOffset(xDir + c, b, a + zDir) != GregTech_API.sBlockCasings4) - return true; - if (aBaseMetaTileEntity.getMetaIDOffset(xDir + c, b, a + zDir) != 1) - return true; - amount.increment(); - return false; + private void onCasingAdded() { + mCasingAmount++; + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + setCoilLevel(HeatingCoilLevel.None); + mCasingAmount = 0; + mMiddleInputHatches.clear(); + mInputOnSide = -1; + mOutputOnSide = -1; + replaceDeprecatedCoils(aBaseMetaTileEntity); + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 1, 0) && mInputOnSide != -1 && mOutputOnSide != -1 && mCasingAmount >= 18; } @Override @@ -330,22 +315,25 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_MultiBlockBa public ArrayList getStoredFluids() { ArrayList rList = new ArrayList<>(); for (GT_MetaTileEntity_Hatch_Input tHatch : mInputHatches) { + tHatch.mRecipeMap = getRecipeMap(); + if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { + rList.add(tHatch.getFillableStack()); + } + } + for (GT_MetaTileEntity_Hatch_Input tHatch : mMiddleInputHatches) { tHatch.mRecipeMap = getRecipeMap(); if (isValidMetaTileEntity(tHatch) && tHatch.getFillableStack() != null) { FluidStack tStack = tHatch.getFillableStack(); if (tStack.isFluidEqual(GT_ModHandler.getSteam(1000)) || tStack.isFluidEqual(Materials.Hydrogen.getGas(1000))) { - if (isHatchInMiddleRing(tHatch)) - rList.add(tStack); - } else if (!isHatchInMiddleRing(tHatch)) rList.add(tStack); + } } } return rList; } - private boolean isHatchInMiddleRing(GT_MetaTileEntity_Hatch_Input inputHatch){ - if (orientation == ForgeDirection.NORTH || orientation == ForgeDirection.SOUTH) - return inputHatch.getBaseMetaTileEntity().getXCoord() == this.controllerX; - return inputHatch.getBaseMetaTileEntity().getZCoord() == this.controllerZ; + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 2, 1, 0); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java index 73d8131fed..610c21e89b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill1.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OilDrill1 extends GT_MetaTileEntity_OilDrillBase { public GT_MetaTileEntity_OilDrill1(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_OilDrill1 extends GT_MetaTileEntity_OilDrillBase } @Override - public String[] getDescription() { - return getDescriptionInternal("I"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("I"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java index 9d36b340d3..eab1ebf614 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill2.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OilDrill2 extends GT_MetaTileEntity_OilDrillBase { public GT_MetaTileEntity_OilDrill2(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_OilDrill2 extends GT_MetaTileEntity_OilDrillBase } @Override - public String[] getDescription() { - return getDescriptionInternal("II"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("II"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java index 8ebc658406..738f60544b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilDrill3.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OilDrill3 extends GT_MetaTileEntity_OilDrillBase { public GT_MetaTileEntity_OilDrill3(int aID, String aName, String aNameRegional) { @@ -15,8 +16,8 @@ public class GT_MetaTileEntity_OilDrill3 extends GT_MetaTileEntity_OilDrillBase } @Override - public String[] getDescription() { - return getDescriptionInternal("III"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("III"); } @Override 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 44fb734534..554e5dfd63 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 @@ -19,7 +19,6 @@ import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.chunk.Chunk; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import org.lwjgl.input.Keyboard; import java.util.ArrayList; @@ -52,12 +51,12 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D if (aSide == aFacing) { if (aActive) return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_OIL_DRILL_ACTIVE), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_ACTIVE_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_ACTIVE).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_ACTIVE_GLOW).extFacing().glow().build()}; return new ITexture[]{ getCasingTextureForId(casingTextureIndex), - TextureFactory.of(OVERLAY_FRONT_OIL_DRILL), - TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_GLOW).glow().build()}; + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FRONT_OIL_DRILL_GLOW).extFacing().glow().build()}; } return new ITexture[]{getCasingTextureForId(casingTextureIndex)}; } @@ -77,7 +76,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D chunkRangeConfig = aNBT.getInteger("chunkRangeConfig"); } - protected String[] getDescriptionInternal(String tierSuffix) { + protected GT_Multiblock_Tooltip_Builder createTooltip(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); @@ -98,11 +97,7 @@ public abstract class GT_MetaTileEntity_OilDrillBase extends GT_MetaTileEntity_D .addInputBus("Mining Pipes or Circuits, optional, any base casing") .addOutputHatch("Any base casing") .toolTipFinisher("Gregtech"); - if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getStructureInformation(); - } else { - return tt.getInformation(); - } + return tt; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java index d23ce2edd0..ac3e40c5f5 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant1.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant1 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant1(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant1 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("I"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("I"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java index db7c4cd9e7..bf9c628911 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant2.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant2 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant2(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant2 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("II"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("II"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java index b7053a8ebd..411bbef3a7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant3.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant3 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant3(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant3 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("III"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("III"); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java index db86b963ca..d7daea327c 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OreDrillingPlant4.java @@ -4,6 +4,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Multiblock_Tooltip_Builder; public class GT_MetaTileEntity_OreDrillingPlant4 extends GT_MetaTileEntity_OreDrillingPlantBase { public GT_MetaTileEntity_OreDrillingPlant4(int aID, String aName, String aNameRegional) { @@ -17,8 +18,8 @@ public class GT_MetaTileEntity_OreDrillingPlant4 extends GT_MetaTileEntity_OreDr } @Override - public String[] getDescription() { - return getDescriptionInternal("IV"); + protected GT_Multiblock_Tooltip_Builder createTooltip() { + return createTooltip("IV"); } @Override 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 224f1de557..5b4444cec3 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 @@ -332,7 +332,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile protected abstract int getBaseProgressTime(); - protected String[] getDescriptionInternal(String tierSuffix) { + protected GT_Multiblock_Tooltip_Builder createTooltip(String tierSuffix) { String casings = getCasingBlockItem().get(0).getDisplayName(); final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); @@ -356,11 +356,7 @@ public abstract class GT_MetaTileEntity_OreDrillingPlantBase extends GT_MetaTile .addInputHatch("Drilling Fluid, any base casing") .addOutputBus("Any base casing") .toolTipFinisher("Gregtech"); - if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { - return tt.getInformation(); - } else { - return tt.getStructureInformation(); - } + return tt; } @Override -- cgit From 05c9015847ed770492152f93dee6beae45e61b4e Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 11 Jun 2021 03:09:49 +0800 Subject: Fix rebase derp Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 3 +-- .../tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 8e06207267..3a2fc8b50f 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -26,6 +26,7 @@ import gregtech.api.interfaces.tileentity.ITurnable; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.net.GT_Packet_ClientPreference; import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_ClientPreference; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_PlayedSound; import gregtech.api.util.GT_Recipe; @@ -46,7 +47,6 @@ import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; @@ -56,7 +56,6 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; 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 8916c9f42a..f1bfbe80f0 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 @@ -354,7 +354,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En } @Override - public IStructureDefinition getStructureDefinition() { + public final IStructureDefinition getStructureDefinition() { return STRUCTURE_DEFINITION; } -- cgit From 62f04c2893a66c4f80383da1a973fad4708171d4 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 16 Jun 2021 16:15:18 +0800 Subject: draw flipped textures & flipping markers Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- build.properties | 2 +- .../GT_MetaTileEntity_EnhancedMultiBlockBase.java | 4 +- src/main/java/gregtech/common/GT_Client.java | 66 +++++++++++++++--- .../gregtech/common/render/GT_IconFlipped.java | 80 ++++++++++++++++++++++ .../gregtech/common/render/GT_RenderedTexture.java | 20 ++++-- 5 files changed, 154 insertions(+), 18 deletions(-) create mode 100644 src/main/java/gregtech/common/render/GT_IconFlipped.java (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/build.properties b/build.properties index 8392f3c2a1..e4f67386b8 100644 --- a/build.properties +++ b/build.properties @@ -1,7 +1,7 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 gt.version=5.09.37.02 -structurelib.version=1.0.1 +structurelib.version=1.0.2 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 buildcraft.version=7.1.11 diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index e871146d4b..76dbca86b1 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -75,7 +75,9 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase 0) { - drawGrid(aEvent, true); + drawGrid(aEvent, true, false, true); return; } return; @@ -538,7 +586,7 @@ public class GT_Client extends GT_Proxy if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) - drawGrid(aEvent, true); + drawGrid(aEvent, true, false, aEvent.player.isSneaking()); } } diff --git a/src/main/java/gregtech/common/render/GT_IconFlipped.java b/src/main/java/gregtech/common/render/GT_IconFlipped.java new file mode 100644 index 0000000000..c3eee2900f --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_IconFlipped.java @@ -0,0 +1,80 @@ +package gregtech.common.render; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IIcon; + +@SideOnly(Side.CLIENT) +public class GT_IconFlipped implements IIcon { + private final IIcon baseIcon; + private final boolean flipU; + private final boolean flipV; + + public GT_IconFlipped(IIcon baseIcon, boolean flipU, boolean flipV) { + this.baseIcon = baseIcon; + this.flipU = flipU; + this.flipV = flipV; + } + + /** + * Returns the width of the icon, in pixels. + */ + public int getIconWidth() { + return this.baseIcon.getIconWidth(); + } + + /** + * Returns the height of the icon, in pixels. + */ + public int getIconHeight() { + return this.baseIcon.getIconHeight(); + } + + /** + * Returns the minimum U coordinate to use when rendering with this icon. + */ + public float getMinU() { + return this.flipU ? this.baseIcon.getMaxU() : this.baseIcon.getMinU(); + } + + /** + * Returns the maximum U coordinate to use when rendering with this icon. + */ + public float getMaxU() { + return this.flipU ? this.baseIcon.getMinU() : this.baseIcon.getMaxU(); + } + + /** + * Gets a U coordinate on the icon. 0 returns uMin and 16 returns uMax. Other arguments return in-between values. + */ + public float getInterpolatedU(double p_94214_1_) { + float f = this.getMaxU() - this.getMinU(); + return this.getMinU() + f * ((float) p_94214_1_ / 16.0F); + } + + /** + * Returns the minimum V coordinate to use when rendering with this icon. + */ + public float getMinV() { + return this.flipV ? this.baseIcon.getMaxV() : this.baseIcon.getMinV(); + } + + /** + * Returns the maximum V coordinate to use when rendering with this icon. + */ + public float getMaxV() { + return this.flipV ? this.baseIcon.getMinV() : this.baseIcon.getMaxV(); + } + + /** + * Gets a V coordinate on the icon. 0 returns vMin and 16 returns vMax. Other arguments return in-between values. + */ + public float getInterpolatedV(double p_94207_1_) { + float f = this.getMaxV() - this.getMinV(); + return this.getMinV() + f * ((float) p_94207_1_ / 16.0F); + } + + public String getIconName() { + return this.baseIcon.getIconName(); + } +} \ No newline at end of file diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java index 135ebf28c6..e35e2dbb6b 100644 --- a/src/main/java/gregtech/common/render/GT_RenderedTexture.java +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -2,6 +2,7 @@ package gregtech.common.render; import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; import gregtech.GT_Mod; import gregtech.api.interfaces.IColorModulationContainer; @@ -12,7 +13,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.util.LightingHelper; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.IconFlipped; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.init.Blocks; @@ -225,7 +225,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceYNeg(Blocks.air, x, y, z, new IconFlipped(icon, !stdOrient, false)); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceYNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped() ^ !stdOrient, aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateBottom = 0; } @@ -249,7 +250,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceYPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceYPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateTop = 0; } @@ -274,7 +276,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceZNeg(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceZNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateEast = 0; aRenderer.field_152631_f = false; } @@ -299,7 +302,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceZPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceZPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateWest = 0; } @@ -323,7 +327,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceXNeg(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceXNeg(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateNorth = 0; } @@ -348,7 +353,8 @@ class GT_RenderedTexture implements ITexture, IColorModulationContainer { break; } - aRenderer.renderFaceXPos(Blocks.air, x, y, z, icon); + Flip aFlip = extendedFacing.getFlip(); + aRenderer.renderFaceXPos(Blocks.air, x, y, z, useExtFacing ? new GT_IconFlipped(icon, aFlip.isHorizontallyFlipped(), aFlip.isVerticallyFliped()) : icon); aRenderer.uvRotateSouth = 0; aRenderer.field_152631_f = false; } -- cgit From bbaa5a3837c2e1999a09abdedf55293095000185 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 25 Jun 2021 23:21:38 +0800 Subject: make rotation marker a bit fancier, fix fusion texture Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 52 +++++++++++++++------- .../multi/GT_MetaTileEntity_FusionComputer1.java | 5 +-- .../multi/GT_MetaTileEntity_FusionComputer2.java | 4 +- .../multi/GT_MetaTileEntity_FusionComputer3.java | 5 +-- 4 files changed, 43 insertions(+), 23 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 3578af5756..5c2fc3c4d9 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -286,22 +286,24 @@ public class GT_Client extends GT_Proxy if (tAlignment != null) { ForgeDirection direction = tAlignment.getDirection(); if (direction.ordinal() == tSideHit) - drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER, aIsSneaking); + drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER, aIsSneaking, false); else if (direction.getOpposite().ordinal() == tSideHit) { for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) { - drawExtendedRotationMarker(t, aIsSneaking); + drawExtendedRotationMarker(t, aIsSneaking, true); } } else { - drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit * 6 + direction.ordinal()]], aIsSneaking); + drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit * 6 + direction.ordinal()]], aIsSneaking, true); } } } GL11.glPopMatrix(); // get back to player center } - private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking) { + private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking, boolean small) { if (sneaking) drawFlipMarker(transform); + else if (small) + drawRotationMarkerSmall(transform); else drawRotationMarker(transform); } @@ -311,17 +313,37 @@ public class GT_Client extends GT_Proxy transform.glApply(); Tessellator t = Tessellator.instance; t.startDrawing(GL11.GL_LINE_LOOP); - t.addVertex(-0.4d, 0d, -0.4d); - t.addVertex(-0.4d, 0d, 0.4d); - t.addVertex(0.4d, 0d, 0.4d); - t.addVertex(0.4d, 0d, -0.325d); - t.addVertex(0.45d, 0d, -0.325d); - t.addVertex(0.35d, 0d, -0.425d); - t.addVertex(0.25d, 0d, -0.325d); - t.addVertex(0.3d, 0d, -0.325d); - t.addVertex(0.3d, 0d, 0.3d); - t.addVertex(-0.3d, 0d, 0.3d); - t.addVertex(-0.3d, 0d, -0.4d); + t.addVertex(-0.3000d, 0d, -0.3000d); + t.addVertex(-0.3000d, 0d, +0.3000d); + t.addVertex(+0.3000d, 0d, +0.3000d); + t.addVertex(+0.3000d, 0d, -0.1750d); + t.addVertex(+0.3600d, 0d, -0.1750d); + t.addVertex(+0.2500d, 0d, -0.3000d); + t.addVertex(+0.1400d, 0d, -0.1750d); + t.addVertex(+0.2000d, 0d, -0.1750d); + t.addVertex(+0.2000d, 0d, +0.2000d); + t.addVertex(-0.2000d, 0d, +0.2000d); + t.addVertex(-0.2000d, 0d, -0.3000d); + t.draw(); + GL11.glPopMatrix(); + } + + private static void drawRotationMarkerSmall(Transformation transform) { + GL11.glPushMatrix(); + transform.glApply(); + Tessellator t = Tessellator.instance; + t.startDrawing(GL11.GL_LINE_LOOP); + t.addVertex(-0.3500d, 0d, -0.3500d); + t.addVertex(-0.3500d, 0d, +0.3500d); + t.addVertex(+0.3500d, 0d, +0.3500d); + t.addVertex(+0.3500d, 0d, -0.2000d); + t.addVertex(+0.4500d, 0d, -0.2000d); + t.addVertex(+0.3000d, 0d, -0.3500d); + t.addVertex(+0.1500d, 0d, -0.2000d); + t.addVertex(+0.2500d, 0d, -0.2000d); + t.addVertex(+0.2500d, 0d, +0.2500d); + t.addVertex(-0.2500d, 0d, +0.2500d); + t.addVertex(-0.2500d, 0d, -0.3500d); t.draw(); GL11.glPopMatrix(); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java index fd55bf715b..2901a9e4f1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer1.java @@ -7,7 +7,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; -import org.lwjgl.input.Keyboard; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION1; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION1_GLOW; @@ -15,8 +14,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION1_GLOW; public class GT_MetaTileEntity_FusionComputer1 extends GT_MetaTileEntity_FusionComputer { private static final ITexture textureOverlay = TextureFactory.of( - TextureFactory.of(OVERLAY_FUSION1), - TextureFactory.builder().addIcon(OVERLAY_FUSION1_GLOW).glow().build()); + TextureFactory.builder().addIcon(OVERLAY_FUSION1).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FUSION1_GLOW).extFacing().glow().build()); public GT_MetaTileEntity_FusionComputer1(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 6); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java index 890b43cc7a..6cefdc6812 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer2.java @@ -14,8 +14,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION2_GLOW; public class GT_MetaTileEntity_FusionComputer2 extends GT_MetaTileEntity_FusionComputer { private static final ITexture textureOverlay = TextureFactory.of( - TextureFactory.of(OVERLAY_FUSION2), - TextureFactory.builder().addIcon(OVERLAY_FUSION2_GLOW).glow().build()); + TextureFactory.builder().addIcon(OVERLAY_FUSION2).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FUSION2_GLOW).extFacing().glow().build()); public GT_MetaTileEntity_FusionComputer2(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 6); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java index 0a3bc89d20..b879c7923b 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_FusionComputer3.java @@ -7,7 +7,6 @@ import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import net.minecraft.block.Block; -import org.lwjgl.input.Keyboard; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION3; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION3_GLOW; @@ -15,8 +14,8 @@ import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FUSION3_GLOW; public class GT_MetaTileEntity_FusionComputer3 extends GT_MetaTileEntity_FusionComputer { private static final ITexture textureOverlay = TextureFactory.of( - TextureFactory.of(OVERLAY_FUSION3), - TextureFactory.builder().addIcon(OVERLAY_FUSION3_GLOW).glow().build()); + TextureFactory.builder().addIcon(OVERLAY_FUSION3).extFacing().build(), + TextureFactory.builder().addIcon(OVERLAY_FUSION3_GLOW).extFacing().glow().build()); public GT_MetaTileEntity_FusionComputer3(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional, 6); -- cgit From 580a6a0c09844941fc74ed4cc867a78ae70cb257 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sat, 26 Jun 2021 21:11:47 +0800 Subject: make rotation marker a lot more fancier Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 125 ++++++++++++++------------- 1 file changed, 65 insertions(+), 60 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 5c2fc3c4d9..674719eab5 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -46,6 +46,7 @@ import gregtech.common.render.GT_Renderer_Entity_Arrow; import ic2.api.tile.IWrenchable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; @@ -69,6 +70,8 @@ import java.util.List; import java.util.Map; import java.util.Scanner; +import static org.lwjgl.opengl.GL11.GL_LINE_LOOP; + // Referenced classes of package gregtech.common: // GT_Proxy @@ -110,6 +113,8 @@ public class GT_Client extends GT_Proxy new Scale(0.25).with(new Translation(0.375, 0, -0.375)).compile(), new Scale(0.25).with(new Translation(-0.375, 0, -0.375)).compile(), }; + private static int rotationMarkerDisplayList; + private static boolean rotationMarkerDisplayListCompiled = false; static { ROTATABLE_VANILLA_BLOCKS = Arrays.asList(Blocks.piston, Blocks.sticky_piston, Blocks.furnace, Blocks.lit_furnace, Blocks.dropper, Blocks.dispenser, Blocks.chest, Blocks.trapped_chest, Blocks.ender_chest, Blocks.hopper, @@ -148,6 +153,8 @@ public class GT_Client extends GT_Proxy private String mMessage; private GT_ClientPreference mPreference; private boolean mFirstTick = false; + public static final int ROTATION_MARKER_RESOLUTION = 120; + public GT_Client() { mCapeRenderer = new GT_CapeRenderer(mCapeList); mAnimationTick = 0L; @@ -222,7 +229,7 @@ public class GT_Client extends GT_Proxy tConnections = ((BaseMetaPipeEntity) tTile).mConnections; } - if (tConnections>0) { + if (tConnections > 0) { for (byte i = 0; i < 6; i++) { if ((tConnections & (1 << i)) != 0) { switch (GRID_SWITCH_ARR[aEvent.target.sideHit][i]) { @@ -302,50 +309,36 @@ public class GT_Client extends GT_Proxy private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking, boolean small) { if (sneaking) drawFlipMarker(transform); - else if (small) - drawRotationMarkerSmall(transform); else drawRotationMarker(transform); } private static void drawRotationMarker(Transformation transform) { + if (!rotationMarkerDisplayListCompiled) { + rotationMarkerDisplayList = GLAllocation.generateDisplayLists(1); + compileRotationMarkerDisplayList(rotationMarkerDisplayList); + rotationMarkerDisplayListCompiled = true; + } GL11.glPushMatrix(); transform.glApply(); - Tessellator t = Tessellator.instance; - t.startDrawing(GL11.GL_LINE_LOOP); - t.addVertex(-0.3000d, 0d, -0.3000d); - t.addVertex(-0.3000d, 0d, +0.3000d); - t.addVertex(+0.3000d, 0d, +0.3000d); - t.addVertex(+0.3000d, 0d, -0.1750d); - t.addVertex(+0.3600d, 0d, -0.1750d); - t.addVertex(+0.2500d, 0d, -0.3000d); - t.addVertex(+0.1400d, 0d, -0.1750d); - t.addVertex(+0.2000d, 0d, -0.1750d); - t.addVertex(+0.2000d, 0d, +0.2000d); - t.addVertex(-0.2000d, 0d, +0.2000d); - t.addVertex(-0.2000d, 0d, -0.3000d); - t.draw(); + GL11.glCallList(rotationMarkerDisplayList); GL11.glPopMatrix(); } - private static void drawRotationMarkerSmall(Transformation transform) { - GL11.glPushMatrix(); - transform.glApply(); - Tessellator t = Tessellator.instance; - t.startDrawing(GL11.GL_LINE_LOOP); - t.addVertex(-0.3500d, 0d, -0.3500d); - t.addVertex(-0.3500d, 0d, +0.3500d); - t.addVertex(+0.3500d, 0d, +0.3500d); - t.addVertex(+0.3500d, 0d, -0.2000d); - t.addVertex(+0.4500d, 0d, -0.2000d); - t.addVertex(+0.3000d, 0d, -0.3500d); - t.addVertex(+0.1500d, 0d, -0.2000d); - t.addVertex(+0.2500d, 0d, -0.2000d); - t.addVertex(+0.2500d, 0d, +0.2500d); - t.addVertex(-0.2500d, 0d, +0.2500d); - t.addVertex(-0.2500d, 0d, -0.3500d); - t.draw(); - GL11.glPopMatrix(); + private static void compileRotationMarkerDisplayList(int displayList) { + GL11.glNewList(displayList, GL11.GL_COMPILE); + GL11.glBegin(GL_LINE_LOOP); + for (int i = 0; i <= ROTATION_MARKER_RESOLUTION; i++) { + GL11.glVertex3d(Math.cos(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.4, 0, Math.sin(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.4); + } + for (int i = ROTATION_MARKER_RESOLUTION; i >=0; i--) { + GL11.glVertex3d(Math.cos(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.24, 0, Math.sin(i * Math.PI * 1.75 / ROTATION_MARKER_RESOLUTION) * 0.24); + } + GL11.glVertex3d(0.141114561800, 0, 0); + GL11.glVertex3d(0.32, 0, -0.178885438199); + GL11.glVertex3d(0.498885438199, 0, 0); + GL11.glEnd(); + GL11.glEndList(); } private static void drawFlipMarker(Transformation transform) { @@ -469,7 +462,9 @@ public class GT_Client extends GT_Proxy } i++; } while (true); - } catch (Throwable e) {e.printStackTrace(GT_Log.err);} + } catch (Throwable e) { + e.printStackTrace(GT_Log.err); + } // super.onPostLoad(); @@ -574,8 +569,21 @@ public class GT_Client extends GT_Proxy Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) - { + if (aBlock == Blocks.glass) { + GL11.glPushMatrix(); + GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks)); + GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F); + int tSideHit = aEvent.target.sideHit; + Rotation.sideRotations[tSideHit].glApply(); + // draw grid + GL11.glTranslated(0.0D, -0.501D, 0.0D); + GL11.glLineWidth(2.0F); + GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F); + drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); + GL11.glPopMatrix(); + } + + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) { if (aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable) drawGrid(aEvent, false, true, aEvent.player.isSneaking()); return; @@ -585,17 +593,15 @@ public class GT_Client extends GT_Proxy 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)) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) drawGrid(aEvent, false, false, aEvent.player.isSneaking()); return; } if ((aEvent.currentItem == null && aEvent.player.isSneaking()) || - GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList) || - GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)) - { + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList) || + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) for (byte i = 0; i < 6; i++) if (((ICoverable) aTileEntity).getCoverIDAtSide(i) > 0) { @@ -605,8 +611,7 @@ public class GT_Client extends GT_Proxy return; } - if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) - { + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet())) { if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) drawGrid(aEvent, true, false, aEvent.player.isSneaking()); } @@ -776,13 +781,12 @@ public class GT_Client extends GT_Proxy tString = (new StringBuilder()).append(tString).append("wherearewenow").toString(); break; } - if (tString.startsWith("streaming.")){ + if (tString.startsWith("streaming.")) { new WorldSpawnedEventBuilder.RecordEffectEventBuilder() .setIdentifier(tString.substring(10)) .setPosition(aX, aY, aZ) .run(); - } - else{ + } else { new WorldSpawnedEventBuilder.SoundEventBuilder() .setVolume(3f) .setPitch(tString.startsWith("note.") ? (float) Math.pow(2D, (double) (aStack.stackSize - 13) / 12D) : 1.0F) @@ -792,13 +796,14 @@ public class GT_Client extends GT_Proxy } } - public static int hideValue=0; + public static int hideValue = 0; - /**

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

+ /** + *

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; + public static int changeDetected = 0; private static int shouldHeldItemHideThings() { try { @@ -815,17 +820,17 @@ public class GT_Client extends GT_Proxy } } if (GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWrenchList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList) - || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList) - || GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { - hide |= 0x2; + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sScrewdriverList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sHardHammerList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSoftHammerList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList) + || GT_Utility.isStackInList(tCurrentItem, GregTech_API.sCrowbarList) + || GregTech_API.sCovers.containsKey(new GT_ItemStack(tCurrentItem))) { + hide |= 0x2; } return hide; - }catch(Exception e){ + } catch (Exception e) { return 0; } } -- cgit From 8f5a4afac46140c9b93a0161feccd0b5a2eca07e Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Sun, 27 Jun 2021 01:15:34 +0800 Subject: remove debug code Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 674719eab5..eeaf5a96ff 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -569,21 +569,8 @@ public class GT_Client extends GT_Proxy Block aBlock = aEvent.player.worldObj.getBlock(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - if (aBlock == Blocks.glass) { - GL11.glPushMatrix(); - GL11.glTranslated(-(aEvent.player.lastTickPosX + (aEvent.player.posX - aEvent.player.lastTickPosX) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosY + (aEvent.player.posY - aEvent.player.lastTickPosY) * (double) aEvent.partialTicks), -(aEvent.player.lastTickPosZ + (aEvent.player.posZ - aEvent.player.lastTickPosZ) * (double) aEvent.partialTicks)); - GL11.glTranslated((float) aEvent.target.blockX + 0.5F, (float) aEvent.target.blockY + 0.5F, (float) aEvent.target.blockZ + 0.5F); - int tSideHit = aEvent.target.sideHit; - Rotation.sideRotations[tSideHit].glApply(); - // draw grid - GL11.glTranslated(0.0D, -0.501D, 0.0D); - GL11.glLineWidth(2.0F); - GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F); - drawRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER); - GL11.glPopMatrix(); - } - - if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) { + if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) + { if (aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable) drawGrid(aEvent, false, true, aEvent.player.isSneaking()); return; -- cgit From 112f7809ecaa0ccb5e8060b70d7e437086ffa735 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 16 Jul 2021 19:49:22 +0800 Subject: Minor clean up in GT_Client ARR is taboo :kekw: Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- src/main/java/gregtech/common/GT_Client.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/main/java/gregtech/common/GT_Client.java') diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index eeaf5a96ff..55efd20920 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -82,7 +82,7 @@ public class GT_Client extends GT_Proxy public static final String GT_CAPE_LIST_URL = "http://gregtech.overminddl1.com/com/gregoriust/gregtech/supporterlist.txt"; private static final List ROTATABLE_VANILLA_BLOCKS; - private static final int[][] GRID_SWITCH_ARR = new int[][]{ + private static final int[][] GRID_SWITCH_TABLE = new int[][]{ {0, 5, 3, 1, 2, 4}, {5, 0, 1, 3, 2, 4}, {1, 3, 0, 5, 2, 4}, @@ -149,8 +149,6 @@ public class GT_Client extends GT_Proxy private int mLastUpdatedBlockX; private int mLastUpdatedBlockY; private int mLastUpdatedBlockZ; - private boolean isFirstClientPlayerTick; - private String mMessage; private GT_ClientPreference mPreference; private boolean mFirstTick = false; public static final int ROTATION_MARKER_RESOLUTION = 120; @@ -159,8 +157,6 @@ public class GT_Client extends GT_Proxy mCapeRenderer = new GT_CapeRenderer(mCapeList); mAnimationTick = 0L; mAnimationDirection = false; - isFirstClientPlayerTick = true; - mMessage = ""; mPosR = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, Materials.Pyrotheum, Materials.Sunnarium, Materials.Glowstone, Materials.Thaumium, Materials.InfusedVis, Materials.InfusedAir, Materials.InfusedFire, Materials.FierySteel, Materials.Firestone); mPosG = Arrays.asList(Materials.Enderium, Materials.Vinteum, Materials.Uranium235, Materials.InfusedGold, Materials.Plutonium241, Materials.NaquadahEnriched, Materials.Naquadria, Materials.InfusedOrder, Materials.Force, @@ -232,7 +228,7 @@ public class GT_Client extends GT_Proxy if (tConnections > 0) { for (byte i = 0; i < 6; i++) { if ((tConnections & (1 << i)) != 0) { - switch (GRID_SWITCH_ARR[aEvent.target.sideHit][i]) { + switch (GRID_SWITCH_TABLE[aEvent.target.sideHit][i]) { case 0: GL11.glVertex3d(+.25D, .0D, +.25D); GL11.glVertex3d(-.25D, .0D, -.25D); -- cgit