From bb1c341c959cc3c835a48fc9508b76fd7ac19f09 Mon Sep 17 00:00:00 2001 From: thatsIch Date: Fri, 3 Apr 2015 20:15:59 +0200 Subject: [PATCH] Fixes #1059 FMP Blocks don't disturb the ME Interface identifier --- .../ContainerInterfaceTerminal.java | 18 +++--- .../java/appeng/helpers/DualityInterface.java | 64 +++++++++---------- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java index 9e0da207d..e90a29dbb 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java +++ b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java @@ -54,17 +54,17 @@ import appeng.util.inv.AdaptorPlayerHand; import appeng.util.inv.WrapperInvSlot; -public class ContainerInterfaceTerminal extends AEBaseContainer +public final class ContainerInterfaceTerminal extends AEBaseContainer { /** * this stuff is all server side.. */ - static private long autoBase = Long.MIN_VALUE; + private static long autoBase = Long.MIN_VALUE; final Map diList = new HashMap(); final Map byId = new HashMap(); - IGrid g; + IGrid grid; NBTTagCompound data = new NBTTagCompound(); public ContainerInterfaceTerminal( InventoryPlayer ip, PartMonitor anchor ) @@ -72,7 +72,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer super( ip, anchor ); if( Platform.isServer() ) - this.g = anchor.getActionableNode().getGrid(); + this.grid = anchor.getActionableNode().getGrid(); this.bindPlayerInventory( ip, 0, 222 - /* height of player inventory */82 ); } @@ -85,7 +85,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer super.detectAndSendChanges(); - if( this.g == null ) + if( this.grid == null ) return; int total = 0; @@ -97,7 +97,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer IGridNode agn = host.getActionableNode(); if( agn != null && agn.isActive() ) { - for( IGridNode gn : this.g.getMachines( TileInterface.class ) ) + for( IGridNode gn : this.grid.getMachines( TileInterface.class ) ) { if( gn.isActive() ) { @@ -120,7 +120,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer } } - for( IGridNode gn : this.g.getMachines( PartInterface.class ) ) + for( IGridNode gn : this.grid.getMachines( PartInterface.class ) ) { if( gn.isActive() ) { @@ -289,7 +289,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer IGridNode agn = host.getActionableNode(); if( agn != null && agn.isActive() ) { - for( IGridNode gn : this.g.getMachines( TileInterface.class ) ) + for( IGridNode gn : this.grid.getMachines( TileInterface.class ) ) { IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); DualityInterface dual = ih.getInterfaceDuality(); @@ -297,7 +297,7 @@ public class ContainerInterfaceTerminal extends AEBaseContainer this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) ); } - for( IGridNode gn : this.g.getMachines( PartInterface.class ) ) + for( IGridNode gn : this.grid.getMachines( PartInterface.class ) ) { IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); DualityInterface dual = ih.getInterfaceDuality(); diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index 8d56b8f92..3e63c47b1 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -981,32 +981,28 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public String getTermName() { - TileEntity tile = this.iHost.getTileEntity(); - World w = tile.getWorldObj(); + final TileEntity hostTile = this.iHost.getTileEntity(); + final World hostWorld = hostTile.getWorldObj(); if( ( (ICustomNameObject) this.iHost ).hasCustomName() ) return ( (ICustomNameObject) this.iHost ).getCustomName(); - EnumSet possibleDirections = this.iHost.getTargets(); - for( ForgeDirection s : possibleDirections ) + final EnumSet possibleDirections = this.iHost.getTargets(); + for( ForgeDirection direction : possibleDirections ) { - Vec3 from = Vec3.createVectorHelper( tile.xCoord + 0.5, tile.yCoord + 0.5, tile.zCoord + 0.5 ); - from = from.addVector( s.offsetX * 0.501, s.offsetY * 0.501, s.offsetZ * 0.501 ); - Vec3 to = from.addVector( s.offsetX, s.offsetY, s.offsetZ ); + final int xPos = hostTile.xCoord + direction.offsetX; + final int yPos = hostTile.yCoord + direction.offsetY; + final int zPos = hostTile.zCoord + direction.offsetZ; + final TileEntity directedTile = hostWorld.getTileEntity( xPos, yPos, zPos ); - Block blk = w.getBlock( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ ); - MovingObjectPosition mop = w.rayTraceBlocks( from, to, true ); - - TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ ); - - if( te == null ) + if( directedTile == null ) continue; - if( te instanceof IInterfaceHost ) + if( directedTile instanceof IInterfaceHost ) { try { - if( ( (IInterfaceHost) te ).getInterfaceDuality().sameGrid( this.gridProxy.getGrid() ) ) + if( ( (IInterfaceHost) directedTile ).getInterfaceDuality().sameGrid( this.gridProxy.getGrid() ) ) continue; } catch( GridAccessException e ) @@ -1015,35 +1011,33 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn } } - Item item = Item.getItemFromBlock( blk ); - - if( item == null ) + final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( directedTile, direction.getOpposite() ); + if( directedTile instanceof ICraftingMachine || adaptor != null ) { - return blk.getUnlocalizedName(); - } - - ItemStack what = new ItemStack( item, 1, blk.getDamageValue( w, tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ ) ); - - if( te instanceof ICraftingMachine || InventoryAdaptor.getAdaptor( te, s.getOpposite() ) != null ) - { - if( te instanceof IInventory && ( (IInventory) te ).getSizeInventory() == 0 ) + if( directedTile instanceof IInventory && ( (IInventory) directedTile ).getSizeInventory() == 0 ) continue; - if( te instanceof ISidedInventory ) + if( directedTile instanceof ISidedInventory ) { - int[] sides = ( (ISidedInventory) te ).getAccessibleSlotsFromSide( s.getOpposite().ordinal() ); + int[] sides = ( (ISidedInventory) directedTile ).getAccessibleSlotsFromSide( direction.getOpposite().ordinal() ); if( sides == null || sides.length == 0 ) continue; } + final Block directedBlock = hostWorld.getBlock( xPos, yPos, zPos ); + ItemStack what = new ItemStack( directedBlock, 1, directedBlock.getDamageValue( hostWorld, xPos, yPos, zPos ) ); try { - if( mop != null && !badBlocks.contains( blk ) ) + Vec3 from = Vec3.createVectorHelper( hostTile.xCoord + 0.5, hostTile.yCoord + 0.5, hostTile.zCoord + 0.5 ); + from = from.addVector( direction.offsetX * 0.501, direction.offsetY * 0.501, direction.offsetZ * 0.501 ); + Vec3 to = from.addVector( direction.offsetX, direction.offsetY, direction.offsetZ ); + MovingObjectPosition mop = hostWorld.rayTraceBlocks( from, to, true ); + if( mop != null && !badBlocks.contains( directedBlock ) ) { - if( mop.blockX == te.xCoord && mop.blockY == te.yCoord && mop.blockZ == te.zCoord ) + if( mop.blockX == directedTile.xCoord && mop.blockY == directedTile.yCoord && mop.blockZ == directedTile.zCoord ) { - ItemStack g = blk.getPickBlock( mop, w, te.xCoord, te.yCoord, te.zCoord, null ); + ItemStack g = directedBlock.getPickBlock( mop, hostWorld, directedTile.xCoord, directedTile.yCoord, directedTile.zCoord, null ); if( g != null ) what = g; } @@ -1051,11 +1045,17 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn } catch( Throwable t ) { - badBlocks.add( blk ); // nope! + badBlocks.add( directedBlock ); // nope! } if( what.getItem() != null ) return what.getUnlocalizedName(); + + Item item = Item.getItemFromBlock( directedBlock ); + if( item == null ) + { + return directedBlock.getUnlocalizedName(); + } } }