From c45d7f1b714b7a900ba30e22d2302da22e7438fd Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 2 Aug 2014 23:53:34 -0500 Subject: [PATCH] Added Network Tool Facade Transparency Option. --- client/ClientHelper.java | 31 ++++++++++++ .../gui/implementations/GuiNetworkTool.java | 38 +++++++++++++++ client/render/RenderBlocksWorkaround.java | 5 +- .../implementations/ContainerNetworkTool.java | 20 ++++++++ core/CommonHelper.java | 8 ++-- core/api/ApiPart.java | 8 ++++ core/localization/GuiText.java | 24 ++++++++-- core/sync/packets/PacketPartPlacement.java | 3 ++ core/sync/packets/PacketValueConfig.java | 8 ++++ facade/FacadePart.java | 32 +++++++++++-- fmp/CableBusPart.java | 4 +- hooks/TickHandler.java | 11 +++++ parts/CableBusContainer.java | 36 ++++++++------ parts/PartPlacement.java | 16 +++++-- server/ServerHelper.java | 47 +++++++++++++++++++ 15 files changed, 257 insertions(+), 34 deletions(-) diff --git a/client/ClientHelper.java b/client/ClientHelper.java index bb1ba398..6029c5cb 100644 --- a/client/ClientHelper.java +++ b/client/ClientHelper.java @@ -33,6 +33,7 @@ import net.minecraftforge.common.MinecraftForge; import org.lwjgl.opengl.GL11; +import appeng.api.parts.CableRenderMode; import appeng.api.util.AEColor; import appeng.block.AEBaseBlock; import appeng.client.render.BaseBlockRender; @@ -72,6 +73,36 @@ public class ClientHelper extends ServerHelper private static RenderItem itemRenderer = new RenderItem(); private static RenderBlocks blockRenderer = new RenderBlocks(); + @Override + public CableRenderMode getRenderMode() + { + if ( Platform.isServer() ) + return super.getRenderMode(); + + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayer player = mc.thePlayer; + + return renderModeForPlayer( player ); + } + + @Override + public void triggerUpdates() + { + Minecraft mc = Minecraft.getMinecraft(); + EntityPlayer player = mc.thePlayer; + + if ( player == null ) + return; + + int x = (int) player.posX; + int y = (int) player.posY; + int z = (int) player.posZ; + + int range = 16 * 16; + + mc.theWorld.markBlockRangeForRenderUpdate( x - range, y - range, z - range, x + range, y + range, z + range ); + } + @SubscribeEvent public void postPlayerRender(RenderLivingEvent.Pre p) { diff --git a/client/gui/implementations/GuiNetworkTool.java b/client/gui/implementations/GuiNetworkTool.java index c919a3d7..ddf4b49d 100644 --- a/client/gui/implementations/GuiNetworkTool.java +++ b/client/gui/implementations/GuiNetworkTool.java @@ -1,19 +1,54 @@ package appeng.client.gui.implementations; +import java.io.IOException; + +import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import appeng.api.implementations.guiobjects.INetworkTool; import appeng.client.gui.AEBaseGui; +import appeng.client.gui.widgets.GuiToggleButton; import appeng.container.implementations.ContainerNetworkTool; +import appeng.core.AELog; import appeng.core.localization.GuiText; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketValueConfig; public class GuiNetworkTool extends AEBaseGui { + GuiToggleButton tFacades; + public GuiNetworkTool(InventoryPlayer inventoryPlayer, INetworkTool te) { super( new ContainerNetworkTool( inventoryPlayer, te ) ); this.ySize = 166; } + @Override + protected void actionPerformed(GuiButton btn) + { + super.actionPerformed( btn ); + + try + { + if ( btn == tFacades ) + NetworkHandler.instance.sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) ); + } + catch (IOException e) + { + AELog.error( e ); + } + } + + @Override + public void initGui() + { + super.initGui(); + + tFacades = new GuiToggleButton( this.guiLeft - 18, guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint.getLocal() ); + + buttonList.add( tFacades ); + } + @Override public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) { @@ -24,6 +59,9 @@ public class GuiNetworkTool extends AEBaseGui @Override public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) { + if ( tFacades != null ) + tFacades.setState( ((ContainerNetworkTool) inventorySlots).facadeMode ); + fontRendererObj.drawString( getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 ); fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 ); } diff --git a/client/render/RenderBlocksWorkaround.java b/client/render/RenderBlocksWorkaround.java index 5e5368b7..fae4a8fb 100644 --- a/client/render/RenderBlocksWorkaround.java +++ b/client/render/RenderBlocksWorkaround.java @@ -234,7 +234,7 @@ public class RenderBlocksWorkaround extends RenderBlocks brightnessBottomRight = z[1]; brightnessTopLeft = z[2]; brightnessTopRight = z[3]; - Tessellator.instance.setColorOpaque_I( z[4] ); + Tessellator.instance.setColorRGBA_I( z[4], (int) (opacity * 255) ); colorRedTopLeft = c[0]; colorGreenTopLeft = c[1]; @@ -430,7 +430,7 @@ public class RenderBlocksWorkaround extends RenderBlocks int out = (high << 16) | low; - Tessellator.instance.setColorOpaque_F( r, g, b ); + Tessellator.instance.setColorRGBA_F( r, g, b, opacity ); Tessellator.instance.setBrightness( out ); } @@ -657,6 +657,7 @@ public class RenderBlocksWorkaround extends RenderBlocks } int lightHashTmp[] = new int[27]; + public float opacity = 1.0f; private int getLightingHash(Block blk, IBlockAccess w, int x, int y, int z) { diff --git a/container/implementations/ContainerNetworkTool.java b/container/implementations/ContainerNetworkTool.java index 84a24492..e39190ca 100644 --- a/container/implementations/ContainerNetworkTool.java +++ b/container/implementations/ContainerNetworkTool.java @@ -2,8 +2,10 @@ package appeng.container.implementations; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import appeng.api.implementations.guiobjects.INetworkTool; import appeng.container.AEBaseContainer; +import appeng.container.guisync.GuiSync; import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; import appeng.util.Platform; @@ -13,6 +15,9 @@ public class ContainerNetworkTool extends AEBaseContainer INetworkTool toolInv; + @GuiSync(1) + public boolean facadeMode; + public ContainerNetworkTool(InventoryPlayer ip, INetworkTool te) { super( ip, null, null ); toolInv = te; @@ -26,6 +31,13 @@ public class ContainerNetworkTool extends AEBaseContainer bindPlayerInventory( ip, 0, 166 - /* height of playerinventory */82 ); } + public void toggleFacadeMode() + { + NBTTagCompound data = Platform.openNbtData( toolInv.getItemStack() ); + data.setBoolean( "hideFacades", !data.getBoolean( "hideFacades" ) ); + this.detectAndSendChanges(); + } + @Override public void detectAndSendChanges() { @@ -36,7 +48,9 @@ public class ContainerNetworkTool extends AEBaseContainer if ( currentItem != null ) { if ( Platform.isSameItem( toolInv.getItemStack(), currentItem ) ) + { getPlayerInv().setInventorySlotContents( getPlayerInv().currentItem, toolInv.getItemStack() ); + } else isContainerValid = false; } @@ -44,6 +58,12 @@ public class ContainerNetworkTool extends AEBaseContainer isContainerValid = false; } + if ( isContainerValid ) + { + NBTTagCompound data = Platform.openNbtData( currentItem ); + facadeMode = data.getBoolean( "hideFacades" ); + } + super.detectAndSendChanges(); } } diff --git a/core/CommonHelper.java b/core/CommonHelper.java index 572f3151..67be9d67 100644 --- a/core/CommonHelper.java +++ b/core/CommonHelper.java @@ -7,6 +7,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; +import appeng.api.parts.CableRenderMode; import appeng.block.AEBaseBlock; import appeng.client.EffectType; import appeng.core.sync.AppEngPacket; @@ -38,9 +39,10 @@ public abstract class CommonHelper public abstract void postinit(); - { - // TODO Auto-generated method stub + public abstract CableRenderMode getRenderMode(); - } + public abstract void triggerUpdates(); + + public abstract void updateRenderMode(EntityPlayer player); } diff --git a/core/api/ApiPart.java b/core/api/ApiPart.java index 14f0dba8..c30be2ad 100644 --- a/core/api/ApiPart.java +++ b/core/api/ApiPart.java @@ -23,12 +23,14 @@ import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodInsnNode; import org.objectweb.asm.tree.MethodNode; +import appeng.api.parts.CableRenderMode; import appeng.api.parts.IPartHelper; import appeng.api.parts.IPartItem; import appeng.api.parts.LayerBase; import appeng.client.render.BusRenderer; import appeng.core.AELog; import appeng.core.AppEng; +import appeng.core.CommonHelper; import appeng.integration.IntegrationType; import appeng.integration.abstraction.IFMP; import appeng.parts.PartPlacement; @@ -345,4 +347,10 @@ public class ApiPart implements IPartHelper return false; } + @Override + public CableRenderMode getCableRenderMode() + { + return CommonHelper.proxy.getRenderMode(); + } + } diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 862cfab7..46c456ae 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -24,15 +24,29 @@ public enum GuiText CraftingTerminal, FormationPlane, Inscriber, QuartzCuttingKnife, - METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel, StoredSize, + METunnel, ItemTunnel, RedstoneTunnel, MJTunnel, EUTunnel, FluidTunnel, - CopyMode, CopyModeDesc, PatternTerminal, CraftingPattern, ProcessingPattern, Crafts, Creates, And, With, MolecularAssembler, + StoredSize, CopyMode, CopyModeDesc, PatternTerminal, CraftingPattern, - StoredPower, MaxPower, RequiredPower, Efficiency, InWorldCrafting, inWorldFluix, inWorldPurificationCertus, inWorldPurificationNether, inWorldPurificationFluix, inWorldSingularity, ChargedQuartz, + ProcessingPattern, Crafts, Creates, And, With, MolecularAssembler, - OfSecondOutput, NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, ConfirmCrafting, + StoredPower, MaxPower, RequiredPower, Efficiency, InWorldCrafting, - Stored, Crafting, Scheduled, CraftingStatus, Cancel, FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, CraftingCPU, Automatic, CoProcessors, Simulation, Missing, InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean, InvalidPattern, InterfaceTerminalHint, Range; + inWorldFluix, inWorldPurificationCertus, inWorldPurificationNether, + + inWorldPurificationFluix, inWorldSingularity, ChargedQuartz, OfSecondOutput, + + NoSecondOutput, RFTunnel, Stores, Next, SelectAmount, Lumen, Empty, + + ConfirmCrafting, Stored, Crafting, Scheduled, CraftingStatus, Cancel, + + FromStorage, ToCraft, CraftingPlan, CalculatingWait, Start, Bytes, + + CraftingCPU, Automatic, CoProcessors, Simulation, Missing, + + InterfaceTerminal, NoCraftingCPUs, LightTunnel, Clean, InvalidPattern, + + InterfaceTerminalHint, Range, TransparentFacades, TransparentFacadesHint; String root; diff --git a/core/sync/packets/PacketPartPlacement.java b/core/sync/packets/PacketPartPlacement.java index 76b2160b..fa1edb63 100644 --- a/core/sync/packets/PacketPartPlacement.java +++ b/core/sync/packets/PacketPartPlacement.java @@ -7,6 +7,7 @@ import java.io.IOException; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import appeng.core.CommonHelper; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.parts.PartPlacement; @@ -28,7 +29,9 @@ public class PacketPartPlacement extends AppEngPacket public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player) { EntityPlayerMP sender = (EntityPlayerMP) player; + CommonHelper.proxy.updateRenderMode( sender ); PartPlacement.place( sender.getHeldItem(), x, y, z, face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 ); + CommonHelper.proxy.updateRenderMode( null ); } // api diff --git a/core/sync/packets/PacketValueConfig.java b/core/sync/packets/PacketValueConfig.java index fdec8a56..5b9c5861 100644 --- a/core/sync/packets/PacketValueConfig.java +++ b/core/sync/packets/PacketValueConfig.java @@ -20,6 +20,7 @@ import appeng.container.implementations.ContainerCellWorkbench; import appeng.container.implementations.ContainerCraftConfirm; import appeng.container.implementations.ContainerCraftingCPU; import appeng.container.implementations.ContainerLevelEmitter; +import appeng.container.implementations.ContainerNetworkTool; import appeng.container.implementations.ContainerPatternTerm; import appeng.container.implementations.ContainerPriority; import appeng.container.implementations.ContainerQuartzKnife; @@ -151,6 +152,13 @@ public class PacketValueConfig extends AppEngPacket ccw.setFuzzy( FuzzyMode.valueOf( Value ) ); } } + else if ( c instanceof ContainerNetworkTool ) + { + if ( Name.equals( "NetworkTool" ) && Value.equals( "Toggle" ) ) + { + ((ContainerNetworkTool) c).toggleFacadeMode(); + } + } else if ( c instanceof IConfigureableObject ) { IConfigManager cm = ((IConfigureableObject) c).getConfigManager(); diff --git a/facade/FacadePart.java b/facade/FacadePart.java index 85eb9ebe..7349a62d 100644 --- a/facade/FacadePart.java +++ b/facade/FacadePart.java @@ -5,6 +5,8 @@ import java.util.EnumSet; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -16,6 +18,7 @@ import net.minecraftforge.common.util.ForgeDirection; import org.lwjgl.opengl.GL11; +import appeng.api.AEApi; import appeng.api.parts.IFacadeContainer; import appeng.api.parts.IFacadePart; import appeng.api.parts.IPartCollsionHelper; @@ -52,10 +55,18 @@ public class FacadePart implements IFacadePart } @Override - public void getBoxes(IPartCollsionHelper ch) + public void getBoxes(IPartCollsionHelper ch, Entity e) { - // the box is 15.9 for transition planes to pick up collision events. - ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 15.9 ); + if ( e instanceof EntityLivingBase ) + { + // prevent weird snagg behavior + ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 16.0 ); + } + else + { + // the box is 15.9 for transition planes to pick up collision events. + ch.addBox( 0.0, 0.0, 14, 16.0, 16.0, 15.9 ); + } } public static boolean isFacade(ItemStack is) @@ -136,10 +147,19 @@ public class FacadePart implements IFacadePart ItemBlock ib = (ItemBlock) randomItem.getItem(); Block blk = Block.getBlockFromItem( ib ); - if ( blk.canRenderInPass( 1 ) ) + if ( AEApi.instance().partHelper().getCableRenderMode().transparentFacades ) { + if ( rbw != null ) + rbw.opacity = 0.3f; instance.renderForPass( 1 ); } + else + { + if ( blk.canRenderInPass( 1 ) ) + { + instance.renderForPass( 1 ); + } + } int color = 0xffffff; @@ -265,6 +285,7 @@ public class FacadePart implements IFacadePart if ( rbw != null ) { + rbw.opacity = 1.0f; rbw.faces = EnumSet.allOf( ForgeDirection.class ); } @@ -505,6 +526,9 @@ public class FacadePart implements IFacadePart @Override public boolean isTransparent() { + if ( AEApi.instance().partHelper().getCableRenderMode().transparentFacades ) + return true; + ItemStack is = getTexture(); Block blk = Block.getBlockFromItem( is.getItem() ); if ( !blk.isOpaqueCube() ) diff --git a/fmp/CableBusPart.java b/fmp/CableBusPart.java index 981f9842..773eb137 100644 --- a/fmp/CableBusPart.java +++ b/fmp/CableBusPart.java @@ -101,7 +101,7 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds { return cb.recolourBlock( side, colour, who ); } - + @Override public AEColor getColor() { @@ -311,7 +311,7 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds { List boxes = new ArrayList(); IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true ); - fp.getBoxes( bch ); + fp.getBoxes( bch, null ); for (AxisAlignedBB bb : boxes) { disableFacadeOcclusion.set( true ); diff --git a/hooks/TickHandler.java b/hooks/TickHandler.java index c6b062d3..da3ed37a 100644 --- a/hooks/TickHandler.java +++ b/hooks/TickHandler.java @@ -11,9 +11,12 @@ import java.util.concurrent.Callable; import net.minecraft.world.World; import net.minecraftforge.event.world.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; +import appeng.api.AEApi; import appeng.api.networking.IGridNode; +import appeng.api.parts.CableRenderMode; import appeng.api.util.AEColor; import appeng.core.AELog; +import appeng.core.CommonHelper; import appeng.core.sync.packets.PacketPaintedEntity; import appeng.crafting.CraftingJob; import appeng.entity.EntityFloatingItem; @@ -181,6 +184,8 @@ public class TickHandler } } + CableRenderMode crm = CableRenderMode.Standard; + @SubscribeEvent public void onTick(TickEvent ev) { @@ -189,6 +194,12 @@ public class TickHandler { tickColors( cliPlayerColors ); EntityFloatingItem.ageStatic = (EntityFloatingItem.ageStatic + 1) % 60000; + CableRenderMode currentMode = AEApi.instance().partHelper().getCableRenderMode(); + if ( currentMode != crm ) + { + crm = currentMode; + CommonHelper.proxy.triggerUpdates(); + } } // rwar! diff --git a/parts/CableBusContainer.java b/parts/CableBusContainer.java index 4045de9c..4b4da71b 100644 --- a/parts/CableBusContainer.java +++ b/parts/CableBusContainer.java @@ -447,11 +447,14 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer part.getBoxes( bch ); } - if ( includeFacades && s != null && s != ForgeDirection.UNKNOWN ) + if ( AEApi.instance().partHelper().getCableRenderMode().opaqueFacades || !visual ) { - IFacadePart fp = fc.getFacade( s ); - if ( fp != null ) - fp.getBoxes( bch ); + if ( includeFacades && s != null && s != ForgeDirection.UNKNOWN ) + { + IFacadePart fp = fc.getFacade( s ); + if ( fp != null ) + fp.getBoxes( bch, e ); + } } } @@ -844,21 +847,24 @@ public class CableBusContainer implements AEMultiTile, ICableBusContainer } } - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) + if ( AEApi.instance().partHelper().getCableRenderMode().opaqueFacades ) { - IFacadePart p = fc.getFacade( side ); - if ( p != null ) + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - List boxes = new LinkedList(); - - IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true ); - p.getBoxes( bch ); - for (AxisAlignedBB bb : boxes) + IFacadePart p = fc.getFacade( side ); + if ( p != null ) { - bb = bb.expand( 0.01, 0.01, 0.01 ); - if ( bb.isVecInside( pos ) ) + List boxes = new LinkedList(); + + IPartCollsionHelper bch = new BusCollisionHelper( boxes, side, null, true ); + p.getBoxes( bch, null ); + for (AxisAlignedBB bb : boxes) { - return new SelectedPart( p, side ); + bb = bb.expand( 0.01, 0.01, 0.01 ); + if ( bb.isVecInside( pos ) ) + { + return new SelectedPart( p, side ); + } } } } diff --git a/parts/PartPlacement.java b/parts/PartPlacement.java index bf5d9686..2ddc8f9e 100644 --- a/parts/PartPlacement.java +++ b/parts/PartPlacement.java @@ -27,6 +27,7 @@ import appeng.api.parts.PartItemStack; import appeng.api.parts.SelectedPart; import appeng.core.AELog; import appeng.core.AppEng; +import appeng.core.CommonHelper; import appeng.core.sync.network.NetworkHandler; import appeng.core.sync.packets.PacketClick; import appeng.core.sync.packets.PacketPartPlacement; @@ -137,7 +138,7 @@ public class PartPlacement if ( mop != null ) { List is = new LinkedList(); - SelectedPart sp = host.selectPart( mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) ); + SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) ); if ( sp.part != null ) { @@ -247,7 +248,7 @@ public class PartPlacement if ( mop != null ) { mop.hitVec = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ); - SelectedPart sPart = host.selectPart( mop.hitVec ); + SelectedPart sPart = selectPart( player, host, mop.hitVec ); if ( sPart != null && sPart.part != null ) if ( sPart.part.onShiftActivate( player, mop.hitVec ) ) { @@ -364,7 +365,7 @@ public class PartPlacement MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b ); if ( mop != null ) { - SelectedPart sp = host.selectPart( mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) ); + SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) ); if ( sp.part != null ) { @@ -407,6 +408,15 @@ public class PartPlacement return true; } + private static SelectedPart selectPart(EntityPlayer player, IPartHost host, Vec3 pos) + { + CommonHelper.proxy.updateRenderMode( player ); + SelectedPart sp = host.selectPart( pos ); + CommonHelper.proxy.updateRenderMode( null ); + + return sp; + } + public static IFacadePart isFacade(ItemStack held, ForgeDirection side) { if ( held.getItem() instanceof IFacadeItem ) diff --git a/server/ServerHelper.java b/server/ServerHelper.java index ab3be36b..48815c1c 100644 --- a/server/ServerHelper.java +++ b/server/ServerHelper.java @@ -6,15 +6,19 @@ import java.util.Random; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; +import appeng.api.parts.CableRenderMode; import appeng.block.AEBaseBlock; import appeng.client.EffectType; import appeng.core.CommonHelper; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.NetworkHandler; +import appeng.items.tools.ToolNetworkTool; import appeng.util.Platform; import cpw.mods.fml.common.FMLCommonHandler; @@ -107,4 +111,47 @@ public class ServerHelper extends CommonHelper return null; } + @Override + public CableRenderMode getRenderMode() + { + if ( renderModeBased == null ) + return CableRenderMode.Standard; + + return renderModeForPlayer( renderModeBased ); + } + + private EntityPlayer renderModeBased; + + @Override + public void updateRenderMode(EntityPlayer player) + { + renderModeBased = player; + } + + protected CableRenderMode renderModeForPlayer(EntityPlayer player) + { + if ( player != null ) + { + for (int x = 0; x < InventoryPlayer.getHotbarSize(); x++) + { + ItemStack is = player.inventory.getStackInSlot( x ); + + if ( is != null && is.getItem() instanceof ToolNetworkTool ) + { + NBTTagCompound c = is.getTagCompound(); + if ( c != null && c.getBoolean( "hideFacades" ) ) + return CableRenderMode.CableView; + } + } + } + + return CableRenderMode.Standard; + } + + @Override + public void triggerUpdates() + { + + } + }