aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/GT_Client.java
diff options
context:
space:
mode:
authorDreamMasterXXL <dream-master@gmx.net>2020-05-10 16:21:22 +0200
committerDreamMasterXXL <dream-master@gmx.net>2020-05-10 16:21:22 +0200
commit920e2eb543ce7fa413bee19c0626d3d89f9542fb (patch)
treef0175359b32bed488afd19373af3741c415e6e2f /src/main/java/gregtech/common/GT_Client.java
parent33ec8e37624aa9403d130ecbe4817c45c3a76a4f (diff)
parent87321491668b5b07801eaafb22390051c97fd9d8 (diff)
downloadGT5-Unofficial-920e2eb543ce7fa413bee19c0626d3d89f9542fb.tar.gz
GT5-Unofficial-920e2eb543ce7fa413bee19c0626d3d89f9542fb.tar.bz2
GT5-Unofficial-920e2eb543ce7fa413bee19c0626d3d89f9542fb.zip
Merge branch 'experimental' into HEE-Bees
Diffstat (limited to 'src/main/java/gregtech/common/GT_Client.java')
-rw-r--r--src/main/java/gregtech/common/GT_Client.java98
1 files changed, 72 insertions, 26 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java
index 978afd9e06..51f5e30c28 100644
--- a/src/main/java/gregtech/common/GT_Client.java
+++ b/src/main/java/gregtech/common/GT_Client.java
@@ -130,7 +130,21 @@ public class GT_Client extends GT_Proxy
});
}
- private static void drawGrid(DrawBlockHighlightEvent aEvent) {
+
+ private static boolean checkedForChicken = false;
+ private static void drawGrid(DrawBlockHighlightEvent aEvent, boolean showCoverConnections) {
+ if (!checkedForChicken) {
+ try {
+ Class.forName("codechicken.lib.vec.Rotation");
+ } catch (Throwable e) {
+ if (GT_Values.D1) {
+ e.printStackTrace(GT_Log.err);
+ }
+ return;
+ }
+ checkedForChicken = true;
+ }
+
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 +162,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 +183,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]) {
@@ -217,6 +243,10 @@ public class GT_Client extends GT_Proxy
GL11.glPopMatrix();
}
+ private static void drawGrid(DrawBlockHighlightEvent aEvent) {
+ drawGrid(aEvent, false);
+ }
+
//TODO less bad
//@SubscribeEvent
//public void manipulateDensity(EntityViewRenderEvent.FogDensity event) {
@@ -441,28 +471,44 @@ public class GT_Client extends GT_Proxy
@SubscribeEvent
public void onDrawBlockHighlight(DrawBlockHighlightEvent aEvent) {
- 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)) && (((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);
- 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);
- }
- }
+ 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 (aTileEntity instanceof ITurnable || ROTATABLE_VANILLA_BLOCKS.contains(aBlock) || aTileEntity instanceof IWrenchable)
+ drawGrid(aEvent, false);
+ return;
+ }
+
+ if (!(aTileEntity instanceof ICoverable))
+ return;
+
+ if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sWireCutterList) ||
+ GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sSolderingToolList) )
+ {
+ if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0)
+ drawGrid(aEvent, false);
+ return;
+ }
+
+ if ((aEvent.currentItem == null && aEvent.player.isSneaking()) ||
+ 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) {
+ drawGrid(aEvent, true);
+ return;
+ }
+ return;
+ }
+
+ if (GT_Utility.isStackInList(aEvent.currentItem, GregTech_API.sCovers.keySet()))
+ {
+ if (((ICoverable) aTileEntity).getCoverIDAtSide((byte) aEvent.target.sideHit) == 0)
+ drawGrid(aEvent, true);
}
}