From d47a698e19bf3682efa7ddac8b12bd1a44cd2b71 Mon Sep 17 00:00:00 2001 From: Technus Date: Sun, 27 Nov 2016 12:34:02 +0100 Subject: [PATCH] Add pipe/wire hiding when holding soldering iron. --- .../GT_MetaPipeEntity_Cable.java | 2 + .../GT_MetaPipeEntity_Fluid.java | 2 + .../GT_MetaPipeEntity_Item.java | 2 + src/main/java/gregtech/common/GT_Client.java | 51 ++++++++----------- 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index b4c6b3f5..ea8b629b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -17,6 +17,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Client; import ic2.api.energy.tile.IEnergySink; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -300,6 +301,7 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public float getThickNess() { + if(GT_Client.hideValue==1) return 0.125F; return mThickNess; } diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java index 3abc45ac..22abec36 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Fluid.java @@ -12,6 +12,7 @@ import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.objects.XSTR; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Client; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; @@ -382,6 +383,7 @@ public class GT_MetaPipeEntity_Fluid extends MetaPipeEntity { @Override public float getThickNess() { + if(GT_Client.hideValue==1) return 0.125F; return mThickNess; } } \ No newline at end of file diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java index eb8e3eeb..966e4bcc 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Item.java @@ -10,6 +10,7 @@ import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.MetaPipeEntity; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Utility; +import gregtech.common.GT_Client; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; @@ -313,6 +314,7 @@ public class GT_MetaPipeEntity_Item extends MetaPipeEntity implements IMetaTileE @Override public float getThickNess() { + if(GT_Client.hideValue==1) return 0.125F; return mThickNess; } } \ No newline at end of file diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java index 05563ab8..112f8d2f 100644 --- a/src/main/java/gregtech/common/GT_Client.java +++ b/src/main/java/gregtech/common/GT_Client.java @@ -36,6 +36,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraftforge.client.event.DrawBlockHighlightEvent; +import net.minecraftforge.oredict.OreDictionary; import org.lwjgl.opengl.GL11; import java.net.URL; @@ -370,7 +371,7 @@ public class GT_Client extends GT_Proxy @SubscribeEvent public void onClientTickEvent(cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent aEvent) { if (aEvent.phase == cpw.mods.fml.common.gameevent.TickEvent.Phase.END) { - //hideValue=shouldHeldItemHideThings(); + hideValue=shouldHeldItemHideThings(); mAnimationTick++; if (mAnimationTick % 50L == 0L) {mAnimationDirection = !mAnimationDirection;} @@ -538,33 +539,25 @@ public class GT_Client extends GT_Proxy aWorld.playSound(aX, aY, aZ, tString, 3F, tString.startsWith("note.") ? (float) Math.pow(2D, (double) (aStack.stackSize - 13) / 12D) : 1.0F, false); } - //public static int hideValue=0; + public static int hideValue=0; - //private static int shouldHeldItemHideThings() { - // try { - // EntityPlayer player = Minecraft.getMinecraft().thePlayer; - // if (player == null) return 0; - // ItemStack held = player.getCurrentEquippedItem(); - // if (held == null) return 0; - // int[] ids = OreDictionary.getOreIDs(held); - // int hide = 0; - // for (int i : ids) { - // if (OreDictionary.getOreName(i).equals("craftingToolWrench")) { - // hide |= 0x1; - // continue; - // } - // if (OreDictionary.getOreName(i).equals("craftingToolWireCutter")) { - // hide |= 0x2; - // continue; - // } - // if (OreDictionary.getOreName(i).equals("craftingToolSolderingIron")) { - // hide |= 0x3; - // continue; - // } - // } - // return hide; - // }catch(Exception e){ - // return 0; - // } - //} + private static int shouldHeldItemHideThings() { + try { + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if (player == null) return 0; + ItemStack held = player.getCurrentEquippedItem(); + if (held == null) return 0; + int[] ids = OreDictionary.getOreIDs(held); + int hide = 0; + for (int i : ids) { + if (OreDictionary.getOreName(i).equals("craftingToolSolderingIron")) { + hide |= 0x1; + break; + } + } + return hide; + }catch(Exception e){ + return 0; + } + } }