diff options
Diffstat (limited to 'src/main/java/gregtech/common/GT_Client.java')
-rw-r--r-- | src/main/java/gregtech/common/GT_Client.java | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 9b7bdbfed6..bda1852c31 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -130,7 +130,7 @@ public class GT_Client extends GT_Proxy }); } - private static void drawGrid(DrawBlockHighlightEvent aEvent) { + private static void drawGrid(DrawBlockHighlightEvent aEvent, boolean showCoverConnections) { 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); @@ -148,7 +148,20 @@ public class GT_Client extends GT_Proxy GL11.glVertex3d(-.25D, .0D, -.50D); GL11.glVertex3d(-.25D, .0D, +.50D); TileEntity tTile = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); - if (tTile instanceof BaseMetaPipeEntity) { + + byte tConnections = 0; + if (tTile instanceof ICoverable){ + if (showCoverConnections) { + for (byte i = 0; i < 6; i++) { + if ( ((ICoverable) tTile).getCoverIDAtSide(i) > 0) + tConnections = (byte)(tConnections + (1 << i)); + } + } + 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}, @@ -156,8 +169,7 @@ public class GT_Client extends GT_Proxy {3, 1, 5, 0, 2, 4}, {4, 2, 3, 1, 0, 5}, {2, 4, 3, 1, 5, 0}, - }; - int tConnections = ((BaseMetaPipeEntity) tTile).mConnections; + }; for (byte i = 0; i < 6; i++) { if ((tConnections & (1 << i)) != 0) { switch (GridSwitchArr[aEvent.target.sideHit][i]) { @@ -441,26 +453,50 @@ public class GT_Client extends GT_Proxy @SubscribeEvent public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) { + TileEntity aTileEntity = aEvent.player.worldObj.getTileEntity(aEvent.target.blockX, aEvent.target.blockY, aEvent.target.blockZ); + if (aTileEntity == null) + return; + try { + Class.forName("codechicken.lib.vec.Rotation");//Whats this do, need to check every frame? + } catch (Throwable e) { + if (GT_Values.D1) { + e.printStackTrace(GT_Log.err); + } + return; + } + if (GT_Utility.isStackValid(aEvent.currentItem)) { 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); - try { - Class.forName("codechicken.lib.vec.Rotation"); - if ((aTileEntity instanceof BaseMetaPipeEntity) && ((BaseMetaPipeEntity) aTileEntity).shouldDisplayWrenchGrid(aEvent.currentItem, (byte) aEvent.target.sideHit)) { - drawGrid(aEvent); - return; - } - if ((aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable) && GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) { - drawGrid(aEvent); - return; - } - if (aTileEntity instanceof BaseTileEntity && (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList) || GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList))) { - drawGrid(aEvent); - return; - } - } catch (Throwable e) { - if (GT_Values.D1) { - e.printStackTrace(GT_Log.err); + if (((aTileEntity instanceof BaseMetaPipeEntity)) && (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0) && ( + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet()) || + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCrowbarList) || + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList) || + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sScrewdriverList)|| + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList) )) + { + drawGrid(aEvent, false); + return; + } + if ((aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable) && + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWrenchList)) + { + drawGrid(aEvent, false); + return; + } + if (aTileEntity instanceof BaseTileEntity && ( + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList) || + GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList))) + { + drawGrid(aEvent, false); + return; + } + } else if (aEvent.currentItem == null && aEvent.player.isSneaking()) { + if (aTileEntity instanceof ICoverable && ((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0 ){ + for (byte i = 0; i < 6; i++) { + if(((ICoverable) aTileEntity).getCoverIDAtSide(i) > 0) { + drawGrid(aEvent, true); + return; + } } } } |