diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2023-08-27 02:48:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-27 02:48:43 +0800 |
commit | c18e91469b33a60df690cde8cbace1b7c38bbee2 (patch) | |
tree | 59388304f983fa0343774199ec9f2d2d2b531b4a | |
parent | b318af16da91dd479644923dfd34f0378ae240c5 (diff) | |
download | GT5-Unofficial-c18e91469b33a60df690cde8cbace1b7c38bbee2.tar.gz GT5-Unofficial-c18e91469b33a60df690cde8cbace1b7c38bbee2.tar.bz2 GT5-Unofficial-c18e91469b33a60df690cde8cbace1b7c38bbee2.zip |
change way to fix zfighting (#2253)
-rw-r--r-- | src/main/java/gregtech/common/GT_Client.java | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 6c44a1fcae..0378e7f127 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -30,6 +30,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; @@ -301,24 +302,19 @@ public class GT_Client extends GT_Proxy implements Runnable { checkedForChicken = true; } - GL11.glDisable(GL11.GL_DEPTH_TEST); 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); - final int tSideHit = aEvent.target.sideHit; + MovingObjectPosition target = aEvent.target; + EntityPlayer player = aEvent.player; + double camX = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) aEvent.partialTicks; + double camY = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) aEvent.partialTicks; + double camZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) aEvent.partialTicks; + GL11.glTranslated(target.blockX - (int) camX, target.blockY - (int) camY, target.blockZ - (int) camZ); + GL11.glTranslated(0.5D - (camX - (int) camX), 0.5D - (camY - (int) camY), 0.5D - (camZ - (int) camZ)); + final int tSideHit = target.sideHit; Rotation.sideRotations[tSideHit].glApply(); // draw grid - GL11.glTranslated(0.0D, -0.501D, 0.0D); - GL11.glLineWidth(2.0F); + GL11.glTranslated(0.0D, -0.502D, 0.0D); + GL11.glLineWidth(2.5F); GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.5F); GL11.glBegin(GL11.GL_LINES); GL11.glVertex3d(+.50D, .0D, -.25D); @@ -329,8 +325,7 @@ public class GT_Client extends GT_Proxy implements Runnable { GL11.glVertex3d(+.25D, .0D, +.50D); GL11.glVertex3d(-.25D, .0D, -.50D); GL11.glVertex3d(-.25D, .0D, +.50D); - final TileEntity tTile = aEvent.player.worldObj - .getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); + final TileEntity tTile = player.worldObj.getTileEntity(target.blockX, target.blockY, target.blockZ); // draw connection indicators int tConnections = 0; @@ -345,7 +340,7 @@ public class GT_Client extends GT_Proxy implements Runnable { if (tConnections != 0) { for (ForgeDirection tSide : ForgeDirection.VALID_DIRECTIONS) { if ((tConnections & tSide.flag) != 0) { - switch (GRID_SWITCH_TABLE[aEvent.target.sideHit][tSide.ordinal()]) { + switch (GRID_SWITCH_TABLE[target.sideHit][tSide.ordinal()]) { case 0 -> { GL11.glVertex3d(+.25D, .0D, +.25D); GL11.glVertex3d(-.25D, .0D, -.25D); @@ -421,7 +416,6 @@ public class GT_Client extends GT_Proxy implements Runnable { } } GL11.glPopMatrix(); // get back to player center - GL11.glEnable(GL11.GL_DEPTH_TEST); } private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking, boolean small) { |