diff --git a/src/api/java/appeng/api/storage/MEMonitorHandler.java b/src/api/java/appeng/api/storage/MEMonitorHandler.java index 5b6ba0b3..fb14960a 100644 --- a/src/api/java/appeng/api/storage/MEMonitorHandler.java +++ b/src/api/java/appeng/api/storage/MEMonitorHandler.java @@ -80,7 +80,9 @@ public class MEMonitorHandler implements IMEMonitor< public StackType injectItems( StackType input, Actionable mode, BaseActionSource src ) { if( mode == Actionable.SIMULATE ) + { return this.getHandler().injectItems( input, mode, src ); + } return this.monitorDifference( input.copy(), this.getHandler().injectItems( input, mode, src ), false, src ); } @@ -94,12 +96,18 @@ public class MEMonitorHandler implements IMEMonitor< StackType diff = (StackType) original.copy(); if( extraction ) + { diff.setStackSize( leftOvers == null ? 0 : -leftOvers.getStackSize() ); + } else if( leftOvers != null ) + { diff.decStackSize( leftOvers.getStackSize() ); + } if( diff.getStackSize() != 0 ) + { this.postChangesToListeners( ImmutableList.of( diff ), src ); + } return leftOvers; } @@ -118,9 +126,13 @@ public class MEMonitorHandler implements IMEMonitor< Entry, Object> o = i.next(); IMEMonitorHandlerReceiver receiver = o.getKey(); if( receiver.isValid( o.getValue() ) ) + { receiver.postChange( this, diff, src ); + } else + { i.remove(); + } } } @@ -133,7 +145,9 @@ public class MEMonitorHandler implements IMEMonitor< public StackType extractItems( StackType request, Actionable mode, BaseActionSource src ) { if( mode == Actionable.SIMULATE ) + { return this.getHandler().extractItems( request, mode, src ); + } return this.monitorDifference( request.copy(), this.getHandler().extractItems( request, mode, src ), true, src ); } diff --git a/src/api/java/appeng/api/storage/StorageChannel.java b/src/api/java/appeng/api/storage/StorageChannel.java index b2131e55..e0bd3789 100644 --- a/src/api/java/appeng/api/storage/StorageChannel.java +++ b/src/api/java/appeng/api/storage/StorageChannel.java @@ -53,8 +53,12 @@ public enum StorageChannel public IItemList createList() { if( this == ITEMS ) + { return AEApi.instance().storage().createItemList(); + } else + { return AEApi.instance().storage().createFluidList(); + } } } diff --git a/src/api/java/appeng/api/util/WorldCoord.java b/src/api/java/appeng/api/util/WorldCoord.java index 3f935c04..d020e15d 100644 --- a/src/api/java/appeng/api/util/WorldCoord.java +++ b/src/api/java/appeng/api/util/WorldCoord.java @@ -105,22 +105,34 @@ public class WorldCoord int zlen = Math.abs( oz ); if( loc.isEqual( this.copy().add( ForgeDirection.EAST, xlen ) ) ) + { return ForgeDirection.EAST; + } if( loc.isEqual( this.copy().add( ForgeDirection.WEST, xlen ) ) ) + { return ForgeDirection.WEST; + } if( loc.isEqual( this.copy().add( ForgeDirection.NORTH, zlen ) ) ) + { return ForgeDirection.NORTH; + } if( loc.isEqual( this.copy().add( ForgeDirection.SOUTH, zlen ) ) ) + { return ForgeDirection.SOUTH; + } if( loc.isEqual( this.copy().add( ForgeDirection.UP, ylen ) ) ) + { return ForgeDirection.UP; + } if( loc.isEqual( this.copy().add( ForgeDirection.DOWN, ylen ) ) ) + { return ForgeDirection.DOWN; + } return null; } diff --git a/src/main/java/appeng/block/AEBaseBlock.java b/src/main/java/appeng/block/AEBaseBlock.java index 7c35b71e..35367221 100644 --- a/src/main/java/appeng/block/AEBaseBlock.java +++ b/src/main/java/appeng/block/AEBaseBlock.java @@ -117,13 +117,21 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature super( mat ); if( mat == AEGlassMaterial.INSTANCE || mat == Material.glass ) + { this.setStepSound( Block.soundTypeGlass ); + } else if( mat == Material.rock ) + { this.setStepSound( Block.soundTypeStone ); + } else if( mat == Material.wood ) + { this.setStepSound( Block.soundTypeWood ); + } else + { this.setStepSound( Block.soundTypeMetal ); + } this.featureFullName = new FeatureNameExtractor( c, subName ).get(); this.featureSubName = subName; @@ -152,7 +160,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature public BlockRenderInfo getRendererInstance() { if( this.renderInfo != null ) + { return this.renderInfo; + } try { @@ -243,7 +253,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature public IIcon getIcon( int direction, int metadata ) { if( this.renderIcon != null ) + { return this.renderIcon; + } return this.getRendererInstance().getTexture( ForgeDirection.getOrientation( direction ) ); } @@ -256,12 +268,16 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature ICustomCollision collisionHandler = null; if( this instanceof ICustomCollision ) + { collisionHandler = (ICustomCollision) this; + } else { AEBaseTile te = this.getTileEntity( w, x, y, z ); if( te instanceof ICustomCollision ) + { collisionHandler = (ICustomCollision) te; + } } if( collisionHandler != null && bb != null ) @@ -277,11 +293,15 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature b.maxY += y; b.maxZ += z; if( bb.intersectsWith( b ) ) + { out.add( b ); + } } } else + { super.addCollisionBoxesToList( w, x, y, z, bb, out, e ); + } } @Override @@ -292,12 +312,16 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature AxisAlignedBB b = null; if( this instanceof ICustomCollision ) + { collisionHandler = (ICustomCollision) this; + } else { AEBaseTile te = this.getTileEntity( w, x, y, z ); if( te instanceof ICustomCollision ) + { collisionHandler = (ICustomCollision) te; + } } if( collisionHandler != null ) @@ -345,7 +369,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature for( AxisAlignedBB bx : collisionHandler.getSelectedBoundingBoxesFromPool( w, x, y, z, null, false ) ) { if( b == null ) + { b = bx; + } else { double minX = Math.min( b.minX, bx.minX ); @@ -361,7 +387,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature b.setBounds( b.minX + x, b.minY + y, b.minZ + z, b.maxX + x, b.maxY + y, b.maxZ + z ); } else + { b = super.getSelectedBoundingBoxFromPool( w, x, y, z ); + } return b; } @@ -378,12 +406,16 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature ICustomCollision collisionHandler = null; if( this instanceof ICustomCollision ) + { collisionHandler = (ICustomCollision) this; + } else { AEBaseTile te = this.getTileEntity( w, x, y, z ); if( te instanceof ICustomCollision ) + { collisionHandler = (ICustomCollision) te; + } } if( collisionHandler != null ) @@ -444,10 +476,14 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature ItemStack[] drops = Platform.getBlockDrops( w, x, y, z ); if( tile == null ) + { return false; + } if( tile instanceof TileCableBus || tile instanceof TileSkyChest ) + { return false; + } ItemStack op = new ItemStack( this ); for( ItemStack ol : drops ) @@ -456,7 +492,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature { NBTTagCompound tag = tile.downloadSettings( SettingsFrom.DISMANTLE_ITEM ); if( tag != null ) + { ol.setTagCompound( tag ); + } } } @@ -499,7 +537,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED ); } else + { memoryCard.notifyUser( player, MemoryCardMessages.INVALID_MACHINE ); + } return false; } } @@ -521,7 +561,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature { TileEntity te = this.getTileEntity( w, x, y, z ); if( te instanceof AEBaseTile ) + { ( (AEBaseTile) w.getTileEntity( x, y, z ) ).setName( is.getDisplayName() ); + } } } @@ -544,7 +586,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature { TileEntity te = this.getTileEntity( w, x, y, z ); if( te instanceof IInventory ) + { return Container.calcRedstoneFromInventory( (IInventory) te ); + } return 0; } @@ -678,7 +722,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature { // if the input is an flippable IIcon find the original. while( substitute instanceof FlippableIcon ) + { substitute = ( (FlippableIcon) substitute ).getOriginal(); + } if( substitute != null ) { @@ -689,7 +735,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature IResource res = Minecraft.getMinecraft().getResourceManager().getResource( resLoc ); if( res != null ) + { return new FlippableIcon( ir.registerIcon( Name ) ); + } } catch( Throwable e ) { @@ -731,11 +779,15 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature public T getTileEntity( IBlockAccess w, int x, int y, int z ) { if( !this.hasBlockTileEntity() ) + { return null; + } TileEntity te = w.getTileEntity( x, y, z ); if( this.tileEntityType.isInstance( te ) ) + { return (T) te; + } return null; } @@ -754,30 +806,48 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature ForgeDirection west = ForgeDirection.UNKNOWN; if( forward == null || up == null ) + { return dir; + } int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY; int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ; int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX; for( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS ) + { if( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z ) + { west = dx; + } + } if( dir == forward ) + { return ForgeDirection.SOUTH; + } if( dir == forward.getOpposite() ) + { return ForgeDirection.NORTH; + } if( dir == up ) + { return ForgeDirection.UP; + } if( dir == up.getOpposite() ) + { return ForgeDirection.DOWN; + } if( dir == west ) + { return ForgeDirection.WEST; + } if( dir == west.getOpposite() ) + { return ForgeDirection.EAST; + } return ForgeDirection.UNKNOWN; } @@ -823,9 +893,13 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature { ArrayList drops = new ArrayList(); if( te.dropItems() ) + { te.getDrops( w, x, y, z, drops ); + } else + { te.getNoDrops( w, x, y, z, drops ); + } // Cry ;_; ... Platform.spawnDrops( w, x, y, z, drops ); @@ -833,7 +907,9 @@ public class AEBaseBlock extends BlockContainer implements IAEFeature super.breakBlock( w, x, y, z, a, b ); if( te != null ) + { w.setTileEntity( x, y, z, null ); + } } public String getUnlocalizedName( ItemStack is ) diff --git a/src/main/java/appeng/block/AEBaseItemBlock.java b/src/main/java/appeng/block/AEBaseItemBlock.java index c06218f7..6b3634e6 100644 --- a/src/main/java/appeng/block/AEBaseItemBlock.java +++ b/src/main/java/appeng/block/AEBaseItemBlock.java @@ -56,14 +56,18 @@ public class AEBaseItemBlock extends ItemBlock this.hasSubtypes = this.blockType.hasSubtypes; if( Platform.isClient() ) + { MinecraftForgeClient.registerItemRenderer( this, ItemRenderer.INSTANCE ); + } } @Override public int getMetadata( int dmg ) { if( this.hasSubtypes ) + { return dmg; + } return 0; } @@ -107,17 +111,25 @@ public class AEBaseItemBlock extends ItemBlock { up = ForgeDirection.getOrientation( side ); if( up == ForgeDirection.UP || up == ForgeDirection.DOWN ) + { forward = ForgeDirection.SOUTH; + } else + { forward = ForgeDirection.UP; + } } else if( this.blockType instanceof BlockWireless || this.blockType instanceof BlockSkyCompass ) { forward = ForgeDirection.getOrientation( side ); if( forward == ForgeDirection.UP || forward == ForgeDirection.DOWN ) + { up = ForgeDirection.SOUTH; + } else + { up = ForgeDirection.UP; + } } else { @@ -161,11 +173,15 @@ public class AEBaseItemBlock extends ItemBlock up = ForgeDirection.getOrientation( side ); forward = ForgeDirection.SOUTH; if( up.offsetY == 0 ) + { forward = ForgeDirection.UP; + } } if( !this.blockType.isValidOrientation( w, x, y, z, forward, up ) ) + { return false; + } if( super.placeBlockAt( stack, player, w, x, y, z, side, hitX, hitY, hitZ, metadata ) ) { @@ -175,13 +191,17 @@ public class AEBaseItemBlock extends ItemBlock ori = tile; if( tile == null ) + { return true; + } if( ori.canBeRotated() && !this.blockType.hasCustomRotation() ) { if( ori.getForward() == null || ori.getUp() == null || // null tile.getForward() == ForgeDirection.UNKNOWN || ori.getUp() == ForgeDirection.UNKNOWN ) + { ori.setOrientation( forward, up ); + } } if( tile instanceof IGridProxyable ) diff --git a/src/main/java/appeng/block/crafting/BlockCraftingStorage.java b/src/main/java/appeng/block/crafting/BlockCraftingStorage.java index 0ec7694b..fff46bef 100644 --- a/src/main/java/appeng/block/crafting/BlockCraftingStorage.java +++ b/src/main/java/appeng/block/crafting/BlockCraftingStorage.java @@ -89,13 +89,19 @@ public class BlockCraftingStorage extends BlockCraftingUnit public String getUnlocalizedName( ItemStack is ) { if( is.getItemDamage() == 1 ) + { return "tile.appliedenergistics2.BlockCraftingStorage4k"; + } if( is.getItemDamage() == 2 ) + { return "tile.appliedenergistics2.BlockCraftingStorage16k"; + } if( is.getItemDamage() == 3 ) + { return "tile.appliedenergistics2.BlockCraftingStorage64k"; + } return this.getItemUnlocalizedName( is ); } diff --git a/src/main/java/appeng/block/crafting/BlockCraftingUnit.java b/src/main/java/appeng/block/crafting/BlockCraftingUnit.java index f3e60054..d025098e 100644 --- a/src/main/java/appeng/block/crafting/BlockCraftingUnit.java +++ b/src/main/java/appeng/block/crafting/BlockCraftingUnit.java @@ -94,7 +94,9 @@ public class BlockCraftingUnit extends AEBaseBlock if( tg != null && !p.isSneaking() && tg.isFormed() && tg.isActive() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CRAFTING_CPU ); return true; @@ -124,7 +126,9 @@ public class BlockCraftingUnit extends AEBaseBlock { TileCraftingTile cp = this.getTileEntity( w, x, y, z ); if( cp != null ) + { cp.breakCluster(); + } super.breakBlock( w, x, y, z, a, b ); } @@ -133,7 +137,9 @@ public class BlockCraftingUnit extends AEBaseBlock public String getUnlocalizedName( ItemStack is ) { if( is.getItemDamage() == 1 ) + { return "tile.appliedenergistics2.BlockCraftingAccelerator"; + } return this.getItemUnlocalizedName( is ); } @@ -148,7 +154,9 @@ public class BlockCraftingUnit extends AEBaseBlock { TileCraftingTile cp = this.getTileEntity( w, x, y, z ); if( cp != null ) + { cp.updateMultiBlock(); + } } @Override diff --git a/src/main/java/appeng/block/grindstone/BlockCrank.java b/src/main/java/appeng/block/grindstone/BlockCrank.java index 0e5dff9c..0cebc0d1 100644 --- a/src/main/java/appeng/block/grindstone/BlockCrank.java +++ b/src/main/java/appeng/block/grindstone/BlockCrank.java @@ -117,10 +117,12 @@ public class BlockCrank extends AEBaseBlock private ForgeDirection findCrankable( World world, int x, int y, int z ) { for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS ) + { if( this.isCrankable( world, x, y, z, dir ) ) { return dir; } + } return ForgeDirection.UNKNOWN; } diff --git a/src/main/java/appeng/block/misc/BlockCellWorkbench.java b/src/main/java/appeng/block/misc/BlockCellWorkbench.java index 2a977f29..8525084e 100644 --- a/src/main/java/appeng/block/misc/BlockCellWorkbench.java +++ b/src/main/java/appeng/block/misc/BlockCellWorkbench.java @@ -47,13 +47,17 @@ public class BlockCellWorkbench extends AEBaseBlock public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileCellWorkbench tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_CELL_WORKBENCH ); + } return true; } return false; diff --git a/src/main/java/appeng/block/misc/BlockCharger.java b/src/main/java/appeng/block/misc/BlockCharger.java index f2935f58..667e7965 100644 --- a/src/main/java/appeng/block/misc/BlockCharger.java +++ b/src/main/java/appeng/block/misc/BlockCharger.java @@ -71,7 +71,9 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ ) { if( player.isSneaking() ) + { return false; + } if( Platform.isServer() ) { @@ -90,10 +92,14 @@ public class BlockCharger extends AEBaseBlock implements ICustomCollision public void randomDisplayTick( World w, int x, int y, int z, Random r ) { if( !AEConfig.instance.enableEffects ) + { return; + } if( r.nextFloat() < 0.98 ) + { return; + } AEBaseTile tile = this.getTileEntity( w, x, y, z ); if( tile instanceof TileCharger ) diff --git a/src/main/java/appeng/block/misc/BlockCondenser.java b/src/main/java/appeng/block/misc/BlockCondenser.java index a5f7470a..129d6ca8 100644 --- a/src/main/java/appeng/block/misc/BlockCondenser.java +++ b/src/main/java/appeng/block/misc/BlockCondenser.java @@ -47,7 +47,9 @@ public class BlockCondenser extends AEBaseBlock public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ ) { if( player.isSneaking() ) + { return false; + } if( Platform.isServer() ) { diff --git a/src/main/java/appeng/block/misc/BlockInscriber.java b/src/main/java/appeng/block/misc/BlockInscriber.java index 06c1a97e..b314055b 100644 --- a/src/main/java/appeng/block/misc/BlockInscriber.java +++ b/src/main/java/appeng/block/misc/BlockInscriber.java @@ -57,13 +57,17 @@ public class BlockInscriber extends AEBaseBlock public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileInscriber tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INSCRIBER ); + } return true; } return false; diff --git a/src/main/java/appeng/block/misc/BlockInterface.java b/src/main/java/appeng/block/misc/BlockInterface.java index 561062bf..c0f32388 100644 --- a/src/main/java/appeng/block/misc/BlockInterface.java +++ b/src/main/java/appeng/block/misc/BlockInterface.java @@ -56,13 +56,17 @@ public class BlockInterface extends AEBaseBlock public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileInterface tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_INTERFACE ); + } return true; } return false; diff --git a/src/main/java/appeng/block/misc/BlockLightDetector.java b/src/main/java/appeng/block/misc/BlockLightDetector.java index 016a6021..cf792030 100644 --- a/src/main/java/appeng/block/misc/BlockLightDetector.java +++ b/src/main/java/appeng/block/misc/BlockLightDetector.java @@ -46,7 +46,9 @@ public class BlockLightDetector extends BlockQuartzTorch public int isProvidingWeakPower( IBlockAccess w, int x, int y, int z, int side ) { if( w instanceof World && ( (TileLightDetector) this.getTileEntity( w, x, y, z ) ).isReady() ) + { return ( (World) w ).getBlockLightValue( x, y, z ) - 6; + } return 0; } @@ -58,7 +60,9 @@ public class BlockLightDetector extends BlockQuartzTorch TileLightDetector tld = this.getTileEntity( world, x, y, z ); if( tld != null ) + { tld.updateLight(); + } } @Override diff --git a/src/main/java/appeng/block/misc/BlockPaint.java b/src/main/java/appeng/block/misc/BlockPaint.java index e69cbab3..0de12959 100644 --- a/src/main/java/appeng/block/misc/BlockPaint.java +++ b/src/main/java/appeng/block/misc/BlockPaint.java @@ -88,7 +88,9 @@ public class BlockPaint extends AEBaseBlock TilePaint tp = this.getTileEntity( w, x, y, z ); if( tp != null ) + { tp.onNeighborBlockChange(); + } } @Override @@ -107,7 +109,9 @@ public class BlockPaint extends AEBaseBlock public void fillWithRain( World w, int x, int y, int z ) { if( Platform.isServer() ) + { w.setBlock( x, y, z, Platform.AIR, 0, 3 ); + } } @Override diff --git a/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java b/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java index 811e8acd..df165038 100644 --- a/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java +++ b/src/main/java/appeng/block/misc/BlockQuartzGrowthAccelerator.java @@ -68,7 +68,9 @@ public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrient public void randomDisplayTick( World w, int x, int y, int z, Random r ) { if( !AEConfig.instance.enableEffects ) + { return; + } TileQuartzGrowthAccelerator tileQuartzGrowthAccelerator = this.getTileEntity( w, x, y, z ); @@ -98,25 +100,33 @@ public class BlockQuartzGrowthAccelerator extends AEBaseBlock implements IOrient dx = 0.6; dz = d1; if( !w.getBlock( x + west.offsetX, y + west.offsetY, z + west.offsetZ ).isAir( w, x + west.offsetX, y + west.offsetY, z + west.offsetZ ) ) + { return; + } break; case 1: dx = d1; dz += 0.6; if( !w.getBlock( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ).isAir( w, x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ ) ) + { return; + } break; case 2: dx = d1; dz = -0.6; if( !w.getBlock( x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ).isAir( w, x - forward.offsetX, y - forward.offsetY, z - forward.offsetZ ) ) + { return; + } break; case 3: dx = -0.6; dz = d1; if( !w.getBlock( x - west.offsetX, y - west.offsetY, z - west.offsetZ ).isAir( w, x - west.offsetX, y - west.offsetY, z - west.offsetZ ) ) + { return; + } break; } diff --git a/src/main/java/appeng/block/misc/BlockQuartzTorch.java b/src/main/java/appeng/block/misc/BlockQuartzTorch.java index 34e42bdd..b5a50175 100644 --- a/src/main/java/appeng/block/misc/BlockQuartzTorch.java +++ b/src/main/java/appeng/block/misc/BlockQuartzTorch.java @@ -107,10 +107,14 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I public void randomDisplayTick( World w, int x, int y, int z, Random r ) { if( !AEConfig.instance.enableEffects ) + { return; + } if( r.nextFloat() < 0.98 ) + { return; + } ForgeDirection up = this.getOrientable( w, x, y, z ).getUp(); double xOff = -0.3 * up.offsetX; @@ -132,7 +136,9 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I { ForgeDirection up = this.getOrientable( w, x, y, z ).getUp(); if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) ) + { this.dropTorch( w, x, y, z ); + } } private void dropTorch( World w, int x, int y, int z ) @@ -146,8 +152,12 @@ public class BlockQuartzTorch extends AEBaseBlock implements IOrientableBlock, I public boolean canPlaceBlockAt( World w, int x, int y, int z ) { for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS ) + { if( this.canPlaceAt( w, x, y, z, dir ) ) + { return true; + } + } return false; } diff --git a/src/main/java/appeng/block/misc/BlockSecurity.java b/src/main/java/appeng/block/misc/BlockSecurity.java index 8c903ba0..4ec47bb5 100644 --- a/src/main/java/appeng/block/misc/BlockSecurity.java +++ b/src/main/java/appeng/block/misc/BlockSecurity.java @@ -55,13 +55,17 @@ public class BlockSecurity extends AEBaseBlock public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileSecurity tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SECURITY ); return true; diff --git a/src/main/java/appeng/block/misc/BlockSkyCompass.java b/src/main/java/appeng/block/misc/BlockSkyCompass.java index 0c17f8bd..411c7cde 100644 --- a/src/main/java/appeng/block/misc/BlockSkyCompass.java +++ b/src/main/java/appeng/block/misc/BlockSkyCompass.java @@ -80,7 +80,9 @@ public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision { TileSkyCompass sc = this.getTileEntity( w, x, y, z ); if( sc != null ) + { return false; + } return this.canPlaceAt( w, x, y, z, forward.getOpposite() ); } @@ -95,7 +97,9 @@ public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision TileSkyCompass sc = this.getTileEntity( w, x, y, z ); ForgeDirection up = sc.getForward(); if( !this.canPlaceAt( w, x, y, z, up.getOpposite() ) ) + { this.dropTorch( w, x, y, z ); + } } private void dropTorch( World w, int x, int y, int z ) @@ -109,8 +113,12 @@ public class BlockSkyCompass extends AEBaseBlock implements ICustomCollision public boolean canPlaceBlockAt( World w, int x, int y, int z ) { for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS ) + { if( this.canPlaceAt( w, x, y, z, dir ) ) + { return true; + } + } return false; } diff --git a/src/main/java/appeng/block/misc/BlockVibrationChamber.java b/src/main/java/appeng/block/misc/BlockVibrationChamber.java index 27489b36..574aaaf7 100644 --- a/src/main/java/appeng/block/misc/BlockVibrationChamber.java +++ b/src/main/java/appeng/block/misc/BlockVibrationChamber.java @@ -68,7 +68,9 @@ public class BlockVibrationChamber extends AEBaseBlock public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ ) { if( player.isSneaking() ) + { return false; + } if( Platform.isServer() ) { @@ -87,7 +89,9 @@ public class BlockVibrationChamber extends AEBaseBlock public void randomDisplayTick( World w, int x, int y, int z, Random r ) { if( !AEConfig.instance.enableEffects ) + { return; + } AEBaseTile tile = this.getTileEntity( w, x, y, z ); if( tile instanceof TileVibrationChamber ) diff --git a/src/main/java/appeng/block/networking/BlockCableBus.java b/src/main/java/appeng/block/networking/BlockCableBus.java index 36b6551b..426e62d2 100644 --- a/src/main/java/appeng/block/networking/BlockCableBus.java +++ b/src/main/java/appeng/block/networking/BlockCableBus.java @@ -119,7 +119,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection public int getRenderBlockPass() { if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) ) + { return 1; + } return 0; } @@ -162,7 +164,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection return block.getLightValue( world, x, y, z ); } if( block == null ) + { return 0; + } return this.cb( world, x, y, z ).getLightValue(); } @@ -192,7 +196,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection { AEBaseTile tile = this.getTileEntity( world, x, y, z ); if( tile != null ) + { tile.disableDrops(); + } // maybe ray trace? } return super.removedByPlayer( world, player, x, y, z ); @@ -224,7 +230,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection BusRenderHelper.INSTANCE.setPass( pass ); if( AEConfig.instance.isFeatureEnabled( AEFeature.AlphaPass ) ) + { return true; + } return pass == 0; } @@ -236,9 +244,13 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection SelectedPart sp = this.cb( world, x, y, z ).selectPart( v3 ); if( sp.part != null ) + { return sp.part.getItemStack( PartItemStack.Pick ); + } else if( sp.facade != null ) + { return sp.facade.getItemStack(); + } return null; } @@ -258,7 +270,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection IIcon ico = this.getIcon( p ); if( ico == null ) + { continue; + } byte b0 = (byte) ( Platform.getRandomInt() % 2 == 0 ? 1 : 0 ); @@ -304,7 +318,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection IIcon ico = this.getIcon( p ); if( ico == null ) + { continue; + } byte b0 = 3; @@ -335,19 +351,25 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection public void onNeighborChange( IBlockAccess w, int x, int y, int z, int tileX, int tileY, int tileZ ) { if( Platform.isServer() ) + { this.cb( w, x, y, z ).onNeighborChanged(); + } } private IIcon getIcon( IPart p ) { if( p == null ) + { return null; + } try { IIcon ico = p.getBreakingTexture(); if( ico != null ) + { return ico; + } } catch( Throwable t ) { @@ -356,7 +378,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection ItemStack is = p.getItemStack( PartItemStack.Network ); if( is == null || is.getItem() == null ) + { return null; + } return is.getItem().getIcon( is, 0 ); } @@ -367,10 +391,13 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection ICableBusContainer out = null; if( te instanceof TileCableBus ) + { out = ( (TileCableBus) te ).cb; - + } else if( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) + { out = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getCableContainer( te ); + } return out == null ? NULL_CABLE_BUS : out; } @@ -392,7 +419,9 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection { IIcon i = super.getIcon( direction, metadata ); if( i != null ) + { return i; + } return ExtraBlockTextures.BlockQuartzGlassB.getIcon(); } @@ -440,10 +469,14 @@ public class BlockCableBus extends AEBaseBlock implements IRedNetConnection TileEntity te = w.getTileEntity( x, y, z ); if( noTesrTile.isInstance( te ) ) + { return (T) te; + } if( tesrTile != null && tesrTile.isInstance( te ) ) + { return (T) te; + } return null; } diff --git a/src/main/java/appeng/block/networking/BlockController.java b/src/main/java/appeng/block/networking/BlockController.java index 23a7b1ae..cfe1b602 100644 --- a/src/main/java/appeng/block/networking/BlockController.java +++ b/src/main/java/appeng/block/networking/BlockController.java @@ -48,7 +48,9 @@ public class BlockController extends AEBaseBlock { TileController tc = this.getTileEntity( w, x, y, z ); if( tc != null ) + { tc.onNeighborChange( false ); + } } @Override diff --git a/src/main/java/appeng/block/networking/BlockWireless.java b/src/main/java/appeng/block/networking/BlockWireless.java index d6c0d2ff..105764ec 100644 --- a/src/main/java/appeng/block/networking/BlockWireless.java +++ b/src/main/java/appeng/block/networking/BlockWireless.java @@ -63,13 +63,17 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileWireless tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_WIRELESS ); + } return true; } return false; @@ -197,6 +201,8 @@ public class BlockWireless extends AEBaseBlock implements ICustomCollision out.add( AxisAlignedBB.getBoundingBox( minX, minY, minZ, maxX, maxY, maxZ ) ); } else + { out.add( AxisAlignedBB.getBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ) ); + } } } diff --git a/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java b/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java index 5735183d..d0886fda 100644 --- a/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java +++ b/src/main/java/appeng/block/qnb/BlockQuantumLinkChamber.java @@ -71,7 +71,9 @@ public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomColli if( bridge.hasQES() ) { if( CommonHelper.proxy.shouldAddParticles( r ) ) + { CommonHelper.proxy.spawnEffect( EffectType.Energy, w, bx + 0.5, by + 0.5, bz + 0.5, null ); + } } } } @@ -81,7 +83,9 @@ public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomColli { TileQuantumBridge bridge = this.getTileEntity( w, x, y, z ); if( bridge != null ) + { bridge.neighborUpdate(); + } } @Override @@ -94,13 +98,17 @@ public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomColli public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileQuantumBridge tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_QNB ); + } return true; } return false; @@ -111,7 +119,9 @@ public class BlockQuantumLinkChamber extends AEBaseBlock implements ICustomColli { TileQuantumBridge bridge = this.getTileEntity( w, x, y, z ); if( bridge != null ) + { bridge.breakCluster(); + } super.breakBlock( w, x, y, z, a, b ); } diff --git a/src/main/java/appeng/block/qnb/BlockQuantumRing.java b/src/main/java/appeng/block/qnb/BlockQuantumRing.java index 90751d3d..807903dc 100644 --- a/src/main/java/appeng/block/qnb/BlockQuantumRing.java +++ b/src/main/java/appeng/block/qnb/BlockQuantumRing.java @@ -56,7 +56,9 @@ public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision { TileQuantumBridge bridge = this.getTileEntity( w, x, y, z ); if( bridge != null ) + { bridge.neighborUpdate(); + } } @Override @@ -70,7 +72,9 @@ public class BlockQuantumRing extends AEBaseBlock implements ICustomCollision { TileQuantumBridge bridge = this.getTileEntity( w, x, y, z ); if( bridge != null ) + { bridge.breakCluster(); + } super.breakBlock( w, x, y, z, a, b ); } diff --git a/src/main/java/appeng/block/solids/BlockQuartzGlass.java b/src/main/java/appeng/block/solids/BlockQuartzGlass.java index 235bc211..4b2c065a 100644 --- a/src/main/java/appeng/block/solids/BlockQuartzGlass.java +++ b/src/main/java/appeng/block/solids/BlockQuartzGlass.java @@ -64,7 +64,9 @@ public class BlockQuartzGlass extends AEBaseBlock if( mat == Material.glass || mat == AEGlassMaterial.INSTANCE ) { if( w.getBlock( x, y, z ).getRenderType() == this.getRenderType() ) + { return false; + } } return super.shouldSideBeRendered( w, x, y, z, side ); } diff --git a/src/main/java/appeng/block/solids/BlockQuartzLamp.java b/src/main/java/appeng/block/solids/BlockQuartzLamp.java index 1d1deba2..647c5a02 100644 --- a/src/main/java/appeng/block/solids/BlockQuartzLamp.java +++ b/src/main/java/appeng/block/solids/BlockQuartzLamp.java @@ -50,7 +50,9 @@ public class BlockQuartzLamp extends BlockQuartzGlass public void randomDisplayTick( World w, int x, int y, int z, Random r ) { if( !AEConfig.instance.enableEffects ) + { return; + } if( CommonHelper.proxy.shouldAddParticles( r ) ) { diff --git a/src/main/java/appeng/block/solids/BlockSkyStone.java b/src/main/java/appeng/block/solids/BlockSkyStone.java index 4a9793bc..5c0cdc16 100644 --- a/src/main/java/appeng/block/solids/BlockSkyStone.java +++ b/src/main/java/appeng/block/solids/BlockSkyStone.java @@ -90,10 +90,14 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock int level = -1; if( is != null ) + { level = is.getItem().getHarvestLevel( is, "pickaxe" ); + } if( Ev.metadata > 0 || level >= 3 || Ev.originalSpeed > 7.0 ) + { Ev.newSpeed /= 0.1; + } } } @@ -117,7 +121,9 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock { super.onBlockAdded( w, x, y, z ); if( Platform.isServer() ) + { WorldSettings.getInstance().getCompass().updateArea( w, x, y, z ); + } } // use AE2's renderer, no rotatable blocks. @@ -142,12 +148,16 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock { IOrientable out = ( (IRB) AppEng.instance.getIntegration( IntegrationType.RB ) ).getOrientable( te ); if( out != null ) + { return out; + } } } if( w.getBlockMetadata( x, y, z ) == 0 ) + { return new LocationRotation( w, x, y, z ); + } return new NullRotation(); } @@ -156,13 +166,19 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock public String getUnlocalizedName( ItemStack is ) { if( is.getItemDamage() == 1 ) + { return this.getUnlocalizedName() + ".Block"; + } if( is.getItemDamage() == 2 ) + { return this.getUnlocalizedName() + ".Brick"; + } if( is.getItemDamage() == 3 ) + { return this.getUnlocalizedName() + ".SmallBrick"; + } return this.getUnlocalizedName(); } @@ -182,11 +198,17 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock public IIcon getIcon( int direction, int metadata ) { if( metadata == 1 ) + { return this.Block; + } if( metadata == 2 ) + { return this.Brick; + } if( metadata == 3 ) + { return this.SmallBrick; + } return super.getIcon( direction, metadata ); } @@ -212,6 +234,8 @@ public class BlockSkyStone extends AEBaseBlock implements IOrientableBlock { super.breakBlock( w, x, y, z, b, WTF ); if( Platform.isServer() ) + { WorldSettings.getInstance().getCompass().updateArea( w, x, y, z ); + } } } diff --git a/src/main/java/appeng/block/solids/OreQuartz.java b/src/main/java/appeng/block/solids/OreQuartz.java index 913fdc6c..cd1d00d8 100644 --- a/src/main/java/appeng/block/solids/OreQuartz.java +++ b/src/main/java/appeng/block/solids/OreQuartz.java @@ -91,7 +91,9 @@ public class OreQuartz extends AEBaseBlock } if( j1 > 15 ) + { j1 = 15; + } return j1 << 20 | j1 << 4; } return j1; diff --git a/src/main/java/appeng/block/solids/OreQuartzCharged.java b/src/main/java/appeng/block/solids/OreQuartzCharged.java index d074c3d6..ca6c87be 100644 --- a/src/main/java/appeng/block/solids/OreQuartzCharged.java +++ b/src/main/java/appeng/block/solids/OreQuartzCharged.java @@ -20,7 +20,6 @@ package appeng.block.solids; import java.util.Random; - import javax.annotation.Nullable; import net.minecraft.client.Minecraft; @@ -76,7 +75,9 @@ public class OreQuartzCharged extends OreQuartz public void randomDisplayTick( World w, int x, int y, int z, Random r ) { if ( !AEConfig.instance.enableEffects ) + { return; + } double xOff = ( r.nextFloat() ); double yOff = ( r.nextFloat() ); diff --git a/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java b/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java index 3282486d..00427594 100644 --- a/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java +++ b/src/main/java/appeng/block/spatial/BlockSpatialIOPort.java @@ -49,20 +49,26 @@ public class BlockSpatialIOPort extends AEBaseBlock { TileSpatialIOPort te = this.getTileEntity( w, x, y, z ); if( te != null ) + { te.updateRedstoneState(); + } } @Override public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileSpatialIOPort tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_SPATIAL_IO_PORT ); + } return true; } return false; diff --git a/src/main/java/appeng/block/spatial/BlockSpatialPylon.java b/src/main/java/appeng/block/spatial/BlockSpatialPylon.java index 2c46055b..7949f39d 100644 --- a/src/main/java/appeng/block/spatial/BlockSpatialPylon.java +++ b/src/main/java/appeng/block/spatial/BlockSpatialPylon.java @@ -48,7 +48,9 @@ public class BlockSpatialPylon extends AEBaseBlock { TileSpatialPylon tsp = this.getTileEntity( w, x, y, z ); if( tsp != null ) + { tsp.onNeighborBlockChange(); + } } @Override @@ -56,7 +58,9 @@ public class BlockSpatialPylon extends AEBaseBlock { TileSpatialPylon tsp = this.getTileEntity( w, x, y, z ); if( tsp != null ) + { return tsp.getLightValue(); + } return super.getLightValue( w, x, y, z ); } diff --git a/src/main/java/appeng/block/storage/BlockChest.java b/src/main/java/appeng/block/storage/BlockChest.java index 19473101..e26f4e06 100644 --- a/src/main/java/appeng/block/storage/BlockChest.java +++ b/src/main/java/appeng/block/storage/BlockChest.java @@ -62,7 +62,9 @@ public class BlockChest extends AEBaseBlock if( tg != null && !p.isSneaking() ) { if( Platform.isClient() ) + { return true; + } if( side != tg.getUp().ordinal() ) { @@ -78,7 +80,9 @@ public class BlockChest extends AEBaseBlock tg.openGui( p, ch, cell, side ); } else + { p.addChatMessage( PlayerMessages.ChestCannotReadStorageCell.get() ); + } } return true; diff --git a/src/main/java/appeng/block/storage/BlockDrive.java b/src/main/java/appeng/block/storage/BlockDrive.java index 9f0c60f5..5fd7a9c7 100644 --- a/src/main/java/appeng/block/storage/BlockDrive.java +++ b/src/main/java/appeng/block/storage/BlockDrive.java @@ -55,13 +55,17 @@ public class BlockDrive extends AEBaseBlock public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileDrive tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_DRIVE ); + } return true; } return false; diff --git a/src/main/java/appeng/block/storage/BlockIOPort.java b/src/main/java/appeng/block/storage/BlockIOPort.java index 63d7f5d3..6a396789 100644 --- a/src/main/java/appeng/block/storage/BlockIOPort.java +++ b/src/main/java/appeng/block/storage/BlockIOPort.java @@ -49,20 +49,26 @@ public class BlockIOPort extends AEBaseBlock { TileIOPort te = this.getTileEntity( w, x, y, z ); if( te != null ) + { te.updateRedstoneState(); + } } @Override public boolean onActivated( World w, int x, int y, int z, EntityPlayer p, int side, float hitX, float hitY, float hitZ ) { if( p.isSneaking() ) + { return false; + } TileIOPort tg = this.getTileEntity( w, x, y, z ); if( tg != null ) { if( Platform.isServer() ) + { Platform.openGUI( p, tg, ForgeDirection.getOrientation( side ), GuiBridge.GUI_IOPORT ); + } return true; } return false; diff --git a/src/main/java/appeng/block/storage/BlockSkyChest.java b/src/main/java/appeng/block/storage/BlockSkyChest.java index 8afc192a..e42678fd 100644 --- a/src/main/java/appeng/block/storage/BlockSkyChest.java +++ b/src/main/java/appeng/block/storage/BlockSkyChest.java @@ -104,7 +104,9 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision public boolean onActivated( World w, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ ) { if( Platform.isServer() ) + { Platform.openGUI( player, this.getTileEntity( w, x, y, z ), ForgeDirection.getOrientation( side ), GuiBridge.GUI_SKYCHEST ); + } return true; } @@ -127,7 +129,9 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision public String getUnlocalizedName( ItemStack is ) { if( is.getItemDamage() == 1 ) + { return this.getUnlocalizedName() + ".Block"; + } return this.getUnlocalizedName(); } @@ -140,7 +144,9 @@ public class BlockSkyChest extends AEBaseBlock implements ICustomCollision ForgeDirection o = ForgeDirection.UNKNOWN; if( sk != null ) + { o = sk.getUp(); + } double X = o.offsetX == 0 ? 0.06 : 0.0; double Y = o.offsetY == 0 ? 0.06 : 0.0; diff --git a/src/main/java/appeng/client/ClientHelper.java b/src/main/java/appeng/client/ClientHelper.java index 4a706292..1afa6651 100644 --- a/src/main/java/appeng/client/ClientHelper.java +++ b/src/main/java/appeng/client/ClientHelper.java @@ -119,9 +119,13 @@ public class ClientHelper extends ServerHelper public World getWorld() { if( Platform.isClient() ) + { return Minecraft.getMinecraft().theWorld; + } else + { return super.getWorld(); + } } @Override @@ -129,7 +133,9 @@ public class ClientHelper extends ServerHelper { BaseBlockRender bbr = blk.getRendererInstance().rendererInstance; if( bbr.hasTESR() && tile != null ) + { ClientRegistry.bindTileEntitySpecialRenderer( tile, new TESRWrapper( bbr ) ); + } } @Override @@ -142,7 +148,9 @@ public class ClientHelper extends ServerHelper return o; } else + { return super.getPlayers(); + } } @Override @@ -243,9 +251,13 @@ public class ClientHelper extends ServerHelper { int setting = Minecraft.getMinecraft().gameSettings.particleSetting; if( setting == 2 ) + { return false; + } if( setting == 0 ) + { return true; + } return r.nextInt( 2 * ( setting + 1 ) ) == 0; } @@ -347,7 +359,9 @@ public class ClientHelper extends ServerHelper public CableRenderMode getRenderMode() { if( Platform.isServer() ) + { return super.getRenderMode(); + } Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.thePlayer; @@ -360,7 +374,9 @@ public class ClientHelper extends ServerHelper { Minecraft mc = Minecraft.getMinecraft(); if( mc == null || mc.thePlayer == null || mc.theWorld == null ) + { return; + } EntityPlayer player = mc.thePlayer; @@ -383,7 +399,9 @@ public class ClientHelper extends ServerHelper public void wheelEvent( MouseEvent me ) { if( me.isCanceled() || me.dwheel == 0 ) + { return; + } Minecraft mc = Minecraft.getMinecraft(); EntityPlayer player = mc.thePlayer; @@ -409,16 +427,22 @@ public class ClientHelper extends ServerHelper if( ev.map.getTextureType() == 1 ) { for( ExtraItemTextures et : ExtraItemTextures.values() ) + { et.registerIcon( ev.map ); + } } if( ev.map.getTextureType() == 0 ) { for( ExtraBlockTextures et : ExtraBlockTextures.values() ) + { et.registerIcon( ev.map ); + } for( CableBusTextures cb : CableBusTextures.values() ) + { cb.registerIcon( ev.map ); + } } } } \ No newline at end of file diff --git a/src/main/java/appeng/client/gui/AEBaseGui.java b/src/main/java/appeng/client/gui/AEBaseGui.java index a8e0edfb..93640134 100644 --- a/src/main/java/appeng/client/gui/AEBaseGui.java +++ b/src/main/java/appeng/client/gui/AEBaseGui.java @@ -136,11 +136,17 @@ public abstract class AEBaseGui extends GuiContainer final List slots = this.getInventorySlots(); Iterator i = slots.iterator(); while( i.hasNext() ) + { if( i.next() instanceof SlotME ) + { i.remove(); + } + } for( InternalSlotME me : this.meSlots ) + { slots.add( new SlotME( me ) ); + } } @SuppressWarnings( "unchecked" ) @@ -156,7 +162,9 @@ public abstract class AEBaseGui extends GuiContainer boolean hasClicked = Mouse.isButtonDown( 0 ); if( hasClicked && this.myScrollBar != null ) + { this.myScrollBar.click( this, mouse_x - this.guiLeft, mouse_y - this.guiTop ); + } for( Object c : this.buttonList ) { @@ -171,11 +179,15 @@ public abstract class AEBaseGui extends GuiContainer if( y < mouse_y && y + tooltip.getHeight() > mouse_y ) { if( y < 15 ) + { y = 15; + } String msg = tooltip.getMessage(); if( msg != null ) + { this.drawTooltip( x + 11, y + 4, 0, msg ); + } } } } @@ -222,7 +234,9 @@ public abstract class AEBaseGui extends GuiContainer } if( forceWidth > 0 ) + { var5 = forceWidth; + } this.zLevel = 300.0F; itemRender.zLevel = 300.0F; @@ -276,7 +290,9 @@ public abstract class AEBaseGui extends GuiContainer GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F ); if( this.myScrollBar != null ) + { this.myScrollBar.draw( this ); + } this.drawFG( ox, oy, x, y ); } @@ -357,7 +373,9 @@ public abstract class AEBaseGui extends GuiContainer } } else + { super.mouseClickMove( x, y, c, d ); + } } @Override @@ -370,7 +388,9 @@ public abstract class AEBaseGui extends GuiContainer final InventoryAction action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACE_SINGLE : InventoryAction.PICKUP_OR_SET_DOWN; if( this.drag_click.size() > 1 ) + { return; + } PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 ); NetworkHandler.instance.sendToServer( p ); @@ -381,7 +401,9 @@ public abstract class AEBaseGui extends GuiContainer if( slot instanceof SlotPatternTerm ) { if( key == 6 ) + { return; // prevent weird double clicks.. + } try { @@ -395,13 +417,19 @@ public abstract class AEBaseGui extends GuiContainer else if( slot instanceof SlotCraftingTerm ) { if( key == 6 ) + { return; // prevent weird double clicks.. + } InventoryAction action = null; if( key == 1 ) + { action = InventoryAction.CRAFT_SHIFT; + } else + { action = ctrlDown == 1 ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM; + } PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 ); NetworkHandler.instance.sendToServer( p ); @@ -415,12 +443,16 @@ public abstract class AEBaseGui extends GuiContainer { IAEItemStack stack = null; if( slot instanceof SlotME ) + { stack = ( (SlotME) slot ).getAEStack(); + } int slotNum = this.getInventorySlots().size(); if( !( slot instanceof SlotME ) && slot != null ) + { slotNum = slot.slotNumber; + } ( (AEBaseContainer) this.inventorySlots ).setTargetStack( stack ); PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 ); @@ -477,7 +509,9 @@ public abstract class AEBaseGui extends GuiContainer stack = ( (SlotME) slot ).getAEStack(); if( stack != null && action == InventoryAction.PICKUP_OR_SET_DOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null ) + { action = InventoryAction.AUTO_CRAFT; + } break; case 1: @@ -489,8 +523,9 @@ public abstract class AEBaseGui extends GuiContainer stack = ( (SlotME) slot ).getAEStack(); if( stack != null && stack.isCraftable() ) + { action = InventoryAction.AUTO_CRAFT; - + } else if( player.capabilities.isCreativeMode ) { IAEItemStack slotItem = ( (SlotME) slot ).getAEStack(); @@ -526,9 +561,13 @@ public abstract class AEBaseGui extends GuiContainer this.bl_clicked = slot; this.dbl_clickTimer = Stopwatch.createStarted(); if( slot != null ) + { this.dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : null; + } else + { this.dbl_whichItem = null; + } } else if( this.dbl_whichItem != null ) { @@ -642,7 +681,9 @@ public abstract class AEBaseGui extends GuiContainer this.mouseWheelEvent( x, y, i / Math.abs( i ) ); } else if( i != 0 && this.myScrollBar != null ) + { this.myScrollBar.wheel( i ); + } } protected void mouseWheelEvent( int x, int y, int wheel ) @@ -702,7 +743,9 @@ public abstract class AEBaseGui extends GuiContainer private boolean hasCustomInventoryName() { if( this.inventorySlots instanceof AEBaseContainer ) + { return ( (AEBaseContainer) this.inventorySlots ).customName != null; + } return false; } @@ -835,7 +878,9 @@ public abstract class AEBaseGui extends GuiContainer this.safeDrawSlot( s ); } else + { this.safeDrawSlot( s ); + } return; } diff --git a/src/main/java/appeng/client/gui/AEBaseMEGui.java b/src/main/java/appeng/client/gui/AEBaseMEGui.java index 75dc0dc9..8b04675d 100644 --- a/src/main/java/appeng/client/gui/AEBaseMEGui.java +++ b/src/main/java/appeng/client/gui/AEBaseMEGui.java @@ -121,10 +121,14 @@ public abstract class AEBaseMEGui extends AEBaseGui List currentToolTip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips ); if( myStack.getStackSize() > BigNumber || ( myStack.getStackSize() > 1 && stack.isItemDamaged() ) ) + { currentToolTip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) ); + } if( myStack.getCountRequestable() > 0 ) + { currentToolTip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) ); + } this.drawTooltip( x, y, 0, join( currentToolTip, "\n" ) ); } diff --git a/src/main/java/appeng/client/gui/config/AEConfigGui.java b/src/main/java/appeng/client/gui/config/AEConfigGui.java index ff19afb9..34bf74f4 100644 --- a/src/main/java/appeng/client/gui/config/AEConfigGui.java +++ b/src/main/java/appeng/client/gui/config/AEConfigGui.java @@ -48,15 +48,21 @@ public class AEConfigGui extends GuiConfig for( String cat : AEConfig.instance.getCategoryNames() ) { if( cat.equals( "versionchecker" ) ) + { continue; + } if( cat.equals( "settings" ) ) + { continue; + } ConfigCategory cc = AEConfig.instance.getCategory( cat ); if( cc.isChild() ) + { continue; + } ConfigElement ce = new ConfigElement( cc ); list.add( ce ); diff --git a/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java b/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java index 8ef12c64..0d984c79 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCellWorkbench.java @@ -98,9 +98,13 @@ public class GuiCellWorkbench extends GuiUpgradeable int dx = this.workbench.availableUpgrades() - 8; this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18 ); if( dx == 8 ) + { this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7 ); + } else + { this.drawTexturedModalRect( offsetX + 177 + 27 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7 ); + } } else { @@ -113,13 +117,19 @@ public class GuiCellWorkbench extends GuiUpgradeable int dx = this.workbench.availableUpgrades() - 16; this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18 ); if( dx == 8 ) + { this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY + ( 7 + ( dx ) * 18 ), 186, 151, 35 - 8, 7 ); + } else + { this.drawTexturedModalRect( offsetX + 177 + 27 + 18 + 4, offsetY + ( 7 + ( dx ) * 18 ), 186 + 4, 151, 35 - 8, 7 ); + } } } if( this.hasToolbox() ) + { this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, 161, 68, 68 ); + } } @Override @@ -135,7 +145,9 @@ public class GuiCellWorkbench extends GuiUpgradeable if( is != null && is.getItem() instanceof IUpgradeModule ) { if( ( (IUpgradeModule) is.getItem() ).getType( is ) == Upgrades.FUZZY ) + { hasFuzzy = true; + } } } this.fuzzyMode.setVisibility( hasFuzzy ); @@ -186,7 +198,9 @@ public class GuiCellWorkbench extends GuiUpgradeable NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) ); } else + { super.actionPerformed( btn ); + } } catch( IOException ignored ) { diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java index 672ecf74..a2641cbc 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java @@ -197,10 +197,14 @@ public class GuiCraftAmount extends AEBaseGui } if( fixed ) + { this.amountToCraft.setText( out ); + } if( out.length() == 0 ) + { out = "0"; + } long result = Long.parseLong( out ); if( result < 0 ) @@ -248,7 +252,9 @@ public class GuiCraftAmount extends AEBaseGui boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; if( isPlus || isMinus ) + { this.addQty( this.getQty( btn ) ); + } } private void addQty( int i ) @@ -265,19 +271,27 @@ public class GuiCraftAmount extends AEBaseGui } if( fixed ) + { this.amountToCraft.setText( out ); + } if( out.length() == 0 ) + { out = "0"; + } long result = Integer.parseInt( out ); if( result == 1 && i > 1 ) + { result = 0; + } result += i; if( result < 1 ) + { result = 1; + } out = Long.toString( result ); Integer.parseInt( out ); diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java index bc11251c..58c760b6 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java @@ -84,16 +84,24 @@ public class GuiCraftConfirm extends AEBaseGui this.ccc = (ContainerCraftConfirm) this.inventorySlots; if( te instanceof WirelessTerminalGuiObject ) + { this.OriginalGui = GuiBridge.GUI_WIRELESS_TERM; + } if( te instanceof PartTerminal ) + { this.OriginalGui = GuiBridge.GUI_ME; + } if( te instanceof PartCraftingTerminal ) + { this.OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL; + } if( te instanceof PartPatternTerminal ) + { this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL; + } } boolean isAutoStart() @@ -115,7 +123,9 @@ public class GuiCraftConfirm extends AEBaseGui this.buttonList.add( this.selectCPU ); if( this.OriginalGui != null ) + { this.cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + this.ySize - 25, 50, 20, GuiText.Cancel.getLocal() ); + } this.buttonList.add( this.cancel ); } @@ -174,11 +184,15 @@ public class GuiCraftConfirm extends AEBaseGui btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name; } else + { btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + this.ccc.selectedCpu; + } } if( this.ccc.noCPU ) + { btnTextText = GuiText.NoCraftingCPUs.getLocal(); + } this.selectCPU.displayString = btnTextText; } @@ -199,9 +213,13 @@ public class GuiCraftConfirm extends AEBaseGui String dsp = null; if( this.isSimulation() ) + { dsp = GuiText.Simulation.getLocal(); + } else + { dsp = this.ccc.cpuBytesAvail > 0 ? ( GuiText.Bytes.getLocal() + ": " + this.ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + this.ccc.cpuCoProcessors ) : GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A"; + } int offset = ( 219 - this.fontRendererObj.getStringWidth( dsp ) ) / 2; this.fontRendererObj.drawString( dsp, offset, 165, 4210752 ); @@ -237,11 +255,17 @@ public class GuiCraftConfirm extends AEBaseGui int lines = 0; if( stored != null && stored.getStackSize() > 0 ) + { lines++; + } if( pendingStack != null && pendingStack.getStackSize() > 0 ) + { lines++; + } if( pendingStack != null && pendingStack.getStackSize() > 0 ) + { lines++; + } int negY = ( ( lines - 1 ) * 5 ) / 2; int downY = 0; @@ -251,16 +275,22 @@ public class GuiCraftConfirm extends AEBaseGui { String str = Long.toString( stored.getStackSize() ); if( stored.getStackSize() >= 10000 ) + { str = Long.toString( stored.getStackSize() / 1000 ) + 'k'; + } if( stored.getStackSize() >= 10000000 ) + { str = Long.toString( stored.getStackSize() / 1000000 ) + 'm'; + } str = GuiText.FromStorage.getLocal() + ": " + str; int w = 4 + this.fontRendererObj.getStringWidth( str ); this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); if( this.tooltip == z - viewStart ) + { lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) ); + } downY += 5; } @@ -269,16 +299,22 @@ public class GuiCraftConfirm extends AEBaseGui { String str = Long.toString( missingStack.getStackSize() ); if( missingStack.getStackSize() >= 10000 ) + { str = Long.toString( missingStack.getStackSize() / 1000 ) + 'k'; + } if( missingStack.getStackSize() >= 10000000 ) + { str = Long.toString( missingStack.getStackSize() / 1000000 ) + 'm'; + } str = GuiText.Missing.getLocal() + ": " + str; int w = 4 + this.fontRendererObj.getStringWidth( str ); this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); if( this.tooltip == z - viewStart ) + { lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) ); + } red = true; downY += 5; @@ -288,16 +324,22 @@ public class GuiCraftConfirm extends AEBaseGui { String str = Long.toString( pendingStack.getStackSize() ); if( pendingStack.getStackSize() >= 10000 ) + { str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k'; + } if( pendingStack.getStackSize() >= 10000000 ) + { str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm'; + } str = GuiText.ToCraft.getLocal() + ": " + str; int w = 4 + this.fontRendererObj.getStringWidth( str ); this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); if( this.tooltip == z - viewStart ) + { lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) ); + } } GL11.glPopMatrix(); @@ -311,7 +353,9 @@ public class GuiCraftConfirm extends AEBaseGui dspToolTip = Platform.getItemDisplayName( is ); if( lineList.size() > 0 ) + { dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList ); + } toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8; toolPosY = y * offY + yo; @@ -366,17 +410,23 @@ public class GuiCraftConfirm extends AEBaseGui { case 0: for( IAEItemStack l : list ) + { this.handleInput( this.storage, l ); + } break; case 1: for( IAEItemStack l : list ) + { this.handleInput( this.pending, l ); + } break; case 2: for( IAEItemStack l : list ) + { this.handleInput( this.missing, l ); + } break; } @@ -385,7 +435,9 @@ public class GuiCraftConfirm extends AEBaseGui long amt = this.getTotal( l ); if( amt <= 0 ) + { this.deleteVisualStack( l ); + } else { IAEItemStack is = this.findVisualStack( l ); @@ -403,7 +455,9 @@ public class GuiCraftConfirm extends AEBaseGui if( l.getStackSize() <= 0 ) { if( a != null ) + { a.reset(); + } } else { @@ -414,7 +468,9 @@ public class GuiCraftConfirm extends AEBaseGui } if( a != null ) + { a.setStackSize( l.getStackSize() ); + } } } @@ -427,13 +483,19 @@ public class GuiCraftConfirm extends AEBaseGui long total = 0; if( a != null ) + { total += a.getStackSize(); + } if( c != null ) + { total += c.getStackSize(); + } if( m != null ) + { total += m.getStackSize(); + } return total; } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java index 437abbdc..96b6a637 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingCPU.java @@ -228,16 +228,22 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource { String str = Long.toString( stored.getStackSize() ); if( stored.getStackSize() >= 10000 ) + { str = Long.toString( stored.getStackSize() / 1000 ) + 'k'; + } if( stored.getStackSize() >= 10000000 ) + { str = Long.toString( stored.getStackSize() / 1000000 ) + 'm'; + } str = GuiText.Stored.getLocal() + ": " + str; int w = 4 + this.fontRendererObj.getStringWidth( str ); this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); if( this.tooltip == z - viewStart ) + { lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) ); + } downY += 5; } @@ -246,16 +252,22 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource { String str = Long.toString( activeStack.getStackSize() ); if( activeStack.getStackSize() >= 10000 ) + { str = Long.toString( activeStack.getStackSize() / 1000 ) + 'k'; + } if( activeStack.getStackSize() >= 10000000 ) + { str = Long.toString( activeStack.getStackSize() / 1000000 ) + 'm'; + } str = GuiText.Crafting.getLocal() + ": " + str; int w = 4 + this.fontRendererObj.getStringWidth( str ); this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); if( this.tooltip == z - viewStart ) + { lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) ); + } downY += 5; } @@ -264,16 +276,22 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource { String str = Long.toString( pendingStack.getStackSize() ); if( pendingStack.getStackSize() >= 10000 ) + { str = Long.toString( pendingStack.getStackSize() / 1000 ) + 'k'; + } if( pendingStack.getStackSize() >= 10000000 ) + { str = Long.toString( pendingStack.getStackSize() / 1000000 ) + 'm'; + } str = GuiText.Scheduled.getLocal() + ": " + str; int w = 4 + this.fontRendererObj.getStringWidth( str ); this.fontRendererObj.drawString( str, (int) ( ( x * ( 1 + sectionLength ) + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * offY + yo + 6 - negY + downY ) * 2, 4210752 ); if( this.tooltip == z - viewStart ) + { lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) ); + } } GL11.glPopMatrix(); @@ -287,7 +305,9 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource dspToolTip = Platform.getItemDisplayName( is ); if( lineList.size() > 0 ) + { dspToolTip = dspToolTip + '\n' + Joiner.on( "\n" ).join( lineList ); + } toolPosX = x * ( 1 + sectionLength ) + xo + sectionLength - 8; toolPosY = y * offY + yo; @@ -326,17 +346,23 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource { case 0: for( IAEItemStack l : list ) + { this.handleInput( this.storage, l ); + } break; case 1: for( IAEItemStack l : list ) + { this.handleInput( this.active, l ); + } break; case 2: for( IAEItemStack l : list ) + { this.handleInput( this.pending, l ); + } break; } @@ -345,7 +371,9 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource long amt = this.getTotal( l ); if( amt <= 0 ) + { this.deleteVisualStack( l ); + } else { IAEItemStack is = this.findVisualStack( l ); @@ -363,7 +391,9 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource if( l.getStackSize() <= 0 ) { if( a != null ) + { a.reset(); + } } else { @@ -374,7 +404,9 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource } if( a != null ) + { a.setStackSize( l.getStackSize() ); + } } } @@ -387,13 +419,19 @@ public class GuiCraftingCPU extends AEBaseGui implements ISortSource long total = 0; if( a != null ) + { total += a.getStackSize(); + } if( b != null ) + { total += b.getStackSize(); + } if( c != null ) + { total += c.getStackSize(); + } return total; } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java index 46597364..728fcf19 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java @@ -166,11 +166,15 @@ public class GuiCraftingStatus extends GuiCraftingCPU btnTextText = GuiText.CPUs.getLocal() + ": " + name; } else + { btnTextText = GuiText.CPUs.getLocal() + ": #" + this.status.selectedCpu; + } } if( this.status.noCPU ) + { btnTextText = GuiText.NoCraftingJobs.getLocal(); + } this.selectCPU.displayString = btnTextText; } diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java index 99626433..9cf53c18 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingTerm.java @@ -59,7 +59,9 @@ public class GuiCraftingTerm extends GuiMEMonitorable for( Object j : c.inventorySlots ) { if( j instanceof SlotCraftingMatrix ) + { s = (Slot) j; + } } if( s != null ) diff --git a/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java b/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java index 6d839c9b..70e47062 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java +++ b/src/main/java/appeng/client/gui/implementations/GuiFormationPlane.java @@ -69,10 +69,14 @@ public class GuiFormationPlane extends GuiUpgradeable this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); if( this.fuzzyMode != null ) + { this.fuzzyMode.set( this.cvb.fzMode ); + } if( this.placeMode != null ) + { this.placeMode.set( ( (ContainerFormationPlane) this.cvb ).placeMode ); + } } @Override diff --git a/src/main/java/appeng/client/gui/implementations/GuiIOPort.java b/src/main/java/appeng/client/gui/implementations/GuiIOPort.java index 28ce0c9d..3f7fe8bb 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiIOPort.java +++ b/src/main/java/appeng/client/gui/implementations/GuiIOPort.java @@ -70,13 +70,19 @@ public class GuiIOPort extends GuiUpgradeable this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); if( this.redstoneMode != null ) + { this.redstoneMode.set( this.cvb.rsMode ); + } if( this.operationMode != null ) + { this.operationMode.set( ( (ContainerIOPort) this.cvb ).opMode ); + } if( this.fullMode != null ) + { this.fullMode.set( ( (ContainerIOPort) this.cvb ).fMode ); + } } @Override @@ -111,9 +117,13 @@ public class GuiIOPort extends GuiUpgradeable boolean backwards = Mouse.isButtonDown( 1 ); if( btn == this.fullMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) ); + } if( btn == this.operationMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) ); + } } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiInscriber.java b/src/main/java/appeng/client/gui/implementations/GuiInscriber.java index 56e30fe0..5f636610 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInscriber.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInscriber.java @@ -77,9 +77,13 @@ public class GuiInscriber extends AEBaseGui this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize ); if( this.drawUpgrades() ) + { this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvc.availableUpgrades() * 18 ); + } if( this.hasToolbox() ) + { this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 ); + } } protected boolean drawUpgrades() diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterface.java b/src/main/java/appeng/client/gui/implementations/GuiInterface.java index 92b8b7d9..d1273997 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterface.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterface.java @@ -68,10 +68,14 @@ public class GuiInterface extends GuiUpgradeable public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY ) { if( this.BlockMode != null ) + { this.BlockMode.set( ( (ContainerInterface) this.cvb ).bMode ); + } if( this.interfaceMode != null ) + { this.interfaceMode.setState( ( (ContainerInterface) this.cvb ).iTermMode == YesNo.YES ); + } this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 ); @@ -101,9 +105,13 @@ public class GuiInterface extends GuiUpgradeable } if( btn == this.interfaceMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) ); + } if( btn == this.BlockMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.BlockMode.getSetting(), backwards ) ); + } } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java index 659cc71f..e50c6ca1 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java +++ b/src/main/java/appeng/client/gui/implementations/GuiInterfaceTerminal.java @@ -105,7 +105,9 @@ public class GuiInterfaceTerminal extends AEBaseGui while( o.hasNext() ) { if( o.next() instanceof SlotDisconnected ) + { o.remove(); + } } for( int x = 0; x < LINES_ON_PAGE && ex + x < this.lines.size(); x++ ) @@ -124,10 +126,14 @@ public class GuiInterfaceTerminal extends AEBaseGui String name = (String) lineObj; int rows = this.byName.get( name ).size(); if( rows > 1 ) + { name = name + " (" + rows + ')'; + } while( name.length() > 2 && this.fontRendererObj.getStringWidth( name ) > 155 ) + { name = name.substring( 0, name.length() - 1 ); + } this.fontRendererObj.drawString( name, 10, 6 + offset, 4210752 ); } @@ -173,7 +179,9 @@ public class GuiInterfaceTerminal extends AEBaseGui } if( this.searchField != null ) + { this.searchField.drawTextBox(); + } } @Override @@ -182,7 +190,9 @@ public class GuiInterfaceTerminal extends AEBaseGui if( !this.checkHotbarKeys( key ) ) { if( character == ' ' && this.searchField.getText().length() == 0 ) + { return; + } if( this.searchField.textboxKeyTyped( character, key ) ) { @@ -218,7 +228,9 @@ public class GuiInterfaceTerminal extends AEBaseGui { String which = Integer.toString( x ); if( invData.hasKey( which ) ) + { current.inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( invData.getCompoundTag( which ) ) ); + } } } catch( NumberFormatException ignored ) diff --git a/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java b/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java index faa6c887..62a2c490 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java +++ b/src/main/java/appeng/client/gui/implementations/GuiLevelEmitter.java @@ -130,10 +130,14 @@ public class GuiLevelEmitter extends GuiUpgradeable super.drawFG( offsetX, offsetY, mouseX, mouseY ); if( this.craftingMode != null ) + { this.craftingMode.set( ( (ContainerLevelEmitter) this.cvb ).cmType ); + } if( this.levelMode != null ) + { this.levelMode.set( ( (ContainerLevelEmitter) this.cvb ).lvType ); + } } @Override @@ -170,16 +174,22 @@ public class GuiLevelEmitter extends GuiUpgradeable boolean backwards = Mouse.isButtonDown( 1 ); if( btn == this.craftingMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.craftingMode.getSetting(), backwards ) ); + } if( btn == this.levelMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.levelMode.getSetting(), backwards ) ); + } boolean isPlus = btn == this.plus1 || btn == this.plus10 || btn == this.plus100 || btn == this.plus1000; boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; if( isPlus || isMinus ) + { this.addQty( this.getQty( btn ) ); + } } private void addQty( long i ) @@ -196,15 +206,21 @@ public class GuiLevelEmitter extends GuiUpgradeable } if( Fixed ) + { this.level.setText( Out ); + } if( Out.length() == 0 ) + { Out = "0"; + } long result = Long.parseLong( Out ); result += i; if( result < 0 ) + { result = 0; + } this.level.setText( Out = Long.toString( result ) ); @@ -240,10 +256,14 @@ public class GuiLevelEmitter extends GuiUpgradeable } if( Fixed ) + { this.level.setText( Out ); + } if( Out.length() == 0 ) + { Out = "0"; + } NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) ); } diff --git a/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java b/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java index 5f575312..9da5d36e 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java +++ b/src/main/java/appeng/client/gui/implementations/GuiMEMonitorable.java @@ -111,7 +111,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi this.ySize = 204; if( te instanceof IViewCellStorage ) + { this.xSize += 33; + } this.standardSize = this.xSize; @@ -121,21 +123,33 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi this.viewCell = te instanceof IViewCellStorage; if( te instanceof TileSecurity ) + { this.myName = GuiText.Security; + } else if( te instanceof WirelessTerminalGuiObject ) + { this.myName = GuiText.WirelessTerminal; + } else if( te instanceof IPortableCell ) + { this.myName = GuiText.PortableCell; + } else if( te instanceof IMEChest ) + { this.myName = GuiText.Chest; + } else if( te instanceof PartTerminal ) + { this.myName = GuiText.Terminal; + } } public void postUpdate( List list ) { for( IAEItemStack is : list ) + { this.repo.postUpdate( is ); + } this.repo.updateView(); this.setScrollBar(); @@ -166,9 +180,13 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() ); if( btn == this.terminalStyleBox ) + { AEConfig.instance.settings.putSetting( iBtn.getSetting(), next ); + } else if( btn == this.searchBoxSettings ) + { AEConfig.instance.settings.putSetting( iBtn.getSetting(), next ); + } else { try @@ -184,7 +202,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi iBtn.set( next ); if( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class ) + { this.re_init(); + } } } } @@ -217,10 +237,14 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi } if( hasNEI ) + { this.rows--; + } if( this.rows < 3 ) + { this.rows = 3; + } this.meSlots.clear(); for( int y = 0; y < this.rows; y++ ) @@ -232,9 +256,13 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi } if( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ) + { this.xSize = this.standardSize + ( ( this.perRow - 9 ) * 18 ); + } else + { this.xSize = this.standardSize; + } super.initGui(); // full size : 204 @@ -303,7 +331,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi if( s instanceof AppEngSlot ) { if( ( (AppEngSlot) s ).xDisplayPosition < 197 ) + { this.repositionSlot( (AppEngSlot) s ); + } } if( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix ) @@ -365,10 +395,14 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 ); if( this.viewCell || ( this instanceof GuiSecurity ) ) + { this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 ); + } for( int x = 0; x < this.rows; x++ ) + { this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 ); + } this.drawTexturedModalRect( offsetX, offsetY + 16 + this.rows * 18 + this.lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + this.reservedSpace - this.lowerTextureOffset ); @@ -386,11 +420,15 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi } if( update ) + { this.repo.setViewCell( this.myCurrentViewCells ); + } } if( this.searchField != null ) + { this.searchField.drawTextBox(); + } } protected String getBackground() @@ -420,7 +458,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi if( !this.checkHotbarKeys( key ) ) { if( character == ' ' && this.searchField.getText().length() == 0 ) + { return; + } if( this.searchField.textboxKeyTyped( character, key ) ) { @@ -464,13 +504,19 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfi public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) { if( this.SortByBox != null ) + { this.SortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) ); + } if( this.SortDirBox != null ) + { this.SortDirBox.set( this.configSrc.getSetting( Settings.SORT_DIRECTION ) ); + } if( this.ViewBox != null ) + { this.ViewBox.set( this.configSrc.getSetting( Settings.VIEW_MODE ) ); + } this.repo.updateView(); } diff --git a/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java b/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java index c69c4a64..5947281e 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiNetworkStatus.java @@ -161,7 +161,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource String str = Long.toString( refStack.getStackSize() ); if( refStack.getStackSize() >= 10000 ) + { str = Long.toString( refStack.getStackSize() / 1000 ) + 'k'; + } int w = this.fontRendererObj.getStringWidth( str ); this.fontRendererObj.drawString( str, (int) ( ( x * sectionLength + xo + sectionLength - 19 - ( w * 0.5 ) ) * 2 ), ( y * 18 + yo + 6 ) * 2, 4210752 ); @@ -176,7 +178,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource toolTip += ( '\n' + GuiText.Installed.getLocal() + ": " + ( refStack.getStackSize() ) ); if( refStack.getCountRequestable() > 0 ) + { toolTip += ( '\n' + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ) ); + } toolPosX = x * sectionLength + xo + sectionLength - 8; toolPosY = y * 18 + yo; @@ -214,7 +218,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource this.repo.clear(); for( IAEItemStack is : list ) + { this.repo.postUpdate( is ); + } this.repo.updateView(); this.setScrollBar(); @@ -249,7 +255,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource if( myStack != null ) { while( currentToolTip.size() > 1 ) + { currentToolTip.remove( 1 ); + } } } } @@ -278,7 +286,9 @@ public class GuiNetworkStatus extends AEBaseGui implements ISortSource List currentToolTip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips ); while( currentToolTip.size() > 1 ) + { currentToolTip.remove( 1 ); + } currentToolTip.add( GuiText.Installed.getLocal() + ": " + ( myStack.getStackSize() ) ); currentToolTip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) ); diff --git a/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java b/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java index 0c3ed219..d3aa702c 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java +++ b/src/main/java/appeng/client/gui/implementations/GuiNetworkTool.java @@ -53,7 +53,9 @@ public class GuiNetworkTool extends AEBaseGui try { if( btn == this.tFacades ) + { NetworkHandler.instance.sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) ); + } } catch( IOException e ) { @@ -75,7 +77,9 @@ public class GuiNetworkTool extends AEBaseGui public void drawFG( int offsetX, int offsetY, int mouseX, int mouseY ) { if( this.tFacades != null ) + { this.tFacades.setState( ( (ContainerNetworkTool) this.inventorySlots ).facadeMode ); + } this.fontRendererObj.drawString( this.getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 ); this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); diff --git a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java index f3a29b3b..72b7efa5 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPatternTerm.java @@ -130,7 +130,9 @@ public class GuiPatternTerm extends GuiMEMonitorable protected String getBackground() { if( this.container.craftingMode ) + { return "guis/pattern.png"; + } return "guis/pattern2.png"; } @@ -138,8 +140,12 @@ public class GuiPatternTerm extends GuiMEMonitorable protected void repositionSlot( AppEngSlot s ) { if( s.isPlayerSide() ) + { s.yDisplayPosition = s.defY + this.ySize - 78 - 5; + } else + { s.yDisplayPosition = s.defY + this.ySize - 78 - 3; + } } } diff --git a/src/main/java/appeng/client/gui/implementations/GuiPriority.java b/src/main/java/appeng/client/gui/implementations/GuiPriority.java index 5c419cae..62dddb1c 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiPriority.java +++ b/src/main/java/appeng/client/gui/implementations/GuiPriority.java @@ -156,7 +156,9 @@ public class GuiPriority extends AEBaseGui } if( this.OriginalGui != null && myIcon != null ) + { this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) ); + } this.priority = new GuiNumberBox( this.fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRendererObj.FONT_HEIGHT, Long.class ); this.priority.setEnableBackgroundDrawing( false ); @@ -196,7 +198,9 @@ public class GuiPriority extends AEBaseGui boolean isMinus = btn == this.minus1 || btn == this.minus10 || btn == this.minus100 || btn == this.minus1000; if( isPlus || isMinus ) + { this.addQty( this.getQty( btn ) ); + } } private void addQty( int i ) @@ -213,10 +217,14 @@ public class GuiPriority extends AEBaseGui } if( fixed ) + { this.priority.setText( out ); + } if( out.length() == 0 ) + { out = "0"; + } long result = Long.parseLong( out ); result += i; @@ -255,10 +263,14 @@ public class GuiPriority extends AEBaseGui } if( fixed ) + { this.priority.setText( out ); + } if( out.length() == 0 ) + { out = "0"; + } NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", out ) ); } diff --git a/src/main/java/appeng/client/gui/implementations/GuiSecurity.java b/src/main/java/appeng/client/gui/implementations/GuiSecurity.java index 6c5083ef..cd53849a 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiSecurity.java +++ b/src/main/java/appeng/client/gui/implementations/GuiSecurity.java @@ -62,15 +62,25 @@ public class GuiSecurity extends GuiMEMonitorable SecurityPermissions toggleSetting = null; if( btn == this.inject ) + { toggleSetting = SecurityPermissions.INJECT; + } if( btn == this.extract ) + { toggleSetting = SecurityPermissions.EXTRACT; + } if( btn == this.craft ) + { toggleSetting = SecurityPermissions.CRAFT; + } if( btn == this.build ) + { toggleSetting = SecurityPermissions.BUILD; + } if( btn == this.security ) + { toggleSetting = SecurityPermissions.SECURITY; + } if( toggleSetting != null ) { diff --git a/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java b/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java index ce43b725..78654e28 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiStorageBus.java @@ -84,13 +84,19 @@ public class GuiStorageBus extends GuiUpgradeable this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); if( this.fuzzyMode != null ) + { this.fuzzyMode.set( this.cvb.fzMode ); + } if( this.storageFilter != null ) + { this.storageFilter.set( ( (ContainerStorageBus) this.cvb ).storageFilter ); + } if( this.rwMode != null ) + { this.rwMode.set( ( (ContainerStorageBus) this.cvb ).rwMode ); + } } @Override @@ -109,19 +115,25 @@ public class GuiStorageBus extends GuiUpgradeable try { if( btn == this.partition ) + { NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) ); - + } else if( btn == this.clear ) + { NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) ); - + } else if( btn == this.priority ) + { NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) ); - + } else if( btn == this.rwMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) ); - + } else if( btn == this.storageFilter ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) ); + } } catch( IOException e ) { diff --git a/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java b/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java index 25ea0ad1..b4f27816 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java +++ b/src/main/java/appeng/client/gui/implementations/GuiUpgradeable.java @@ -94,13 +94,19 @@ public class GuiUpgradeable extends AEBaseGui this.fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752 ); if( this.redstoneMode != null ) + { this.redstoneMode.set( this.cvb.rsMode ); + } if( this.fuzzyMode != null ) + { this.fuzzyMode.set( this.cvb.fzMode ); + } if( this.craftMode != null ) + { this.craftMode.set( this.cvb.cMode ); + } } @Override @@ -111,19 +117,29 @@ public class GuiUpgradeable extends AEBaseGui this.bindTexture( this.getBackground() ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, this.ySize ); if( this.drawUpgrades() ) + { this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + this.cvb.availableUpgrades() * 18 ); + } if( this.hasToolbox() ) + { this.drawTexturedModalRect( offsetX + 178, offsetY + this.ySize - 90, 178, this.ySize - 90, 68, 68 ); + } } protected void handleButtonVisibility() { if( this.redstoneMode != null ) + { this.redstoneMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 ); + } if( this.fuzzyMode != null ) + { this.fuzzyMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ); + } if( this.craftMode != null ) + { this.craftMode.setVisibility( this.bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ); + } } protected String getBackground() @@ -149,12 +165,18 @@ public class GuiUpgradeable extends AEBaseGui boolean backwards = Mouse.isButtonDown( 1 ); if( btn == this.redstoneMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.redstoneMode.getSetting(), backwards ) ); + } if( btn == this.craftMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.craftMode.getSetting(), backwards ) ); + } if( btn == this.fuzzyMode ) + { NetworkHandler.instance.sendToServer( new PacketConfigButton( this.fuzzyMode.getSetting(), backwards ) ); + } } } diff --git a/src/main/java/appeng/client/gui/widgets/GuiImgButton.java b/src/main/java/appeng/client/gui/widgets/GuiImgButton.java index 26fa7ccb..d154c8d3 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiImgButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiImgButton.java @@ -193,9 +193,13 @@ public class GuiImgButton extends GuiButton implements ITooltip GL11.glScalef( 0.5f, 0.5f, 0.5f ); if( this.enabled ) + { GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); + } else + { GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); + } par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) ); this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; @@ -212,9 +216,13 @@ public class GuiImgButton extends GuiButton implements ITooltip else { if( this.enabled ) + { GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); + } else + { GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f ); + } par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) ); this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height; @@ -236,7 +244,9 @@ public class GuiImgButton extends GuiButton implements ITooltip { ButtonAppearance app = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) ); if( app == null ) + { return 256 - 1; + } return app.index; } return 256 - 1; @@ -262,7 +272,9 @@ public class GuiImgButton extends GuiButton implements ITooltip { ButtonAppearance buttonAppearance = appearances.get( new EnumPair( this.buttonSetting, this.currentValue ) ); if( buttonAppearance == null ) + { return "No Such Message"; + } displayName = buttonAppearance.displayName; displayValue = buttonAppearance.displayValue; @@ -274,19 +286,27 @@ public class GuiImgButton extends GuiButton implements ITooltip String value = StatCollector.translateToLocal( displayValue ); if( name == null || name.isEmpty() ) + { name = displayName; + } if( value == null || value.isEmpty() ) + { value = displayValue; + } if( this.fillVar != null ) + { value = COMPILE.matcher( value ).replaceFirst( this.fillVar ); + } value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" ); StringBuilder sb = new StringBuilder( value ); int i = sb.lastIndexOf( "\n" ); if( i <= 0 ) + { i = 0; + } while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 ) { sb.replace( i, i + 1, "\n" ); @@ -357,9 +377,13 @@ public class GuiImgButton extends GuiButton implements ITooltip public boolean equals( Object obj ) { if( obj == null ) + { return false; + } if( this.getClass() != obj.getClass() ) + { return false; + } EnumPair other = (EnumPair) obj; return other.setting == this.setting && other.value == this.value; } diff --git a/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java b/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java index 90af80db..c3fc4ff2 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java +++ b/src/main/java/appeng/client/gui/widgets/GuiNumberBox.java @@ -43,11 +43,17 @@ public class GuiNumberBox extends GuiTextField try { if( this.type == int.class || this.type == Integer.class ) + { Integer.parseInt( this.getText() ); + } else if( this.type == long.class || this.type == Long.class ) + { Long.parseLong( this.getText() ); + } else if( this.type == double.class || this.type == Double.class ) + { Double.parseDouble( this.getText() ); + } } catch( NumberFormatException e ) { diff --git a/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java b/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java index b78e5e62..0feb481c 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java +++ b/src/main/java/appeng/client/gui/widgets/GuiProgressBar.java @@ -91,7 +91,9 @@ public class GuiProgressBar extends GuiButton implements ITooltip public String getMessage() { if( this.fullMsg != null ) + { return this.fullMsg; + } return ( this.titleName != null ? this.titleName : "" ) + '\n' + this.source.getCurrentProgress() + ' ' + GuiText.Of.getLocal() + ' ' + this.source.getMaxProgress(); } diff --git a/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java b/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java index 5d3c5962..301b2a08 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java +++ b/src/main/java/appeng/client/gui/widgets/GuiScrollbar.java @@ -109,7 +109,9 @@ public class GuiScrollbar implements IScrollSource this.pageSize = pageSize; if( this.minScroll > this.maxScroll ) + { this.maxScroll = this.minScroll; + } this.applyRange(); } @@ -128,7 +130,9 @@ public class GuiScrollbar implements IScrollSource public void click( AEBaseGui aeBaseGui, int x, int y ) { if( this.getRange() == 0 ) + { return; + } if( x > this.displayX && x <= this.displayX + this.width ) { diff --git a/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java b/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java index 851e59c5..d6a1bd11 100644 --- a/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java +++ b/src/main/java/appeng/client/gui/widgets/GuiToggleButton.java @@ -93,16 +93,22 @@ public class GuiToggleButton extends GuiButton implements ITooltip String value = StatCollector.translateToLocal( this.displayHint ); if( name == null || name.isEmpty() ) + { name = this.displayName; + } if( value == null || value.isEmpty() ) + { value = this.displayHint; + } value = PATTERN_NEW_LINE.matcher( value ).replaceAll( "\n" ); StringBuilder sb = new StringBuilder( value ); int i = sb.lastIndexOf( "\n" ); if( i <= 0 ) + { i = 0; + } while( i + 30 < sb.length() && ( i = sb.lastIndexOf( " ", i + 30 ) ) != -1 ) { sb.replace( i, i + 1, "\n" ); diff --git a/src/main/java/appeng/client/me/ClientDCInternalInv.java b/src/main/java/appeng/client/me/ClientDCInternalInv.java index 2f440691..e5491dcd 100644 --- a/src/main/java/appeng/client/me/ClientDCInternalInv.java +++ b/src/main/java/appeng/client/me/ClientDCInternalInv.java @@ -45,7 +45,9 @@ public class ClientDCInternalInv implements Comparable { String s = StatCollector.translateToLocal( this.unlocalizedName + ".name" ); if( s.equals( this.unlocalizedName + ".name" ) ) + { return StatCollector.translateToLocal( this.unlocalizedName ); + } return s; } diff --git a/src/main/java/appeng/client/me/ItemRepo.java b/src/main/java/appeng/client/me/ItemRepo.java index a98ac0a4..3d409741 100644 --- a/src/main/java/appeng/client/me/ItemRepo.java +++ b/src/main/java/appeng/client/me/ItemRepo.java @@ -74,7 +74,9 @@ public class ItemRepo idx += this.src.getCurrentScroll() * this.rowSize; if( idx >= this.view.size() ) + { return null; + } return this.view.get( idx ); } @@ -83,7 +85,9 @@ public class ItemRepo idx += this.src.getCurrentScroll() * this.rowSize; if( idx >= this.dsp.size() ) + { return null; + } return this.dsp.get( idx ); } @@ -102,7 +106,9 @@ public class ItemRepo st.add( is ); } else + { this.list.add( is ); + } } public void setViewCell( ItemStack[] list ) @@ -122,7 +128,9 @@ public class ItemRepo Enum viewMode = this.sortSrc.getSortDisplay(); Enum searchMode = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ); if( searchMode == SearchBoxMode.NEI_AUTOSEARCH || searchMode == SearchBoxMode.NEI_MANUAL_SEARCH ) + { this.updateNEI( this.searchString ); + } this.innerSearch = this.searchString; boolean terminalSearchToolTips = AEConfig.instance.settings.getSetting( Settings.SEARCH_TOOLTIPS ) != YesNo.NO; @@ -158,11 +166,15 @@ public class ItemRepo if( this.myPartitionList != null ) { if( !this.myPartitionList.isListed( is ) ) + { continue; + } } if( viewMode == ViewItems.CRAFTABLE && !is.isCraftable() ) + { continue; + } if( viewMode == ViewItems.CRAFTABLE ) { @@ -171,7 +183,9 @@ public class ItemRepo } if( viewMode == ViewItems.STORED && is.getStackSize() == 0 ) + { continue; + } String dspName = searchMod ? Platform.getModId( is ) : Platform.getItemDisplayName( is ); notDone = true; @@ -185,12 +199,14 @@ public class ItemRepo if( terminalSearchToolTips && notDone ) { for( Object lp : Platform.getTooltip( is ) ) + { if( lp instanceof String && m.matcher( (String) lp ).find() ) { this.view.add( is ); notDone = false; break; } + } } /* @@ -206,16 +222,26 @@ public class ItemRepo ItemSorters.init(); if( SortBy == SortOrder.MOD ) + { Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_MOD ); + } else if( SortBy == SortOrder.AMOUNT ) + { Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_SIZE ); + } else if( SortBy == SortOrder.INVTWEAKS ) + { Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_INV_TWEAKS ); + } else + { Collections.sort( this.view, ItemSorters.CONFIG_BASED_SORT_BY_NAME ); + } for( IAEItemStack is : this.view ) + { this.dsp.add( is.getItemStack() ); + } } private void updateNEI( String filter ) diff --git a/src/main/java/appeng/client/me/SlotDisconnected.java b/src/main/java/appeng/client/me/SlotDisconnected.java index e63ef1be..c0ecf570 100644 --- a/src/main/java/appeng/client/me/SlotDisconnected.java +++ b/src/main/java/appeng/client/me/SlotDisconnected.java @@ -68,7 +68,9 @@ public class SlotDisconnected extends AppEngSlot ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); ItemStack out = iep.getOutput( is ); if( out != null ) + { return out; + } } } return super.getStack(); diff --git a/src/main/java/appeng/client/me/SlotME.java b/src/main/java/appeng/client/me/SlotME.java index c8d27945..1545c1e5 100644 --- a/src/main/java/appeng/client/me/SlotME.java +++ b/src/main/java/appeng/client/me/SlotME.java @@ -41,7 +41,9 @@ public class SlotME extends Slot public IAEItemStack getAEStack() { if( this.mySlot.hasPower() ) + { return this.mySlot.getAEStack(); + } return null; } @@ -60,7 +62,9 @@ public class SlotME extends Slot public ItemStack getStack() { if( this.mySlot.hasPower() ) + { return this.mySlot.getStack(); + } return null; } @@ -68,7 +72,9 @@ public class SlotME extends Slot public boolean getHasStack() { if( this.mySlot.hasPower() ) + { return this.getStack() != null; + } return false; } diff --git a/src/main/java/appeng/client/render/BaseBlockRender.java b/src/main/java/appeng/client/render/BaseBlockRender.java index a90446e2..ef7a286c 100644 --- a/src/main/java/appeng/client/render/BaseBlockRender.java +++ b/src/main/java/appeng/client/render/BaseBlockRender.java @@ -289,7 +289,9 @@ public class BaseBlockRender if( info.isValid() ) { if( block.hasSubtypes() ) + { block.setRenderStateByMeta( item.getItemDamage() ); + } renderer.uvRotateBottom = info.getTexture( ForgeDirection.DOWN ).setFlip( getOrientation( ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.UP ) ); renderer.uvRotateTop = info.getTexture( ForgeDirection.UP ).setFlip( getOrientation( ForgeDirection.UP, ForgeDirection.SOUTH, ForgeDirection.UP ) ); @@ -304,7 +306,9 @@ public class BaseBlockRender this.renderInvBlock( EnumSet.allOf( ForgeDirection.class ), block, item, tess, 0xffffff, renderer ); if( block.hasSubtypes() ) + { info.setTemporaryRenderIcon( null ); + } renderer.uvRotateBottom = renderer.uvRotateEast = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; } @@ -314,7 +318,9 @@ public class BaseBlockRender if( in == null || in == ForgeDirection.UNKNOWN // 1 || forward == null || forward == ForgeDirection.UNKNOWN // 2 || up == null || up == ForgeDirection.UNKNOWN ) + { return 0; + } int a = in.ordinal(); int b = forward.ordinal(); @@ -327,7 +333,9 @@ public class BaseBlockRender { int meta = 0; if( block != null && block.hasSubtypes() && item != null ) + { meta = item.getItemDamage(); + } if( sides.contains( ForgeDirection.DOWN ) ) { @@ -387,8 +395,12 @@ public class BaseBlockRender public IIcon firstNotNull( IIcon... s ) { for( IIcon o : s ) + { if( o != null ) + { return o; + } + } return ExtraBlockTextures.getMissing(); } @@ -434,9 +446,13 @@ public class BaseBlockRender public IOrientable getOrientable( AEBaseBlock block, IBlockAccess w, int x, int y, int z ) { if( block.hasBlockTileEntity() ) + { return (AEBaseTile) block.getTileEntity( w, x, y, z ); + } else if( block instanceof IOrientableBlock ) + { return ( (IOrientableBlock) block ).getOrientable( w, x, y, z ); + } return null; } @@ -660,10 +676,14 @@ public class BaseBlockRender private double mapFaceUV( int offset, int uv ) { if( offset == 0 ) + { return 0; + } if( offset > 0 ) + { return uv / 16.0; + } return ( 16.0 - uv ) / 16.0; } @@ -681,9 +701,13 @@ public class BaseBlockRender RenderHelper.disableStandardItemLighting(); if( Minecraft.isAmbientOcclusionEnabled() ) + { GL11.glShadeModel( GL11.GL_SMOOTH ); + } else + { GL11.glShadeModel( GL11.GL_FLAT ); + } GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); @@ -706,10 +730,14 @@ public class BaseBlockRender if( forward != null && up != null ) { if( forward == ForgeDirection.UNKNOWN ) + { forward = ForgeDirection.SOUTH; + } if( up == ForgeDirection.UNKNOWN ) + { up = ForgeDirection.UP; + } ForgeDirection west = Platform.crossProduct( forward, up ); diff --git a/src/main/java/appeng/client/render/BlockRenderInfo.java b/src/main/java/appeng/client/render/BlockRenderInfo.java index 885655d9..146a9967 100644 --- a/src/main/java/appeng/client/render/BlockRenderInfo.java +++ b/src/main/java/appeng/client/render/BlockRenderInfo.java @@ -62,7 +62,9 @@ public class BlockRenderInfo public void setTemporaryRenderIcon( IIcon IIcon ) { if( IIcon == null ) + { this.useTmp = false; + } else { this.useTmp = true; diff --git a/src/main/java/appeng/client/render/BusRenderHelper.java b/src/main/java/appeng/client/render/BusRenderHelper.java index 157db49c..e0e964c4 100644 --- a/src/main/java/appeng/client/render/BusRenderHelper.java +++ b/src/main/java/appeng/client/render/BusRenderHelper.java @@ -151,7 +151,9 @@ public final class BusRenderHelper implements IPartRenderHelper public void setBounds( double[] bounds ) { if( bounds == null || bounds.length != 6 ) + { return; + } this.minX = bounds[0]; this.minY = bounds[1]; @@ -301,18 +303,30 @@ public final class BusRenderHelper implements IPartRenderHelper p.getBoxes( this.bbc ); if( this.bbc.minX < 1 ) + { this.bbc.minX = 1; + } if( this.bbc.minY < 1 ) + { this.bbc.minY = 1; + } if( this.bbc.minZ < 1 ) + { this.bbc.minZ = 1; + } if( this.bbc.maxX > 15 ) + { this.bbc.maxX = 15; + } if( this.bbc.maxY > 15 ) + { this.bbc.maxY = 15; + } if( this.bbc.maxZ > 15 ) + { this.bbc.maxZ = 15; + } } this.setBounds( this.bbc.minX, this.bbc.minY, this.bbc.minZ, this.bbc.maxX, this.bbc.maxY, this.bbc.maxZ ); @@ -384,30 +398,48 @@ public final class BusRenderHelper implements IPartRenderHelper ForgeDirection west = ForgeDirection.UNKNOWN; if( forward == null || up == null ) + { return dir; + } int west_x = forward.offsetY * up.offsetZ - forward.offsetZ * up.offsetY; int west_y = forward.offsetZ * up.offsetX - forward.offsetX * up.offsetZ; int west_z = forward.offsetX * up.offsetY - forward.offsetY * up.offsetX; for( ForgeDirection dx : ForgeDirection.VALID_DIRECTIONS ) + { if( dx.offsetX == west_x && dx.offsetY == west_y && dx.offsetZ == west_z ) + { west = dx; + } + } if( dir == forward ) + { return ForgeDirection.SOUTH; + } if( dir == forward.getOpposite() ) + { return ForgeDirection.NORTH; + } if( dir == up ) + { return ForgeDirection.UP; + } if( dir == up.getOpposite() ) + { return ForgeDirection.DOWN; + } if( dir == west ) + { return ForgeDirection.WEST; + } if( dir == west.getOpposite() ) + { return ForgeDirection.EAST; + } return ForgeDirection.UNKNOWN; } @@ -439,7 +471,9 @@ public final class BusRenderHelper implements IPartRenderHelper public void renderBlock( int x, int y, int z, RenderBlocks renderer ) { if( !this.renderThis() ) + { return; + } for( Block multiPart : AEApi.instance().definitions().blocks().multiPart().maybeBlock().asSet() ) { @@ -490,7 +524,9 @@ public final class BusRenderHelper implements IPartRenderHelper public void renderBlockCurrentBounds( int x, int y, int z, RenderBlocks renderer ) { if( !this.renderThis() ) + { return; + } for( Block block : this.maybeBlock.asSet() ) { @@ -502,7 +538,9 @@ public final class BusRenderHelper implements IPartRenderHelper public void renderFaceCutout( int x, int y, int z, IIcon ico, ForgeDirection face, float edgeThickness, RenderBlocks renderer ) { if( !this.renderThis() ) + { return; + } switch( face ) { @@ -540,7 +578,9 @@ public final class BusRenderHelper implements IPartRenderHelper public void renderFace( int x, int y, int z, IIcon ico, ForgeDirection face, RenderBlocks renderer ) { if( !this.renderThis() ) + { return; + } this.prepareBounds( renderer ); switch( face ) diff --git a/src/main/java/appeng/client/render/BusRenderer.java b/src/main/java/appeng/client/render/BusRenderer.java index 74c6e961..cf099776 100644 --- a/src/main/java/appeng/client/render/BusRenderer.java +++ b/src/main/java/appeng/client/render/BusRenderer.java @@ -68,7 +68,9 @@ public class BusRenderer implements IItemRenderer public void renderItem( ItemRenderType type, ItemStack item, Object... data ) { if( item == null ) + { return; + } GL11.glPushMatrix(); GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS ); @@ -103,7 +105,9 @@ public class BusRenderer implements IItemRenderer } if( type == ItemRenderType.INVENTORY ) + { GL11.glTranslatef( 0.0f, -0.1f, 0.0f ); + } GL11.glTranslated( 0.2, 0.3, 0.1 ); GL11.glScaled( 1.2, 1.2, 1. ); @@ -135,7 +139,9 @@ public class BusRenderer implements IItemRenderer } if( fp != null ) + { fp.renderInventory( BusRenderHelper.INSTANCE, this.renderer ); + } } else { @@ -167,7 +173,9 @@ public class BusRenderer implements IItemRenderer { part = c.createPartFromItemStack( is ); if( part != null ) + { RENDER_PART.put( id, part ); + } } return part; diff --git a/src/main/java/appeng/client/render/CableRenderHelper.java b/src/main/java/appeng/client/render/CableRenderHelper.java index 3e23343f..06a6ce20 100644 --- a/src/main/java/appeng/client/render/CableRenderHelper.java +++ b/src/main/java/appeng/client/render/CableRenderHelper.java @@ -51,10 +51,14 @@ public class CableRenderHelper RenderBlocksWorkaround renderer = BusRenderer.INSTANCE.renderer; if( renderer.overrideBlockTexture != null ) + { BusRenderHelper.INSTANCE.setPass( 0 ); + } if( renderer.blockAccess == null ) + { renderer.blockAccess = Minecraft.getMinecraft().theWorld; + } for( ForgeDirection s : ForgeDirection.values() ) { @@ -108,7 +112,9 @@ public class CableRenderHelper o += bb.minZ < min ? 1 : 0; if( o >= 2 ) + { useThinFacades = true; + } } for( ForgeDirection s : ForgeDirection.VALID_DIRECTIONS ) @@ -124,7 +130,9 @@ public class CableRenderHelper if( bb.intersectsWith( pb ) ) { if( b == null ) + { b = bb; + } else { b.maxX = Math.max( b.maxX, bb.maxX ); diff --git a/src/main/java/appeng/client/render/ItemRenderer.java b/src/main/java/appeng/client/render/ItemRenderer.java index 19f48328..69590909 100644 --- a/src/main/java/appeng/client/render/ItemRenderer.java +++ b/src/main/java/appeng/client/render/ItemRenderer.java @@ -54,9 +54,13 @@ public class ItemRenderer implements IItemRenderer GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); if( type == ItemRenderType.ENTITY ) + { GL11.glTranslatef( -0.5f, -0.5f, -0.5f ); + } if( type == ItemRenderType.INVENTORY ) + { GL11.glTranslatef( 0.0f, -0.1f, 0.0f ); + } WorldRender.INSTANCE.renderItemBlock( item, type, data ); diff --git a/src/main/java/appeng/client/render/RenderBlocksWorkaround.java b/src/main/java/appeng/client/render/RenderBlocksWorkaround.java index 96e73925..d18635b2 100644 --- a/src/main/java/appeng/client/render/RenderBlocksWorkaround.java +++ b/src/main/java/appeng/client/render/RenderBlocksWorkaround.java @@ -220,7 +220,9 @@ public class RenderBlocksWorkaround extends RenderBlocks if( this.faces.contains( ForgeDirection.DOWN ) ) { if( !this.renderFaces.contains( ForgeDirection.DOWN ) ) + { return; + } if( this.isFacade ) { @@ -257,7 +259,9 @@ public class RenderBlocksWorkaround extends RenderBlocks } } else + { super.renderFaceYNeg( par1Block, par2, par4, par6, par8Icon ); + } } else { @@ -274,7 +278,9 @@ public class RenderBlocksWorkaround extends RenderBlocks if( this.faces.contains( ForgeDirection.UP ) ) { if( !this.renderFaces.contains( ForgeDirection.UP ) ) + { return; + } if( this.isFacade ) { @@ -311,7 +317,9 @@ public class RenderBlocksWorkaround extends RenderBlocks } } else + { super.renderFaceYPos( par1Block, par2, par4, par6, par8Icon ); + } } else { @@ -328,7 +336,9 @@ public class RenderBlocksWorkaround extends RenderBlocks if( this.faces.contains( ForgeDirection.NORTH ) ) { if( !this.renderFaces.contains( ForgeDirection.NORTH ) ) + { return; + } if( this.isFacade ) { @@ -365,7 +375,9 @@ public class RenderBlocksWorkaround extends RenderBlocks } } else + { super.renderFaceZNeg( par1Block, par2, par4, par6, par8Icon ); + } } else { @@ -382,7 +394,9 @@ public class RenderBlocksWorkaround extends RenderBlocks if( this.faces.contains( ForgeDirection.SOUTH ) ) { if( !this.renderFaces.contains( ForgeDirection.SOUTH ) ) + { return; + } if( this.isFacade ) { @@ -419,7 +433,9 @@ public class RenderBlocksWorkaround extends RenderBlocks } } else + { super.renderFaceZPos( par1Block, par2, par4, par6, par8Icon ); + } } else { @@ -436,7 +452,9 @@ public class RenderBlocksWorkaround extends RenderBlocks if( this.faces.contains( ForgeDirection.WEST ) ) { if( !this.renderFaces.contains( ForgeDirection.WEST ) ) + { return; + } if( this.isFacade ) { @@ -473,7 +491,9 @@ public class RenderBlocksWorkaround extends RenderBlocks } } else + { super.renderFaceXNeg( par1Block, par2, par4, par6, par8Icon ); + } } else { @@ -490,7 +510,9 @@ public class RenderBlocksWorkaround extends RenderBlocks if( this.faces.contains( ForgeDirection.EAST ) ) { if( !this.renderFaces.contains( ForgeDirection.EAST ) ) + { return; + } if( this.isFacade ) { @@ -527,7 +549,9 @@ public class RenderBlocksWorkaround extends RenderBlocks } } else + { super.renderFaceXPos( par1Block, par2, par4, par6, par8Icon ); + } } else { @@ -577,13 +601,17 @@ public class RenderBlocksWorkaround extends RenderBlocks int o = 0; for( int i = -1; i <= 1; i++ ) + { for( int j = -1; j <= 1; j++ ) + { for( int k = -1; k <= 1; k++ ) { this.lightHashTmp[o] = blk.getMixedBrightnessForBlock( this.blockAccess, x + i, y + j, z + k ); o++; } + } + } return Arrays.hashCode( this.lightHashTmp ); } diff --git a/src/main/java/appeng/client/render/TESRWrapper.java b/src/main/java/appeng/client/render/TESRWrapper.java index 5b6f9673..3783831c 100644 --- a/src/main/java/appeng/client/render/TESRWrapper.java +++ b/src/main/java/appeng/client/render/TESRWrapper.java @@ -60,7 +60,9 @@ public class TESRWrapper extends TileEntitySpecialRenderer if( b instanceof AEBaseBlock && ( (AEBaseTile) te ).requiresTESR() ) { if( Math.abs( x ) > this.MAX_DISTANCE || Math.abs( y ) > this.MAX_DISTANCE || Math.abs( z ) > this.MAX_DISTANCE ) + { return; + } Tessellator tess = Tessellator.instance; diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockAssembler.java b/src/main/java/appeng/client/render/blocks/RenderBlockAssembler.java index 896510d0..565c062f 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockAssembler.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockAssembler.java @@ -266,7 +266,9 @@ public class RenderBlockAssembler extends BaseBlockRender implements IBoxProvide if( pc.isConnected( side.getOpposite() ) ) { if( covered ) + { return pc.getCoveredTexture( pc.getCableColor() ); + } return pc.getGlassTexture( pc.getCableColor() ); } } diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockCharger.java b/src/main/java/appeng/client/render/blocks/RenderBlockCharger.java index 5a9aadf7..e99a42f7 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockCharger.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockCharger.java @@ -130,7 +130,9 @@ public class RenderBlockCharger extends BaseBlockRender { ItemStack sis = null; if( tile instanceof IInventory ) + { sis = ( (IInventory) tile ).getStackInSlot( 0 ); + } if( sis != null ) { diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockController.java b/src/main/java/appeng/client/render/blocks/RenderBlockController.java index 89462434..486bbf3a 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockController.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockController.java @@ -58,12 +58,18 @@ public class RenderBlockController extends BaseBlockRender { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() ); if( isConflict ) + { lights = ExtraBlockTextures.BlockControllerColumnConflict; + } else + { lights = ExtraBlockTextures.BlockControllerColumnLights; + } } else + { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() ); + } renderer.uvRotateEast = 1; renderer.uvRotateWest = 1; @@ -76,12 +82,18 @@ public class RenderBlockController extends BaseBlockRender { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() ); if( isConflict ) + { lights = ExtraBlockTextures.BlockControllerColumnConflict; + } else + { lights = ExtraBlockTextures.BlockControllerColumnLights; + } } else + { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() ); + } renderer.uvRotateEast = 0; renderer.uvRotateNorth = 0; @@ -92,12 +104,18 @@ public class RenderBlockController extends BaseBlockRender { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumnPowered.getIcon() ); if( isConflict ) + { lights = ExtraBlockTextures.BlockControllerColumnConflict; + } else + { lights = ExtraBlockTextures.BlockControllerColumnLights; + } } else + { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerColumn.getIcon() ); + } renderer.uvRotateNorth = 1; renderer.uvRotateSouth = 1; @@ -109,9 +127,13 @@ public class RenderBlockController extends BaseBlockRender renderer.uvRotateEast = renderer.uvRotateBottom = renderer.uvRotateNorth = renderer.uvRotateSouth = renderer.uvRotateTop = renderer.uvRotateWest = 0; if( v == 0 ) + { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerInsideA.getIcon() ); + } else + { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerInsideB.getIcon() ); + } } else { @@ -119,12 +141,18 @@ public class RenderBlockController extends BaseBlockRender { blk.getRendererInstance().setTemporaryRenderIcon( ExtraBlockTextures.BlockControllerPowered.getIcon() ); if( isConflict ) + { lights = ExtraBlockTextures.BlockControllerConflict; + } else + { lights = ExtraBlockTextures.BlockControllerLights; + } } else + { blk.getRendererInstance().setTemporaryRenderIcon( null ); + } } boolean out = renderer.renderStandardBlock( blk, x, y, z ); @@ -148,7 +176,9 @@ public class RenderBlockController extends BaseBlockRender private TileEntity getTileEntity( IBlockAccess world, int x, int y, int z ) { if( y >= 0 ) + { return world.getTileEntity( x, y, z ); + } return null; } } diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java index 8a384544..79092a82 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPU.java @@ -126,7 +126,9 @@ public class RenderBlockCraftingCPU extends BaseBlockRender boolean LocalEmit = emitsLight; if( blk instanceof BlockCraftingMonitor && ct.getForward() != side ) + { LocalEmit = false; + } this.handleSide( blk, meta, x, y, z, i, renderer, ct.getForward() == side ? theIcon : nonForward, LocalEmit, isMonitor, side, w ); } @@ -165,11 +167,17 @@ public class RenderBlockCraftingCPU extends BaseBlockRender private void renderCorner( BusRenderHelper i, RenderBlocks renderer, IBlockAccess w, int x, int y, int z, ForgeDirection up, ForgeDirection east, ForgeDirection south ) { if( this.isConnected( w, x, y, z, up ) ) + { return; + } if( this.isConnected( w, x, y, z, east ) ) + { return; + } if( this.isConnected( w, x, y, z, south ) ) + { return; + } i.setBounds( this.gso( east, 3, ForgeDirection.WEST ), this.gso( up, 3, ForgeDirection.DOWN ), this.gso( south, 3, ForgeDirection.NORTH ), this.gso( east, 13, ForgeDirection.EAST ), this.gso( up, 13, ForgeDirection.UP ), this.gso( south, 13, ForgeDirection.SOUTH ) ); i.prepareBounds( renderer ); @@ -182,7 +190,9 @@ public class RenderBlockCraftingCPU extends BaseBlockRender if( side == target ) { if( side.offsetX > 0 || side.offsetY > 0 || side.offsetZ > 0 ) + { return 16; + } return 0; } return def; @@ -191,7 +201,9 @@ public class RenderBlockCraftingCPU extends BaseBlockRender private void handleSide( AEBaseBlock blk, int meta, int x, int y, int z, BusRenderHelper i, RenderBlocks renderer, IIcon color, boolean emitsLight, boolean isMonitor, ForgeDirection side, IBlockAccess w ) { if( this.isConnected( w, x, y, z, side ) ) + { return; + } i.setFacesToRender( EnumSet.of( side ) ); @@ -203,9 +215,13 @@ public class RenderBlockCraftingCPU extends BaseBlockRender else { if( color == ExtraBlockTextures.BlockCraftingMonitorFit_Light.getIcon() ) + { i.setTexture( ExtraBlockTextures.BlockCraftingMonitorOuter.getIcon() ); + } else + { i.setTexture( ExtraBlockTextures.BlockCraftingFitSolid.getIcon() ); + } i.renderBlockCurrentBounds( x, y, z, renderer ); @@ -233,7 +249,9 @@ public class RenderBlockCraftingCPU extends BaseBlockRender i.renderFace( x, y, z, ExtraBlockTextures.BlockCraftingMonitorFit_Dark.getIcon(), side, renderer ); } else + { i.renderBlockCurrentBounds( x, y, z, renderer ); + } } else { @@ -267,14 +285,22 @@ public class RenderBlockCraftingCPU extends BaseBlockRender for( ForgeDirection a : ForgeDirection.VALID_DIRECTIONS ) { if( a == side || a == side.getOpposite() ) + { continue; + } if( ( side.offsetX != 0 || side.offsetZ != 0 ) && ( a == ForgeDirection.NORTH || a == ForgeDirection.EAST || a == ForgeDirection.WEST || a == ForgeDirection.SOUTH ) ) + { i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLongRotated.getIcon() ); + } else if( ( side.offsetY != 0 ) && ( a == ForgeDirection.EAST || a == ForgeDirection.WEST ) ) + { i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLongRotated.getIcon() ); + } else + { i.setTexture( ExtraBlockTextures.BlockCraftingUnitRingLong.getIcon() ); + } double width = 3.0 / 16.0; @@ -334,7 +360,9 @@ public class RenderBlockCraftingCPU extends BaseBlockRender if( side != target ) { if( side.offsetX > 0 || side.offsetY > 0 || side.offsetZ > 0 ) + { return 16; + } return 0; } return def; diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java index f87ac1ba..c7f59f50 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockCraftingCPUMonitor.java @@ -84,7 +84,9 @@ public class RenderBlockCraftingCPUMonitor extends RenderBlockCraftingCPU GL11.glEndList(); } else + { GL11.glCallList( cmt.dspList ); + } GL11.glPopMatrix(); } diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockCrank.java b/src/main/java/appeng/client/render/blocks/RenderBlockCrank.java index 931ca22e..8557cfe8 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockCrank.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockCrank.java @@ -70,15 +70,21 @@ public class RenderBlockCrank extends BaseBlockRender { TileCrank tc = (TileCrank) tile; if( tc.getUp() == null || tc.getUp() == ForgeDirection.UNKNOWN ) + { return; + } Minecraft.getMinecraft().getTextureManager().bindTexture( TextureMap.locationBlocksTexture ); RenderHelper.disableStandardItemLighting(); if( Minecraft.isAmbientOcclusionEnabled() ) + { GL11.glShadeModel( GL11.GL_SMOOTH ); + } else + { GL11.glShadeModel( GL11.GL_FLAT ); + } GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockEnergyCube.java b/src/main/java/appeng/client/render/blocks/RenderBlockEnergyCube.java index c2f7ee15..bddf6546 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockEnergyCube.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockEnergyCube.java @@ -47,9 +47,13 @@ public class RenderBlockEnergyCube extends BaseBlockRender int meta = (int) ( 8.0 * ( internalCurrentPower / internalMaxPower ) ); if( meta > 7 ) + { meta = 7; + } if( meta < 0 ) + { meta = 0; + } renderer.setOverrideBlockTexture( blk.getIcon( 0, meta ) ); super.renderInventory( blk, is, renderer, type, obj ); diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockInscriber.java b/src/main/java/appeng/client/render/blocks/RenderBlockInscriber.java index 1a0ab2e5..7fcf6abb 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockInscriber.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockInscriber.java @@ -112,7 +112,9 @@ public class RenderBlockInscriber extends BaseBlockRender IOrientable te = this.getOrientable( block, world, x, y, z ); if( te == null ) + { return false; + } ForgeDirection fdy = te.getUp(); ForgeDirection fdz = te.getForward(); @@ -178,14 +180,18 @@ public class RenderBlockInscriber extends BaseBlockRender long currentTime = System.currentTimeMillis(); absoluteProgress = currentTime - inv.clientStart; if( absoluteProgress > 800 ) + { inv.smash = false; + } } float relativeProgress = absoluteProgress % 800 / 400.0f; float progress = relativeProgress; if( progress > 1.0f ) + { progress = 1.0f - ( progress - 1.0f ); + } press -= progress / 5.0f; IIcon ic = ExtraBlockTextures.BlockInscriberInside.getIcon(); @@ -219,11 +225,17 @@ public class RenderBlockInscriber extends BaseBlockRender int items = 0; if( inv.getStackInSlot( 0 ) != null ) + { items++; + } if( inv.getStackInSlot( 1 ) != null ) + { items++; + } if( inv.getStackInSlot( 2 ) != null ) + { items++; + } if( relativeProgress > 1.0f || items == 0 ) { @@ -233,7 +245,9 @@ public class RenderBlockInscriber extends BaseBlockRender { IInscriberRecipe ir = inv.getTask(); if( ir != null ) + { is = ir.getOutput().copy(); + } } this.renderItem( is, 0.0f, block, tile, tess, x, y, z, f, renderer ); diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockPaint.java b/src/main/java/appeng/client/render/blocks/RenderBlockPaint.java index 3fa38a79..a0ae285f 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockPaint.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockPaint.java @@ -73,13 +73,17 @@ public class RenderBlockPaint extends BaseBlockRender for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) { if( tp.isSideValid( side ) ) + { validSides.add( side ); + } } for( Splotch s : tp.getDots() ) { if( !validSides.contains( s.side ) ) + { continue; + } if( s.lumen ) { diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockSkyChest.java b/src/main/java/appeng/client/render/blocks/RenderBlockSkyChest.java index 4a10df5c..b514fa39 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockSkyChest.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockSkyChest.java @@ -54,9 +54,13 @@ public class RenderBlockSkyChest extends BaseBlockRender ResourceLocation loc; if( is.getItemDamage() == 1 ) + { loc = new ResourceLocation( "appliedenergistics2", "textures/models/skyblockchest.png" ); + } else + { loc = new ResourceLocation( "appliedenergistics2", "textures/models/skychest.png" ); + } Minecraft.getMinecraft().getTextureManager().bindTexture( loc ); @@ -83,12 +87,16 @@ public class RenderBlockSkyChest extends BaseBlockRender public void renderTile( AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float partialTick, RenderBlocks renderer ) { if( !( tile instanceof TileSkyChest ) ) + { return; + } TileSkyChest skyChest = (TileSkyChest) tile; if( !skyChest.hasWorldObj() ) + { return; + } GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */ ); GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F ); @@ -96,9 +104,13 @@ public class RenderBlockSkyChest extends BaseBlockRender ResourceLocation loc; if( tile.getWorldObj().getBlockMetadata( tile.xCoord, tile.yCoord, tile.zCoord ) == 1 ) + { loc = new ResourceLocation( "appliedenergistics2", "textures/models/skyblockchest.png" ); + } else + { loc = new ResourceLocation( "appliedenergistics2", "textures/models/skychest.png" ); + } Minecraft.getMinecraft().getTextureManager().bindTexture( loc ); @@ -111,15 +123,23 @@ public class RenderBlockSkyChest extends BaseBlockRender long distance = now - skyChest.lastEvent; if( skyChest.playerOpen > 0 ) + { skyChest.lidAngle += distance * 0.0001; + } else + { skyChest.lidAngle -= distance * 0.0001; + } if( skyChest.lidAngle > 0.5f ) + { skyChest.lidAngle = 0.5f; + } if( skyChest.lidAngle < 0.0f ) + { skyChest.lidAngle = 0.0f; + } float lidAngle = skyChest.lidAngle; lidAngle = 1.0F - lidAngle; diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockSkyCompass.java b/src/main/java/appeng/client/render/blocks/RenderBlockSkyCompass.java index 1d3195a9..46a23d39 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockSkyCompass.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockSkyCompass.java @@ -61,11 +61,17 @@ public class RenderBlockSkyCompass extends BaseBlockRender IInventory inv = Minecraft.getMinecraft().thePlayer.inventory; for( int x = 0; x < inv.getSizeInventory(); x++ ) + { if( inv.getStackInSlot( x ) == is ) + { isGood = true; + } + } if( !isGood ) + { type = ItemRenderType.FIRST_PERSON_MAP; + } } GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */ ); @@ -85,15 +91,21 @@ public class RenderBlockSkyCompass extends BaseBlockRender else { if( type == ItemRenderType.EQUIPPED_FIRST_PERSON ) + { GL11.glRotatef( 15.3f, 0.0f, 0.0f, 1.0f ); + } GL11.glScalef( 1.0F, -1F, -1F ); GL11.glScalef( 2.5f, 2.5f, 2.5f ); if( type == ItemRenderType.EQUIPPED_FIRST_PERSON ) + { GL11.glTranslatef( 0.3F, -1.65F, -0.19F ); + } else + { GL11.glTranslatef( 0.2F, -1.65F, -0.19F ); + } } long now = System.currentTimeMillis(); @@ -114,8 +126,12 @@ public class RenderBlockSkyCompass extends BaseBlockRender CompassResult cr = CompassManager.INSTANCE.getCompassDirection( 0, x, y, z ); for( int i = 0; i < 3; i++ ) + { for( int j = 0; j < 3; j++ ) + { CompassManager.INSTANCE.getCompassDirection( 0, x + i - 1, y, z + j - 1 ); + } + } if( cr.hasResult ) { @@ -166,12 +182,16 @@ public class RenderBlockSkyCompass extends BaseBlockRender public void renderTile( AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float partialTick, RenderBlocks renderer ) { if( !( tile instanceof TileSkyCompass ) ) + { return; + } TileSkyCompass skyCompass = (TileSkyCompass) tile; if( !skyCompass.hasWorldObj() ) + { return; + } GL11.glEnable( 32826 /* GL_RESCALE_NORMAL_EXT */ ); GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F ); @@ -189,9 +209,13 @@ public class RenderBlockSkyCompass extends BaseBlockRender CompassResult cr = null; if( skyCompass.getForward() == ForgeDirection.UP || skyCompass.getForward() == ForgeDirection.DOWN ) + { cr = CompassManager.INSTANCE.getCompassDirection( 0, tile.xCoord, tile.yCoord, tile.zCoord ); + } else + { cr = new CompassResult( false, true, 0 ); + } if( cr.hasResult ) { @@ -201,7 +225,9 @@ public class RenderBlockSkyCompass extends BaseBlockRender this.model.renderAll( ( now / 50000.0f ) * (float) Math.PI * 500.0f ); } else + { this.model.renderAll( (float) ( skyCompass.getForward() == ForgeDirection.DOWN ? this.flipidiy( cr.rad ) : cr.rad ) ); + } } else { diff --git a/src/main/java/appeng/client/render/blocks/RenderBlockWireless.java b/src/main/java/appeng/client/render/blocks/RenderBlockWireless.java index 408d35f0..9fa3cc53 100644 --- a/src/main/java/appeng/client/render/blocks/RenderBlockWireless.java +++ b/src/main/java/appeng/client/render/blocks/RenderBlockWireless.java @@ -185,17 +185,29 @@ public class RenderBlockWireless extends BaseBlockRender } if( ForgeDirection.UP != fdz.getOpposite() ) + { super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.UP ); + } if( ForgeDirection.DOWN != fdz.getOpposite() ) + { super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.DOWN ); + } if( ForgeDirection.EAST != fdz.getOpposite() ) + { super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.EAST ); + } if( ForgeDirection.WEST != fdz.getOpposite() ) + { super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.WEST ); + } if( ForgeDirection.SOUTH != fdz.getOpposite() ) + { super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.SOUTH ); + } if( ForgeDirection.NORTH != fdz.getOpposite() ) + { super.renderFace( x, y, z, blk, r, renderer, ForgeDirection.NORTH ); + } ri.setTemporaryRenderIcon( null ); renderer.renderAllFaces = false; diff --git a/src/main/java/appeng/client/render/blocks/RenderDrive.java b/src/main/java/appeng/client/render/blocks/RenderDrive.java index 63924a54..7343f563 100644 --- a/src/main/java/appeng/client/render/blocks/RenderDrive.java +++ b/src/main/java/appeng/client/render/blocks/RenderDrive.java @@ -253,9 +253,13 @@ public class RenderDrive extends BaseBlockRender } if( ( forward == ForgeDirection.UP && up == ForgeDirection.SOUTH ) || forward == ForgeDirection.DOWN ) + { this.selectFace( renderer, west, up, forward, 3 + xx * 7, 4 + xx * 7, 1 + yy * 3, 2 + yy * 3 ); + } else + { this.selectFace( renderer, west, up, forward, 5 + xx * 7, 6 + xx * 7, 2 + yy * 3, 3 + yy * 3 ); + } if( stat != 0 ) { @@ -271,16 +275,26 @@ public class RenderDrive extends BaseBlockRender v4 = whiteIcon.getInterpolatedV( ( ( spin ) % 4 < 2 ) ? 1 : 3 ); if( sp.isPowered() ) + { tess.setBrightness( 15 << 20 | 15 << 4 ); + } else + { tess.setBrightness( 0 ); + } if( stat == 1 ) + { Tessellator.instance.setColorOpaque_I( 0x00ff00 ); + } if( stat == 2 ) + { Tessellator.instance.setColorOpaque_I( 0xffaa00 ); + } if( stat == 3 ) + { Tessellator.instance.setColorOpaque_I( 0xff0000 ); + } switch( forward.offsetX + forward.offsetY * 2 + forward.offsetZ * 3 ) { diff --git a/src/main/java/appeng/client/render/blocks/RenderMEChest.java b/src/main/java/appeng/client/render/blocks/RenderMEChest.java index 10dea7ec..1e2cd03c 100644 --- a/src/main/java/appeng/client/render/blocks/RenderMEChest.java +++ b/src/main/java/appeng/client/render/blocks/RenderMEChest.java @@ -70,7 +70,9 @@ public class RenderMEChest extends BaseBlockRender renderer.setRenderBounds( 0, 0, 0, 1, 1, 1 ); if( sp == null ) + { return false; + } ForgeDirection up = sp.getUp(); ForgeDirection forward = sp.getForward(); @@ -86,7 +88,9 @@ public class RenderMEChest extends BaseBlockRender int offsetU = -4; int offsetV = 8; if( stat == 0 ) + { offsetV = 3; + } int b = world.getLightBrightnessForSkyBlocks( x + forward.offsetX, y + forward.offsetY, z + forward.offsetZ, 0 ); Tessellator.instance.setBrightness( b ); @@ -94,15 +98,25 @@ public class RenderMEChest extends BaseBlockRender FlippableIcon flippableIcon = new FlippableIcon( new OffsetIcon( ExtraBlockTextures.MEStorageCellTextures.getIcon(), offsetU, offsetV ) ); if( forward == ForgeDirection.EAST && ( up == ForgeDirection.NORTH || up == ForgeDirection.SOUTH ) ) + { flippableIcon.setFlip( true, false ); + } else if( forward == ForgeDirection.NORTH && up == ForgeDirection.EAST ) + { flippableIcon.setFlip( false, true ); + } else if( forward == ForgeDirection.NORTH && up == ForgeDirection.WEST ) + { flippableIcon.setFlip( true, false ); + } else if( forward == ForgeDirection.DOWN && up == ForgeDirection.EAST ) + { flippableIcon.setFlip( false, true ); + } else if( forward == ForgeDirection.DOWN ) + { flippableIcon.setFlip( true, false ); + } /* * 1.7.2 @@ -123,11 +137,17 @@ public class RenderMEChest extends BaseBlockRender Tessellator.instance.setBrightness( b ); if( stat == 1 ) + { Tessellator.instance.setColorOpaque_I( 0x00ff00 ); + } if( stat == 2 ) + { Tessellator.instance.setColorOpaque_I( 0xffaa00 ); + } if( stat == 3 ) + { Tessellator.instance.setColorOpaque_I( 0xff0000 ); + } this.selectFace( renderer, west, up, forward, 9, 10, 11, 12 ); this.renderFace( x, y, z, imb, ExtraBlockTextures.White.getIcon(), renderer, forward ); } diff --git a/src/main/java/appeng/client/render/blocks/RenderQNB.java b/src/main/java/appeng/client/render/blocks/RenderQNB.java index 753a0fcc..30dd5614 100644 --- a/src/main/java/appeng/client/render/blocks/RenderQNB.java +++ b/src/main/java/appeng/client/render/blocks/RenderQNB.java @@ -61,7 +61,9 @@ public class RenderQNB extends BaseBlockRender { TileQuantumBridge tqb = block.getTileEntity( world, x, y, z ); if( tqb == null ) + { return false; + } renderer.renderAllFaces = true; @@ -120,7 +122,9 @@ public class RenderQNB extends BaseBlockRender Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F ); Tessellator.instance.setBrightness( bn << 20 | bn << 4 ); for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) + { this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingCornerLight.getIcon(), renderer, side ); + } } } else @@ -146,7 +150,9 @@ public class RenderQNB extends BaseBlockRender Tessellator.instance.setColorOpaque_F( 1.0F, 1.0F, 1.0F ); Tessellator.instance.setBrightness( bn << 20 | bn << 4 ); for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) + { this.renderFace( x, y, z, block, ExtraBlockTextures.BlockQRingEdgeLight.getIcon(), renderer, side ); + } } } } diff --git a/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java b/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java index bbc06beb..7ef682b2 100644 --- a/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java +++ b/src/main/java/appeng/client/render/blocks/RenderQuartzGlass.java @@ -47,8 +47,12 @@ public class RenderQuartzGlass extends BaseBlockRender Random r = new Random( 924 ); offsets = new byte[10][10][10]; for( int x = 0; x < 10; x++ ) + { for( int y = 0; y < 10; y++ ) + { r.nextBytes( offsets[x][y] ); + } + } } } @@ -155,18 +159,30 @@ public class RenderQuartzGlass extends BaseBlockRender } if( maxX <= 0.001f ) + { maxX += 0.9f / 16.0f; + } if( maxY <= 0.001f ) + { maxY += 0.9f / 16.0f; + } if( maxZ <= 0.001f ) + { maxZ += 0.9f / 16.0f; + } if( minX >= 0.999f ) + { minX -= 0.9f / 16.0f; + } if( minY >= 0.999f ) + { minY -= 0.9f / 16.0f; + } if( minZ >= 0.999f ) + { minZ -= 0.9f / 16.0f; + } renderer.setRenderBounds( minX, minY, minZ, maxX, maxY, maxZ ); diff --git a/src/main/java/appeng/client/render/blocks/RenderSpatialPylon.java b/src/main/java/appeng/client/render/blocks/RenderSpatialPylon.java index 851477b6..d3ba70a0 100644 --- a/src/main/java/appeng/client/render/blocks/RenderSpatialPylon.java +++ b/src/main/java/appeng/client/render/blocks/RenderSpatialPylon.java @@ -136,7 +136,9 @@ public class RenderSpatialPylon extends BaseBlockRender Tessellator.instance.setColorOpaque_I( 0xffffff ); for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { this.renderFace( x, y, z, imb, this.getBlockTextureFromSideInside( imb, sp, displayBits, ori, d ), renderer, d ); + } } else { @@ -166,16 +168,22 @@ public class RenderSpatialPylon extends BaseBlockRender { if( ori == dir || ori.getOpposite() == dir ) + { return blk.getRendererInstance().getTexture( dir ); + } if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_MIDDLE ) + { return ExtraBlockTextures.BlockSpatialPylonC.getIcon(); - + } else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MIN ) + { return ExtraBlockTextures.BlockSpatialPylonE.getIcon(); - + } else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MAX ) + { return ExtraBlockTextures.BlockSpatialPylonE.getIcon(); + } return blk.getIcon( 0, 0 ); } @@ -185,16 +193,22 @@ public class RenderSpatialPylon extends BaseBlockRender boolean good = ( displayBits & sp.DISPLAY_ENABLED ) == sp.DISPLAY_ENABLED; if( ori == dir || ori.getOpposite() == dir ) + { return good ? ExtraBlockTextures.BlockSpatialPylon_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylon_red.getIcon(); + } if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_MIDDLE ) + { return good ? ExtraBlockTextures.BlockSpatialPylonC_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonC_red.getIcon(); - + } else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MIN ) + { return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon(); - + } else if( ( displayBits & sp.DISPLAY_MIDDLE ) == sp.DISPLAY_END_MAX ) + { return good ? ExtraBlockTextures.BlockSpatialPylonE_dim.getIcon() : ExtraBlockTextures.BlockSpatialPylonE_red.getIcon(); + } return blk.getIcon( 0, 0 ); } diff --git a/src/main/java/appeng/client/render/effects/AssemblerFX.java b/src/main/java/appeng/client/render/effects/AssemblerFX.java index 7cee3803..53198433 100644 --- a/src/main/java/appeng/client/render/effects/AssemblerFX.java +++ b/src/main/java/appeng/client/render/effects/AssemblerFX.java @@ -64,7 +64,9 @@ public class AssemblerFX extends EntityFX super.onUpdate(); if( this.isDead ) + { this.fi.setDead(); + } else { float lifeSpan = (float) this.particleAge / (float) this.particleMaxAge; @@ -81,7 +83,9 @@ public class AssemblerFX extends EntityFX this.time -= 4.0; // if ( CommonHelper.proxy.shouldAddParticles( r ) ) for( int x = 0; x < (int) Math.ceil( this.speed / 5 ); x++ ) + { CommonHelper.proxy.spawnEffect( EffectType.Crafting, this.worldObj, this.posX, this.posY, this.posZ, null ); + } } } } diff --git a/src/main/java/appeng/client/render/effects/ChargedOreFX.java b/src/main/java/appeng/client/render/effects/ChargedOreFX.java index 5ba8023d..905deeb7 100644 --- a/src/main/java/appeng/client/render/effects/ChargedOreFX.java +++ b/src/main/java/appeng/client/render/effects/ChargedOreFX.java @@ -38,7 +38,9 @@ public class ChargedOreFX extends EntityReddustFX j1 = Math.max( j1 >> 20, j1 >> 4 ); j1 += 3; if( j1 > 15 ) + { j1 = 15; + } return j1 << 20 | j1 << 4; } } diff --git a/src/main/java/appeng/client/render/effects/CraftingFx.java b/src/main/java/appeng/client/render/effects/CraftingFx.java index 3b60cb2b..4172dba1 100644 --- a/src/main/java/appeng/client/render/effects/CraftingFx.java +++ b/src/main/java/appeng/client/render/effects/CraftingFx.java @@ -72,7 +72,9 @@ public class CraftingFx extends EntityBreakingFX public void renderParticle( Tessellator par1Tessellator, float partialTick, float x, float y, float z, float rx, float rz ) { if( partialTick < 0 || partialTick > 1 ) + { return; + } float f6 = this.particleTextureIndex.getMinU(); float f7 = this.particleTextureIndex.getMaxU(); diff --git a/src/main/java/appeng/client/render/items/ItemEncodedPatternRenderer.java b/src/main/java/appeng/client/render/items/ItemEncodedPatternRenderer.java index aa33343e..640a71cb 100644 --- a/src/main/java/appeng/client/render/items/ItemEncodedPatternRenderer.java +++ b/src/main/java/appeng/client/render/items/ItemEncodedPatternRenderer.java @@ -46,7 +46,9 @@ public class ItemEncodedPatternRenderer implements IItemRenderer { ItemEncodedPattern iep = (ItemEncodedPattern) item.getItem(); if( iep.getOutput( item ) != null ) + { return true; + } } return false; diff --git a/src/main/java/appeng/client/render/items/PaintBallRender.java b/src/main/java/appeng/client/render/items/PaintBallRender.java index 7fd6dc57..4376561c 100644 --- a/src/main/java/appeng/client/render/items/PaintBallRender.java +++ b/src/main/java/appeng/client/render/items/PaintBallRender.java @@ -52,7 +52,9 @@ public class PaintBallRender implements IItemRenderer { IIcon par2Icon = item.getIconIndex(); if( item.getItemDamage() >= 20 ) + { par2Icon = ExtraItemTextures.ItemPaintBallShimmer.getIcon(); + } float f4 = par2Icon.getMinU(); float f5 = par2Icon.getMaxU(); @@ -77,9 +79,13 @@ public class PaintBallRender implements IItemRenderer float fail = 0.7f; if( item.getItemDamage() >= 20 ) + { GL11.glColor4ub( (byte) ( full + r * fail ), (byte) ( full + g * fail ), (byte) ( full + b * fail ), (byte) 255 ); + } else + { GL11.glColor4ub( (byte) r, (byte) g, (byte) b, (byte) 255 ); + } if( type == ItemRenderType.INVENTORY ) { @@ -99,9 +105,13 @@ public class PaintBallRender implements IItemRenderer else { if( type == ItemRenderType.EQUIPPED_FIRST_PERSON ) + { GL11.glTranslatef( 0.0F, 0.0F, 0.0F ); + } else + { GL11.glTranslatef( -0.5F, -0.3F, 0.01F ); + } ItemRenderer.renderItemIn2D( tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12 ); GL11.glDisable( GL11.GL_CULL_FACE ); diff --git a/src/main/java/appeng/client/render/items/ToolBiometricCardRender.java b/src/main/java/appeng/client/render/items/ToolBiometricCardRender.java index 92baeaa6..5c2cedaf 100644 --- a/src/main/java/appeng/client/render/items/ToolBiometricCardRender.java +++ b/src/main/java/appeng/client/render/items/ToolBiometricCardRender.java @@ -100,7 +100,9 @@ public class ToolBiometricCardRender implements IItemRenderer { GameProfile gp = ( (IBiometricCard) item.getItem() ).getProfile( item ); if( gp != null ) + { username = gp.getName(); + } } int hash = username.length() > 0 ? username.hashCode() : 0; @@ -113,7 +115,9 @@ public class ToolBiometricCardRender implements IItemRenderer AEColor col = AEColor.values()[Math.abs( 3 + hash ) % AEColor.values().length]; if( hash == 0 ) + { col = AEColor.Black; + } for( int x = 0; x < 8; x++ )// 8 { @@ -123,14 +127,22 @@ public class ToolBiometricCardRender implements IItemRenderer float scale = 0.3f / 255.0f; if( x == 0 || y == 0 || x == 7 || y == 5 ) + { isLit = false; + } else + { isLit = ( hash & ( 1 << x ) ) != 0 || ( hash & ( 1 << y ) ) != 0; + } if( isLit ) + { tessellator.setColorOpaque_I( col.mediumVariant ); + } else + { tessellator.setColorOpaque_F( ( ( col.blackVariant >> 16 ) & 0xff ) * scale, ( ( col.blackVariant >> 8 ) & 0xff ) * scale, ( col.blackVariant & 0xff ) * scale ); + } tessellator.addVertexWithUV( x, y, z, u, v ); tessellator.addVertexWithUV( x + 1, y, z, u, v ); diff --git a/src/main/java/appeng/client/render/items/ToolColorApplicatorRender.java b/src/main/java/appeng/client/render/items/ToolColorApplicatorRender.java index d9e9bc73..17c1baee 100644 --- a/src/main/java/appeng/client/render/items/ToolColorApplicatorRender.java +++ b/src/main/java/appeng/client/render/items/ToolColorApplicatorRender.java @@ -81,11 +81,17 @@ public class ToolColorApplicatorRender implements IItemRenderer else { if( type == ItemRenderType.EQUIPPED_FIRST_PERSON ) + { GL11.glTranslatef( 0.0F, 0.0F, 0.0F ); + } else if( type == ItemRenderType.EQUIPPED ) + { GL11.glTranslatef( 0.0F, 0.0F, 0.0F ); + } else + { GL11.glTranslatef( -0.5F, -0.3F, 0.01F ); + } ItemRenderer.renderItemIn2D( tessellator, f5, f6, f4, f7, par2Icon.getIconWidth(), par2Icon.getIconHeight(), f12 ); GL11.glDisable( GL11.GL_CULL_FACE ); @@ -101,7 +107,9 @@ public class ToolColorApplicatorRender implements IItemRenderer GL11.glScalef( 1F / 16F, 1F / 16F, 1F ); if( type != ItemRenderType.INVENTORY ) + { GL11.glTranslatef( 2, 0, 0 ); + } GL11.glDisable( GL11.GL_LIGHTING ); AEColor col = null; diff --git a/src/main/java/appeng/client/texture/FlippableIcon.java b/src/main/java/appeng/client/texture/FlippableIcon.java index 489bbe1b..1db6e69f 100644 --- a/src/main/java/appeng/client/texture/FlippableIcon.java +++ b/src/main/java/appeng/client/texture/FlippableIcon.java @@ -32,7 +32,9 @@ public class FlippableIcon implements IIcon public FlippableIcon( IIcon o ) { if( o == null ) + { throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); + } this.original = o; this.flip_u = false; @@ -55,7 +57,9 @@ public class FlippableIcon implements IIcon public float getMinU() { if( this.flip_u ) + { return this.original.getMaxU(); + } return this.original.getMinU(); } @@ -63,7 +67,9 @@ public class FlippableIcon implements IIcon public float getMaxU() { if( this.flip_u ) + { return this.original.getMinU(); + } return this.original.getMaxU(); } @@ -71,7 +77,9 @@ public class FlippableIcon implements IIcon public float getInterpolatedU( double px ) { if( this.flip_u ) + { return this.original.getInterpolatedU( 16 - px ); + } return this.original.getInterpolatedU( px ); } @@ -79,7 +87,9 @@ public class FlippableIcon implements IIcon public float getMinV() { if( this.flip_v ) + { return this.original.getMaxV(); + } return this.original.getMinV(); } @@ -87,7 +97,9 @@ public class FlippableIcon implements IIcon public float getMaxV() { if( this.flip_v ) + { return this.original.getMinV(); + } return this.original.getMaxV(); } @@ -95,7 +107,9 @@ public class FlippableIcon implements IIcon public float getInterpolatedV( double px ) { if( this.flip_v ) + { return this.original.getInterpolatedV( 16 - px ); + } return this.original.getInterpolatedV( px ); } diff --git a/src/main/java/appeng/client/texture/FullIcon.java b/src/main/java/appeng/client/texture/FullIcon.java index cf369504..272a76ae 100644 --- a/src/main/java/appeng/client/texture/FullIcon.java +++ b/src/main/java/appeng/client/texture/FullIcon.java @@ -33,7 +33,9 @@ public class FullIcon implements IIcon public FullIcon( IIcon o ) { if( o == null ) + { throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); + } this.p = o; } @@ -69,7 +71,9 @@ public class FullIcon implements IIcon public float getInterpolatedU( double d0 ) { if( d0 > 8.0 ) + { return this.p.getMaxU(); + } return this.p.getMinU(); } @@ -92,7 +96,9 @@ public class FullIcon implements IIcon public float getInterpolatedV( double d0 ) { if( d0 > 8.0 ) + { return this.p.getMaxV(); + } return this.p.getMinV(); } diff --git a/src/main/java/appeng/client/texture/OffsetIcon.java b/src/main/java/appeng/client/texture/OffsetIcon.java index 30bfb05a..33bb066b 100644 --- a/src/main/java/appeng/client/texture/OffsetIcon.java +++ b/src/main/java/appeng/client/texture/OffsetIcon.java @@ -36,7 +36,9 @@ public class OffsetIcon implements IIcon public OffsetIcon( IIcon o, float x, float y ) { if( o == null ) + { throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); + } this.p = o; this.offsetX = x; diff --git a/src/main/java/appeng/client/texture/TaughtIcon.java b/src/main/java/appeng/client/texture/TaughtIcon.java index 298b8572..12699c34 100644 --- a/src/main/java/appeng/client/texture/TaughtIcon.java +++ b/src/main/java/appeng/client/texture/TaughtIcon.java @@ -35,7 +35,9 @@ public class TaughtIcon implements IIcon public TaughtIcon( IIcon icon, float tightness ) { if( icon == null ) + { throw new IllegalArgumentException( "Cannot create a wrapper icon with a null icon." ); + } this.icon = icon; this.tightness = tightness * 0.4f; @@ -105,18 +107,26 @@ public class TaughtIcon implements IIcon private float v( double d ) { if( d < 8 ) + { d -= this.tightness; + } if( d > 8 ) + { d += this.tightness; + } return this.icon.getInterpolatedV( Math.min( 16.0, Math.max( 0.0, d ) ) ); } private float u( double d ) { if( d < 8 ) + { d -= this.tightness; + } if( d > 8 ) + { d += this.tightness; + } return this.icon.getInterpolatedU( Math.min( 16.0, Math.max( 0.0, d ) ) ); } } diff --git a/src/main/java/appeng/client/texture/TmpFlippableIcon.java b/src/main/java/appeng/client/texture/TmpFlippableIcon.java index 0b472565..ca789dc9 100644 --- a/src/main/java/appeng/client/texture/TmpFlippableIcon.java +++ b/src/main/java/appeng/client/texture/TmpFlippableIcon.java @@ -41,17 +41,25 @@ public class TmpFlippableIcon extends FlippableIcon { FlippableIcon fi = (FlippableIcon) i; if( fi.flip_u ) + { this.flip_u = !this.flip_u; + } if( fi.flip_v ) + { this.flip_v = !this.flip_v; + } i = fi.getOriginal(); } if( i == null ) + { this.original = NULL_ICON; + } else + { this.original = i; + } } } diff --git a/src/main/java/appeng/container/AEBaseContainer.java b/src/main/java/appeng/container/AEBaseContainer.java index 2f604e8c..69624218 100644 --- a/src/main/java/appeng/container/AEBaseContainer.java +++ b/src/main/java/appeng/container/AEBaseContainer.java @@ -120,13 +120,19 @@ public abstract class AEBaseContainer extends Container protected IActionHost getActionHost() { if( this.obj instanceof IActionHost ) + { return (IActionHost) this.obj; + } if( this.tileEntity instanceof IActionHost ) + { return (IActionHost) this.tileEntity; + } if( this.part instanceof IActionHost ) + { return (IActionHost) this.part; + } return null; } @@ -139,9 +145,13 @@ public abstract class AEBaseContainer extends Container { GuiSync annotation = f.getAnnotation( GuiSync.class ); if( this.syncData.containsKey( annotation.value() ) ) + { AELog.warning( "Channel already in use: " + annotation.value() + " for " + f.getName() ); + } else + { this.syncData.put( annotation.value(), new SyncData( this, f, annotation ) ); + } } } } @@ -154,7 +164,9 @@ public abstract class AEBaseContainer extends Container this.obj = anchor instanceof IGuiItemObject ? (IGuiItemObject) anchor : null; if( this.tileEntity == null && this.part == null && this.obj == null ) + { throw new IllegalArgumentException( "Must have a valid anchor, instead " + anchor + " in " + ip ); + } this.mySrc = new PlayerSource( ip.player, this.getActionHost() ); @@ -165,26 +177,34 @@ public abstract class AEBaseContainer extends Container { this.dataChunks.add( packetPartialItem ); if( packetPartialItem.getPageCount() == this.dataChunks.size() ) + { this.parsePartials(); + } } private void parsePartials() { int total = 0; for( PacketPartialItem ppi : this.dataChunks ) + { total += ppi.getSize(); + } byte[] buffer = new byte[total]; int cursor = 0; for( PacketPartialItem ppi : this.dataChunks ) + { cursor = ppi.write( buffer, cursor ); + } try { NBTTagCompound data = CompressedStreamTools.readCompressed( new ByteArrayInputStream( buffer ) ); if( data != null ) + { this.setTargetStack( AEApi.instance().storage().createItemStack( ItemStack.loadItemStackFromNBT( data ) ) ); + } } catch( IOException e ) { @@ -208,13 +228,17 @@ public abstract class AEBaseContainer extends Container ItemStack b = this.clientRequestedTargetItem == null ? null : this.clientRequestedTargetItem.getItemStack(); if( Platform.isSameItemPrecise( a, b ) ) + { return; + } ByteArrayOutputStream stream = new ByteArrayOutputStream(); NBTTagCompound item = new NBTTagCompound(); if( stack != null ) + { stack.writeToNBT( item ); + } try { @@ -262,11 +286,15 @@ public abstract class AEBaseContainer extends Container public void verifyPermissions( SecurityPermissions security, boolean requirePower ) { if( Platform.isClient() ) + { return; + } this.ticksSinceCheck++; if( this.ticksSinceCheck < 20 ) + { return; + } this.ticksSinceCheck = 0; this.isContainerValid = this.isContainerValid && this.hasAccess( security, requirePower ); @@ -288,12 +316,16 @@ public abstract class AEBaseContainer extends Container { IEnergyGrid eg = g.getCache( IEnergyGrid.class ); if( !eg.isNetworkPowered() ) + { return false; + } } ISecurityGrid sg = g.getCache( ISecurityGrid.class ); if( sg.hasPermission( this.invPlayer.player, perm ) ) + { return true; + } } } } @@ -309,11 +341,17 @@ public abstract class AEBaseContainer extends Container public Object getTarget() { if( this.tileEntity != null ) + { return this.tileEntity; + } if( this.part != null ) + { return this.part; + } if( this.obj != null ) + { return this.obj; + } return null; } @@ -354,9 +392,13 @@ public abstract class AEBaseContainer extends Container for( int j = 0; j < 9; j++ ) { if( this.locked.contains( j + i * 9 + 9 ) ) + { this.addSlotToContainer( new SlotDisabled( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) ); + } else + { this.addSlotToContainer( new SlotPlayerInv( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offset_x, offset_y + i * 18 ) ); + } } } @@ -364,9 +406,13 @@ public abstract class AEBaseContainer extends Container for( int i = 0; i < 9; i++ ) { if( this.locked.contains( i ) ) + { this.addSlotToContainer( new SlotDisabled( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) ); + } else + { this.addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offset_x, 58 + offset_y ) ); + } } } @@ -380,7 +426,9 @@ public abstract class AEBaseContainer extends Container return super.addSlotToContainer( newSlot ); } else + { throw new IllegalArgumentException( "Invalid Slot [" + newSlot + "]for AE Container instead of AppEngSlot." ); + } } @Override @@ -395,7 +443,9 @@ public abstract class AEBaseContainer extends Container ICrafting icrafting = (ICrafting) crafter; for( SyncData sd : this.syncData.values() ) + { sd.tick( icrafting ); + } } } @@ -406,7 +456,9 @@ public abstract class AEBaseContainer extends Container public ItemStack transferStackInSlot( EntityPlayer p, int idx ) { if( Platform.isClient() ) + { return null; + } boolean hasMETiles = false; for( Object is : this.inventorySlots ) @@ -427,13 +479,17 @@ public abstract class AEBaseContainer extends Container AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get( idx ); // require AE SLots! if( clickSlot instanceof SlotDisabled || clickSlot instanceof SlotInaccessible ) + { return null; + } if( clickSlot != null && clickSlot.getHasStack() ) { tis = clickSlot.getStack(); if( tis == null ) + { return null; + } List selectedSlots = new ArrayList(); @@ -512,7 +568,9 @@ public abstract class AEBaseContainer extends Container for( Slot d : selectedSlots ) { if( d instanceof SlotDisabled || d instanceof SlotME ) + { continue; + } if( d.isItemValid( tis ) ) { @@ -524,7 +582,9 @@ public abstract class AEBaseContainer extends Container { int maxSize = t.getMaxStackSize(); if( maxSize > d.getSlotStackLimit() ) + { maxSize = d.getSlotStackLimit(); + } int placeAble = maxSize - t.stackSize; @@ -548,7 +608,9 @@ public abstract class AEBaseContainer extends Container return null; } else + { this.updateSlot( d ); + } } } } @@ -558,7 +620,9 @@ public abstract class AEBaseContainer extends Container for( Slot d : selectedSlots ) { if( d instanceof SlotDisabled || d instanceof SlotME ) + { continue; + } if( d.isItemValid( tis ) ) { @@ -570,7 +634,9 @@ public abstract class AEBaseContainer extends Container { int maxSize = t.getMaxStackSize(); if( d.getSlotStackLimit() < maxSize ) + { maxSize = d.getSlotStackLimit(); + } int placeAble = maxSize - t.stackSize; @@ -596,18 +662,24 @@ public abstract class AEBaseContainer extends Container return null; } else + { this.updateSlot( d ); + } } } else { int maxSize = tis.getMaxStackSize(); if( maxSize > d.getSlotStackLimit() ) + { maxSize = d.getSlotStackLimit(); + } ItemStack tmp = tis.copy(); if( tmp.stackSize > maxSize ) + { tmp.stackSize = maxSize; + } tis.stackSize -= tmp.stackSize; d.putStack( tmp ); @@ -626,7 +698,9 @@ public abstract class AEBaseContainer extends Container return null; } else + { this.updateSlot( d ); + } } } } @@ -654,7 +728,9 @@ public abstract class AEBaseContainer extends Container if( this.isContainerValid ) { if( this.tileEntity instanceof IInventory ) + { return ( (IInventory) this.tileEntity ).isUseableByPlayer( entityplayer ); + } return true; } return false; @@ -694,9 +770,13 @@ public abstract class AEBaseContainer extends Container case PICKUP_OR_SET_DOWN: if( hand == null ) + { s.putStack( null ); + } else + { s.putStack( hand.copy() ); + } break; case PLACE_SINGLE: @@ -715,9 +795,13 @@ public abstract class AEBaseContainer extends Container if( is != null ) { if( hand == null ) + { is.stackSize--; + } else if( hand.isItemEqual( is ) ) + { is.stackSize = Math.min( is.getMaxStackSize(), is.stackSize + 1 ); + } else { is = hand.copy(); @@ -749,11 +833,15 @@ public abstract class AEBaseContainer extends Container for( Object j : this.inventorySlots ) { if( j instanceof Slot && j.getClass() == s.getClass() ) + { from.add( (Slot) j ); + } } for( Slot fr : from ) + { this.transferStackInSlot( player, fr.slotNumber ); + } } return; @@ -766,7 +854,9 @@ public abstract class AEBaseContainer extends Container { case SHIFT_CLICK: if( this.powerSrc == null || this.cellInv == null ) + { return; + } if( slotItem != null ) { @@ -780,16 +870,22 @@ public abstract class AEBaseContainer extends Container myItem = adp.simulateAdd( myItem ); if( myItem != null ) + { ais.setStackSize( ais.getStackSize() - myItem.stackSize ); + } ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc ); if( ais != null ) + { adp.addItems( ais.getItemStack() ); + } } break; case ROLL_DOWN: if( this.powerSrc == null || this.cellInv == null ) + { return; + } int releaseQty = 1; ItemStack isg = player.inventory.getItemStack(); @@ -807,7 +903,9 @@ public abstract class AEBaseContainer extends Container ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null ); if( fail == null ) + { this.cellInv.extractItems( extracted, Actionable.MODULATE, this.mySrc ); + } this.updateHeld( player ); } @@ -817,7 +915,9 @@ public abstract class AEBaseContainer extends Container case ROLL_UP: case PICKUP_SINGLE: if( this.powerSrc == null || this.cellInv == null ) + { return; + } if( slotItem != null ) { @@ -827,9 +927,13 @@ public abstract class AEBaseContainer extends Container if( item != null ) { if( item.stackSize >= item.getMaxStackSize() ) + { liftQty = 0; + } if( !Platform.isSameItemPrecise( slotItem.getItemStack(), item ) ) + { liftQty = 0; + } } if( liftQty > 0 ) @@ -843,7 +947,9 @@ public abstract class AEBaseContainer extends Container ItemStack fail = ia.addItems( ais.getItemStack() ); if( fail != null ) + { this.cellInv.injectItems( ais, Actionable.MODULATE, this.mySrc ); + } this.updateHeld( player ); } @@ -852,7 +958,9 @@ public abstract class AEBaseContainer extends Container break; case PICKUP_OR_SET_DOWN: if( this.powerSrc == null || this.cellInv == null ) + { return; + } if( player.inventory.getItemStack() == null ) { @@ -862,9 +970,13 @@ public abstract class AEBaseContainer extends Container ais.setStackSize( ais.getItemStack().getMaxStackSize() ); ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc ); if( ais != null ) + { player.inventory.setItemStack( ais.getItemStack() ); + } else + { player.inventory.setItemStack( null ); + } this.updateHeld( player ); } } @@ -873,16 +985,22 @@ public abstract class AEBaseContainer extends Container IAEItemStack ais = AEApi.instance().storage().createItemStack( player.inventory.getItemStack() ); ais = Platform.poweredInsert( this.powerSrc, this.cellInv, ais, this.mySrc ); if( ais != null ) + { player.inventory.setItemStack( ais.getItemStack() ); + } else + { player.inventory.setItemStack( null ); + } this.updateHeld( player ); } break; case SPLIT_OR_PLACE_SINGLE: if( this.powerSrc == null || this.cellInv == null ) + { return; + } if( player.inventory.getItemStack() == null ) { @@ -901,9 +1019,13 @@ public abstract class AEBaseContainer extends Container } if( ais != null ) + { player.inventory.setItemStack( ais.getItemStack() ); + } else + { player.inventory.setItemStack( null ); + } this.updateHeld( player ); } } @@ -917,7 +1039,9 @@ public abstract class AEBaseContainer extends Container ItemStack is = player.inventory.getItemStack(); is.stackSize--; if( is.stackSize <= 0 ) + { player.inventory.setItemStack( null ); + } this.updateHeld( player ); } } @@ -935,7 +1059,9 @@ public abstract class AEBaseContainer extends Container case MOVE_REGION: if( this.powerSrc == null || this.cellInv == null ) + { return; + } if( slotItem != null ) { @@ -952,13 +1078,19 @@ public abstract class AEBaseContainer extends Container myItem = adp.simulateAdd( myItem ); if( myItem != null ) + { ais.setStackSize( ais.getStackSize() - myItem.stackSize ); + } ais = Platform.poweredExtraction( this.powerSrc, this.cellInv, ais, this.mySrc ); if( ais != null ) + { adp.addItems( ais.getItemStack() ); + } else + { return; + } } } @@ -986,10 +1118,14 @@ public abstract class AEBaseContainer extends Container public ItemStack shiftStoreItem( ItemStack input ) { if( this.powerSrc == null || this.cellInv == null ) + { return input; + } IAEItemStack ais = Platform.poweredInsert( this.powerSrc, this.cellInv, AEApi.instance().storage().createItemStack( input ), this.mySrc ); if( ais == null ) + { return null; + } return ais.getItemStack(); } @@ -1009,21 +1145,31 @@ public abstract class AEBaseContainer extends Container ICustomNameObject name = null; if( this.part instanceof ICustomNameObject ) + { name = (ICustomNameObject) this.part; + } if( this.tileEntity instanceof ICustomNameObject ) + { name = (ICustomNameObject) this.tileEntity; + } if( this.obj instanceof ICustomNameObject ) + { name = (ICustomNameObject) this.obj; + } if( this instanceof ICustomNameObject ) + { name = (ICustomNameObject) this; + } if( name != null ) { if( name.hasCustomName() ) + { this.customName = name.getCustomName(); + } if( this.customName != null ) { @@ -1048,30 +1194,42 @@ public abstract class AEBaseContainer extends Container // NPE protection... if( a == null || b == null ) + { return; + } ItemStack isA = a.getStack(); ItemStack isB = b.getStack(); // something to do? if( isA == null && isB == null ) + { return; + } // can take? if( isA != null && !a.canTakeStack( this.invPlayer.player ) ) + { return; + } if( isB != null && !b.canTakeStack( this.invPlayer.player ) ) + { return; + } // swap valid? if( isB != null && !a.isItemValid( isB ) ) + { return; + } if( isA != null && !b.isItemValid( isA ) ) + { return; + } ItemStack testA = isB == null ? null : isB.copy(); ItemStack testB = isA == null ? null : isA.copy(); @@ -1080,7 +1238,9 @@ public abstract class AEBaseContainer extends Container if( testA != null && testA.stackSize > a.getSlotStackLimit() ) { if( testB != null ) + { return; + } int totalA = testA.stackSize; testA.stackSize = a.getSlotStackLimit(); @@ -1092,7 +1252,9 @@ public abstract class AEBaseContainer extends Container if( testB != null && testB.stackSize > b.getSlotStackLimit() ) { if( testA != null ) + { return; + } int totalB = testB.stackSize; testB.stackSize = b.getSlotStackLimit(); diff --git a/src/main/java/appeng/container/ContainerOpenContext.java b/src/main/java/appeng/container/ContainerOpenContext.java index 6ee41b10..0380132b 100644 --- a/src/main/java/appeng/container/ContainerOpenContext.java +++ b/src/main/java/appeng/container/ContainerOpenContext.java @@ -45,7 +45,9 @@ public class ContainerOpenContext public TileEntity getTile() { if( this.isItem ) + { return null; + } return this.w.getTileEntity( this.x, this.y, this.z ); } } diff --git a/src/main/java/appeng/container/guisync/SyncData.java b/src/main/java/appeng/container/guisync/SyncData.java index 20e0707e..dca07d0d 100644 --- a/src/main/java/appeng/container/guisync/SyncData.java +++ b/src/main/java/appeng/container/guisync/SyncData.java @@ -60,9 +60,13 @@ public class SyncData { Object val = this.field.get( this.source ); if( val != null && this.clientVersion == null ) + { this.send( c, val ); + } else if( !val.equals( this.clientVersion ) ) + { this.send( c, val ); + } } catch( IllegalArgumentException e ) { @@ -83,7 +87,9 @@ public class SyncData if( val instanceof String ) { if( o instanceof EntityPlayerMP ) + { NetworkHandler.instance.sendTo( new PacketValueConfig( "SyncDat." + this.channel, (String) val ), (EntityPlayerMP) o ); + } } else if( this.field.getType().isEnum() ) { @@ -111,9 +117,13 @@ public class SyncData { Object oldValue = this.field.get( this.source ); if( val instanceof String ) + { this.updateString( oldValue, (String) val ); + } else + { this.updateValue( oldValue, (Long) val ); + } } catch( IllegalArgumentException e ) { @@ -160,17 +170,29 @@ public class SyncData else { if( this.field.getType().equals( int.class ) ) + { this.field.set( this.source, (int) val ); + } else if( this.field.getType().equals( long.class ) ) + { this.field.set( this.source, val ); + } else if( this.field.getType().equals( boolean.class ) ) + { this.field.set( this.source, val == 1 ); + } else if( this.field.getType().equals( Integer.class ) ) + { this.field.set( this.source, (int) val ); + } else if( this.field.getType().equals( Long.class ) ) + { this.field.set( this.source, val ); + } else if( this.field.getType().equals( Boolean.class ) ) + { this.field.set( this.source, val == 1 ); + } } this.source.onUpdate( this.field.getName(), oldValue, this.field.get( this.source ) ); diff --git a/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java b/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java index 07daec5b..0fb4cd2d 100644 --- a/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java +++ b/src/main/java/appeng/container/implementations/ContainerCellWorkbench.java @@ -67,7 +67,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable { ICellWorkbenchItem cwi = this.workBench.getCell(); if( cwi != null ) + { cwi.setFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ), valueOf ); + } } public void nextCopyMode() @@ -101,18 +103,22 @@ public class ContainerCellWorkbench extends ContainerUpgradeable // null, 3 * 8 ); for( int w = 0; w < 7; w++ ) + { for( int z = 0; z < 9; z++ ) { this.addSlotToContainer( new SlotFakeTypeOnly( inv, offset, x + z * 18, y + w * 18 ) ); offset++; } + } for( int zz = 0; zz < 3; zz++ ) + { for( int z = 0; z < 8; z++ ) { int iSLot = zz * 8 + z; this.addSlotToContainer( new OptionalSlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgradeInventory, this, iSLot, 187 + zz * 18, 8 + 18 * z, iSLot, this.invPlayer ) ); } + } /* * if ( supportCapacity() ) { for (int w = 0; w < 2; w++) for (int z = 0; z < 9; z++) addSlotToContainer( new * OptionalSlotFakeTypeOnly( inv, this, offset++, x, y, z, w, 1 ) ); @@ -187,7 +193,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable public void onUpdate( String field, Object oldValue, Object newValue ) { if( field.equals( "copyMode" ) ) + { this.workBench.getConfigManager().putSetting( Settings.COPY_MODE, this.copyMode ); + } super.onUpdate( field, oldValue, newValue ); } @@ -196,7 +204,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable { IInventory inv = this.upgradeable.getInventoryByName( "config" ); for( int x = 0; x < inv.getSizeInventory(); x++ ) + { inv.setInventorySlotContents( x, null ); + } this.detectAndSendChanges(); } @@ -204,7 +214,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable { ICellWorkbenchItem cwi = this.workBench.getCell(); if( cwi != null ) + { return cwi.getFuzzyMode( this.workBench.getInventoryByName( "cell" ).getStackInSlot( 0 ) ); + } return FuzzyMode.IGNORE_ALL; } @@ -230,7 +242,9 @@ public class ContainerCellWorkbench extends ContainerUpgradeable inv.setInventorySlotContents( x, g ); } else + { inv.setInventorySlotContents( x, null ); + } } this.detectAndSendChanges(); diff --git a/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java b/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java index 8b5a36aa..22315797 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftConfirm.java @@ -98,14 +98,22 @@ public class ContainerCraftConfirm extends AEBaseContainer public void cycleCpu( boolean next ) { if( next ) + { this.selectedCpu++; + } else + { this.selectedCpu--; + } if( this.selectedCpu < -1 ) + { this.selectedCpu = this.cpus.size() - 1; + } else if( this.selectedCpu >= this.cpus.size() ) + { this.selectedCpu = -1; + } if( this.selectedCpu == -1 ) { @@ -125,7 +133,9 @@ public class ContainerCraftConfirm extends AEBaseContainer public void detectAndSendChanges() { if( Platform.isClient() ) + { return; + } ICraftingGrid cc = this.getGrid().getCache( ICraftingGrid.class ); ImmutableSet cpuSet = cc.getCpus(); @@ -136,16 +146,24 @@ public class ContainerCraftConfirm extends AEBaseContainer { boolean found = false; for( CraftingCPURecord ccr : this.cpus ) + { if( ccr.cpu == c ) + { found = true; + } + } boolean matched = this.cpuMatches( c ); if( matched ) + { matches++; + } if( found == !matched ) + { changed = true; + } } if( changed || this.cpus.size() != matches ) @@ -154,7 +172,9 @@ public class ContainerCraftConfirm extends AEBaseContainer for( ICraftingCPU c : cpuSet ) { if( this.cpuMatches( c ) ) + { this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) ); + } } this.sendCPUs(); @@ -180,7 +200,9 @@ public class ContainerCraftConfirm extends AEBaseContainer } } else + { this.simulation = true; + } try { @@ -223,13 +245,19 @@ public class ContainerCraftConfirm extends AEBaseContainer } if( o.getStackSize() > 0 ) + { a.appendItem( o ); + } if( p.getStackSize() > 0 ) + { b.appendItem( p ); + } if( c != null && m != null && m.getStackSize() > 0 ) + { c.appendItem( m ); + } } for( Object g : this.crafters ) @@ -239,7 +267,9 @@ public class ContainerCraftConfirm extends AEBaseContainer NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g ); NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g ); if( c != null ) + { NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g ); + } } } } @@ -297,16 +327,24 @@ public class ContainerCraftConfirm extends AEBaseContainer IActionHost ah = this.getActionHost(); if( ah instanceof WirelessTerminalGuiObject ) + { OriginalGui = GuiBridge.GUI_WIRELESS_TERM; + } if( ah instanceof PartTerminal ) + { OriginalGui = GuiBridge.GUI_ME; + } if( ah instanceof PartCraftingTerminal ) + { OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL; + } if( ah instanceof PartPatternTerminal ) + { OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL; + } if( this.result != null && !this.simulation ) { diff --git a/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java b/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java index 89e51755..15e947f8 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftingCPU.java @@ -67,14 +67,20 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH { this.findNode( host, ForgeDirection.UNKNOWN ); for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { this.findNode( host, d ); + } } if( te instanceof TileCraftingTile ) + { this.setCPU( (ICraftingCPU) ( (TileCraftingTile) te ).getCluster() ); + } if( this.network == null && Platform.isServer() ) + { this.isContainerValid = false; + } } private void findNode( IGridHost host, ForgeDirection d ) @@ -83,17 +89,23 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH { IGridNode node = host.getGridNode( d ); if( node != null ) + { this.network = node.getGrid(); + } } } protected void setCPU( ICraftingCPU c ) { if( c == this.monitor ) + { return; + } if( this.monitor != null ) + { this.monitor.removeListener( this ); + } for( Object g : this.crafters ) { @@ -143,7 +155,9 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH super.removeCraftingFromCrafters( c ); if( this.crafters.isEmpty() && this.monitor != null ) + { this.monitor.removeListener( this ); + } } @Override @@ -151,7 +165,9 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH { super.onContainerClosed( player ); if( this.monitor != null ) + { this.monitor.removeListener( this ); + } } @Override @@ -179,13 +195,19 @@ public class ContainerCraftingCPU extends AEBaseContainer implements IMEMonitorH if( g instanceof EntityPlayer ) { if( !a.isEmpty() ) + { NetworkHandler.instance.sendTo( a, (EntityPlayerMP) g ); + } if( !b.isEmpty() ) + { NetworkHandler.instance.sendTo( b, (EntityPlayerMP) g ); + } if( !c.isEmpty() ) + { NetworkHandler.instance.sendTo( c, (EntityPlayerMP) g ); + } } } } diff --git a/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java b/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java index b505fd6c..c000e53f 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftingStatus.java @@ -60,16 +60,24 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU { boolean found = false; for( CraftingCPURecord ccr : this.cpus ) + { if( ccr.cpu == c ) + { found = true; + } + } boolean matched = this.cpuMatches( c ); if( matched ) + { matches++; + } if( found == !matched ) + { changed = true; + } } if( changed || this.cpus.size() != matches ) @@ -78,7 +86,9 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU for( ICraftingCPU c : cpuSet ) { if( this.cpuMatches( c ) ) + { this.cpus.add( new CraftingCPURecord( c.getAvailableStorage(), c.getCoProcessors(), c ) ); + } } this.sendCPUs(); @@ -109,31 +119,47 @@ public class ContainerCraftingStatus extends ContainerCraftingCPU } if( this.selectedCpu == -1 && this.cpus.size() > 0 ) + { this.selectedCpu = 0; + } if( this.selectedCpu != -1 ) { if( this.cpus.get( this.selectedCpu ).cpu != this.monitor ) + { this.setCPU( this.cpus.get( this.selectedCpu ).cpu ); + } } else + { this.setCPU( null ); + } } public void cycleCpu( boolean next ) { if( next ) + { this.selectedCpu++; + } else + { this.selectedCpu--; + } if( this.selectedCpu < -1 ) + { this.selectedCpu = this.cpus.size() - 1; + } else if( this.selectedCpu >= this.cpus.size() ) + { this.selectedCpu = -1; + } if( this.selectedCpu == -1 && this.cpus.size() > 0 ) + { this.selectedCpu = 0; + } if( this.selectedCpu == -1 ) { diff --git a/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java b/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java index 28d27bae..39cb8dcb 100644 --- a/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerCraftingTerm.java @@ -52,8 +52,12 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE IInventory crafting = this.ct.getInventoryByName( "crafting" ); for( int y = 0; y < 3; y++ ) + { for( int x = 0; x < 3; x++ ) + { this.addSlotToContainer( this.craftingSlots[x + y * 3] = new SlotCraftingMatrix( this, crafting, x + y * 3, 37 + x * 18, -72 + y * 18 ) ); + } + } this.addSlotToContainer( this.outputSlot = new SlotCraftingTerm( this.getPlayerInv().player, this.mySrc, this.powerSrc, monitorable, crafting, crafting, this.output, 131, -72 + 18, this ) ); @@ -72,7 +76,9 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE InventoryCrafting ic = new InventoryCrafting( cn, 3, 3 ); for( int x = 0; x < 9; x++ ) + { ic.setInventorySlotContents( x, this.craftingSlots[x].getStack() ); + } this.outputSlot.putStack( CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj ) ); } diff --git a/src/main/java/appeng/container/implementations/ContainerDrive.java b/src/main/java/appeng/container/implementations/ContainerDrive.java index c53636b1..a00a94d1 100644 --- a/src/main/java/appeng/container/implementations/ContainerDrive.java +++ b/src/main/java/appeng/container/implementations/ContainerDrive.java @@ -37,10 +37,12 @@ public class ContainerDrive extends AEBaseContainer this.drive = drive; for( int y = 0; y < 5; y++ ) + { for( int x = 0; x < 2; x++ ) { this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, drive, x + y * 2, 71 + x * 18, 14 + y * 18, this.invPlayer ) ); } + } this.bindPlayerInventory( ip, 0, 199 - /* height of player inventory */82 ); } diff --git a/src/main/java/appeng/container/implementations/ContainerFormationPlane.java b/src/main/java/appeng/container/implementations/ContainerFormationPlane.java index 7625031b..4ec34bc0 100644 --- a/src/main/java/appeng/container/implementations/ContainerFormationPlane.java +++ b/src/main/java/appeng/container/implementations/ContainerFormationPlane.java @@ -67,9 +67,13 @@ public class ContainerFormationPlane extends ContainerUpgradeable for( int x = 0; x < 9; x++ ) { if( y < 2 ) + { this.addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) ); + } else + { this.addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) ); + } } } diff --git a/src/main/java/appeng/container/implementations/ContainerIOPort.java b/src/main/java/appeng/container/implementations/ContainerIOPort.java index ad90b8d0..2dcb2538 100644 --- a/src/main/java/appeng/container/implementations/ContainerIOPort.java +++ b/src/main/java/appeng/container/implementations/ContainerIOPort.java @@ -65,14 +65,22 @@ public class ContainerIOPort extends ContainerUpgradeable IInventory cells = this.upgradeable.getInventoryByName( "cells" ); for( int y = 0; y < 3; y++ ) + { for( int x = 0; x < 2; x++ ) + { this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, cells, x + y * 2, offX + x * 18, offY + y * 18, this.invPlayer ) ); + } + } offX = 122; offY = 17; for( int y = 0; y < 3; y++ ) + { for( int x = 0; x < 2; x++ ) + { this.addSlotToContainer( new SlotOutput( cells, 6 + x + y * 2, offX + x * 18, offY + y * 18, SlotRestrictedInput.PlacableItemType.STORAGE_CELLS.IIcon ) ); + } + } IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" ); this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() ); diff --git a/src/main/java/appeng/container/implementations/ContainerInscriber.java b/src/main/java/appeng/container/implementations/ContainerInscriber.java index 94832a0a..d1ec1e3f 100644 --- a/src/main/java/appeng/container/implementations/ContainerInscriber.java +++ b/src/main/java/appeng/container/implementations/ContainerInscriber.java @@ -118,7 +118,9 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres for( ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() ) { if( Platform.isSameItemPrecise( optional, is ) ) + { return false; + } } boolean matches = false; @@ -138,13 +140,17 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres for( ItemStack option : recipe.getInputs() ) { if( Platform.isSameItemPrecise( is, option ) ) + { found = true; + } } } } if( matches && !found ) + { return false; + } } if( ( s == this.top && bot != null ) || ( s == this.bottom && top != null ) ) @@ -152,9 +158,13 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres boolean isValid = false; ItemStack otherSlot = null; if( s == this.top ) + { otherSlot = this.bottom.getStack(); + } else + { otherSlot = this.top.getStack(); + } // name presses final IItemDefinition namePress = AEApi.instance().definitions().materials().namePress(); @@ -176,11 +186,15 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres } if( isValid ) + { break; + } } if( !isValid ) + { return false; + } } return true; diff --git a/src/main/java/appeng/container/implementations/ContainerInterface.java b/src/main/java/appeng/container/implementations/ContainerInterface.java index 71c05f47..71dbd054 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterface.java +++ b/src/main/java/appeng/container/implementations/ContainerInterface.java @@ -51,13 +51,19 @@ public class ContainerInterface extends ContainerUpgradeable this.myDuality = te.getInterfaceDuality(); for( int x = 0; x < 9; x++ ) + { this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, this.myDuality.getPatterns(), x, 8 + 18 * x, 90 + 7, this.invPlayer ) ); + } for( int x = 0; x < 8; x++ ) + { this.addSlotToContainer( new SlotFake( this.myDuality.getConfig(), x, 17 + 18 * x, 35 ) ); + } for( int x = 0; x < 8; x++ ) + { this.addSlotToContainer( new SlotNormal( this.myDuality.getStorage(), x, 17 + 18 * x, 35 + 18 ) ); + } } @Override diff --git a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java index e90a29db..f24c561f 100644 --- a/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java +++ b/src/main/java/appeng/container/implementations/ContainerInterfaceTerminal.java @@ -72,7 +72,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer super( ip, anchor ); if( Platform.isServer() ) + { this.grid = anchor.getActionableNode().getGrid(); + } this.bindPlayerInventory( ip, 0, 222 - /* height of player inventory */82 ); } @@ -81,12 +83,16 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer public void detectAndSendChanges() { if( Platform.isClient() ) + { return; + } super.detectAndSendChanges(); if( this.grid == null ) + { return; + } int total = 0; boolean missing = false; @@ -103,17 +109,23 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer { IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO ) + { continue; + } InvTracker t = this.diList.get( ih ); if( t == null ) + { missing = true; + } else { DualityInterface dual = ih.getInterfaceDuality(); if( !t.unlocalizedName.equals( dual.getTermName() ) ) + { missing = true; + } } total++; @@ -126,17 +138,23 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer { IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); if( ih.getInterfaceDuality().getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.NO ) + { continue; + } InvTracker t = this.diList.get( ih ); if( t == null ) + { missing = true; + } else { DualityInterface dual = ih.getInterfaceDuality(); if( !t.unlocalizedName.equals( dual.getTermName() ) ) + { missing = true; + } } total++; @@ -146,7 +164,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer } if( total != this.diList.size() || missing ) + { this.regenList( this.data ); + } else { for( Entry en : this.diList.entrySet() ) @@ -155,7 +175,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer for( int x = 0; x < inv.server.getSizeInventory(); x++ ) { if( this.isDifferent( inv.server.getStackInSlot( x ), inv.client.getStackInSlot( x ) ) ) + { this.addItems( this.data, inv, x, 1 ); + } } } } @@ -199,7 +221,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer { ItemStack inSlot = theSlot.getStackInSlot( 0 ); if( inSlot == null ) + { player.inventory.setItemStack( interfaceSlot.addItems( player.inventory.getItemStack() ) ); + } else { inSlot = inSlot.copy(); @@ -211,7 +235,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) ); if( player.inventory.getItemStack() == null ) + { player.inventory.setItemStack( inSlot ); + } else { player.inventory.setItemStack( inHand ); @@ -232,17 +258,25 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer { ItemStack extra = playerHand.removeItems( 1, null, null ); if( extra != null ) + { extra = interfaceSlot.addItems( extra ); + } if( extra != null ) + { playerHand.addItems( extra ); + } } else if( is != null ) { ItemStack extra = interfaceSlot.removeItems( ( is.stackSize + 1 ) / 2, null, null ); if( extra != null ) + { extra = playerHand.addItems( extra ); + } if( extra != null ) + { interfaceSlot.addItems( extra ); + } } break; @@ -294,7 +328,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); DualityInterface dual = ih.getInterfaceDuality(); if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES ) + { this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) ); + } } for( IGridNode gn : this.grid.getMachines( PartInterface.class ) ) @@ -302,7 +338,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer IInterfaceHost ih = (IInterfaceHost) gn.getMachine(); DualityInterface dual = ih.getInterfaceDuality(); if( gn.isActive() && dual.getConfigManager().getSetting( Settings.INTERFACE_TERMINAL ) == YesNo.YES ) + { this.diList.put( ih, new InvTracker( dual, dual.getPatterns(), dual.getTermName() ) ); + } } } } @@ -320,10 +358,14 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer private boolean isDifferent( ItemStack a, ItemStack b ) { if( a == null && b == null ) + { return false; + } if( a == null || b == null ) + { return true; + } return !ItemStack.areItemStacksEqual( a, b ); } @@ -349,7 +391,9 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer inv.client.setInventorySlotContents( x + offset, is == null ? null : is.copy() ); if( is != null ) + { is.writeToNBT( itemNBT ); + } tag.setTag( Integer.toString( x + offset ), itemNBT ); } diff --git a/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java b/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java index 5d24e2b8..5135344e 100644 --- a/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java +++ b/src/main/java/appeng/container/implementations/ContainerLevelEmitter.java @@ -81,13 +81,21 @@ public class ContainerLevelEmitter extends ContainerUpgradeable IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" ); if( this.availableUpgrades() > 0 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() ); + } if( this.availableUpgrades() > 1 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer ) ).setNotDraggable() ); + } if( this.availableUpgrades() > 2 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer ) ).setNotDraggable() ); + } if( this.availableUpgrades() > 3 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer ) ).setNotDraggable() ); + } IInventory inv = this.upgradeable.getInventoryByName( "config" ); this.addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) ); @@ -129,7 +137,9 @@ public class ContainerLevelEmitter extends ContainerUpgradeable if( field.equals( "EmitterValue" ) ) { if( this.textField != null ) + { this.textField.setText( String.valueOf( this.EmitterValue ) ); + } } } } diff --git a/src/main/java/appeng/container/implementations/ContainerMAC.java b/src/main/java/appeng/container/implementations/ContainerMAC.java index 1c18c587..81d49d30 100644 --- a/src/main/java/appeng/container/implementations/ContainerMAC.java +++ b/src/main/java/appeng/container/implementations/ContainerMAC.java @@ -58,7 +58,9 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi ItemStack is = mac.getStackInSlot( 10 ); if( is == null ) + { return false; + } if( is.getItem() instanceof ItemEncodedPattern ) { @@ -66,7 +68,9 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); ICraftingPatternDetails ph = iep.getPatternForItem( is, w ); if( ph.isCraftable() ) + { return ph.isValidItemForSlot( slotIndex, i, w ); + } } return false; @@ -87,11 +91,13 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi IInventory mac = this.upgradeable.getInventoryByName( "mac" ); for( int y = 0; y < 3; y++ ) + { for( int x = 0; x < 3; x++ ) { SlotMACPattern s = new SlotMACPattern( this, mac, x + y * 3, offX + x * 18, offY + y * 18 ); this.addSlotToContainer( s ); } + } offX = 126; offY = 16; diff --git a/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java b/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java index 63f7d140..cfb3c5b4 100644 --- a/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java +++ b/src/main/java/appeng/container/implementations/ContainerMEMonitorable.java @@ -112,9 +112,13 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa this.cellInv = this.monitor; if( monitorable instanceof IPortableCell ) + { this.powerSrc = (IPortableCell) monitorable; + } else if( monitorable instanceof IMEChest ) + { this.powerSrc = (IMEChest) monitorable; + } else if( monitorable instanceof IGridHost ) { IGridNode node = ( (IGridHost) monitorable ).getGridNode( ForgeDirection.UNKNOWN ); @@ -123,15 +127,21 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa this.networkNode = node; IGrid g = node.getGrid(); if( g != null ) + { this.powerSrc = new ChannelPowerSrc( this.networkNode, (IEnergyGrid) g.getCache( IEnergyGrid.class ) ); + } } } } else + { this.isContainerValid = false; + } } else + { this.monitor = null; + } this.canAccessViewCells = false; if( monitorable instanceof IViewCellStorage ) @@ -145,7 +155,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa } if( bindInventory ) + { this.bindPlayerInventory( ip, 0, 0 ); + } } public IGridNode getNetworkNode() @@ -159,7 +171,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa if( Platform.isServer() ) { if( this.monitor != this.host.getItemInventory() ) + { this.isContainerValid = false; + } for( Settings set : this.serverCM.getSettings() ) { @@ -200,7 +214,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa piu.appendItem( is ); } else + { piu.appendItem( send ); + } } if( !piu.isEmpty() ) @@ -210,7 +226,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa for( Object c : this.crafters ) { if( c instanceof EntityPlayer ) + { NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c ); + } } } } @@ -229,7 +247,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa for( int y = 0; y < 5; y++ ) { if( this.cellView[y] != null ) + { this.cellView[y].allowEdit = this.canAccessViewCells; + } } } @@ -242,11 +262,17 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa try { if( this.networkNode != null ) + { this.hasPower = this.networkNode.isActive(); + } else if( this.powerSrc instanceof IEnergyGrid ) + { this.hasPower = ( (IEnergyGrid) this.powerSrc ).isNetworkPowered(); + } else + { this.hasPower = this.powerSrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.8; + } } catch( Throwable t ) { @@ -260,8 +286,12 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa if( field.equals( "canAccessViewCells" ) ) { for( int y = 0; y < 5; y++ ) + { if( this.cellView[y] != null ) + { this.cellView[y].allowEdit = this.canAccessViewCells; + } + } } super.onUpdate( field, oldValue, newValue ); @@ -313,7 +343,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa super.removeCraftingFromCrafters( c ); if( this.crafters.isEmpty() && this.monitor != null ) + { this.monitor.removeListener( this ); + } } @Override @@ -321,7 +353,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa { super.onContainerClosed( player ); if( this.monitor != null ) + { this.monitor.removeListener( this ); + } } @Override @@ -334,7 +368,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa public void postChange( IBaseMonitor monitor, Iterable change, BaseActionSource source ) { for( IAEItemStack is : change ) + { this.items.add( is ); + } } @Override @@ -354,14 +390,18 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) { if( this.gui != null ) + { this.gui.updateSetting( manager, settingName, newValue ); + } } @Override public IConfigManager getConfigManager() { if( Platform.isServer() ) + { return this.serverCM; + } return this.clientCM; } @@ -370,7 +410,9 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IConfigMa ItemStack[] list = new ItemStack[this.cellView.length]; for( int x = 0; x < this.cellView.length; x++ ) + { list[x] = this.cellView[x].getStack(); + } return list; } diff --git a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java index 155ccf15..c082c7f7 100644 --- a/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java +++ b/src/main/java/appeng/container/implementations/ContainerMEPortableCell.java @@ -68,16 +68,24 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable if( currentItem != null ) { if( Platform.isSameItem( this.civ.getItemStack(), currentItem ) ) + { this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.civ.getItemStack() ); + } else + { this.isContainerValid = false; + } } else + { this.isContainerValid = false; + } } } else + { this.isContainerValid = false; + } // drain 1 ae t this.ticks++; diff --git a/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java b/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java index 84bb9a0a..6f083f67 100644 --- a/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java +++ b/src/main/java/appeng/container/implementations/ContainerNetworkStatus.java @@ -67,11 +67,15 @@ public class ContainerNetworkStatus extends AEBaseContainer { this.findNode( host, ForgeDirection.UNKNOWN ); for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { this.findNode( host, d ); + } } if( this.network == null && Platform.isServer() ) + { this.isContainerValid = false; + } } private void findNode( IGridHost host, ForgeDirection d ) @@ -80,7 +84,9 @@ public class ContainerNetworkStatus extends AEBaseContainer { IGridNode node = host.getGridNode( d ); if( node != null ) + { this.network = node.getGrid(); + } } } @@ -123,13 +129,17 @@ public class ContainerNetworkStatus extends AEBaseContainer } for( IAEItemStack ais : list ) + { piu.appendItem( ais ); + } } for( Object c : this.crafters ) { if( c instanceof EntityPlayer ) + { NetworkHandler.instance.sendTo( piu, (EntityPlayerMP) c ); + } } } catch( IOException e ) diff --git a/src/main/java/appeng/container/implementations/ContainerNetworkTool.java b/src/main/java/appeng/container/implementations/ContainerNetworkTool.java index 38123197..3cebae3f 100644 --- a/src/main/java/appeng/container/implementations/ContainerNetworkTool.java +++ b/src/main/java/appeng/container/implementations/ContainerNetworkTool.java @@ -46,8 +46,12 @@ public class ContainerNetworkTool extends AEBaseContainer this.lockPlayerInventorySlot( ip.currentItem ); for( int y = 0; y < 3; y++ ) + { for( int x = 0; x < 3; x++ ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, te, y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this.invPlayer ) ) ); + } + } this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 ); } @@ -73,10 +77,14 @@ public class ContainerNetworkTool extends AEBaseContainer this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() ); } else + { this.isContainerValid = false; + } } else + { this.isContainerValid = false; + } } if( this.isContainerValid ) diff --git a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java index e6361a77..2573c7a2 100644 --- a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java @@ -91,8 +91,12 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA this.crafting = this.ct.getInventoryByName( "crafting" ); for( int y = 0; y < 3; y++ ) + { for( int x = 0; x < 3; x++ ) + { this.addSlotToContainer( this.craftingSlots[x + y * 3] = new SlotFakeCraftingMatrix( this.crafting, x + y * 3, 18 + x * 18, -76 + y * 18 ) ); + } + } this.addSlotToContainer( this.craftSlot = new SlotPatternTerm( ip.player, this.mySrc, this.powerSrc, monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this ) ); this.craftSlot.IIcon = -1; @@ -120,14 +124,18 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA this.craftSlot.xDisplayPosition = -9000; for( int y = 0; y < 3; y++ ) + { this.outputSlots[y].xDisplayPosition = this.outputSlots[y].defX; + } } else { this.craftSlot.xDisplayPosition = this.craftSlot.defX; for( int y = 0; y < 3; y++ ) + { this.outputSlots[y].xDisplayPosition = -9000; + } } } @@ -149,7 +157,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { InventoryCrafting ic = new InventoryCrafting( this, 3, 3 ); for( int x = 0; x < ic.getSizeInventory(); x++ ) + { ic.setInventorySlotContents( x, this.crafting.getStackInSlot( x ) ); + } ItemStack is = CraftingManager.getInstance().findMatchingRecipe( ic, this.getPlayerInv().player.worldObj ); this.cOut.setInventorySlotContents( 0, is ); @@ -177,23 +187,29 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA // if there is no input, this would be silly. if( in == null || out == null ) + { return; + } // first check the output slots, should either be null, or a pattern if( output != null && !this.isPattern( output ) ) + { return; - - // if nothing is there we should snag a new pattern. + }// if nothing is there we should snag a new pattern. else if( output == null ) { output = this.patternSlotIN.getStack(); if( output == null || !this.isPattern( output ) ) + { return; // no blanks. + } // remove one, and clear the input slot. output.stackSize--; if( output.stackSize == 0 ) + { this.patternSlotIN.putStack( null ); + } // add a new encoded pattern. for( ItemStack encodedPatternStack : AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ).asSet() ) @@ -210,10 +226,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA NBTTagList tagOut = new NBTTagList(); for( ItemStack i : in ) + { tagIn.appendTag( this.createItemTag( i ) ); + } for( ItemStack i : out ) + { tagOut.appendTag( this.createItemTag( i ) ); + } encodedValue.setTag( "in", tagIn ); encodedValue.setTag( "out", tagOut ); @@ -231,11 +251,15 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { input[x] = this.craftingSlots[x].getStack(); if( input[x] != null ) + { hasValue = true; + } } if( hasValue ) + { return input; + } return null; } @@ -246,7 +270,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { ItemStack out = this.getAndUpdateOutput(); if( out != null && out.stackSize > 0 ) + { return new ItemStack[] { out }; + } } else { @@ -264,7 +290,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA } if( hasValue ) + { return list.toArray( new ItemStack[list.size()] ); + } } return null; @@ -273,7 +301,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA private boolean isPattern( ItemStack output ) { if( output == null ) + { return false; + } final IDefinitions definitions = AEApi.instance().definitions(); @@ -288,7 +318,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA NBTTagCompound c = new NBTTagCompound(); if( i != null ) + { i.writeToNBT( c ); + } return c; } @@ -297,11 +329,17 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA public boolean isSlotEnabled( int idx ) { if( idx == 1 ) + { return Platform.isServer() ? !this.ct.isCraftingRecipe() : !this.craftingMode; + } else if( idx == 2 ) + { return Platform.isServer() ? this.ct.isCraftingRecipe() : this.craftingMode; + } else + { return false; + } } public void craftOrGetItem( PacketPatternSlot packetPatternSlot ) @@ -313,10 +351,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA InventoryAdaptor inv = new AdaptorPlayerHand( this.getPlayerInv().player ); InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player, ForgeDirection.UNKNOWN ); if( packetPatternSlot.shift ) + { inv = playerInv; + } if( inv.simulateAdd( out.getItemStack() ) != null ) + { return; + } IAEItemStack extracted = Platform.poweredExtraction( this.powerSrc, this.cellInv, out, this.mySrc ); EntityPlayer p = this.getPlayerInv().player; @@ -325,7 +367,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { inv.addItems( extracted.getItemStack() ); if( p instanceof EntityPlayerMP ) + { this.updateHeld( (EntityPlayerMP) p ); + } this.detectAndSendChanges(); return; } @@ -340,7 +384,9 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj ); if( r == null ) + { return; + } IMEMonitor storage = this.ct.getItemInventory(); IItemList all = storage.getStorageList(); @@ -367,12 +413,16 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA { ItemStack failed = playerInv.addItems( real.getStackInSlot( x ) ); if( failed != null ) + { p.dropPlayerItemWithRandomChoice( failed, false ); + } } inv.addItems( is ); if( p instanceof EntityPlayerMP ) + { this.updateHeld( (EntityPlayerMP) p ); + } this.detectAndSendChanges(); } else @@ -441,10 +491,14 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA public void clear() { for( Slot s : this.craftingSlots ) + { s.putStack( null ); + } for( Slot s : this.outputSlots ) + { s.putStack( null ); + } this.detectAndSendChanges(); this.getAndUpdateOutput(); diff --git a/src/main/java/appeng/container/implementations/ContainerPriority.java b/src/main/java/appeng/container/implementations/ContainerPriority.java index ad45106c..a554957f 100644 --- a/src/main/java/appeng/container/implementations/ContainerPriority.java +++ b/src/main/java/appeng/container/implementations/ContainerPriority.java @@ -82,7 +82,9 @@ public class ContainerPriority extends AEBaseContainer if( field.equals( "PriorityValue" ) ) { if( this.textField != null ) + { this.textField.setText( String.valueOf( this.PriorityValue ) ); + } } super.onUpdate( field, oldValue, newValue ); diff --git a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java index 5ecae41d..df53d532 100644 --- a/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java +++ b/src/main/java/appeng/container/implementations/ContainerQuartzKnife.java @@ -76,12 +76,18 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn if( currentItem != null ) { if( Platform.isSameItem( this.toolInv.getItemStack(), currentItem ) ) + { this.getPlayerInv().setInventorySlotContents( this.getPlayerInv().currentItem, this.toolInv.getItemStack() ); + } else + { this.isContainerValid = false; + } } else + { this.isContainerValid = false; + } } super.detectAndSendChanges(); @@ -91,7 +97,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn public void onContainerClosed( EntityPlayer par1EntityPlayer ) { if( this.inSlot.getStackInSlot( 0 ) != null ) + { par1EntityPlayer.dropPlayerItemWithRandomChoice( this.inSlot.getStackInSlot( 0 ), false ); + } } @Override @@ -117,7 +125,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn { ItemStack input = this.inSlot.getStackInSlot( 0 ); if( input == null ) + { return null; + } if( SlotRestrictedInput.isMetalIngot( input ) ) { @@ -143,7 +153,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn if( is != null ) { if( this.makePlate() ) + { return is; + } } return null; } @@ -176,7 +188,9 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn public void setInventorySlotContents( int var1, ItemStack var2 ) { if( var2 == null && Platform.isServer() ) + { this.makePlate(); + } } @Override diff --git a/src/main/java/appeng/container/implementations/ContainerSecurity.java b/src/main/java/appeng/container/implementations/ContainerSecurity.java index 2bee5bce..31325b76 100644 --- a/src/main/java/appeng/container/implementations/ContainerSecurity.java +++ b/src/main/java/appeng/container/implementations/ContainerSecurity.java @@ -79,9 +79,13 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE { IBiometricCard bc = (IBiometricCard) a.getItem(); if( bc.hasPermission( a, permission ) ) + { bc.removePermission( a, permission ); + } else + { bc.addPermission( a, permission ); + } } } catch( EnumConstantNotPresentException ex ) @@ -103,7 +107,9 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE IBiometricCard bc = (IBiometricCard) a.getItem(); for( SecurityPermissions sp : bc.getPermissions( a ) ) + { this.security |= ( 1 << sp.ordinal() ); + } } this.updatePowerStatus(); @@ -117,10 +123,14 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE super.onContainerClosed( player ); if( this.wirelessIn.getHasStack() ) + { player.dropPlayerItemWithRandomChoice( this.wirelessIn.getStack(), false ); + } if( this.wirelessOut.getHasStack() ) + { player.dropPlayerItemWithRandomChoice( this.wirelessOut.getStack(), false ); + } } @Override @@ -140,11 +150,15 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE INetworkEncodable networkEncodable = null; if( term.getItem() instanceof INetworkEncodable ) + { networkEncodable = (INetworkEncodable) term.getItem(); + } IWirelessTermHandler wTermHandler = AEApi.instance().registries().wireless().getWirelessTerminalHandler( term ); if( wTermHandler != null ) + { networkEncodable = wTermHandler; + } if( networkEncodable != null ) { diff --git a/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java b/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java index 21f709ce..5fe4b262 100644 --- a/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java +++ b/src/main/java/appeng/container/implementations/ContainerSpatialIOPort.java @@ -55,7 +55,9 @@ public class ContainerSpatialIOPort extends AEBaseContainer this.spatialIOPort = spatialIOPort; if( Platform.isServer() ) + { this.network = spatialIOPort.getGridNode( ForgeDirection.UNKNOWN ).getGrid(); + } this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, spatialIOPort, 0, 52, 48, this.invPlayer ) ); this.addSlotToContainer( new SlotOutput( spatialIOPort, 1, 113, 48, SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon ) ); diff --git a/src/main/java/appeng/container/implementations/ContainerStorageBus.java b/src/main/java/appeng/container/implementations/ContainerStorageBus.java index 07c4641b..a5ec6b6d 100644 --- a/src/main/java/appeng/container/implementations/ContainerStorageBus.java +++ b/src/main/java/appeng/container/implementations/ContainerStorageBus.java @@ -79,9 +79,13 @@ public class ContainerStorageBus extends ContainerUpgradeable for( int x = 0; x < 9; x++ ) { if( y < 2 ) + { this.addSlotToContainer( new SlotFakeTypeOnly( config, y * 9 + x, xo + x * 18, yo + y * 18 ) ); + } else + { this.addSlotToContainer( new OptionalSlotFakeTypeOnly( config, this, y * 9 + x, xo, yo, x, y, y - 2 ) ); + } } } @@ -132,7 +136,9 @@ public class ContainerStorageBus extends ContainerUpgradeable { IInventory inv = this.upgradeable.getInventoryByName( "config" ); for( int x = 0; x < inv.getSizeInventory(); x++ ) + { inv.setInventorySlotContents( x, null ); + } this.detectAndSendChanges(); } @@ -158,7 +164,9 @@ public class ContainerStorageBus extends ContainerUpgradeable inv.setInventorySlotContents( x, g ); } else + { inv.setInventorySlotContents( x, null ); + } } this.detectAndSendChanges(); diff --git a/src/main/java/appeng/container/implementations/ContainerUpgradeable.java b/src/main/java/appeng/container/implementations/ContainerUpgradeable.java index 58613574..9a81b78c 100644 --- a/src/main/java/appeng/container/implementations/ContainerUpgradeable.java +++ b/src/main/java/appeng/container/implementations/ContainerUpgradeable.java @@ -104,8 +104,12 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl if( this.hasToolbox() ) { for( int v = 0; v < 3; v++ ) + { for( int u = 0; u < 3; u++ ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, this.tbInventory, u + v * 3, 186 + u * 18, this.getHeight() - 82 + v * 18, this.invPlayer ) ).setPlayerSide() ); + } + } } this.setupConfig(); @@ -150,13 +154,21 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl { IInventory upgrades = this.upgradeable.getInventoryByName( "upgrades" ); if( this.availableUpgrades() > 0 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.invPlayer ) ).setNotDraggable() ); + } if( this.availableUpgrades() > 1 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 1, 187, 8 + 18, this.invPlayer ) ).setNotDraggable() ); + } if( this.availableUpgrades() > 2 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 2, 187, 8 + 18 * 2, this.invPlayer ) ).setNotDraggable() ); + } if( this.availableUpgrades() > 3 ) + { this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 3, 187, 8 + 18 * 3, this.invPlayer ) ).setNotDraggable() ); + } } protected boolean supportCapacity() @@ -188,7 +200,9 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl { OptionalSlotFake fs = (OptionalSlotFake) o; if( !fs.isEnabled() && fs.getDisplayStack() != null ) + { fs.clearStack(); + } } } @@ -200,7 +214,9 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl this.fzMode = (FuzzyMode) cm.getSetting( Settings.FUZZY_MODE ); this.rsMode = (RedstoneMode) cm.getSetting( Settings.REDSTONE_CONTROLLED ); if( this.upgradeable instanceof PartExportBus ) + { this.cMode = (YesNo) cm.getSetting( Settings.CRAFT_ONLY ); + } } public void checkToolbox() @@ -214,12 +230,18 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl if( currentItem != null ) { if( Platform.isSameItem( this.tbInventory.getItemStack(), currentItem ) ) + { this.getPlayerInv().setInventorySlotContents( this.tbSlot, this.tbInventory.getItemStack() ); + } else + { this.isContainerValid = false; + } } else + { this.isContainerValid = false; + } } } } @@ -235,9 +257,13 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl int upgrades = this.upgradeable.getInstalledUpgrades( Upgrades.CAPACITY ); if( idx == 1 && upgrades > 0 ) + { return true; + } if( idx == 2 && upgrades > 1 ) + { return true; + } return false; } diff --git a/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java b/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java index f05985d9..fb7e4927 100644 --- a/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerWirelessTerm.java @@ -46,7 +46,9 @@ public class ContainerWirelessTerm extends ContainerMEPortableCell if( !this.wirelessTerminalGUIObject.rangeCheck() ) { if( Platform.isServer() && this.isContainerValid ) + { this.getPlayerInv().player.addChatMessage( PlayerMessages.OutOfRange.get() ); + } this.isContainerValid = false; } diff --git a/src/main/java/appeng/container/implementations/CraftingCPURecord.java b/src/main/java/appeng/container/implementations/CraftingCPURecord.java index 04d61ea2..fb3b4960 100644 --- a/src/main/java/appeng/container/implementations/CraftingCPURecord.java +++ b/src/main/java/appeng/container/implementations/CraftingCPURecord.java @@ -44,7 +44,9 @@ public class CraftingCPURecord implements Comparable { int a = ItemSorters.compareLong( o.processors, this.processors ); if( a != 0 ) + { return a; + } return ItemSorters.compareLong( o.size, this.size ); } } \ No newline at end of file diff --git a/src/main/java/appeng/container/slot/AppEngSlot.java b/src/main/java/appeng/container/slot/AppEngSlot.java index 2ac0800e..9882c1ea 100644 --- a/src/main/java/appeng/container/slot/AppEngSlot.java +++ b/src/main/java/appeng/container/slot/AppEngSlot.java @@ -74,7 +74,9 @@ public class AppEngSlot extends Slot public boolean isItemValid( ItemStack par1ItemStack ) { if( this.isEnabled() ) + { return super.isItemValid( par1ItemStack ); + } return false; } @@ -82,10 +84,14 @@ public class AppEngSlot extends Slot public ItemStack getStack() { if( !this.isEnabled() ) + { return null; + } if( this.inventory.getSizeInventory() <= this.getSlotIndex() ) + { return null; + } if( this.isDisplay ) { @@ -103,7 +109,9 @@ public class AppEngSlot extends Slot super.putStack( par1ItemStack ); if( this.myContainer != null ) + { this.myContainer.onSlotChange( this ); + } } } @@ -111,9 +119,13 @@ public class AppEngSlot extends Slot public void onSlotChanged() { if( this.inventory instanceof AppEngInternalInventory ) + { ( (AppEngInternalInventory) this.inventory ).markDirty( this.getSlotIndex() ); + } else + { super.onSlotChanged(); + } this.isValid = hasCalculatedValidness.NotAvailable; } @@ -122,7 +134,9 @@ public class AppEngSlot extends Slot public boolean canTakeStack( EntityPlayer par1EntityPlayer ) { if( this.isEnabled() ) + { return super.canTakeStack( par1EntityPlayer ); + } return false; } diff --git a/src/main/java/appeng/container/slot/OptionalSlotFake.java b/src/main/java/appeng/container/slot/OptionalSlotFake.java index 89d90f1b..47a509f7 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotFake.java +++ b/src/main/java/appeng/container/slot/OptionalSlotFake.java @@ -49,7 +49,9 @@ public class OptionalSlotFake extends SlotFake if( !this.isEnabled() ) { if( this.getDisplayStack() != null ) + { this.clearStack(); + } } return super.getStack(); @@ -59,7 +61,9 @@ public class OptionalSlotFake extends SlotFake public boolean isEnabled() { if( this.host == null ) + { return false; + } return this.host.isSlotEnabled( this.groupNum ); } diff --git a/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java b/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java index 182895aa..5dbaa0a0 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java +++ b/src/main/java/appeng/container/slot/OptionalSlotFakeTypeOnly.java @@ -38,9 +38,13 @@ public class OptionalSlotFakeTypeOnly extends OptionalSlotFake { is = is.copy(); if( is.stackSize > 1 ) + { is.stackSize = 1; + } else if( is.stackSize < -1 ) + { is.stackSize = -1; + } } super.putStack( is ); diff --git a/src/main/java/appeng/container/slot/OptionalSlotNormal.java b/src/main/java/appeng/container/slot/OptionalSlotNormal.java index ca25b26e..eae5b639 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotNormal.java +++ b/src/main/java/appeng/container/slot/OptionalSlotNormal.java @@ -39,7 +39,9 @@ public class OptionalSlotNormal extends AppEngSlot public boolean isEnabled() { if( this.host == null ) + { return false; + } return this.host.isSlotEnabled( this.groupNum ); } diff --git a/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java b/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java index 26077b7f..45c194d0 100644 --- a/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java +++ b/src/main/java/appeng/container/slot/OptionalSlotRestrictedInput.java @@ -40,7 +40,9 @@ public class OptionalSlotRestrictedInput extends SlotRestrictedInput public boolean isEnabled() { if( this.host == null ) + { return false; + } return this.host.isSlotEnabled( this.groupNum ); } diff --git a/src/main/java/appeng/container/slot/SlotCraftingTerm.java b/src/main/java/appeng/container/slot/SlotCraftingTerm.java index d3764925..65f9e098 100644 --- a/src/main/java/appeng/container/slot/SlotCraftingTerm.java +++ b/src/main/java/appeng/container/slot/SlotCraftingTerm.java @@ -87,9 +87,13 @@ public class SlotCraftingTerm extends AppEngCraftingSlot public void doClick( InventoryAction action, EntityPlayer who ) { if( this.getStack() == null ) + { return; + } if( Platform.isClient() ) + { return; + } IMEMonitor inv = this.storage.getItemInventory(); int howManyPerCraft = this.getStack().stackSize; @@ -116,11 +120,15 @@ public class SlotCraftingTerm extends AppEngCraftingSlot maxTimesToCraft = this.CapCraftingAttempts( maxTimesToCraft ); if( ia == null ) + { return; + } ItemStack rs = Platform.cloneItemStack( this.getStack() ); if( rs == null ) + { return; + } for( int x = 0; x < maxTimesToCraft; x++ ) { @@ -158,7 +166,9 @@ public class SlotCraftingTerm extends AppEngCraftingSlot { InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 ); for( int x = 0; x < 9; x++ ) + { ic.setInventorySlotContents( x, this.pattern.getStackInSlot( x ) ); + } IRecipe r = Platform.findMatchingRecipe( ic, p.worldObj ); @@ -172,9 +182,13 @@ public class SlotCraftingTerm extends AppEngCraftingSlot { ItemStack pis = ic.getStackInSlot( x ); if( pis == null ) + { continue; + } if( pis.getItem() != target ) + { isBad = true; + } } if( !isBad ) { @@ -247,12 +261,16 @@ public class SlotCraftingTerm extends AppEngCraftingSlot // eek! put it back! IAEItemStack fail = inv.injectItems( AEItemStack.create( set[x] ), Actionable.MODULATE, this.mySrc ); if( fail != null ) + { drops.add( fail.getItemStack() ); + } } } } if( drops.size() > 0 ) + { Platform.spawnDrops( p.worldObj, (int) p.posX, (int) p.posY, (int) p.posZ, drops ); + } } } diff --git a/src/main/java/appeng/container/slot/SlotFake.java b/src/main/java/appeng/container/slot/SlotFake.java index bf6667ec..e4e3f53a 100644 --- a/src/main/java/appeng/container/slot/SlotFake.java +++ b/src/main/java/appeng/container/slot/SlotFake.java @@ -56,7 +56,9 @@ public class SlotFake extends AppEngSlot public void putStack( ItemStack is ) { if( is != null ) + { is = is.copy(); + } super.putStack( is ); } diff --git a/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java b/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java index 602ee81f..686c87a8 100644 --- a/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java +++ b/src/main/java/appeng/container/slot/SlotFakeTypeOnly.java @@ -38,9 +38,13 @@ public class SlotFakeTypeOnly extends SlotFake { is = is.copy(); if( is.stackSize > 1 ) + { is.stackSize = 1; + } else if( is.stackSize < -1 ) + { is.stackSize = -1; + } } super.putStack( is ); diff --git a/src/main/java/appeng/container/slot/SlotInaccessible.java b/src/main/java/appeng/container/slot/SlotInaccessible.java index 73a5dbbb..f7f8eedc 100644 --- a/src/main/java/appeng/container/slot/SlotInaccessible.java +++ b/src/main/java/appeng/container/slot/SlotInaccessible.java @@ -60,7 +60,9 @@ public class SlotInaccessible extends AppEngSlot { ItemStack dsp = super.getDisplayStack(); if( dsp != null ) + { this.dspStack = dsp.copy(); + } } return this.dspStack; } diff --git a/src/main/java/appeng/container/slot/SlotPatternTerm.java b/src/main/java/appeng/container/slot/SlotPatternTerm.java index 39288d51..ad45ced8 100644 --- a/src/main/java/appeng/container/slot/SlotPatternTerm.java +++ b/src/main/java/appeng/container/slot/SlotPatternTerm.java @@ -59,7 +59,9 @@ public class SlotPatternTerm extends SlotCraftingTerm if( !this.isEnabled() ) { if( this.getDisplayStack() != null ) + { this.clearStack(); + } } return super.getStack(); @@ -69,7 +71,9 @@ public class SlotPatternTerm extends SlotCraftingTerm public boolean isEnabled() { if( this.host == null ) + { return false; + } return this.host.isSlotEnabled( this.groupNum ); } diff --git a/src/main/java/appeng/container/slot/SlotRestrictedInput.java b/src/main/java/appeng/container/slot/SlotRestrictedInput.java index 8ada8965..eafe6a32 100644 --- a/src/main/java/appeng/container/slot/SlotRestrictedInput.java +++ b/src/main/java/appeng/container/slot/SlotRestrictedInput.java @@ -71,7 +71,9 @@ public class SlotRestrictedInput extends AppEngSlot public int getSlotStackLimit() { if( this.stackLimit != -1 ) + { return this.stackLimit; + } return super.getSlotStackLimit(); } @@ -95,18 +97,28 @@ public class SlotRestrictedInput extends AppEngSlot public boolean isItemValid( ItemStack i ) { if( !this.myContainer.isValidForSlot( this, i ) ) + { return false; + } if( i == null ) + { return false; + } if( i.getItem() == null ) + { return false; + } if( !this.inventory.isItemValidForSlot( this.getSlotIndex(), i ) ) + { return false; + } if( !this.allowEdit ) + { return false; + } final IDefinitions definitions = AEApi.instance().definitions(); final IMaterials materials = definitions.materials(); @@ -120,7 +132,9 @@ public class SlotRestrictedInput extends AppEngSlot ICraftingPatternItem b = (ICraftingPatternItem) i.getItem(); ICraftingPatternDetails de = b.getPatternForItem( i, this.p.player.worldObj ); if( de != null ) + { return de.isCraftable(); + } } return false; case VALID_ENCODED_PATTERN_W_OUTPUT: @@ -128,7 +142,9 @@ public class SlotRestrictedInput extends AppEngSlot case ENCODED_PATTERN: { if( i.getItem() instanceof ICraftingPatternItem ) + { return true; + } // ICraftingPatternDetails pattern = i.getItem() instanceof ICraftingPatternItem ? ((ICraftingPatternItem) // i.getItem()).getPatternForItem( i ) : null; return false;// pattern != null; @@ -139,7 +155,9 @@ public class SlotRestrictedInput extends AppEngSlot case PATTERN: if( i.getItem() instanceof ICraftingPatternItem ) + { return true; + } return materials.blankPattern().isSameAs( i ); @@ -150,8 +168,12 @@ public class SlotRestrictedInput extends AppEngSlot } for( ItemStack optional : AEApi.instance().registries().inscriber().getOptionals() ) + { if( Platform.isSameItemPrecise( optional, i ) ) + { return true; + } + } return false; @@ -190,7 +212,9 @@ public class SlotRestrictedInput extends AppEngSlot return i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i ); case TRASH: if( AEApi.instance().registries().cell().isCellHandled( i ) ) + { return false; + } return !( i.getItem() instanceof IStorageComponent && ( (IStorageComponent) i.getItem() ).isStorageComponent( i ) ); case ENCODABLE_ITEM: @@ -223,7 +247,9 @@ public class SlotRestrictedInput extends AppEngSlot ItemEncodedPattern iep = (ItemEncodedPattern) is.getItem(); ItemStack out = iep.getOutput( is ); if( out != null ) + { return out; + } } } return super.getStack(); @@ -232,14 +258,18 @@ public class SlotRestrictedInput extends AppEngSlot public static boolean isMetalIngot( ItemStack i ) { if( Platform.isSameItemPrecise( i, new ItemStack( Items.iron_ingot ) ) ) + { return true; + } for( String name : new String[] { "Copper", "Tin", "Obsidian", "Iron", "Lead", "Bronze", "Brass", "Nickel", "Aluminium" } ) { for( ItemStack ingot : OreDictionary.getOres( "ingot" + name ) ) { if( Platform.isSameItemPrecise( i, ingot ) ) + { return true; + } } } diff --git a/src/main/java/appeng/core/AEConfig.java b/src/main/java/appeng/core/AEConfig.java index 6eca28f6..574459e6 100644 --- a/src/main/java/appeng/core/AEConfig.java +++ b/src/main/java/appeng/core/AEConfig.java @@ -174,10 +174,14 @@ public final class AEConfig extends Configuration implements IConfigurableObject if( feature.isVisible ) { if( this.get( "Features." + feature.category, feature.name(), feature.defaultValue ).getBoolean( feature.defaultValue ) ) + { this.featureFlags.add( feature ); + } } else + { this.featureFlags.add( feature ); + } } ModContainer imb = cpw.mods.fml.common.Loader.instance().getIndexedModList().get( "ImmibisCore" ); @@ -185,7 +189,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject { List version = Arrays.asList( "59.0.0", "59.0.1", "59.0.2" ); if( version.contains( imb.getVersion() ) ) + { this.featureFlags.remove( AEFeature.AlphaPass ); + } } try @@ -279,9 +285,13 @@ public final class AEConfig extends Configuration implements IConfigurableObject { Enum eg = (Enum) Oeg; if( comment == null ) + { comment = "Possible Values: " + eg.name(); + } else + { comment += ", " + eg.name(); + } } } @@ -316,7 +326,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject if( prop != null ) { if( !category.equals( "Client" ) ) + { prop.setRequiresMcRestart( true ); + } } return prop; @@ -334,7 +346,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject this.get( "Client", "PowerUnit", this.selectedPowerUnit.name(), this.getListComment( this.selectedPowerUnit ) ).set( this.selectedPowerUnit.name() ); if( this.hasChanged() ) + { super.save(); + } } @SubscribeEvent @@ -359,7 +373,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject public boolean useAEVersion( MaterialType mt ) { if( this.isFeatureEnabled( AEFeature.WebsiteRecipes ) ) + { return true; + } this.setCategoryComment( "OreCamouflage", "AE2 Automatically uses alternative ores present in your instance of MC to blend better with its surroundings, if you prefer you can disable this selectively using these flags; Its important to note, that some if these items even if enabled may not be craftable in game because other items are overriding their recipes." ); Property p = this.get( "OreCamouflage", mt.name(), true ); @@ -382,7 +398,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject } if( this.updatable ) + { this.save(); + } } public int getFreeMaterial( int varID ) @@ -400,7 +418,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject int thisInt = p.getInt(); if( varID == thisInt ) + { alreadyUsed = true; + } min = Math.max( min, thisInt + 1 ); } @@ -408,7 +428,9 @@ public final class AEConfig extends Configuration implements IConfigurableObject if( alreadyUsed ) { if( min < 16383 ) + { min = 16383; + } return min; } diff --git a/src/main/java/appeng/core/Api.java b/src/main/java/appeng/core/Api.java index bc32112d..ed4ba296 100644 --- a/src/main/java/appeng/core/Api.java +++ b/src/main/java/appeng/core/Api.java @@ -119,7 +119,9 @@ public final class Api implements IAppEngApi public IGridNode createGridNode( IGridBlock blk ) { if ( Platform.isClient() ) + { throw new IllegalStateException( "Grid features for " + blk + " are server side only." ); + } return new GridNode( blk ); } diff --git a/src/main/java/appeng/core/AppEng.java b/src/main/java/appeng/core/AppEng.java index 8cb16379..903096f1 100644 --- a/src/main/java/appeng/core/AppEng.java +++ b/src/main/java/appeng/core/AppEng.java @@ -121,10 +121,14 @@ public final class AppEng CreativeTab.init(); if( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) ) + { CreativeTabFacade.init(); + } if( Platform.isClient() ) + { CommonHelper.proxy.init(); + } Registration.INSTANCE.preInitialize( event ); diff --git a/src/main/java/appeng/core/FacadeConfig.java b/src/main/java/appeng/core/FacadeConfig.java index 662689f3..05065364 100644 --- a/src/main/java/appeng/core/FacadeConfig.java +++ b/src/main/java/appeng/core/FacadeConfig.java @@ -46,7 +46,9 @@ public class FacadeConfig extends Configuration public boolean checkEnabled( Block id, int metadata, boolean automatic ) { if( id == null ) + { return false; + } UniqueIdentifier blk = GameRegistry.findUniqueIdentifierFor( id ); if( blk == null ) @@ -56,7 +58,9 @@ public class FacadeConfig extends Configuration try { if( f.get( Block.class ) == id ) + { return this.get( "minecraft", f.getName() + ( metadata == 0 ? "" : "." + metadata ), automatic ).getBoolean( automatic ); + } } catch( Throwable e ) { diff --git a/src/main/java/appeng/core/Registration.java b/src/main/java/appeng/core/Registration.java index 37898f4a..4e5b58c5 100644 --- a/src/main/java/appeng/core/Registration.java +++ b/src/main/java/appeng/core/Registration.java @@ -178,7 +178,9 @@ public final class Registration private void registerSpatial( boolean force ) { if( !AEConfig.instance.isFeatureEnabled( AEFeature.SpatialIO ) ) + { return; + } AEConfig config = AEConfig.instance; @@ -188,14 +190,18 @@ public final class Registration { config.storageBiomeID = Platform.findEmpty( BiomeGenBase.getBiomeGenArray() ); if( config.storageBiomeID == -1 ) + { throw new IllegalStateException( "Biome Array is full, please free up some Biome ID's or disable spatial." ); + } this.storageBiome = new BiomeGenStorage( config.storageBiomeID ); config.save(); } if( !force && config.storageBiomeID != -1 ) + { this.storageBiome = new BiomeGenStorage( config.storageBiomeID ); + } } if( config.storageProviderID != -1 ) @@ -208,7 +214,9 @@ public final class Registration config.storageProviderID = -11; while( !DimensionManager.registerProviderType( config.storageProviderID, StorageWorldProvider.class, false ) ) + { config.storageProviderID--; + } config.save(); } @@ -508,9 +516,13 @@ public final class Registration ItemMultiMaterial.instance.makeUnique(); if( AEConfig.instance.isFeatureEnabled( AEFeature.CustomRecipes ) ) + { this.recipeHandler.parseRecipes( new ConfigLoader( AppEng.instance.getConfigDirectory() ), "index.recipe" ); + } else + { this.recipeHandler.parseRecipes( new JarLoader( "/assets/appliedenergistics2/recipes/" ), "index.recipe" ); + } partHelper.registerNewLayer( "appeng.parts.layers.LayerISidedInventory", "net.minecraft.inventory.ISidedInventory" ); partHelper.registerNewLayer( "appeng.parts.layers.LayerIFluidHandler", "net.minecraftforge.fluids.IFluidHandler" ); @@ -523,7 +535,9 @@ public final class Registration } if( AppEng.instance.isIntegrationEnabled( IntegrationType.RF ) ) + { partHelper.registerNewLayer( "appeng.parts.layers.LayerIEnergyHandler", "cofh.api.energy.IEnergyReceiver" ); + } FMLCommonHandler.instance().bus().register( TickHandler.INSTANCE ); MinecraftForge.EVENT_BUS.register( TickHandler.INSTANCE ); @@ -685,10 +699,14 @@ public final class Registration // add villager trading to black smiths for a few basic materials if( AEConfig.instance.isFeatureEnabled( AEFeature.VillagerTrading ) ) + { VillagerRegistry.instance().registerVillageTradeHandler( 3, new AETrading() ); + } if( AEConfig.instance.isFeatureEnabled( AEFeature.CertusQuartzWorldGen ) ) + { GameRegistry.registerWorldGenerator( new QuartzWorldGen(), 0 ); + } if( AEConfig.instance.isFeatureEnabled( AEFeature.MeteoriteWorldGen ) ) { diff --git a/src/main/java/appeng/core/WorldSettings.java b/src/main/java/appeng/core/WorldSettings.java index 8845f614..d2ebf3b4 100644 --- a/src/main/java/appeng/core/WorldSettings.java +++ b/src/main/java/appeng/core/WorldSettings.java @@ -146,7 +146,9 @@ public class WorldSettings extends Configuration // edit. int size = data.getInteger( "num" ); for( int s = 0; s < size; s++ ) + { ll.add( data.getCompoundTag( String.valueOf( s ) ) ); + } } } } @@ -158,7 +160,9 @@ public class WorldSettings extends Configuration NBTTagCompound loadSpawnData( int dim, int chunkX, int chunkZ ) { if( !Thread.holdsLock( WorldSettings.class ) ) + { throw new IllegalStateException( "Invalid Request" ); + } NBTTagCompound data = null; File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" ); @@ -225,7 +229,9 @@ public class WorldSettings extends Configuration void writeSpawnData( int dim, int chunkX, int chunkZ, NBTTagCompound data ) { if( !Thread.holdsLock( WorldSettings.class ) ) + { throw new IllegalStateException( "Invalid Request" ); + } File file = new File( this.spawnDataFolder, dim + '_' + ( chunkX >> 4 ) + '_' + ( chunkZ >> 4 ) + ".dat" ); FileOutputStream fileOutputStream = null; @@ -277,7 +283,9 @@ public class WorldSettings extends Configuration this.save(); for( Integer dimID : this.storageCellDims ) + { DimensionManager.unregisterDimension( dimID ); + } this.storageCellDims.clear(); @@ -301,7 +309,9 @@ public class WorldSettings extends Configuration // save to files if( this.hasChanged() ) + { super.save(); + } } public void addStorageCellDim( int newDim ) @@ -314,7 +324,9 @@ public class WorldSettings extends Configuration String[] values = new String[this.storageCellDims.size()]; for( int x = 0; x < values.length; x++ ) + { values[x] = String.valueOf( this.storageCellDims.get( x ) ); + } this.get( "DimensionManager", "StorageCells", new int[0] ).set( values ); this.save(); @@ -337,7 +349,9 @@ public class WorldSettings extends Configuration else { for( PlayerColor pc : TickHandler.INSTANCE.getPlayerColors().values() ) + { NetworkHandler.instance.sendToAll( pc.getPacket() ); + } } } @@ -427,13 +441,17 @@ public class WorldSettings extends Configuration ConfigCategory playerList = this.getCategory( "players" ); if( playerList == null || profile == null || !profile.isComplete() ) + { return -1; + } String uuid = profile.getId().toString(); Property prop = playerList.get( uuid ); if( prop != null && prop.isIntValue() ) + { return prop.getInt(); + } else { playerList.put( uuid, prop = new Property( uuid, String.valueOf( this.nextPlayer() ), Property.Type.INTEGER ) ); @@ -461,7 +479,9 @@ public class WorldSettings extends Configuration for( EntityPlayer player : CommonHelper.proxy.getPlayers() ) { if( player.getUniqueID().equals( uuid ) ) + { return player; + } } } diff --git a/src/main/java/appeng/core/api/ApiPart.java b/src/main/java/appeng/core/api/ApiPart.java index ea302965..3e75efde 100644 --- a/src/main/java/appeng/core/api/ApiPart.java +++ b/src/main/java/appeng/core/api/ApiPart.java @@ -74,7 +74,9 @@ public class ApiPart implements IPartHelper for( Class layerInterface : this.interfaces2Layer.keySet() ) { if( AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) + { ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).registerPassThrough( layerInterface ); + } } } @@ -147,7 +149,9 @@ public class ApiPart implements IPartHelper public Class getClassByDesc( String Addendum, String fullPath, String root, String next ) { if( this.roots.get( fullPath ) != null ) + { return this.roots.get( fullPath ); + } ClassWriter cw = new ClassWriter( ClassWriter.COMPUTE_MAXS ); ClassNode n = this.getReader( next ); @@ -313,7 +317,9 @@ public class ApiPart implements IPartHelper return true; } else + { AELog.info( "Layer " + layer + " not registered, " + layerInterface + " already has a layer." ); + } } catch( Throwable ignored ) { @@ -326,7 +332,9 @@ public class ApiPart implements IPartHelper public void setItemBusRenderer( IPartItem i ) { if( Platform.isClient() && i instanceof Item ) + { MinecraftForgeClient.registerItemRenderer( (Item) i, BusRenderer.INSTANCE ); + } } @Override @@ -351,7 +359,9 @@ public class ApiPart implements IPartHelper { String o = this.inputOutput.get( typeName ); if( o == null ) + { return typeName; + } return o; } } diff --git a/src/main/java/appeng/core/api/imc/IMCGrinder.java b/src/main/java/appeng/core/api/imc/IMCGrinder.java index d272d2ca..d8c0284c 100644 --- a/src/main/java/appeng/core/api/imc/IMCGrinder.java +++ b/src/main/java/appeng/core/api/imc/IMCGrinder.java @@ -77,10 +77,14 @@ public class IMCGrinder implements IIMCProcessor int turns = msg.getInteger( "turns" ); if( in == null ) + { throw new IllegalStateException( "invalid input" ); + } if( out == null ) + { throw new IllegalStateException( "invalid output" ); + } if( msg.hasKey( "optional" ) ) { @@ -88,13 +92,17 @@ public class IMCGrinder implements IIMCProcessor ItemStack optional = ItemStack.loadItemStackFromNBT( optionalTag ); if( optional == null ) + { throw new IllegalStateException( "invalid optional" ); + } float chance = msg.getFloat( "chance" ); AEApi.instance().registries().grinder().addRecipe( in, out, optional, chance, turns ); } else + { AEApi.instance().registries().grinder().addRecipe( in, out, turns ); + } } } diff --git a/src/main/java/appeng/core/api/imc/IMCMatterCannon.java b/src/main/java/appeng/core/api/imc/IMCMatterCannon.java index d990a6bb..958363c4 100644 --- a/src/main/java/appeng/core/api/imc/IMCMatterCannon.java +++ b/src/main/java/appeng/core/api/imc/IMCMatterCannon.java @@ -54,7 +54,9 @@ public class IMCMatterCannon implements IIMCProcessor double weight = msg.getDouble( "weight" ); if( ammo == null ) + { throw new IllegalStateException( "invalid item in message " + m ); + } AEApi.instance().registries().matterCannon().registerAmmo( ammo, weight ); } diff --git a/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java b/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java index 4a6a4e52..59f1b5b0 100644 --- a/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java +++ b/src/main/java/appeng/core/api/imc/IMCP2PAttunement.java @@ -55,11 +55,17 @@ public class IMCP2PAttunement implements IIMCProcessor { ItemStack is = m.getItemStackValue(); if( is != null ) + { AEApi.instance().registries().p2pTunnel().addNewAttunement( is, type ); + } else + { throw new IllegalStateException( "invalid item in message " + m ); + } } else + { throw new IllegalStateException( "invalid type in message " + m + " is not contained in " + Arrays.toString( TunnelType.values() ) ); + } } } diff --git a/src/main/java/appeng/core/features/ColoredItemDefinition.java b/src/main/java/appeng/core/features/ColoredItemDefinition.java index d777a507..070a0a9d 100644 --- a/src/main/java/appeng/core/features/ColoredItemDefinition.java +++ b/src/main/java/appeng/core/features/ColoredItemDefinition.java @@ -50,7 +50,9 @@ public final class ColoredItemDefinition implements AEColoredItemDefinition ItemStackSrc is = this.colors[color.ordinal()]; if( is == null ) + { return null; + } return is.item; } @@ -67,7 +69,9 @@ public final class ColoredItemDefinition implements AEColoredItemDefinition ItemStackSrc is = this.colors[color.ordinal()]; if( is == null ) + { return null; + } return is.stack( stackSize ); } @@ -77,7 +81,9 @@ public final class ColoredItemDefinition implements AEColoredItemDefinition { ItemStack[] is = new ItemStack[this.colors.length]; for( int x = 0; x < is.length; x++ ) + { is[x] = this.colors[x].stack( 1 ); + } return is; } @@ -87,7 +93,9 @@ public final class ColoredItemDefinition implements AEColoredItemDefinition ItemStackSrc is = this.colors[color.ordinal()]; if( comparableItem == null || is == null ) + { return false; + } return comparableItem.getItem() == is.item && comparableItem.getItemDamage() == is.damage; } diff --git a/src/main/java/appeng/core/features/DamagedItemDefinition.java b/src/main/java/appeng/core/features/DamagedItemDefinition.java index 05913032..ad6f22fc 100644 --- a/src/main/java/appeng/core/features/DamagedItemDefinition.java +++ b/src/main/java/appeng/core/features/DamagedItemDefinition.java @@ -57,7 +57,9 @@ public final class DamagedItemDefinition implements IItemDefinition public boolean isSameAs( ItemStack comparableStack ) { if( comparableStack == null ) + { return false; + } return comparableStack.getItem() == this.source.getItem() && comparableStack.getItemDamage() == this.source.getDamage(); } diff --git a/src/main/java/appeng/core/features/ItemStackSrc.java b/src/main/java/appeng/core/features/ItemStackSrc.java index 7d6cd2bc..734f67f1 100644 --- a/src/main/java/appeng/core/features/ItemStackSrc.java +++ b/src/main/java/appeng/core/features/ItemStackSrc.java @@ -49,10 +49,14 @@ public class ItemStackSrc implements IStackSrc public ItemStack stack( int i ) { if( this.block != null ) + { return new ItemStack( this.block, i, this.damage ); + } if( this.item != null ) + { return new ItemStack( this.item, i, this.damage ); + } return null; } diff --git a/src/main/java/appeng/core/features/NameResolver.java b/src/main/java/appeng/core/features/NameResolver.java index f3caec2d..ec3a01ba 100644 --- a/src/main/java/appeng/core/features/NameResolver.java +++ b/src/main/java/appeng/core/features/NameResolver.java @@ -51,21 +51,31 @@ public final class NameResolver String name = this.withOriginalName.getSimpleName(); if( name.startsWith( "ItemMultiPart" ) ) + { name = ITEM_MULTI_PART.matcher( name ).replaceAll( "ItemPart" ); + } else if( name.startsWith( "ItemMultiMaterial" ) ) + { name = ITEM_MULTI_MATERIAL.matcher( name ).replaceAll( "ItemMaterial" ); + } if( subName != null ) { // simple hack to allow me to do get nice names for these without // mode code outside of AEBaseItem if( subName.startsWith( "P2PTunnel" ) ) + { return "ItemPart.P2PTunnel"; + } if( subName.equals( "CertusQuartzTools" ) ) + { return QUARTZ.matcher( name ).replaceAll( "CertusQuartz" ); + } if( subName.equals( "NetherQuartzTools" ) ) + { return QUARTZ.matcher( name ).replaceAll( "NetherQuartz" ); + } name += '.' + subName; } diff --git a/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java b/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java index 6020641b..deb77b37 100644 --- a/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java +++ b/src/main/java/appeng/core/features/WrappedDamageItemDefinition.java @@ -79,7 +79,9 @@ public final class WrappedDamageItemDefinition implements ITileDefinition public boolean isSameAs( ItemStack comparableStack ) { if( comparableStack == null ) + { return false; + } return this.definition.isSameAs( comparableStack ) && comparableStack.getItemDamage() == this.damage; } diff --git a/src/main/java/appeng/core/features/registries/CellRegistry.java b/src/main/java/appeng/core/features/registries/CellRegistry.java index d658cc73..3e5680db 100644 --- a/src/main/java/appeng/core/features/registries/CellRegistry.java +++ b/src/main/java/appeng/core/features/registries/CellRegistry.java @@ -45,17 +45,25 @@ public class CellRegistry implements ICellRegistry public void addCellHandler( ICellHandler h ) { if( h != null ) + { this.handlers.add( h ); + } } @Override public boolean isCellHandled( ItemStack is ) { if( is == null ) + { return false; + } for( ICellHandler ch : this.handlers ) + { if( ch.isCell( is ) ) + { return true; + } + } return false; } @@ -63,7 +71,9 @@ public class CellRegistry implements ICellRegistry public ICellHandler getHandler( ItemStack is ) { if( is == null ) + { return null; + } for( ICellHandler ch : this.handlers ) { if( ch.isCell( is ) ) @@ -78,7 +88,9 @@ public class CellRegistry implements ICellRegistry public IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider container, StorageChannel chan ) { if( is == null ) + { return null; + } for( ICellHandler ch : this.handlers ) { if( ch.isCell( is ) ) diff --git a/src/main/java/appeng/core/features/registries/ExternalStorageRegistry.java b/src/main/java/appeng/core/features/registries/ExternalStorageRegistry.java index 46cc1eec..085b8aa1 100644 --- a/src/main/java/appeng/core/features/registries/ExternalStorageRegistry.java +++ b/src/main/java/appeng/core/features/registries/ExternalStorageRegistry.java @@ -55,11 +55,15 @@ public class ExternalStorageRegistry implements IExternalStorageRegistry for( IExternalStorageHandler x : this.Handlers ) { if( x.canHandle( te, d, chan, mySrc ) ) + { return x; + } } if( this.lastHandler.canHandle( te, d, chan, mySrc ) ) + { return this.lastHandler; + } return null; } diff --git a/src/main/java/appeng/core/features/registries/GridCacheRegistry.java b/src/main/java/appeng/core/features/registries/GridCacheRegistry.java index b5a5d566..785eec00 100644 --- a/src/main/java/appeng/core/features/registries/GridCacheRegistry.java +++ b/src/main/java/appeng/core/features/registries/GridCacheRegistry.java @@ -38,9 +38,13 @@ public final class GridCacheRegistry implements IGridCacheRegistry public void registerGridCache( Class iface, Class implementation ) { if( iface.isAssignableFrom( implementation ) ) + { this.caches.put( iface, implementation ); + } else + { throw new IllegalArgumentException( "Invalid setup, grid cache must either be the same class, or an interface that the implementation implements. Gotten: " + iface + " and " + implementation ); + } } @Override diff --git a/src/main/java/appeng/core/features/registries/GrinderRecipeManager.java b/src/main/java/appeng/core/features/registries/GrinderRecipeManager.java index 434b82f6..cb1215d7 100644 --- a/src/main/java/appeng/core/features/registries/GrinderRecipeManager.java +++ b/src/main/java/appeng/core/features/registries/GrinderRecipeManager.java @@ -124,8 +124,12 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene private void injectRecipe( AppEngGrinderRecipe appEngGrinderRecipe ) { for( IGrinderEntry gr : this.recipes ) + { if( Platform.isSameItemPrecise( gr.getInput(), appEngGrinderRecipe.getInput() ) ) + { return; + } + } this.recipes.add( appEngGrinderRecipe ); } @@ -133,7 +137,9 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene private ItemStack copy( ItemStack is ) { if( is != null ) + { return is.copy(); + } return null; } @@ -166,18 +172,26 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene private int getDustToOreRatio( String name ) { if( name.equals( "Obsidian" ) ) + { return 1; + } if( name.equals( "Charcoal" ) ) + { return 1; + } if( name.equals( "Coal" ) ) + { return 1; + } return 2; } private void addOre( String name, ItemStack item ) { if( item == null ) + { return; + } this.log( "Adding Ore - " + name + " : " + Platform.getItemDisplayName( item ) ); this.ores.put( item, name ); @@ -193,14 +207,18 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene this.addRecipe( item, is, extra, (float) ( AEConfig.instance.oreDoublePercentage / 100.0 ), 8 ); } else + { this.addRecipe( item, is, 8 ); + } } } private void addIngot( String name, ItemStack item ) { if( item == null ) + { return; + } this.log( "Adding Ingot - " + name + " : " + Platform.getItemDisplayName( item ) ); this.ingots.put( item, name ); @@ -214,7 +232,9 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene private void addDust( String name, ItemStack item ) { if( item == null ) + { return; + } if( this.dusts.containsKey( name ) ) { this.log( "Rejecting Dust - " + name + " : " + Platform.getItemDisplayName( item ) ); @@ -226,6 +246,7 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene this.dusts.put( name, item ); for( Entry d : this.ores.entrySet() ) + { if( name.equals( d.getValue() ) ) { ItemStack is = item.copy(); @@ -238,12 +259,19 @@ public final class GrinderRecipeManager implements IGrinderRegistry, IOreListene this.addRecipe( d.getKey(), is, extra, (float) ( AEConfig.instance.oreDoublePercentage / 100.0 ), 8 ); } else + { this.addRecipe( d.getKey(), is, 8 ); + } } + } for( Entry d : this.ingots.entrySet() ) + { if( name.equals( d.getValue() ) ) + { this.addRecipe( d.getKey(), item, 4 ); + } + } } @Override diff --git a/src/main/java/appeng/core/features/registries/InscriberRegistry.java b/src/main/java/appeng/core/features/registries/InscriberRegistry.java index a0ab7125..9625a7ba 100644 --- a/src/main/java/appeng/core/features/registries/InscriberRegistry.java +++ b/src/main/java/appeng/core/features/registries/InscriberRegistry.java @@ -68,7 +68,9 @@ public final class InscriberRegistry implements IInscriberRegistry public void addRecipe( IInscriberRecipe recipe ) { if( recipe == null ) + { throw new IllegalArgumentException( "Tried to add an invalid (null) inscriber recipe to the registry." ); + } this.recipes.add( recipe ); @@ -154,15 +156,25 @@ public final class InscriberRegistry implements IInscriberRegistry public IInscriberRecipe build() { if( this.inputs == null ) + { throw new IllegalStateException( "Input must be defined." ); + } if( this.inputs.size() == 0 ) + { throw new IllegalStateException( "Input must have a size." ); + } if( this.output == null ) + { throw new IllegalStateException( "Output must be defined." ); + } if ( this.topOptional == null && this.bottomOptional == null ) + { throw new IllegalStateException( "One optional must be defined." ); + } if ( this.type == null ) + { throw new IllegalStateException( "Process type must be defined." ); + } return new InscriberRecipe( this.inputs, this.output, this.topOptional, this.bottomOptional, this.type ); } diff --git a/src/main/java/appeng/core/features/registries/LocatableRegistry.java b/src/main/java/appeng/core/features/registries/LocatableRegistry.java index 6bd890ce..3ce6f10a 100644 --- a/src/main/java/appeng/core/features/registries/LocatableRegistry.java +++ b/src/main/java/appeng/core/features/registries/LocatableRegistry.java @@ -47,7 +47,9 @@ public final class LocatableRegistry implements ILocatableRegistry public void updateLocatable( LocatableEventAnnounce e ) { if( Platform.isClient() ) + { return; // IGNORE! + } if( e.change == LocatableEvent.Register ) { diff --git a/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java b/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java index b406f395..90ef287d 100644 --- a/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java +++ b/src/main/java/appeng/core/features/registries/MatterCannonAmmoRegistry.java @@ -53,7 +53,9 @@ public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmo for( ItemStack o : this.DamageModifiers.keySet() ) { if( Platform.isSameItem( o, is ) ) + { return this.DamageModifiers.get( o ).floatValue(); + } } return 0; } @@ -62,7 +64,9 @@ public class MatterCannonAmmoRegistry implements IOreListener, IMatterCannonAmmo public void oreRegistered( String name, ItemStack item ) { if( !( name.startsWith( "berry" ) || name.startsWith( "nugget" ) ) ) + { return; + } // addNugget( "Cobble", 18 ); // ? this.considerItem( name, item, "MeatRaw", 32 ); diff --git a/src/main/java/appeng/core/features/registries/MovableTileRegistry.java b/src/main/java/appeng/core/features/registries/MovableTileRegistry.java index 20a75816..0558af32 100644 --- a/src/main/java/appeng/core/features/registries/MovableTileRegistry.java +++ b/src/main/java/appeng/core/features/registries/MovableTileRegistry.java @@ -69,12 +69,16 @@ public class MovableTileRegistry implements IMovableRegistry IMovableHandler canMove = this.Valid.get( myClass ); if( canMove == null ) + { canMove = this.testClass( myClass, te ); + } if( canMove != this.nullHandler ) { if( te instanceof IMovableTile ) + { ( (IMovableTile) te ).prepareToMove(); + } te.invalidate(); return true; diff --git a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java index 4d055527..66cbca59 100644 --- a/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java +++ b/src/main/java/appeng/core/features/registries/P2PTunnelRegistry.java @@ -115,7 +115,9 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry public void addNewAttunement( ItemStack trigger, TunnelType type ) { if( type == null || trigger == null ) + { return; + } this.Tunnels.put( trigger, type ); } @@ -125,7 +127,9 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry ItemStack myItemStack = GameRegistry.findItemStack( modID, Name, 1 ); if( myItemStack == null ) + { return null; + } myItemStack.setItemDamage( meta ); return myItemStack; @@ -145,15 +149,21 @@ public class P2PTunnelRegistry implements IP2PTunnelRegistry if( trigger != null ) { if( FluidContainerRegistry.isContainer( trigger ) ) + { return TunnelType.FLUID; + } for( ItemStack is : this.Tunnels.keySet() ) { if( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE ) + { return this.Tunnels.get( is ); + } if( Platform.isSameItem( is, trigger ) ) + { return this.Tunnels.get( is ); + } } } diff --git a/src/main/java/appeng/core/features/registries/RecipeHandlerRegistry.java b/src/main/java/appeng/core/features/registries/RecipeHandlerRegistry.java index a7da1077..f30ee7be 100644 --- a/src/main/java/appeng/core/features/registries/RecipeHandlerRegistry.java +++ b/src/main/java/appeng/core/features/registries/RecipeHandlerRegistry.java @@ -53,7 +53,9 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry { Class clz = this.handlers.get( name ); if( clz == null ) + { return null; + } try { return clz.newInstance(); @@ -90,7 +92,9 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry } if( rr != null ) + { return rr; + } } return null; diff --git a/src/main/java/appeng/core/features/registries/WirelessRegistry.java b/src/main/java/appeng/core/features/registries/WirelessRegistry.java index 5a940849..bba934a2 100644 --- a/src/main/java/appeng/core/features/registries/WirelessRegistry.java +++ b/src/main/java/appeng/core/features/registries/WirelessRegistry.java @@ -48,7 +48,9 @@ public final class WirelessRegistry implements IWirelessTermRegistry public void registerWirelessHandler( IWirelessTermHandler handler ) { if( handler != null ) + { this.handlers.add( handler ); + } } @Override @@ -57,7 +59,9 @@ public final class WirelessRegistry implements IWirelessTermRegistry for( IWirelessTermHandler h : this.handlers ) { if( h.canHandle( is ) ) + { return true; + } } return false; } @@ -68,7 +72,9 @@ public final class WirelessRegistry implements IWirelessTermRegistry for( IWirelessTermHandler h : this.handlers ) { if( h.canHandle( is ) ) + { return h; + } } return null; } @@ -77,7 +83,9 @@ public final class WirelessRegistry implements IWirelessTermRegistry public void openWirelessTerminalGui( ItemStack item, World w, EntityPlayer player ) { if( Platform.isClient() ) + { return; + } if( !this.isWirelessTerminal( item ) ) { @@ -106,6 +114,8 @@ public final class WirelessRegistry implements IWirelessTermRegistry Platform.openGUI( player, null, null, GuiBridge.GUI_WIRELESS_TERM ); } else + { player.addChatMessage( PlayerMessages.DeviceNotPowered.get() ); + } } } diff --git a/src/main/java/appeng/core/features/registries/WorldGenRegistry.java b/src/main/java/appeng/core/features/registries/WorldGenRegistry.java index 051e52fd..7992b989 100644 --- a/src/main/java/appeng/core/features/registries/WorldGenRegistry.java +++ b/src/main/java/appeng/core/features/registries/WorldGenRegistry.java @@ -48,10 +48,14 @@ public final class WorldGenRegistry implements IWorldGen public void disableWorldGenForProviderID( WorldGenType type, Class provider ) { if( type == null ) + { throw new IllegalArgumentException( "Bad Type Passed" ); + } if( provider == null ) + { throw new IllegalArgumentException( "Bad Provider Passed" ); + } this.types[type.ordinal()].badProviders.add( provider ); } @@ -60,7 +64,9 @@ public final class WorldGenRegistry implements IWorldGen public void enableWorldGenForDimension( WorldGenType type, int dimensionID ) { if( type == null ) + { throw new IllegalArgumentException( "Bad Type Passed" ); + } this.types[type.ordinal()].enabledDimensions.add( dimensionID ); } @@ -80,10 +86,14 @@ public final class WorldGenRegistry implements IWorldGen public boolean isWorldGenEnabled( WorldGenType type, World w ) { if( type == null ) + { throw new IllegalArgumentException( "Bad Type Passed" ); + } if( w == null ) + { throw new IllegalArgumentException( "Bad Provider Passed" ); + } boolean isBadProvider = this.types[type.ordinal()].badProviders.contains( w.provider.getClass() ); boolean isBadDimension = this.types[type.ordinal()].badDimensions.contains( w.provider.dimensionId ); diff --git a/src/main/java/appeng/core/features/registries/entries/BasicCellHandler.java b/src/main/java/appeng/core/features/registries/entries/BasicCellHandler.java index d2659240..a48e6b59 100644 --- a/src/main/java/appeng/core/features/registries/entries/BasicCellHandler.java +++ b/src/main/java/appeng/core/features/registries/entries/BasicCellHandler.java @@ -52,7 +52,9 @@ public class BasicCellHandler implements ICellHandler public IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider container, StorageChannel channel ) { if( channel == StorageChannel.ITEMS ) + { return CellInventory.getCell( is, container ); + } return null; } diff --git a/src/main/java/appeng/core/features/registries/entries/CreativeCellHandler.java b/src/main/java/appeng/core/features/registries/entries/CreativeCellHandler.java index 9fc1ec00..9802b05f 100644 --- a/src/main/java/appeng/core/features/registries/entries/CreativeCellHandler.java +++ b/src/main/java/appeng/core/features/registries/entries/CreativeCellHandler.java @@ -50,7 +50,9 @@ public class CreativeCellHandler implements ICellHandler public IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider container, StorageChannel channel ) { if( channel == StorageChannel.ITEMS && is != null && is.getItem() instanceof ItemCreativeStorageCell ) + { return CreativeCellInventory.getCell( is ); + } return null; } diff --git a/src/main/java/appeng/core/features/registries/entries/ExternalIInv.java b/src/main/java/appeng/core/features/registries/entries/ExternalIInv.java index 452a5c57..e754ba94 100644 --- a/src/main/java/appeng/core/features/registries/entries/ExternalIInv.java +++ b/src/main/java/appeng/core/features/registries/entries/ExternalIInv.java @@ -46,7 +46,9 @@ public class ExternalIInv implements IExternalStorageHandler InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, d ); if( channel == StorageChannel.ITEMS && ad != null ) + { return new MEMonitorIInventory( ad ); + } return null; } diff --git a/src/main/java/appeng/core/features/registries/entries/InscriberRecipe.java b/src/main/java/appeng/core/features/registries/entries/InscriberRecipe.java index 1ffadbde..8f58f376 100644 --- a/src/main/java/appeng/core/features/registries/entries/InscriberRecipe.java +++ b/src/main/java/appeng/core/features/registries/entries/InscriberRecipe.java @@ -90,20 +90,32 @@ public class InscriberRecipe implements IInscriberRecipe public boolean equals( Object o ) { if( this == o ) + { return true; + } if( !(o instanceof IInscriberRecipe) ) + { return false; + } IInscriberRecipe that = (IInscriberRecipe) o; if( !this.inputs.equals( that.getInputs() ) ) + { return false; + } if( !this.output.equals( that.getOutput() ) ) + { return false; + } if( !this.maybeTop.equals( that.getTopOptional() ) ) + { return false; + } if( !this.maybeBot.equals( that.getBottomOptional()) ) + { return false; + } return this.type == that.getProcessType(); } diff --git a/src/main/java/appeng/core/stats/AchievementCraftingHandler.java b/src/main/java/appeng/core/stats/AchievementCraftingHandler.java index 20143637..b98ca6e2 100644 --- a/src/main/java/appeng/core/stats/AchievementCraftingHandler.java +++ b/src/main/java/appeng/core/stats/AchievementCraftingHandler.java @@ -45,7 +45,9 @@ public class AchievementCraftingHandler public void onPlayerCraftingEvent( PlayerEvent.ItemCraftedEvent event ) { if( this.differentiator.isNoPlayer( event.player ) || event.crafting == null ) + { return; + } for( Achievements achievement : Achievements.values() ) { diff --git a/src/main/java/appeng/core/stats/AchievementPickupHandler.java b/src/main/java/appeng/core/stats/AchievementPickupHandler.java index 1e757632..91ba2d29 100644 --- a/src/main/java/appeng/core/stats/AchievementPickupHandler.java +++ b/src/main/java/appeng/core/stats/AchievementPickupHandler.java @@ -47,7 +47,9 @@ public class AchievementPickupHandler public void onItemPickUp( PlayerEvent.ItemPickupEvent event ) { if( this.differentiator.isNoPlayer( event.player ) || event.pickedUp == null || event.pickedUp.getEntityItem() == null ) + { return; + } ItemStack is = event.pickedUp.getEntityItem(); diff --git a/src/main/java/appeng/core/stats/PlayerStatsRegistration.java b/src/main/java/appeng/core/stats/PlayerStatsRegistration.java index 67c87662..dca4192a 100644 --- a/src/main/java/appeng/core/stats/PlayerStatsRegistration.java +++ b/src/main/java/appeng/core/stats/PlayerStatsRegistration.java @@ -86,7 +86,9 @@ public class PlayerStatsRegistration hierarchy.registerAchievementHierarchy(); for( Stats s : Stats.values() ) + { s.getStat(); + } /** * register @@ -97,7 +99,9 @@ public class PlayerStatsRegistration { Achievement ach = a.getAchievement(); if( ach != null ) + { list.add( ach ); + } } AchievementPage ae2AchievementPage = new AchievementPage( "Applied Energistics 2", list.toArray( new Achievement[list.size()] ) ); diff --git a/src/main/java/appeng/core/sync/AppEngPacket.java b/src/main/java/appeng/core/sync/AppEngPacket.java index 8fffb003..9c2cd3ef 100644 --- a/src/main/java/appeng/core/sync/AppEngPacket.java +++ b/src/main/java/appeng/core/sync/AppEngPacket.java @@ -62,12 +62,16 @@ public abstract class AppEngPacket public FMLProxyPacket getProxy() { if( this.p.array().length > 2 * 1024 * 1024 ) // 2k walking room :) + { throw new IllegalArgumentException( "Sorry AE2 made a " + this.p.array().length + " byte packet by accident!" ); + } FMLProxyPacket pp = new FMLProxyPacket( this.p, NetworkHandler.instance.getChannel() ); if( AEConfig.instance.isFeatureEnabled( AEFeature.PacketLogging ) ) + { AELog.info( this.getClass().getName() + " : " + pp.payload().readableBytes() ); + } return pp; } diff --git a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java index bbe8ddd8..7c4521d5 100644 --- a/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java +++ b/src/main/java/appeng/core/sync/AppEngPacketHandlerBase.java @@ -130,7 +130,9 @@ public class AppEngPacketHandlerBase REVERSE_LOOKUP.put( this.packetClass, this ); if( this.packetConstructor == null ) + { throw new IllegalStateException( "Invalid Packet Class " + c + ", must be constructable on DataInputStream" ); + } } public static PacketTypes getPacket( int id ) diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index 4e26d594..992127c7 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -228,10 +228,14 @@ public enum GuiBridge implements IGuiHandler String guiClass = start.replaceFirst( "container.", "client.gui." ).replace( ".Container", ".Gui" ); if( start.equals( guiClass ) ) + { throw new IllegalStateException( "Unable to find gui class" ); + } this.Gui = ReflectionHelper.getClass( this.getClass().getClassLoader(), guiClass ); if( this.Gui == null ) + { throw new IllegalStateException( "Cannot Load class: " + guiClass ); + } } } @@ -263,7 +267,9 @@ public enum GuiBridge implements IGuiHandler } Object myItem = this.getGuiObject( it, player, w, x, y, z ); if( myItem != null && ID.CorrectTileOrPart( myItem ) ) + { return this.updateGui( ID.ConstructContainer( player.inventory, side, myItem ), w, x, y, z, side, myItem ); + } } if( ID.type.isTile() ) { @@ -273,12 +279,16 @@ public enum GuiBridge implements IGuiHandler ( (IPartHost) TE ).getPart( side ); IPart part = ( (IPartHost) TE ).getPart( side ); if( ID.CorrectTileOrPart( part ) ) + { return this.updateGui( ID.ConstructContainer( player.inventory, side, part ), w, x, y, z, side, part ); + } } else { if( ID.CorrectTileOrPart( TE ) ) + { return this.updateGui( ID.ConstructContainer( player.inventory, side, TE ), w, x, y, z, side, TE ); + } } } return new ContainerNull(); @@ -295,7 +305,9 @@ public enum GuiBridge implements IGuiHandler IWirelessTermHandler wh = AEApi.instance().registries().wireless().getWirelessTerminalHandler( it ); if( wh != null ) + { return new WirelessTerminalGuiObject( wh, it, player, w, x, y, z ); + } } return null; @@ -304,7 +316,9 @@ public enum GuiBridge implements IGuiHandler public boolean CorrectTileOrPart( Object tE ) { if( this.Tile == null ) + { throw new IllegalArgumentException( "This Gui Cannot use the standard Handler." ); + } return this.Tile.isInstance( tE ); } @@ -331,7 +345,9 @@ public enum GuiBridge implements IGuiHandler { Constructor[] c = this.Container.getConstructors(); if( c.length == 0 ) + { throw new AppEngException( "Invalid Gui Class" ); + } Constructor target = this.findConstructor( c, inventory, tE ); @@ -376,7 +392,9 @@ public enum GuiBridge implements IGuiHandler if( types.length == 2 ) { if( types[0].isAssignableFrom( inventory.getClass() ) && types[1].isAssignableFrom( tE.getClass() ) ) + { return con; + } } } return null; @@ -385,7 +403,9 @@ public enum GuiBridge implements IGuiHandler private String typeName( Object inventory ) { if( inventory == null ) + { return "NULL"; + } return inventory.getClass().getName(); } @@ -429,7 +449,9 @@ public enum GuiBridge implements IGuiHandler } Object myItem = this.getGuiObject( it, player, w, x, y, z ); if( myItem != null && ID.CorrectTileOrPart( myItem ) ) + { return ID.ConstructGui( player.inventory, side, myItem ); + } } if( ID.type.isTile() ) { @@ -439,12 +461,16 @@ public enum GuiBridge implements IGuiHandler ( (IPartHost) TE ).getPart( side ); IPart part = ( (IPartHost) TE ).getPart( side ); if( ID.CorrectTileOrPart( part ) ) + { return ID.ConstructGui( player.inventory, side, part ); + } } else { if( ID.CorrectTileOrPart( TE ) ) + { return ID.ConstructGui( player.inventory, side, TE ); + } } } return new GuiNull( new ContainerNull() ); @@ -456,7 +482,9 @@ public enum GuiBridge implements IGuiHandler { Constructor[] c = this.Gui.getConstructors(); if( c.length == 0 ) + { throw new AppEngException( "Invalid Gui Class" ); + } Constructor target = this.findConstructor( c, inventory, tE ); @@ -500,12 +528,16 @@ public enum GuiBridge implements IGuiHandler ( (IPartHost) TE ).getPart( side ); IPart part = ( (IPartHost) TE ).getPart( side ); if( this.CorrectTileOrPart( part ) ) + { return this.securityCheck( part, player ); + } } else { if( this.CorrectTileOrPart( TE ) ) + { return this.securityCheck( TE, player ); + } } } } @@ -535,7 +567,9 @@ public enum GuiBridge implements IGuiHandler ISecurityGrid sg = g.getCache( ISecurityGrid.class ); if( sg.hasPermission( player, this.requiredPermission ) ) + { return true; + } } } diff --git a/src/main/java/appeng/core/sync/network/NetworkHandler.java b/src/main/java/appeng/core/sync/network/NetworkHandler.java index e540294a..d5c775e2 100644 --- a/src/main/java/appeng/core/sync/network/NetworkHandler.java +++ b/src/main/java/appeng/core/sync/network/NetworkHandler.java @@ -90,7 +90,9 @@ public class NetworkHandler public void newConnection( PlayerLoggedInEvent loginEvent ) { if( loginEvent.player instanceof EntityPlayerMP ) + { WorldSettings.getInstance().sendToPlayer( null ); + } } @SubscribeEvent @@ -98,14 +100,18 @@ public class NetworkHandler { NetHandlerPlayServer srv = (NetHandlerPlayServer) ev.packet.handler(); if( this.serveHandler != null ) + { this.serveHandler.onPacketData( null, ev.packet, srv.playerEntity ); + } } @SubscribeEvent public void clientPacket( ClientCustomPacketEvent ev ) { if( this.clientHandler != null ) + { this.clientHandler.onPacketData( null, ev.packet, null ); + } } public String getChannel() diff --git a/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java b/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java index a2f3b906..68bb97b3 100644 --- a/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java +++ b/src/main/java/appeng/core/sync/packets/PacketCompressedNBT.java @@ -68,7 +68,9 @@ public class PacketCompressedNBT extends AppEngPacket public int read() throws IOException { if( stream.readableBytes() <= 0 ) + { return -1; + } return stream.readByte() & 0xff; } @@ -111,6 +113,8 @@ public class PacketCompressedNBT extends AppEngPacket GuiScreen gs = Minecraft.getMinecraft().currentScreen; if( gs instanceof GuiInterfaceTerminal ) + { ( (GuiInterfaceTerminal) gs ).postUpdate( this.in ); + } } } diff --git a/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java b/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java index 661cdcc6..e742af10 100644 --- a/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java +++ b/src/main/java/appeng/core/sync/packets/PacketCraftRequest.java @@ -82,11 +82,15 @@ public class PacketCraftRequest extends AppEngPacket IGridHost gh = (IGridHost) target; IGridNode gn = gh.getGridNode( ForgeDirection.UNKNOWN ); if( gn == null ) + { return; + } IGrid g = gn.getGrid(); if( g == null || cca.whatToMake == null ) + { return; + } Future futureJob = null; @@ -115,7 +119,9 @@ public class PacketCraftRequest extends AppEngPacket catch( Throwable e ) { if( futureJob != null ) + { futureJob.cancel( true ); + } AELog.error( e ); } } diff --git a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java index eb5827b3..7c2d8c70 100644 --- a/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java +++ b/src/main/java/appeng/core/sync/packets/PacketInventoryAction.java @@ -57,9 +57,13 @@ public class PacketInventoryAction extends AppEngPacket this.id = stream.readLong(); boolean hasItem = stream.readBoolean(); if( hasItem ) + { this.slotItem = AEItemStack.loadItemStackFromPacket( stream ); + } else + { this.slotItem = null; + } } // api @@ -67,7 +71,9 @@ public class PacketInventoryAction extends AppEngPacket { if( Platform.isClient() ) + { throw new IllegalStateException( "invalid packet, client cannot post inv actions with stacks." ); + } this.action = action; this.slot = slot; @@ -82,7 +88,9 @@ public class PacketInventoryAction extends AppEngPacket data.writeLong( this.id ); if( slotItem == null ) + { data.writeBoolean( false ); + } else { data.writeBoolean( true ); @@ -153,9 +161,13 @@ public class PacketInventoryAction extends AppEngPacket if( this.action == InventoryAction.UPDATE_HAND ) { if( this.slotItem == null ) + { ClientHelper.proxy.getPlayers().get( 0 ).inventory.setItemStack( null ); + } else + { ClientHelper.proxy.getPlayers().get( 0 ).inventory.setItemStack( this.slotItem.getItemStack() ); + } } } } diff --git a/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java b/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java index 6563ca27..9dd97d56 100644 --- a/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java +++ b/src/main/java/appeng/core/sync/packets/PacketMEInventoryUpdate.java @@ -88,7 +88,9 @@ public class PacketMEInventoryUpdate extends AppEngPacket public int read() throws IOException { if( stream.readableBytes() <= 0 ) + { return -1; + } return stream.readByte() & STREAM_MASK; } @@ -100,7 +102,9 @@ public class PacketMEInventoryUpdate extends AppEngPacket { int bytes = gzReader.read( tmp ); if( bytes > 0 ) + { uncompressed.writeBytes( tmp, 0, bytes ); + } } gzReader.close(); @@ -108,7 +112,9 @@ public class PacketMEInventoryUpdate extends AppEngPacket // AELog.info( "Receiver: " + originalBytes + " -> " + uncompressedBytes ); while( uncompressed.readableBytes() > 0 ) + { this.list.add( AEItemStack.loadItemStackFromPacket( uncompressed ) ); + } this.empty = this.list.isEmpty(); } @@ -146,16 +152,24 @@ public class PacketMEInventoryUpdate extends AppEngPacket GuiScreen gs = Minecraft.getMinecraft().currentScreen; if( gs instanceof GuiCraftConfirm ) + { ( (GuiCraftConfirm) gs ).postUpdate( this.list, this.ref ); + } if( gs instanceof GuiCraftingCPU ) + { ( (GuiCraftingCPU) gs ).postUpdate( this.list, this.ref ); + } if( gs instanceof GuiMEMonitorable ) + { ( (GuiMEMonitorable) gs ).postUpdate( this.list ); + } if( gs instanceof GuiNetworkStatus ) + { ( (GuiNetworkStatus) gs ).postUpdate( this.list ); + } } @Nullable diff --git a/src/main/java/appeng/core/sync/packets/PacketNEIRecipe.java b/src/main/java/appeng/core/sync/packets/PacketNEIRecipe.java index 91563cba..62dc54bc 100644 --- a/src/main/java/appeng/core/sync/packets/PacketNEIRecipe.java +++ b/src/main/java/appeng/core/sync/packets/PacketNEIRecipe.java @@ -121,7 +121,9 @@ public class PacketNEIRecipe extends AppEngPacket { IGrid grid = node.getGrid(); if( grid == null ) + { return; + } IStorageGrid inv = grid.getCache( IStorageGrid.class ); IEnergyGrid energy = grid.getCache( IEnergyGrid.class ); @@ -172,9 +174,13 @@ public class PacketNEIRecipe extends AppEngPacket { IAEItemStack out = realForFake == Actionable.SIMULATE ? null : Platform.poweredInsert( energy, storage, in, cct.getSource() ); if( out != null ) + { craftMatrix.setInventorySlotContents( x, out.getItemStack() ); + } else + { craftMatrix.setInventorySlotContents( x, null ); + } currentItem = craftMatrix.getStackInSlot( x ); } diff --git a/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java b/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java index 6c961012..5f27d3cd 100644 --- a/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java +++ b/src/main/java/appeng/core/sync/packets/PacketPatternSlot.java @@ -54,7 +54,9 @@ public class PacketPatternSlot extends AppEngPacket this.slotItem = this.readItem( stream ); for( int x = 0; x < 9; x++ ) + { this.pattern[x] = this.readItem( stream ); + } } public IAEItemStack readItem( ByteBuf stream ) throws IOException @@ -62,7 +64,9 @@ public class PacketPatternSlot extends AppEngPacket boolean hasItem = stream.readBoolean(); if( hasItem ) + { return AEItemStack.loadItemStackFromPacket( stream ); + } return null; } @@ -93,7 +97,9 @@ public class PacketPatternSlot extends AppEngPacket private void writeItem( IAEItemStack slotItem, ByteBuf data ) throws IOException { if( slotItem == null ) + { data.writeBoolean( false ); + } else { data.writeBoolean( true ); diff --git a/src/main/java/appeng/core/sync/packets/PacketProgressBar.java b/src/main/java/appeng/core/sync/packets/PacketProgressBar.java index fbc7c75b..e1b07cab 100644 --- a/src/main/java/appeng/core/sync/packets/PacketProgressBar.java +++ b/src/main/java/appeng/core/sync/packets/PacketProgressBar.java @@ -63,7 +63,9 @@ public class PacketProgressBar extends AppEngPacket { Container c = player.openContainer; if( c instanceof AEBaseContainer ) + { ( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value ); + } } @Override @@ -71,6 +73,8 @@ public class PacketProgressBar extends AppEngPacket { Container c = player.openContainer; if( c instanceof AEBaseContainer ) + { ( (AEBaseContainer) c ).updateFullProgressBar( this.id, this.value ); + } } } diff --git a/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java b/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java index 50062621..c678602d 100644 --- a/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java +++ b/src/main/java/appeng/core/sync/packets/PacketSwitchGuis.java @@ -52,7 +52,9 @@ public class PacketSwitchGuis extends AppEngPacket this.newGui = newGui; if( Platform.isClient() ) + { AEBaseGui.switchingGuis = true; + } ByteBuf data = Unpooled.buffer(); diff --git a/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java b/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java index 4669439d..ce097c44 100644 --- a/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java +++ b/src/main/java/appeng/core/sync/packets/PacketTransitionEffect.java @@ -89,12 +89,15 @@ public class PacketTransitionEffect extends AppEngPacket World world = ClientHelper.proxy.getWorld(); for( int zz = 0; zz < ( this.mode ? 32 : 8 ); zz++ ) + { if( CommonHelper.proxy.shouldAddParticles( Platform.getRandom() ) ) { EnergyFx fx = new EnergyFx( world, this.x + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ), this.y + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ), this.z + ( this.mode ? ( Platform.getRandomInt() % 100 ) * 0.01 : ( Platform.getRandomInt() % 100 ) * 0.005 - 0.25 ), Items.diamond ); if( !this.mode ) + { fx.fromItem( this.d ); + } fx.motionX = -0.1 * this.d.offsetX; fx.motionY = -0.1 * this.d.offsetY; @@ -102,6 +105,7 @@ public class PacketTransitionEffect extends AppEngPacket Minecraft.getMinecraft().effectRenderer.addEffect( fx ); } + } if( this.mode ) { diff --git a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java index 9c89acf6..f4cf04d8 100644 --- a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java +++ b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java @@ -246,7 +246,9 @@ public class PacketValueConfig extends AppEngPacket { GuiScreen gs = Minecraft.getMinecraft().currentScreen; if( gs instanceof GuiCraftingCPU ) + { ( (GuiCraftingCPU) gs ).clearItems(); + } } else if( c instanceof IConfigurableObject ) { diff --git a/src/main/java/appeng/crafting/CraftingJob.java b/src/main/java/appeng/crafting/CraftingJob.java index 8d33fdf4..751f978d 100644 --- a/src/main/java/appeng/crafting/CraftingJob.java +++ b/src/main/java/appeng/crafting/CraftingJob.java @@ -253,7 +253,9 @@ public class CraftingJob implements Runnable, ICraftingJob } if( Thread.interrupted() ) + { throw new InterruptedException(); + } } this.incTime++; } @@ -261,7 +263,9 @@ public class CraftingJob implements Runnable, ICraftingJob public void finish() { if( this.callback != null ) + { this.callback.calculationComplete( this ); + } this.availableCheck = null; @@ -294,7 +298,9 @@ public class CraftingJob implements Runnable, ICraftingJob public void populatePlan( IItemList plan ) { if( this.tree != null ) + { this.tree.getPlan( plan ); + } } @Override @@ -327,7 +333,9 @@ public class CraftingJob implements Runnable, ICraftingJob synchronized( this.monitor ) { if( this.done ) + { return false; + } this.watch.reset(); this.watch.start(); diff --git a/src/main/java/appeng/crafting/CraftingLink.java b/src/main/java/appeng/crafting/CraftingLink.java index 4f92ae61..9b66419c 100644 --- a/src/main/java/appeng/crafting/CraftingLink.java +++ b/src/main/java/appeng/crafting/CraftingLink.java @@ -47,7 +47,9 @@ public class CraftingLink implements ICraftingLink this.standalone = data.getBoolean( "standalone" ); if( !data.hasKey( "req" ) || !data.getBoolean( "req" ) ) + { throw new IllegalStateException( "Invalid Crafting Link for Object" ); + } this.req = req; this.cpu = null; @@ -61,7 +63,9 @@ public class CraftingLink implements ICraftingLink this.standalone = data.getBoolean( "standalone" ); if( !data.hasKey( "req" ) || data.getBoolean( "req" ) ) + { throw new IllegalStateException( "Invalid Crafting Link for Object" ); + } this.cpu = cpu; this.req = null; @@ -71,13 +75,19 @@ public class CraftingLink implements ICraftingLink public boolean isCanceled() { if( this.canceled ) + { return true; + } if( this.done ) + { return false; + } if( this.tie == null ) + { return false; + } return this.tie.isCanceled(); } @@ -86,13 +96,19 @@ public class CraftingLink implements ICraftingLink public boolean isDone() { if( this.done ) + { return true; + } if( this.canceled ) + { return false; + } if( this.tie == null ) + { return false; + } return this.tie.isDone(); } @@ -101,12 +117,16 @@ public class CraftingLink implements ICraftingLink public void cancel() { if( this.done ) + { return; + } this.canceled = true; if( this.tie != null ) + { this.tie.cancel(); + } this.tie = null; } @@ -136,7 +156,9 @@ public class CraftingLink implements ICraftingLink public void setNexus( CraftingLinkNexus n ) { if( this.tie != null ) + { this.tie.remove( this ); + } if( this.canceled && n != null ) { @@ -148,13 +170,17 @@ public class CraftingLink implements ICraftingLink this.tie = n; if( n != null ) + { n.add( this ); + } } public IAEItemStack injectItems( IAEItemStack input, Actionable mode ) { if( this.tie == null || this.tie.req == null || this.tie.req.req == null ) + { return input; + } return this.tie.req.req.injectCraftedItems( this.tie.req, input, mode ); } @@ -162,6 +188,8 @@ public class CraftingLink implements ICraftingLink public void markDone() { if( this.tie != null ) + { this.tie.markDone(); + } } } diff --git a/src/main/java/appeng/crafting/CraftingLinkNexus.java b/src/main/java/appeng/crafting/CraftingLinkNexus.java index b88b9687..1082d223 100644 --- a/src/main/java/appeng/crafting/CraftingLinkNexus.java +++ b/src/main/java/appeng/crafting/CraftingLinkNexus.java @@ -42,19 +42,27 @@ public class CraftingLinkNexus public boolean isDead( IGrid g, CraftingGridCache craftingGridCache ) { if( this.canceled || this.done ) + { return true; + } if( this.req == null || this.cpu == null ) + { this.tickOfDeath++; + } else { boolean hasCpu = craftingGridCache.hasCpu( this.cpu.cpu ); boolean hasMachine = this.req.req.getActionableNode().getGrid() == g; if( hasCpu && hasMachine ) + { this.tickOfDeath = 0; + } else + { this.tickOfDeath += 60; + } } if( this.tickOfDeath > 60 ) @@ -74,27 +82,39 @@ public class CraftingLinkNexus { this.req.canceled = true; if( this.req.req != null ) + { this.req.req.jobStateChange( this.req ); + } } if( this.cpu != null ) + { this.cpu.canceled = true; + } } public void remove( CraftingLink craftingLink ) { if( this.req == craftingLink ) + { this.req = null; + } else if( this.cpu == craftingLink ) + { this.cpu = null; + } } public void add( CraftingLink craftingLink ) { if( craftingLink.cpu != null ) + { this.cpu = craftingLink; + } else if( craftingLink.req != null ) + { this.req = craftingLink; + } } public boolean isCanceled() @@ -115,11 +135,15 @@ public class CraftingLinkNexus { this.req.done = true; if( this.req.req != null ) + { this.req.req.jobStateChange( this.req ); + } } if( this.cpu != null ) + { this.cpu.done = true; + } } public boolean isMachine( IGridHost machine ) @@ -130,7 +154,9 @@ public class CraftingLinkNexus public void removeNode() { if( this.req != null ) + { this.req.setNexus( null ); + } this.req = null; this.tickOfDeath = 0; diff --git a/src/main/java/appeng/crafting/CraftingTreeNode.java b/src/main/java/appeng/crafting/CraftingTreeNode.java index 5d92935c..f5676e77 100644 --- a/src/main/java/appeng/crafting/CraftingTreeNode.java +++ b/src/main/java/appeng/crafting/CraftingTreeNode.java @@ -70,13 +70,17 @@ public class CraftingTreeNode this.canEmit = cc.canEmitFor( this.what ); if( this.canEmit ) + { return; // if you can emit for something, you can't make it with patterns. + } for( ICraftingPatternDetails details : cc.getCraftingFor( this.what, this.parent == null ? null : this.parent.details, slot, this.world ) )// in // order. { if( this.parent == null || this.parent.notRecursive( details ) ) + { this.nodes.add( new CraftingTreeProcess( cc, job, details, this, depth + 1 ) ); + } } } @@ -84,16 +88,26 @@ public class CraftingTreeNode { IAEItemStack[] o = details.getCondensedOutputs(); for( IAEItemStack i : o ) + { if( i.equals( this.what ) ) + { return false; + } + } o = details.getCondensedInputs(); for( IAEItemStack i : o ) + { if( i.equals( this.what ) ) + { return false; + } + } if( this.parent == null ) + { return true; + } return this.parent.notRecursive( details ); } @@ -131,7 +145,9 @@ public class CraftingTreeNode l -= available.getStackSize(); if( l == 0 ) + { return available; + } } } } @@ -156,7 +172,9 @@ public class CraftingTreeNode l -= available.getStackSize(); if( l == 0 ) + { return available; + } } } @@ -192,10 +210,14 @@ public class CraftingTreeNode l -= available.getStackSize(); if( l <= 0 ) + { return available; + } } else + { pro.possible = false; // ;P + } } } else if( this.nodes.size() > 1 ) @@ -215,16 +237,22 @@ public class CraftingTreeNode if( available != null ) { if( !subInv.commit( src ) ) + { throw new CraftBranchFailure( this.what, l ); + } this.bytes += available.getStackSize(); l -= available.getStackSize(); if( l <= 0 ) + { return available; + } } else + { pro.possible = false; // ;P + } } } catch( CraftBranchFailure fail ) @@ -256,13 +284,17 @@ public class CraftingTreeNode public void dive( CraftingJob job ) { if( this.missing > 0 ) + { job.addMissing( this.getStack( this.missing ) ); + } // missing = 0; job.addBytes( 8 + this.bytes ); for( CraftingTreeProcess pro : this.nodes ) + { pro.dive( job ); + } } public IAEItemStack getStack( long size ) @@ -281,7 +313,9 @@ public class CraftingTreeNode this.exhausted = false; for( CraftingTreeProcess pro : this.nodes ) + { pro.setSimulate(); + } } public void setJob( MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src ) throws CraftBranchFailure @@ -291,7 +325,9 @@ public class CraftingTreeNode IAEItemStack ex = storage.extractItems( i, Actionable.MODULATE, src ); if( ex == null || ex.getStackSize() != i.getStackSize() ) + { throw new CraftBranchFailure( i, i.getStackSize() ); + } craftingCPUCluster.addStorage( ex ); } @@ -304,7 +340,9 @@ public class CraftingTreeNode } for( CraftingTreeProcess pro : this.nodes ) + { pro.setJob( storage, craftingCPUCluster, src ); + } } public void getPlan( IItemList plan ) @@ -324,9 +362,13 @@ public class CraftingTreeNode } for( IAEItemStack i : this.used ) + { plan.add( i.copy() ); + } for( CraftingTreeProcess pro : this.nodes ) + { pro.getPlan( plan ); + } } } diff --git a/src/main/java/appeng/crafting/CraftingTreeProcess.java b/src/main/java/appeng/crafting/CraftingTreeProcess.java index d8555c4d..9648b7b5 100644 --- a/src/main/java/appeng/crafting/CraftingTreeProcess.java +++ b/src/main/java/appeng/crafting/CraftingTreeProcess.java @@ -73,7 +73,9 @@ public class CraftingTreeProcess InventoryCrafting ic = new InventoryCrafting( new ContainerNull(), 3, 3 ); IAEItemStack[] is = details.getInputs(); for( int x = 0; x < ic.getSizeInventory(); x++ ) + { ic.setInventorySlotContents( x, is[x] == null ? null : is[x].getItemStack() ); + } FMLCommonHandler.instance().firePlayerCraftingEvent( Platform.getPlayer( (WorldServer) world ), details.getOutput( ic, world ), ic ); @@ -81,7 +83,9 @@ public class CraftingTreeProcess { ItemStack g = ic.getStackInSlot( x ); if( g != null && g.stackSize > 1 ) + { this.fullSimulation = true; + } } for( IAEItemStack part : details.getCondensedInputs() ) @@ -92,14 +96,20 @@ public class CraftingTreeProcess for( IAEItemStack a : details.getCondensedOutputs() ) { if( g != null && a != null && a.equals( g ) ) + { isAnInput = true; + } } if( isAnInput ) + { this.limitQty = true; + } if( g.getItem().hasContainerItem( g ) ) + { this.limitQty = this.containerItems = true; + } } boolean complicated = false; @@ -110,7 +120,9 @@ public class CraftingTreeProcess { IAEItemStack part = list[x]; if( part != null ) + { this.nodes.put( new CraftingTreeNode( cc, job, part.copy(), this, x, depth + 1 ), part.getStackSize() ); + } } } else @@ -141,11 +153,15 @@ public class CraftingTreeProcess for( IAEItemStack a : details.getCondensedOutputs() ) { if( g != null && a != null && a.equals( g ) ) + { isAnInput = true; + } } if( isAnInput ) + { this.limitQty = true; + } } for( IAEItemStack part : details.getCondensedInputs() ) @@ -163,7 +179,9 @@ public class CraftingTreeProcess long getTimes( long remaining, long stackSize ) { if( this.limitQty || this.fullSimulation ) + { return 1; + } return ( remaining / stackSize ) + ( remaining % stackSize != 0 ? 1 : 0 ); } @@ -236,7 +254,9 @@ public class CraftingTreeProcess { job.addTask( this.getAmountCrafted( this.parent.getStack( 1 ) ), this.crafts, this.details, this.depth ); for( CraftingTreeNode pro : this.nodes.keySet() ) + { pro.dive( job ); + } job.addBytes( 8 + this.crafts + this.bytes ); } @@ -273,7 +293,9 @@ public class CraftingTreeProcess this.bytes = 0; for( CraftingTreeNode pro : this.nodes.keySet() ) + { pro.setSimulate(); + } } public void setJob( MECraftingInventory storage, CraftingCPUCluster craftingCPUCluster, BaseActionSource src ) throws CraftBranchFailure @@ -281,7 +303,9 @@ public class CraftingTreeProcess craftingCPUCluster.addCrafting( this.details, this.crafts ); for( CraftingTreeNode pro : this.nodes.keySet() ) + { pro.setJob( storage, craftingCPUCluster, src ); + } } public void getPlan( IItemList plan ) @@ -294,6 +318,8 @@ public class CraftingTreeProcess } for( CraftingTreeNode pro : this.nodes.keySet() ) + { pro.getPlan( plan ); + } } } diff --git a/src/main/java/appeng/crafting/CraftingWatcher.java b/src/main/java/appeng/crafting/CraftingWatcher.java index 9e8f1a8a..532ea457 100644 --- a/src/main/java/appeng/crafting/CraftingWatcher.java +++ b/src/main/java/appeng/crafting/CraftingWatcher.java @@ -90,7 +90,9 @@ public class CraftingWatcher implements ICraftingWatcher public boolean add( IAEStack e ) { if( this.myInterests.contains( e ) ) + { return false; + } return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this ); } @@ -113,7 +115,9 @@ public class CraftingWatcher implements ICraftingWatcher boolean didChange = false; for( IAEStack o : c ) + { didChange = this.add( o ) || didChange; + } return didChange; } @@ -123,7 +127,9 @@ public class CraftingWatcher implements ICraftingWatcher { boolean didSomething = false; for( Object o : c ) + { didSomething = this.remove( o ) || didSomething; + } return didSomething; } diff --git a/src/main/java/appeng/crafting/MECraftingInventory.java b/src/main/java/appeng/crafting/MECraftingInventory.java index c9a42eaf..9da58d39 100644 --- a/src/main/java/appeng/crafting/MECraftingInventory.java +++ b/src/main/java/appeng/crafting/MECraftingInventory.java @@ -67,19 +67,31 @@ public class MECraftingInventory implements IMEInventory this.logMissing = parent.logMissing; if( this.logMissing ) + { this.missingCache = AEApi.instance().storage().createItemList(); + } else + { this.missingCache = null; + } if( this.logExtracted ) + { this.extractedCache = AEApi.instance().storage().createItemList(); + } else + { this.extractedCache = null; + } if( this.logInjections ) + { this.injectedCache = AEApi.instance().storage().createItemList(); + } else + { this.injectedCache = null; + } this.localCache = this.target.getAvailableItems( AEApi.instance().storage().createItemList() ); @@ -94,23 +106,37 @@ public class MECraftingInventory implements IMEInventory this.logMissing = logMissing; if( logMissing ) + { this.missingCache = AEApi.instance().storage().createItemList(); + } else + { this.missingCache = null; + } if( logExtracted ) + { this.extractedCache = AEApi.instance().storage().createItemList(); + } else + { this.extractedCache = null; + } if( logInjections ) + { this.injectedCache = AEApi.instance().storage().createItemList(); + } else + { this.injectedCache = null; + } this.localCache = AEApi.instance().storage().createItemList(); for( IAEItemStack is : target.getStorageList() ) + { this.localCache.add( target.extractItems( is, Actionable.SIMULATE, src ) ); + } this.par = null; } @@ -123,19 +149,31 @@ public class MECraftingInventory implements IMEInventory this.logMissing = logMissing; if( logMissing ) + { this.missingCache = AEApi.instance().storage().createItemList(); + } else + { this.missingCache = null; + } if( logExtracted ) + { this.extractedCache = AEApi.instance().storage().createItemList(); + } else + { this.extractedCache = null; + } if( logInjections ) + { this.injectedCache = AEApi.instance().storage().createItemList(); + } else + { this.injectedCache = null; + } this.localCache = target.getAvailableItems( AEApi.instance().storage().createItemList() ); this.par = null; @@ -145,12 +183,16 @@ public class MECraftingInventory implements IMEInventory public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src ) { if( input == null ) + { return null; + } if( mode == Actionable.MODULATE ) { if( this.logInjections ) + { this.injectedCache.add( input ); + } this.localCache.add( input ); } @@ -161,11 +203,15 @@ public class MECraftingInventory implements IMEInventory public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src ) { if( request == null ) + { return null; + } IAEItemStack list = this.localCache.findPrecise( request ); if( list == null || list.getStackSize() == 0 ) + { return null; + } if( list.getStackSize() >= request.getStackSize() ) { @@ -173,7 +219,9 @@ public class MECraftingInventory implements IMEInventory { list.decStackSize( request.getStackSize() ); if( this.logExtracted ) + { this.extractedCache.add( request ); + } } return request; @@ -186,7 +234,9 @@ public class MECraftingInventory implements IMEInventory { list.reset(); if( this.logExtracted ) + { this.extractedCache.add( ret ); + } } return ret; @@ -196,7 +246,9 @@ public class MECraftingInventory implements IMEInventory public IItemList getAvailableItems( IItemList out ) { for( IAEItemStack is : this.localCache ) + { out.add( is ); + } return out; } @@ -236,7 +288,9 @@ public class MECraftingInventory implements IMEInventory if( failed ) { for( IAEItemStack is : added ) + { this.target.extractItems( is, Actionable.MODULATE, src ); + } return false; } @@ -259,10 +313,14 @@ public class MECraftingInventory implements IMEInventory if( failed ) { for( IAEItemStack is : added ) + { this.target.extractItems( is, Actionable.MODULATE, src ); + } for( IAEItemStack is : pulled ) + { this.target.injectItems( is, Actionable.MODULATE, src ); + } return false; } @@ -270,7 +328,9 @@ public class MECraftingInventory implements IMEInventory if( this.logMissing && this.par != null ) { for( IAEItemStack extra : this.missingCache ) + { this.par.addMissing( extra ); + } } return true; @@ -285,6 +345,8 @@ public class MECraftingInventory implements IMEInventory { IAEItemStack list = this.localCache.findPrecise( what ); if( list != null ) + { list.setStackSize( 0 ); + } } } diff --git a/src/main/java/appeng/debug/BlockCubeGenerator.java b/src/main/java/appeng/debug/BlockCubeGenerator.java index c3fc9bd5..600a7acc 100644 --- a/src/main/java/appeng/debug/BlockCubeGenerator.java +++ b/src/main/java/appeng/debug/BlockCubeGenerator.java @@ -46,7 +46,9 @@ public class BlockCubeGenerator extends AEBaseBlock TileCubeGenerator tcg = this.getTileEntity( w, x, y, z ); if( tcg != null ) + { tcg.click( player ); + } return true; } diff --git a/src/main/java/appeng/debug/TileChunkLoader.java b/src/main/java/appeng/debug/TileChunkLoader.java index f8aa7727..26b830fa 100644 --- a/src/main/java/appeng/debug/TileChunkLoader.java +++ b/src/main/java/appeng/debug/TileChunkLoader.java @@ -58,7 +58,9 @@ public class TileChunkLoader extends AEBaseTile void initTicket() { if( Platform.isClient() ) + { return; + } this.ct = ForgeChunkManager.requestTicket( AppEng.instance, this.worldObj, Type.NORMAL ); @@ -84,7 +86,9 @@ public class TileChunkLoader extends AEBaseTile public void invalidate() { if( Platform.isClient() ) + { return; + } AELog.info( "Released Ticket " + this.ct.toString() ); ForgeChunkManager.releaseTicket( this.ct ); diff --git a/src/main/java/appeng/debug/TileCubeGenerator.java b/src/main/java/appeng/debug/TileCubeGenerator.java index b059f210..93696f6c 100644 --- a/src/main/java/appeng/debug/TileCubeGenerator.java +++ b/src/main/java/appeng/debug/TileCubeGenerator.java @@ -56,7 +56,9 @@ public class TileCubeGenerator extends AEBaseTile } if( this.countdown <= 0 ) + { this.spawn(); + } } } @@ -93,14 +95,22 @@ public class TileCubeGenerator extends AEBaseTile this.is = null; if( player.isSneaking() ) + { this.size--; + } else + { this.size++; + } if( this.size < 3 ) + { this.size = 3; + } if( this.size > 64 ) + { this.size = 64; + } player.addChatMessage( new ChatComponentText( "Size: " + this.size ) ); } diff --git a/src/main/java/appeng/debug/TileItemGen.java b/src/main/java/appeng/debug/TileItemGen.java index f759f67c..631ea94e 100644 --- a/src/main/java/appeng/debug/TileItemGen.java +++ b/src/main/java/appeng/debug/TileItemGen.java @@ -49,7 +49,9 @@ public class TileItemGen extends AEBaseTile implements IInventory if( mi.isDamageable() ) { for( int dmg = 0; dmg < mi.getMaxDamage(); dmg++ ) + { POSSIBLE_ITEMS.add( new ItemStack( mi, 1, dmg ) ); + } } else { diff --git a/src/main/java/appeng/debug/TilePhantomNode.java b/src/main/java/appeng/debug/TilePhantomNode.java index 7ec31810..e930725a 100644 --- a/src/main/java/appeng/debug/TilePhantomNode.java +++ b/src/main/java/appeng/debug/TilePhantomNode.java @@ -38,7 +38,9 @@ public class TilePhantomNode extends AENetworkTile public IGridNode getGridNode( ForgeDirection dir ) { if( !this.crashMode ) + { return super.getGridNode( dir ); + } return this.proxy.getNode(); } diff --git a/src/main/java/appeng/debug/ToolDebugCard.java b/src/main/java/appeng/debug/ToolDebugCard.java index 46f3c907..04368686 100644 --- a/src/main/java/appeng/debug/ToolDebugCard.java +++ b/src/main/java/appeng/debug/ToolDebugCard.java @@ -63,7 +63,9 @@ public class ToolDebugCard extends AEBaseItem public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if( Platform.isClient() ) + { return false; + } if( player.isSneaking() ) { @@ -112,16 +114,22 @@ public class ToolDebugCard extends AEBaseItem for( IGridNode n : current ) { if( n.getMachine() instanceof TileController ) + { break outer; + } for( IGridConnection c : n.getConnections() ) + { next.add( c.getOtherSide( n ) ); + } } length++; if( length > maxLength ) + { break; + } } this.outputMsg( player, "Cable Distance: " + length ); @@ -154,10 +162,14 @@ public class ToolDebugCard extends AEBaseItem } } else + { this.outputMsg( player, "No Node Available." ); + } } else + { this.outputMsg( player, "Not Networked Block" ); + } if( te instanceof IPartHost ) { @@ -171,7 +183,9 @@ public class ToolDebugCard extends AEBaseItem { ForgeDirection fd = gc.getDirection( n ); if( fd != ForgeDirection.UNKNOWN ) + { this.outputMsg( player, fd.toString() + ": " + gc.getUsedChannels() ); + } } } } @@ -204,7 +218,9 @@ public class ToolDebugCard extends AEBaseItem { long ms = nanos / 100000; if( nanos <= 100000 ) + { return nanos + "ns"; + } return ( ms / 10.0f ) + "ms"; } } diff --git a/src/main/java/appeng/debug/ToolEraser.java b/src/main/java/appeng/debug/ToolEraser.java index 13448d9f..45dbb53d 100644 --- a/src/main/java/appeng/debug/ToolEraser.java +++ b/src/main/java/appeng/debug/ToolEraser.java @@ -58,7 +58,9 @@ public class ToolEraser extends AEBaseItem public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if( Platform.isClient() ) + { return false; + } Block blk = world.getBlock( x, y, z ); int meta = world.getBlockMetadata( x, y, z ); diff --git a/src/main/java/appeng/debug/ToolMeteoritePlacer.java b/src/main/java/appeng/debug/ToolMeteoritePlacer.java index c5dbb135..6632ed78 100644 --- a/src/main/java/appeng/debug/ToolMeteoritePlacer.java +++ b/src/main/java/appeng/debug/ToolMeteoritePlacer.java @@ -52,13 +52,17 @@ public class ToolMeteoritePlacer extends AEBaseItem public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if( Platform.isClient() ) + { return false; + } MeteoritePlacer mp = new MeteoritePlacer(); boolean worked = mp.spawnMeteorite( new StandardWorld( world ), x, y, z ); if( !worked ) + { player.addChatMessage( new ChatComponentText( "Un-suitable Location." ) ); + } return true; } diff --git a/src/main/java/appeng/debug/ToolReplicatorCard.java b/src/main/java/appeng/debug/ToolReplicatorCard.java index f41ec0f8..70d56e2a 100644 --- a/src/main/java/appeng/debug/ToolReplicatorCard.java +++ b/src/main/java/appeng/debug/ToolReplicatorCard.java @@ -53,7 +53,9 @@ public class ToolReplicatorCard extends AEBaseItem public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ ) { if( Platform.isClient() ) + { return false; + } if( player.isSneaking() ) { @@ -68,7 +70,9 @@ public class ToolReplicatorCard extends AEBaseItem stack.setTagCompound( tag ); } else + { this.outputMsg( player, "This is not a Grid Tile." ); + } } else { @@ -117,7 +121,9 @@ public class ToolReplicatorCard extends AEBaseItem int scale_z = max.z - min.z; for( int i = 1; i < scale_x; i++ ) + { for( int j = 1; j < scale_y; j++ ) + { for( int k = 1; k < scale_z; k++ ) { Block blk = src_w.getBlock( min_x + i, min_y + j, min_z + k ); @@ -135,21 +141,33 @@ public class ToolReplicatorCard extends AEBaseItem } world.markBlockForUpdate( i + rel_x, j + rel_y, k + rel_z ); } + } + } } else + { this.outputMsg( player, "requires valid spatial pylon setup." ); + } } else + { this.outputMsg( player, "no grid?" ); + } } else + { this.outputMsg( player, "No grid node?" ); + } } else + { this.outputMsg( player, "Src is no longer a grid block?" ); + } } else + { this.outputMsg( player, "No Source Defined" ); + } } return true; } diff --git a/src/main/java/appeng/entity/EntityChargedQuartz.java b/src/main/java/appeng/entity/EntityChargedQuartz.java index 40b60934..9c8199f6 100644 --- a/src/main/java/appeng/entity/EntityChargedQuartz.java +++ b/src/main/java/appeng/entity/EntityChargedQuartz.java @@ -63,7 +63,9 @@ public final class EntityChargedQuartz extends AEBaseEntityItem super.onUpdate(); if( !AEConfig.instance.isFeatureEnabled( AEFeature.inWorldFluix ) ) + { return; + } if( Platform.isClient() && this.delay > 30 && AEConfig.instance.enableEffects ) { @@ -83,11 +85,15 @@ public final class EntityChargedQuartz extends AEBaseEntityItem if( this.transformTime > 60 ) { if( !this.transform() ) + { this.transformTime = 0; + } } } else + { this.transformTime = 0; + } } public boolean transform() @@ -111,10 +117,14 @@ public final class EntityChargedQuartz extends AEBaseEntityItem if( other != null && other.stackSize > 0 ) { if( Platform.isSameItem( other, new ItemStack( Items.redstone ) ) ) + { redstone = (EntityItem) e; + } if( Platform.isSameItem( other, new ItemStack( Items.quartz ) ) ) + { netherQuartz = (EntityItem) e; + } } } } @@ -126,13 +136,19 @@ public final class EntityChargedQuartz extends AEBaseEntityItem netherQuartz.getEntityItem().stackSize--; if( this.getEntityItem().stackSize <= 0 ) + { this.setDead(); + } if( redstone.getEntityItem().stackSize <= 0 ) + { redstone.setDead(); + } if( netherQuartz.getEntityItem().stackSize <= 0 ) + { netherQuartz.setDead(); + } for( ItemStack fluixCrystalStack : materials.fluixCrystal().maybeStack( 2 ).asSet() ) { diff --git a/src/main/java/appeng/entity/EntityFloatingItem.java b/src/main/java/appeng/entity/EntityFloatingItem.java index 21614db8..aa0596b9 100644 --- a/src/main/java/appeng/entity/EntityFloatingItem.java +++ b/src/main/java/appeng/entity/EntityFloatingItem.java @@ -48,10 +48,14 @@ public final class EntityFloatingItem extends EntityItem public void onUpdate() { if( !this.isDead && this.parent.isDead ) + { this.setDead(); + } if( this.superDeath > 100 ) + { this.setDead(); + } this.superDeath++; this.age = ageStatic; @@ -61,6 +65,8 @@ public final class EntityFloatingItem extends EntityItem { this.progress = progress; if( this.progress > 0.99 ) + { this.setDead(); + } } } diff --git a/src/main/java/appeng/entity/EntityGrowingCrystal.java b/src/main/java/appeng/entity/EntityGrowingCrystal.java index bc59a747..7f3a90ea 100644 --- a/src/main/java/appeng/entity/EntityGrowingCrystal.java +++ b/src/main/java/appeng/entity/EntityGrowingCrystal.java @@ -58,10 +58,14 @@ public final class EntityGrowingCrystal extends EntityItem super.onUpdate(); if( !AEConfig.instance.isFeatureEnabled( AEFeature.inWorldPurification ) ) + { return; + } if( this.age > 600 ) + { this.age = 100; + } ItemStack is = this.getEntityItem(); Item gc = is.getItem(); @@ -84,34 +88,52 @@ public final class EntityGrowingCrystal extends EntityItem if( mat.isLiquid() ) { if( isClient ) + { this.progress_1000++; + } else + { this.progress_1000 += speed; + } } else + { this.progress_1000 = 0; + } if( isClient ) { int len = 40; if( speed > 2 ) + { len = 20; + } if( speed > 90 ) + { len = 15; + } if( speed > 150 ) + { len = 10; + } if( speed > 240 ) + { len = 7; + } if( speed > 360 ) + { len = 3; + } if( speed > 500 ) + { len = 1; + } if( this.progress_1000 >= len ) { @@ -138,22 +160,34 @@ public final class EntityGrowingCrystal extends EntityItem int qty = 0; if( this.isAccelerated( x + 1, y, z ) ) + { qty += per + qty * mul; + } if( this.isAccelerated( x, y + 1, z ) ) + { qty += per + qty * mul; + } if( this.isAccelerated( x, y, z + 1 ) ) + { qty += per + qty * mul; + } if( this.isAccelerated( x - 1, y, z ) ) + { qty += per + qty * mul; + } if( this.isAccelerated( x, y - 1, z ) ) + { qty += per + qty * mul; + } if( this.isAccelerated( x, y, z - 1 ) ) + { qty += per + qty * mul; + } return qty; } diff --git a/src/main/java/appeng/entity/EntityIds.java b/src/main/java/appeng/entity/EntityIds.java index 2951de70..3acbc9a8 100644 --- a/src/main/java/appeng/entity/EntityIds.java +++ b/src/main/java/appeng/entity/EntityIds.java @@ -36,13 +36,21 @@ public final class EntityIds public static int get( Class droppedEntity ) { if( droppedEntity == EntityTinyTNTPrimed.class ) + { return TINY_TNT; + } if( droppedEntity == EntitySingularity.class ) + { return SINGULARITY; + } if( droppedEntity == EntityChargedQuartz.class ) + { return CHARGED_QUARTZ; + } if( droppedEntity == EntityGrowingCrystal.class ) + { return GROWING_CRYSTAL; + } throw new IllegalStateException( "Missing entity id: " + droppedEntity.getName() ); } diff --git a/src/main/java/appeng/entity/EntitySingularity.java b/src/main/java/appeng/entity/EntitySingularity.java index 857fbc94..594a78e9 100644 --- a/src/main/java/appeng/entity/EntitySingularity.java +++ b/src/main/java/appeng/entity/EntitySingularity.java @@ -70,10 +70,14 @@ public final class EntitySingularity extends AEBaseEntityItem public void doExplosion() { if( Platform.isClient() ) + { return; + } if( !AEConfig.instance.isFeatureEnabled( AEFeature.inWorldSingularity ) ) + { return; + } ItemStack item = this.getEntityItem(); @@ -120,7 +124,9 @@ public final class EntitySingularity extends AEBaseEntityItem { other.stackSize--; if( other.stackSize == 0 ) + { e.setDead(); + } for( ItemStack singularityStack : materials.qESingularity().maybeStack( 2 ).asSet() ) { @@ -135,7 +141,9 @@ public final class EntitySingularity extends AEBaseEntityItem } if( item.stackSize <= 0 ) + { this.setDead(); + } } } } diff --git a/src/main/java/appeng/entity/RenderFloatingItem.java b/src/main/java/appeng/entity/RenderFloatingItem.java index 82eb0207..0cd78b43 100644 --- a/src/main/java/appeng/entity/RenderFloatingItem.java +++ b/src/main/java/appeng/entity/RenderFloatingItem.java @@ -56,7 +56,9 @@ public class RenderFloatingItem extends RenderItem GL11.glPushMatrix(); if( !( efi.getEntityItem().getItem() instanceof ItemBlock ) ) + { GL11.glTranslatef( 0, -0.15f, 0 ); + } super.doRender( efi, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_ ); GL11.glPopMatrix(); diff --git a/src/main/java/appeng/facade/FacadeContainer.java b/src/main/java/appeng/facade/FacadeContainer.java index 061c798d..6aaa0ac3 100644 --- a/src/main/java/appeng/facade/FacadeContainer.java +++ b/src/main/java/appeng/facade/FacadeContainer.java @@ -71,7 +71,9 @@ public class FacadeContainer implements IFacadeContainer { this.storage.setFacade( side.ordinal(), null ); if( host != null ) + { host.markForUpdate(); + } } } } @@ -97,7 +99,9 @@ public class FacadeContainer implements IFacadeContainer newFacades[ForgeDirection.NORTH.ordinal()] = this.storage.getFacade( ForgeDirection.WEST.ordinal() ); for( int x = 0; x < this.facades; x++ ) + { this.storage.setFacade( x, newFacades[x] ); + } } @Override @@ -178,14 +182,18 @@ public class FacadeContainer implements IFacadeContainer { Item i = is.getItem(); if( i instanceof IFacadeItem ) + { this.storage.setFacade( x, ( (IFacadeItem) i ).createPartFromItemStack( is, ForgeDirection.getOrientation( x ) ) ); + } else { if( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) ) { IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC ); if( bc.isFacade( is ) ) + { this.storage.setFacade( x, bc.createFacadePart( is, ForgeDirection.getOrientation( x ) ) ); + } } } } @@ -200,7 +208,9 @@ public class FacadeContainer implements IFacadeContainer for( int x = 0; x < this.facades; x++ ) { if( this.getFacade( ForgeDirection.getOrientation( x ) ) != null ) + { facadeSides |= ( 1 << x ); + } } out.writeByte( (byte) facadeSides ); @@ -221,8 +231,12 @@ public class FacadeContainer implements IFacadeContainer public boolean isEmpty() { for( int x = 0; x < this.facades; x++ ) + { if( this.storage.getFacade( x ) != null ) + { return false; + } + } return true; } } diff --git a/src/main/java/appeng/facade/FacadePart.java b/src/main/java/appeng/facade/FacadePart.java index 2f244a9f..3af92ecb 100644 --- a/src/main/java/appeng/facade/FacadePart.java +++ b/src/main/java/appeng/facade/FacadePart.java @@ -70,7 +70,9 @@ public class FacadePart implements IFacadePart, IBoxProvider public FacadePart( ItemStack facade, ForgeDirection side ) { if( facade == null ) + { throw new IllegalArgumentException( "Facade Part constructed on null item." ); + } this.facade = facade.copy(); this.facade.stackSize = 1; this.side = side; @@ -136,14 +138,20 @@ public class FacadePart implements IFacadePart, IBoxProvider } if( myIcon == null ) + { myIcon = this.facade.getIconIndex(); + } instance.setTexture( myIcon ); if( this.isBC() ) + { instance.setBounds( 6, 6, 10, 10, 10, 15 ); + } else + { instance.setBounds( 7, 7, 10, 9, 9, 15 ); + } instance.renderBlock( x, y, z, renderer ); instance.setTexture( null ); @@ -159,7 +167,9 @@ public class FacadePart implements IFacadePart, IBoxProvider if( AEApi.instance().partHelper().getCableRenderMode().transparentFacades ) { if( rbw != null ) + { rbw.opacity = 0.3f; + } instance.renderForPass( 1 ); } else @@ -192,7 +202,9 @@ public class FacadePart implements IFacadePart, IBoxProvider rbw.faces = EnumSet.noneOf( ForgeDirection.class ); if( this.prevLight != null && rbw.similarLighting( blk, rbw.blockAccess, x, y, z, this.prevLight ) ) + { rbw.populate( this.prevLight ); + } else { instance.setRenderColor( color ); @@ -368,28 +380,36 @@ public class FacadePart implements IFacadePart, IBoxProvider { IFacadePart fp = fc.getFacade( ForgeDirection.UP ); if( fp != null && ( fp.isTransparent() == facade.isTransparent() ) ) + { out.remove( ForgeDirection.UP ); + } } if( out.contains( ForgeDirection.DOWN ) && ( side.offsetX != 0 || side.offsetZ != 0 ) ) { IFacadePart fp = fc.getFacade( ForgeDirection.DOWN ); if( fp != null && ( fp.isTransparent() == facade.isTransparent() ) ) + { out.remove( ForgeDirection.DOWN ); + } } if( out.contains( ForgeDirection.SOUTH ) && ( side.offsetX != 0 ) ) { IFacadePart fp = fc.getFacade( ForgeDirection.SOUTH ); if( fp != null && ( fp.isTransparent() == facade.isTransparent() ) ) + { out.remove( ForgeDirection.SOUTH ); + } } if( out.contains( ForgeDirection.NORTH ) && ( side.offsetX != 0 ) ) { IFacadePart fp = fc.getFacade( ForgeDirection.NORTH ); if( fp != null && ( fp.isTransparent() == facade.isTransparent() ) ) + { out.remove( ForgeDirection.NORTH ); + } } /* @@ -535,7 +555,9 @@ public class FacadePart implements IFacadePart, IBoxProvider { ItemStack is = this.getTexture(); if( is == null ) + { return null; + } return is.getItem(); } @@ -544,7 +566,9 @@ public class FacadePart implements IFacadePart, IBoxProvider { ItemStack is = this.getTexture(); if( is == null ) + { return 0; + } return is.getItemDamage(); } @@ -564,7 +588,9 @@ public class FacadePart implements IFacadePart, IBoxProvider public boolean isTransparent() { if( AEApi.instance().partHelper().getCableRenderMode().transparentFacades ) + { return true; + } ItemStack is = this.getTexture(); Block blk = Block.getBlockFromItem( is.getItem() ); diff --git a/src/main/java/appeng/fmp/CableBusPart.java b/src/main/java/appeng/fmp/CableBusPart.java index bd641627..075753de 100644 --- a/src/main/java/appeng/fmp/CableBusPart.java +++ b/src/main/java/appeng/fmp/CableBusPart.java @@ -118,7 +118,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds for( AxisAlignedBB bx : this.cb.getSelectedBoundingBoxesFromPool( false, true, null, true ) ) { if( b == null ) + { b = bx; + } else { double minX = Math.min( b.minX, bx.minX ); @@ -132,7 +134,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds } if( b == null ) + { return new Cuboid6( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ); + } return new Cuboid6( b.minX, b.minY, b.minZ, b.maxX, b.maxY, b.maxZ ); } @@ -251,9 +255,13 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds if( sp != null ) { if( sp.part != null ) + { return sp.part.getItemStack( PartItemStack.Break ); + } if( sp.facade != null ) + { return sp.facade.getItemStack(); + } } return null; } @@ -372,7 +380,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds IPart fPart = this.getPart( whichSide ); if( fPart != null ) + { fPart.getBoxes( bch ); + } } AxisAlignedBB b = null; @@ -383,7 +393,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds if( bb.intersectsWith( pb ) ) { if( b == null ) + { b = bb; + } else { b.maxX = Math.max( b.maxX, bb.maxX ); @@ -397,7 +409,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds } if( b == null ) + { return 0; + } switch( dir ) { @@ -433,9 +447,13 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds for( ForgeDirection side : ForgeDirection.values() ) { if( this.getPart( side ) != null ) + { mask |= 1 << side.ordinal(); + } else if( side != ForgeDirection.UNKNOWN && this.getFacadeContainer().getFacade( side ) != null ) + { mask |= 1 << side.ordinal(); + } } return mask; @@ -520,7 +538,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds public void markForUpdate() { if( Platform.isServer() && this.canUpdate ) + { this.sendDescUpdate(); + } } @Override @@ -554,7 +574,9 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds public boolean isBlocked( ForgeDirection side ) { if( side == null || side == ForgeDirection.UNKNOWN || this.tile() == null ) + { return false; + } DISABLE_FACADE_OCCLUSION.set( true ); boolean blocked = !this.tile().canAddPart( new NormallyOccludedPart( SIDE_TESTS[side.ordinal()] ) ); @@ -575,14 +597,18 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds // mark the chunk for save... TileEntity te = this.tile(); if( te != null && te.getWorldObj() != null ) + { te.getWorldObj().getChunkFromBlockCoords( this.x(), this.z() ).isModified = true; + } } @Override public void partChanged() { if( this.isInWorld() ) + { this.notifyNeighbors(); + } } @Override @@ -622,10 +648,14 @@ public class CableBusPart extends JCuboidPart implements JNormalOcclusion, IReds public void notifyNeighbors() { if( this.tile() instanceof TIInventoryTile ) + { ( (TIInventoryTile) this.tile() ).rebuildSlotMap(); + } if( this.world() != null && this.world().blockExists( this.x(), this.y(), this.z() ) && !CableBusContainer.isLoading() ) + { Platform.notifyBlocksOfNeighbors( this.world(), this.x(), this.y(), this.z() ); + } } @Override diff --git a/src/main/java/appeng/fmp/FMPEvent.java b/src/main/java/appeng/fmp/FMPEvent.java index c55b41c0..df92189e 100644 --- a/src/main/java/appeng/fmp/FMPEvent.java +++ b/src/main/java/appeng/fmp/FMPEvent.java @@ -64,7 +64,9 @@ public class FMPEvent { MovingObjectPosition hit = RayTracer.reTrace( world, player ); if( hit == null ) + { return false; + } BlockCoord pos = new BlockCoord( hit.blockX, hit.blockY, hit.blockZ ).offset( hit.sideHit ); ItemStack held = player.getHeldItem(); @@ -73,7 +75,9 @@ public class FMPEvent Block blk = null; if( held == null ) + { return false; + } if( held.getItem() instanceof AEBaseItemBlock ) { @@ -83,7 +87,9 @@ public class FMPEvent } if( part == null ) + { return false; + } if( world.isRemote && !player.isSneaking() )// attempt to use block activated like normal and tell the server // the right stuff @@ -100,7 +106,9 @@ public class FMPEvent TileMultipart tile = TileMultipart.getOrConvertTile( world, pos ); if( tile == null || !tile.canAddPart( part ) ) + { return false; + } if( !world.isRemote ) { @@ -130,7 +138,9 @@ public class FMPEvent private static boolean ignoreActivate( Block block ) { if( block instanceof BlockFence ) + { return true; + } return false; } @@ -140,10 +150,14 @@ public class FMPEvent if( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote ) { if( this.placing.get() != null ) + { return; + } this.placing.set( event ); if( place( event.entityPlayer, event.entityPlayer.worldObj ) ) + { event.setCanceled( true ); + } this.placing.set( null ); } } diff --git a/src/main/java/appeng/fmp/FMPPlacementHelper.java b/src/main/java/appeng/fmp/FMPPlacementHelper.java index bdfb212b..5364bea8 100644 --- a/src/main/java/appeng/fmp/FMPPlacementHelper.java +++ b/src/main/java/appeng/fmp/FMPPlacementHelper.java @@ -62,7 +62,9 @@ public class FMPPlacementHelper implements IPartHost public IFacadeContainer getFacadeContainer() { if( this.myPart == null ) + { return new FacadeContainer( NULL_STORAGE ); + } return this.myPart.getFacadeContainer(); } @@ -85,11 +87,15 @@ public class FMPPlacementHelper implements IPartHost { TMultiPart p = i.next(); if( p instanceof CableBusPart ) + { this.myPart = (CableBusPart) p; + } } if( this.myPart == null ) + { this.myPart = (CableBusPart) PartRegistry.CableBusPart.construct( 0 ); + } BlockCoord loc = new BlockCoord( this.myMP.xCoord, this.myMP.yCoord, this.myMP.zCoord ); @@ -137,7 +143,9 @@ public class FMPPlacementHelper implements IPartHost public IPart getPart( ForgeDirection side ) { if( this.myPart == null ) + { return null; + } return this.myPart.getPart( side ); } @@ -145,7 +153,9 @@ public class FMPPlacementHelper implements IPartHost public void removePart( ForgeDirection side, boolean suppressUpdate ) { if( this.myPart == null ) + { return; + } this.myPart.removePart( side, suppressUpdate ); } @@ -153,7 +163,9 @@ public class FMPPlacementHelper implements IPartHost public void markForUpdate() { if( this.myPart == null ) + { return; + } this.myPart.markForUpdate(); } @@ -161,7 +173,9 @@ public class FMPPlacementHelper implements IPartHost public DimensionalCoord getLocation() { if( this.myPart == null ) + { return new DimensionalCoord( this.myMP ); + } return this.myPart.getLocation(); } @@ -175,7 +189,9 @@ public class FMPPlacementHelper implements IPartHost public AEColor getColor() { if( this.myPart == null ) + { return AEColor.Transparent; + } return this.myPart.getColor(); } @@ -183,7 +199,9 @@ public class FMPPlacementHelper implements IPartHost public void clearContainer() { if( this.myPart == null ) + { return; + } this.myPart.clearContainer(); } @@ -203,7 +221,9 @@ public class FMPPlacementHelper implements IPartHost public SelectedPart selectPart( Vec3 pos ) { if( this.myPart == null ) + { return new SelectedPart(); + } return this.myPart.selectPart( pos ); } @@ -211,7 +231,9 @@ public class FMPPlacementHelper implements IPartHost public void markForSave() { if( this.myPart == null ) + { return; + } this.myPart.markForSave(); } @@ -219,7 +241,9 @@ public class FMPPlacementHelper implements IPartHost public void partChanged() { if( this.myPart == null ) + { return; + } this.myPart.partChanged(); } @@ -227,7 +251,9 @@ public class FMPPlacementHelper implements IPartHost public boolean hasRedstone( ForgeDirection side ) { if( this.myPart == null ) + { return false; + } return this.myPart.hasRedstone( side ); } @@ -235,7 +261,9 @@ public class FMPPlacementHelper implements IPartHost public boolean isEmpty() { if( this.myPart == null ) + { return true; + } return this.myPart.isEmpty(); } @@ -243,7 +271,9 @@ public class FMPPlacementHelper implements IPartHost public Set getLayerFlags() { if( this.myPart == null ) + { return EnumSet.noneOf( LayerFlags.class ); + } return this.myPart.getLayerFlags(); } @@ -251,7 +281,9 @@ public class FMPPlacementHelper implements IPartHost public void cleanup() { if( this.myPart == null ) + { return; + } this.myPart.cleanup(); } @@ -259,7 +291,9 @@ public class FMPPlacementHelper implements IPartHost public void notifyNeighbors() { if( this.myPart == null ) + { return; + } this.myPart.notifyNeighbors(); } @@ -267,7 +301,9 @@ public class FMPPlacementHelper implements IPartHost public boolean isInWorld() { if( this.myPart == null ) + { return this.myMP.getWorldObj() != null; + } return this.myPart.isInWorld(); } diff --git a/src/main/java/appeng/fmp/PartRegistry.java b/src/main/java/appeng/fmp/PartRegistry.java index c3bef9ea..b7414d66 100644 --- a/src/main/java/appeng/fmp/PartRegistry.java +++ b/src/main/java/appeng/fmp/PartRegistry.java @@ -75,9 +75,13 @@ public enum PartRegistry try { if( this == CableBusPart ) + { return (TMultiPart) Api.INSTANCE.partHelper().getCombinedInstance( this.part.getName() ).newInstance(); + } else + { return this.part.getConstructor( int.class ).newInstance( meta ); + } } catch( Throwable t ) { diff --git a/src/main/java/appeng/helpers/DualityInterface.java b/src/main/java/appeng/helpers/DualityInterface.java index bf5de1e8..a66df4ad 100644 --- a/src/main/java/appeng/helpers/DualityInterface.java +++ b/src/main/java/appeng/helpers/DualityInterface.java @@ -148,12 +148,18 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ) { if( this.isWorking ) + { return; + } if( inv == this.config ) + { this.readConfig(); + } else if( inv == this.patterns && ( removed != null || added != null ) ) + { this.updateCraftingList(); + } else if( inv == this.storage && slot >= 0 ) { boolean had = this.hasWorkToDo(); @@ -167,9 +173,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn try { if( now ) + { this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() ); + } else + { this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); + } } catch( GridAccessException e ) { @@ -233,10 +243,14 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public void addToSendList( ItemStack is ) { if( is == null ) + { return; + } if( this.waitingToSend == null ) + { this.waitingToSend = new LinkedList(); + } this.waitingToSend.add( is ); @@ -266,7 +280,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn boolean had = this.hasWorkToDo(); for( int x = 0; x < 8; x++ ) + { this.updatePlan( x ); + } boolean has = this.hasWorkToDo(); @@ -275,9 +291,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn try { if( has ) + { this.gridProxy.getTick().alertDevice( this.gridProxy.getNode() ); + } else + { this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); + } } catch( GridAccessException e ) { @@ -295,7 +315,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn assert ( accountedFor.length == this.patterns.getSizeInventory() ); if( !this.gridProxy.isReady() ) + { return; + } if( this.craftingList != null ) { @@ -315,14 +337,18 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn } if( !found ) + { i.remove(); + } } } for( int x = 0; x < accountedFor.length; x++ ) { if( !accountedFor[x] ) + { this.addToCraftingList( this.patterns.getStackInSlot( x ) ); + } } try @@ -404,13 +430,17 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn TileEntity te = this.iHost.getTileEntity(); if( te != null && te.getWorldObj() != null ) + { Platform.notifyBlocksOfNeighbors( te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord ); + } } public void addToCraftingList( ItemStack is ) { if( is == null ) + { return; + } if( is.getItem() instanceof ICraftingPatternItem ) { @@ -420,7 +450,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn if( details != null ) { if( this.craftingList == null ) + { this.craftingList = new LinkedList(); + } this.craftingList.add( details ); } @@ -437,7 +469,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { IAEItemStack out = this.destination.injectItems( AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, null ); if( out == null ) + { return true; + } return out.getStackSize() != stack.stackSize; // ItemStack after = adaptor.simulateAdd( stack ); // if ( after == null ) @@ -489,7 +523,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public void markDirty() { for( int slot = 0; slot < this.storage.getSizeInventory(); slot++ ) + { this.onChangeInventory( this.storage, slot, InvOperation.markDirty, null, null ); + } } public int[] getAccessibleSlotsFromSide( int side ) @@ -507,10 +543,14 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { if( !this.gridProxy.isActive() ) + { return TickRateModulation.SLEEP; + } if( this.hasItemsToSend() ) + { this.pushItemsOut( this.iHost.getTargets() ); + } boolean couldDoWork = this.updateStorage(); return this.hasWorkToDo() ? ( couldDoWork ? TickRateModulation.URGENT : TickRateModulation.SLOWER ) : TickRateModulation.SLEEP; @@ -519,7 +559,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn private void pushItemsOut( EnumSet possibleDirections ) { if( !this.hasItemsToSend() ) + { return; + } TileEntity tile = this.iHost.getTileEntity(); World w = tile.getWorldObj(); @@ -533,7 +575,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { TileEntity te = w.getTileEntity( tile.xCoord + s.offsetX, tile.yCoord + s.offsetY, tile.zCoord + s.offsetZ ); if( te == null ) + { continue; + } InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, s.getOpposite() ); if( ad != null ) @@ -541,21 +585,31 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn ItemStack Result = ad.addItems( whatToSend ); if( Result == null ) + { whatToSend = null; + } else + { whatToSend.stackSize -= whatToSend.stackSize - Result.stackSize; + } if( whatToSend == null ) + { break; + } } } if( whatToSend == null ) + { i.remove(); + } } if( this.waitingToSend.isEmpty() ) + { this.waitingToSend = null; + } } private boolean updateStorage() @@ -585,7 +639,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn IEnergySource src = this.gridProxy.getEnergy(); if( this.craftingTracker.isBusy( x ) ) + { changed = this.handleCrafting( x, adaptor, itemStack ) || changed; + } else if( itemStack.getStackSize() > 0 ) { // make sure strange things didn't happen... @@ -601,10 +657,14 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn changed = true; ItemStack issue = adaptor.addItems( acquired.getItemStack() ); if( issue != null ) + { throw new IllegalStateException( "bad attempt at managing inventory. ( addItems )" ); + } } else + { changed = this.handleCrafting( x, adaptor, itemStack ) || changed; + } } else if( itemStack.getStackSize() < 0 ) { @@ -624,7 +684,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn toStore = Platform.poweredInsert( src, this.destination, toStore, this.interfaceRequestSource ); if( toStore != null ) + { diff -= toStore.getStackSize(); + } if( diff != 0 ) { @@ -632,9 +694,13 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn changed = true; ItemStack removed = adaptor.removeItems( (int) diff, null, null ); if( removed == null ) + { throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" ); + } else if( removed.stackSize != diff ) + { throw new IllegalStateException( "bad attempt at managing inventory. ( removeItems )" ); + } } } // else wtf? @@ -645,7 +711,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn } if( changed ) + { this.updatePlan( x ); + } this.isWorking = false; return changed; @@ -677,7 +745,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public int getInstalledUpgrades( Upgrades u ) { if( this.upgrades == null ) + { return 0; + } return this.upgrades.getInstalledUpgrades( u ); } @@ -691,7 +761,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public IMEMonitor getItemInventory() { if( this.hasConfig() ) + { return new InterfaceInventory( this ); + } return this.items; } @@ -705,16 +777,24 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public IInventory getInventoryByName( String name ) { if( name.equals( "storage" ) ) + { return this.storage; + } if( name.equals( "patterns" ) ) + { return this.patterns; + } if( name.equals( "config" ) ) + { return this.config; + } if( name.equals( "upgrades" ) ) + { return this.upgrades; + } return null; } @@ -734,7 +814,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public void updateSetting( IConfigManager manager, Enum settingName, Enum newValue ) { if( this.getInstalledUpgrades( Upgrades.CRAFTING ) == 0 ) + { this.cancelCrafting(); + } this.markDirty(); } @@ -743,7 +825,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public IMEMonitor getFluidInventory() { if( this.hasConfig() ) + { return null; + } return this.fluids; } @@ -756,7 +840,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src, IStorageMonitorable myInterface ) { if( Platform.canAccess( this.gridProxy, src ) ) + { return myInterface; + } final DualityInterface di = this; @@ -781,7 +867,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public boolean pushPattern( ICraftingPatternDetails patternDetails, InventoryCrafting table ) { if( this.hasItemsToSend() || !this.gridProxy.isActive() ) + { return false; + } TileEntity tile = this.iHost.getTileEntity(); World w = tile.getWorldObj(); @@ -795,7 +883,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn try { if( ( (IInterfaceHost) te ).getInterfaceDuality().sameGrid( this.gridProxy.getGrid() ) ) + { continue; + } } catch( GridAccessException e ) { @@ -809,7 +899,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn if( cm.acceptsPlans() ) { if( cm.pushPattern( patternDetails, table, s.getOpposite() ) ) + { return true; + } continue; } } @@ -820,7 +912,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn if( this.isBlocking() ) { if( ad.simulateRemove( 1, null, null ) != null ) + { continue; + } } if( this.acceptsItems( ad, table ) ) @@ -847,7 +941,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public boolean isBusy() { if( this.hasItemsToSend() ) + { return true; + } boolean busy = false; @@ -896,10 +992,14 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { ItemStack is = table.getStackInSlot( x ); if( is == null ) + { continue; + } if( ad.simulateAdd( is.copy() ) != null ) + { return false; + } } return true; @@ -923,29 +1023,49 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn if( this.waitingToSend != null ) { for( ItemStack is : this.waitingToSend ) + { if( is != null ) + { drops.add( is ); + } + } } for( ItemStack is : this.upgrades ) + { if( is != null ) + { drops.add( is ); + } + } for( ItemStack is : this.storage ) + { if( is != null ) + { drops.add( is ); + } + } for( ItemStack is : this.patterns ) + { if( is != null ) + { drops.add( is ); + } + } } public IUpgradeableHost getHost() { if( this.getPart() instanceof IUpgradeableHost ) + { return (IUpgradeableHost) this.getPart(); + } if( this.getTile() instanceof IUpgradeableHost ) + { return (IUpgradeableHost) this.getTile(); + } return null; } @@ -968,7 +1088,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn InventoryAdaptor adaptor = this.getAdaptor( slot ); if( mode == Actionable.SIMULATE ) + { return AEItemStack.create( adaptor.simulateAdd( acquired.getItemStack() ) ); + } else { IAEItemStack is = AEItemStack.create( adaptor.addItems( acquired.getItemStack() ) ); @@ -991,7 +1113,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn final World hostWorld = hostTile.getWorldObj(); if( ( (ICustomNameObject) this.iHost ).hasCustomName() ) + { return ( (ICustomNameObject) this.iHost ).getCustomName(); + } final EnumSet possibleDirections = this.iHost.getTargets(); for( ForgeDirection direction : possibleDirections ) @@ -1002,14 +1126,18 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn final TileEntity directedTile = hostWorld.getTileEntity( xPos, yPos, zPos ); if( directedTile == null ) + { continue; + } if( directedTile instanceof IInterfaceHost ) { try { if( ( (IInterfaceHost) directedTile ).getInterfaceDuality().sameGrid( this.gridProxy.getGrid() ) ) + { continue; + } } catch( GridAccessException e ) { @@ -1021,14 +1149,18 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn if( directedTile instanceof ICraftingMachine || adaptor != null ) { if( directedTile instanceof IInventory && ( (IInventory) directedTile ).getSizeInventory() == 0 ) + { continue; + } if( directedTile instanceof ISidedInventory ) { int[] sides = ( (ISidedInventory) directedTile ).getAccessibleSlotsFromSide( direction.getOpposite().ordinal() ); if( sides == null || sides.length == 0 ) + { continue; + } } final Block directedBlock = hostWorld.getBlock( xPos, yPos, zPos ); @@ -1045,7 +1177,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn { ItemStack g = directedBlock.getPickBlock( mop, hostWorld, directedTile.xCoord, directedTile.yCoord, directedTile.zCoord, null ); if( g != null ) + { what = g; + } } } } @@ -1055,7 +1189,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn } if( what.getItem() != null ) + { return what.getUnlocalizedName(); + } Item item = Item.getItemFromBlock( directedBlock ); if( item == null ) @@ -1124,7 +1260,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src ) { if( src instanceof InterfaceRequestSource ) + { return input; + } return super.injectItems( input, type, src ); } @@ -1133,7 +1271,9 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn public IAEItemStack extractItems( IAEItemStack request, Actionable type, BaseActionSource src ) { if( src instanceof InterfaceRequestSource ) + { return null; + } return super.extractItems( request, type, src ); } diff --git a/src/main/java/appeng/helpers/LocationRotation.java b/src/main/java/appeng/helpers/LocationRotation.java index f6f77ffc..a520052d 100644 --- a/src/main/java/appeng/helpers/LocationRotation.java +++ b/src/main/java/appeng/helpers/LocationRotation.java @@ -51,7 +51,9 @@ public class LocationRotation implements IOrientable public ForgeDirection getForward() { if( this.getUp().offsetY == 0 ) + { return ForgeDirection.UP; + } return ForgeDirection.SOUTH; } diff --git a/src/main/java/appeng/helpers/MetaRotation.java b/src/main/java/appeng/helpers/MetaRotation.java index 5cdf422c..7056ff88 100644 --- a/src/main/java/appeng/helpers/MetaRotation.java +++ b/src/main/java/appeng/helpers/MetaRotation.java @@ -52,7 +52,9 @@ public class MetaRotation implements IOrientable public ForgeDirection getForward() { if( this.getUp().offsetY == 0 ) + { return ForgeDirection.UP; + } return ForgeDirection.SOUTH; } @@ -66,8 +68,12 @@ public class MetaRotation implements IOrientable public void setOrientation( ForgeDirection Forward, ForgeDirection Up ) { if( this.w instanceof World ) + { ( (World) this.w ).setBlockMetadataWithNotify( this.x, this.y, this.z, Up.ordinal(), 1 + 2 ); + } else + { throw new IllegalStateException( this.w.getClass().getName() + " received, expected World" ); + } } } diff --git a/src/main/java/appeng/helpers/MultiCraftingTracker.java b/src/main/java/appeng/helpers/MultiCraftingTracker.java index 54a4caa8..1a00abea 100644 --- a/src/main/java/appeng/helpers/MultiCraftingTracker.java +++ b/src/main/java/appeng/helpers/MultiCraftingTracker.java @@ -60,14 +60,18 @@ public class MultiCraftingTracker { NBTTagCompound link = extra.getCompoundTag( "links-" + x ); if( link != null && !link.hasNoTags() ) + { this.setLink( x, AEApi.instance().storage().loadCraftingLink( link, this.owner ) ); + } } } void setLink( int slot, ICraftingLink l ) { if( this.links == null ) + { this.links = new ICraftingLink[this.size]; + } this.links[slot] = l; @@ -77,13 +81,19 @@ public class MultiCraftingTracker ICraftingLink g = this.links[x]; if( g == null || g.isCanceled() || g.isDone() ) + { this.links[x] = null; + } else + { hasStuff = true; + } } if( !hasStuff ) + { this.links = null; + } } public void writeToNBT( NBTTagCompound extra ) @@ -103,7 +113,9 @@ public class MultiCraftingTracker ICraftingLink getLink( int slot ) { if( this.links == null ) + { return null; + } return this.links[slot]; } @@ -123,7 +135,9 @@ public class MultiCraftingTracker try { if( craftingJob.isDone() ) + { job = craftingJob.get(); + } if( job != null ) { @@ -157,7 +171,9 @@ public class MultiCraftingTracker Future getJob( int slot ) { if( this.jobs == null ) + { return null; + } return this.jobs[slot]; } @@ -165,7 +181,9 @@ public class MultiCraftingTracker void setJob( int slot, Future l ) { if( this.jobs == null ) + { this.jobs = new Future[this.size]; + } this.jobs[slot] = l; @@ -179,13 +197,17 @@ public class MultiCraftingTracker } if( !hasStuff ) + { this.jobs = null; + } } public ImmutableSet getRequestedJobs() { if( this.links == null ) + { return ImmutableSet.of(); + } return ImmutableSet.copyOf( new NonNullArrayIterator( this.links ) ); } @@ -212,7 +234,9 @@ public class MultiCraftingTracker for( int x = 0; x < this.links.length; x++ ) { if( this.links[x] == link ) + { return x; + } } } @@ -226,7 +250,9 @@ public class MultiCraftingTracker for( ICraftingLink l : this.links ) { if( l != null ) + { l.cancel(); + } } this.links = null; @@ -237,7 +263,9 @@ public class MultiCraftingTracker for( Future l : this.jobs ) { if( l != null ) + { l.cancel( true ); + } } this.jobs = null; diff --git a/src/main/java/appeng/helpers/PatternHelper.java b/src/main/java/appeng/helpers/PatternHelper.java index bdf0894c..50c6afdc 100644 --- a/src/main/java/appeng/helpers/PatternHelper.java +++ b/src/main/java/appeng/helpers/PatternHelper.java @@ -65,7 +65,9 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable tmpInputs = new HashMap(); for( IAEItemStack io : this.inputs ) { if( io == null ) + { continue; + } IAEItemStack g = tmpInputs.get( io ); if( g == null ) + { tmpInputs.put( io, io.copy() ); + } else + { g.add( io ); + } } if( tmpOutputs.isEmpty() || tmpInputs.isEmpty() ) + { throw new IllegalStateException( "No pattern here!" ); + } int offset = 0; this.condensedInputs = new IAEItemStack[tmpInputs.size()]; @@ -166,7 +186,9 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable 0 ) + { return this.outputs[0].getItemStack(); + } return null; } @@ -287,19 +317,29 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable getItemInventory() { if( this.sg == null ) + { return null; + } return this.sg.getItemInventory(); } @@ -120,7 +124,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public IMEMonitor getFluidInventory() { if( this.sg == null ) + { return null; + } return this.sg.getFluidInventory(); } @@ -128,21 +134,27 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public void addListener( IMEMonitorHandlerReceiver l, Object verificationToken ) { if( this.itemStorage != null ) + { this.itemStorage.addListener( l, verificationToken ); + } } @Override public void removeListener( IMEMonitorHandlerReceiver l ) { if( this.itemStorage != null ) + { this.itemStorage.removeListener( l ); + } } @Override public IItemList getAvailableItems( IItemList out ) { if( this.itemStorage != null ) + { return this.itemStorage.getAvailableItems( out ); + } return out; } @@ -150,7 +162,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public IItemList getStorageList() { if( this.itemStorage != null ) + { return this.itemStorage.getStorageList(); + } return null; } @@ -158,7 +172,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public AccessRestriction getAccess() { if( this.itemStorage != null ) + { return this.itemStorage.getAccess(); + } return AccessRestriction.NO_ACCESS; } @@ -166,7 +182,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public boolean isPrioritized( IAEItemStack input ) { if( this.itemStorage != null ) + { return this.itemStorage.isPrioritized( input ); + } return false; } @@ -174,7 +192,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public boolean canAccept( IAEItemStack input ) { if( this.itemStorage != null ) + { return this.itemStorage.canAccept( input ); + } return false; } @@ -182,7 +202,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public int getPriority() { if( this.itemStorage != null ) + { return this.itemStorage.getPriority(); + } return 0; } @@ -190,7 +212,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public int getSlot() { if( this.itemStorage != null ) + { return this.itemStorage.getSlot(); + } return 0; } @@ -204,7 +228,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src ) { if( this.itemStorage != null ) + { return this.itemStorage.injectItems( input, type, src ); + } return input; } @@ -212,7 +238,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src ) { if( this.itemStorage != null ) + { return this.itemStorage.extractItems( request, mode, src ); + } return null; } @@ -220,7 +248,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II public StorageChannel getChannel() { if( this.itemStorage != null ) + { return this.itemStorage.getChannel(); + } return StorageChannel.ITEMS; } @@ -273,7 +303,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II { this.rangeCheck(); if( this.myWap != null ) + { return this.myWap.getActionableNode(); + } return null; } @@ -288,7 +320,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II if( this.myWap.getGrid() == this.targetGrid ) { if( this.testWap( this.myWap ) ) + { return true; + } } return false; } @@ -301,7 +335,9 @@ public class WirelessTerminalGuiObject implements IPortableCell, IActionHost, II { IWirelessAccessPoint wap = (IWirelessAccessPoint) n.getMachine(); if( this.testWap( wap ) ) + { this.myWap = wap; + } } return this.myWap != null; diff --git a/src/main/java/appeng/hooks/AETrading.java b/src/main/java/appeng/hooks/AETrading.java index 64c05e96..0e7e7368 100644 --- a/src/main/java/appeng/hooks/AETrading.java +++ b/src/main/java/appeng/hooks/AETrading.java @@ -105,14 +105,22 @@ public class AETrading implements IVillageTradeHandler private void addToList( MerchantRecipeList l, ItemStack a, ItemStack b ) { if( a.stackSize < 1 ) + { a.stackSize = 1; + } if( b.stackSize < 1 ) + { b.stackSize = 1; + } if( a.stackSize > a.getMaxStackSize() ) + { a.stackSize = a.getMaxStackSize(); + } if( b.stackSize > b.getMaxStackSize() ) + { b.stackSize = b.getMaxStackSize(); + } l.add( new MerchantRecipe( a, b ) ); } diff --git a/src/main/java/appeng/hooks/CompassManager.java b/src/main/java/appeng/hooks/CompassManager.java index f798bc8c..f99034e9 100644 --- a/src/main/java/appeng/hooks/CompassManager.java +++ b/src/main/java/appeng/hooks/CompassManager.java @@ -48,7 +48,9 @@ public class CompassManager CompassResult res = i.next(); long diff = now - res.time; if( diff > 20000 ) + { i.remove(); + } } CompassRequest r = new CompassRequest( attunement, x, y, z ); @@ -106,9 +108,13 @@ public class CompassManager public boolean equals( Object obj ) { if( obj == null ) + { return false; + } if( this.getClass() != obj.getClass() ) + { return false; + } CompassRequest other = (CompassRequest) obj; return this.attunement == other.attunement && this.cx == other.cx && this.cdy == other.cdy && this.cz == other.cz; } diff --git a/src/main/java/appeng/hooks/DispenserMatterCannon.java b/src/main/java/appeng/hooks/DispenserMatterCannon.java index 05c8a83f..ab0152e4 100644 --- a/src/main/java/appeng/hooks/DispenserMatterCannon.java +++ b/src/main/java/appeng/hooks/DispenserMatterCannon.java @@ -48,7 +48,9 @@ public final class DispenserMatterCannon extends BehaviorDefaultDispenseItem for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) { if( enumfacing.getFrontOffsetX() == d.offsetX && enumfacing.getFrontOffsetY() == d.offsetY && enumfacing.getFrontOffsetZ() == d.offsetZ ) + { dir = d; + } } ToolMassCannon tm = (ToolMassCannon) i; diff --git a/src/main/java/appeng/hooks/TickHandler.java b/src/main/java/appeng/hooks/TickHandler.java index 2da75352..3c7969d3 100644 --- a/src/main/java/appeng/hooks/TickHandler.java +++ b/src/main/java/appeng/hooks/TickHandler.java @@ -74,20 +74,26 @@ public class TickHandler public HashMap getPlayerColors() { if( Platform.isServer() ) + { return this.srvPlayerColors; + } return this.cliPlayerColors; } public void addCallable( World w, Callable c ) { if( w == null ) + { this.serverQueue.add( c ); + } else { Queue queue = this.callQueue.get( w ); if( queue == null ) + { this.callQueue.put( w, queue = new LinkedList() ); + } queue.add( c ); } @@ -96,26 +102,34 @@ public class TickHandler public void addInit( AEBaseTile tile ) { if( Platform.isServer() ) // for no there is no reason to care about this on the client... + { this.getRepo().tiles.add( tile ); + } } HandlerRep getRepo() { if( Platform.isServer() ) + { return this.server; + } return this.client; } public void addNetwork( Grid grid ) { if( Platform.isServer() ) // for no there is no reason to care about this on the client... + { this.getRepo().networks.add( grid ); + } } public void removeNetwork( Grid grid ) { if( Platform.isServer() ) // for no there is no reason to care about this on the client... + { this.getRepo().networks.remove( grid ); + } } public Iterable getGridList() @@ -140,12 +154,16 @@ public class TickHandler for( IGridNode n : g.getNodes() ) { if( n.getWorld() == ev.world ) + { toDestroy.add( n ); + } } } for( IGridNode n : toDestroy ) + { n.destroy(); + } } } @@ -191,7 +209,9 @@ public class TickHandler { CraftingJob cj = i.next(); if( !cj.simulateFor( simTime ) ) + { i.remove(); + } } } } @@ -207,12 +227,16 @@ public class TickHandler { AEBaseTile bt = repo.tiles.poll(); if( !bt.isInvalid() ) + { bt.onReady(); + } } // tick networks. for( Grid g : this.getRepo().networks ) + { g.update(); + } // cross world queue. this.processQueue( this.serverQueue ); @@ -232,7 +256,9 @@ public class TickHandler { PlayerColor pc = i.next(); if( pc.ticksLeft <= 0 ) + { i.remove(); + } pc.ticksLeft--; } } @@ -240,7 +266,9 @@ public class TickHandler private void processQueue( Queue queue ) { if( queue == null ) + { return; + } Stopwatch sw = Stopwatch.createStarted(); @@ -252,7 +280,9 @@ public class TickHandler c.call(); if( sw.elapsed( TimeUnit.MILLISECONDS ) > 50 ) + { break; + } } catch( Exception e ) { diff --git a/src/main/java/appeng/integration/IntegrationNode.java b/src/main/java/appeng/integration/IntegrationNode.java index 1fa709e0..91abab96 100644 --- a/src/main/java/appeng/integration/IntegrationNode.java +++ b/src/main/java/appeng/integration/IntegrationNode.java @@ -60,7 +60,9 @@ public final class IntegrationNode public boolean isActive() { if( this.state == IntegrationStage.PRE_INIT ) + { this.call( IntegrationStage.PRE_INIT ); + } return this.state != IntegrationStage.FAILED; } @@ -70,7 +72,9 @@ public final class IntegrationNode if( this.state != IntegrationStage.FAILED ) { if( this.state.ordinal() > stage.ordinal() ) + { return; + } try { @@ -84,9 +88,13 @@ public final class IntegrationNode String mode = AEConfig.instance.get( "ModIntegration", this.displayName.replace( " ", "" ), "AUTO" ).getString(); if( mode.toUpperCase().equals( "ON" ) ) + { enabled = true; + } if( mode.toUpperCase().equals( "OFF" ) ) + { enabled = false; + } if( enabled ) { @@ -96,7 +104,9 @@ public final class IntegrationNode f.set( this.classValue, this.instance = this.mod ); } else + { throw new ModNotInstalled( this.modID ); + } this.state = IntegrationStage.INIT; @@ -130,7 +140,9 @@ public final class IntegrationNode { AELog.info( this.displayName + " - Integration Disabled" ); if( !( this.exception instanceof ModNotInstalled ) ) + { AELog.integration( this.exception ); + } } else { diff --git a/src/main/java/appeng/integration/IntegrationRegistry.java b/src/main/java/appeng/integration/IntegrationRegistry.java index 3bd1ef88..a838d426 100644 --- a/src/main/java/appeng/integration/IntegrationRegistry.java +++ b/src/main/java/appeng/integration/IntegrationRegistry.java @@ -35,10 +35,14 @@ public enum IntegrationRegistry public void add( IntegrationType type ) { if( type.side == IntegrationSide.CLIENT && FMLLaunchHandler.side() == Side.SERVER ) + { return; + } if( type.side == IntegrationSide.SERVER && FMLLaunchHandler.side() == Side.CLIENT ) + { return; + } this.modules.add( new IntegrationNode( type.dspName, type.modID, type, "appeng.integration.modules." + type.name() ) ); } @@ -46,16 +50,22 @@ public enum IntegrationRegistry public void init() { for( IntegrationNode node : this.modules ) + { node.call( IntegrationStage.PRE_INIT ); + } for( IntegrationNode node : this.modules ) + { node.call( IntegrationStage.INIT ); + } } public void postInit() { for( IntegrationNode node : this.modules ) + { node.call( IntegrationStage.POST_INIT ); + } } public String getStatus() @@ -81,7 +91,9 @@ public enum IntegrationRegistry for( IntegrationNode node : this.modules ) { if( node.shortName == name ) + { return node.isActive(); + } } return false; } diff --git a/src/main/java/appeng/integration/modules/BC.java b/src/main/java/appeng/integration/modules/BC.java index 35ea3824..6c611f4f 100644 --- a/src/main/java/appeng/integration/modules/BC.java +++ b/src/main/java/appeng/integration/modules/BC.java @@ -134,7 +134,9 @@ public final class BC extends BaseModule implements IBC public boolean isFacade( ItemStack is ) { if( is == null ) + { return false; + } return is.getItem() instanceof IFacadeItem; } @@ -155,7 +157,9 @@ public final class BC extends BaseModule implements IBC public void addFacade( ItemStack item ) { if( item != null ) + { FMLInterModComms.sendMessage( "BuildCraft|Transport", "add-facade", item ); + } } @Override diff --git a/src/main/java/appeng/integration/modules/BCHelpers/BCPipeHandler.java b/src/main/java/appeng/integration/modules/BCHelpers/BCPipeHandler.java index 1320c1ad..3abe52b7 100644 --- a/src/main/java/appeng/integration/modules/BCHelpers/BCPipeHandler.java +++ b/src/main/java/appeng/integration/modules/BCHelpers/BCPipeHandler.java @@ -42,7 +42,9 @@ public class BCPipeHandler implements IExternalStorageHandler public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src ) { if( chan == StorageChannel.ITEMS ) + { return new BCPipeInventory( te, d ); + } return null; } } diff --git a/src/main/java/appeng/integration/modules/BCHelpers/BCPipeInventory.java b/src/main/java/appeng/integration/modules/BCHelpers/BCPipeInventory.java index 417dd826..7cd75fd3 100644 --- a/src/main/java/appeng/integration/modules/BCHelpers/BCPipeInventory.java +++ b/src/main/java/appeng/integration/modules/BCHelpers/BCPipeInventory.java @@ -49,12 +49,16 @@ public class BCPipeInventory implements IMEInventory if( mode == Actionable.SIMULATE ) { if( BC.instance.canAddItemsToPipe( this.te, input.getItemStack(), this.dir ) ) + { return null; + } return input; } if( BC.instance.addItemsToPipe( this.te, input.getItemStack(), this.dir ) ) + { return null; + } return input; } diff --git a/src/main/java/appeng/integration/modules/CraftGuide.java b/src/main/java/appeng/integration/modules/CraftGuide.java index c6f624a0..12ff00ac 100644 --- a/src/main/java/appeng/integration/modules/CraftGuide.java +++ b/src/main/java/appeng/integration/modules/CraftGuide.java @@ -213,7 +213,9 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul output[i] = items.get( i ); if( output[i] instanceof ItemStack[] ) + { output[i] = Arrays.asList( (ItemStack[]) output[i] ); + } if( output[i] instanceof IIngredient ) { @@ -248,7 +250,9 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul output[i] = items[y * width + x]; if( output[i] instanceof ItemStack[] ) + { output[i] = Arrays.asList( (ItemStack[]) output[i] ); + } if( output[i] instanceof IIngredient ) { @@ -284,7 +288,9 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul output[i] = items[y * width + x]; if( output[i] instanceof ItemStack[] ) + { output[i] = Arrays.asList( (ItemStack[]) output[i] ); + } if( output[i] instanceof IIngredient ) { @@ -316,7 +322,9 @@ public class CraftGuide extends CraftGuideAPIObject implements IIntegrationModul { list.set( x, list.get( x ).copy() ); if( list.get( x ).stackSize == 0 ) + { list.get( x ).stackSize = 1; + } } return list; diff --git a/src/main/java/appeng/integration/modules/FMP.java b/src/main/java/appeng/integration/modules/FMP.java index 75a341f7..8fae4cfb 100644 --- a/src/main/java/appeng/integration/modules/FMP.java +++ b/src/main/java/appeng/integration/modules/FMP.java @@ -66,7 +66,9 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF for( PartRegistry pr : PartRegistry.values() ) { if( pr.getName().equals( name ) ) + { return pr.construct( 0 ); + } } return null; @@ -125,7 +127,9 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF String[] data = new String[reg.length]; for( int x = 0; x < data.length; x++ ) + { data[x] = reg[x].getName(); + } MultiPartRegistry.registerConverter( this ); MultiPartRegistry.registerParts( this, data ); @@ -162,7 +166,9 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF { TMultiPart p = i.next(); if( p instanceof CableBusPart ) + { return (IPartHost) p; + } } return new FMPPlacementHelper( mp ); @@ -186,7 +192,9 @@ public class FMP implements IIntegrationModule, IPartFactory, IPartConverter, IF { TMultiPart p = i.next(); if( p instanceof CableBusPart ) + { return ( (CableBusPart) p ).cb; + } } } return null; diff --git a/src/main/java/appeng/integration/modules/FZ.java b/src/main/java/appeng/integration/modules/FZ.java index f470505e..de7137f8 100644 --- a/src/main/java/appeng/integration/modules/FZ.java +++ b/src/main/java/appeng/integration/modules/FZ.java @@ -57,10 +57,14 @@ public class FZ implements IFZ, IIntegrationModule ItemStack i = null; if( day_BarrelClass.isInstance( te ) ) + { i = (ItemStack) day_item.get( te ); + } if( i != null ) + { i = Platform.cloneItemStack( i ); + } return i; } @@ -79,7 +83,9 @@ public class FZ implements IFZ, IIntegrationModule try { if( day_BarrelClass.isInstance( te ) ) + { return (Integer) day_getMaxSize.invoke( te ); + } } catch( IllegalAccessException ignored ) { @@ -99,7 +105,9 @@ public class FZ implements IFZ, IIntegrationModule try { if( day_BarrelClass.isInstance( te ) ) + { return (Integer) day_getItemCount.invoke( te ); + } } catch( IllegalAccessException ignored ) { @@ -119,7 +127,9 @@ public class FZ implements IFZ, IIntegrationModule try { if( day_BarrelClass.isInstance( te ) ) + { day_item.set( te, input == null ? null : input.copy() ); + } } catch( IllegalArgumentException ignored ) { @@ -135,7 +145,9 @@ public class FZ implements IFZ, IIntegrationModule try { if( day_BarrelClass.isInstance( te ) ) + { day_setItemCount.invoke( te, max ); + } te.markDirty(); } diff --git a/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java b/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java index d1c8b6fd..4efd1a57 100644 --- a/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java +++ b/src/main/java/appeng/integration/modules/ImmibisMicroblocks.java @@ -115,7 +115,9 @@ public class ImmibisMicroblocks extends BaseModule implements IImmibisMicroblock final TileEntity tx = w.getTileEntity( x, y, z ); if( tx instanceof IPartHost ) + { return (IPartHost) tx; + } return null; } diff --git a/src/main/java/appeng/integration/modules/InvTweaks.java b/src/main/java/appeng/integration/modules/InvTweaks.java index fce2430d..1ed46843 100644 --- a/src/main/java/appeng/integration/modules/InvTweaks.java +++ b/src/main/java/appeng/integration/modules/InvTweaks.java @@ -46,7 +46,9 @@ public class InvTweaks extends BaseModule implements IInvTweaks public void postInit() { if( api == null ) + { throw new IllegalStateException( "InvTweaks API Instance Failed." ); + } } @Override diff --git a/src/main/java/appeng/integration/modules/NEI.java b/src/main/java/appeng/integration/modules/NEI.java index acf81834..f9535443 100644 --- a/src/main/java/appeng/integration/modules/NEI.java +++ b/src/main/java/appeng/integration/modules/NEI.java @@ -84,7 +84,9 @@ public class NEI extends BaseModule implements INEI, IContainerTooltipHandler this.registerRecipeHandler( new NEIGrinderRecipeHandler() ); if( AEConfig.instance.isFeatureEnabled( AEFeature.Facades ) && AEConfig.instance.isFeatureEnabled( AEFeature.enableFacadeCrafting ) ) + { this.registerRecipeHandler( new NEIFacadeRecipeHandler() ); + } // large stack tooltips GuiContainerManager.addTooltipHandler( this ); @@ -119,12 +121,16 @@ public class NEI extends BaseModule implements INEI, IContainerTooltipHandler public void drawSlot( Slot s ) { if( s == null ) + { return; + } ItemStack stack = s.getStack(); if( stack == null ) + { return; + } Minecraft mc = Minecraft.getMinecraft(); FontRenderer fontRenderer = mc.fontRenderer; @@ -166,7 +172,9 @@ public class NEI extends BaseModule implements INEI, IContainerTooltipHandler public List handleItemTooltip( GuiContainer guiScreen, ItemStack stack, int mouseX, int mouseY, List currentToolTip ) { if( guiScreen instanceof AEBaseMEGui ) + { return ( (AEBaseMEGui) guiScreen ).handleItemTooltip( stack, mouseX, mouseY, currentToolTip ); + } return currentToolTip; } diff --git a/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java b/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java index 808a4b22..58042f11 100644 --- a/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java +++ b/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapedRecipeHandler.java @@ -152,11 +152,15 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler { IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); if( renderer != null ) + { return renderer; + } IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" ); if( positioner == null ) + { return null; + } return new DefaultOverlayRenderer( this.getIngredientStacks( recipe ), positioner ); } @@ -166,7 +170,9 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler { IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); if( handler != null ) + { return handler; + } return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); } @@ -176,7 +182,9 @@ public class NEIAEShapedRecipeHandler extends TemplateRecipeHandler for( PositionedStack stack : this.getIngredientStacks( recipe ) ) { if( ( stack.relx > 43 ) || ( stack.rely > 24 ) ) + { return false; + } } return true; } diff --git a/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java b/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java index f9ab5979..726e881b 100644 --- a/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java +++ b/src/main/java/appeng/integration/modules/NEIHelpers/NEIAEShapelessRecipeHandler.java @@ -152,11 +152,15 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler { IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); if( renderer != null ) + { return renderer; + } IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" ); if( positioner == null ) + { return null; + } return new DefaultOverlayRenderer( this.getIngredientStacks( recipe ), positioner ); } @@ -166,7 +170,9 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler { IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); if( handler != null ) + { return handler; + } return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); } @@ -176,7 +182,9 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler for( PositionedStack stack : this.getIngredientStacks( recipe ) ) { if( ( stack.relx > 43 ) || ( stack.rely > 24 ) ) + { return false; + } } return true; } @@ -246,7 +254,9 @@ public class NEIAEShapelessRecipeHandler extends TemplateRecipeHandler public void computeVisuals() { for( PositionedStack p : this.ingredients ) + { p.generatePermutations(); + } this.result.generatePermutations(); } diff --git a/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java b/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java index 53b018e4..948c55ed 100644 --- a/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java +++ b/src/main/java/appeng/integration/modules/NEIHelpers/NEIFacadeRecipeHandler.java @@ -151,11 +151,15 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler { IRecipeOverlayRenderer renderer = super.getOverlayRenderer( gui, recipe ); if( renderer != null ) + { return renderer; + } IStackPositioner positioner = RecipeInfo.getStackPositioner( gui, "crafting2x2" ); if( positioner == null ) + { return null; + } return new DefaultOverlayRenderer( this.getIngredientStacks( recipe ), positioner ); } @@ -165,7 +169,9 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler { IOverlayHandler handler = super.getOverlayHandler( gui, recipe ); if( handler != null ) + { return handler; + } return RecipeInfo.getOverlayHandler( gui, "crafting2x2" ); } @@ -175,7 +181,9 @@ public class NEIFacadeRecipeHandler extends TemplateRecipeHandler for( PositionedStack stack : this.getIngredientStacks( recipe ) ) { if( ( stack.relx > 43 ) || ( stack.rely > 24 ) ) + { return false; + } } return true; } diff --git a/src/main/java/appeng/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java b/src/main/java/appeng/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java index b4385ba7..0fd624f7 100644 --- a/src/main/java/appeng/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java +++ b/src/main/java/appeng/integration/modules/NEIHelpers/NEIGrinderRecipeHandler.java @@ -206,7 +206,9 @@ public class NEIGrinderRecipeHandler extends TemplateRecipeHandler } if( recipe.getInput() != null ) + { this.ingredients.add( new PositionedStack( recipe.getInput(), 45, 24 ) ); + } } @Override diff --git a/src/main/java/appeng/integration/modules/NEIHelpers/TerminalCraftingSlotFinder.java b/src/main/java/appeng/integration/modules/NEIHelpers/TerminalCraftingSlotFinder.java index d955a4d2..fd241d45 100644 --- a/src/main/java/appeng/integration/modules/NEIHelpers/TerminalCraftingSlotFinder.java +++ b/src/main/java/appeng/integration/modules/NEIHelpers/TerminalCraftingSlotFinder.java @@ -34,11 +34,13 @@ public class TerminalCraftingSlotFinder implements IStackPositioner public ArrayList positionStacks( ArrayList a ) { for( PositionedStack ps : a ) + { if( ps != null ) { ps.relx += GuiMEMonitorable.CraftingGridOffsetX; ps.rely += GuiMEMonitorable.CraftingGridOffsetY; } + } return a; } } diff --git a/src/main/java/appeng/integration/modules/RB.java b/src/main/java/appeng/integration/modules/RB.java index ec5e81fd..b8543d5d 100644 --- a/src/main/java/appeng/integration/modules/RB.java +++ b/src/main/java/appeng/integration/modules/RB.java @@ -49,7 +49,9 @@ public class RB extends BaseModule implements IRB public appeng.api.util.IOrientable getOrientable( TileEntity te ) { if( te instanceof IOrientable ) + { return new RBWrapper( (IOrientable) te ); + } return null; } diff --git a/src/main/java/appeng/integration/modules/helpers/BSCrate.java b/src/main/java/appeng/integration/modules/helpers/BSCrate.java index 475b7690..1e0bfbf1 100644 --- a/src/main/java/appeng/integration/modules/helpers/BSCrate.java +++ b/src/main/java/appeng/integration/modules/helpers/BSCrate.java @@ -47,11 +47,15 @@ public class BSCrate implements IMEInventory public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src ) { if( mode == Actionable.SIMULATE ) + { return null; + } ItemStack failed = this.crateStorage.insertItems( input.getItemStack() ); if( failed == null ) + { return null; + } input.setStackSize( failed.stackSize ); return input; } diff --git a/src/main/java/appeng/integration/modules/helpers/BSCrateHandler.java b/src/main/java/appeng/integration/modules/helpers/BSCrateHandler.java index f50efca9..25171e0a 100644 --- a/src/main/java/appeng/integration/modules/helpers/BSCrateHandler.java +++ b/src/main/java/appeng/integration/modules/helpers/BSCrateHandler.java @@ -42,7 +42,9 @@ public class BSCrateHandler implements IExternalStorageHandler public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource src ) { if( channel == StorageChannel.ITEMS ) + { return new BSCrate( te, ForgeDirection.UNKNOWN ); + } return null; } } diff --git a/src/main/java/appeng/integration/modules/helpers/BSCrateStorageAdaptor.java b/src/main/java/appeng/integration/modules/helpers/BSCrateStorageAdaptor.java index 474c2c66..d83cc1fc 100644 --- a/src/main/java/appeng/integration/modules/helpers/BSCrateStorageAdaptor.java +++ b/src/main/java/appeng/integration/modules/helpers/BSCrateStorageAdaptor.java @@ -99,9 +99,13 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor { int cnt = this.cs.getItemCount( target ); if( cnt == 0 ) + { return null; + } if( cnt > amount ) + { cnt = amount; + } ItemStack c = target.copy(); c.stackSize = cnt; return c; @@ -164,9 +168,13 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor { int cnt = this.cs.getItemCount( target ); if( cnt == 0 ) + { return null; + } if( cnt > amount ) + { cnt = amount; + } ItemStack c = target.copy(); c.stackSize = cnt; return c; @@ -187,7 +195,9 @@ public class BSCrateStorageAdaptor extends InventoryAdaptor int items = this.cs.getSpaceForItem( toBeSimulated ); ItemStack B = Platform.cloneItemStack( toBeSimulated ); if( toBeSimulated.stackSize <= items ) + { return null; + } B.stackSize -= items; return B; } diff --git a/src/main/java/appeng/integration/modules/helpers/FactorizationBarrel.java b/src/main/java/appeng/integration/modules/helpers/FactorizationBarrel.java index cbebe4f8..13a74fb4 100644 --- a/src/main/java/appeng/integration/modules/helpers/FactorizationBarrel.java +++ b/src/main/java/appeng/integration/modules/helpers/FactorizationBarrel.java @@ -53,18 +53,26 @@ public class FactorizationBarrel implements IMEInventory public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src ) { if( input == null ) + { return null; + } if( input.getStackSize() == 0 ) + { return null; + } ItemStack shared = input.getItemStack(); if( shared.isItemDamaged() ) + { return input; + } if( this.remainingItemTypes() > 0 ) { if( mode == Actionable.MODULATE ) + { this.fProxy.setItemType( this.te, input.getItemStack() ); + } } if( this.containsItemType( input, mode == Actionable.SIMULATE ) ) @@ -74,7 +82,9 @@ public class FactorizationBarrel implements IMEInventory if( newTotal > max ) { if( mode == Actionable.MODULATE ) + { this.fProxy.barrelSetCount( this.te, max ); + } IAEItemStack result = input.copy(); result.setStackSize( newTotal - max ); return result; @@ -82,7 +92,9 @@ public class FactorizationBarrel implements IMEInventory else { if( mode == Actionable.MODULATE ) + { this.fProxy.barrelSetCount( this.te, newTotal ); + } return null; } } @@ -101,7 +113,9 @@ public class FactorizationBarrel implements IMEInventory // empty barrels want your love too! if( acceptEmpty && currentItem == null ) + { return true; + } return i.equals( currentItem ); } @@ -132,7 +146,9 @@ public class FactorizationBarrel implements IMEInventory else { if( mode == Actionable.MODULATE ) + { this.fProxy.barrelSetCount( this.te, (int) ( howMany - request.getStackSize() ) ); + } return request.copy(); } } diff --git a/src/main/java/appeng/integration/modules/helpers/FactorizationHandler.java b/src/main/java/appeng/integration/modules/helpers/FactorizationHandler.java index 2aa98081..535a5ccc 100644 --- a/src/main/java/appeng/integration/modules/helpers/FactorizationHandler.java +++ b/src/main/java/appeng/integration/modules/helpers/FactorizationHandler.java @@ -44,7 +44,9 @@ public class FactorizationHandler implements IExternalStorageHandler public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src ) { if( chan == StorageChannel.ITEMS ) + { return new MEMonitorIInventory( new IMEAdaptor( FZ.instance.getFactorizationBarrel( te ), src ) ); + } return null; } } diff --git a/src/main/java/appeng/integration/modules/helpers/MFRDSUHandler.java b/src/main/java/appeng/integration/modules/helpers/MFRDSUHandler.java index ed9cdc30..d3389067 100644 --- a/src/main/java/appeng/integration/modules/helpers/MFRDSUHandler.java +++ b/src/main/java/appeng/integration/modules/helpers/MFRDSUHandler.java @@ -44,7 +44,9 @@ public class MFRDSUHandler implements IExternalStorageHandler public IMEInventory getInventory( TileEntity te, ForgeDirection d, StorageChannel chan, BaseActionSource src ) { if( chan == StorageChannel.ITEMS ) + { return new MEMonitorIInventory( new IMEAdaptor( DSU.instance.getDSU( te ), src ) ); + } return null; } diff --git a/src/main/java/appeng/integration/modules/helpers/MinefactoryReloadedDeepStorageUnit.java b/src/main/java/appeng/integration/modules/helpers/MinefactoryReloadedDeepStorageUnit.java index 550d70e8..b0acfb72 100644 --- a/src/main/java/appeng/integration/modules/helpers/MinefactoryReloadedDeepStorageUnit.java +++ b/src/main/java/appeng/integration/modules/helpers/MinefactoryReloadedDeepStorageUnit.java @@ -56,7 +56,9 @@ public class MinefactoryReloadedDeepStorageUnit implements IMEInventory max ) @@ -64,13 +66,17 @@ public class MinefactoryReloadedDeepStorageUnit implements IMEInventory 1 ? " (" + limit + ')' : "" ); + } } if( name == null ) + { name = j.getKey().getDisplayName() + ( limit > 1 ? " (" + limit + ')' : "" ); + } if( !textList.contains( name ) ) + { textList.add( name ); + } } Pattern p = Pattern.compile( "(\\d+)[^\\d]" ); @@ -134,7 +142,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, public MaterialType getTypeByStack( ItemStack is ) { if( this.dmgToMaterial.containsKey( is.getItemDamage() ) ) + { return this.dmgToMaterial.get( is.getItemDamage() ); + } return MaterialType.InvalidType; } @@ -166,7 +176,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, { boolean enabled = true; for( AEFeature f : mat.getFeature() ) + { enabled = enabled && AEConfig.instance.isFeatureEnabled( f ); + } if( enabled ) { @@ -177,9 +189,13 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, mat.stackSrc = new MaterialStackSrc( mat ); if( this.dmgToMaterial.get( newMaterialNum ) == null ) + { this.dmgToMaterial.put( newMaterialNum, mat ); + } else + { throw new IllegalStateException( "Meta Overlap detected." ); + } return mat.stackSrc; } @@ -187,7 +203,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, return mat.stackSrc; } else + { throw new IllegalStateException( "Cannot create the same material twice..." ); + } } public void makeUnique() @@ -203,7 +221,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, for( String name : names ) { if( replacement != null ) + { break; + } List options = OreDictionary.getOres( name ); if( options != null && options.size() > 0 ) @@ -223,12 +243,16 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, { // continue using the AE2 item. for( String name : names ) + { OreDictionary.registerOre( name, mt.stack( 1 ) ); + } } else { if( mt.itemInstance == this ) + { this.dmgToMaterial.remove( mt.damageValue ); + } mt.itemInstance = replacement.getItem(); mt.damageValue = replacement.getItemDamage(); @@ -241,7 +265,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, public IIcon getIconFromDamage( int dmg ) { if( this.dmgToMaterial.containsKey( dmg ) ) + { return this.dmgToMaterial.get( dmg ).IIcon; + } return new MissingIcon( this ); } @@ -254,11 +280,15 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, private String nameOf( ItemStack is ) { if( is == null ) + { return "null"; + } MaterialType mt = this.getTypeByStack( is ); if( mt == null ) + { return "null"; + } return this.nameResolver.getName( mt.name() ); } @@ -280,7 +310,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, for( MaterialType mat : types ) { if( mat.damageValue >= 0 && mat.isRegistered() && mat.itemInstance == this ) + { cList.add( new ItemStack( this, 1, mat.damageValue ) ); + } } } @@ -313,10 +345,14 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, { SelectedPart sp = ( (IPartHost) te ).selectPart( Vec3.createVectorHelper( hitX, hitY, hitZ ) ); if( sp.part instanceof IUpgradeableHost ) + { upgrades = ( (ISegmentedInventory) sp.part ).getInventoryByName( "upgrades" ); + } } else if( te instanceof IUpgradeableHost ) + { upgrades = ( (ISegmentedInventory) te ).getInventoryByName( "upgrades" ); + } if( upgrades != null && is != null && is.getItem() instanceof IUpgradeModule ) { @@ -329,7 +365,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, if( ad != null ) { if( player.worldObj.isRemote ) + { return false; + } player.inventory.setInventorySlotContents( player.inventory.currentItem, ad.addItems( is ) ); return true; @@ -367,7 +405,9 @@ public class ItemMultiMaterial extends AEBaseItem implements IStorageComponent, eqi.motionZ = location.motionZ; if( location instanceof EntityItem && eqi instanceof EntityItem ) + { ( (EntityItem) eqi ).delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup; + } return eqi; } diff --git a/src/main/java/appeng/items/misc/ItemCrystalSeed.java b/src/main/java/appeng/items/misc/ItemCrystalSeed.java index 48b17281..01bd8f86 100644 --- a/src/main/java/appeng/items/misc/ItemCrystalSeed.java +++ b/src/main/java/appeng/items/misc/ItemCrystalSeed.java @@ -142,7 +142,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal } } if( newDamage > END ) + { return null; + } this.setProgress( is, newDamage ); return is; @@ -183,13 +185,19 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal int damage = this.getProgress( is ); if( damage < Certus + SINGLE_OFFSET ) + { return this.getUnlocalizedName() + ".Certus"; + } if( damage < Nether + SINGLE_OFFSET ) + { return this.getUnlocalizedName() + ".Nether"; + } if( damage < Fluix + SINGLE_OFFSET ) + { return this.getUnlocalizedName() + ".Fluix"; + } return this.getUnlocalizedName(); } @@ -226,8 +234,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal int damage = this.getProgress( stack ); if( damage < Certus + SINGLE_OFFSET ) + { list = this.certus; - + } else if( damage < Nether + SINGLE_OFFSET ) { damage -= Nether; @@ -241,14 +250,22 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal } if( list == null ) + { return Items.diamond.getIconFromDamage( 0 ); + } if( damage < LEVEL_OFFSET ) + { return list[0]; + } else if( damage < LEVEL_OFFSET * 2 ) + { return list[1]; + } else + { return list[2]; + } } @Override @@ -285,7 +302,9 @@ public class ItemCrystalSeed extends AEBaseItem implements IGrowableCrystal egc.motionZ = location.motionZ; if( location instanceof EntityItem ) + { egc.delayBeforeCanPickup = ( (EntityItem) location ).delayBeforeCanPickup; + } return egc; } diff --git a/src/main/java/appeng/items/misc/ItemEncodedPattern.java b/src/main/java/appeng/items/misc/ItemEncodedPattern.java index 62a3c90a..39f532b7 100644 --- a/src/main/java/appeng/items/misc/ItemEncodedPattern.java +++ b/src/main/java/appeng/items/misc/ItemEncodedPattern.java @@ -54,7 +54,9 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt this.setFeature( EnumSet.of( AEFeature.Patterns ) ); this.setMaxStackSize( 1 ); if( Platform.isClient() ) + { MinecraftForgeClient.registerItemRenderer( this, new ItemEncodedPatternRenderer() ); + } } @Override @@ -76,7 +78,9 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt if( player.isSneaking() ) { if( Platform.isClient() ) + { return false; + } InventoryPlayer inv = player.inventory; @@ -159,16 +163,22 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt { ItemStack out = SIMPLE_CACHE.get( item ); if( out != null ) + { return out; + } World w = CommonHelper.proxy.getWorld(); if( w == null ) + { return null; + } ICraftingPatternDetails details = this.getPatternForItem( item, w ); if( details == null ) + { return null; + } SIMPLE_CACHE.put( item, out = details.getCondensedOutputs()[0].getItemStack() ); return out; diff --git a/src/main/java/appeng/items/misc/ItemPaintBall.java b/src/main/java/appeng/items/misc/ItemPaintBall.java index 6c2ecf95..863591fe 100644 --- a/src/main/java/appeng/items/misc/ItemPaintBall.java +++ b/src/main/java/appeng/items/misc/ItemPaintBall.java @@ -46,7 +46,9 @@ public class ItemPaintBall extends AEBaseItem this.setHasSubtypes( true ); if( Platform.isClient() ) + { MinecraftForgeClient.registerItemRenderer( this, new PaintBallRender() ); + } } @Override @@ -64,10 +66,14 @@ public class ItemPaintBall extends AEBaseItem { int dmg = is.getItemDamage(); if( dmg >= DAMAGE_THRESHOLD ) + { dmg -= DAMAGE_THRESHOLD; + } if( dmg >= AEColor.values().length ) + { return AEColor.Transparent; + } return AEColor.values()[dmg]; } @@ -76,12 +82,20 @@ public class ItemPaintBall extends AEBaseItem public void getSubItems( Item i, CreativeTabs ct, List l ) { for( AEColor c : AEColor.values() ) + { if( c != AEColor.Transparent ) + { l.add( new ItemStack( this, 1, c.ordinal() ) ); + } + } for( AEColor c : AEColor.values() ) + { if( c != AEColor.Transparent ) + { l.add( new ItemStack( this, 1, DAMAGE_THRESHOLD + c.ordinal() ) ); + } + } } public boolean isLumen( ItemStack is ) diff --git a/src/main/java/appeng/items/parts/ItemFacade.java b/src/main/java/appeng/items/parts/ItemFacade.java index 0a0a66e1..9c9b190a 100644 --- a/src/main/java/appeng/items/parts/ItemFacade.java +++ b/src/main/java/appeng/items/parts/ItemFacade.java @@ -65,7 +65,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte this.setFeature( EnumSet.of( AEFeature.Facades ) ); this.setHasSubtypes( true ); if( Platform.isClient() ) + { MinecraftForgeClient.registerItemRenderer( this, BusRenderer.INSTANCE ); + } } @Override @@ -125,7 +127,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte { ItemStack facade = this.createFacadeForItem( l, false ); if( facade != null ) + { this.subTypes.add( facade ); + } } } catch( Throwable t ) @@ -135,18 +139,24 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte } if( FacadeConfig.instance.hasChanged() ) + { FacadeConfig.instance.save(); + } } } public ItemStack createFacadeForItem( ItemStack l, boolean returnItem ) { if( l == null ) + { return null; + } Block b = Block.getBlockFromItem( l.getItem() ); if( b == null || l.hasTagCompound() ) + { return null; + } int metadata = l.getItem().getMetadata( l.getItemDamage() ); @@ -158,7 +168,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte if( FacadeConfig.instance.checkEnabled( b, metadata, defaultValue ) ) { if( returnItem ) + { return l; + } ItemStack is = new ItemStack( this ); NBTTagCompound data = new NBTTagCompound(); @@ -180,7 +192,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte { ItemStack in = this.getTextureItem( is ); if( in != null ) + { return new FacadePart( is, side ); + } return null; } @@ -189,7 +203,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte { Block blk = this.getBlock( is ); if( blk != null ) + { return new ItemStack( blk, 1, this.getMeta( is ) ); + } return null; } @@ -201,7 +217,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte { int[] blk = data.getIntArray( "x" ); if( blk != null && blk.length == 2 ) + { return blk[1]; + } } return 0; } @@ -220,7 +238,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte { int[] blk = data.getIntArray( "x" ); if( blk != null && blk.length == 2 ) + { return Block.getBlockById( blk[0] ); + } } } return Blocks.glass; @@ -236,7 +256,9 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte { this.calculateSubTypes(); if( this.subTypes.isEmpty() ) + { return new ItemStack( Items.cake ); + } return this.subTypes.get( 0 ); } @@ -260,11 +282,15 @@ public class ItemFacade extends AEBaseItem implements IFacadeItem, IAlphaPassIte ItemStack out = this.getTextureItem( is ); if( out == null || out.getItem() == null ) + { return false; + } Block blk = Block.getBlockFromItem( out.getItem() ); if( blk != null && blk.canRenderInPass( 1 ) ) + { return true; + } return false; } diff --git a/src/main/java/appeng/items/parts/ItemMultiPart.java b/src/main/java/appeng/items/parts/ItemMultiPart.java index cbd62863..061d3af2 100644 --- a/src/main/java/appeng/items/parts/ItemMultiPart.java +++ b/src/main/java/appeng/items/parts/ItemMultiPart.java @@ -112,15 +112,21 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG for( PartTypeWithVariant p : this.registered.values() ) { if( p.part == mat && p.variant == varID ) + { throw new IllegalStateException( "Cannot create the same material twice..." ); + } } boolean enabled = true; for( AEFeature f : mat.getFeature() ) + { enabled = enabled && AEConfig.instance.isFeatureEnabled( f ); + } for( IntegrationType integrationType : mat.getIntegrations() ) + { enabled &= IntegrationRegistry.INSTANCE.isEnabled( integrationType ); + } final int partDamage = mat.baseDamage + varID; final ItemStackSrc output = new ItemStackSrc( this, partDamage ); @@ -140,7 +146,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG final Map reference = ( enabled ) ? this.registered : this.unregistered; if( reference.containsKey( partDamage ) ) + { throw new IllegalStateException( "Meta Overlap detected with type " + mat + " and damage " + partDamage + ". Found " + reference.get( partDamage ) + " there already." ); + } reference.put( partDamage, pti ); } @@ -152,7 +160,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG for( Entry pt : this.registered.entrySet() ) { if( pt.getValue().part == t ) + { return pt.getKey(); + } } return -1; } @@ -195,7 +205,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG } if( pt.getExtraName() != null ) + { return super.getItemStackDisplayName( is ) + " - " + pt.getExtraName().getLocal(); + } return super.getItemStackDisplayName( is ); } @@ -215,7 +227,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG } ); for( Entry part : types ) + { cList.add( new ItemStack( this, 1, part.getKey() ) ); + } } @Override @@ -245,10 +259,14 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG final PartTypeWithVariant pt = this.registered.get( is.getItemDamage() ); if( pt != null ) + { return pt.part; + } final PartTypeWithVariant unregisteredPartType = this.unregistered.get( is.getItemDamage() ); if( unregisteredPartType != null ) + { return unregisteredPartType.part; + } throw new IllegalStateException( "ItemStack " + is + " has to be either registered or unregistered, but was not found in either." ); } @@ -263,7 +281,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG try { if( type.constructor == null ) + { type.constructor = part.getConstructor( ItemStack.class ); + } return type.constructor.newInstance( is ); } @@ -288,7 +308,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG public int variantOf( int itemDamage ) { if( this.registered.containsKey( itemDamage ) ) + { return this.registered.get( itemDamage ).variant; + } return 0; } @@ -312,12 +334,16 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG case ImportBus: importBus = true; if( u == pt ) + { group = true; + } break; case ExportBus: exportBus = true; if( u == pt ) + { group = true; + } break; default: } @@ -325,7 +351,9 @@ public final class ItemMultiPart extends AEBaseItem implements IPartItem, IItemG } if( group && importBus && exportBus ) + { return GuiText.IOBuses.getUnlocalized(); + } return null; } diff --git a/src/main/java/appeng/items/storage/ItemBasicStorageCell.java b/src/main/java/appeng/items/storage/ItemBasicStorageCell.java index 50d93ef0..8b0c8756 100644 --- a/src/main/java/appeng/items/storage/ItemBasicStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemBasicStorageCell.java @@ -117,9 +117,13 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe String list = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal(); if( handler.isFuzzy() ) + { lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Fuzzy.getLocal() ); + } else + { lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal() ); + } } } } @@ -229,7 +233,9 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe if( player.isSneaking() ) { if( Platform.isClient() ) + { return false; + } InventoryPlayer playerInventory = player.inventory; IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, StorageChannel.ITEMS ); @@ -244,7 +250,9 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe // drop core ItemStack extraB = ia.addItems( this.component.stack( 1 ) ); if( extraB != null ) + { player.dropPlayerItemWithRandomChoice( extraB, false ); + } // drop upgrades final IInventory upgradesInventory = this.getUpgradesInventory( stack ); @@ -269,7 +277,9 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe } if( player.inventoryContainer != null ) + { player.inventoryContainer.detectAndSendChanges(); + } return true; } diff --git a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java index 4e9b26d5..bfb2f0f9 100644 --- a/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java +++ b/src/main/java/appeng/items/storage/ItemSpatialStorageCell.java @@ -59,7 +59,9 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag { WorldCoord wc = this.getStoredSize( stack ); if( wc.x > 0 ) + { lines.add( GuiText.StoredSize.getLocal() + ": " + wc.x + " x " + wc.y + " x " + wc.z ); + } } @Override @@ -111,7 +113,9 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag return WorldSettings.getInstance().getStoredSize( dim ); } else + { return new WorldCoord( c.getInteger( "sizeX" ), c.getInteger( "sizeY" ), c.getInteger( "sizeZ" ) ); + } } return new WorldCoord( 0, 0, 0 ); } @@ -164,7 +168,9 @@ public class ItemSpatialStorageCell extends AEBaseItem implements ISpatialStorag if( targetX <= maxSize && targetY <= maxSize && targetZ <= maxSize ) { if( destination == null ) + { destination = this.createNewWorld( is ); + } StorageHelper.getInstance().swapRegions( w, destination, min.x + 1, min.y + 1, min.z + 1, 1, floorBuffer + 1, 1, targetX - 1, targetY - 1, targetZ - 1 ); this.setStoredSize( is, targetX, targetY, targetZ ); diff --git a/src/main/java/appeng/items/storage/ItemViewCell.java b/src/main/java/appeng/items/storage/ItemViewCell.java index 912cef42..3c5e13dc 100644 --- a/src/main/java/appeng/items/storage/ItemViewCell.java +++ b/src/main/java/appeng/items/storage/ItemViewCell.java @@ -60,7 +60,9 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem for( ItemStack currentViewCell : list ) { if( currentViewCell == null ) + { continue; + } if( ( currentViewCell.getItem() instanceof ItemViewCell ) ) { @@ -100,15 +102,21 @@ public class ItemViewCell extends AEBaseItem implements ICellWorkbenchItem { ItemStack is = config.getStackInSlot( x ); if( is != null ) + { priorityList.add( AEItemStack.create( is ) ); + } } if( !priorityList.isEmpty() ) { if( hasFuzzy ) + { myMergedList.addNewList( new FuzzyPriorityList( priorityList, fzMode ), !hasInverter ); + } else + { myMergedList.addNewList( new PrecisePriorityList( priorityList ), !hasInverter ); + } myPartitionList = myMergedList; } diff --git a/src/main/java/appeng/items/tools/ToolBiometricCard.java b/src/main/java/appeng/items/tools/ToolBiometricCard.java index aea5517e..5daf939f 100644 --- a/src/main/java/appeng/items/tools/ToolBiometricCard.java +++ b/src/main/java/appeng/items/tools/ToolBiometricCard.java @@ -51,7 +51,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard this.setMaxStackSize( 1 ); if( Platform.isClient() ) + { MinecraftForgeClient.registerItemRenderer( this, new ToolBiometricCardRender() ); + } } @Override @@ -73,7 +75,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard if( target instanceof EntityPlayer && !par2EntityPlayer.isSneaking() ) { if( par2EntityPlayer.capabilities.isCreativeMode ) + { is = par2EntityPlayer.getCurrentEquippedItem(); + } this.encode( is, (EntityPlayer) target ); par2EntityPlayer.swingItem(); return true; @@ -93,9 +97,13 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard GameProfile username = this.getProfile( is ); if( username != null && username.equals( p.getGameProfile() ) ) + { this.setProfile( is, null ); + } else + { this.setProfile( is, p.getGameProfile() ); + } } @Override @@ -110,7 +118,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard tag.setTag( "profile", pNBT ); } else + { tag.removeTag( "profile" ); + } } @Override @@ -118,7 +128,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard { NBTTagCompound tag = Platform.openNbtData( is ); if( tag.hasKey( "profile" ) ) + { return NBTUtil.func_152459_a( tag.getCompoundTag( "profile" ) ); + } return null; } @@ -131,7 +143,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard for( SecurityPermissions sp : SecurityPermissions.values() ) { if( tag.getBoolean( sp.name() ) ) + { result.add( sp ); + } } return result; @@ -149,7 +163,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard { NBTTagCompound tag = Platform.openNbtData( itemStack ); if( tag.hasKey( permission.name() ) ) + { tag.removeTag( permission.name() ); + } } @Override @@ -170,7 +186,9 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard { EnumSet perms = this.getPermissions( stack ); if( perms.isEmpty() ) + { lines.add( GuiText.NoPermissions.getLocal() ); + } else { String msg = null; @@ -178,9 +196,13 @@ public class ToolBiometricCard extends AEBaseItem implements IBiometricCard for( SecurityPermissions sp : perms ) { if( msg == null ) + { msg = Platform.gui_localize( sp.getUnlocalizedName() ); + } else + { msg = msg + ", " + Platform.gui_localize( sp.getUnlocalizedName() ); + } } lines.add( msg ); } diff --git a/src/main/java/appeng/items/tools/ToolMemoryCard.java b/src/main/java/appeng/items/tools/ToolMemoryCard.java index 24515764..91d82dbc 100644 --- a/src/main/java/appeng/items/tools/ToolMemoryCard.java +++ b/src/main/java/appeng/items/tools/ToolMemoryCard.java @@ -52,7 +52,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard NBTTagCompound data = this.getData( stack ); if( data.hasKey( "tooltip" ) ) + { lines.add( StatCollector.translateToLocal( this.getLocalizedName( data.getString( "tooltip" ) + ".name", data.getString( "tooltip" ) ) ) ); + } } /** @@ -68,11 +70,15 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard { String l = StatCollector.translateToLocal( n ); if( !l.equals( n ) ) + { return l; + } } for( String n : name ) + { return n; + } return ""; } @@ -99,7 +105,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard NBTTagCompound c = Platform.openNbtData( is ); NBTTagCompound o = c.getCompoundTag( "Data" ); if( o == null ) + { o = new NBTTagCompound(); + } return (NBTTagCompound) o.copy(); } @@ -107,7 +115,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard public void notifyUser( EntityPlayer player, MemoryCardMessages msg ) { if( Platform.isClient() ) + { return; + } switch( msg ) { @@ -138,7 +148,9 @@ public class ToolMemoryCard extends AEBaseItem implements IMemoryCard return true; } else + { return super.onItemUse( is, player, w, x, y, z, side, hx, hy, hz ); + } } @Override diff --git a/src/main/java/appeng/items/tools/ToolNetworkTool.java b/src/main/java/appeng/items/tools/ToolNetworkTool.java index 165aa67e..1c3dc3f4 100644 --- a/src/main/java/appeng/items/tools/ToolNetworkTool.java +++ b/src/main/java/appeng/items/tools/ToolNetworkTool.java @@ -91,7 +91,9 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, int k = mop.blockZ; if( w.getBlock( i, j, k ).isAir( w, i, j, k ) ) + { this.onItemUseFirst( it, p, w, 0, 0, 0, -1, 0, 0, 0 ); + } } } @@ -109,7 +111,9 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, if( part.part != null ) { if( part.part instanceof INetworkToolAgent && !( (INetworkToolAgent) part.part ).showNetworkInfo( mop ) ) + { return false; + } } } else if( te instanceof INetworkToolAgent && !( (INetworkToolAgent) te ).showNetworkInfo( mop ) ) @@ -135,7 +139,9 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, if( side >= 0 ) { if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) ) + { return false; + } Block b = w.getBlock( x, y, z ); if( b != null && !p.isSneaking() ) @@ -155,22 +161,32 @@ public class ToolNetworkTool extends AEBaseItem implements IGuiItem, IAEWrench, if( !p.isSneaking() ) { if( p.openContainer instanceof AEBaseContainer ) + { return true; + } TileEntity te = w.getTileEntity( x, y, z ); if( te instanceof IGridHost ) + { Platform.openGUI( p, te, ForgeDirection.getOrientation( side ), GuiBridge.GUI_NETWORK_STATUS ); + } else + { Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_NETWORK_TOOL ); + } return true; } else + { b.onBlockActivated( w, x, y, z, p, side, hitX, hitY, hitZ ); + } } else + { Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_NETWORK_TOOL ); + } return false; } diff --git a/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java b/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java index 3d19a9c2..0d5546a2 100644 --- a/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java +++ b/src/main/java/appeng/items/tools/powered/ToolColorApplicator.java @@ -90,7 +90,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe for( AEColor col : AEColor.values() ) { if( col == AEColor.Transparent ) + { continue; + } ORE_TO_COLOR.put( OreDictionary.getOreID( "dye" + col.name() ), col ); } @@ -101,7 +103,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe super( AEConfig.instance.colorApplicatorBattery, Optional.absent() ); this.setFeature( EnumSet.of( AEFeature.ColorApplicator, AEFeature.PoweredTools ) ); if( Platform.isClient() ) + { MinecraftForgeClient.registerItemRenderer( this, new ToolColorApplicatorRender() ); + } } @Override @@ -130,10 +134,14 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe paintBall.stackSize = 1; } else + { paintBall = null; + } if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) ) + { return false; + } if( paintBall != null && paintBall.getItem() instanceof ItemSnowball ) { @@ -196,7 +204,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe AEColor selected = this.getActiveColor( par1ItemStack ); if( selected != null && Platform.isClient() ) + { extra = Platform.gui_localize( selected.unlocalizedName ); + } return super.getItemStackDisplayName( par1ItemStack ) + " - " + extra; } @@ -209,10 +219,14 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe public AEColor getColorFromItem( ItemStack paintBall ) { if( paintBall == null ) + { return null; + } if( paintBall.getItem() instanceof ItemSnowball ) + { return AEColor.Transparent; + } if( paintBall.getItem() instanceof ItemPaintBall ) { @@ -226,7 +240,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe for( int oreID : id ) { if( ORE_TO_COLOR.containsKey( oreID ) ) + { return ORE_TO_COLOR.get( oreID ); + } } } @@ -241,7 +257,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe NBTTagCompound color = c.getCompoundTag( "color" ); ItemStack oldColor = ItemStack.loadItemStackFromNBT( color ); if( oldColor != null ) + { return oldColor; + } } return this.findNextColor( is, null, 0 ); @@ -259,14 +277,18 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { IAEItemStack firstItem = itemList.getFirstItem(); if( firstItem != null ) + { newColor = firstItem.getItemStack(); + } } else { LinkedList list = new LinkedList(); for( IAEItemStack i : itemList ) + { list.add( i ); + } Collections.sort( list, new Comparator() { @@ -279,7 +301,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe } ); if( list.size() <= 0 ) + { return null; + } IAEItemStack where = list.getFirst(); int cycles = 1 + list.size(); @@ -292,17 +316,23 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe } if( scrollOffset > 0 ) + { list.addLast( list.removeFirst() ); + } if( scrollOffset < 0 ) + { list.addFirst( list.removeLast() ); + } return list.get( 0 ).getItemStack(); } } if( newColor != null ) + { this.setColor( is, newColor ); + } return newColor; } @@ -311,7 +341,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { NBTTagCompound data = Platform.openNbtData( is ); if( newColor == null ) + { data.removeTag( "color" ); + } else { NBTTagCompound color = new NBTTagCompound(); @@ -326,7 +358,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { int meta = w.getBlockMetadata( x, y, z ); if( newColor.ordinal() == meta ) + { return false; + } return w.setBlock( x, y, z, Blocks.carpet, newColor.ordinal(), 3 ); } @@ -339,7 +373,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { int meta = w.getBlockMetadata( x, y, z ); if( newColor.ordinal() == meta ) + { return false; + } return w.setBlock( x, y, z, Blocks.stained_glass, newColor.ordinal(), 3 ); } @@ -352,7 +388,9 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { int meta = w.getBlockMetadata( x, y, z ); if( newColor.ordinal() == meta ) + { return false; + } return w.setBlock( x, y, z, Blocks.stained_glass_pane, newColor.ordinal(), 3 ); } @@ -365,12 +403,16 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe { int meta = w.getBlockMetadata( x, y, z ); if( newColor.ordinal() == meta ) + { return false; + } return w.setBlock( x, y, z, Blocks.stained_hardened_clay, newColor.ordinal(), 3 ); } if( blk instanceof BlockCableBus ) + { return ( (BlockCableBus) blk ).recolourBlock( w, x, y, z, side, newColor.ordinal(), p ); + } return blk.recolourBlock( w, x, y, z, side, newColor.ordinal() ); } @@ -439,11 +481,15 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe for( int x : id ) { if( ORE_TO_COLOR.containsKey( x ) ) + { return false; + } } if( requestedAddition.getItem() instanceof ItemSnowball ) + { return false; + } return !( requestedAddition.getItem() instanceof ItemPaintBall && requestedAddition.getItemDamage() < 20 ); } diff --git a/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java b/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java index 2aa7a101..db819b44 100644 --- a/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java +++ b/src/main/java/appeng/items/tools/powered/ToolEntropyManipulator.java @@ -114,9 +114,13 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT public boolean equals( Object obj ) { if( obj == null ) + { return false; + } if( this.getClass() != obj.getClass() ) + { return false; + } InWorldToolOperationIngredient other = (InWorldToolOperationIngredient) obj; return this.blockID == other.blockID && this.metadata == other.metadata; } @@ -212,7 +216,9 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT MovingObjectPosition target = this.getMovingObjectPositionFromPlayer( w, p, true ); if( target == null ) + { return item; + } else { if( target.typeOfHit == MovingObjectType.BLOCK ) @@ -240,7 +246,9 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT if( this.getAECurrentPower( item ) > 1600 ) { if( !p.canPlayerEdit( x, y, z, side, item ) ) + { return false; + } Block blockID = w.getBlock( x, y, z ); int metadata = w.getBlockMetadata( x, y, z ); @@ -335,7 +343,9 @@ public class ToolEntropyManipulator extends AEBasePoweredItem implements IBlockT z += dir.offsetZ; if( !p.canPlayerEdit( x, y, z, side, item ) ) + { return false; + } if( w.isAirBlock( x, y, z ) ) { diff --git a/src/main/java/appeng/items/tools/powered/ToolMassCannon.java b/src/main/java/appeng/items/tools/powered/ToolMassCannon.java index 47f22416..7c56b5c9 100644 --- a/src/main/java/appeng/items/tools/powered/ToolMassCannon.java +++ b/src/main/java/appeng/items/tools/powered/ToolMassCannon.java @@ -121,7 +121,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell CellUpgrades cu = (CellUpgrades) this.getUpgradesInventory( item ); if( cu != null ) + { shots += cu.getInstalledUpgrades( Upgrades.SPEED ); + } IMEInventory inv = AEApi.instance().registries().cell().getCellInventory( item, null, StorageChannel.ITEMS ); if( inv != null ) @@ -136,17 +138,23 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell this.extractAEPower( item, 1600 ); if( Platform.isClient() ) + { return item; + } aeAmmo.setStackSize( 1 ); ItemStack ammo = ( (IAEItemStack) aeAmmo ).getItemStack(); if( ammo == null ) + { return item; + } ammo.stackSize = 1; aeAmmo = inv.extractItems( aeAmmo, Actionable.MODULATE, new PlayerSource( p, null ) ); if( aeAmmo == null ) + { return item; + } float f = 1.0F; float f1 = p.prevRotationPitch + ( p.rotationPitch - p.prevRotationPitch ) * f; @@ -186,7 +194,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell else { if( Platform.isServer() ) + { p.addChatMessage( PlayerMessages.AmmoDepleted.get() ); + } return item; } } @@ -213,7 +223,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell { // prevent killing / flying of mounts. if( entity1.riddenByEntity == p ) + { continue; + } float f1 = 0.3F; @@ -286,7 +298,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell int z = pos.blockZ + side.offsetZ; if( !Platform.hasPermissions( new DimensionalCoord( w, x, y, z ), p ) ) + { return; + } Block whatsThere = w.getBlock( x, y, z ); if( whatsThere.isReplaceable( w, x, y, z ) && w.isAirBlock( x, y, z ) ) @@ -333,7 +347,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell { // prevent killing / flying of mounts. if( entity1.riddenByEntity == p ) + { continue; + } float f1 = 0.3F; @@ -391,7 +407,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell // vec3.zCoord ); el.attackEntityFrom( dmgSrc, dmg ); if( !el.isEntityAlive() ) + { hasDestroyedSomething = true; + } } else if( pos.entityHit instanceof EntityItem ) { @@ -406,7 +424,9 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell else if( pos.typeOfHit == MovingObjectType.BLOCK ) { if( !AEConfig.instance.isFeatureEnabled( AEFeature.MassCannonBlockDamage ) ) + { penetration = 0; + } else { Block b = w.getBlock( pos.blockX, pos.blockY, pos.blockZ ); @@ -498,10 +518,14 @@ public class ToolMassCannon extends AEBasePoweredItem implements IStorageCell { float pen = AEApi.instance().registries().matterCannon().getPenetration( requestedAddition.getItemStack() ); if( pen > 0 ) + { return false; + } if( requestedAddition.getItem() instanceof ItemPaintBall ) + { return false; + } return true; } diff --git a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java index 086d5a44..aaff413b 100644 --- a/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java +++ b/src/main/java/appeng/items/tools/powered/ToolWirelessTerminal.java @@ -85,13 +85,19 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless String encKey = tag.getString( "encryptionKey" ); if( encKey == null || encKey.isEmpty() ) + { lines.add( GuiText.Unlinked.getLocal() ); + } else + { lines.add( GuiText.Linked.getLocal() ); + } } } else + { lines.add( StatCollector.translateToLocal( "AppEng.GuiITooltip.Unlinked" ) ); + } } @Override diff --git a/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java b/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java index 0ca60108..9dcef9f3 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java +++ b/src/main/java/appeng/items/tools/powered/powersink/AERootPoweredItem.java @@ -156,7 +156,9 @@ public abstract class AERootPoweredItem extends AEBaseItem implements IAEItemPow { int requiredEU = (int) PowerUnits.AE.convertTo( PowerUnits.EU, this.getAEMaxPower( is ) - this.getAECurrentPower( is ) ); if( amount < requiredEU ) + { return 0; + } return amount - requiredEU; } else diff --git a/src/main/java/appeng/items/tools/powered/powersink/IC2.java b/src/main/java/appeng/items/tools/powered/powersink/IC2.java index bfb66b1a..fb55afe2 100644 --- a/src/main/java/appeng/items/tools/powered/powersink/IC2.java +++ b/src/main/java/appeng/items/tools/powered/powersink/IC2.java @@ -48,7 +48,9 @@ public abstract class IC2 extends AERootPoweredItem implements IElectricItemMana double limit = this.getTransferLimit( is ); if( !ignoreTransferLimit && amount > limit ) + { addedAmt = limit; + } return addedAmt - ( (int) this.injectExternalPower( PowerUnits.EU, is, addedAmt, simulate ) ); } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java index 6f4e6a5a..43bfc3c9 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzCuttingKnife.java @@ -55,7 +55,9 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem public boolean onItemUse( ItemStack is, EntityPlayer p, World w, int x, int y, int z, int s, float hitX, float hitY, float hitZ ) { if( Platform.isServer() ) + { Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE ); + } return true; } @@ -63,7 +65,9 @@ public class ToolQuartzCuttingKnife extends AEBaseItem implements IGuiItem public ItemStack onItemRightClick( ItemStack it, World w, EntityPlayer p ) { if( Platform.isServer() ) + { Platform.openGUI( p, null, ForgeDirection.UNKNOWN, GuiBridge.GUI_QUARTZ_KNIFE ); + } p.swingItem(); return it; } diff --git a/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java b/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java index a2bbdca1..cefb9922 100644 --- a/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java +++ b/src/main/java/appeng/items/tools/quartz/ToolQuartzWrench.java @@ -58,7 +58,9 @@ public class ToolQuartzWrench extends AEBaseItem implements IAEWrench, IToolWren if( b != null && !player.isSneaking() && Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) ) { if( Platform.isClient() ) + { return !world.isRemote; + } ForgeDirection mySide = ForgeDirection.getOrientation( side ); if( b.rotateBlock( world, x, y, z, mySide ) ) diff --git a/src/main/java/appeng/me/Grid.java b/src/main/java/appeng/me/Grid.java index 06f98714..7c137402 100644 --- a/src/main/java/appeng/me/Grid.java +++ b/src/main/java/appeng/me/Grid.java @@ -95,7 +95,9 @@ public class Grid implements IGrid { int out = 0; for( Collection x : this.machines.values() ) + { out += x.size(); + } return out; } @@ -110,7 +112,9 @@ public class Grid implements IGrid Class machineClass = gridNode.getMachineClass(); Set nodes = this.machines.get( machineClass ); if( nodes != null ) + { nodes.remove( gridNode ); + } gridNode.setGridStorage( null ); @@ -118,7 +122,9 @@ public class Grid implements IGrid { Iterator n = this.getNodes().iterator(); if( n.hasNext() ) + { this.pivot = (GridNode) n.next(); + } else { this.pivot = null; @@ -152,7 +158,9 @@ public class Grid implements IGrid this.myStorage.setGrid( this ); for( IGridCache gc : this.caches.values() ) + { gc.onJoin( this.myStorage ); + } } else if( grid != this ) { @@ -168,10 +176,14 @@ public class Grid implements IGrid gs.addDivided( this.myStorage ); for( IGridCache gc : ( (Grid) grid ).caches.values() ) + { gc.onSplit( tmp ); + } for( IGridCache gc : this.caches.values() ) + { gc.onJoin( tmp ); + } } } } @@ -229,7 +241,9 @@ public class Grid implements IGrid { MachineSet s = this.machines.get( c ); if( s == null ) + { return new MachineSet( c ); + } return s; } @@ -262,7 +276,9 @@ public class Grid implements IGrid { // are there any nodes left? if( this.pivot != null ) + { gc.onUpdateTick(); + } } } diff --git a/src/main/java/appeng/me/GridConnection.java b/src/main/java/appeng/me/GridConnection.java index fedaf736..d5f72090 100644 --- a/src/main/java/appeng/me/GridConnection.java +++ b/src/main/java/appeng/me/GridConnection.java @@ -71,7 +71,9 @@ public class GridConnection implements IGridConnection, IPathItem } if( a == null || b == null ) + { throw new GridException( "Connection Forged Between null entities." ); + } if( a.hasConnection( b ) || b.hasConnection( a ) ) { @@ -129,9 +131,13 @@ public class GridConnection implements IGridConnection, IPathItem public IGridNode getOtherSide( IGridNode gridNode ) { if( gridNode == this.sideA ) + { return this.sideB; + } if( gridNode == this.sideB ) + { return this.sideA; + } throw new GridException( "Invalid Side of Connection" ); } @@ -140,12 +146,18 @@ public class GridConnection implements IGridConnection, IPathItem public ForgeDirection getDirection( IGridNode side ) { if( this.fromAtoB == ForgeDirection.UNKNOWN ) + { return this.fromAtoB; + } if( this.sideA == side ) + { return this.fromAtoB; + } else + { return this.fromAtoB.getOpposite(); + } } @Override @@ -190,7 +202,9 @@ public class GridConnection implements IGridConnection, IPathItem public IPathItem getControllerRoute() { if( this.sideA.getFlags().contains( GridFlags.CANNOT_CARRY ) ) + { return null; + } return this.sideA; } @@ -198,7 +212,9 @@ public class GridConnection implements IGridConnection, IPathItem public void setControllerRoute( IPathItem fast, boolean zeroOut ) { if( zeroOut ) + { this.channelData &= ~0xff; + } if( this.sideB == fast ) { @@ -242,10 +258,14 @@ public class GridConnection implements IGridConnection, IPathItem this.channelData |= this.channelData << 8; if( this.sideA.getInternalGrid() != null ) + { this.sideA.getInternalGrid().postEventTo( this.sideA, EVENT ); + } if( this.sideB.getInternalGrid() != null ) + { this.sideB.getInternalGrid().postEventTo( this.sideB, EVENT ); + } } } diff --git a/src/main/java/appeng/me/GridNode.java b/src/main/java/appeng/me/GridNode.java index 798e6e76..8458cba0 100644 --- a/src/main/java/appeng/me/GridNode.java +++ b/src/main/java/appeng/me/GridNode.java @@ -102,7 +102,9 @@ public class GridNode implements IGridNode, IPathItem { this.connections.add( gridConnection ); if( gridConnection.hasDirection() ) + { this.gridProxy.onGridNotification( GridNotification.ConnectionsChanged ); + } final IGridNode gn = this; @@ -113,7 +115,9 @@ public class GridNode implements IGridNode, IPathItem { this.connections.remove( gridConnection ); if( gridConnection.hasDirection() ) + { this.gridProxy.onGridNotification( GridNotification.ConnectionsChanged ); + } } public boolean hasConnection( IGridNode otherSide ) @@ -121,7 +125,9 @@ public class GridNode implements IGridNode, IPathItem for( IGridConnection gc : this.connections ) { if( gc.a() == otherSide || gc.b() == otherSide ) + { return true; + } } return false; } @@ -140,7 +146,9 @@ public class GridNode implements IGridNode, IPathItem public Grid getInternalGrid() { if( this.myGrid == null ) + { this.myGrid = new Grid( this ); + } return this.myGrid; } @@ -163,13 +171,17 @@ public class GridNode implements IGridNode, IPathItem while( !nextRun.isEmpty() ) { while( !nextConn.isEmpty() ) + { gcv.visitConnection( nextConn.poll() ); + } LinkedList thisRun = nextRun; nextRun = new LinkedList(); for( GridNode n : thisRun ) + { n.visitorConnection( tracker, g, nextRun, nextConn ); + } } } else @@ -180,7 +192,9 @@ public class GridNode implements IGridNode, IPathItem nextRun = new LinkedList(); for( GridNode n : thisRun ) + { n.visitorNode( tracker, g, nextRun ); + } } } } @@ -195,7 +209,9 @@ public class GridNode implements IGridNode, IPathItem this.compressedData |= ( this.gridProxy.getGridColor().ordinal() << 3 ); for( ForgeDirection dir : this.gridProxy.getConnectableSides() ) + { this.compressedData |= ( 1 << ( dir.ordinal() + 8 ) ); + } this.FindConnections(); this.getInternalGrid(); @@ -216,7 +232,9 @@ public class GridNode implements IGridNode, IPathItem public void setGrid( Grid grid ) { if( this.myGrid == grid ) + { return; + } if( this.myGrid != null ) { @@ -227,7 +245,9 @@ public class GridNode implements IGridNode, IPathItem this.myGrid.saveState(); for( IGridCache c : grid.getCaches().values() ) + { c.onJoin( this.myGrid.getMyStorage() ); + } } } @@ -242,7 +262,9 @@ public class GridNode implements IGridNode, IPathItem { // not part of this network for real anymore. if( this.connections.size() == 1 ) + { this.setGridStorage( null ); + } IGridConnection c = this.connections.listIterator().next(); GridNode otherSide = (GridNode) c.getOtherSide( this ); @@ -251,7 +273,9 @@ public class GridNode implements IGridNode, IPathItem } if( this.myGrid != null ) + { this.myGrid.remove( this ); + } } @Override @@ -265,7 +289,9 @@ public class GridNode implements IGridNode, IPathItem { EnumSet set = EnumSet.noneOf( ForgeDirection.class ); for( IGridConnection gc : this.connections ) + { set.add( gc.getDirection( this ) ); + } return set; } @@ -305,7 +331,9 @@ public class GridNode implements IGridNode, IPathItem this.setGridStorage( WorldSettings.getInstance().getGridStorage( node.getLong( "g" ) ) ); } else + { throw new IllegalStateException( "Loading data after part of a grid, this is invalid." ); + } } @Override @@ -322,7 +350,9 @@ public class GridNode implements IGridNode, IPathItem nodeData.setTag( name, node ); } else + { nodeData.removeTag( name ); + } } @Override @@ -347,7 +377,9 @@ public class GridNode implements IGridNode, IPathItem public void setPlayerID( int playerID ) { if( playerID >= 0 ) + { this.playerID = playerID; + } } public int getUsedChannels() @@ -358,7 +390,9 @@ public class GridNode implements IGridNode, IPathItem public void FindConnections() { if( !this.gridProxy.isWorldAccessible() ) + { return; + } EnumSet newSecurityConnections = EnumSet.noneOf( ForgeDirection.class ); @@ -370,7 +404,9 @@ public class GridNode implements IGridNode, IPathItem { GridNode node = (GridNode) te.getGridNode( f.getOpposite() ); if( node == null ) + { continue; + } boolean isValidConnection = this.canConnect( node, f ) && node.canConnect( this, f.getOpposite() ); @@ -392,7 +428,9 @@ public class GridNode implements IGridNode, IPathItem { // if this connection is no longer valid, destroy it. if( !isValidConnection ) + { con.destroy(); + } } else { @@ -403,7 +441,9 @@ public class GridNode implements IGridNode, IPathItem else if( isValidConnection ) { if( node.lastSecurityKey != -1 ) + { newSecurityConnections.add( f ); + } else { // construct a new connection between these two nodes. @@ -429,7 +469,9 @@ public class GridNode implements IGridNode, IPathItem { GridNode node = (GridNode) te.getGridNode( f.getOpposite() ); if( node == null ) + { continue; + } // construct a new connection between these two nodes. try @@ -452,7 +494,9 @@ public class GridNode implements IGridNode, IPathItem { TileEntity te = world.getTileEntity( x, y, z ); if( te instanceof IGridHost ) + { return (IGridHost) te; + } } return null; } @@ -460,10 +504,14 @@ public class GridNode implements IGridNode, IPathItem public boolean canConnect( GridNode from, ForgeDirection dir ) { if( !this.isValidDirection( dir ) ) + { return false; + } if( !from.getColor().matches( this.getColor() ) ) + { return false; + } return true; } @@ -494,7 +542,9 @@ public class GridNode implements IGridNode, IPathItem } if( tracker == gn.visitorIterationNumber ) + { continue; + } gn.visitorIterationNumber = tracker; @@ -512,7 +562,9 @@ public class GridNode implements IGridNode, IPathItem GridNode gn = (GridNode) gc.getOtherSide( this ); if( tracker == gn.visitorIterationNumber ) + { continue; + } gn.visitorIterationNumber = tracker; @@ -536,7 +588,9 @@ public class GridNode implements IGridNode, IPathItem public IPathItem getControllerRoute() { if( this.connections.isEmpty() || this.getFlags().contains( GridFlags.CANNOT_CARRY ) ) + { return null; + } return (IPathItem) this.connections.get( 0 ); } @@ -545,7 +599,9 @@ public class GridNode implements IGridNode, IPathItem public void setControllerRoute( IPathItem fast, boolean zeroOut ) { if( zeroOut ) + { this.channelData &= ~0xff; + } int idx = this.connections.indexOf( fast ); if( idx > 0 ) @@ -588,7 +644,9 @@ public class GridNode implements IGridNode, IPathItem public void finalizeChannels() { if( this.getFlags().contains( GridFlags.CANNOT_CARRY ) ) + { return; + } if( this.getLastUsedChannels() != this.getUsedChannels() ) { @@ -596,7 +654,9 @@ public class GridNode implements IGridNode, IPathItem this.channelData |= this.channelData << 8; if( this.getInternalGrid() != null ) + { this.getInternalGrid().postEventTo( this, EVENT ); + } } } diff --git a/src/main/java/appeng/me/GridNodeCollection.java b/src/main/java/appeng/me/GridNodeCollection.java index 6c11d15a..4895b4e3 100644 --- a/src/main/java/appeng/me/GridNodeCollection.java +++ b/src/main/java/appeng/me/GridNodeCollection.java @@ -49,7 +49,9 @@ public class GridNodeCollection implements IReadOnlyCollection int size = 0; for( Set o : this.machines.values() ) + { size += o.size(); + } return size; } @@ -58,8 +60,12 @@ public class GridNodeCollection implements IReadOnlyCollection public boolean isEmpty() { for( Set o : this.machines.values() ) + { if( !o.isEmpty() ) + { return false; + } + } return true; } diff --git a/src/main/java/appeng/me/GridSplitDetector.java b/src/main/java/appeng/me/GridSplitDetector.java index f84cceb8..695f83fd 100644 --- a/src/main/java/appeng/me/GridSplitDetector.java +++ b/src/main/java/appeng/me/GridSplitDetector.java @@ -38,7 +38,9 @@ class GridSplitDetector implements IGridVisitor public boolean visitNode( IGridNode n ) { if( n == this.pivot ) + { this.pivotFound = true; + } return !this.pivotFound; } diff --git a/src/main/java/appeng/me/GridStorageSearch.java b/src/main/java/appeng/me/GridStorageSearch.java index b7e6420a..dc119b05 100644 --- a/src/main/java/appeng/me/GridStorageSearch.java +++ b/src/main/java/appeng/me/GridStorageSearch.java @@ -48,13 +48,19 @@ public class GridStorageSearch public boolean equals( Object obj ) { if( obj == null ) + { return false; + } if( this.getClass() != obj.getClass() ) + { return false; + } GridStorageSearch other = (GridStorageSearch) obj; if( this.id == other.id ) + { return true; + } return false; } diff --git a/src/main/java/appeng/me/NetworkEventBus.java b/src/main/java/appeng/me/NetworkEventBus.java index 194b3884..c55b740b 100644 --- a/src/main/java/appeng/me/NetworkEventBus.java +++ b/src/main/java/appeng/me/NetworkEventBus.java @@ -42,7 +42,9 @@ public class NetworkEventBus public void readClass( Class listAs, Class c ) { if( READ_CLASSES.contains( c ) ) + { return; + } READ_CLASSES.add( c ); try @@ -60,21 +62,29 @@ public class NetworkEventBus Map classEvents = EVENTS.get( types[0] ); if( classEvents == null ) + { EVENTS.put( types[0], classEvents = new HashMap() ); + } MENetworkEventInfo thisEvent = classEvents.get( listAs ); if( thisEvent == null ) + { thisEvent = new MENetworkEventInfo(); + } thisEvent.Add( types[0], c, m ); classEvents.put( listAs, thisEvent ); } else + { throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m.getName() + "s Parameter must extend MENetworkEvent." ); + } } else + { throw new IllegalStateException( "Invalid ME Network Event Subscriber, " + m.getName() + " must have exactly 1 parameter." ); + } } } } @@ -183,7 +193,9 @@ public class NetworkEventBus } if( e.isCanceled() ) + { throw new NetworkEventDone(); + } } } @@ -201,7 +213,9 @@ public class NetworkEventBus public void invoke( Object obj, MENetworkEvent e ) throws NetworkEventDone { for( EventMethod em : this.methods ) + { em.invoke( obj, e ); + } } } } diff --git a/src/main/java/appeng/me/cache/CraftingGridCache.java b/src/main/java/appeng/me/cache/CraftingGridCache.java index e5faf1b1..15455ee6 100644 --- a/src/main/java/appeng/me/cache/CraftingGridCache.java +++ b/src/main/java/appeng/me/cache/CraftingGridCache.java @@ -544,13 +544,17 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper { int comparison = ItemSorters.compareLong( nextCluster.getCoProcessors(), firstCluster.getCoProcessors() ); if( comparison != 0 ) + { return comparison; + } return ItemSorters.compareLong( nextCluster.getAvailableStorage(), firstCluster.getAvailableStorage() ); } int comparison = ItemSorters.compareLong( firstCluster.getCoProcessors(), nextCluster.getCoProcessors() ); if( comparison != 0 ) + { return comparison; + } return ItemSorters.compareLong( firstCluster.getAvailableStorage(), nextCluster.getAvailableStorage() ); } } ); diff --git a/src/main/java/appeng/me/cache/EnergyGridCache.java b/src/main/java/appeng/me/cache/EnergyGridCache.java index 578dba1a..8bd4149f 100644 --- a/src/main/java/appeng/me/cache/EnergyGridCache.java +++ b/src/main/java/appeng/me/cache/EnergyGridCache.java @@ -129,11 +129,15 @@ public class EnergyGridCache implements IEnergyGrid { case PROVIDE_POWER: if( ev.storage.getPowerFlow() != AccessRestriction.WRITE ) + { this.providers.add( ev.storage ); + } break; case REQUEST_POWER: if( ev.storage.getPowerFlow() != AccessRestriction.READ ) + { this.requesters.add( ev.storage ); + } break; } } @@ -183,18 +187,26 @@ public class EnergyGridCache implements IEnergyGrid // ticks since change.. if( currentlyHasPower == this.hasPower ) + { this.ticksSinceHasPowerChange++; + } else + { this.ticksSinceHasPowerChange = 0; + } // update status.. this.hasPower = currentlyHasPower; // update public status, this buffers power ups for 30 ticks. if( this.hasPower && this.ticksSinceHasPowerChange > 30 ) + { this.publicPowerState( true, this.myGrid ); + } else if( !this.hasPower ) + { this.publicPowerState( false, this.myGrid ); + } this.availableTicksSinceUpdate++; } @@ -215,7 +227,9 @@ public class EnergyGridCache implements IEnergyGrid private void publicPowerState( boolean newState, IGrid grid ) { if( this.publicHasPower == newState ) + { return; + } this.publicHasPower = newState; ( (Grid) this.myGrid ).setImportantFlag( 0, this.publicHasPower ); @@ -230,14 +244,18 @@ public class EnergyGridCache implements IEnergyGrid this.availableTicksSinceUpdate = 0; this.globalAvailablePower = 0; for( IAEPowerStorage p : this.providers ) + { this.globalAvailablePower += p.getAECurrentPower(); + } } @Override public double extractAEPower( double amt, Actionable mode, Set seen ) { if( !seen.add( this ) ) + { return 0; + } double extractedPower = this.extra; @@ -249,7 +267,9 @@ public class EnergyGridCache implements IEnergyGrid { Iterator i = this.energyGridProviders.iterator(); while( extractedPower < amt && i.hasNext() ) + { extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen ); + } } return extractedPower; @@ -274,7 +294,9 @@ public class EnergyGridCache implements IEnergyGrid { Iterator i = this.energyGridProviders.iterator(); while( extractedPower < amt && i.hasNext() ) + { extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen ); + } } // go less or the correct amount? @@ -287,7 +309,9 @@ public class EnergyGridCache implements IEnergyGrid public double injectAEPower( double amt, Actionable mode, Set seen ) { if( !seen.add( this ) ) + { return 0; + } double ignore = this.extra; amt += this.extra; @@ -303,7 +327,9 @@ public class EnergyGridCache implements IEnergyGrid Iterator i = this.energyGridProviders.iterator(); while( amt > 0 && i.hasNext() ) + { amt = i.next().injectAEPower( amt, mode, seen ); + } } else { @@ -345,7 +371,9 @@ public class EnergyGridCache implements IEnergyGrid public double getEnergyDemand( double maxRequired, Set seen ) { if( !seen.add( this ) ) + { return 0; + } double required = this.buffer() - this.extra; @@ -354,7 +382,9 @@ public class EnergyGridCache implements IEnergyGrid { IAEPowerStorage node = it.next(); if( node.getPowerFlow() != AccessRestriction.READ ) + { required += Math.max( 0.0, node.getAEMaxPower() - node.getAECurrentPower() ); + } } Iterator ix = this.energyGridProviders.iterator(); @@ -460,7 +490,9 @@ public class EnergyGridCache implements IEnergyGrid public double getStoredPower() { if( this.availableTicksSinceUpdate > 90 ) + { this.refreshPower(); + } return Math.max( 0.0, this.globalAvailablePower ); } @@ -482,7 +514,9 @@ public class EnergyGridCache implements IEnergyGrid public void removeNode( IGridNode node, IGridHost machine ) { if( machine instanceof IEnergyGridProvider ) + { this.energyGridProviders.remove( machine ); + } // idle draw. GridNode gridNode = (GridNode) node; @@ -501,10 +535,14 @@ public class EnergyGridCache implements IEnergyGrid } if( this.lastProvider == machine ) + { this.lastProvider = null; + } if( this.lastRequester == machine ) + { this.lastRequester = null; + } this.providers.remove( machine ); this.requesters.remove( machine ); @@ -526,7 +564,9 @@ public class EnergyGridCache implements IEnergyGrid public void addNode( IGridNode node, IGridHost machine ) { if( machine instanceof IEnergyGridProvider ) + { this.energyGridProviders.add( (IEnergyGridProvider) machine ); + } // idle draw... GridNode gridNode = (GridNode) node; @@ -555,7 +595,9 @@ public class EnergyGridCache implements IEnergyGrid } if( current < max && ps.getPowerFlow() != AccessRestriction.READ ) + { this.requesters.add( ps ); + } } } diff --git a/src/main/java/appeng/me/cache/GridStorageCache.java b/src/main/java/appeng/me/cache/GridStorageCache.java index b3bce2cc..25c6d0e1 100644 --- a/src/main/java/appeng/me/cache/GridStorageCache.java +++ b/src/main/java/appeng/me/cache/GridStorageCache.java @@ -114,7 +114,9 @@ public class GridStorageCache implements IStorageGrid this.myGrid.postEvent( new MENetworkCellArrayUpdate() ); if( node.isActive() ) + { this.addCellProvider( cc, new CellChangeTracker() ).applyChanges(); + } } if( machine instanceof IStackWatcherHost ) @@ -153,7 +155,9 @@ public class GridStorageCache implements IStorageGrid BaseActionSource actionSrc = new BaseActionSource(); if( cc instanceof IActionHost ) + { actionSrc = new MachineSource( (IActionHost) cc ); + } for( IMEInventoryHandler h : cc.getCellArray( StorageChannel.ITEMS ) ) { @@ -178,7 +182,9 @@ public class GridStorageCache implements IStorageGrid BaseActionSource actionSrc = new BaseActionSource(); if( cc instanceof IActionHost ) + { actionSrc = new MachineSource( (IActionHost) cc ); + } for( IMEInventoryHandler h : cc.getCellArray( StorageChannel.ITEMS ) ) { @@ -214,15 +220,23 @@ public class GridStorageCache implements IStorageGrid { IGridNode node = ( (IActionHost) cc ).getActionableNode(); if( node != null && node.isActive() ) + { Active = true; + } else + { Active = false; + } } if( Active ) + { this.addCellProvider( cc, tracker ); + } else + { this.removeCellProvider( cc, tracker ); + } } this.itemMonitor.forceUpdate(); @@ -248,7 +262,9 @@ public class GridStorageCache implements IStorageGrid public IMEInventoryHandler getItemInventoryHandler() { if( this.myItemNetwork == null ) + { this.buildNetworkStorage( StorageChannel.ITEMS ); + } return this.myItemNetwork; } @@ -263,7 +279,9 @@ public class GridStorageCache implements IStorageGrid for( ICellProvider cc : this.activeCellProviders ) { for( IMEInventoryHandler h : cc.getCellArray( chan ) ) + { this.myFluidNetwork.addNewStorage( h ); + } } break; case ITEMS: @@ -271,7 +289,9 @@ public class GridStorageCache implements IStorageGrid for( ICellProvider cc : this.activeCellProviders ) { for( IMEInventoryHandler h : cc.getCellArray( chan ) ) + { this.myItemNetwork.addNewStorage( h ); + } } break; default: @@ -281,7 +301,9 @@ public class GridStorageCache implements IStorageGrid public IMEInventoryHandler getFluidInventoryHandler() { if( this.myFluidNetwork == null ) + { this.buildNetworkStorage( StorageChannel.FLUIDS ); + } return this.myFluidNetwork; } @@ -289,9 +311,13 @@ public class GridStorageCache implements IStorageGrid public void postAlterationOfStoredItems( StorageChannel chan, Iterable input, BaseActionSource src ) { if( chan == StorageChannel.ITEMS ) + { this.itemMonitor.postChange( true, (Iterable) input, src ); + } else if( chan == StorageChannel.FLUIDS ) + { this.fluidMonitor.postChange( true, (Iterable) input, src ); + } } @Override @@ -335,11 +361,17 @@ public class GridStorageCache implements IStorageGrid this.src = actionSrc; if( channel == StorageChannel.ITEMS ) + { this.list = ( (IMEInventoryHandler) h ).getAvailableItems( AEApi.instance().storage().createItemList() ); + } else if( channel == StorageChannel.FLUIDS ) + { this.list = ( (IMEInventoryHandler) h ).getAvailableItems( AEApi.instance().storage().createFluidList() ); + } else + { this.list = null; + } } public void applyChanges() @@ -362,7 +394,9 @@ public class GridStorageCache implements IStorageGrid public void applyChanges() { for( CellChangeTrackerRecord rec : this.data ) + { rec.applyChanges(); + } } } } diff --git a/src/main/java/appeng/me/cache/NetworkMonitor.java b/src/main/java/appeng/me/cache/NetworkMonitor.java index 9815d27c..ec8444be 100644 --- a/src/main/java/appeng/me/cache/NetworkMonitor.java +++ b/src/main/java/appeng/me/cache/NetworkMonitor.java @@ -62,9 +62,13 @@ public class NetworkMonitor> extends MEMonitorHandler IMEMonitorHandlerReceiver receiver = o.getKey(); if( receiver.isValid( o.getValue() ) ) + { receiver.onListUpdate(); + } else + { i.remove(); + } } } @@ -100,7 +104,9 @@ public class NetworkMonitor> extends MEMonitorHandler protected void postChange( boolean Add, Iterable changes, BaseActionSource src ) { if( DEPTH.contains( this ) ) + { return; + } DEPTH.push( this ); @@ -114,7 +120,9 @@ public class NetworkMonitor> extends MEMonitorHandler T difference = changedItem; if( !Add && changedItem != null ) + { ( difference = changedItem.copy() ).setStackSize( -changedItem.getStackSize() ); + } if( this.myGridCache.interestManager.containsKey( changedItem ) ) { @@ -131,7 +139,9 @@ public class NetworkMonitor> extends MEMonitorHandler this.myGridCache.interestManager.enableTransactions(); for( ItemWatcher iw : list ) + { iw.getHost().onStackChange( myStorageList, fullStack, difference, src, this.getChannel() ); + } this.myGridCache.interestManager.disableTransactions(); } @@ -140,6 +150,8 @@ public class NetworkMonitor> extends MEMonitorHandler final NetworkMonitor last = DEPTH.pop(); if( last != this ) + { throw new IllegalStateException( "Invalid Access to Networked Storage API detected." ); + } } } diff --git a/src/main/java/appeng/me/cache/P2PCache.java b/src/main/java/appeng/me/cache/P2PCache.java index 6428a294..5f330592 100644 --- a/src/main/java/appeng/me/cache/P2PCache.java +++ b/src/main/java/appeng/me/cache/P2PCache.java @@ -59,7 +59,9 @@ public class P2PCache implements IGridCache for( PartP2PTunnel me : this.inputs.values() ) { if( me instanceof PartP2PTunnelME ) + { tm.wakeDevice( me.getGridNode() ); + } } } @@ -70,7 +72,9 @@ public class P2PCache implements IGridCache for( PartP2PTunnel me : this.inputs.values() ) { if( me instanceof PartP2PTunnelME ) + { tm.wakeDevice( me.getGridNode() ); + } } } @@ -88,7 +92,9 @@ public class P2PCache implements IGridCache if( machine instanceof PartP2PTunnelME ) { if( !node.hasFlag( GridFlags.REQUIRE_CHANNEL ) ) + { return; + } } PartP2PTunnel t = (PartP2PTunnel) machine; @@ -96,9 +102,13 @@ public class P2PCache implements IGridCache // ); if( t.output ) + { this.outputs.remove( t.freq, t ); + } else + { this.inputs.remove( t.freq ); + } this.updateTunnel( t.freq, !t.output, false ); } @@ -112,7 +122,9 @@ public class P2PCache implements IGridCache if( machine instanceof PartP2PTunnelME ) { if( !node.hasFlag( GridFlags.REQUIRE_CHANNEL ) ) + { return; + } } PartP2PTunnel t = (PartP2PTunnel) machine; @@ -120,9 +132,13 @@ public class P2PCache implements IGridCache // ); if( t.output ) + { this.outputs.put( t.freq, t ); + } else + { this.inputs.put( t.freq, t ); + } this.updateTunnel( t.freq, !t.output, false ); } @@ -151,7 +167,9 @@ public class P2PCache implements IGridCache for( PartP2PTunnel p : this.outputs.get( freq ) ) { if( configChange ) + { p.onTunnelConfigChange(); + } p.onTunnelNetworkChange(); } @@ -159,7 +177,9 @@ public class P2PCache implements IGridCache if( in != null ) { if( configChange ) + { in.onTunnelConfigChange(); + } in.onTunnelNetworkChange(); } } @@ -167,17 +187,25 @@ public class P2PCache implements IGridCache public void updateFreq( PartP2PTunnel t, long NewFreq ) { if( this.outputs.containsValue( t ) ) + { this.outputs.remove( t.freq, t ); + } if( this.inputs.containsValue( t ) ) + { this.inputs.remove( t.freq ); + } t.freq = NewFreq; if( t.output ) + { this.outputs.put( t.freq, t ); + } else + { this.inputs.put( t.freq, t ); + } // AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq // ); @@ -189,11 +217,15 @@ public class P2PCache implements IGridCache { PartP2PTunnel in = this.inputs.get( freq ); if( in == null ) + { return this.NullColl; + } TunnelCollection out = this.inputs.get( freq ).getCollection( this.outputs.get( freq ), c ); if( out == null ) + { return this.NullColl; + } return out; } diff --git a/src/main/java/appeng/me/cache/PathGridCache.java b/src/main/java/appeng/me/cache/PathGridCache.java index 22b86a2a..fea22d7a 100644 --- a/src/main/java/appeng/me/cache/PathGridCache.java +++ b/src/main/java/appeng/me/cache/PathGridCache.java @@ -93,7 +93,9 @@ public class PathGridCache implements IPathingGrid if( this.updateNetwork ) { if( !this.booting ) + { this.myGrid.postEvent( new MENetworkBootingStatusChange() ); + } this.booting = true; this.updateNetwork = false; @@ -116,7 +118,9 @@ public class PathGridCache implements IPathingGrid int requiredChannels = this.calculateRequiredChannels(); int used = requiredChannels; if( requiredChannels > 8 ) + { used = 0; + } int nodes = this.myGrid.getNodes().size(); this.channelsInUse = used; @@ -209,10 +213,14 @@ public class PathGridCache implements IPathingGrid EnumSet flags = gridNode.getGridBlock().getFlags(); if( flags.contains( GridFlags.REQUIRE_CHANNEL ) ) + { this.requireChannels.remove( gridNode ); + } if( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) ) + { this.blockDense.remove( gridNode ); + } this.repath(); } @@ -229,10 +237,14 @@ public class PathGridCache implements IPathingGrid EnumSet flags = gridNode.getGridBlock().getFlags(); if( flags.contains( GridFlags.REQUIRE_CHANNEL ) ) + { this.requireChannels.add( gridNode ); + } if( flags.contains( GridFlags.CANNOT_CARRY_COMPRESSED ) ) + { this.blockDense.add( gridNode ); + } this.repath(); } @@ -279,9 +291,13 @@ public class PathGridCache implements IPathingGrid startingNode.beginVisit( cv ); if( cv.isValid && cv.found == this.controllers.size() ) + { this.controllerState = ControllerState.CONTROLLER_ONLINE; + } else + { this.controllerState = ControllerState.CONTROLLER_CONFLICT; + } } if( old != this.controllerState ) @@ -303,7 +319,9 @@ public class PathGridCache implements IPathingGrid EnumSet flags = gb.getFlags(); if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) && !this.blockDense.isEmpty() ) + { return 9; + } depth++; @@ -312,7 +330,9 @@ public class PathGridCache implements IPathingGrid IGridMultiblock gmb = (IGridMultiblock) gb; Iterator i = gmb.getMultiblockNodes(); while( i.hasNext() ) + { this.semiOpen.add( (IPathItem) i.next() ); + } } } } @@ -330,7 +350,9 @@ public class PathGridCache implements IPathingGrid { Set players = new HashSet(); for( IGridNode n : this.requireChannels ) + { players.add( n.getPlayerID() ); + } for( int id : players ) { @@ -344,13 +366,19 @@ public class PathGridCache implements IPathingGrid private Achievements getAchievementBracket( int ch ) { if( ch < 8 ) + { return null; + } if( ch < 128 ) + { return Achievements.Networking1; + } if( ch < 2048 ) + { return Achievements.Networking2; + } return Achievements.Networking3; } @@ -361,9 +389,13 @@ public class PathGridCache implements IPathingGrid IGridNode gridNode = ev.node; if( gridNode.getGridBlock().getFlags().contains( GridFlags.REQUIRE_CHANNEL ) ) + { this.requireChannels.add( gridNode ); + } else + { this.requireChannels.remove( gridNode ); + } this.repath(); } diff --git a/src/main/java/appeng/me/cache/SecurityCache.java b/src/main/java/appeng/me/cache/SecurityCache.java index 30c647f6..a42bcfea 100644 --- a/src/main/java/appeng/me/cache/SecurityCache.java +++ b/src/main/java/appeng/me/cache/SecurityCache.java @@ -57,7 +57,9 @@ public class SecurityCache implements ISecurityGrid { this.playerPerms.clear(); if( this.securityProvider.isEmpty() ) + { return; + } this.securityProvider.get( 0 ).readPermissions( this.playerPerms ); } @@ -88,15 +90,21 @@ public class SecurityCache implements ISecurityGrid long lastCode = this.securityKey; if( this.securityProvider.size() == 1 ) + { this.securityKey = this.securityProvider.get( 0 ).getSecurityKey(); + } else + { this.securityKey = -1; + } if( lastCode != this.securityKey ) { this.myGrid.postEvent( new MENetworkSecurityChange() ); for( IGridNode n : this.myGrid.getNodes() ) + { ( (GridNode) n ).lastSecurityKey = this.securityKey; + } } } @@ -109,7 +117,9 @@ public class SecurityCache implements ISecurityGrid this.updateSecurityKey(); } else + { ( (GridNode) gridNode ).lastSecurityKey = this.securityKey; + } } @Override @@ -152,9 +162,13 @@ public class SecurityCache implements ISecurityGrid if( perms == null ) { if( playerID == -1 ) // no default? + { return false; + } else + { return this.hasPermission( -1, perm ); + } } return perms.contains( perm ); @@ -166,7 +180,9 @@ public class SecurityCache implements ISecurityGrid public int getOwner() { if( this.isAvailable() ) + { return this.securityProvider.get( 0 ).getOwner(); + } return -1; } } diff --git a/src/main/java/appeng/me/cache/SpatialPylonCache.java b/src/main/java/appeng/me/cache/SpatialPylonCache.java index 40894b31..d801c88b 100644 --- a/src/main/java/appeng/me/cache/SpatialPylonCache.java +++ b/src/main/java/appeng/me/cache/SpatialPylonCache.java @@ -87,7 +87,9 @@ public class SpatialPylonCache implements ISpatialCache { SpatialPylonCluster c = ( (TileSpatialPylon) gm.getMachine() ).getCluster(); if( c != null ) + { this.clusters.put( c, c ); + } } } @@ -99,9 +101,13 @@ public class SpatialPylonCache implements ISpatialCache for( SpatialPylonCluster cl : this.clusters.values() ) { if( this.captureMax == null ) + { this.captureMax = cl.max.copy(); + } if( this.captureMin == null ) + { this.captureMin = cl.min.copy(); + } pylonBlocks += cl.tileCount(); @@ -151,9 +157,13 @@ public class SpatialPylonCache implements ISpatialCache this.efficiency = (double) pylonBlocks / (double) requirePylonBlocks; if( this.efficiency > 1.0 ) + { this.efficiency = 1.0; + } if( this.efficiency < 0.0 ) + { this.efficiency = 0.0; + } minPower = (double) reqX * (double) reqY * reqZ * AEConfig.instance.spatialPowerMultiplier; maxPower = Math.pow( minPower, AEConfig.instance.spatialPowerExponent ); @@ -167,7 +177,9 @@ public class SpatialPylonCache implements ISpatialCache boolean myWasValid = cl.isValid; cl.isValid = this.isValid; if( myWasValid != this.isValid ) + { cl.updateStatus( false ); + } } } diff --git a/src/main/java/appeng/me/cache/TickManagerCache.java b/src/main/java/appeng/me/cache/TickManagerCache.java index c4c017aa..2f7c7e7b 100644 --- a/src/main/java/appeng/me/cache/TickManagerCache.java +++ b/src/main/java/appeng/me/cache/TickManagerCache.java @@ -62,10 +62,14 @@ public class TickManagerCache implements ITickManager TickTracker tt = this.awake.get( node ); if( tt == null ) + { tt = this.sleeping.get( node ); + } if( tt == null ) + { return -1; + } return tt.getAvgNanos(); } @@ -111,10 +115,14 @@ public class TickManagerCache implements ITickManager } if( this.awake.containsKey( tt.node ) ) + { this.addToQueue( tt ); + } } else + { return; // done! + } } } catch( Throwable t ) @@ -154,10 +162,14 @@ public class TickManagerCache implements ITickManager TickTracker tt = new TickTracker( tr, gridNode, (IGridTickable) machine, this.currentTick, this ); if( tr.canBeAlerted ) + { this.alertable.put( gridNode, tt ); + } if( tr.isSleeping ) + { this.sleeping.put( gridNode, tt ); + } else { this.awake.put( gridNode, tt ); @@ -190,7 +202,9 @@ public class TickManagerCache implements ITickManager { TickTracker tt = this.alertable.get( node ); if( tt == null ) + { return false; + } // throw new RuntimeException( // "Invalid alerted device, this node is not marked as alertable, or part of this grid." ); diff --git a/src/main/java/appeng/me/cache/helpers/TickTracker.java b/src/main/java/appeng/me/cache/helpers/TickTracker.java index 392a8f94..a887202b 100644 --- a/src/main/java/appeng/me/cache/helpers/TickTracker.java +++ b/src/main/java/appeng/me/cache/helpers/TickTracker.java @@ -62,10 +62,14 @@ public class TickTracker implements Comparable this.current_rate = rate; if( this.current_rate < this.request.minTickRate ) + { this.current_rate = this.request.minTickRate; + } if( this.current_rate > this.request.maxTickRate ) + { this.current_rate = this.request.maxTickRate; + } } @Override @@ -93,6 +97,8 @@ public class TickTracker implements Comparable DimensionalCoord dc = this.node.getGridBlock().getLocation(); if( dc != null ) + { crashreportcategory.addCrashSection( "Location", dc ); + } } } diff --git a/src/main/java/appeng/me/cache/helpers/TunnelCollection.java b/src/main/java/appeng/me/cache/helpers/TunnelCollection.java index 09679a1c..f6f2f850 100644 --- a/src/main/java/appeng/me/cache/helpers/TunnelCollection.java +++ b/src/main/java/appeng/me/cache/helpers/TunnelCollection.java @@ -52,7 +52,9 @@ public class TunnelCollection implements Iterable public Iterator iterator() { if( this.tunnelSources == null ) + { return new NullIterator(); + } return new TunnelIterator( this.tunnelSources, this.clz ); } diff --git a/src/main/java/appeng/me/cache/helpers/TunnelIterator.java b/src/main/java/appeng/me/cache/helpers/TunnelIterator.java index 620cdf98..89436df1 100644 --- a/src/main/java/appeng/me/cache/helpers/TunnelIterator.java +++ b/src/main/java/appeng/me/cache/helpers/TunnelIterator.java @@ -45,7 +45,9 @@ public class TunnelIterator implements Iterator { this.Next = this.wrapped.next(); if( !this.targetType.isInstance( this.Next ) ) + { this.Next = null; + } } } diff --git a/src/main/java/appeng/me/cluster/MBCalculator.java b/src/main/java/appeng/me/cluster/MBCalculator.java index 8f3f9d87..775b5c6f 100644 --- a/src/main/java/appeng/me/cluster/MBCalculator.java +++ b/src/main/java/appeng/me/cluster/MBCalculator.java @@ -41,7 +41,9 @@ public abstract class MBCalculator public void calculateMultiblock( World world, WorldCoord loc ) { if( Platform.isClient() ) + { return; + } try { @@ -50,17 +52,29 @@ public abstract class MBCalculator // find size of MB structure... while( this.isValidTileAt( world, min.x - 1, min.y, min.z ) ) + { min.x--; + } while( this.isValidTileAt( world, min.x, min.y - 1, min.z ) ) + { min.y--; + } while( this.isValidTileAt( world, min.x, min.y, min.z - 1 ) ) + { min.z--; + } while( this.isValidTileAt( world, max.x + 1, max.y, max.z ) ) + { max.x++; + } while( this.isValidTileAt( world, max.x, max.y + 1, max.z ) ) + { max.y++; + } while( this.isValidTileAt( world, max.x, max.y, max.z + 1 ) ) + { max.z++; + } if( this.checkMultiblockScale( min, max ) ) { @@ -91,7 +105,9 @@ public abstract class MBCalculator updateGrid = true; } else + { c = cluster; + } c.updateStatus( updateGrid ); return; @@ -124,8 +140,12 @@ public abstract class MBCalculator public boolean verifyUnownedRegion( World w, WorldCoord min, WorldCoord max ) { for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) + { if( this.verifyUnownedRegionInner( w, min.x, min.y, min.z, max.x, max.y, max.z, side ) ) + { return false; + } + } return true; } @@ -207,7 +227,9 @@ public abstract class MBCalculator { TileEntity te = w.getTileEntity( x, y, z ); if( this.isValidTile( te ) ) + { return true; + } } } } diff --git a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java index cda32860..d2d32204 100644 --- a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java +++ b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCalculator.java @@ -51,13 +51,19 @@ public class CraftingCPUCalculator extends MBCalculator public boolean checkMultiblockScale( WorldCoord min, WorldCoord max ) { if( max.x - min.x > 16 ) + { return false; + } if( max.y - min.y > 16 ) + { return false; + } if( max.z - min.z > 16 ) + { return false; + } return true; } @@ -82,10 +88,14 @@ public class CraftingCPUCalculator extends MBCalculator IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z ); if( !te.isValid() ) + { return false; + } if( !storage && te instanceof TileCraftingTile ) + { storage = ( (TileCraftingTile) te ).getStorageBytes() > 0; + } } } } diff --git a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java index 6e8e9806..1461f416 100644 --- a/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/CraftingCPUCluster.java @@ -142,14 +142,18 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public void updateStatus( boolean updateGrid ) { for( TileCraftingTile r : this.tiles ) + { r.updateMeta( true ); + } } @Override public void destroy() { if( this.isDestroyed ) + { return; + } this.isDestroyed = true; boolean posted = false; @@ -180,7 +184,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public void addTile( TileCraftingTile te ) { if( this.machineSrc == null || te.isCoreBlock ) + { this.machineSrc = new MachineSource( te ); + } te.isCoreBlock = false; te.markDirty(); @@ -192,9 +198,13 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.storage.add( te ); } else if( te.isStatus() ) + { this.status.add( (TileCraftingMonitorTile) te ); + } else if( te.isAccelerator() ) + { this.accelerator++; + } } public boolean canAccept( IAEStack input ) @@ -203,7 +213,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { IAEItemStack is = this.waitingFor.findPrecise( (IAEItemStack) input ); if( is != null && is.getStackSize() > 0 ) + { return true; + } } return false; } @@ -222,7 +234,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU if( this.finalOutput.equals( what ) ) { if( this.myLastLink != null ) + { return ( (CraftingLink) this.myLastLink ).injectItems( what.copy(), type ); + } return what; // ignore it. } @@ -270,12 +284,16 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { this.finalOutput.decStackSize( input.getStackSize() ); if( this.finalOutput.getStackSize() <= 0 ) + { this.completeJob(); + } this.updateCPU(); if( this.myLastLink != null ) + { return ( (CraftingLink) this.myLastLink ).injectItems( (IAEItemStack) input, type ); + } return input; // ignore it. } @@ -294,7 +312,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { this.finalOutput.decStackSize( insert.getStackSize() ); if( this.finalOutput.getStackSize() <= 0 ) + { this.completeJob(); + } this.updateCPU(); @@ -305,7 +325,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU } if( this.myLastLink != null ) + { return ( (CraftingLink) this.myLastLink ).injectItems( (IAEItemStack) input, type ); + } return input; // ignore it. } @@ -328,16 +350,22 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU // protect integrity if( i.hasNext() ) + { single = ImmutableList.of( diff.copy() ); + } while( i.hasNext() ) { Entry, Object> o = i.next(); IMEMonitorHandlerReceiver receiver = o.getKey(); if( receiver.isValid( o.getValue() ) ) + { receiver.postChange( null, single, src ); + } else + { i.remove(); + } } } @@ -349,7 +377,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public void postCraftingStatusChange( IAEItemStack diff ) { if( this.getGrid() == null ) + { return; + } CraftingGridCache sg = this.getGrid().getCache( ICraftingGrid.class ); @@ -361,7 +391,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { for( CraftingWatcher iw : list ) + { iw.getHost().onRequestChange( sg, diff ); + } } } } @@ -369,7 +401,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU private void completeJob() { if( this.myLastLink != null ) + { ( (CraftingLink) this.myLastLink ).markDone(); + } AELog.crafting( "marking job as complete" ); this.isComplete = true; @@ -380,10 +414,14 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU IAEItemStack send = this.finalOutput; if( this.finalOutput != null && this.finalOutput.getStackSize() <= 0 ) + { send = null; + } for( TileCraftingMonitorTile t : this.status ) + { t.setJob( send ); + } } protected Iterator, Object>> getListeners() @@ -405,7 +443,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { IGrid g = gn.getGrid(); if( g != null ) + { return r.getActionableNode().getGrid(); + } } } @@ -441,7 +481,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU } if( !found ) + { return false; + } } else { @@ -449,7 +491,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU ItemStack is = ais == null ? null : ais.getItemStack(); if( is == null || is.stackSize < g.getStackSize() ) + { return false; + } } } @@ -459,12 +503,16 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public void cancel() { if( this.myLastLink != null ) + { this.myLastLink.cancel(); + } IItemList list; this.getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL ); for( IAEItemStack is : list ) + { this.postChange( is, this.machineSrc ); + } this.isComplete = true; this.myLastLink = null; @@ -475,7 +523,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.waitingFor.resetStatus(); for( IAEItemStack is : items ) + { this.postCraftingStatusChange( is ); + } this.finalOutput = null; this.updateCPU(); @@ -486,7 +536,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public void updateCraftingLogic( IGrid grid, IEnergyGrid eg, CraftingGridCache cc ) { if( !this.getCore().isActive() ) + { return; + } if( this.myLastLink != null ) { @@ -500,7 +552,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU if( this.isComplete ) { if( this.inventory.getItemList().isEmpty() ) + { return; + } this.storeItems(); return; @@ -508,7 +562,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.waiting = false; if( this.waiting || this.tasks.isEmpty() ) // nothing to do here... + { return; + } this.remainingOperations = this.accelerator + 1 - ( this.usedOps[0] + this.usedOps[1] + this.usedOps[2] ); int started = this.remainingOperations; @@ -527,7 +583,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.usedOps[0] = started - this.remainingOperations; if( this.remainingOperations > 0 && !this.somethingChanged ) + { this.waiting = true; + } } private void executeCrafting( IEnergyGrid eg, CraftingGridCache cc ) @@ -550,7 +608,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU for( ICraftingMedium m : cc.getMediums( e.getKey() ) ) { if( e.getValue().value <= 0 ) + { continue; + } if( !m.isBusy() ) { @@ -569,7 +629,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU // power... if( eg.extractAEPower( sum, Actionable.MODULATE, PowerMultiplier.CONFIG ) < sum - 0.01 ) + { continue; + } ic = new InventoryCrafting( new ContainerNull(), 3, 3 ); boolean found = false; @@ -620,7 +682,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU } if( !found ) + { break; + } } } @@ -631,7 +695,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { ItemStack is = ic.getStackInSlot( x ); if( is != null ) + { this.inventory.injectItems( AEItemStack.create( is ), Actionable.MODULATE, this.machineSrc ); + } } ic = null; break; @@ -672,10 +738,14 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU e.getValue().value--; if( e.getValue().value <= 0 ) + { continue; + } if( this.remainingOperations == 0 ) + { return; + } } } } @@ -700,7 +770,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { IGrid g = this.getGrid(); if( g == null ) + { return; + } IStorageGrid sg = g.getCache( IStorageGrid.class ); IMEInventory ii = sg.getItemInventory(); @@ -716,11 +788,15 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU } if( is != null ) + { this.inventory.injectItems( is, Actionable.MODULATE, this.machineSrc ); + } } if( this.inventory.getItemList().isEmpty() ) + { this.inventory = new MECraftingInventory(); + } this.markDirty(); } @@ -728,13 +804,19 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU public ICraftingLink submitJob( IGrid g, ICraftingJob job, BaseActionSource src, ICraftingRequester requestingMachine ) { if( !this.tasks.isEmpty() || !this.waitingFor.isEmpty() ) + { return null; + } if( !( job instanceof CraftingJob ) ) + { return null; + } if( this.isBusy() || !this.isActive() || this.availableStorage < job.getByteTotal() ) + { return null; + } IStorageGrid sg = g.getCache( IStorageGrid.class ); IMEInventory storage = sg.getItemInventory(); @@ -757,7 +839,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.myLastLink = new CraftingLink( this.generateLinkData( craftID, requestingMachine == null, false ), this ); if( requestingMachine == null ) + { return this.myLastLink; + } ICraftingLink whatLink = new CraftingLink( this.generateLinkData( craftID, false, true ), requestingMachine ); @@ -768,7 +852,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.getListOfItem( list = AEApi.instance().storage().createItemList(), CraftingItemList.ALL ); for( IAEItemStack ge : list ) + { this.postChange( ge, this.machineSrc ); + } return whatLink; } @@ -795,7 +881,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU while( i.hasNext() ) { if( i.next().getValue().value <= 0 ) + { i.remove(); + } } return !this.tasks.isEmpty() || !this.waitingFor.isEmpty(); @@ -829,11 +917,15 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { TileCraftingTile core = this.getCore(); if( core == null ) + { return false; + } IGridNode node = core.getActionableNode(); if( node == null ) + { return false; + } return node.isActive(); } @@ -875,7 +967,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { case ACTIVE: for( IAEItemStack ais : this.waitingFor ) + { list.add( ais ); + } break; case PENDING: for( Entry t : this.tasks.entrySet() ) @@ -896,7 +990,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.inventory.getAvailableItems( list ); for( IAEItemStack ais : this.waitingFor ) + { list.add( ais ); + } for( Entry t : this.tasks.entrySet() ) { @@ -927,7 +1023,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU TaskProgress i = this.tasks.get( details ); if( i == null ) + { this.tasks.put( details, i = new TaskProgress() ); + } i.value += crafts; } @@ -953,7 +1051,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU for( IAEItemStack ais : t.getKey().getCondensedOutputs() ) { if( ais.equals( is ) ) + { is.setStackSize( is.getStackSize() + ais.getStackSize() * t.getValue().value ); + } } } @@ -964,7 +1064,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU } if( is != null ) + { return is.copy(); + } is = what.copy(); is.setStackSize( 0 ); @@ -1002,7 +1104,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU NBTTagCompound out = new NBTTagCompound(); if( finalOutput2 != null ) + { finalOutput2.writeToNBT( out ); + } return out; } @@ -1012,7 +1116,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU NBTTagList out = new NBTTagList(); for( IAEItemStack ais : myList ) + { out.appendTag( this.writeItem( ais ) ); + } return out; } @@ -1037,7 +1143,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { this.finalOutput = AEItemStack.loadItemStackFromNBT( (NBTTagCompound) data.getTag( "finalOutput" ) ); for( IAEItemStack ais : this.readList( (NBTTagList) data.getTag( "inventory" ) ) ) + { this.inventory.injectItems( ais, Actionable.MODULATE, this.machineSrc ); + } this.waiting = data.getBoolean( "waiting" ); this.isComplete = data.getBoolean( "isComplete" ); @@ -1069,7 +1177,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU this.waitingFor = this.readList( (NBTTagList) data.getTag( "waitingFor" ) ); for( IAEItemStack is : this.waitingFor ) + { this.postCraftingStatusChange( is.copy() ); + } } public void updateName() @@ -1081,9 +1191,13 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU if( te.hasCustomName() ) { if( this.myName.length() > 0 ) + { this.myName += ' ' + te.getCustomName(); + } else + { this.myName = te.getCustomName(); + } } } } @@ -1092,13 +1206,17 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { IItemList out = AEApi.instance().storage().createItemList(); if( tag == null ) + { return out; + } for( int x = 0; x < tag.tagCount(); x++ ) { IAEItemStack ais = AEItemStack.loadItemStackFromNBT( tag.getCompoundTagAt( x ) ); if( ais != null ) + { out.add( ais ); + } } return out; @@ -1119,7 +1237,9 @@ public class CraftingCPUCluster implements IAECluster, ICraftingCPU { TileCraftingTile t = this.getCore(); if( t != null ) + { t.breakCluster(); + } } static class TaskProgress diff --git a/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java b/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java index d40a3626..cae6c888 100644 --- a/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java +++ b/src/main/java/appeng/me/cluster/implementations/QuantumCalculator.java @@ -81,7 +81,9 @@ public class QuantumCalculator extends MBCalculator IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z ); if( !te.isValid() ) + { return false; + } num++; final IBlocks blocks = AEApi.instance().definitions().blocks(); @@ -137,9 +139,13 @@ public class QuantumCalculator extends MBCalculator else { if( num == 1 || num == 3 || num == 7 || num == 9 ) + { flags = (byte) ( this.tqb.corner | num ); + } else + { flags = num; + } c.Ring[ringNum] = te; ringNum++; } diff --git a/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java b/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java index 4a663af3..3063129d 100644 --- a/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/QuantumCluster.java @@ -88,7 +88,9 @@ public class QuantumCluster implements ILocatable, IAECluster if( qe != 0 ) { if( this.thisSide != 0 ) + { MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) ); + } if( this.canUseNode( -qe ) ) { @@ -130,7 +132,9 @@ public class QuantumCluster implements ILocatable, IAECluster IGridNode sa = sideA.getNode(); IGridNode sb = sideB.getNode(); if( ( a == sa || b == sa ) && ( a == sb || b == sb ) ) + { return; + } } try @@ -161,10 +165,14 @@ public class QuantumCluster implements ILocatable, IAECluster } } else + { shutdown = true; + } } else + { shutdown = true; + } if( shutdown && this.connection != null ) { @@ -202,7 +210,9 @@ public class QuantumCluster implements ILocatable, IAECluster private boolean isActive() { if( this.isDestroyed || !this.registered ) + { return false; + } return this.center.isPowered() && this.hasQES(); } @@ -221,7 +231,9 @@ public class QuantumCluster implements ILocatable, IAECluster public void destroy() { if( this.isDestroyed ) + { return; + } this.isDestroyed = true; if( this.registered ) diff --git a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java index 9331de65..5941699e 100644 --- a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java +++ b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCalculator.java @@ -66,7 +66,9 @@ public class SpatialPylonCalculator extends MBCalculator IAEMultiBlock te = (IAEMultiBlock) w.getTileEntity( x, y, z ); if( !te.isValid() ) + { return false; + } } } } diff --git a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java index f4d40c3e..792db69b 100644 --- a/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java +++ b/src/main/java/appeng/me/cluster/implementations/SpatialPylonCluster.java @@ -48,13 +48,21 @@ public class SpatialPylonCluster implements IAECluster this.max = _max.copy(); if( this.min.x != this.max.x ) + { this.currentAxis = Axis.X; + } else if( this.min.y != this.max.y ) + { this.currentAxis = Axis.Y; + } else if( this.min.z != this.max.z ) + { this.currentAxis = Axis.Z; + } else + { this.currentAxis = Axis.UNFORMED; + } } @Override @@ -71,7 +79,9 @@ public class SpatialPylonCluster implements IAECluster { if( this.isDestroyed ) + { return; + } this.isDestroyed = true; for( TileSpatialPylon r : this.line ) diff --git a/src/main/java/appeng/me/energy/EnergyThreshold.java b/src/main/java/appeng/me/energy/EnergyThreshold.java index 5f89ac59..25d1937c 100644 --- a/src/main/java/appeng/me/energy/EnergyThreshold.java +++ b/src/main/java/appeng/me/energy/EnergyThreshold.java @@ -36,9 +36,13 @@ public class EnergyThreshold implements Comparable this.watcher = wat; if( this.watcher != null ) + { this.hash = this.watcher.hashCode() ^ ( (Double) lim ).hashCode(); + } else + { this.hash = ( (Double) lim ).hashCode(); + } } @Override diff --git a/src/main/java/appeng/me/energy/EnergyWatcher.java b/src/main/java/appeng/me/energy/EnergyWatcher.java index c4ddc9aa..63167bf2 100644 --- a/src/main/java/appeng/me/energy/EnergyWatcher.java +++ b/src/main/java/appeng/me/energy/EnergyWatcher.java @@ -94,7 +94,9 @@ public class EnergyWatcher implements IEnergyWatcher public boolean add( Double e ) { if( this.myInterests.contains( e ) ) + { return false; + } EnergyThreshold eh = new EnergyThreshold( e, this ); return this.gsc.interests.add( eh ) && this.myInterests.add( eh ); @@ -119,7 +121,9 @@ public class EnergyWatcher implements IEnergyWatcher boolean didChange = false; for( Double o : c ) + { didChange = this.add( o ) || didChange; + } return didChange; } @@ -129,7 +133,9 @@ public class EnergyWatcher implements IEnergyWatcher { boolean didSomething = false; for( Object o : c ) + { didSomething = this.remove( o ) || didSomething; + } return didSomething; } diff --git a/src/main/java/appeng/me/helpers/AENetworkProxy.java b/src/main/java/appeng/me/helpers/AENetworkProxy.java index 7fd35024..59f86f25 100644 --- a/src/main/java/appeng/me/helpers/AENetworkProxy.java +++ b/src/main/java/appeng/me/helpers/AENetworkProxy.java @@ -86,20 +86,26 @@ public class AENetworkProxy implements IGridBlock public void writeToNBT( NBTTagCompound tag ) { if( this.node != null ) + { this.node.saveToNBT( this.nbtName, tag ); + } } public void setValidSides( EnumSet validSides ) { this.validSides = validSides; if( this.node != null ) + { this.node.updateState(); + } } public void validate() { if( this.gp instanceof AEBaseTile ) + { TickHandler.INSTANCE.addInit( (AEBaseTile) this.gp ); + } } public void onChunkUnload() @@ -127,7 +133,9 @@ public class AENetworkProxy implements IGridBlock { IOrientable ori = (IOrientable) this.gp; if( ori.canBeRotated() ) + { ori.setOrientation( ori.getForward(), ori.getUp() ); + } } this.getNode(); @@ -164,10 +172,14 @@ public class AENetworkProxy implements IGridBlock { IGrid grid = this.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } IPathingGrid pg = grid.getCache( IPathingGrid.class ); if( pg == null ) + { throw new GridAccessException(); + } return pg; } @@ -181,10 +193,14 @@ public class AENetworkProxy implements IGridBlock public IGrid getGrid() throws GridAccessException { if( this.node == null ) + { throw new GridAccessException(); + } IGrid grid = this.node.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } return grid; } @@ -192,10 +208,14 @@ public class AENetworkProxy implements IGridBlock { IGrid grid = this.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } ITickManager pg = grid.getCache( ITickManager.class ); if( pg == null ) + { throw new GridAccessException(); + } return pg; } @@ -203,12 +223,16 @@ public class AENetworkProxy implements IGridBlock { IGrid grid = this.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } IStorageGrid pg = grid.getCache( IStorageGrid.class ); if( pg == null ) + { throw new GridAccessException(); + } return pg; } @@ -217,12 +241,16 @@ public class AENetworkProxy implements IGridBlock { IGrid grid = this.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } P2PCache pg = grid.getCache( P2PCache.class ); if( pg == null ) + { throw new GridAccessException(); + } return pg; } @@ -231,12 +259,16 @@ public class AENetworkProxy implements IGridBlock { IGrid grid = this.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } ISecurityGrid sg = grid.getCache( ISecurityGrid.class ); if( sg == null ) + { throw new GridAccessException(); + } return sg; } @@ -245,12 +277,16 @@ public class AENetworkProxy implements IGridBlock { IGrid grid = this.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } ICraftingGrid sg = grid.getCache( ICraftingGrid.class ); if( sg == null ) + { throw new GridAccessException(); + } return sg; } @@ -289,7 +325,9 @@ public class AENetworkProxy implements IGridBlock public void onGridNotification( GridNotification notification ) { if( this.gp instanceof PartCable ) + { ( (PartCable) this.gp ).markForUpdate(); + } } @Override @@ -357,7 +395,9 @@ public class AENetworkProxy implements IGridBlock public boolean isActive() { if( this.node == null ) + { return false; + } return this.node.isActive(); } @@ -378,10 +418,14 @@ public class AENetworkProxy implements IGridBlock { IGrid grid = this.getGrid(); if( grid == null ) + { throw new GridAccessException(); + } IEnergyGrid eg = grid.getCache( IEnergyGrid.class ); if( eg == null ) + { throw new GridAccessException(); + } return eg; } diff --git a/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java b/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java index b060a34e..73a8bce9 100644 --- a/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java +++ b/src/main/java/appeng/me/helpers/AENetworkProxyMultiblock.java @@ -43,7 +43,9 @@ public class AENetworkProxyMultiblock extends AENetworkProxy implements IGridMul public Iterator getMultiblockNodes() { if( this.getCluster() == null ) + { return new ChainedIterator(); + } return new ProxyNodeIterator( this.getCluster().getTiles() ); } diff --git a/src/main/java/appeng/me/helpers/ChannelPowerSrc.java b/src/main/java/appeng/me/helpers/ChannelPowerSrc.java index 5c71414d..1b57baca 100644 --- a/src/main/java/appeng/me/helpers/ChannelPowerSrc.java +++ b/src/main/java/appeng/me/helpers/ChannelPowerSrc.java @@ -41,7 +41,9 @@ public class ChannelPowerSrc implements IEnergySource public double extractAEPower( double amt, Actionable mode, PowerMultiplier usePowerMultiplier ) { if( this.node.isActive() ) + { return this.realSrc.extractAEPower( amt, mode, usePowerMultiplier ); + } return 0.0; } } diff --git a/src/main/java/appeng/me/helpers/GenericInterestManager.java b/src/main/java/appeng/me/helpers/GenericInterestManager.java index 3ed709c9..884673f9 100644 --- a/src/main/java/appeng/me/helpers/GenericInterestManager.java +++ b/src/main/java/appeng/me/helpers/GenericInterestManager.java @@ -42,7 +42,9 @@ public class GenericInterestManager public void enableTransactions() { if( this.transDepth == 0 ) + { this.transactions = new LinkedList(); + } this.transDepth++; } @@ -59,9 +61,13 @@ public class GenericInterestManager for( SavedTransactions t : myActions ) { if( t.put ) + { this.put( t.stack, t.iw ); + } else + { this.remove( t.stack, t.iw ); + } } } } @@ -74,7 +80,9 @@ public class GenericInterestManager return true; } else + { return this.container.put( stack, iw ); + } } public boolean remove( IAEStack stack, T iw ) @@ -85,7 +93,9 @@ public class GenericInterestManager return true; } else + { return this.container.remove( stack, iw ); + } } public boolean containsKey( IAEStack stack ) diff --git a/src/main/java/appeng/me/pathfinding/ControllerValidator.java b/src/main/java/appeng/me/pathfinding/ControllerValidator.java index 45ebc426..23aa4fc4 100644 --- a/src/main/java/appeng/me/pathfinding/ControllerValidator.java +++ b/src/main/java/appeng/me/pathfinding/ControllerValidator.java @@ -71,7 +71,9 @@ public class ControllerValidator implements IGridVisitor this.isValid = false; } else + { return false; + } return this.isValid; } diff --git a/src/main/java/appeng/me/pathfinding/PathSegment.java b/src/main/java/appeng/me/pathfinding/PathSegment.java index ceb0d113..0d4249f0 100644 --- a/src/main/java/appeng/me/pathfinding/PathSegment.java +++ b/src/main/java/appeng/me/pathfinding/PathSegment.java @@ -72,9 +72,13 @@ public class PathSegment boolean worked; if( flags.contains( GridFlags.COMPRESSED_CHANNEL ) ) + { worked = this.useDenseChannel( pi ); + } else + { worked = this.useChannel( pi ); + } if( worked && flags.contains( GridFlags.MULTIBLOCK ) ) { @@ -83,7 +87,9 @@ public class PathSegment { IGridNode otherNodes = oni.next(); if( otherNodes != pi ) + { this.semiOpen.add( (IPathItem) otherNodes ); + } } } } @@ -109,7 +115,9 @@ public class PathSegment while( pi != null ) { if( !pi.canSupportMoreChannels() || pi.getFlags().contains( GridFlags.CANNOT_CARRY_COMPRESSED ) ) + { return false; + } pi = pi.getControllerRoute(); } @@ -132,7 +140,9 @@ public class PathSegment while( pi != null ) { if( !pi.canSupportMoreChannels() ) + { return false; + } pi = pi.getControllerRoute(); } diff --git a/src/main/java/appeng/me/storage/AEExternalHandler.java b/src/main/java/appeng/me/storage/AEExternalHandler.java index 1f61ee52..0ac82eae 100644 --- a/src/main/java/appeng/me/storage/AEExternalHandler.java +++ b/src/main/java/appeng/me/storage/AEExternalHandler.java @@ -40,7 +40,9 @@ public class AEExternalHandler implements IExternalStorageHandler public boolean canHandle( TileEntity te, ForgeDirection d, StorageChannel channel, BaseActionSource mySrc ) { if( channel == StorageChannel.ITEMS && te instanceof ITileStorageMonitorable ) + { return ( (ITileStorageMonitorable) te ).getMonitorable( d, mySrc ) != null; + } return te instanceof TileCondenser; } @@ -51,9 +53,13 @@ public class AEExternalHandler implements IExternalStorageHandler if( te instanceof TileCondenser ) { if( channel == StorageChannel.ITEMS ) + { return new VoidItemInventory( (TileCondenser) te ); + } else + { return new VoidFluidInventory( (TileCondenser) te ); + } } if( te instanceof ITileStorageMonitorable ) @@ -65,14 +71,18 @@ public class AEExternalHandler implements IExternalStorageHandler { IMEInventory ii = sm.getItemInventory(); if( ii != null ) + { return ii; + } } if( channel == StorageChannel.FLUIDS && sm != null ) { IMEInventory fi = sm.getFluidInventory(); if( fi != null ) + { return fi; + } } } diff --git a/src/main/java/appeng/me/storage/CellInventory.java b/src/main/java/appeng/me/storage/CellInventory.java index 14c437f9..9d4b556b 100644 --- a/src/main/java/appeng/me/storage/CellInventory.java +++ b/src/main/java/appeng/me/storage/CellInventory.java @@ -114,9 +114,13 @@ public class CellInventory implements ICellInventory } if( this.MAX_ITEM_TYPES > 63 ) + { this.MAX_ITEM_TYPES = 63; + } if( this.MAX_ITEM_TYPES < 1 ) + { this.MAX_ITEM_TYPES = 1; + } this.container = container; this.tagCompound = Platform.openNbtData( o ); @@ -184,7 +188,9 @@ public class CellInventory implements ICellInventory public static boolean isBlackListed( IAEItemStack input ) { if( BLACK_LIST.contains( ( OreDictionary.WILDCARD_VALUE << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) ) ) + { return true; + } return BLACK_LIST.contains( ( input.getItemDamage() << Platform.DEF_OFFSET ) | Item.getIdFromItem( input.getItem() ) ); } @@ -197,12 +203,18 @@ public class CellInventory implements ICellInventory public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src ) { if( input == null ) + { return null; + } if( input.getStackSize() == 0 ) + { return null; + } if( isBlackListed( input ) || this.CellType.isBlackListed( this.i, input ) ) + { return input; + } ItemStack sharedItemStack = input.getItemStack(); @@ -210,7 +222,9 @@ public class CellInventory implements ICellInventory { IMEInventory meInventory = getCell( sharedItemStack, null ); if( meInventory != null && !this.isEmpty( meInventory ) ) + { return input; + } } IAEItemStack l = this.getCellItems().findPrecise( input ); @@ -218,7 +232,9 @@ public class CellInventory implements ICellInventory { long remainingItemSlots = this.getRemainingItemCount(); if( remainingItemSlots < 0 ) + { return input; + } if( input.getStackSize() > remainingItemSlots ) { @@ -284,7 +300,9 @@ public class CellInventory implements ICellInventory public IAEItemStack extractItems( IAEItemStack request, Actionable mode, BaseActionSource src ) { if( request == null ) + { return null; + } long size = Math.min( Integer.MAX_VALUE, request.getStackSize() ); @@ -408,13 +426,17 @@ public class CellInventory implements ICellInventory } if( this.container != null ) + { this.container.saveChanges( this ); + } } protected void loadCellItems() { if( this.cellItems == null ) + { this.cellItems = AEApi.instance().storage().createItemList(); + } this.cellItems.resetStatus(); // clears totals and stuff. @@ -441,7 +463,9 @@ public class CellInventory implements ICellInventory public IItemList getAvailableItems( IItemList out ) { for( IAEItemStack i : this.getCellItems() ) + { out.add( i ); + } return out; } @@ -564,9 +588,13 @@ public class CellInventory implements ICellInventory public int getStatusForCell() { if( this.canHoldNewItem() ) + { return 1; + } if( this.getRemainingItemCount() > 0 ) + { return 2; + } return 3; } } diff --git a/src/main/java/appeng/me/storage/CellInventoryHandler.java b/src/main/java/appeng/me/storage/CellInventoryHandler.java index 85db3404..60385265 100644 --- a/src/main/java/appeng/me/storage/CellInventoryHandler.java +++ b/src/main/java/appeng/me/storage/CellInventoryHandler.java @@ -85,7 +85,9 @@ public class CellInventoryHandler extends MEInventoryHandler imple { ItemStack is = config.getStackInSlot( x ); if( is != null ) + { priorityList.add( AEItemStack.create( is ) ); + } } this.setWhitelist( hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST ); @@ -93,9 +95,13 @@ public class CellInventoryHandler extends MEInventoryHandler imple if( !priorityList.isEmpty() ) { if( hasFuzzy ) + { this.setPartitionList( new FuzzyPriorityList( priorityList, fzMode ) ); + } else + { this.setPartitionList( new PrecisePriorityList( priorityList ) ); + } } } } @@ -106,7 +112,9 @@ public class CellInventoryHandler extends MEInventoryHandler imple Object o = this.internal; if( o instanceof MEPassThrough ) + { o = ( (MEPassThrough) o ).getInternal(); + } return (ICellInventory) ( o instanceof ICellInventory ? o : null ); } @@ -139,7 +147,9 @@ public class CellInventoryHandler extends MEInventoryHandler imple int val = this.getCellInv().getStatusForCell(); if( val == 1 && this.isPreformatted() ) + { val = 2; + } return val; } diff --git a/src/main/java/appeng/me/storage/CreativeCellInventory.java b/src/main/java/appeng/me/storage/CreativeCellInventory.java index 0a879a2f..f9983d1d 100644 --- a/src/main/java/appeng/me/storage/CreativeCellInventory.java +++ b/src/main/java/appeng/me/storage/CreativeCellInventory.java @@ -42,12 +42,14 @@ public class CreativeCellInventory implements IMEInventoryHandler { CellConfig cc = new CellConfig( o ); for( ItemStack is : cc ) + { if( is != null ) { IAEItemStack i = AEItemStack.create( is ); i.setStackSize( Integer.MAX_VALUE ); this.itemListCache.add( i ); } + } } public static IMEInventoryHandler getCell( ItemStack o ) @@ -60,7 +62,9 @@ public class CreativeCellInventory implements IMEInventoryHandler { IAEItemStack local = this.itemListCache.findPrecise( input ); if( local == null ) + { return input; + } return null; } @@ -70,7 +74,9 @@ public class CreativeCellInventory implements IMEInventoryHandler { IAEItemStack local = this.itemListCache.findPrecise( request ); if( local == null ) + { return null; + } return request.copy(); } @@ -79,7 +85,9 @@ public class CreativeCellInventory implements IMEInventoryHandler public IItemList getAvailableItems( IItemList out ) { for( IAEItemStack ais : this.itemListCache ) + { out.add( ais ); + } return out; } diff --git a/src/main/java/appeng/me/storage/ItemWatcher.java b/src/main/java/appeng/me/storage/ItemWatcher.java index e3ebd7d0..d1c9a64b 100644 --- a/src/main/java/appeng/me/storage/ItemWatcher.java +++ b/src/main/java/appeng/me/storage/ItemWatcher.java @@ -90,7 +90,9 @@ public class ItemWatcher implements IStackWatcher public boolean add( IAEStack e ) { if( this.myInterests.contains( e ) ) + { return false; + } return this.myInterests.add( e.copy() ) && this.gsc.interestManager.put( e, this ); } @@ -113,7 +115,9 @@ public class ItemWatcher implements IStackWatcher boolean didChange = false; for( IAEStack o : c ) + { didChange = this.add( o ) || didChange; + } return didChange; } @@ -123,7 +127,9 @@ public class ItemWatcher implements IStackWatcher { boolean didSomething = false; for( Object o : c ) + { didSomething = this.remove( o ) || didSomething; + } return didSomething; } diff --git a/src/main/java/appeng/me/storage/MEIInventoryWrapper.java b/src/main/java/appeng/me/storage/MEIInventoryWrapper.java index e7746041..8b72549f 100644 --- a/src/main/java/appeng/me/storage/MEIInventoryWrapper.java +++ b/src/main/java/appeng/me/storage/MEIInventoryWrapper.java @@ -54,7 +54,9 @@ public class MEIInventoryWrapper implements IMEInventory { ItemStack is = mode == Actionable.SIMULATE ? this.adaptor.simulateAdd( input ) : this.adaptor.addItems( input ); if( is == null ) + { return null; + } return AEItemStack.create( is ); } @@ -109,7 +111,9 @@ public class MEIInventoryWrapper implements IMEInventory out.stackSize -= t.stackSize; if( mode == Actionable.MODULATE ) + { this.target.setInventorySlotContents( x, t ); + } if( out.stackSize <= 0 ) { @@ -172,9 +176,13 @@ public class MEIInventoryWrapper implements IMEInventory } if( sub.stackSize <= 0 ) + { this.target.setInventorySlotContents( x, null ); + } else + { this.target.setInventorySlotContents( x, sub ); + } if( retrieved != null ) { diff --git a/src/main/java/appeng/me/storage/MEInventoryHandler.java b/src/main/java/appeng/me/storage/MEInventoryHandler.java index 0eb4a21f..ded200ea 100644 --- a/src/main/java/appeng/me/storage/MEInventoryHandler.java +++ b/src/main/java/appeng/me/storage/MEInventoryHandler.java @@ -53,9 +53,13 @@ public class MEInventoryHandler> implements IMEInventoryHa this.channel = channel; if( i instanceof IMEInventoryHandler ) + { this.internal = (IMEInventoryHandler) i; + } else + { this.internal = new MEPassThrough( i, channel ); + } this.monitor = this.internal instanceof IMEMonitor ? (IMEMonitor) this.internal : null; @@ -102,7 +106,9 @@ public class MEInventoryHandler> implements IMEInventoryHa public T injectItems( T input, Actionable type, BaseActionSource src ) { if( !this.canAccept( input ) ) + { return input; + } return this.internal.injectItems( input, type, src ); } @@ -111,7 +117,9 @@ public class MEInventoryHandler> implements IMEInventoryHa public T extractItems( T request, Actionable type, BaseActionSource src ) { if( !this.hasReadAccess ) + { return null; + } return this.internal.extractItems( request, type, src ); } @@ -120,7 +128,9 @@ public class MEInventoryHandler> implements IMEInventoryHa public IItemList getAvailableItems( IItemList out ) { if( !this.hasReadAccess ) + { return out; + } return this.internal.getAvailableItems( out ); } @@ -141,7 +151,9 @@ public class MEInventoryHandler> implements IMEInventoryHa public boolean isPrioritized( T input ) { if( this.myWhitelist == IncludeExclude.WHITELIST ) + { return this.myPartitionList.isListed( input ) || this.internal.isPrioritized( input ); + } return false; } @@ -149,12 +161,18 @@ public class MEInventoryHandler> implements IMEInventoryHa public boolean canAccept( T input ) { if( !this.hasWriteAccess ) + { return false; + } if( this.myWhitelist == IncludeExclude.BLACKLIST && this.myPartitionList.isListed( input ) ) + { return false; + } if( this.myPartitionList.isEmpty() || this.myWhitelist == IncludeExclude.BLACKLIST ) + { return this.internal.canAccept( input ); + } return this.myPartitionList.isListed( input ) && this.internal.canAccept( input ); } diff --git a/src/main/java/appeng/me/storage/MEMonitorIInventory.java b/src/main/java/appeng/me/storage/MEMonitorIInventory.java index 43098b62..cd26b763 100644 --- a/src/main/java/appeng/me/storage/MEMonitorIInventory.java +++ b/src/main/java/appeng/me/storage/MEMonitorIInventory.java @@ -78,14 +78,20 @@ public class MEMonitorIInventory implements IMEMonitor ItemStack out = null; if( type == Actionable.SIMULATE ) + { out = this.adaptor.simulateAdd( input.getItemStack() ); + } else + { out = this.adaptor.addItems( input.getItemStack() ); + } this.onTick(); if( out == null ) + { return null; + } // better then doing construction from scratch :3 IAEItemStack o = input.copy(); @@ -99,12 +105,18 @@ public class MEMonitorIInventory implements IMEMonitor ItemStack out = null; if( type == Actionable.SIMULATE ) + { out = this.adaptor.simulateRemove( (int) request.getStackSize(), request.getItemStack(), null ); + } else + { out = this.adaptor.removeItems( (int) request.getStackSize(), request.getItemStack(), null ); + } if( out == null ) + { return null; + } // better then doing construction from scratch :3 IAEItemStack o = request.copy(); @@ -199,7 +211,9 @@ public class MEMonitorIInventory implements IMEMonitor } if( !changes.isEmpty() ) + { this.postDifference( changes ); + } return changed ? TickRateModulation.URGENT : TickRateModulation.SLOWER; } @@ -207,10 +221,14 @@ public class MEMonitorIInventory implements IMEMonitor private boolean isDifferent( ItemStack a, ItemStack b ) { if( a == b && b == null ) + { return false; + } if( ( a == null && b != null ) || ( a != null && b == null ) ) + { return true; + } return !Platform.isSameItemPrecise( a, b ); } @@ -226,9 +244,13 @@ public class MEMonitorIInventory implements IMEMonitor Entry, Object> l = i.next(); IMEMonitorHandlerReceiver key = l.getKey(); if( key.isValid( l.getValue() ) ) + { key.postChange( this, a, this.mySource ); + } else + { i.remove(); + } } } } @@ -273,7 +295,9 @@ public class MEMonitorIInventory implements IMEMonitor public IItemList getAvailableItems( IItemList out ) { for( CachedItemStack is : this.memory.values() ) + { out.addStorage( is.aeStack ); + } return out; } diff --git a/src/main/java/appeng/me/storage/MEMonitorPassThrough.java b/src/main/java/appeng/me/storage/MEMonitorPassThrough.java index 467f6486..dd0940b7 100644 --- a/src/main/java/appeng/me/storage/MEMonitorPassThrough.java +++ b/src/main/java/appeng/me/storage/MEMonitorPassThrough.java @@ -46,26 +46,34 @@ public class MEMonitorPassThrough> extends MEPassThrough) i; + } } @Override public void setInternal( IMEInventory i ) { if( this.monitor != null ) + { this.monitor.removeListener( this ); + } this.monitor = null; IItemList before = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) ); super.setInternal( i ); if( i instanceof IMEMonitor ) + { this.monitor = (IMEMonitor) i; + } IItemList after = this.getInternal() == null ? this.channel.createList() : this.getInternal().getAvailableItems( new ItemListIgnoreCrafting( this.channel.createList() ) ); if( this.monitor != null ) + { this.monitor.addListener( this, this.monitor ); + } Platform.postListChanges( before, after, this, this.changeSource ); } @@ -116,9 +124,13 @@ public class MEMonitorPassThrough> extends MEPassThrough, Object> e = i.next(); IMEMonitorHandlerReceiver receiver = e.getKey(); if( receiver.isValid( e.getValue() ) ) + { receiver.postChange( this, change, source ); + } else + { i.remove(); + } } } @@ -131,9 +143,13 @@ public class MEMonitorPassThrough> extends MEPassThrough, Object> e = i.next(); IMEMonitorHandlerReceiver receiver = e.getKey(); if( receiver.isValid( e.getValue() ) ) + { receiver.onListUpdate(); + } else + { i.remove(); + } } } } diff --git a/src/main/java/appeng/me/storage/NetworkInventoryHandler.java b/src/main/java/appeng/me/storage/NetworkInventoryHandler.java index 0c035cf8..247caa69 100644 --- a/src/main/java/appeng/me/storage/NetworkInventoryHandler.java +++ b/src/main/java/appeng/me/storage/NetworkInventoryHandler.java @@ -77,7 +77,9 @@ public class NetworkInventoryHandler> implements IMEInvent int priority = h.getPriority(); List> list = this.priorityInventory.get( priority ); if( list == null ) + { this.priorityInventory.put( priority, list = new ArrayList>() ); + } list.add( h ); } @@ -86,7 +88,9 @@ public class NetworkInventoryHandler> implements IMEInvent public T injectItems( T input, Actionable type, BaseActionSource src ) { if( this.diveList( this, type ) ) + { return input; + } if( this.testPermission( src, SecurityPermissions.INJECT ) ) { @@ -127,7 +131,9 @@ public class NetworkInventoryHandler> implements IMEInvent { LinkedList cDepth = this.getDepth( type ); if( cDepth.contains( networkInventoryHandler ) ) + { return true; + } cDepth.push( this ); return false; @@ -138,7 +144,9 @@ public class NetworkInventoryHandler> implements IMEInvent if( src.isPlayer() ) { if( !this.security.hasPermission( ( (PlayerSource) src ).player, permission ) ) + { return true; + } } else if( src.isMachine() ) { @@ -146,7 +154,9 @@ public class NetworkInventoryHandler> implements IMEInvent { IGridNode n = ( (MachineSource) src ).via.getActionableNode(); if( n == null ) + { return true; + } IGrid gn = n.getGrid(); if( gn != this.security.myGrid ) @@ -157,7 +167,9 @@ public class NetworkInventoryHandler> implements IMEInvent playerID = sg.getOwner(); if( !this.security.hasPermission( playerID, permission ) ) + { return true; + } } } } @@ -168,7 +180,9 @@ public class NetworkInventoryHandler> implements IMEInvent private void surface( NetworkInventoryHandler networkInventoryHandler, Actionable type ) { if( this.getDepth( type ).pop() != this ) + { throw new IllegalStateException( "Invalid Access to Networked Storage API detected." ); + } } private LinkedList getDepth( Actionable type ) @@ -178,7 +192,9 @@ public class NetworkInventoryHandler> implements IMEInvent LinkedList s = depth.get(); if( s == null ) + { depth.set( s = new LinkedList() ); + } return s; } @@ -187,7 +203,9 @@ public class NetworkInventoryHandler> implements IMEInvent public T extractItems( T request, Actionable mode, BaseActionSource src ) { if( this.diveList( this, mode ) ) + { return null; + } if( this.testPermission( src, SecurityPermissions.EXTRACT ) ) { @@ -219,7 +237,9 @@ public class NetworkInventoryHandler> implements IMEInvent this.surface( this, mode ); if( output.getStackSize() <= 0 ) + { return null; + } return output; } @@ -228,12 +248,18 @@ public class NetworkInventoryHandler> implements IMEInvent public IItemList getAvailableItems( IItemList out ) { if( this.diveIteration( this, Actionable.SIMULATE ) ) + { return out; + } // for (Entry> h : priorityInventory.entries()) for( List> i : this.priorityInventory.values() ) + { for( IMEInventoryHandler j : i ) + { out = j.getAvailableItems( out ); + } + } this.surface( this, Actionable.SIMULATE ); @@ -251,9 +277,13 @@ public class NetworkInventoryHandler> implements IMEInvent else { if( currentPass == this.myPass ) + { return true; + } else + { this.myPass = currentPass; + } } cDepth.push( this ); diff --git a/src/main/java/appeng/me/storage/SecurityInventory.java b/src/main/java/appeng/me/storage/SecurityInventory.java index 50eb1e1d..fa2efcc2 100644 --- a/src/main/java/appeng/me/storage/SecurityInventory.java +++ b/src/main/java/appeng/me/storage/SecurityInventory.java @@ -57,7 +57,9 @@ public class SecurityInventory implements IMEInventoryHandler if( this.canAccept( input ) ) { if( type == Actionable.SIMULATE ) + { return null; + } this.storedItems.add( input ); this.securityTile.inventoryChanged(); @@ -95,7 +97,9 @@ public class SecurityInventory implements IMEInventoryHandler IAEItemStack output = target.copy(); if( mode == Actionable.SIMULATE ) + { return output; + } target.setStackSize( 0 ); this.securityTile.inventoryChanged(); @@ -109,7 +113,9 @@ public class SecurityInventory implements IMEInventoryHandler public IItemList getAvailableItems( IItemList out ) { for( IAEItemStack ais : this.storedItems ) + { out.add( ais ); + } return out; } @@ -142,7 +148,9 @@ public class SecurityInventory implements IMEInventoryHandler int PlayerID = AEApi.instance().registries().players().getID( newUser ); if( this.securityTile.getOwner() == PlayerID ) + { return false; + } for( IAEItemStack ais : this.storedItems ) { @@ -150,10 +158,14 @@ public class SecurityInventory implements IMEInventoryHandler { GameProfile thisUser = tbc.getProfile( ais.getItemStack() ); if( thisUser == newUser ) + { return false; + } if( thisUser != null && thisUser.equals( newUser ) ) + { return false; + } } } diff --git a/src/main/java/appeng/me/storage/VoidFluidInventory.java b/src/main/java/appeng/me/storage/VoidFluidInventory.java index f767f01a..045ab04c 100644 --- a/src/main/java/appeng/me/storage/VoidFluidInventory.java +++ b/src/main/java/appeng/me/storage/VoidFluidInventory.java @@ -43,10 +43,14 @@ public class VoidFluidInventory implements IMEInventoryHandler public IAEFluidStack injectItems( IAEFluidStack input, Actionable mode, BaseActionSource src ) { if( mode == Actionable.SIMULATE ) + { return null; + } if( input != null ) + { this.target.addPower( input.getStackSize() / 1000.0 ); + } return null; } diff --git a/src/main/java/appeng/me/storage/VoidItemInventory.java b/src/main/java/appeng/me/storage/VoidItemInventory.java index ad827210..2ed92610 100644 --- a/src/main/java/appeng/me/storage/VoidItemInventory.java +++ b/src/main/java/appeng/me/storage/VoidItemInventory.java @@ -43,10 +43,14 @@ public class VoidItemInventory implements IMEInventoryHandler public IAEItemStack injectItems( IAEItemStack input, Actionable mode, BaseActionSource src ) { if( mode == Actionable.SIMULATE ) + { return null; + } if( input != null ) + { this.target.addPower( input.getStackSize() ); + } return null; } diff --git a/src/main/java/appeng/parts/AEBasePart.java b/src/main/java/appeng/parts/AEBasePart.java index e50e7808..9fb4bc62 100644 --- a/src/main/java/appeng/parts/AEBasePart.java +++ b/src/main/java/appeng/parts/AEBasePart.java @@ -123,7 +123,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, protected AEColor getColor() { if( this.host == null ) + { return AEColor.Transparent; + } return this.host.getColor(); } @@ -376,7 +378,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, { IConfigManager cm = this.getConfigManager(); if( cm != null ) + { cm.readFromNBT( compound ); + } } if( this instanceof IPriorityHost ) @@ -392,7 +396,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSizeInventory() ); tmp.readFromNBT( compound, "config" ); for( int x = 0; x < tmp.getSizeInventory(); x++ ) + { target.setInventorySlotContents( x, tmp.getStackInSlot( x ) ); + } } } @@ -409,7 +415,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, IConfigManager cm = this.getConfigManager(); if( cm != null ) + { cm.writeToNBT( output ); + } if( this instanceof IPriorityHost ) { @@ -472,7 +480,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, memoryCard.notifyUser( player, MemoryCardMessages.SETTINGS_LOADED ); } else + { memoryCard.notifyUser( player, MemoryCardMessages.INVALID_MACHINE ); + } } return true; } @@ -483,7 +493,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, public final boolean onActivate( EntityPlayer player, Vec3 pos ) { if( this.useMemoryCard( player ) ) + { return true; + } return this.onPartActivate( player, pos ); } @@ -492,7 +504,9 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost, public final boolean onShiftActivate( EntityPlayer player, Vec3 pos ) { if( this.useMemoryCard( player ) ) + { return true; + } return this.onPartShiftActivate( player, pos ); } diff --git a/src/main/java/appeng/parts/CableBusContainer.java b/src/main/java/appeng/parts/CableBusContainer.java index e542c8c1..d038dd45 100644 --- a/src/main/java/appeng/parts/CableBusContainer.java +++ b/src/main/java/appeng/parts/CableBusContainer.java @@ -112,7 +112,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I newSides[ForgeDirection.NORTH.ordinal()] = this.getSide( ForgeDirection.WEST ); for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS ) + { this.setSide( dir, newSides[dir.ordinal()] ); + } this.getFacadeContainer().rotateLeft(); } @@ -127,7 +129,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I public boolean canAddPart( ItemStack is, ForgeDirection side ) { if( PartPlacement.isFacade( is, side ) != null ) + { return true; + } if( is.getItem() instanceof IPartItem ) { @@ -143,11 +147,17 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { boolean canPlace = true; for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { if( this.getPart( d ) != null && !this.getPart( d ).canBePlacedOn( ( (IPartCable) bp ).supportsBuses() ) ) + { canPlace = false; + } + } if( !canPlace ) + { return false; + } return this.getPart( ForgeDirection.UNKNOWN ) == null; } @@ -155,7 +165,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart cable = this.getPart( ForgeDirection.UNKNOWN ); if( cable != null && !bp.canBePlacedOn( ( (IPartCable) cable ).supportsBuses() ) ) + { return false; + } return this.getPart( side ) == null; } @@ -181,23 +193,35 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { boolean canPlace = true; for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { if( this.getPart( d ) != null && !this.getPart( d ).canBePlacedOn( ( (IPartCable) bp ).supportsBuses() ) ) + { canPlace = false; + } + } if( !canPlace ) + { return null; + } if( this.getPart( ForgeDirection.UNKNOWN ) != null ) + { return null; + } this.setCenter( (IPartCable) bp ); bp.setPartHostInfo( ForgeDirection.UNKNOWN, this, this.tcb.getTile() ); if( player != null ) + { bp.onPlacement( player, is, side ); + } if( this.inWorld ) + { bp.addToWorld(); + } IGridNode cn = this.getCenter().getGridNode(); if( cn != null ) @@ -237,16 +261,22 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart cable = this.getPart( ForgeDirection.UNKNOWN ); if( cable != null && !bp.canBePlacedOn( ( (IPartCable) cable ).supportsBuses() ) ) + { return null; + } this.setSide( side, bp ); bp.setPartHostInfo( side, this, this.getTile() ); if( player != null ) + { bp.onPlacement( player, is, side ); + } if( this.inWorld ) + { bp.addToWorld(); + } if( this.getCenter() != null ) { @@ -286,7 +316,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I public IPart getPart( ForgeDirection side ) { if( side == ForgeDirection.UNKNOWN ) + { return this.getCenter(); + } return this.getSide( side ); } @@ -296,13 +328,17 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I if( side == ForgeDirection.UNKNOWN ) { if( this.getCenter() != null ) + { this.getCenter().removeFromWorld(); + } this.setCenter( null ); } else { if( this.getSide( side ) != null ) + { this.getSide( side ).removeFromWorld(); + } this.setSide( side, null ); } @@ -445,7 +481,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I public boolean hasRedstone( ForgeDirection side ) { if( this.hasRedstone == YesNo.UNDECIDED ) + { this.updateRedstone(); + } return this.hasRedstone == YesNo.YES; } @@ -458,13 +496,17 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart part = this.getPart( s ); if( part != null ) + { return false; + } if( s != ForgeDirection.UNKNOWN ) { IFacadePart fp = fc.getFacade( s ); if( fp != null ) + { return false; + } } } return true; @@ -507,7 +549,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart p = this.getPart( s ); if( p != null ) + { this.requiresDynamicRender = this.requiresDynamicRender || p.requireDynamicRender(); + } } } @@ -523,20 +567,26 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I for( ForgeDirection s : ForgeDirection.VALID_DIRECTIONS ) { if( this.getPart( s ) != null || this.isBlocked( s ) ) + { sides.remove( s ); + } } this.getCenter().setValidSides( sides ); IGridNode n = this.getCenter().getGridNode(); if( n != null ) + { n.updateState(); + } } } public void addToWorld() { if( this.inWorld ) + { return; + } this.inWorld = true; IS_LOADING.set( true ); @@ -592,7 +642,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I public void removeFromWorld() { if( !this.inWorld ) + { return; + } this.inWorld = false; @@ -600,7 +652,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart part = this.getPart( s ); if( part != null ) + { part.removeFromWorld(); + } } this.partChanged(); @@ -614,11 +668,15 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IGridNode n = part.getExternalFacingNode(); if( n != null ) + { return n; + } } if( this.getCenter() != null ) + { return this.getCenter().getGridNode(); + } return null; } @@ -631,7 +689,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { AECableType t = ( (IGridHost) part ).getCableConnectionType( dir ); if( t != null && t != AECableType.NONE ) + { return t; + } } if( this.getCenter() != null ) @@ -649,7 +709,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart p = this.getPart( d ); if( p instanceof IGridHost ) + { ( (IGridHost) p ).securityBreak(); + } } } @@ -666,9 +728,13 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I if( part != null ) { if( ignoreCableConnections && part instanceof IPartCable ) + { bch.addBox( 6.0, 6.0, 6.0, 10.0, 10.0, 10.0 ); + } else + { part.getBoxes( bch ); + } } if( AEApi.instance().partHelper().getCableRenderMode().opaqueFacades || !visual ) @@ -677,7 +743,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IFacadePart fp = fc.getFacade( s ); if( fp != null ) + { fp.getBoxes( bch, e ); + } } } } @@ -706,7 +774,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart part = this.getPart( dir ); if( part != null && part.canConnectRedstone() ) + { return true; + } } return false; } @@ -718,7 +788,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart part = this.getPart( s ); if( part != null ) + { part.onEntityCollision( entity ); + } } } @@ -742,7 +814,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart part = this.getPart( s ); if( part != null ) + { part.onNeighborChanged(); + } } } @@ -750,12 +824,16 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I public boolean isSolidOnSide( ForgeDirection side ) { if( side == null || side == ForgeDirection.UNKNOWN ) + { return false; + } // facades are solid.. IFacadePart fp = this.getFacadeContainer().getFacade( side ); if( fp != null ) + { return true; + } // buses can be too. IPart part = this.getPart( side ); @@ -771,7 +849,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I if( p != null ) { if( p.isLadder( entity ) ) + { return true; + } } } @@ -800,11 +880,15 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IPart p = this.getPart( d ); if( p != null ) + { light = Math.max( p.getLightLevel(), light ); + } } if( light > 0 && AppEng.instance.isIntegrationEnabled( IntegrationType.CLApi ) ) + { return ( (ICLApi) AppEng.instance.getIntegration( IntegrationType.CLApi ) ).colorLight( this.getColor(), light ); + } return light; } @@ -875,7 +959,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I if( current != null && current.getItem() == myItem && current.getItemDamage() == dmgValue ) { if( p.readFromStream( data ) ) + { updateBlock = true; + } } else { @@ -887,15 +973,21 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I p.readFromStream( data ); } else + { throw new IllegalStateException( "Invalid Stream For CableBus Container." ); + } } } else if( this.getPart( side ) != null ) + { this.removePart( side, false ); + } } if( this.getFacadeContainer().readFromStream( data ) ) + { return true; + } return updateBlock; } @@ -927,14 +1019,18 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I ForgeDirection getSide( IPart part ) { if( this.getCenter() == part ) + { return ForgeDirection.UNKNOWN; + } else { for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) + { if( this.getSide( side ) == part ) { return side; } + } } throw new IllegalStateException( "Uhh Bad Part (" + part + ") on Side." ); @@ -943,7 +1039,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I public void readFromNBT( NBTTagCompound data ) { if( data.hasKey( "hasRedstone" ) ) + { this.hasRedstone = YesNo.values()[data.getInteger( "hasRedstone" )]; + } for( int x = 0; x < 7; x++ ) { @@ -956,12 +1054,16 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I IPart p = this.getPart( side ); ItemStack iss = ItemStack.loadItemStackFromNBT( def ); if( iss == null ) + { continue; + } ItemStack current = p == null ? null : p.getItemStack( PartItemStack.World ); if( Platform.isSameItemType( iss, current ) ) + { p.readFromNBT( extra ); + } else { this.removePart( side, true ); @@ -978,7 +1080,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I } } else + { this.removePart( side, false ); + } } this.getFacadeContainer().readFromNBT( data ); @@ -999,7 +1103,9 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I { IFacadePart fp = this.getFacadeContainer().getFacade( s ); if( fp != null ) + { drops.add( fp.getItemStack() ); + } } } diff --git a/src/main/java/appeng/parts/CableBusStorage.java b/src/main/java/appeng/parts/CableBusStorage.java index 2ed38395..73cd35b6 100644 --- a/src/main/java/appeng/parts/CableBusStorage.java +++ b/src/main/java/appeng/parts/CableBusStorage.java @@ -50,7 +50,9 @@ public class CableBusStorage { int x = side.ordinal(); if( this.sides != null && this.sides.length > x ) + { return this.sides[x]; + } return null; } @@ -75,15 +77,23 @@ public class CableBusStorage { int newSize = -1; for( int x = 0; x < in.length; x++ ) + { if( in[x] != null ) + { newSize = x; + } + } if( newSize == -1 ) + { return null; + } newSize++; if( newSize == in.length ) + { return in; + } T[] newArray = (T[]) ( parts ? new IPart[newSize] : new IFacadePart[newSize] ); System.arraycopy( in, 0, newArray, 0, newSize ); @@ -94,13 +104,17 @@ public class CableBusStorage private T[] grow( T[] in, int new_value, boolean parts ) { if( in != null && in.length > new_value ) + { return in; + } int newSize = new_value + 1; T[] newArray = (T[]) ( parts ? new IPart[newSize] : new IFacadePart[newSize] ); if( in != null ) + { System.arraycopy( in, 0, newArray, 0, in.length ); + } return newArray; } @@ -108,7 +122,9 @@ public class CableBusStorage public IFacadePart getFacade( int x ) { if( this.facades != null && this.facades.length > x ) + { return this.facades[x]; + } return null; } diff --git a/src/main/java/appeng/parts/PartBasicState.java b/src/main/java/appeng/parts/PartBasicState.java index 413c0a40..2517f45c 100644 --- a/src/main/java/appeng/parts/PartBasicState.java +++ b/src/main/java/appeng/parts/PartBasicState.java @@ -110,10 +110,14 @@ public abstract class PartBasicState extends AEBasePart implements IPowerChannel try { if( this.proxy.getEnergy().isNetworkPowered() ) + { this.clientFlags |= this.POWERED_FLAG; + } if( this.proxy.getNode().meetsChannelRequirements() ) + { this.clientFlags |= this.CHANNEL_FLAG; + } this.clientFlags = this.populateFlags( this.clientFlags ); } diff --git a/src/main/java/appeng/parts/PartPlacement.java b/src/main/java/appeng/parts/PartPlacement.java index f5717821..0f55d5fb 100644 --- a/src/main/java/appeng/parts/PartPlacement.java +++ b/src/main/java/appeng/parts/PartPlacement.java @@ -76,21 +76,27 @@ public class PartPlacement public static boolean place( ItemStack held, int x, int y, int z, int face, EntityPlayer player, World world, PlaceType pass, int depth ) { if( depth > 3 ) + { return false; + } ForgeDirection side = ForgeDirection.getOrientation( face ); if( held != null && Platform.isWrench( player, held, x, y, z ) && player.isSneaking() ) { if( !Platform.hasPermissions( new DimensionalCoord( world, x, y, z ), player ) ) + { return false; + } Block block = world.getBlock( x, y, z ); TileEntity tile = world.getTileEntity( x, y, z ); IPartHost host = null; if( tile instanceof IPartHost ) + { host = (IPartHost) tile; + } if( host != null ) { @@ -118,7 +124,9 @@ public class PartPlacement } if( host.isEmpty() ) + { host.cleanup(); + } if( !is.isEmpty() ) { @@ -141,7 +149,9 @@ public class PartPlacement IPartHost host = null; if( tile instanceof IPartHost ) + { host = (IPartHost) tile; + } if( held != null ) { @@ -153,7 +163,9 @@ public class PartPlacement if( !world.isRemote ) { if( host.getPart( ForgeDirection.UNKNOWN ) == null ) + { return false; + } if( host.canAddPart( held, side ) ) { @@ -185,10 +197,14 @@ public class PartPlacement } if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) + { host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile ); + } if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) ) + { host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile ); + } // if ( held == null ) { @@ -202,6 +218,7 @@ public class PartPlacement mop.hitVec = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ); SelectedPart sPart = selectPart( player, host, mop.hitVec ); if( sPart != null && sPart.part != null ) + { if( sPart.part.onShiftActivate( player, mop.hitVec ) ) { if( world.isRemote ) @@ -210,12 +227,15 @@ public class PartPlacement } return true; } + } } } } if( held == null || !( held.getItem() instanceof IPartItem ) ) + { return false; + } int te_x = x; int te_y = y; @@ -231,7 +251,9 @@ public class PartPlacement { offset = side; if( Platform.isServer() ) + { side = side.getOpposite(); + } } te_x = x + offset.offsetX; @@ -240,13 +262,19 @@ public class PartPlacement tile = world.getTileEntity( te_x, te_y, te_z ); if( tile instanceof IPartHost ) + { host = (IPartHost) tile; + } if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) + { host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile ); + } if( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) ) + { host = ( (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ) ).getOrCreateHost( player, face, tile ); + } final Optional maybeMultiPartStack = multiPart.maybeStack( 1 ); final Optional maybeMultiPartBlock = multiPart.maybeBlock(); @@ -263,7 +291,9 @@ public class PartPlacement tile = world.getTileEntity( te_x, te_y, te_z ); if( tile instanceof IPartHost ) + { host = (IPartHost) tile; + } pass = PlaceType.INTERACT_SECOND_PASS; } @@ -281,7 +311,9 @@ public class PartPlacement } if( host == null ) + { return false; + } if( !host.canAddPart( held, side ) ) { @@ -295,10 +327,14 @@ public class PartPlacement tile = world.getTileEntity( te_x, te_y, te_z ); if( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) ) + { host = ( (IFMP) AppEng.instance.getIntegration( IntegrationType.FMP ) ).getOrCreateHost( tile ); + } if( ( blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null ) && side != ForgeDirection.UNKNOWN ) + { return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world, pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 ); + } } return false; } @@ -315,13 +351,17 @@ public class PartPlacement if( sp.part != null ) { if( !player.isSneaking() && sp.part.onActivate( player, mop.hitVec ) ) + { return false; + } } } DimensionalCoord dc = host.getLocation(); if( !Platform.hasPermissions( dc, player ) ) + { return false; + } ForgeDirection mySide = host.addPart( held, side, player ); if( mySide != null ) @@ -355,7 +395,9 @@ public class PartPlacement private static float getEyeOffset( EntityPlayer p ) { if( p.worldObj.isRemote ) + { return Platform.getEyeOffset( p ); + } return eyeHeight; } @@ -372,13 +414,17 @@ public class PartPlacement public static IFacadePart isFacade( ItemStack held, ForgeDirection side ) { if( held.getItem() instanceof IFacadeItem ) + { return ( (IFacadeItem) held.getItem() ).createPartFromItemStack( held, side ); + } if( AppEng.instance.isIntegrationEnabled( IntegrationType.BC ) ) { IBC bc = (IBC) AppEng.instance.getIntegration( IntegrationType.BC ); if( bc.isFacade( held ) ) + { return bc.createFacadePart( held, side ); + } } return null; @@ -408,7 +454,9 @@ public class PartPlacement World w = event.entity.worldObj; TileEntity te = w.getTileEntity( mop.blockX, mop.blockY, mop.blockZ ); if( te instanceof IPartHost && this.wasCanceled ) + { event.setCanceled( true ); + } } else { @@ -427,7 +475,9 @@ public class PartPlacement else if( event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote ) { if( this.placing.get() != null ) + { return; + } this.placing.set( event ); diff --git a/src/main/java/appeng/parts/automation/NonNullArrayIterator.java b/src/main/java/appeng/parts/automation/NonNullArrayIterator.java index 601a043e..975c1312 100644 --- a/src/main/java/appeng/parts/automation/NonNullArrayIterator.java +++ b/src/main/java/appeng/parts/automation/NonNullArrayIterator.java @@ -39,7 +39,9 @@ public class NonNullArrayIterator implements Iterator public boolean hasNext() { while( this.offset < this.g.length && this.g[this.offset] == null ) + { this.offset++; + } return this.offset != this.g.length; } diff --git a/src/main/java/appeng/parts/automation/PartExportBus.java b/src/main/java/appeng/parts/automation/PartExportBus.java index f1e3bded..00a49a32 100644 --- a/src/main/java/appeng/parts/automation/PartExportBus.java +++ b/src/main/java/appeng/parts/automation/PartExportBus.java @@ -100,7 +100,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest TickRateModulation doBusWork() { if( !this.proxy.isActive() ) + { return TickRateModulation.IDLE; + } this.itemToSend = 1; this.didSomething = false; @@ -141,7 +143,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest if( ais == null || this.itemToSend <= 0 || this.craftOnly() ) { if( this.isCraftingEnabled() ) + { this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething; + } continue; } @@ -153,14 +157,20 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest { this.pushItemIntoTarget( d, energy, inv, o ); if( this.itemToSend <= 0 ) + { break; + } } } else + { this.pushItemIntoTarget( d, energy, inv, ais ); + } if( this.itemToSend == before && this.isCraftingEnabled() ) + { this.didSomething = this.cratingTracker.handleCrafting( x, this.itemToSend, ais, d, this.getTile().getWorldObj(), this.proxy.getGrid(), cg, this.mySrc ) || this.didSomething; + } } } } @@ -234,7 +244,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest if( !player.isSneaking() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_BUS ); return true; @@ -302,7 +314,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest inv.injectItems( ais, Actionable.MODULATE, this.mySrc ); } else + { this.didSomething = true; + } } } } @@ -328,7 +342,9 @@ public class PartExportBus extends PartSharedItemBus implements ICraftingRequest if( energy.extractAEPower( power, mode, PowerMultiplier.CONFIG ) > power - 0.01 ) { if( mode == Actionable.MODULATE ) + { return AEItemStack.create( d.addItems( items.getItemStack() ) ); + } return AEItemStack.create( d.simulateAdd( items.getItemStack() ) ); } } diff --git a/src/main/java/appeng/parts/automation/PartFormationPlane.java b/src/main/java/appeng/parts/automation/PartFormationPlane.java index be0d6ad1..c978c4f8 100644 --- a/src/main/java/appeng/parts/automation/PartFormationPlane.java +++ b/src/main/java/appeng/parts/automation/PartFormationPlane.java @@ -113,13 +113,19 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine { IAEItemStack is = this.Config.getAEStackInSlot( x ); if( is != null ) + { priorityList.add( is ); + } } if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) + { this.myHandler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); + } else + { this.myHandler.setPartitionList( new PrecisePriorityList( priorityList ) ); + } try { @@ -150,7 +156,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine super.onChangeInventory( inv, slot, mc, removedStack, newStack ); if( inv == this.Config ) + { this.updateHandler(); + } } @Override @@ -180,7 +188,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine public IInventory getInventoryByName( String name ) { if( name.equals( "config" ) ) + { return this.Config; + } return super.getInventoryByName( name ); } @@ -231,16 +241,24 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine ForgeDirection u = bch.getWorldY(); if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) ) + { minX = 0; + } if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) ) + { maxX = 16; + } if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) ) + { minY = 0; + } if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) ) + { maxY = 16; + } } bch.addBox( 5, 5, 14, 11, 11, 15 ); @@ -275,16 +293,24 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine TileEntity te = this.getHost().getTile(); if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - e.offsetX, y - e.offsetY, z - e.offsetZ ), this.side ) ) + { minX = 0; + } if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + e.offsetX, y + e.offsetY, z + e.offsetZ ), this.side ) ) + { maxX = 16; + } if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x - u.offsetX, y - u.offsetY, z - u.offsetZ ), this.side ) ) + { minY = 0; + } if( this.isTransitionPlane( te.getWorldObj().getTileEntity( x + u.offsetX, y + u.offsetY, z + u.offsetZ ), this.side ) ) + { maxY = 16; + } boolean isActive = ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) == ( this.POWERED_FLAG | this.CHANNEL_FLAG ); @@ -328,7 +354,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine if( !player.isSneaking() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_FORMATION_PLANE ); return true; @@ -383,7 +411,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine public IAEItemStack injectItems( IAEItemStack input, Actionable type, BaseActionSource src ) { if( this.blocked || input == null || input.getStackSize() <= 0 ) + { return input; + } YesNo placeBlock = (YesNo) this.getConfigManager().getSetting( Settings.PLACE_BLOCK ); @@ -413,9 +443,13 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine Chunk c = w.getChunkFromBlockCoords( x, z ); int sum = 0; for( List Z : c.entityLists ) + { sum += Z.size(); + } if( sum > 32 ) + { return input; + } } maxStorage = is.stackSize; worked = true; @@ -426,16 +460,24 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine boolean Worked = false; if( side.offsetX == 0 && side.offsetZ == 0 ) + { Worked = i.onItemUse( is, player, w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ ); + } if( !Worked && side.offsetX == 0 && side.offsetZ == 0 ) + { Worked = i.onItemUse( is, player, w, x - side.offsetX, y - side.offsetY, z - side.offsetZ, side.ordinal(), side.offsetX, side.offsetY, side.offsetZ ); + } if( !Worked && side.offsetY == 0 ) + { Worked = i.onItemUse( is, player, w, x, y - 1, z, ForgeDirection.UP.ordinal(), side.offsetX, side.offsetY, side.offsetZ ); + } if( !Worked ) + { i.onItemUse( is, player, w, x, y, z, side.getOpposite().ordinal(), side.offsetX, side.offsetY, side.offsetZ ); + } maxStorage -= is.stackSize; } @@ -446,7 +488,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine } } else + { maxStorage = 1; + } } else { @@ -454,7 +498,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine Chunk c = w.getChunkFromBlockCoords( x, z ); int sum = 0; for( List Z : c.entityLists ) + { sum += Z.size(); + } if( sum < AEConfig.instance.formationPlaneEntityLimit ) { @@ -478,9 +524,13 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine { result = is.getItem().createEntity( w, ei, is ); if( result != null ) + { ei.setDead(); + } else + { result = ei; + } } if( !w.spawnEntityInWorld( result ) ) @@ -491,7 +541,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine } } else + { worked = false; + } } } @@ -502,7 +554,9 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine IAEItemStack out = input.copy(); out.decStackSize( maxStorage ); if( out.getStackSize() == 0 ) + { return null; + } return out; } diff --git a/src/main/java/appeng/parts/automation/PartImportBus.java b/src/main/java/appeng/parts/automation/PartImportBus.java index 77645514..0a0fab58 100644 --- a/src/main/java/appeng/parts/automation/PartImportBus.java +++ b/src/main/java/appeng/parts/automation/PartImportBus.java @@ -78,11 +78,15 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin public boolean canInsert( ItemStack stack ) { if( stack == null || stack.getItem() == null ) + { return false; + } IAEItemStack out = this.destination.injectItems( this.lastItemChecked = AEApi.instance().storage().createItemStack( stack ), Actionable.SIMULATE, this.source ); if( out == null ) + { return true; + } return out.getStackSize() != stack.stackSize; } @@ -145,7 +149,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin if( !player.isSneaking() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_BUS ); return true; @@ -170,7 +176,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin TickRateModulation doBusWork() { if( !this.proxy.isActive() ) + { return TickRateModulation.IDLE; + } this.worked = false; @@ -215,7 +223,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin while( this.itemToSend > 0 ) { if( this.importStuff( myAdaptor, ais, inv, energy, fzMode ) ) + { break; + } } } } @@ -225,7 +235,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin while( this.itemToSend > 0 ) { if( this.importStuff( myAdaptor, null, inv, energy, fzMode ) ) + { break; + } } } } @@ -235,7 +247,9 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin } } else + { return TickRateModulation.SLEEP; + } return this.worked ? TickRateModulation.FASTER : TickRateModulation.SLOWER; } @@ -245,13 +259,19 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin int toSend = this.itemToSend; if( toSend > 64 ) + { toSend = 64; + } ItemStack newItems; if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) + { newItems = myAdaptor.removeSimilarItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), fzMode, this.configDestination( inv ) ); + } else + { newItems = myAdaptor.removeItems( toSend, whatToImport == null ? null : whatToImport.getItemStack(), this.configDestination( inv ) ); + } if( newItems != null ) { @@ -259,9 +279,13 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin this.itemToSend -= newItems.stackSize; if( this.lastItemChecked == null || !this.lastItemChecked.isSameType( newItems ) ) + { this.lastItemChecked = AEApi.instance().storage().createItemStack( newItems ); + } else + { this.lastItemChecked.setStackSize( newItems.stackSize ); + } IAEItemStack failed = Platform.poweredInsert( energy, this.destination, this.lastItemChecked, this.source ); // destination.injectItems( lastItemChecked, Actionable.MODULATE ); @@ -271,10 +295,14 @@ public class PartImportBus extends PartSharedItemBus implements IInventoryDestin return true; } else + { this.worked = true; + } } else + { return true; + } return false; } diff --git a/src/main/java/appeng/parts/automation/PartLevelEmitter.java b/src/main/java/appeng/parts/automation/PartLevelEmitter.java index e6cf3bf1..6748a77e 100644 --- a/src/main/java/appeng/parts/automation/PartLevelEmitter.java +++ b/src/main/java/appeng/parts/automation/PartLevelEmitter.java @@ -120,9 +120,13 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH { this.reportingValue = v; if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL ) + { this.configureWatchers(); + } else + { this.updateState(); + } } @MENetworkEventSubscribe @@ -211,13 +215,19 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH IAEItemStack myStack = this.config.getAEStackInSlot( 0 ); if( this.myWatcher != null ) + { this.myWatcher.clear(); + } if( this.myEnergyWatcher != null ) + { this.myEnergyWatcher.clear(); + } if( this.myCraftingWatcher != null ) + { this.myCraftingWatcher.clear(); + } try { @@ -231,7 +241,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH if( this.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 ) { if( this.myCraftingWatcher != null && myStack != null ) + { this.myCraftingWatcher.add( myStack ); + } return; } @@ -239,7 +251,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH if( this.getConfigManager().getSetting( Settings.LEVEL_TYPE ) == LevelType.ENERGY_LEVEL ) { if( this.myEnergyWatcher != null ) + { this.myEnergyWatcher.add( (double) this.reportingValue ); + } try { @@ -269,7 +283,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH this.proxy.getStorage().getItemInventory().removeListener( this ); if( this.myWatcher != null ) + { this.myWatcher.add( myStack ); + } } this.updateReportingValue( this.proxy.getStorage().getItemInventory() ); @@ -288,7 +304,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH { this.lastReportedValue = 0; for( IAEItemStack st : monitor.getStorageList() ) + { this.lastReportedValue += st.getStackSize(); + } } else if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) { @@ -296,15 +314,21 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH FuzzyMode fzMode = (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ); Collection fuzzyList = monitor.getStorageList().findFuzzy( myStack, fzMode ); for( IAEItemStack st : fuzzyList ) + { this.lastReportedValue += st.getStackSize(); + } } else { IAEItemStack r = monitor.getStorageList().findPrecise( myStack ); if( r == null ) + { this.lastReportedValue = 0; + } else + { this.lastReportedValue = r.getStackSize(); + } } this.updateState(); @@ -624,7 +648,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH if( !player.isSneaking() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_LEVEL_EMITTER ); return true; @@ -643,7 +669,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removedStack, ItemStack newStack ) { if( inv == this.config ) + { this.configureWatchers(); + } super.onChangeInventory( inv, slot, mc, removedStack, newStack ); } @@ -684,7 +712,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH public IInventory getInventoryByName( String name ) { if( name.equals( "config" ) ) + { return this.config; + } return super.getInventoryByName( name ); } @@ -710,7 +740,9 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH { IAEItemStack what = this.config.getAEStackInSlot( 0 ); if( what != null ) + { craftingTracker.setEmitable( what ); + } } } } diff --git a/src/main/java/appeng/parts/automation/PartSharedItemBus.java b/src/main/java/appeng/parts/automation/PartSharedItemBus.java index 6d3e548e..01d4ca07 100644 --- a/src/main/java/appeng/parts/automation/PartSharedItemBus.java +++ b/src/main/java/appeng/parts/automation/PartSharedItemBus.java @@ -76,7 +76,9 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid public IInventory getInventoryByName( String name ) { if( name.equals( "config" ) ) + { return this.config; + } return super.getInventoryByName( name ); } @@ -86,9 +88,13 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid try { if( !this.isSleeping() ) + { this.proxy.getTick().wakeDevice( this.proxy.getNode() ); + } else + { this.proxy.getTick().sleepDevice( this.proxy.getNode() ); + } } catch( GridAccessException e ) { @@ -104,7 +110,9 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid int newAdaptorHash = Platform.generateTileHash( target ); if( this.adaptorHash == newAdaptorHash && newAdaptorHash != 0 ) + { return this.adaptor; + } this.adaptorHash = newAdaptorHash; this.adaptor = InventoryAdaptor.getAdaptor( target, this.side.getOpposite() ); @@ -132,7 +140,9 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid { this.lastRedstone = !this.lastRedstone; if( this.lastRedstone && this.getRSMode() == RedstoneMode.SIGNAL_PULSE ) + { this.doBusWork(); + } } } diff --git a/src/main/java/appeng/parts/automation/PartUpgradeable.java b/src/main/java/appeng/parts/automation/PartUpgradeable.java index 4834948e..2e7b934a 100644 --- a/src/main/java/appeng/parts/automation/PartUpgradeable.java +++ b/src/main/java/appeng/parts/automation/PartUpgradeable.java @@ -83,13 +83,17 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn case HIGH_SIGNAL: if( this.host.hasRedstone( this.side ) ) + { return false; + } break; case LOW_SIGNAL: if( !this.host.hasRedstone( this.side ) ) + { return false; + } break; @@ -136,8 +140,12 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn public void getDrops( List drops, boolean wrenched ) { for( ItemStack is : this.upgrades ) + { if( is != null ) + { drops.add( is ); + } + } } @Override @@ -150,7 +158,9 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn public IInventory getInventoryByName( String name ) { if( name.equals( "upgrades" ) ) + { return this.upgrades; + } return null; } diff --git a/src/main/java/appeng/parts/automation/UpgradeInventory.java b/src/main/java/appeng/parts/automation/UpgradeInventory.java index 954307d5..606bf53e 100644 --- a/src/main/java/appeng/parts/automation/UpgradeInventory.java +++ b/src/main/java/appeng/parts/automation/UpgradeInventory.java @@ -67,7 +67,9 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement public boolean isItemValidForSlot( int i, ItemStack itemstack ) { if( itemstack == null ) + { return false; + } Item it = itemstack.getItem(); if( it instanceof IUpgradeModule ) { @@ -83,7 +85,9 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement public int getInstalledUpgrades( Upgrades u ) { if( !this.cached ) + { this.updateUpgradeInfo(); + } switch( u ) { @@ -114,7 +118,9 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement for( ItemStack is : this ) { if( is == null || is.getItem() == null || !( is.getItem() instanceof IUpgradeModule ) ) + { continue; + } Upgrades myUpgrade = ( (IUpgradeModule) is.getItem() ).getType( is ); switch( myUpgrade ) @@ -168,6 +174,8 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement { this.cached = false; if( this.parent != null && Platform.isServer() ) + { this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack ); + } } } diff --git a/src/main/java/appeng/parts/layers/InvLayerData.java b/src/main/java/appeng/parts/layers/InvLayerData.java index 3acc83f1..3e520050 100644 --- a/src/main/java/appeng/parts/layers/InvLayerData.java +++ b/src/main/java/appeng/parts/layers/InvLayerData.java @@ -47,7 +47,9 @@ public class InvLayerData public ItemStack decreaseStackSize( int slot, int amount ) { if( this.isSlotValid( slot ) ) + { return this.slots.get( slot ).decreaseStackSize( amount ); + } return null; } @@ -67,7 +69,9 @@ public class InvLayerData public int getSizeInventory() { if( this.slots == null ) + { return 0; + } return this.slots.size(); } @@ -75,7 +79,9 @@ public class InvLayerData public ItemStack getStackInSlot( int slot ) { if( this.isSlotValid( slot ) ) + { return this.slots.get( slot ).getStackInSlot(); + } return null; } @@ -83,7 +89,9 @@ public class InvLayerData public boolean isItemValidForSlot( int slot, ItemStack itemstack ) { if( this.isSlotValid( slot ) ) + { return this.slots.get( slot ).isItemValidForSlot( itemstack ); + } return false; } @@ -91,13 +99,17 @@ public class InvLayerData public void setInventorySlotContents( int slot, ItemStack itemstack ) { if( this.isSlotValid( slot ) ) + { this.slots.get( slot ).setInventorySlotContents( itemstack ); + } } public boolean canExtractItem( int slot, ItemStack itemstack, int side ) { if( this.isSlotValid( slot ) ) + { return this.slots.get( slot ).canExtractItem( itemstack, side ); + } return false; } @@ -105,7 +117,9 @@ public class InvLayerData public boolean canInsertItem( int slot, ItemStack itemstack, int side ) { if( this.isSlotValid( slot ) ) + { return this.slots.get( slot ).canInsertItem( itemstack, side ); + } return false; } @@ -115,14 +129,18 @@ public class InvLayerData if( this.inventories != null ) { for( IInventory inv : this.inventories ) + { inv.markDirty(); + } } } public int[] getAccessibleSlotsFromSide( int side ) { if( this.sides == null || side < 0 || side > 5 ) + { return NULL_SIDES; + } return this.sides[side]; } } diff --git a/src/main/java/appeng/parts/layers/LayerIEnergyHandler.java b/src/main/java/appeng/parts/layers/LayerIEnergyHandler.java index 7f1d3c73..422f0a02 100644 --- a/src/main/java/appeng/parts/layers/LayerIEnergyHandler.java +++ b/src/main/java/appeng/parts/layers/LayerIEnergyHandler.java @@ -38,7 +38,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler { IPart part = this.getPart( from ); if( part instanceof IEnergyReceiver ) + { return ( (IEnergyReceiver) part ).receiveEnergy( from, maxReceive, simulate ); + } return 0; } @@ -48,7 +50,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler { IPart part = this.getPart( from ); if( part instanceof IEnergyProvider ) + { return ( (IEnergyProvider) part ).extractEnergy( from, maxExtract, simulate ); + } return 0; } @@ -58,7 +62,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler { IPart part = this.getPart( from ); if( part instanceof IEnergyProvider ) + { return ( (IEnergyProvider) part ).getEnergyStored( from ); + } return 0; } @@ -68,7 +74,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler { IPart part = this.getPart( from ); if( part instanceof IEnergyProvider ) + { return ( (IEnergyProvider) part ).getMaxEnergyStored( from ); + } return 0; } @@ -78,7 +86,9 @@ public class LayerIEnergyHandler extends LayerBase implements IEnergyHandler { IPart part = this.getPart( from ); if( part instanceof IEnergyConnection ) + { return ( (IEnergyConnection) part ).canConnectEnergy( from ); + } return false; } diff --git a/src/main/java/appeng/parts/layers/LayerIEnergySink.java b/src/main/java/appeng/parts/layers/LayerIEnergySink.java index 03867ae5..b02daa1d 100644 --- a/src/main/java/appeng/parts/layers/LayerIEnergySink.java +++ b/src/main/java/appeng/parts/layers/LayerIEnergySink.java @@ -46,7 +46,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink private World getEnergySinkWorld() { if( this.getEnergySinkTile() == null ) + { return null; + } return this.getEnergySinkTile().getWorldObj(); } @@ -56,7 +58,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink TileEntity te = this.getEnergySinkTile(); if( te == null ) + { return false; + } return !te.isInvalid() && te.getWorldObj().blockExists( te.xCoord, te.yCoord, te.zCoord ); } @@ -64,7 +68,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink private void addToENet() { if( this.getEnergySinkWorld() == null ) + { return; + } // re-add this.removeFromENet(); @@ -79,7 +85,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink private void removeFromENet() { if( this.getEnergySinkWorld() == null ) + { return; + } if( this.isInIC2() && Platform.isServer() ) { @@ -91,7 +99,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink private boolean interestedInIC2() { if( !( (IPartHost) this ).isInWorld() ) + { return false; + } int interested = 0; for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS ) @@ -111,20 +121,28 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink super.partChanged(); if( this.interestedInIC2() ) + { this.addToENet(); + } else + { this.removeFromENet(); + } } @Override public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction ) { if( !this.isInIC2() ) + { return false; + } IPart part = this.getPart( direction ); if( part instanceof IEnergySink ) + { return ( (IEnergySink) part ).acceptsEnergyFrom( emitter, direction ); + } return false; } @@ -137,7 +155,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink public double getDemandedEnergy() { if( !this.isInIC2() ) + { return 0; + } // this is a flawed implementation, that requires a change to the IC2 API. @@ -164,7 +184,9 @@ public class LayerIEnergySink extends LayerBase implements IEnergySink public double injectEnergy( ForgeDirection directionFrom, double amount, double voltage ) { if( !this.isInIC2() ) + { return amount; + } for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS ) { diff --git a/src/main/java/appeng/parts/layers/LayerIEnergySource.java b/src/main/java/appeng/parts/layers/LayerIEnergySource.java index ad76f01c..95ed2b81 100644 --- a/src/main/java/appeng/parts/layers/LayerIEnergySource.java +++ b/src/main/java/appeng/parts/layers/LayerIEnergySource.java @@ -48,7 +48,9 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource private World getEnergySourceWorld() { if( this.getEnergySourceTile() == null ) + { return null; + } return this.getEnergySourceTile().getWorldObj(); } @@ -56,14 +58,18 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource { TileEntity te = this.getEnergySourceTile(); if( te == null ) + { return false; + } return !te.isInvalid(); } private void addToENet() { if( this.getEnergySourceWorld() == null ) + { return; + } // re-add this.removeFromENet(); @@ -78,7 +84,9 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource private void removeFromENet() { if( this.getEnergySourceWorld() == null ) + { return; + } if( this.isInIC2() && Platform.isServer() ) { @@ -90,7 +98,9 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource private boolean interestedInIC2() { if( !( (IPartHost) this ).isInWorld() ) + { return false; + } int interested = 0; for( ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS ) @@ -110,20 +120,28 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource super.partChanged(); if( this.interestedInIC2() ) + { this.addToENet(); + } else + { this.removeFromENet(); + } } @Override public boolean emitsEnergyTo( TileEntity receiver, ForgeDirection direction ) { if( !this.isInIC2() ) + { return false; + } IPart part = this.getPart( direction ); if( part instanceof IEnergySink ) + { return ( (IEnergyEmitter) part ).emitsEnergyTo( receiver, direction ); + } return false; } @@ -136,7 +154,9 @@ public class LayerIEnergySource extends LayerBase implements IEnergySource public double getOfferedEnergy() { if( !this.isInIC2() ) + { return 0; + } // this is a flawed implementation, that requires a change to the IC2 API. diff --git a/src/main/java/appeng/parts/layers/LayerIFluidHandler.java b/src/main/java/appeng/parts/layers/LayerIFluidHandler.java index 6ea61908..3b3d3eaa 100644 --- a/src/main/java/appeng/parts/layers/LayerIFluidHandler.java +++ b/src/main/java/appeng/parts/layers/LayerIFluidHandler.java @@ -38,7 +38,9 @@ public class LayerIFluidHandler extends LayerBase implements IFluidHandler { IPart part = this.getPart( from ); if( part instanceof IFluidHandler ) + { return ( (IFluidHandler) part ).fill( from, resource, doFill ); + } return 0; } @@ -47,7 +49,9 @@ public class LayerIFluidHandler extends LayerBase implements IFluidHandler { IPart part = this.getPart( from ); if( part instanceof IFluidHandler ) + { return ( (IFluidHandler) part ).drain( from, resource, doDrain ); + } return null; } @@ -56,7 +60,9 @@ public class LayerIFluidHandler extends LayerBase implements IFluidHandler { IPart part = this.getPart( from ); if( part instanceof IFluidHandler ) + { return ( (IFluidHandler) part ).drain( from, maxDrain, doDrain ); + } return null; } @@ -65,7 +71,9 @@ public class LayerIFluidHandler extends LayerBase implements IFluidHandler { IPart part = this.getPart( from ); if( part instanceof IFluidHandler ) + { return ( (IFluidHandler) part ).canFill( from, fluid ); + } return false; } @@ -74,7 +82,9 @@ public class LayerIFluidHandler extends LayerBase implements IFluidHandler { IPart part = this.getPart( from ); if( part instanceof IFluidHandler ) + { return ( (IFluidHandler) part ).canDrain( from, fluid ); + } return false; } @@ -83,7 +93,9 @@ public class LayerIFluidHandler extends LayerBase implements IFluidHandler { IPart part = this.getPart( from ); if( part instanceof IFluidHandler ) + { return ( (IFluidHandler) part ).getTankInfo( from ); + } return EMPTY_LIST; } } diff --git a/src/main/java/appeng/parts/layers/LayerIPipeConnection.java b/src/main/java/appeng/parts/layers/LayerIPipeConnection.java index 4d11c8d5..4553b718 100644 --- a/src/main/java/appeng/parts/layers/LayerIPipeConnection.java +++ b/src/main/java/appeng/parts/layers/LayerIPipeConnection.java @@ -36,7 +36,9 @@ public class LayerIPipeConnection extends LayerBase implements IPipeConnection { IPart part = this.getPart( with ); if( part instanceof IPipeConnection ) + { return ( (IPipeConnection) part ).overridePipeConnection( type, with ); + } return ConnectOverride.DEFAULT; } } diff --git a/src/main/java/appeng/parts/layers/LayerISidedInventory.java b/src/main/java/appeng/parts/layers/LayerISidedInventory.java index bc17777a..f311aee9 100644 --- a/src/main/java/appeng/parts/layers/LayerISidedInventory.java +++ b/src/main/java/appeng/parts/layers/LayerISidedInventory.java @@ -95,11 +95,13 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory ForgeDirection currentSide = ForgeDirection.UNKNOWN; for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) + { if( this.getPart( side ) == sides ) { currentSide = side; break; } + } int[] cSidesList = sideData[currentSide.ordinal()] = new int[slotCount]; for( int cSlot = 0; cSlot < slotCount; cSlot++ ) @@ -113,9 +115,13 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory } if( sideData == null || slots == null ) + { this.invLayer = null; + } else + { this.invLayer = new InvLayerData( sideData, inventories, slots ); + } // make sure inventory is updated before we call FMP. super.notifyNeighbors(); @@ -125,7 +131,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public int getSizeInventory() { if( this.invLayer == null ) + { return 0; + } return this.invLayer.getSizeInventory(); } @@ -134,7 +142,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public ItemStack getStackInSlot( int slot ) { if( this.invLayer == null ) + { return null; + } return this.invLayer.getStackInSlot( slot ); } @@ -143,7 +153,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public ItemStack decrStackSize( int slot, int amount ) { if( this.invLayer == null ) + { return null; + } return this.invLayer.decreaseStackSize( slot, amount ); } @@ -158,7 +170,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public void setInventorySlotContents( int slot, ItemStack itemstack ) { if( this.invLayer == null ) + { return; + } this.invLayer.setInventorySlotContents( slot, itemstack ); } @@ -201,7 +215,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public boolean isItemValidForSlot( int slot, ItemStack itemstack ) { if( this.invLayer == null ) + { return false; + } return this.invLayer.isItemValidForSlot( slot, itemstack ); } @@ -210,7 +226,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public void markDirty() { if( this.invLayer != null ) + { this.invLayer.markDirty(); + } super.markForSave(); } @@ -219,7 +237,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public int[] getAccessibleSlotsFromSide( int side ) { if( this.invLayer != null ) + { return this.invLayer.getAccessibleSlotsFromSide( side ); + } return NULL_SIDES; } @@ -228,7 +248,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public boolean canInsertItem( int slot, ItemStack itemstack, int side ) { if( this.invLayer == null ) + { return false; + } return this.invLayer.canInsertItem( slot, itemstack, side ); } @@ -237,7 +259,9 @@ public class LayerISidedInventory extends LayerBase implements ISidedInventory public boolean canExtractItem( int slot, ItemStack itemstack, int side ) { if( this.invLayer == null ) + { return false; + } return this.invLayer.canExtractItem( slot, itemstack, side ); } diff --git a/src/main/java/appeng/parts/layers/LayerITileStorageMonitorable.java b/src/main/java/appeng/parts/layers/LayerITileStorageMonitorable.java index 691b1e29..a6897042 100644 --- a/src/main/java/appeng/parts/layers/LayerITileStorageMonitorable.java +++ b/src/main/java/appeng/parts/layers/LayerITileStorageMonitorable.java @@ -36,7 +36,9 @@ public class LayerITileStorageMonitorable extends LayerBase implements ITileStor { IPart part = this.getPart( side ); if( part instanceof ITileStorageMonitorable ) + { return ( (ITileStorageMonitorable) part ).getMonitorable( side, src ); + } return null; } } diff --git a/src/main/java/appeng/parts/misc/PartCableAnchor.java b/src/main/java/appeng/parts/misc/PartCableAnchor.java index b82c7150..55019091 100644 --- a/src/main/java/appeng/parts/misc/PartCableAnchor.java +++ b/src/main/java/appeng/parts/misc/PartCableAnchor.java @@ -67,9 +67,13 @@ public class PartCableAnchor implements IPart public void getBoxes( IPartCollisionHelper bch ) { if( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null ) + { bch.addBox( 7, 7, 10, 9, 9, 14 ); + } else + { bch.addBox( 7, 7, 10, 9, 9, 16 ); + } } @Override @@ -96,9 +100,13 @@ public class PartCableAnchor implements IPart IIcon myIcon = this.is.getIconIndex(); rh.setTexture( myIcon ); if( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null ) + { rh.setBounds( 7, 7, 10, 9, 9, 14 ); + } else + { rh.setBounds( 7, 7, 10, 9, 9, 16 ); + } rh.renderBlock( x, y, z, renderer ); rh.setTexture( null ); } diff --git a/src/main/java/appeng/parts/misc/PartInterface.java b/src/main/java/appeng/parts/misc/PartInterface.java index 64ee1591..5d17cd9c 100644 --- a/src/main/java/appeng/parts/misc/PartInterface.java +++ b/src/main/java/appeng/parts/misc/PartInterface.java @@ -203,10 +203,14 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto public boolean onPartActivate( EntityPlayer p, Vec3 pos ) { if( p.isSneaking() ) + { return false; + } if( Platform.isServer() ) + { Platform.openGUI( p, this.getTileEntity(), this.side, GuiBridge.GUI_INTERFACE ); + } return true; } diff --git a/src/main/java/appeng/parts/misc/PartStorageBus.java b/src/main/java/appeng/parts/misc/PartStorageBus.java index 06786896..64379e1f 100644 --- a/src/main/java/appeng/parts/misc/PartStorageBus.java +++ b/src/main/java/appeng/parts/misc/PartStorageBus.java @@ -163,7 +163,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC super.onChangeInventory( inv, slot, mc, removedStack, newStack ); if( inv == this.Config ) + { this.resetCache( true ); + } } @Override @@ -193,7 +195,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC public IInventory getInventoryByName( String name ) { if( name.equals( "config" ) ) + { return this.Config; + } return super.getInventoryByName( name ); } @@ -201,12 +205,18 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC private void resetCache( boolean fullReset ) { if( this.host == null || this.host.getTile() == null || this.host.getTile().getWorldObj() == null || this.host.getTile().getWorldObj().isRemote ) + { return; + } if( fullReset ) + { this.resetCacheLogic = 2; + } else + { this.resetCacheLogic = 1; + } try { @@ -230,7 +240,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC try { if( this.proxy.isActive() ) + { this.proxy.getStorage().postAlterationOfStoredItems( StorageChannel.ITEMS, change, this.mySrc ); + } } catch( GridAccessException e ) { @@ -312,7 +324,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC if( !player.isSneaking() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_STORAGEBUS ); return true; @@ -331,10 +345,14 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { if( this.resetCacheLogic != 0 ) + { this.resetCache(); + } if( this.monitor != null ) + { return this.monitor.onTick(); + } return TickRateModulation.SLEEP; } @@ -347,20 +365,28 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC IMEInventory in = this.getInternalHandler(); IItemList before = AEApi.instance().storage().createItemList(); if( in != null ) + { before = in.getAvailableItems( before ); + } this.cached = false; if( fullReset ) + { this.handlerHash = 0; + } IMEInventory out = this.getInternalHandler(); if( this.monitor != null ) + { this.monitor.onTick(); + } IItemList after = AEApi.instance().storage().createItemList(); if( out != null ) + { after = out.getAvailableItems( after ); + } Platform.postListChanges( before, after, this, this.mySrc ); } @@ -368,7 +394,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC public MEInventoryHandler getInternalHandler() { if( this.cached ) + { return this.handler; + } boolean wasSleeping = this.monitor == null; @@ -379,7 +407,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC int newHandlerHash = Platform.generateTileHash( target ); if( this.handlerHash == newHandlerHash && this.handlerHash != 0 ) + { return this.handler; + } try { @@ -409,7 +439,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC } if( inv instanceof MEMonitorIInventory ) + { this.monitor = (MEMonitorIInventory) inv; + } if( inv != null ) { @@ -428,16 +460,24 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC { IAEItemStack is = this.Config.getAEStackInSlot( x ); if( is != null ) + { priorityList.add( is ); + } } if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 ) + { this.handler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) ); + } else + { this.handler.setPartitionList( new PrecisePriorityList( priorityList ) ); + } if( inv instanceof IMEMonitor ) + { ( (IMEMonitor) inv ).addListener( this, this.handler ); + } } } } @@ -449,9 +489,13 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC { ITickManager tm = this.proxy.getTick(); if( this.monitor == null ) + { tm.sleepDevice( this.proxy.getNode() ); + } else + { tm.wakeDevice( this.proxy.getNode() ); + } } catch( GridAccessException e ) { @@ -467,13 +511,17 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC IInterfaceHost achievement = null; if( target instanceof IInterfaceHost ) + { achievement = (IInterfaceHost) target; + } if( target instanceof IPartHost ) { Object part = ( (IPartHost) target ).getPart( side ); if( part instanceof IInterfaceHost ) + { achievement = (IInterfaceHost) part; + } } if( achievement != null && achievement.getActionableNode() != null ) @@ -490,7 +538,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC { IMEInventoryHandler out = this.proxy.isActive() ? this.getInternalHandler() : null; if( out != null ) + { return Collections.singletonList( out ); + } } return Arrays.asList( new IMEInventoryHandler[] {} ); } diff --git a/src/main/java/appeng/parts/networking/PartCableCovered.java b/src/main/java/appeng/parts/networking/PartCableCovered.java index f33f5afb..001034a8 100644 --- a/src/main/java/appeng/parts/networking/PartCableCovered.java +++ b/src/main/java/appeng/parts/networking/PartCableCovered.java @@ -82,9 +82,13 @@ public class PartCableCovered extends PartCable { IGridNode n = this.getGridNode(); if( n != null ) + { this.connections = n.getConnectedSides(); + } else + { this.connections.clear(); + } } for( ForgeDirection of : this.connections ) diff --git a/src/main/java/appeng/parts/networking/PartCableSmart.java b/src/main/java/appeng/parts/networking/PartCableSmart.java index 7553df0c..624282e4 100644 --- a/src/main/java/appeng/parts/networking/PartCableSmart.java +++ b/src/main/java/appeng/parts/networking/PartCableSmart.java @@ -86,9 +86,13 @@ public class PartCableSmart extends PartCable { IGridNode n = this.getGridNode(); if( n != null ) + { this.connections = n.getConnectedSides(); + } else + { this.connections.clear(); + } } for( ForgeDirection of : this.connections ) diff --git a/src/main/java/appeng/parts/networking/PartDenseCable.java b/src/main/java/appeng/parts/networking/PartDenseCable.java index ffd5dcdf..a84f3de4 100644 --- a/src/main/java/appeng/parts/networking/PartDenseCable.java +++ b/src/main/java/appeng/parts/networking/PartDenseCable.java @@ -90,9 +90,13 @@ public class PartDenseCable extends PartCable { IGridNode n = this.getGridNode(); if( n != null ) + { this.connections = n.getConnectedSides(); + } else + { this.connections.clear(); + } } for( ForgeDirection of : this.connections ) @@ -222,7 +226,9 @@ public class PartDenseCable extends PartCable for( ForgeDirection of : this.connections ) { if( !this.isDense( of ) ) + { hasBuses = true; + } } if( sides.size() != 2 || !this.nonLinear( sides ) || hasBuses ) @@ -230,11 +236,17 @@ public class PartDenseCable extends PartCable for( ForgeDirection of : this.connections ) { if( this.isDense( of ) ) + { this.renderDenseConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); + } else if( this.isSmart( of ) ) + { this.renderSmartConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); + } else + { this.renderCoveredConnection( x, y, z, rh, renderer, this.channelsOnSide[of.ordinal()], of ); + } } rh.setTexture( this.getDenseTexture( this.getCableColor() ) ); @@ -388,9 +400,13 @@ public class PartDenseCable extends PartCable rh.setFacesToRender( EnumSet.complementOf( EnumSet.of( of, of.getOpposite() ) ) ); if( ghh != null && partHost != null && ghh.getCableConnectionType( of ) != AECableType.GLASS && partHost.getColor() != AEColor.Transparent && partHost.getPart( of.getOpposite() ) == null ) + { rh.setTexture( this.getTexture( myColor = partHost.getColor() ) ); + } else + { rh.setTexture( this.getTexture( this.getCableColor() ) ); + } switch( of ) { diff --git a/src/main/java/appeng/parts/networking/PartQuartzFiber.java b/src/main/java/appeng/parts/networking/PartQuartzFiber.java index 13ee23af..c2f2e116 100644 --- a/src/main/java/appeng/parts/networking/PartQuartzFiber.java +++ b/src/main/java/appeng/parts/networking/PartQuartzFiber.java @@ -188,7 +188,9 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider { IEnergyGrid eg = this.proxy.getEnergy(); if( !seen.contains( eg ) ) + { return eg.injectAEPower( amt, mode, seen ); + } } catch( GridAccessException e ) { @@ -199,7 +201,9 @@ public class PartQuartzFiber extends AEBasePart implements IEnergyGridProvider { IEnergyGrid eg = this.outerProxy.getEnergy(); if( !seen.contains( eg ) ) + { return eg.injectAEPower( amt, mode, seen ); + } } catch( GridAccessException e ) { diff --git a/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java b/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java index 3e350fee..538023c7 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java +++ b/src/main/java/appeng/parts/p2p/PartP2PIC2Power.java @@ -98,7 +98,9 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i public boolean acceptsEnergyFrom( TileEntity emitter, ForgeDirection direction ) { if( !this.output ) + { return direction == this.side; + } return false; } @@ -106,7 +108,9 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i public boolean emitsEnergyTo( TileEntity receiver, ForgeDirection direction ) { if( this.output ) + { return direction == this.side; + } return false; } @@ -114,7 +118,9 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i public double getDemandedEnergy() { if( this.output ) + { return 0; + } try { @@ -154,30 +160,42 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i } if( outs.isEmpty() ) + { return amount; + } LinkedList Options = new LinkedList(); for( PartP2PIC2Power o : outs ) { if( o.OutputEnergyA <= 0.01 ) + { Options.add( o ); + } } if( Options.isEmpty() ) { for( PartP2PIC2Power o : outs ) + { if( o.OutputEnergyB <= 0.01 ) + { Options.add( o ); + } + } } if( Options.isEmpty() ) { for( PartP2PIC2Power o : outs ) + { Options.add( o ); + } } if( Options.isEmpty() ) + { return amount; + } PartP2PIC2Power x = Platform.pickRandom( Options ); @@ -209,7 +227,9 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i public double getOfferedEnergy() { if( this.output ) + { return this.OutputEnergyA; + } return 0; } @@ -231,7 +251,9 @@ public class PartP2PIC2Power extends PartP2PTunnel implements i public int getSourceTier() { if( this.output ) + { return this.calculateTierFromVoltage( this.OutputVoltageA ); + } return 4; } diff --git a/src/main/java/appeng/parts/p2p/PartP2PItems.java b/src/main/java/appeng/parts/p2p/PartP2PItems.java index 8febadf6..b1b2ea5b 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PItems.java +++ b/src/main/java/appeng/parts/p2p/PartP2PItems.java @@ -81,7 +81,9 @@ public class PartP2PItems extends PartP2PTunnel implements IPipeCo this.cachedInv = null; PartP2PItems input = this.getInput(); if( input != null && this.output ) + { input.onTunnelNetworkChange(); + } } IInventory getDestination() @@ -89,7 +91,9 @@ public class PartP2PItems extends PartP2PTunnel implements IPipeCo this.requested = true; if( this.cachedInv != null ) + { return this.cachedInv; + } List outs = new LinkedList(); TunnelCollection itemTunnels; @@ -109,9 +113,13 @@ public class PartP2PItems extends PartP2PTunnel implements IPipeCo if( inv != null ) { if( Platform.getRandomInt() % 2 == 0 ) + { outs.add( inv ); + } else + { outs.add( 0, inv ); + } } } @@ -127,7 +135,9 @@ public class PartP2PItems extends PartP2PTunnel implements IPipeCo TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + this.side.offsetX, this.tile.yCoord + this.side.offsetY, this.tile.zCoord + this.side.offsetZ ); if( this.which.contains( this ) ) + { return null; + } this.which.add( this ); @@ -189,7 +199,9 @@ public class PartP2PItems extends PartP2PTunnel implements IPipeCo boolean wasReq = this.requested; if( this.requested && this.cachedInv != null ) + { ( (WrapperChainedInventory) this.cachedInv ).cycleOrder(); + } this.requested = false; return wasReq ? TickRateModulation.FASTER : TickRateModulation.SLOWER; @@ -264,7 +276,9 @@ public class PartP2PItems extends PartP2PTunnel implements IPipeCo { PartP2PItems input = this.getInput(); if( input != null ) + { input.getHost().notifyNeighbors(); + } } } @@ -273,7 +287,9 @@ public class PartP2PItems extends PartP2PTunnel implements IPipeCo { int[] slots = new int[this.getSizeInventory()]; for( int x = 0; x < this.getSizeInventory(); x++ ) + { slots[x] = x; + } return slots; } diff --git a/src/main/java/appeng/parts/p2p/PartP2PLight.java b/src/main/java/appeng/parts/p2p/PartP2PLight.java index a35324dd..6d935d4e 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PLight.java +++ b/src/main/java/appeng/parts/p2p/PartP2PLight.java @@ -87,7 +87,9 @@ public class PartP2PLight extends PartP2PTunnel implements IGridTi private boolean doWork() { if( this.output ) + { return false; + } TileEntity te = this.getTile(); World w = te.getWorldObj(); @@ -100,7 +102,9 @@ public class PartP2PLight extends PartP2PTunnel implements IGridTi try { for( PartP2PLight out : this.getOutputs() ) + { out.setLightLevel( this.lastValue ); + } } catch( GridAccessException e ) { @@ -119,14 +123,18 @@ public class PartP2PLight extends PartP2PTunnel implements IGridTi this.doWork(); if( this.output ) + { this.getHost().markForUpdate(); + } } @Override public int getLightLevel() { if( this.output && this.isPowered() ) + { return this.blockLight( this.lastValue ); + } return 0; } @@ -160,7 +168,9 @@ public class PartP2PLight extends PartP2PTunnel implements IGridTi { super.readFromNBT( tag ); if( tag.hasKey( "opacity" ) ) + { this.opacity = tag.getFloat( "opacity" ); + } this.lastValue = tag.getInteger( "lastValue" ); } @@ -185,12 +195,18 @@ public class PartP2PLight extends PartP2PTunnel implements IGridTi { PartP2PLight src = this.getInput(); if( src != null && src.proxy.isActive() ) + { this.setLightLevel( src.lastValue ); + } else + { this.getHost().markForUpdate(); + } } else + { this.doWork(); + } } @Override diff --git a/src/main/java/appeng/parts/p2p/PartP2PLiquids.java b/src/main/java/appeng/parts/p2p/PartP2PLiquids.java index 027a5659..67e67257 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PLiquids.java +++ b/src/main/java/appeng/parts/p2p/PartP2PLiquids.java @@ -80,7 +80,9 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl { PartP2PLiquids in = this.getInput(); if( in != null ) + { in.onTunnelNetworkChange(); + } } } @@ -90,8 +92,12 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl Stack stack = this.getDepth(); for( PartP2PLiquids t : stack ) + { if( t == this ) + { return 0; + } + } stack.push( this ); @@ -104,20 +110,30 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl PartP2PLiquids l = i.next(); IFluidHandler tank = l.getTarget(); if( tank != null ) + { l.tmpUsed = tank.fill( l.side.getOpposite(), resource.copy(), false ); + } else + { l.tmpUsed = 0; + } if( l.tmpUsed <= 0 ) + { i.remove(); + } else + { requestTotal += l.tmpUsed; + } } if( requestTotal <= 0 ) { if( stack.pop() != this ) + { throw new IllegalStateException( "Invalid Recursion detected." ); + } return 0; } @@ -125,7 +141,9 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl if( !doFill ) { if( stack.pop() != this ) + { throw new IllegalStateException( "Invalid Recursion detected." ); + } return Math.min( resource.amount, requestTotal ); } @@ -141,20 +159,28 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl FluidStack insert = resource.copy(); insert.amount = (int) Math.ceil( insert.amount * ( (double) l.tmpUsed / (double) requestTotal ) ); if( insert.amount > available ) + { insert.amount = available; + } IFluidHandler tank = l.getTarget(); if( tank != null ) + { l.tmpUsed = tank.fill( l.side.getOpposite(), insert.copy(), true ); + } else + { l.tmpUsed = 0; + } available -= insert.amount; used += insert.amount; } if( stack.pop() != this ) + { throw new IllegalStateException( "Invalid Recursion detected." ); + } return used; } @@ -164,7 +190,9 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl Stack s = DEPTH.get(); if( s == null ) + { DEPTH.set( s = new Stack() ); + } return s; } @@ -181,7 +209,9 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl if( handler != null ) { if( handler.canFill( l.side.getOpposite(), input ) ) + { outs.add( l ); + } } } } @@ -196,14 +226,20 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl IFluidHandler getTarget() { if( !this.proxy.isActive() ) + { return null; + } if( this.cachedTank != null ) + { return this.cachedTank; + } TileEntity te = this.tile.getWorldObj().getTileEntity( this.tile.xCoord + this.side.offsetX, this.tile.yCoord + this.side.offsetY, this.tile.zCoord + this.side.offsetZ ); if( te instanceof IFluidHandler ) + { return this.cachedTank = (IFluidHandler) te; + } return null; } @@ -236,7 +272,9 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl public FluidTankInfo[] getTankInfo( ForgeDirection from ) { if( from == this.side ) + { return this.getTank(); + } return new FluidTankInfo[0]; } @@ -246,14 +284,18 @@ public class PartP2PLiquids extends PartP2PTunnel implements IFl { PartP2PLiquids tun = this.getInput(); if( tun != null ) + { return ACTIVE_TANK; + } } else { try { if( !this.getOutputs().isEmpty() ) + { return ACTIVE_TANK; + } } catch( GridAccessException e ) { diff --git a/src/main/java/appeng/parts/p2p/PartP2PRFPower.java b/src/main/java/appeng/parts/p2p/PartP2PRFPower.java index 9c3fa655..1d49d2b7 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PRFPower.java +++ b/src/main/java/appeng/parts/p2p/PartP2PRFPower.java @@ -81,15 +81,21 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen public int receiveEnergy( ForgeDirection from, int maxReceive, boolean simulate ) { if( this.output ) + { return 0; + } if( this.isActive() ) { Stack stack = this.getDepth(); for( PartP2PRFPower t : stack ) + { if( t == this ) + { return 0; + } + } stack.push( this ); @@ -106,7 +112,9 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen total += receiver; if( maxReceive <= 0 ) + { break; + } } } @@ -119,7 +127,9 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen total += receiver; if( maxReceive <= 0 ) + { break; + } } } @@ -130,7 +140,9 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen } if( stack.pop() != this ) + { throw new IllegalStateException( "Invalid Recursion detected." ); + } return total; } @@ -143,7 +155,9 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen Stack s = THREAD_STACK.get(); if( s == null ) + { THREAD_STACK.set( s = new Stack() ); + } return s; } @@ -161,7 +175,9 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen } if( this.outputTarget == null || !this.outputTarget.canConnectEnergy( this.side.getOpposite() ) ) + { return NULL_HANDLER; + } return this.outputTarget; } @@ -172,15 +188,21 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen public int getEnergyStored( ForgeDirection from ) { if( this.output || !this.isActive() ) + { return 0; + } int total = 0; Stack stack = this.getDepth(); for( PartP2PRFPower t : stack ) + { if( t == this ) + { return 0; + } + } stack.push( this ); @@ -197,7 +219,9 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen } if( stack.pop() != this ) + { throw new IllegalStateException( "Invalid Recursion detected." ); + } return total; } @@ -206,15 +230,21 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen public int getMaxEnergyStored( ForgeDirection from ) { if( this.output || !this.isActive() ) + { return 0; + } int total = 0; Stack stack = this.getDepth(); for( PartP2PRFPower t : stack ) + { if( t == this ) + { return 0; + } + } stack.push( this ); @@ -231,7 +261,9 @@ public final class PartP2PRFPower extends PartP2PTunnel implemen } if( stack.pop() != this ) + { throw new IllegalStateException( "Invalid Recursion detected." ); + } return total; } diff --git a/src/main/java/appeng/parts/p2p/PartP2PRedstone.java b/src/main/java/appeng/parts/p2p/PartP2PRedstone.java index 30d92997..894a34ee 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PRedstone.java +++ b/src/main/java/appeng/parts/p2p/PartP2PRedstone.java @@ -61,14 +61,18 @@ public class PartP2PRedstone extends PartP2PTunnel { PartP2PRedstone in = this.getInput(); if( in != null ) + { this.putInput( in.power ); + } } } protected void putInput( Object o ) { if( this.recursive ) + { return; + } this.recursive = true; if( this.output && this.proxy.isActive() ) @@ -160,13 +164,17 @@ public class PartP2PRedstone extends PartP2PTunnel { int srcSide = this.side.ordinal(); if( b instanceof BlockRedstoneWire ) + { srcSide = 1; + } this.power = b.isProvidingStrongPower( this.tile.getWorldObj(), x, y, z, srcSide ); this.power = Math.max( this.power, b.isProvidingWeakPower( this.tile.getWorldObj(), x, y, z, srcSide ) ); this.sendToOutput( this.power ); } else + { this.sendToOutput( 0 ); + } } } diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java index 389cdfd6..dcfbee40 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnel.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnel.java @@ -84,14 +84,18 @@ public abstract class PartP2PTunnel extends PartBasicSt public T getInput() { if( this.freq == 0 ) + { return null; + } PartP2PTunnel tunnel; try { tunnel = this.proxy.getP2P().getInput( this.freq ); if( this.getClass().isInstance( tunnel ) ) + { return (T) tunnel; + } } catch( GridAccessException e ) { @@ -103,7 +107,9 @@ public abstract class PartP2PTunnel extends PartBasicSt public TunnelCollection getOutputs() throws GridAccessException { if( this.proxy.isActive() ) + { return (TunnelCollection) this.proxy.getP2P().getOutputs( this.freq, this.getClass() ); + } return new TunnelCollection( new ArrayList(), this.getClass() ); } @@ -179,7 +185,9 @@ public abstract class PartP2PTunnel extends PartBasicSt public ItemStack getItemStack( PartItemStack type ) { if( type == PartItemStack.World || type == PartItemStack.Network || type == PartItemStack.Wrench || type == PartItemStack.Pick ) + { return super.getItemStack( type ); + } final Optional maybeMEStack = AEApi.instance().definitions().parts().p2PTunnelME().maybeStack( 1 ); if( maybeMEStack.isPresent() ) @@ -380,7 +388,9 @@ public abstract class PartP2PTunnel extends PartBasicSt this.output = false; if( wasOutput || this.freq == 0 ) + { newFreq = System.currentTimeMillis(); + } try { diff --git a/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java b/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java index 821818db..bd2a3204 100644 --- a/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java +++ b/src/main/java/appeng/parts/p2p/PartP2PTunnelME.java @@ -180,7 +180,9 @@ public class PartP2PTunnelME extends PartP2PTunnel implements I if( connections.destroy ) { for( TunnelConnection cw : this.connection.connections.values() ) + { cw.c.destroy(); + } this.connection.connections.clear(); } diff --git a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java index 24e133da..738cf63a 100644 --- a/src/main/java/appeng/parts/reporting/PartConversionMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartConversionMonitor.java @@ -57,13 +57,19 @@ public class PartConversionMonitor extends PartStorageMonitor public boolean onPartShiftActivate( EntityPlayer player, Vec3 pos ) { if( Platform.isClient() ) + { return true; + } if( !this.proxy.isActive() ) + { return false; + } if( !Platform.hasPermissions( this.getLocation(), player ) ) + { return false; + } boolean ModeB = false; @@ -79,7 +85,9 @@ public class PartConversionMonitor extends PartStorageMonitor try { if( !this.proxy.isActive() ) + { return false; + } IEnergySource energy = this.proxy.getEnergy(); IMEMonitor cell = this.proxy.getStorage().getItemInventory(); @@ -122,7 +130,9 @@ public class PartConversionMonitor extends PartStorageMonitor try { if( !this.proxy.isActive() ) + { return; + } IEnergySource energy = this.proxy.getEnergy(); IMEMonitor cell = this.proxy.getStorage().getItemInventory(); @@ -144,7 +154,9 @@ public class PartConversionMonitor extends PartStorageMonitor } if( player.openContainer != null ) + { player.openContainer.detectAndSendChanges(); + } } } catch( GridAccessException e ) diff --git a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java index 840d14be..f58ed834 100644 --- a/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartCraftingTerminal.java @@ -54,8 +54,12 @@ public class PartCraftingTerminal extends PartTerminal super.getDrops( drops, wrenched ); for( ItemStack is : this.craftingGrid ) + { if( is != null ) + { drops.add( is ); + } + } } @Override @@ -86,7 +90,9 @@ public class PartCraftingTerminal extends PartTerminal } if( GuiBridge.GUI_CRAFTING_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) ) + { return GuiBridge.GUI_CRAFTING_TERMINAL; + } return GuiBridge.GUI_ME; } @@ -100,7 +106,9 @@ public class PartCraftingTerminal extends PartTerminal public IInventory getInventoryByName( String name ) { if( name.equals( "crafting" ) ) + { return this.craftingGrid; + } return super.getInventoryByName( name ); } } diff --git a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java index a48a9635..6726c60a 100644 --- a/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartInterfaceTerminal.java @@ -47,7 +47,9 @@ public class PartInterfaceTerminal extends PartMonitor if( !player.isSneaking() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( player, this.getHost().getTile(), this.side, GuiBridge.GUI_INTERFACE_TERMINAL ); diff --git a/src/main/java/appeng/parts/reporting/PartMonitor.java b/src/main/java/appeng/parts/reporting/PartMonitor.java index 78db3209..8d54b53a 100644 --- a/src/main/java/appeng/parts/reporting/PartMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartMonitor.java @@ -80,14 +80,18 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann this.proxy.setIdlePowerUsage( 1.0 / 2.0 ); } else + { this.proxy.setIdlePowerUsage( 1.0 / 16.0 ); // lights drain a little bit. + } } @MENetworkEventSubscribe public void bootingRender( MENetworkBootingStatusChange c ) { if( this.notLightSource ) + { this.getHost().markForUpdate(); + } } @MENetworkEventSubscribe @@ -210,9 +214,13 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann try { if( Platform.isServer() ) + { return this.proxy.getEnergy().isNetworkPowered(); + } else + { return ( ( this.clientFlags & this.POWERED_FLAG ) == this.POWERED_FLAG ); + } } catch( GridAccessException e ) { @@ -232,7 +240,9 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann { super.readFromNBT( data ); if( data.hasKey( "opacity" ) ) + { this.opacity = data.getFloat( "opacity" ); + } this.spin = data.getByte( "spin" ); } @@ -253,13 +263,19 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann try { if( this.proxy.getEnergy().isNetworkPowered() ) + { this.clientFlags |= this.POWERED_FLAG; + } if( this.proxy.getPath().isNetworkBooting() ) + { this.clientFlags |= this.BOOTING_FLAG; + } if( this.proxy.getNode().meetsChannelRequirements() ) + { this.clientFlags |= this.CHANNEL_FLAG; + } } catch( GridAccessException e ) { @@ -277,7 +293,9 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann this.clientFlags = data.readByte(); this.spin = (byte) ( this.clientFlags & 3 ); if( this.clientFlags == oldFlags ) + { return false; + } return true; } @@ -297,7 +315,9 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann if( Platform.isServer() ) { if( this.spin > 3 ) + { this.spin = 0; + } switch( this.spin ) { @@ -321,7 +341,9 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann return true; } else + { return super.onPartActivate( player, pos ); + } } @Override @@ -331,17 +353,25 @@ public class PartMonitor extends AEBasePart implements IPartMonitor, IPowerChann byte rotation = (byte) ( MathHelper.floor_double( ( player.rotationYaw * 4F ) / 360F + 2.5D ) & 3 ); if( side == ForgeDirection.UP ) + { this.spin = rotation; + } else if( side == ForgeDirection.DOWN ) + { this.spin = rotation; + } } @Override public boolean isActive() { if( this.notLightSource ) + { return ( ( this.clientFlags & ( this.CHANNEL_FLAG | this.POWERED_FLAG ) ) == ( this.CHANNEL_FLAG | this.POWERED_FLAG ) ); + } else + { return this.isPowered(); + } } } diff --git a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java index 523b4ec0..a4972407 100644 --- a/src/main/java/appeng/parts/reporting/PartPatternTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartPatternTerminal.java @@ -58,8 +58,12 @@ public class PartPatternTerminal extends PartTerminal public void getDrops( List drops, boolean wrenched ) { for( ItemStack is : this.pattern ) + { if( is != null ) + { drops.add( is ); + } + } } @Override @@ -96,7 +100,9 @@ public class PartPatternTerminal extends PartTerminal } if( GuiBridge.GUI_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.side, p ) ) + { return GuiBridge.GUI_PATTERN_TERMINAL; + } return GuiBridge.GUI_ME; } @@ -144,7 +150,9 @@ public class PartPatternTerminal extends PartTerminal { ItemStack is = this.crafting.getStackInSlot( x ); if( is != null ) + { is.stackSize = 1; + } } } } @@ -164,13 +172,19 @@ public class PartPatternTerminal extends PartTerminal public IInventory getInventoryByName( String name ) { if( name.equals( "crafting" ) ) + { return this.crafting; + } if( name.equals( "output" ) ) + { return this.output; + } if( name.equals( "pattern" ) ) + { return this.pattern; + } return super.getInventoryByName( name ); } diff --git a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java index c2bce2e7..f49a4948 100644 --- a/src/main/java/appeng/parts/reporting/PartStorageMonitor.java +++ b/src/main/java/appeng/parts/reporting/PartStorageMonitor.java @@ -113,7 +113,9 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit NBTTagCompound myItem = new NBTTagCompound(); if( this.configuredItem != null ) + { this.configuredItem.writeToNBT( myItem ); + } data.setTag( "configuredItem", myItem ); } @@ -127,7 +129,9 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit data.writeBoolean( this.isLocked ); data.writeBoolean( this.configuredItem != null ); if( this.configuredItem != null ) + { this.configuredItem.writeToPacket( data ); + } } @Override @@ -139,9 +143,13 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit this.isLocked = data.readBoolean(); boolean val = data.readBoolean(); if( val ) + { this.configuredItem = AEItemStack.loadItemStackFromPacket( data ); + } else + { this.configuredItem = null; + } this.updateList = true; @@ -152,13 +160,19 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit public boolean onPartActivate( EntityPlayer player, Vec3 pos ) { if( Platform.isClient() ) + { return true; + } if( !this.proxy.isActive() ) + { return false; + } if( !Platform.hasPermissions( this.getLocation(), player ) ) + { return false; + } TileEntity te = this.tile; ItemStack eq = player.getCurrentEquippedItem(); @@ -175,7 +189,9 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit this.getHost().markForUpdate(); } else + { this.extractItem( player ); + } return true; } @@ -184,14 +200,18 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit public void configureWatchers() { if( this.myWatcher != null ) + { this.myWatcher.clear(); + } try { if( this.configuredItem != null ) { if( this.myWatcher != null ) + { this.myWatcher.add( this.configuredItem ); + } this.updateReportingValue( this.proxy.getStorage().getItemInventory() ); } @@ -213,9 +233,13 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit { IAEItemStack result = itemInventory.getStorageList().findPrecise( this.configuredItem ); if( result == null ) + { this.configuredItem.setStackSize( 0 ); + } else + { this.configuredItem.setStackSize( result.getStackSize() ); + } } } @@ -225,7 +249,9 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit { super.finalize(); if( this.dspList != null ) + { GLAllocation.deleteDisplayLists( this.dspList ); + } } @Override @@ -233,12 +259,16 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit public void renderDynamic( double x, double y, double z, IPartRenderHelper rh, RenderBlocks renderer ) { if( this.dspList == null ) + { this.dspList = GLAllocation.generateDisplayLists( 1 ); + } Tessellator tess = Tessellator.instance; if( ( this.clientFlags & ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) != ( this.POWERED_FLAG | this.CHANNEL_FLAG ) ) + { return; + } IAEItemStack ais = (IAEItemStack) this.getDisplayed(); if( ais != null ) @@ -254,7 +284,9 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit GL11.glEndList(); } else + { GL11.glCallList( this.dspList ); + } GL11.glPopMatrix(); } @@ -375,9 +407,13 @@ public class PartStorageMonitor extends PartMonitor implements IPartStorageMonit if( this.configuredItem != null ) { if( fullStack == null ) + { this.configuredItem.setStackSize( 0 ); + } else + { this.configuredItem.setStackSize( fullStack.getStackSize() ); + } this.getHost().markForUpdate(); } diff --git a/src/main/java/appeng/parts/reporting/PartTerminal.java b/src/main/java/appeng/parts/reporting/PartTerminal.java index 17c18208..efcfdc90 100644 --- a/src/main/java/appeng/parts/reporting/PartTerminal.java +++ b/src/main/java/appeng/parts/reporting/PartTerminal.java @@ -72,8 +72,12 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM super.getDrops( drops, wrenched ); for( ItemStack is : this.viewCell ) + { if( is != null ) + { drops.add( is ); + } + } } @Override @@ -106,7 +110,9 @@ public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigM if( !player.isSneaking() ) { if( Platform.isClient() ) + { return true; + } Platform.openGUI( player, this.getHost().getTile(), this.side, this.getGui( player ) ); diff --git a/src/main/java/appeng/recipes/AEItemResolver.java b/src/main/java/appeng/recipes/AEItemResolver.java index f02f204e..a89abfa9 100644 --- a/src/main/java/appeng/recipes/AEItemResolver.java +++ b/src/main/java/appeng/recipes/AEItemResolver.java @@ -104,11 +104,17 @@ public class AEItemResolver implements ISubItemResolver if( itemName.startsWith( "ItemCrystalSeed." ) ) { if( itemName.equalsIgnoreCase( "ItemCrystalSeed.Certus" ) ) + { return ItemCrystalSeed.getResolver( ItemCrystalSeed.Certus ); + } if( itemName.equalsIgnoreCase( "ItemCrystalSeed.Nether" ) ) + { return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Nether ); + } if( itemName.equalsIgnoreCase( "ItemCrystalSeed.Fluix" ) ) + { return new ResolverResult( "ItemCrystalSeed", ItemCrystalSeed.Fluix ); + } return null; } @@ -119,7 +125,9 @@ public class AEItemResolver implements ISubItemResolver MaterialType mt = MaterialType.valueOf( materialName ); // itemName = itemName.substring( 0, itemName.indexOf( "." ) ); if( mt.itemInstance == ItemMultiMaterial.instance && mt.damageValue >= 0 && mt.isRegistered() ) + { return new ResolverResult( "ItemMultiMaterial", mt.damageValue ); + } } if( itemName.startsWith( "ItemPart." ) ) @@ -129,7 +137,9 @@ public class AEItemResolver implements ISubItemResolver // itemName = itemName.substring( 0, itemName.indexOf( "." ) ); int dVal = ItemMultiPart.instance.getDamageByType( pt ); if( dVal >= 0 ) + { return new ResolverResult( "ItemMultiPart", dVal ); + } } } @@ -150,7 +160,9 @@ public class AEItemResolver implements ISubItemResolver } if( col == AEColor.Transparent ) + { return null; + } ItemStack is = partType.stack( col, 1 ); return new ResolverResult( "ItemPaintBall", ( lumen ? 20 : 0 ) + is.getItemDamage() ); diff --git a/src/main/java/appeng/recipes/GroupIngredient.java b/src/main/java/appeng/recipes/GroupIngredient.java index 639f94b1..96079123 100644 --- a/src/main/java/appeng/recipes/GroupIngredient.java +++ b/src/main/java/appeng/recipes/GroupIngredient.java @@ -47,8 +47,12 @@ public class GroupIngredient implements IIngredient this.name = myName; for( IIngredient I : ingredients ) + { if( I.isAir() ) + { throw new RecipeError( "Cannot include air in a group." ); + } + } this.ingredients = ingredients; } @@ -70,10 +74,14 @@ public class GroupIngredient implements IIngredient public ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError { if( this.baked != null ) + { return this.baked; + } if( this.isInside ) + { return new ItemStack[0]; + } List out = new LinkedList(); this.isInside = true; @@ -97,10 +105,14 @@ public class GroupIngredient implements IIngredient } if( out.size() == 0 ) + { throw new MissingIngredientError( this.toString() + " - group could not be resolved to any items." ); + } for( ItemStack is : out ) + { is.stackSize = this.qty; + } return out.toArray( new ItemStack[out.size()] ); } diff --git a/src/main/java/appeng/recipes/Ingredient.java b/src/main/java/appeng/recipes/Ingredient.java index 58685d21..7bee0b85 100644 --- a/src/main/java/appeng/recipes/Ingredient.java +++ b/src/main/java/appeng/recipes/Ingredient.java @@ -79,7 +79,9 @@ public class Ingredient implements IIngredient if( this.nameSpace.equals( "oreDictionary" ) ) { if( parts.length == 3 ) + { throw new RecipeError( "Cannot specify meta when using ore dictionary." ); + } sel = OreDictionary.WILDCARD_VALUE; } else @@ -128,7 +130,9 @@ public class Ingredient implements IIngredient this.itemName = tmpName; } else + { throw new RecipeError( input + " : Needs at least Namespace and Name." ); + } handler.data.knownItem.add( this.toString() ); } @@ -143,28 +147,40 @@ public class Ingredient implements IIngredient public ItemStack getItemStack() throws RegistrationError, MissingIngredientError { if( this.isAir ) + { throw new RegistrationError( "Found blank item and expected a real item." ); + } if( this.nameSpace.equalsIgnoreCase( "oreDictionary" ) ) + { throw new RegistrationError( "Recipe format expected a single item, but got a set of items." ); + } Block blk = GameRegistry.findBlock( this.nameSpace, this.itemName ); if( blk == null ) + { blk = GameRegistry.findBlock( this.nameSpace, "tile." + this.itemName ); + } if( blk != null ) { Item it = Item.getItemFromBlock( blk ); if( it != null ) + { return this.MakeItemStack( it, this.qty, this.meta, this.nbt ); + } } Item it = GameRegistry.findItem( this.nameSpace, this.itemName ); if( it == null ) + { it = GameRegistry.findItem( this.nameSpace, "item." + this.itemName ); + } if( it != null ) + { return this.MakeItemStack( it, this.qty, this.meta, this.nbt ); + } /* * Object o = Item.itemRegistry.getObject( nameSpace + ":" + itemName ); if ( o instanceof Item ) return new @@ -193,7 +209,9 @@ public class Ingredient implements IIngredient public ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError { if( this.baked != null ) + { return this.baked; + } if( this.nameSpace.equalsIgnoreCase( "oreDictionary" ) ) { @@ -209,7 +227,9 @@ public class Ingredient implements IIngredient } if( set.length == 0 ) + { throw new MissingIngredientError( this.itemName + " - ore dictionary could not be resolved to any items." ); + } return set; } diff --git a/src/main/java/appeng/recipes/IngredientSet.java b/src/main/java/appeng/recipes/IngredientSet.java index 5023b0e1..fbb849a2 100644 --- a/src/main/java/appeng/recipes/IngredientSet.java +++ b/src/main/java/appeng/recipes/IngredientSet.java @@ -56,19 +56,27 @@ public class IngredientSet implements IIngredient public ItemStack[] getItemStackSet() throws RegistrationError, MissingIngredientError { if( this.baked != null ) + { return this.baked; + } if( this.isInside ) + { return new ItemStack[0]; + } List out = new LinkedList(); out.addAll( this.items ); if( out.size() == 0 ) + { throw new MissingIngredientError( this.toString() + " - group could not be resolved to any items." ); + } for( ItemStack is : out ) + { is.stackSize = this.qty; + } return out.toArray( new ItemStack[out.size()] ); } diff --git a/src/main/java/appeng/recipes/RecipeHandler.java b/src/main/java/appeng/recipes/RecipeHandler.java index c516186e..a964922a 100644 --- a/src/main/java/appeng/recipes/RecipeHandler.java +++ b/src/main/java/appeng/recipes/RecipeHandler.java @@ -118,7 +118,9 @@ public class RecipeHandler implements IRecipeHandler String realName = id.modId + ':' + id.name; if( !id.modId.equals( AppEng.MOD_ID ) && !id.modId.equals( "minecraft" ) ) + { throw new RecipeError( "Not applicable for website" ); + } final IDefinitions definitions = AEApi.instance().definitions(); final IItems items = definitions.items(); @@ -134,11 +136,17 @@ public class RecipeHandler implements IRecipeHandler { int dmg = is.getItemDamage(); if( dmg < ItemCrystalSeed.Nether ) + { realName += ".Certus"; + } else if( dmg < ItemCrystalSeed.Fluix ) + { realName += ".Nether"; + } else if( dmg < ItemCrystalSeed.END ) + { realName += ".Fluix"; + } } else if( maybeSkyStoneItem.isPresent() && is.getItem() == maybeSkyStoneItem.get() ) { @@ -203,7 +211,9 @@ public class RecipeHandler implements IRecipeHandler realName += '.' + ( (ItemMultiPart) is.getItem() ).getTypeByStack( is ).name(); } else if( is.getItemDamage() > 0 ) + { realName += "." + is.getItemDamage(); + } return realName; } @@ -213,7 +223,9 @@ public class RecipeHandler implements IRecipeHandler String out = this.data.aliases.get( in ); if( out != null ) + { return out; + } return in; } @@ -232,7 +244,9 @@ public class RecipeHandler implements IRecipeHandler { AELog.warning( "Error Loading Recipe File:" + path ); if( this.data.exceptions ) + { AELog.error( err ); + } return; } @@ -248,12 +262,16 @@ public class RecipeHandler implements IRecipeHandler char c = (char) val; if( c == '\n' ) + { line++; + } if( inComment ) { if( c == '\n' || c == '\r' ) + { inComment = false; + } } else if( inQuote ) { @@ -288,7 +306,9 @@ public class RecipeHandler implements IRecipeHandler this.processTokens( loader, path, line ); if( token.length() > 0 ) + { this.tokens.add( token ); + } token = ""; break; @@ -303,7 +323,9 @@ public class RecipeHandler implements IRecipeHandler case ' ': if( token.length() > 0 ) + { this.tokens.add( token ); + } token = ""; break; @@ -314,7 +336,9 @@ public class RecipeHandler implements IRecipeHandler } if( token.length() > 0 ) + { this.tokens.add( token ); + } reader.close(); this.processTokens( loader, path, line ); @@ -323,7 +347,9 @@ public class RecipeHandler implements IRecipeHandler { AELog.error( e ); if( this.data.crash ) + { throw new IllegalStateException( e ); + } } } @@ -331,7 +357,9 @@ public class RecipeHandler implements IRecipeHandler public void injectRecipes() { if( cpw.mods.fml.common.Loader.instance().hasReachedState( LoaderState.POSTINITIALIZATION ) ) + { throw new IllegalStateException( "Recipes must now be loaded in Init." ); + } HashMap processed = new HashMap(); try @@ -345,17 +373,25 @@ public class RecipeHandler implements IRecipeHandler Class clz = ch.getClass(); Integer i = processed.get( clz ); if( i == null ) + { processed.put( clz, 1 ); + } else + { processed.put( clz, i + 1 ); + } } catch( RegistrationError e ) { AELog.warning( "Unable to register a recipe: " + e.getMessage() ); if( this.data.exceptions ) + { AELog.error( e ); + } if( this.data.crash ) + { throw e; + } } catch( MissingIngredientError e ) { @@ -363,9 +399,13 @@ public class RecipeHandler implements IRecipeHandler { AELog.warning( "Unable to register a recipe:" + e.getMessage() ); if( this.data.exceptions ) + { AELog.error( e ); + } if( this.data.crash ) + { throw e; + } } } } @@ -373,9 +413,13 @@ public class RecipeHandler implements IRecipeHandler catch( Throwable e ) { if( this.data.exceptions ) + { AELog.error( e ); + } if( this.data.crash ) + { throw new IllegalStateException( e ); + } } for( Entry e : processed.entrySet() ) @@ -403,7 +447,9 @@ public class RecipeHandler implements IRecipeHandler String realName = this.getName( is ); List recipes = this.findRecipe( is ); if( !recipes.isEmpty() ) + { combined.putAll( realName, recipes ); + } } } catch( RecipeError ignored ) @@ -482,7 +528,9 @@ public class RecipeHandler implements IRecipeHandler IRecipeHandlerRegistry cr = AEApi.instance().registries().recipes(); if( this.tokens.isEmpty() ) + { return; + } int split = this.tokens.indexOf( "->" ); if( split != -1 ) @@ -492,9 +540,13 @@ public class RecipeHandler implements IRecipeHandler if( operation.equals( "alias" ) ) { if( this.tokens.size() == 3 && this.tokens.indexOf( "->" ) == 1 ) + { this.data.aliases.put( this.tokens.get( 0 ), this.tokens.get( 2 ) ); + } else + { throw new RecipeError( "Alias must have exactly 1 input and 1 output." ); + } } else if( operation.equals( "group" ) ) { @@ -508,7 +560,9 @@ public class RecipeHandler implements IRecipeHandler this.data.groups.put( post.get( 0 ), new GroupIngredient( post.get( 0 ), inputs.get( 0 ) ) ); } else + { throw new RecipeError( "Group must have exactly 1 output, and 1 or more inputs." ); + } } else if( operation.equals( "ore" ) ) { @@ -523,7 +577,9 @@ public class RecipeHandler implements IRecipeHandler this.addCrafting( ch ); } else + { throw new RecipeError( "Group must have exactly 1 output, and 1 or more inputs in a single row." ); + } } else { @@ -541,7 +597,9 @@ public class RecipeHandler implements IRecipeHandler this.addCrafting( ch ); } else + { throw new RecipeError( "Invalid crafting type: " + operation ); + } } } else @@ -555,7 +613,9 @@ public class RecipeHandler implements IRecipeHandler this.data.exceptions = this.tokens.get( 0 ).equals( "true" ); } else + { throw new RecipeError( "exceptions must be true or false explicitly." ); + } } else if( operation.equals( "crash" ) && ( this.tokens.get( 0 ).equals( "true" ) || this.tokens.get( 0 ).equals( "false" ) ) ) { @@ -564,7 +624,9 @@ public class RecipeHandler implements IRecipeHandler this.data.crash = this.tokens.get( 0 ).equals( "true" ); } else + { throw new RecipeError( "crash must be true or false explicitly." ); + } } else if( operation.equals( "erroronmissing" ) ) { @@ -573,26 +635,38 @@ public class RecipeHandler implements IRecipeHandler this.data.errorOnMissing = this.tokens.get( 0 ).equals( "true" ); } else + { throw new RecipeError( "erroronmissing must be true or false explicitly." ); + } } else if( operation.equals( "import" ) ) { if( this.tokens.size() == 1 ) + { ( new RecipeHandler( this ) ).parseRecipes( loader, this.tokens.get( 0 ) ); + } else + { throw new RecipeError( "Import must have exactly 1 input." ); + } } else + { throw new RecipeError( operation + ": " + this.tokens.toString() + "; recipe without an output." ); + } } } catch( RecipeError e ) { AELog.warning( "Recipe Error '" + e.getMessage() + "' near line:" + line + " in " + file + " with: " + this.tokens.toString() ); if( this.data.exceptions ) + { AELog.error( e ); + } if( this.data.crash ) + { throw e; + } } this.tokens.clear(); @@ -611,9 +685,13 @@ public class RecipeHandler implements IRecipeHandler if( v.equals( "," ) ) { if( hasQty ) + { throw new RecipeError( "Qty found with no item." ); + } if( !cList.isEmpty() ) + { out.add( cList ); + } cList = new LinkedList(); } else @@ -621,7 +699,9 @@ public class RecipeHandler implements IRecipeHandler if( this.isNumber( v ) ) { if( hasQty ) + { throw new RecipeError( "Qty found with no item." ); + } hasQty = true; qty = Integer.parseInt( v ); } @@ -633,13 +713,17 @@ public class RecipeHandler implements IRecipeHandler hasQty = false; } else + { cList.add( this.findIngredient( v, 1 ) ); + } } } } if( !cList.isEmpty() ) + { out.add( cList ); + } return out; } @@ -649,7 +733,9 @@ public class RecipeHandler implements IRecipeHandler GroupIngredient gi = this.data.groups.get( v ); if( gi != null ) + { return gi.copy( qty ); + } try { @@ -664,13 +750,17 @@ public class RecipeHandler implements IRecipeHandler private boolean isNumber( String v ) { if( v.length() <= 0 ) + { return false; + } int l = v.length(); for( int x = 0; x < l; x++ ) { if( !Character.isDigit( v.charAt( x ) ) ) + { return false; + } } return true; diff --git a/src/main/java/appeng/recipes/game/DisassembleRecipe.java b/src/main/java/appeng/recipes/game/DisassembleRecipe.java index bf16646b..9bb4b740 100644 --- a/src/main/java/appeng/recipes/game/DisassembleRecipe.java +++ b/src/main/java/appeng/recipes/game/DisassembleRecipe.java @@ -93,7 +93,9 @@ public final class DisassembleRecipe implements IRecipe // needs a single input in the recipe itemCount++; if ( itemCount > 1 ) + { return MISMATCHED_STACK; + } // handle storage cells for( ItemStack storageCellStack : this.getCellOutput( stackInSlot ).asSet() ) @@ -104,7 +106,9 @@ public final class DisassembleRecipe implements IRecipe { IItemList list = cellInv.getAvailableItems( StorageChannel.ITEMS.createList() ); if( !list.isEmpty() ) + { return null; + } } output = storageCellStack; diff --git a/src/main/java/appeng/recipes/game/FacadeRecipe.java b/src/main/java/appeng/recipes/game/FacadeRecipe.java index 4b721554..b0bdbf52 100644 --- a/src/main/java/appeng/recipes/game/FacadeRecipe.java +++ b/src/main/java/appeng/recipes/game/FacadeRecipe.java @@ -69,7 +69,9 @@ public final class FacadeRecipe implements IRecipe ItemStack facades = facade.createFacadeForItem( inv.getStackInSlot( 4 ), !createFacade ); if( facades != null && createFacade ) + { facades.stackSize = 4; + } return facades; } } diff --git a/src/main/java/appeng/recipes/game/ShapedRecipe.java b/src/main/java/appeng/recipes/game/ShapedRecipe.java index 8ae18fa8..50062fe5 100644 --- a/src/main/java/appeng/recipes/game/ShapedRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapedRecipe.java @@ -144,7 +144,9 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable public boolean matches( InventoryCrafting inv, World world ) { if( this.disable ) + { return false; + } for( int x = 0; x <= MAX_CRAFT_GRID_WIDTH - this.width; x++ ) { @@ -187,7 +189,9 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable private boolean checkMatch( InventoryCrafting inv, int startX, int startY, boolean mirror ) { if( this.disable ) + { return false; + } for( int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++ ) { @@ -310,7 +314,9 @@ public class ShapedRecipe implements IRecipe, IRecipeBakeable for( Object o : this.input ) { if( o instanceof IIngredient ) + { ( (IIngredient) o ).bake(); + } } } catch( MissingIngredientError err ) diff --git a/src/main/java/appeng/recipes/game/ShapelessRecipe.java b/src/main/java/appeng/recipes/game/ShapelessRecipe.java index 8b7fcdb4..0d599994 100644 --- a/src/main/java/appeng/recipes/game/ShapelessRecipe.java +++ b/src/main/java/appeng/recipes/game/ShapelessRecipe.java @@ -71,7 +71,9 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable public boolean matches( InventoryCrafting var1, World world ) { if( this.disable ) + { return false; + } ArrayList required = new ArrayList( this.input ); @@ -167,7 +169,9 @@ public class ShapelessRecipe implements IRecipe, IRecipeBakeable for( Object o : this.input ) { if( o instanceof IIngredient ) + { ( (IIngredient) o ).bake(); + } } } catch( MissingIngredientError e ) diff --git a/src/main/java/appeng/recipes/handlers/Grind.java b/src/main/java/appeng/recipes/handlers/Grind.java index 308530bc..7bdd058c 100644 --- a/src/main/java/appeng/recipes/handlers/Grind.java +++ b/src/main/java/appeng/recipes/handlers/Grind.java @@ -59,7 +59,9 @@ public class Grind implements ICraftHandler, IWebsiteSerializer public void register() throws RegistrationError, MissingIngredientError { for( ItemStack is : this.pro_input.getItemStackSet() ) + { AEApi.instance().registries().grinder().addRecipe( is, this.pro_output[0].getItemStack(), 8 ); + } } @Override diff --git a/src/main/java/appeng/recipes/handlers/Inscribe.java b/src/main/java/appeng/recipes/handlers/Inscribe.java index 620a6b7f..46523b10 100644 --- a/src/main/java/appeng/recipes/handlers/Inscribe.java +++ b/src/main/java/appeng/recipes/handlers/Inscribe.java @@ -47,9 +47,13 @@ public final class Inscribe extends InscriberProcess public void register() throws RegistrationError, MissingIngredientError { if ( this.getImprintable() == null ) + { return; + } if ( this.getOutput() == null ) + { return; + } final ItemStack[] realInput = this.getImprintable().getItemStackSet(); final List inputs = new ArrayList( realInput.length ); diff --git a/src/main/java/appeng/recipes/handlers/InscriberProcess.java b/src/main/java/appeng/recipes/handlers/InscriberProcess.java index 8f8d2ed3..84c1216a 100644 --- a/src/main/java/appeng/recipes/handlers/InscriberProcess.java +++ b/src/main/java/appeng/recipes/handlers/InscriberProcess.java @@ -49,15 +49,21 @@ public abstract class InscriberProcess implements ICraftHandler, IWebsiteSeriali this.topOptional = input.get( 0 ).get( 1 ); if( input.get( 0 ).size() > 2 ) + { this.botOptional = input.get( 0 ).get( 2 ); + } this.output = output.get( 0 ).get( 0 ); } else + { throw new RecipeError( "Inscriber recipes cannot have rows, and must have more then one input." ); + } } else + { throw new RecipeError( "Inscriber recipes must produce a single output." ); + } } @Override @@ -78,13 +84,19 @@ public abstract class InscriberProcess implements ICraftHandler, IWebsiteSeriali } if( this.topOptional != null ) + { pattern += handler.getName( this.topOptional ) + '\n'; + } if ( this.imprintable != null ) + { pattern += handler.getName( this.imprintable ); + } if( this.botOptional != null ) + { pattern += '\n' + handler.getName( this.botOptional ); + } return pattern; } diff --git a/src/main/java/appeng/recipes/handlers/Press.java b/src/main/java/appeng/recipes/handlers/Press.java index 5ccaceae..ccbdb530 100644 --- a/src/main/java/appeng/recipes/handlers/Press.java +++ b/src/main/java/appeng/recipes/handlers/Press.java @@ -47,9 +47,13 @@ public final class Press extends InscriberProcess public void register() throws RegistrationError, MissingIngredientError { if ( this.getImprintable() == null ) + { return; + } if ( this.getOutput() == null ) + { return; + } final ItemStack[] realInput = this.getImprintable().getItemStackSet(); final List inputs = new ArrayList( realInput.length ); diff --git a/src/main/java/appeng/recipes/handlers/Shaped.java b/src/main/java/appeng/recipes/handlers/Shaped.java index ea5db3d9..2b710601 100644 --- a/src/main/java/appeng/recipes/handlers/Shaped.java +++ b/src/main/java/appeng/recipes/handlers/Shaped.java @@ -68,13 +68,19 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer this.output = output.get( 0 ).get( 0 ); } else + { throw new RecipeError( "Crafting recipes must have 1-3 columns." ); + } } else + { throw new RecipeError( "shaped crafting recipes must have 1-3 rows." ); + } } else + { throw new RecipeError( "Crafting must produce a single output." ); + } } @Override @@ -89,7 +95,9 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer for( int x = 0; x < this.cols; x++ ) { if( this.inputs.get( y ).get( x ).isAir() ) + { row.append( ' ' ); + } else { row.append( first ); @@ -123,15 +131,21 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer o += h.getName( this.output ) + '\n'; for( int y = 0; y < this.rows; y++ ) + { for( int x = 0; x < this.cols; x++ ) { IIngredient i = this.inputs.get( y ).get( x ); if( i.isAir() ) + { o += "air" + ( x + 1 == this.cols ? "\n" : " " ); + } else + { o += h.getName( i ) + ( x + 1 == this.cols ? "\n" : " " ); + } } + } return o.trim(); } @@ -140,6 +154,7 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer public boolean canCraft( ItemStack reqOutput ) throws RegistrationError, MissingIngredientError { for( int y = 0; y < this.rows; y++ ) + { for( int x = 0; x < this.cols; x++ ) { IIngredient i = this.inputs.get( y ).get( x ); @@ -149,10 +164,13 @@ public class Shaped implements ICraftHandler, IWebsiteSerializer for( ItemStack r : i.getItemStackSet() ) { if( Platform.isSameItemPrecise( r, reqOutput ) ) + { return false; + } } } } + } return Platform.isSameItemPrecise( this.output.getItemStack(), reqOutput ); } diff --git a/src/main/java/appeng/recipes/handlers/Shapeless.java b/src/main/java/appeng/recipes/handlers/Shapeless.java index 5ee59ada..6881dbf6 100644 --- a/src/main/java/appeng/recipes/handlers/Shapeless.java +++ b/src/main/java/appeng/recipes/handlers/Shapeless.java @@ -54,10 +54,14 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer this.output = output.get( 0 ).get( 0 ); } else + { throw new RecipeError( "Shapeless crafting recipes cannot have rows." ); + } } else + { throw new RecipeError( "Crafting must produce a single output." ); + } } @Override @@ -65,7 +69,9 @@ public class Shapeless implements ICraftHandler, IWebsiteSerializer { List args = new ArrayList(); for( IIngredient i : this.inputs ) + { args.add( i ); + } ItemStack outIS = this.output.getItemStack(); diff --git a/src/main/java/appeng/recipes/handlers/Smelt.java b/src/main/java/appeng/recipes/handlers/Smelt.java index ef679767..810961f4 100644 --- a/src/main/java/appeng/recipes/handlers/Smelt.java +++ b/src/main/java/appeng/recipes/handlers/Smelt.java @@ -61,10 +61,14 @@ public class Smelt implements ICraftHandler, IWebsiteSerializer public void register() throws RegistrationError, MissingIngredientError { if( this.in.getItemStack().getItem() == null ) + { throw new RegistrationError( this.in.toString() + ": Smelting Input is not a valid item." ); + } if( this.out.getItemStack().getItem() == null ) + { throw new RegistrationError( this.out.toString() + ": Smelting Output is not a valid item." ); + } GameRegistry.addSmelting( this.in.getItemStack(), this.out.getItemStack(), 0 ); } diff --git a/src/main/java/appeng/recipes/ores/OreDictionaryHandler.java b/src/main/java/appeng/recipes/ores/OreDictionaryHandler.java index f4715354..19fadf21 100644 --- a/src/main/java/appeng/recipes/ores/OreDictionaryHandler.java +++ b/src/main/java/appeng/recipes/ores/OreDictionaryHandler.java @@ -45,16 +45,22 @@ public class OreDictionaryHandler public void onOreDictionaryRegister( OreDictionary.OreRegisterEvent event ) { if( event.Name == null || event.Ore == null ) + { return; + } if( this.shouldCare( event.Name ) ) { for( IOreListener v : this.ol ) + { v.oreRegistered( event.Name, event.Ore ); + } } if( this.enableRebaking ) + { this.bakeRecipes(); + } } /** @@ -107,7 +113,9 @@ public class OreDictionaryHandler for( ItemStack item : OreDictionary.getOres( name ) ) { if( item != null ) + { n.oreRegistered( name, item ); + } } } } diff --git a/src/main/java/appeng/server/AECommand.java b/src/main/java/appeng/server/AECommand.java index 539f9263..99e3c047 100644 --- a/src/main/java/appeng/server/AECommand.java +++ b/src/main/java/appeng/server/AECommand.java @@ -99,9 +99,13 @@ public final class AECommand extends CommandBase { Commands c = Commands.valueOf( args[0] ); if( sender.canCommandSenderUseCommand( c.level, this.getCommandName() ) ) + { c.command.call( this.srv, args, sender ); + } else + { throw new WrongUsageException( "commands.ae2.permissions" ); + } } catch( WrongUsageException wrong ) { diff --git a/src/main/java/appeng/server/ServerHelper.java b/src/main/java/appeng/server/ServerHelper.java index c21b0f08..f5665d73 100644 --- a/src/main/java/appeng/server/ServerHelper.java +++ b/src/main/java/appeng/server/ServerHelper.java @@ -75,7 +75,9 @@ public class ServerHelper extends CommonHelper MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if( server != null ) + { return server.getConfigurationManager().playerEntityList; + } } return new ArrayList(); @@ -85,7 +87,9 @@ public class ServerHelper extends CommonHelper public void sendToAllNearExcept( EntityPlayer p, double x, double y, double z, double dist, World w, AppEngPacket packet ) { if( Platform.isClient() ) + { return; + } for( EntityPlayer o : this.getPlayers() ) { @@ -139,7 +143,9 @@ public class ServerHelper extends CommonHelper public CableRenderMode getRenderMode() { if( this.renderModeBased == null ) + { return CableRenderMode.Standard; + } return this.renderModeForPlayer( this.renderModeBased ); } @@ -156,7 +162,9 @@ public class ServerHelper extends CommonHelper { NBTTagCompound c = is.getTagCompound(); if( c != null && c.getBoolean( "hideFacades" ) ) + { return CableRenderMode.CableView; + } } } } diff --git a/src/main/java/appeng/server/subcommands/ChunkLogger.java b/src/main/java/appeng/server/subcommands/ChunkLogger.java index 259568a9..1fa42ed9 100644 --- a/src/main/java/appeng/server/subcommands/ChunkLogger.java +++ b/src/main/java/appeng/server/subcommands/ChunkLogger.java @@ -56,7 +56,9 @@ public class ChunkLogger implements ISubCommand for( StackTraceElement e : Thread.currentThread().getStackTrace() ) { if( output ) + { AELog.info( " " + e.getClassName() + '.' + e.getMethodName() + " (" + e.getLineNumber() + ')' ); + } else { output = e.getClassName().contains( "EventBus" ) && e.getMethodName().contains( "post" ); diff --git a/src/main/java/appeng/services/CompassService.java b/src/main/java/appeng/services/CompassService.java index de2ad00c..45211efc 100644 --- a/src/main/java/appeng/services/CompassService.java +++ b/src/main/java/appeng/services/CompassService.java @@ -67,7 +67,9 @@ public class CompassService implements ThreadFactory public void cleanUp() { for( CompassReader cr : this.worldSet.values() ) + { cr.close(); + } } public void updateArea( World w, int chunkX, int chunkZ ) @@ -206,7 +208,9 @@ public class CompassService implements ThreadFactory cr.setHasBeacon( this.chunkX, this.chunkZ, this.doubleChunkY, this.value ); if( CompassService.this.jobSize() < 2 ) + { CompassService.this.cleanUp(); + } } } @@ -241,7 +245,9 @@ public class CompassService implements ThreadFactory this.callback.calculatedDirection( true, true, -999, 0 ); if( CompassService.this.jobSize() < 2 ) + { CompassService.this.cleanUp(); + } return; } @@ -313,7 +319,9 @@ public class CompassService implements ThreadFactory this.callback.calculatedDirection( true, false, CompassService.this.rad( cx, cz, chosen_x, chosen_z ), CompassService.this.dist( cx, cz, chosen_x, chosen_z ) ); if( CompassService.this.jobSize() < 2 ) + { CompassService.this.cleanUp(); + } return; } @@ -323,7 +331,9 @@ public class CompassService implements ThreadFactory this.callback.calculatedDirection( false, true, -999, 999 ); if( CompassService.this.jobSize() < 2 ) + { CompassService.this.cleanUp(); + } } } } diff --git a/src/main/java/appeng/services/compass/CompassRegion.java b/src/main/java/appeng/services/compass/CompassRegion.java index 89d9ec2b..8f3beaf8 100644 --- a/src/main/java/appeng/services/compass/CompassRegion.java +++ b/src/main/java/appeng/services/compass/CompassRegion.java @@ -63,7 +63,9 @@ public class CompassRegion { File fName = this.getFileName(); if( this.hasFile ) + { return; + } if( create || this.fileExists( fName ) ) { @@ -89,7 +91,9 @@ public class CompassRegion if( !folderFile.exists() || !folderFile.isDirectory() ) { if( !folderFile.mkdir() ) + { AELog.info( "Failed to create AE2/compass/" ); + } } return new File( folder, this.world + '_' + this.low_x + '_' + this.low_z + ".dat" ); @@ -127,7 +131,9 @@ public class CompassRegion int val = this.read( cx, cz ); if( val != 0 ) + { return true; + } } return false; @@ -164,12 +170,18 @@ public class CompassRegion int originalVal = val; if( hasBeacon ) + { val |= 1 << cdy; + } else + { val &= ~( 1 << cdy ); + } if( originalVal != val ) + { this.write( cx, cz, val ); + } } } diff --git a/src/main/java/appeng/services/version/BaseVersion.java b/src/main/java/appeng/services/version/BaseVersion.java index 33dc1968..3384a300 100644 --- a/src/main/java/appeng/services/version/BaseVersion.java +++ b/src/main/java/appeng/services/version/BaseVersion.java @@ -66,16 +66,24 @@ public abstract class BaseVersion implements Version public final boolean equals( Object o ) { if( this == o ) + { return true; + } if( !( o instanceof Version ) ) + { return false; + } Version that = (Version) o; if( this.revision != that.revision() ) + { return false; + } if( this.build != that.build() ) + { return false; + } return this.channel == that.channel(); } diff --git a/src/main/java/appeng/spatial/CachedPlane.java b/src/main/java/appeng/spatial/CachedPlane.java index 49776886..c0130c4d 100644 --- a/src/main/java/appeng/spatial/CachedPlane.java +++ b/src/main/java/appeng/spatial/CachedPlane.java @@ -97,14 +97,17 @@ public class CachedPlane } for( int x = 0; x < this.x_size; x++ ) + { for( int z = 0; z < this.z_size; z++ ) { this.myColumns[x][z] = new Column( w.getChunkFromChunkCoords( ( minX + x ) >> 4, ( minZ + z ) >> 4 ), ( minX + x ) & 0xF, ( minZ + z ) & 0xF, minCY, cy_size ); } + } IMovableRegistry mr = AEApi.instance().registries().movable(); for( int cx = 0; cx < this.cx_size; cx++ ) + { for( int cz = 0; cz < this.cz_size; cz++ ) { LinkedList> rawTiles = new LinkedList>(); @@ -137,7 +140,9 @@ public class CachedPlane c.worldObj.notifyBlocksOfNeighborChange( te.xCoord, te.yCoord, te.zCoord, Platform.AIR ); } else + { this.myColumns[te.xCoord - minX][te.zCoord - minZ].setSkip( te.yCoord ); + } } } } @@ -163,6 +168,7 @@ public class CachedPlane } } } + } for( TileEntity te : this.tiles ) { @@ -260,7 +266,9 @@ public class CachedPlane { this.updates.add( new WorldCoord( src_x, src_y, src_z ) ); for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { this.updates.add( new WorldCoord( src_x + d.offsetX, src_y + d.offsetY, src_z + d.offsetZ ) ); + } } private void addTick( int x, int y, int z, NextTickListEntry entry ) @@ -320,6 +328,7 @@ public class CachedPlane // update shit.. for( int x = 0; x < this.cx_size; x++ ) + { for( int z = 0; z < this.cz_size; z++ ) { Chunk c = this.myChunks[x][z]; @@ -327,19 +336,24 @@ public class CachedPlane c.generateSkylightMap(); c.isModified = true; } + } // send shit... for( int x = 0; x < this.cx_size; x++ ) + { for( int z = 0; z < this.cz_size; z++ ) { Chunk c = this.myChunks[x][z]; for( int y = 1; y < 255; y += 32 ) + { WorldSettings.getInstance().getCompass().updateArea( this.world, c.xPosition << 4, y, c.zPosition << 4 ); + } Platform.sendChunk( c, this.verticalBits ); } + } } class Column @@ -365,7 +379,9 @@ public class CachedPlane int by = ( ay + cy ); ExtendedBlockStorage extendedblockstorage = this.storage[by]; if( extendedblockstorage == null ) + { extendedblockstorage = this.storage[by] = new ExtendedBlockStorage( by << 4, !this.c.worldObj.provider.hasNoSky ); + } } } @@ -399,7 +415,9 @@ public class CachedPlane { ExtendedBlockStorage extendedblockstorage = this.storage[y >> 4]; if( CachedPlane.this.reg.isBlacklisted( extendedblockstorage.getBlockByExtId( this.x, y & 15, this.z ) ) ) + { return false; + } return this.skipThese == null || !this.skipThese.contains( y ); } @@ -407,7 +425,9 @@ public class CachedPlane public void setSkip( int yCoord ) { if( this.skipThese == null ) + { this.skipThese = new LinkedList(); + } this.skipThese.add( yCoord ); } } diff --git a/src/main/java/appeng/spatial/StorageChunkProvider.java b/src/main/java/appeng/spatial/StorageChunkProvider.java index 661cb65c..0a58b05e 100644 --- a/src/main/java/appeng/spatial/StorageChunkProvider.java +++ b/src/main/java/appeng/spatial/StorageChunkProvider.java @@ -68,7 +68,9 @@ public class StorageChunkProvider extends ChunkProviderGenerate AEConfig config = AEConfig.instance; for( int k = 0; k < biomes.length; ++k ) + { biomes[k] = (byte) config.storageBiomeID; + } if( !chunk.isTerrainPopulated ) { diff --git a/src/main/java/appeng/spatial/StorageHelper.java b/src/main/java/appeng/spatial/StorageHelper.java index a441eeb6..2e854024 100644 --- a/src/main/java/appeng/spatial/StorageHelper.java +++ b/src/main/java/appeng/spatial/StorageHelper.java @@ -48,7 +48,9 @@ public class StorageHelper public static StorageHelper getInstance() { if( instance == null ) + { instance = new StorageHelper(); + } return instance; } @@ -78,9 +80,13 @@ public class StorageHelper } if( oldWorld == null ) + { return entity; + } if( newWorld == null ) + { return entity; + } // Is something riding? Handle it first. if( entity.riddenByEntity != null ) @@ -105,7 +111,9 @@ public class StorageHelper if( player != null ) { if( link.dim.provider instanceof StorageWorldProvider ) + { Achievements.SpatialIOExplorer.addToPlayer( player ); + } player.mcServer.getConfigurationManager().transferPlayerToDimension( player, link.dim.provider.dimensionId, new METeleporter( newWorld, link ) ); } @@ -143,7 +151,9 @@ public class StorageHelper entity = newEntity; } else + { return null; + } // myChunk.addEntity( entity ); // newWorld.loadedEntityList.add( entity ); @@ -157,7 +167,9 @@ public class StorageHelper if( cart != null ) { if( player != null ) + { entity.worldObj.updateEntityWithOptionalForce( entity, true ); + } entity.mountEntity( cart ); } @@ -168,25 +180,31 @@ public class StorageHelper public void transverseEdges( int minX, int minY, int minZ, int maxX, int maxY, int maxZ, ISpatialVisitor visitor ) { for( int y = minY; y < maxY; y++ ) + { for( int z = minZ; z < maxZ; z++ ) { visitor.visit( minX, y, z ); visitor.visit( maxX, y, z ); } + } for( int x = minX; x < maxX; x++ ) + { for( int z = minZ; z < maxZ; z++ ) { visitor.visit( x, minY, z ); visitor.visit( x, maxY, z ); } + } for( int x = minX; x < maxX; x++ ) + { for( int y = minY; y < maxY; y++ ) { visitor.visit( x, y, minZ ); visitor.visit( x, y, maxZ ); } + } } public void swapRegions( World src /** over world **/, World dst /** storage cell **/, int x, int y, int z, int i, int j, int k, int scaleX, int scaleY, int scaleZ ) @@ -220,10 +238,14 @@ public class StorageHelper } for( WorldCoord wc : cDst.updates ) + { cDst.world.notifyBlockOfNeighborChange( wc.x, wc.y, wc.z, Platform.AIR ); + } for( WorldCoord wc : cSrc.updates ) + { cSrc.world.notifyBlockOfNeighborChange( wc.x, wc.y, wc.z, Platform.AIR ); + } this.transverseEdges( x - 1, y - 1, z - 1, x + scaleX + 1, y + scaleY + 1, z + scaleZ + 1, new TriggerUpdates( src ) ); this.transverseEdges( i - 1, j - 1, k - 1, i + scaleX + 1, j + scaleY + 1, k + scaleZ + 1, new TriggerUpdates( dst ) ); diff --git a/src/main/java/appeng/tile/AEBaseInvTile.java b/src/main/java/appeng/tile/AEBaseInvTile.java index 8b517dfb..9ceef281 100644 --- a/src/main/java/appeng/tile/AEBaseInvTile.java +++ b/src/main/java/appeng/tile/AEBaseInvTile.java @@ -60,7 +60,9 @@ public abstract class AEBaseInvTile extends AEBaseTile implements ISidedInventor NBTTagCompound item = new NBTTagCompound(); ItemStack is = this.getStackInSlot( x ); if( is != null ) + { is.writeToNBT( item ); + } opt.setTag( "item" + x, item ); } data.setTag( "inv", opt ); diff --git a/src/main/java/appeng/tile/AEBaseTile.java b/src/main/java/appeng/tile/AEBaseTile.java index 5a10c436..5e67c8b5 100644 --- a/src/main/java/appeng/tile/AEBaseTile.java +++ b/src/main/java/appeng/tile/AEBaseTile.java @@ -93,7 +93,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, { ItemStackSrc src = ITEM_STACKS.get( obj.getClass() ); if( src == null ) + { return null; + } return src.stack( 1 ); } @@ -108,7 +110,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, public void onChunkLoad() { if( this.isInvalid() ) + { this.validate(); + } } @Override @@ -118,9 +122,13 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, super.readFromNBT( data ); if( data.hasKey( "customName" ) ) + { this.customName = data.getString( "customName" ); + } else + { this.customName = null; + } try { @@ -153,17 +161,23 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, } if( this.customName != null ) + { data.setString( "customName", this.customName ); + } for( AETileEventHandler h : this.getHandlerListFor( TileEventType.WORLD_NBT_WRITE ) ) + { h.writeToNBT( this, data ); + } } @Override public final void updateEntity() { for( AETileEventHandler h : this.getHandlerListFor( TileEventType.TICK ) ) + { h.Tick( this ); + } } @Override @@ -177,7 +191,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, { this.writeToStream( stream ); if( stream.readableBytes() == 0 ) + { return null; + } } catch( Throwable t ) { @@ -209,7 +225,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, { ByteBuf stream = Unpooled.copiedBuffer( pkt.func_148857_g().getByteArray( "X" ) ); if( this.readFromStream( stream ) ) + { this.markForUpdate(); + } } } @@ -217,7 +235,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, public void onChunkUnload() { if( !this.isInvalid() ) + { this.invalidate(); + } } public final boolean readFromStream( ByteBuf data ) @@ -241,11 +261,17 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, this.renderFragment = 100; for( AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_READ ) ) + { if( h.readFromStream( this, data ) ) + { output = true; + } + } if( ( this.renderFragment & 1 ) == 1 ) + { output = true; + } this.renderFragment = 0; } catch( Throwable t ) @@ -259,7 +285,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, public void markForUpdate() { if( this.renderFragment > 0 ) + { this.renderFragment |= 1; + } else { // TODO: Optimize Network Load @@ -282,7 +310,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, } for( AETileEventHandler h : this.getHandlerListFor( TileEventType.NETWORK_WRITE ) ) + { h.writeToStream( this, data ); + } } catch( Throwable t ) { @@ -323,7 +353,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, List list = handlerSet.get( type ); if( list == null ) + { handlerSet.put( type, list = new LinkedList() ); + } return list; } @@ -333,7 +365,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, List list = handlerSet.get( value ); if( list == null ) + { handlerSet.put( value, list = new ArrayList() ); + } list.add( new AETileEventHandler( m, value ) ); } @@ -379,7 +413,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, { IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager(); if( cm != null ) + { cm.readFromNBT( compound ); + } } if( this instanceof IPriorityHost ) @@ -397,7 +433,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSizeInventory() ); tmp.readFromNBT( compound, "config" ); for( int x = 0; x < tmp.getSizeInventory(); x++ ) + { target.setInventorySlotContents( x, tmp.getStackInSlot( x ) ); + } } } } @@ -422,7 +460,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, { ItemStack is = inv.getStackInSlot( l ); if( is != null ) + { drops.add( is ); + } } } } @@ -459,7 +499,9 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile, { IConfigManager cm = ( (IConfigurableObject) this ).getConfigManager(); if( cm != null ) + { cm.writeToNBT( output ); + } } if( this instanceof IPriorityHost ) diff --git a/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java b/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java index 3c16e176..62dbf2e2 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingMonitorTile.java @@ -59,9 +59,13 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora boolean hasItem = data.readBoolean(); if( hasItem ) + { this.dspPlay = AEItemStack.loadItemStackFromPacket( data ); + } else + { this.dspPlay = null; + } this.updateList = true; return oldPaintedColor != this.paintedColor; // tesr! @@ -73,7 +77,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora data.writeByte( this.paintedColor.ordinal() ); if( this.dspPlay == null ) + { data.writeBoolean( false ); + } else { data.writeBoolean( true ); @@ -85,7 +91,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora public void readFromNBT_TileCraftingMonitorTile( NBTTagCompound data ) { if( data.hasKey( "paintedColor" ) ) + { this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )]; + } } @TileEvent( TileEventType.WORLD_NBT_WRITE ) @@ -144,7 +152,9 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who ) { if( this.paintedColor == newPaintedColor ) + { return false; + } this.paintedColor = newPaintedColor; this.markDirty(); diff --git a/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java b/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java index f895ce0d..7466d410 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingStorageTile.java @@ -76,7 +76,9 @@ public class TileCraftingStorageTile extends TileCraftingTile public int getStorageBytes() { if( this.worldObj == null || this.notLoaded() ) + { return 0; + } switch( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 ) { diff --git a/src/main/java/appeng/tile/crafting/TileCraftingTile.java b/src/main/java/appeng/tile/crafting/TileCraftingTile.java index 1e7421a0..5e5f0a8b 100644 --- a/src/main/java/appeng/tile/crafting/TileCraftingTile.java +++ b/src/main/java/appeng/tile/crafting/TileCraftingTile.java @@ -101,13 +101,17 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP { super.setName( name ); if( this.cluster != null ) + { this.cluster.updateName(); + } } public boolean isAccelerator() { if( this.worldObj == null ) + { return false; + } return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 3 ) == 1; } @@ -127,7 +131,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP public void updateStatus( CraftingCPUCluster c ) { if( this.cluster != null && this.cluster != c ) + { this.cluster.breakCluster(); + } this.cluster = c; this.updateMeta( true ); @@ -136,33 +142,45 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP public void updateMeta( boolean updateFormed ) { if( this.worldObj == null || this.notLoaded() ) + { return; + } boolean formed = this.isFormed(); boolean power = false; if( this.gridProxy.isReady() ) + { power = this.gridProxy.isActive(); + } int current = this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ); int newMeta = ( current & 3 ) | ( formed ? 8 : 0 ) | ( power ? 4 : 0 ); if( current != newMeta ) + { this.worldObj.setBlockMetadataWithNotify( this.xCoord, this.yCoord, this.zCoord, newMeta, 2 ); + } if( updateFormed ) { if( formed ) + { this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) ); + } else + { this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + } } } public boolean isFormed() { if( Platform.isClient() ) + { return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 8 ) == 8; + } return this.cluster != null; } @@ -171,7 +189,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP { data.setBoolean( "core", this.isCoreBlock ); if( this.isCoreBlock && this.cluster != null ) + { this.cluster.writeToNBT( data ); + } } @TileEvent( TileEventType.WORLD_NBT_READ ) @@ -181,9 +201,13 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP if( this.isCoreBlock ) { if( this.cluster != null ) + { this.cluster.readFromNBT( data ); + } else + { this.previousState = (NBTTagCompound) data.copy(); + } } } @@ -194,7 +218,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP { this.cluster.destroy(); if( update ) + { this.updateMeta( true ); + } } } @@ -251,7 +277,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP { IGridHost h = i.next(); if( h == this ) + { places.add( new WorldCoord( this ) ); + } else { TileEntity te = (TileEntity) h; @@ -261,7 +289,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP WorldCoord wc = new WorldCoord( te ); wc.add( d, 1 ); if( this.worldObj.isAirBlock( wc.x, wc.y, wc.z ) ) + { places.add( wc ); + } } } } @@ -269,7 +299,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP Collections.shuffle( places ); if( places.isEmpty() ) + { throw new IllegalStateException( this.cluster + " does not contain any kind of blocks, which were destroyed." ); + } for( IAEItemStack ais : inv.getAvailableItems( AEApi.instance().storage().createItemList() ) ) { @@ -279,7 +311,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP { IAEItemStack g = inv.extractItems( ais.copy(), Actionable.MODULATE, this.cluster.getActionSource() ); if( g == null ) + { break; + } WorldCoord wc = places.poll(); places.add( wc ); @@ -296,7 +330,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP public boolean isPowered() { if( Platform.isClient() ) + { return ( this.worldObj.getBlockMetadata( this.xCoord, this.yCoord, this.zCoord ) & 4 ) == 4; + } return this.gridProxy.isActive(); } @@ -304,7 +340,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP public boolean isActive() { if( Platform.isServer() ) + { return this.gridProxy.isActive(); + } return this.isPowered() && this.isFormed(); } } diff --git a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java index 8bccd2b9..4527ea9e 100644 --- a/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java +++ b/src/main/java/appeng/tile/crafting/TileMolecularAssembler.java @@ -119,7 +119,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade { boolean isEmpty = true; for( int x = 0; x < this.inv.getSizeInventory(); x++ ) + { isEmpty = this.inv.getStackInSlot( x ) == null && isEmpty; + } if( isEmpty && patternDetails.isCraftable() ) { @@ -128,7 +130,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.pushDirection = where; for( int x = 0; x < table.getSizeInventory(); x++ ) + { this.inv.setInventorySlotContents( x, table.getStackInSlot( x ) ); + } this.updateSleepiness(); this.markDirty(); @@ -147,9 +151,13 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade try { if( this.isAwake ) + { this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); + } else + { this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); + } } catch( GridAccessException e ) { @@ -166,10 +174,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade private boolean hasMats() { if( this.myPlan == null ) + { return false; + } for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) + { this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) ); + } return this.myPlan.getOutput( this.craftingInv, this.getWorldObj() ) != null; } @@ -252,7 +264,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.reboot = true; if( this.forcePlan ) + { return; + } ItemStack is = this.inv.getStackInSlot( 10 ); @@ -306,10 +320,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade public IInventory getInventoryByName( String name ) { if( name.equals( "upgrades" ) ) + { return this.upgrades; + } if( name.equals( "mac" ) ) + { return this.inv; + } return null; } @@ -336,10 +354,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade public boolean isItemValidForSlot( int i, ItemStack itemstack ) { if( i >= 9 ) + { return false; + } if( this.hasPattern() ) + { return this.myPlan.isValidItemForSlot( i, itemstack, this.getWorldObj() ); + } return false; } @@ -353,7 +375,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ) { if( inv == this.inv ) + { this.recalculatePlan(); + } } @Override @@ -382,7 +406,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade { ItemStack is = this.upgrades.getStackInSlot( h ); if( is != null ) + { drops.add( is ); + } } } @@ -403,7 +429,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade // did it eject? if( this.inv.getStackInSlot( 9 ) == null ) + { this.markDirty(); + } this.ejectHeldItems(); this.updateSleepiness(); @@ -418,10 +446,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade } if( this.reboot ) + { TicksSinceLastCall = 1; + } if( !this.isAwake ) + { return TickRateModulation.SLEEP; + } this.reboot = false; int speed = 10; @@ -450,7 +482,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade if( this.progress >= 100 ) { for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) + { this.craftingInv.setInventorySlotContents( x, this.inv.getStackInSlot( x ) ); + } this.progress = 0; ItemStack output = this.myPlan.getOutput( this.craftingInv, this.getWorldObj() ); @@ -461,7 +495,9 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade this.pushOut( output.copy() ); for( int x = 0; x < this.craftingInv.getSizeInventory(); x++ ) + { this.inv.setInventorySlotContents( x, Platform.getContainerItem( this.craftingInv.getStackInSlot( x ) ) ); + } if( this.inv.getStackInSlot( 10 ) == null ) { @@ -530,10 +566,14 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade if( this.pushDirection == ForgeDirection.UNKNOWN ) { for( ForgeDirection d : ForgeDirection.VALID_DIRECTIONS ) + { output = this.pushTo( output, d ); + } } else + { output = this.pushTo( output, this.pushDirection ); + } if( output == null && this.forcePlan ) { @@ -547,24 +587,32 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade private ItemStack pushTo( ItemStack output, ForgeDirection d ) { if( output == null ) + { return output; + } TileEntity te = this.getWorldObj().getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ ); if( te == null ) + { return output; + } InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( te, d.getOpposite() ); if( adaptor == null ) + { return output; + } int size = output.stackSize; output = adaptor.addItems( output ); int newSize = output == null ? 0 : output.stackSize; if( size != newSize ) + { this.markDirty(); + } return output; } diff --git a/src/main/java/appeng/tile/grindstone/TileCrank.java b/src/main/java/appeng/tile/grindstone/TileCrank.java index 1ca4b57a..ffbfc437 100644 --- a/src/main/java/appeng/tile/grindstone/TileCrank.java +++ b/src/main/java/appeng/tile/grindstone/TileCrank.java @@ -62,7 +62,9 @@ public class TileCrank extends AEBaseTile implements ICustomCollision this.charge -= this.ticksPerRotation; ICrankable g = this.getGrinder(); if( g != null ) + { g.applyTurn(); + } } this.rotation--; @@ -72,12 +74,16 @@ public class TileCrank extends AEBaseTile implements ICustomCollision public ICrankable getGrinder() { if( Platform.isClient() ) + { return null; + } ForgeDirection grinder = this.getUp().getOpposite(); TileEntity te = this.worldObj.getTileEntity( this.xCoord + grinder.offsetX, this.yCoord + grinder.offsetY, this.zCoord + grinder.offsetZ ); if( te instanceof ICrankable ) + { return (ICrankable) te; + } return null; } @@ -113,7 +119,9 @@ public class TileCrank extends AEBaseTile implements ICustomCollision public boolean power() { if( Platform.isClient() ) + { return false; + } if( this.rotation < 3 ) { diff --git a/src/main/java/appeng/tile/grindstone/TileGrinder.java b/src/main/java/appeng/tile/grindstone/TileGrinder.java index 90dfef34..004fbfcb 100644 --- a/src/main/java/appeng/tile/grindstone/TileGrinder.java +++ b/src/main/java/appeng/tile/grindstone/TileGrinder.java @@ -69,7 +69,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable public boolean canInsertItem( int slotIndex, ItemStack insertingItem, int side ) { if( AEApi.instance().registries().grinder().getRecipeForInput( insertingItem ) == null ) + { return false; + } return slotIndex >= 0 && slotIndex <= 2; } @@ -90,7 +92,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable public boolean canTurn() { if( Platform.isClient() ) + { return false; + } if( null == this.getStackInSlot( 6 ) ) // Add if there isn't one... { @@ -99,7 +103,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable { ItemStack item = src.getStackInSlot( x ); if( item == null ) + { continue; + } IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( item ); if( r != null ) @@ -111,7 +117,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable ais.stackSize = r.getInput().stackSize; if( item.stackSize <= 0 ) + { item = null; + } src.setInventorySlotContents( x, item ); this.setInventorySlotContents( 6, ais ); @@ -128,7 +136,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable public void applyTurn() { if( Platform.isClient() ) + { return; + } this.points++; @@ -137,7 +147,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable if( r != null ) { if( r.getEnergyCost() > this.points ) + { return; + } this.points = 0; InventoryAdaptor sia = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( this, 3, 3, true ), ForgeDirection.EAST ); @@ -146,11 +158,15 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable float chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f; if( chance <= r.getOptionalChance() ) + { this.addItem( sia, r.getOptionalOutput() ); + } chance = ( Platform.getRandomInt() % 2000 ) / 2000.0f; if( chance <= r.getSecondOptionalChance() ) + { this.addItem( sia, r.getSecondOptionalOutput() ); + } this.setInventorySlotContents( 6, null ); } @@ -159,7 +175,9 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable private void addItem( InventoryAdaptor sia, ItemStack output ) { if( output == null ) + { return; + } ItemStack notAdded = sia.addItems( output ); if( notAdded != null ) diff --git a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java index 5fd1a5d9..1cc61ffa 100644 --- a/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java +++ b/src/main/java/appeng/tile/inventory/AppEngInternalAEInventory.java @@ -54,8 +54,12 @@ public class AppEngInternalAEInventory implements IInventory, Iterable public boolean isEmpty() { for( int x = 0; x < this.size; x++ ) + { if( this.getStackInSlot( x ) != null ) + { return false; + } + } return true; } @@ -89,7 +93,9 @@ public class AppEngInternalInventory implements IInventory, Iterable this.inv[slot] = null; } else + { ns = split.splitStack( qty ); + } if( this.te != null && this.eventsEnabled() ) { @@ -246,7 +252,9 @@ public class AppEngInternalInventory implements IInventory, Iterable { NBTTagCompound c = data.getCompoundTag( name ); if( c != null ) + { this.readFromNBT( c ); + } } public void readFromNBT( NBTTagCompound target ) @@ -258,7 +266,9 @@ public class AppEngInternalInventory implements IInventory, Iterable NBTTagCompound c = target.getCompoundTag( "#" + x ); if( c != null ) + { this.inv[x] = ItemStack.loadItemStackFromNBT( c ); + } } catch( Exception e ) { diff --git a/src/main/java/appeng/tile/misc/TileCellWorkbench.java b/src/main/java/appeng/tile/misc/TileCellWorkbench.java index e87805be..96e4c502 100644 --- a/src/main/java/appeng/tile/misc/TileCellWorkbench.java +++ b/src/main/java/appeng/tile/misc/TileCellWorkbench.java @@ -66,15 +66,21 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I { ICellWorkbenchItem cell = this.getCell(); if( cell == null ) + { return null; + } ItemStack is = this.cell.getStackInSlot( 0 ); if( is == null ) + { return null; + } IInventory inv = cell.getUpgradesInventory( is ); if( inv == null ) + { return null; + } return this.cacheUpgrades = inv; } @@ -84,10 +90,14 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I public ICellWorkbenchItem getCell() { if( this.cell.getStackInSlot( 0 ) == null ) + { return null; + } if( this.cell.getStackInSlot( 0 ).getItem() instanceof ICellWorkbenchItem ) + { return ( (ICellWorkbenchItem) this.cell.getStackInSlot( 0 ).getItem() ); + } return null; } @@ -112,10 +122,14 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I public IInventory getInventoryByName( String name ) { if( name.equals( "config" ) ) + { return this.config; + } if( name.equals( "cell" ) ) + { return this.cell; + } return null; } @@ -152,12 +166,16 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I if( cellHasConfig ) { for( int x = 0; x < this.config.getSizeInventory(); x++ ) + { this.config.setInventorySlotContents( x, configInventory.getStackInSlot( x ) ); + } } else { for( int x = 0; x < this.config.getSizeInventory(); x++ ) + { configInventory.setInventorySlotContents( x, this.config.getStackInSlot( x ) ); + } configInventory.markDirty(); } @@ -165,7 +183,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I else if( this.manager.getSetting( Settings.COPY_MODE ) == CopyMode.CLEAR_ON_REMOVE ) { for( int x = 0; x < this.config.getSizeInventory(); x++ ) + { this.config.setInventorySlotContents( x, null ); + } this.markDirty(); } @@ -178,7 +198,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I if( c != null ) { for( int x = 0; x < this.config.getSizeInventory(); x++ ) + { c.setInventorySlotContents( x, this.config.getStackInSlot( x ) ); + } c.markDirty(); } @@ -191,15 +213,21 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I { ICellWorkbenchItem cell = this.getCell(); if( cell == null ) + { return null; + } ItemStack is = this.cell.getStackInSlot( 0 ); if( is == null ) + { return null; + } IInventory inv = cell.getConfigInventory( is ); if( inv == null ) + { return null; + } this.cacheConfig = inv; } @@ -212,7 +240,9 @@ public class TileCellWorkbench extends AEBaseTile implements IUpgradeableHost, I super.getDrops( w, x, y, z, drops ); if( this.cell.getStackInSlot( 0 ) != null ) + { drops.add( this.cell.getStackInSlot( 0 ) ); + } } @Override diff --git a/src/main/java/appeng/tile/misc/TileCharger.java b/src/main/java/appeng/tile/misc/TileCharger.java index b2b591cc..0f221cf3 100644 --- a/src/main/java/appeng/tile/misc/TileCharger.java +++ b/src/main/java/appeng/tile/misc/TileCharger.java @@ -97,7 +97,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable { AEItemStack is = AEItemStack.create( this.getStackInSlot( 0 ) ); if( is != null ) + { is.writeToPacket( data ); + } } @TileEvent( TileEventType.TICK ) @@ -113,7 +115,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable this.tickTickTimer++; if( this.tickTickTimer < 20 ) + { return; + } this.tickTickTimer = 0; ItemStack myItem = this.getStackInSlot( 0 ); @@ -133,7 +137,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable } if( myItem == null ) + { return; + } final IMaterials materials = AEApi.instance().definitions().materials(); @@ -147,7 +153,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable double adjustment = ps.injectAEPower( myItem, this.extractAEPower( 150.0, Actionable.MODULATE, PowerMultiplier.CONFIG ) ); this.internalCurrentPower += adjustment; if( oldPower > this.internalCurrentPower ) + { this.requiresUpdate = true; + } this.tickTickTimer = 20; // keep ticking... } } @@ -246,7 +254,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable { IAEItemPowerStorage ips = (IAEItemPowerStorage) extractedItem.getItem(); if( ips.getAECurrentPower( extractedItem ) >= ips.getAEMaxPower( extractedItem ) ) + { return true; + } } return AEApi.instance().definitions().materials().certusQuartzCrystalCharged().isSameAs( extractedItem ); @@ -261,7 +271,9 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable public void activate( EntityPlayer player ) { if( !Platform.hasPermissions( new DimensionalCoord( this ), player ) ) + { return; + } ItemStack myItem = this.getStackInSlot( 0 ); if( myItem == null ) diff --git a/src/main/java/appeng/tile/misc/TileCondenser.java b/src/main/java/appeng/tile/misc/TileCondenser.java index 8092ae50..a379e235 100644 --- a/src/main/java/appeng/tile/misc/TileCondenser.java +++ b/src/main/java/appeng/tile/misc/TileCondenser.java @@ -83,7 +83,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf { IStorageComponent sc = (IStorageComponent) is.getItem(); if( sc.isStorageComponent( is ) ) + { return sc.getBytes( is ) * 8; + } } } return 0; @@ -104,7 +106,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf this.addOutput( output ); } else + { break; + } } } @@ -123,7 +127,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf { ItemStack outputStack = this.getStackInSlot( 1 ); if( outputStack == null ) + { this.setInventorySlotContents( 1, output.copy() ); + } else { outputStack.stackSize++; @@ -172,7 +178,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf if( i == 0 ) { if( itemstack != null ) + { this.addPower( itemstack.stackSize ); + } } else { @@ -222,7 +230,9 @@ public class TileCondenser extends AEBaseInvTile implements IFluidHandler, IConf public int fill( ForgeDirection from, FluidStack resource, boolean doFill ) { if( doFill ) + { this.addPower( ( resource == null ? 0.0 : (double) resource.amount ) / 500.0 ); + } return resource == null ? 0 : resource.amount; } diff --git a/src/main/java/appeng/tile/misc/TileInscriber.java b/src/main/java/appeng/tile/misc/TileInscriber.java index 72f65ed2..36701433 100644 --- a/src/main/java/appeng/tile/misc/TileInscriber.java +++ b/src/main/java/appeng/tile/misc/TileInscriber.java @@ -149,9 +149,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, for( int num = 0; num < this.inv.getSizeInventory(); num++ ) { if( ( slot & ( 1 << num ) ) > 0 ) + { this.inv.setInventorySlotContents( num, AEItemStack.loadItemStackFromPacket( data ).getItemStack() ); + } else + { this.inv.setInventorySlotContents( num, null ); + } } return false; @@ -165,7 +169,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, for( int num = 0; num < this.inv.getSizeInventory(); num++ ) { if( this.inv.getStackInSlot( num ) != null ) + { slot |= ( 1 << num ); + } } data.writeByte( slot ); @@ -196,7 +202,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, { ItemStack is = this.upgrades.getStackInSlot( h ); if( is != null ) + { drops.add( is ); + } } } @@ -222,7 +230,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, public boolean isItemValidForSlot( int i, ItemStack itemstack ) { if( this.smash ) + { return false; + } if( i == 0 || i == 1 ) { @@ -232,8 +242,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, } for( ItemStack optionals : AEApi.instance().registries().inscriber().getOptionals() ) + { if( Platform.isSameItemPrecise( optionals, itemstack ) ) + { return true; + } + } } return i == 2; @@ -247,10 +261,14 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, if( mc != InvOperation.markDirty ) { if( slot != 3 ) + { this.processingTime = 0; + } if( !this.smash ) + { this.markForUpdate(); + } this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); } @@ -265,7 +283,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, public boolean canExtractItem( int slotIndex, ItemStack extractedItem, int side ) { if( this.smash ) + { return false; + } return slotIndex == 0 || slotIndex == 1 || slotIndex == 3; } @@ -274,10 +294,14 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, public int[] getAccessibleSlotsBySide( ForgeDirection d ) { if( d == ForgeDirection.UP ) + { return this.top; + } if( d == ForgeDirection.DOWN ) + { return this.bottom; + } return this.sides; } @@ -291,7 +315,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, private boolean hasWork() { if( this.getTask() != null ) + { return true; + } this.processingTime = 0; return this.smash; @@ -305,13 +331,19 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, ItemStack renamedItem = this.getStackInSlot( 2 ); if( plateA != null && plateA.stackSize > 1 ) + { return null; + } if( plateB != null && plateB.stackSize > 1 ) + { return null; + } if( renamedItem != null && renamedItem.stackSize > 1 ) + { return null; + } final IComparableDefinition namePress = AEApi.instance().definitions().materials().namePress(); boolean isNameA = namePress.isSameAs( plateA ); @@ -333,7 +365,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, { NBTTagCompound tag = Platform.openNbtData( plateB ); if( name.length() > 0 ) + { name += " "; + } name += tag.getString( "InscribeName" ); } @@ -345,9 +379,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, tag.setTag( "display", display ); if( name.length() > 0 ) + { display.setString( "Name", name ); + } else + { display.removeTag( "Name" ); + } final List inputs = Lists.newArrayList( startingItem ); final InscriberProcessType type = InscriberProcessType.Inscribe; @@ -370,7 +408,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, for( ItemStack option : recipe.getInputs() ) { if( Platform.isSameItemPrecise( option, this.getStackInSlot( 2 ) ) ) + { return recipe; + } } } } @@ -437,9 +477,13 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, src.extractAEPower( powerConsumption, Actionable.MODULATE, PowerMultiplier.CONFIG ); if( this.processingTime == 0 ) + { this.processingTime += speedFactor; + } else + { this.processingTime += TicksSinceLastCall * speedFactor; + } } } catch( GridAccessException e ) @@ -478,10 +522,14 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable, public IInventory getInventoryByName( String name ) { if( name.equals( "inv" ) ) + { return this.inv; + } if( name.equals( "upgrades" ) ) + { return this.upgrades; + } return null; } diff --git a/src/main/java/appeng/tile/misc/TileInterface.java b/src/main/java/appeng/tile/misc/TileInterface.java index d59c4fc0..b08cc3a9 100644 --- a/src/main/java/appeng/tile/misc/TileInterface.java +++ b/src/main/java/appeng/tile/misc/TileInterface.java @@ -85,21 +85,35 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT public void setSide( ForgeDirection axis ) { if( Platform.isClient() ) + { return; + } if( this.pointAt == axis.getOpposite() ) + { this.pointAt = axis; + } else if( this.pointAt == axis || this.pointAt == axis.getOpposite() ) + { this.pointAt = ForgeDirection.UNKNOWN; + } else if( this.pointAt == ForgeDirection.UNKNOWN ) + { this.pointAt = axis.getOpposite(); + } else + { this.pointAt = Platform.rotateAround( this.pointAt, axis ); + } if( ForgeDirection.UNKNOWN == this.pointAt ) + { this.setOrientation( this.pointAt, this.pointAt ); + } else + { this.setOrientation( this.pointAt.offsetY != 0 ? ForgeDirection.SOUTH : ForgeDirection.UP, this.pointAt.getOpposite() ); + } this.gridProxy.setValidSides( EnumSet.complementOf( EnumSet.of( this.pointAt ) ) ); this.markForUpdate(); @@ -145,9 +159,13 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT int val = data.getInteger( "pointAt" ); if( val >= 0 && val < ForgeDirection.values().length ) + { this.pointAt = ForgeDirection.values()[val]; + } else + { this.pointAt = ForgeDirection.UNKNOWN; + } this.duality.readFromNBT( data ); } @@ -228,7 +246,9 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, IT public EnumSet getTargets() { if( this.pointAt == null || this.pointAt == ForgeDirection.UNKNOWN ) + { return EnumSet.complementOf( EnumSet.of( ForgeDirection.UNKNOWN ) ); + } return EnumSet.of( this.pointAt ); } diff --git a/src/main/java/appeng/tile/misc/TilePaint.java b/src/main/java/appeng/tile/misc/TilePaint.java index 5cbab815..935aee52 100644 --- a/src/main/java/appeng/tile/misc/TilePaint.java +++ b/src/main/java/appeng/tile/misc/TilePaint.java @@ -58,7 +58,9 @@ public class TilePaint extends AEBaseTile ByteBuf myDat = Unpooled.buffer(); this.writeBuffer( myDat ); if( myDat.hasArray() ) + { data.setByteArray( "dots", myDat.array() ); + } } void writeBuffer( ByteBuf out ) @@ -72,14 +74,18 @@ public class TilePaint extends AEBaseTile out.writeByte( this.dots.size() ); for( Splotch s : this.dots ) + { s.writeToStream( out ); + } } @TileEvent( TileEventType.WORLD_NBT_READ ) public void readFromNBT_TilePaint( NBTTagCompound data ) { if( data.hasKey( "dots" ) ) + { this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) ); + } } void readBuffer( ByteBuf in ) @@ -95,7 +101,9 @@ public class TilePaint extends AEBaseTile this.dots = new ArrayList( howMany ); for( int x = 0; x < howMany; x++ ) + { this.dots.add( new Splotch( in ) ); + } this.isLit = 0; for( Splotch s : this.dots ) @@ -112,10 +120,14 @@ public class TilePaint extends AEBaseTile private void maxLit() { if( this.isLit > 14 ) + { this.isLit = 14; + } if( this.worldObj != null ) + { this.worldObj.updateLightByType( EnumSkyBlock.Block, this.xCoord, this.yCoord, this.zCoord ); + } } @TileEvent( TileEventType.NETWORK_WRITE ) @@ -134,12 +146,16 @@ public class TilePaint extends AEBaseTile public void onNeighborBlockChange() { if( this.dots == null ) + { return; + } for( ForgeDirection side : ForgeDirection.VALID_DIRECTIONS ) { if( !this.isSideValid( side ) ) + { this.removeSide( side ); + } } this.updateData(); @@ -158,7 +174,9 @@ public class TilePaint extends AEBaseTile { Splotch s = i.next(); if( s.side == side ) + { i.remove(); + } } this.markForUpdate(); @@ -179,16 +197,22 @@ public class TilePaint extends AEBaseTile this.maxLit(); if( this.dots.isEmpty() ) + { this.dots = null; + } if( this.dots == null ) + { this.worldObj.setBlock( this.xCoord, this.yCoord, this.zCoord, Blocks.air ); + } } public void cleanSide( ForgeDirection side ) { if( this.dots == null ) + { return; + } this.removeSide( side ); @@ -211,14 +235,20 @@ public class TilePaint extends AEBaseTile boolean lit = ipb.isLumen( type ); if( this.dots == null ) + { this.dots = new ArrayList(); + } if( this.dots.size() > 20 ) + { this.dots.remove( 0 ); + } this.dots.add( new Splotch( col, lit, side, hitVec ) ); if( lit ) + { this.isLit += LIGHT_PER_DOT; + } this.maxLit(); this.markForUpdate(); @@ -229,7 +259,9 @@ public class TilePaint extends AEBaseTile public Collection getDots() { if( this.dots == null ) + { return ImmutableList.of(); + } return this.dots; } diff --git a/src/main/java/appeng/tile/misc/TileSecurity.java b/src/main/java/appeng/tile/misc/TileSecurity.java index fc2a6df8..bd014bae 100644 --- a/src/main/java/appeng/tile/misc/TileSecurity.java +++ b/src/main/java/appeng/tile/misc/TileSecurity.java @@ -98,7 +98,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp this.securityKey = System.currentTimeMillis() * 10 + difference; if( difference > 10 ) + { difference = 0; + } this.cm.registerSetting( Settings.SORT_BY, SortOrder.NAME ); this.cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL ); @@ -115,10 +117,14 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp public void getDrops( World w, int x, int y, int z, ArrayList drops ) { if( !this.configSlot.isEmpty() ) + { drops.add( this.configSlot.getStackInSlot( 0 ) ); + } for( IAEItemStack ais : this.inventory.storedItems ) + { drops.add( ais.getItemStack() ); + } } IMEInventoryHandler getSecurityInventory() @@ -173,7 +179,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp { this.cm.readFromNBT( data ); if( data.hasKey( "paintedColor" ) ) + { this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )]; + } this.securityKey = data.getLong( "securityKey" ); this.configSlot.readFromNBT( data, "config" ); @@ -342,7 +350,9 @@ public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEApp public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who ) { if( this.paintedColor == newPaintedColor ) + { return false; + } this.paintedColor = newPaintedColor; this.markDirty(); diff --git a/src/main/java/appeng/tile/misc/TileVibrationChamber.java b/src/main/java/appeng/tile/misc/TileVibrationChamber.java index a084455c..60230e6d 100644 --- a/src/main/java/appeng/tile/misc/TileVibrationChamber.java +++ b/src/main/java/appeng/tile/misc/TileVibrationChamber.java @@ -157,7 +157,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka { int newBurnTime = TileEntityFurnace.getItemBurnTime( is ); if( newBurnTime > 0 && is.stackSize > 0 ) + { return true; + } } return false; } @@ -172,7 +174,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka public TickingRequest getTickingRequest( IGridNode node ) { if( this.burnTime <= 0 ) + { this.eatFuel(); + } return new TickingRequest( TickRates.VibrationChamber.min, TickRates.VibrationChamber.max, this.burnTime <= 0, false ); } @@ -185,7 +189,9 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka this.eatFuel(); if( this.burnTime > 0 ) + { return TickRateModulation.URGENT; + } this.burnSpeed = 100; return TickRateModulation.SLEEP; @@ -212,9 +218,13 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka grid.injectPower( Math.max( 0.0, newPower - overFlow ), Actionable.MODULATE ); if( overFlow > 0 ) + { this.burnSpeed -= TicksSinceLastCall; + } else + { this.burnSpeed += TicksSinceLastCall; + } this.burnSpeed = Math.max( 20, Math.min( this.burnSpeed, 200 ) ); return overFlow > 0 ? TickRateModulation.SLOWER : TickRateModulation.FASTER; @@ -243,12 +253,16 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka ItemStack container = null; if( is.getItem().hasContainerItem( is ) ) + { container = is.getItem().getContainerItem( is ); + } this.setInventorySlotContents( 0, container ); } else + { this.setInventorySlotContents( 0, is ); + } } } diff --git a/src/main/java/appeng/tile/networking/TileCableBus.java b/src/main/java/appeng/tile/networking/TileCableBus.java index f94e1c84..2de8272c 100644 --- a/src/main/java/appeng/tile/networking/TileCableBus.java +++ b/src/main/java/appeng/tile/networking/TileCableBus.java @@ -179,7 +179,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl public void markForUpdate() { if( this.worldObj == null ) + { return; + } int newLV = this.cb.getLightValue(); if( newLV != this.oldLV ) @@ -217,10 +219,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl if( this.cb.isEmpty() ) { if( this.worldObj.getTileEntity( this.xCoord, this.yCoord, this.zCoord ) == this ) + { this.worldObj.func_147480_a( this.xCoord, this.yCoord, this.zCoord, true ); + } } else + { this.cb.addToWorld(); + } } @Override @@ -330,7 +336,9 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl { IImmibisMicroblocks imb = (IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks ); if( imb != null && imb.leaveParts( this ) ) + { return; + } } this.getWorldObj().setBlock( this.xCoord, this.yCoord, this.zCoord, Platform.AIR ); @@ -338,14 +346,18 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl public void addCollidingBlockToList( World w, int x, int y, int z, AxisAlignedBB bb, List out, Entity e ) { for( AxisAlignedBB bx : this.getSelectedBoundingBoxesFromPool( w, x, y, z, e, false ) ) + { out.add( AxisAlignedBB.getBoundingBox( bx.minX, bx.minY, bx.minZ, bx.maxX, bx.maxY, bx.maxZ ) ); + } } @Override public void notifyNeighbors() { if( this.worldObj != null && this.worldObj.blockExists( this.xCoord, this.yCoord, this.zCoord ) && !CableBusContainer.isLoading() ) + { Platform.notifyBlocksOfNeighbors( this.worldObj, this.xCoord, this.yCoord, this.zCoord ); + } } @Override diff --git a/src/main/java/appeng/tile/networking/TileController.java b/src/main/java/appeng/tile/networking/TileController.java index 74374da0..7706940a 100644 --- a/src/main/java/appeng/tile/networking/TileController.java +++ b/src/main/java/appeng/tile/networking/TileController.java @@ -85,9 +85,13 @@ public class TileController extends AENetworkPowerTile if( oldValid != this.isValid || force ) { if( this.isValid ) + { this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) ); + } else + { this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + } } this.updateMeta(); @@ -96,7 +100,9 @@ public class TileController extends AENetworkPowerTile private void updateMeta() { if( !this.gridProxy.isReady() ) + { return; + } int meta = 0; @@ -107,7 +113,9 @@ public class TileController extends AENetworkPowerTile meta = 1; if( this.gridProxy.getPath().getControllerState() == ControllerState.CONTROLLER_CONFLICT ) + { meta = 2; + } } } catch( GridAccessException e ) @@ -139,7 +147,9 @@ public class TileController extends AENetworkPowerTile { double ret = this.gridProxy.getEnergy().injectPower( AEUnits, mode ); if( mode == Actionable.SIMULATE ) + { return ret; + } return 0; } catch( GridAccessException e ) diff --git a/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java b/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java index 87704460..01b56c00 100644 --- a/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java +++ b/src/main/java/appeng/tile/networking/TileEnergyAcceptor.java @@ -89,7 +89,9 @@ public class TileEnergyAcceptor extends AENetworkPowerTile IEnergyGrid grid = this.gridProxy.getEnergy(); double leftOver = grid.injectPower( newPower, mode ); if( mode == Actionable.SIMULATE ) + { return leftOver; + } return 0.0; } catch( GridAccessException e ) diff --git a/src/main/java/appeng/tile/networking/TileEnergyCell.java b/src/main/java/appeng/tile/networking/TileEnergyCell.java index c048150f..4515adcc 100644 --- a/src/main/java/appeng/tile/networking/TileEnergyCell.java +++ b/src/main/java/appeng/tile/networking/TileEnergyCell.java @@ -66,14 +66,20 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage private void changePowerLevel() { if( this.notLoaded() ) + { return; + } byte boundMetadata = (byte) ( 8.0 * ( this.internalCurrentPower / this.internalMaxPower ) ); if( boundMetadata > 7 ) + { boundMetadata = 7; + } if( boundMetadata < 0 ) + { boundMetadata = 0; + } if( this.currentMeta != boundMetadata ) { @@ -86,7 +92,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage public void writeToNBT_TileEnergyCell( NBTTagCompound data ) { if( !this.worldObj.isRemote ) + { data.setDouble( "internalCurrentPower", this.internalCurrentPower ); + } } @TileEvent( TileEventType.WORLD_NBT_READ ) @@ -138,7 +146,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage } if( this.internalCurrentPower < 0.01 && amt > 0.01 ) + { this.gridProxy.getNode().getGrid().postEvent( new MENetworkPowerStorage( this, PowerEventType.PROVIDE_POWER ) ); + } this.internalCurrentPower += amt; if( this.internalCurrentPower > this.internalMaxPower ) @@ -189,7 +199,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage if( mode == Actionable.SIMULATE ) { if( this.internalCurrentPower > amt ) + { return amt; + } return this.internalCurrentPower; } diff --git a/src/main/java/appeng/tile/networking/TileWireless.java b/src/main/java/appeng/tile/networking/TileWireless.java index 7b5a5c8c..7ff518d8 100644 --- a/src/main/java/appeng/tile/networking/TileWireless.java +++ b/src/main/java/appeng/tile/networking/TileWireless.java @@ -100,10 +100,14 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi try { if( this.gridProxy.getEnergy().isNetworkPowered() ) + { this.clientFlags |= POWERED_FLAG; + } if( this.gridProxy.getNode().meetsChannelRequirements() ) + { this.clientFlags |= CHANNEL_FLAG; + } } catch( GridAccessException e ) { @@ -183,7 +187,9 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi public boolean isActive() { if( Platform.isClient() ) + { return this.isPowered() && ( CHANNEL_FLAG == ( this.clientFlags & CHANNEL_FLAG ) ); + } return this.gridProxy.isActive(); } diff --git a/src/main/java/appeng/tile/powersink/AERootPoweredTile.java b/src/main/java/appeng/tile/powersink/AERootPoweredTile.java index 65d50ce2..c48ddae6 100644 --- a/src/main/java/appeng/tile/powersink/AERootPoweredTile.java +++ b/src/main/java/appeng/tile/powersink/AERootPoweredTile.java @@ -95,21 +95,27 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe public final double injectAEPower( double amt, Actionable mode ) { if( amt < 0.000001 ) + { return 0; + } if( mode == Actionable.SIMULATE ) { double fakeBattery = this.internalCurrentPower + amt; if( fakeBattery > this.internalMaxPower ) + { return fakeBattery - this.internalMaxPower; + } return 0; } else { if( this.internalCurrentPower < 0.01 && amt > 0.01 ) + { this.PowerEvent( PowerEventType.PROVIDE_POWER ); + } this.internalCurrentPower += amt; if( this.internalCurrentPower > this.internalMaxPower ) @@ -163,7 +169,9 @@ public abstract class AERootPoweredTile extends AEBaseInvTile implements IAEPowe if( mode == Actionable.SIMULATE ) { if( this.internalCurrentPower > amt ) + { return amt; + } return this.internalCurrentPower; } diff --git a/src/main/java/appeng/tile/powersink/MekJoules.java b/src/main/java/appeng/tile/powersink/MekJoules.java index 78f47007..ef6d8d79 100644 --- a/src/main/java/appeng/tile/powersink/MekJoules.java +++ b/src/main/java/appeng/tile/powersink/MekJoules.java @@ -55,7 +55,9 @@ public abstract class MekJoules extends RedstoneFlux implements IStrictEnergyAcc { double demand = this.getExternalPowerDemand( PowerUnits.MK, Double.MAX_VALUE ); if( amount > demand ) + { amount = demand; + } double overflow = this.injectExternalPower( PowerUnits.MK, amount ); return amount - overflow; diff --git a/src/main/java/appeng/tile/powersink/RotaryCraft.java b/src/main/java/appeng/tile/powersink/RotaryCraft.java index bdbf43d6..b8ffbbb3 100644 --- a/src/main/java/appeng/tile/powersink/RotaryCraft.java +++ b/src/main/java/appeng/tile/powersink/RotaryCraft.java @@ -45,7 +45,9 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver public void Tick_RotaryCraft() { if( this.worldObj != null && !this.worldObj.isRemote && this.power > 0 ) + { this.injectExternalPower( PowerUnits.WA, this.power ); + } } @Override @@ -88,7 +90,9 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver public final void setPower( long p ) { if( Platform.isClient() ) + { return; + } this.power = p; } @@ -118,17 +122,29 @@ public abstract class RotaryCraft extends IC2 implements ShaftPowerReceiver ForgeDirection side = ForgeDirection.UNKNOWN; if( x == this.xCoord - 1 ) + { side = ForgeDirection.WEST; + } else if( x == this.xCoord + 1 ) + { side = ForgeDirection.EAST; + } else if( z == this.zCoord - 1 ) + { side = ForgeDirection.NORTH; + } else if( z == this.zCoord + 1 ) + { side = ForgeDirection.SOUTH; + } else if( y == this.yCoord - 1 ) + { side = ForgeDirection.DOWN; + } else if( y == this.yCoord + 1 ) + { side = ForgeDirection.UP; + } return this.getPowerSides().contains( side ); } diff --git a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java index f49a52d5..a6a997bd 100644 --- a/src/main/java/appeng/tile/qnb/TileQuantumBridge.java +++ b/src/main/java/appeng/tile/qnb/TileQuantumBridge.java @@ -83,7 +83,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock { this.updateStatus = false; if( this.cluster != null ) + { this.cluster.updateStatus( true ); + } this.markForUpdate(); } } @@ -94,10 +96,14 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock int out = this.constructed; if( this.getStackInSlot( 0 ) != null && this.constructed != -1 ) + { out |= this.hasSingularity; + } if( this.gridProxy.isActive() && this.constructed != -1 ) + { out |= this.powered; + } data.writeByte( (byte) out ); } @@ -121,14 +127,18 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock public void onChangeInventory( IInventory inv, int slot, InvOperation mc, ItemStack removed, ItemStack added ) { if( this.cluster != null ) + { this.cluster.updateStatus( true ); + } } @Override public int[] getAccessibleSlotsBySide( ForgeDirection side ) { if( this.isCenter() ) + { return this.sidesLink; + } return this.sidesRing; } @@ -187,7 +197,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock if( this.cluster != null ) { if( !affectWorld ) + { this.cluster.updateStatus = false; + } this.cluster.destroy(); } @@ -195,7 +207,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock this.cluster = null; if( affectWorld ) + { this.gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) ); + } } @Override @@ -227,7 +241,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock this.gridProxy.setValidSides( this.getConnections() ); } else + { this.gridProxy.setValidSides( EnumSet.allOf( ForgeDirection.class ) ); + } } } @@ -244,7 +260,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock { TileEntity te = this.worldObj.getTileEntity( this.xCoord + d.offsetX, this.yCoord + d.offsetY, this.zCoord + d.offsetZ ); if( te instanceof TileQuantumBridge ) + { set.add( d ); + } } return set; @@ -257,7 +275,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock { NBTTagCompound c = is.getTagCompound(); if( c != null ) + { return c.getLong( "freq" ); + } } return 0; } @@ -265,7 +285,9 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock public boolean isPowered() { if( Platform.isClient() ) + { return ( this.constructed & this.powered ) == this.powered && this.constructed != -1; + } try { @@ -304,13 +326,17 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock public boolean hasQES() { if( this.constructed == -1 ) + { return false; + } return ( this.constructed & this.hasSingularity ) == this.hasSingularity; } public void breakCluster() { if( this.cluster != null ) + { this.cluster.destroy(); + } } } diff --git a/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java b/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java index 4925e0dc..105b5eeb 100644 --- a/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java +++ b/src/main/java/appeng/tile/spatial/TileSpatialIOPort.java @@ -71,13 +71,17 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable public void readFromNBT_TileSpatialIOPort( NBTTagCompound data ) { if( data.hasKey( "lastRedstoneState" ) ) + { this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )]; + } } public boolean getRedstoneState() { if( this.lastRedstoneState == YesNo.UNDECIDED ) + { this.updateRedstoneState(); + } return this.lastRedstoneState == YesNo.YES; } @@ -89,7 +93,9 @@ public class TileSpatialIOPort extends AENetworkInvTile implements Callable { this.lastRedstoneState = currentState; if( this.lastRedstoneState == YesNo.YES ) + { this.triggerTransition(); + } } } diff --git a/src/main/java/appeng/tile/spatial/TileSpatialPylon.java b/src/main/java/appeng/tile/spatial/TileSpatialPylon.java index 35f276ed..07de63be 100644 --- a/src/main/java/appeng/tile/spatial/TileSpatialPylon.java +++ b/src/main/java/appeng/tile/spatial/TileSpatialPylon.java @@ -136,11 +136,17 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock if( this.cluster != null ) { if( this.cluster.min.equals( this.getLocation() ) ) + { this.displayBits = this.DISPLAY_END_MIN; + } else if( this.cluster.max.equals( this.getLocation() ) ) + { this.displayBits = this.DISPLAY_END_MAX; + } else + { this.displayBits = this.DISPLAY_MIDDLE; + } switch( this.cluster.currentAxis ) { @@ -161,10 +167,14 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock try { if( this.gridProxy.getEnergy().isNetworkPowered() ) + { this.displayBits |= this.DISPLAY_POWERED_ENABLED; + } if( this.cluster.isValid && this.gridProxy.isActive() ) + { this.displayBits |= this.DISPLAY_ENABLED; + } } catch( GridAccessException e ) { @@ -173,7 +183,9 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock } if( oldBits != this.displayBits ) + { this.markForUpdate(); + } } @Override diff --git a/src/main/java/appeng/tile/storage/TileChest.java b/src/main/java/appeng/tile/storage/TileChest.java index 64fe50d3..1fb1bd09 100644 --- a/src/main/java/appeng/tile/storage/TileChest.java +++ b/src/main/java/appeng/tile/storage/TileChest.java @@ -140,7 +140,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan } } else + { this.recalculateDisplay(); + } } private void recalculateDisplay() @@ -148,12 +150,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan int oldState = this.state; for( int x = 0; x < this.getCellCount(); x++ ) + { this.state |= ( this.getCellStatus( x ) << ( 3 * x ) ); + } if( this.isPowered() ) + { this.state |= 0x40; + } else + { this.state &= ~0x40; + } boolean currentActive = this.gridProxy.isActive(); if( this.wasActive != currentActive ) @@ -170,7 +178,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan } if( oldState != this.state ) + { this.markForUpdate(); + } } @Override @@ -199,9 +209,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan IMEInventoryHandler fluidCell = this.cellHandler.getCellInventory( is, this, StorageChannel.FLUIDS ); if( itemCell != null ) + { power += this.cellHandler.cellIdleDrain( is, itemCell ); + } else if( fluidCell != null ) + { power += this.cellHandler.cellIdleDrain( is, fluidCell ); + } this.gridProxy.setIdlePowerUsage( power ); @@ -215,11 +229,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { case FLUIDS: if( this.fluidCell == null ) + { throw NO_HANDLER; + } return this.fluidCell; case ITEMS: if( this.itemCell == null ) + { throw NO_HANDLER; + } return this.itemCell; default: } @@ -230,7 +248,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan private MEMonitorHandler wrap( IMEInventoryHandler h ) { if( h == null ) + { return null; + } MEInventoryHandler ih = new MEInventoryHandler( h, h.getChannel() ); ih.setPriority( this.priority ); @@ -245,7 +265,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public int getCellStatus( int slot ) { if( Platform.isClient() ) + { return ( this.state >> ( slot * 3 ) ) & 3; + } ItemStack cell = this.inv.getStackInSlot( 1 ); ICellHandler ch = AEApi.instance().registries().cell().getHandler( cell ); @@ -256,7 +278,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { IMEInventoryHandler handler = this.getHandler( StorageChannel.ITEMS ); if( handler instanceof ChestMonitorHandler ) + { return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() ); + } } catch( ChestNoHandler ignored ) { @@ -266,7 +290,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { IMEInventoryHandler handler = this.getHandler( StorageChannel.FLUIDS ); if( handler instanceof ChestMonitorHandler ) + { return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() ); + } } catch( ChestNoHandler ignored ) { @@ -280,7 +306,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public boolean isPowered() { if( Platform.isClient() ) + { return ( this.state & 0x40 ) == 0x40; + } boolean gridPowered = this.getAECurrentPower() > 64; @@ -303,7 +331,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { long now = this.worldObj.getTotalWorldTime(); if( now - this.lastStateChange > 8 ) + { return false; + } return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01; } @@ -319,7 +349,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan eg = this.gridProxy.getEnergy(); stash = eg.extractAEPower( amt, mode, PowerMultiplier.ONE ); if( stash >= amt ) + { return stash; + } } catch( GridAccessException e ) { @@ -334,7 +366,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public void Tick_TileChest() { if( this.worldObj.isRemote ) + { return; + } double idleUsage = this.gridProxy.getIdlePowerUsage(); @@ -344,14 +378,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { double powerUsed = this.extractAEPower( idleUsage, Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 ) + { this.recalculateDisplay(); + } } } catch( GridAccessException e ) { double powerUsed = this.extractAEPower( this.gridProxy.getIdlePowerUsage(), Actionable.MODULATE, PowerMultiplier.CONFIG ); // drain if( powerUsed + 0.1 >= idleUsage != ( this.state & 0x40 ) > 0 ) + { this.recalculateDisplay(); + } } if( this.inv.getStackInSlot( 0 ) != null ) @@ -364,17 +402,27 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public void writeToStream_TileChest( ByteBuf data ) { if( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 ) + { this.state = 0; + } else + { this.state &= 0x24924924; // just keep the blinks... + } for( int x = 0; x < this.getCellCount(); x++ ) + { this.state |= ( this.getCellStatus( x ) << ( 3 * x ) ); + } if( this.isPowered() ) + { this.state |= 0x40; + } else + { this.state &= ~0x40; + } data.writeByte( this.state ); data.writeByte( this.paintedColor.ordinal() ); @@ -404,9 +452,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan int item = data.readInt(); if( item == 0 ) + { this.storageType = null; + } else + { this.storageType = new ItemStack( Item.getItemById( item & 0xffff ), 1, item >> Platform.DEF_OFFSET ); + } this.lastStateChange = this.worldObj.getTotalWorldTime(); @@ -419,7 +471,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan this.config.readFromNBT( data ); this.priority = data.getInteger( "priority" ); if( data.hasKey( "paintedColor" ) ) + { this.paintedColor = AEColor.values()[data.getByte( "paintedColor" )]; + } } @TileEvent( TileEventType.WORLD_NBT_WRITE ) @@ -503,9 +557,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan if( slotIndex == 1 ) { if( AEApi.instance().registries().cell().getCellInventory( insertingItem, this, StorageChannel.ITEMS ) != null ) + { return true; + } if( AEApi.instance().registries().cell().getCellInventory( insertingItem, this, StorageChannel.FLUIDS ) != null ) + { return true; + } } else { @@ -532,14 +590,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public int[] getAccessibleSlotsBySide( ForgeDirection side ) { if( ForgeDirection.SOUTH == side ) + { return FRONT; + } if( this.isPowered() ) { try { if( this.getHandler( StorageChannel.ITEMS ) != null ) + { return SIDES; + } } catch( ChestNoHandler e ) { @@ -560,9 +622,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan IAEItemStack returns = Platform.poweredInsert( this, cell, AEApi.instance().storage().createItemStack( this.inv.getStackInSlot( 0 ) ), this.mySrc ); if( returns == null ) + { this.inv.setInventorySlotContents( 0, null ); + } else + { this.inv.setInventorySlotContents( 0, returns.getItemStack() ); + } } } catch( ChestNoHandler ignored ) @@ -617,7 +683,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { long now = this.worldObj.getTotalWorldTime(); if( now - this.lastStateChange > 8 ) + { this.state = 0; + } this.lastStateChange = now; this.state |= 1 << ( slot * 3 + 2 ); @@ -640,7 +708,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan IAEStack results = h.injectItems( AEFluidStack.create( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE, this.mySrc ); if( results == null ) + { return resource.amount; + } return resource.amount - (int) results.getStackSize(); } @@ -690,7 +760,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { IMEInventoryHandler h = this.getHandler( StorageChannel.FLUIDS ); if( h.getChannel() == StorageChannel.FLUIDS ) + { return new FluidTankInfo[] { new FluidTankInfo( null, 1 ) }; // eh? + } } catch( ChestNoHandler ignored ) { @@ -703,14 +775,18 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public IStorageMonitorable getMonitorable( ForgeDirection side, BaseActionSource src ) { if( Platform.canAccess( this.gridProxy, src ) && side != this.getForward() ) + { return this; + } return null; } public ItemStack getStorageType() { if( this.isPowered() ) + { return this.storageType; + } return null; } @@ -769,7 +845,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public boolean recolourBlock( ForgeDirection side, AEColor newPaintedColor, EntityPlayer who ) { if( this.paintedColor == newPaintedColor ) + { return false; + } this.paintedColor = newPaintedColor; this.markDirty(); @@ -803,9 +881,13 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public boolean isValid( Object verificationToken ) { if( this.chan == StorageChannel.ITEMS ) + { return verificationToken == TileChest.this.itemCell; + } if( this.chan == StorageChannel.FLUIDS ) + { return verificationToken == TileChest.this.fluidCell; + } return false; } @@ -817,7 +899,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan try { if( TileChest.this.gridProxy.isActive() ) + { TileChest.this.gridProxy.getStorage().postAlterationOfStoredItems( this.chan, change, TileChest.this.mySrc ); + } } catch( GridAccessException e ) { @@ -848,7 +932,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan { IMEInventoryHandler h = this.getHandler(); if( h instanceof MEInventoryHandler ) + { return (IMEInventoryHandler) ( (MEInventoryHandler) h ).getInternal(); + } return this.getHandler(); } @@ -856,7 +942,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public T injectItems( T input, Actionable mode, BaseActionSource src ) { if( src.isPlayer() && !this.securityCheck( ( (PlayerSource) src ).player, SecurityPermissions.INJECT ) ) + { return input; + } return super.injectItems( input, mode, src ); } @@ -883,7 +971,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan ISecurityGrid sg = g.getCache( ISecurityGrid.class ); if( sg.hasPermission( player, requiredPermission ) ) + { return true; + } } } @@ -896,7 +986,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, IFluidHan public T extractItems( T request, Actionable mode, BaseActionSource src ) { if( src.isPlayer() && !this.securityCheck( ( (PlayerSource) src ).player, SecurityPermissions.EXTRACT ) ) + { return null; + } return super.extractItems( request, mode, src ); } } diff --git a/src/main/java/appeng/tile/storage/TileDrive.java b/src/main/java/appeng/tile/storage/TileDrive.java index 1d04e6b7..55cd67a3 100644 --- a/src/main/java/appeng/tile/storage/TileDrive.java +++ b/src/main/java/appeng/tile/storage/TileDrive.java @@ -85,17 +85,27 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior public void writeToStream_TileDrive( ByteBuf data ) { if( this.worldObj.getTotalWorldTime() - this.lastStateChange > 8 ) + { this.state = 0; + } else + { this.state &= 0x24924924; // just keep the blinks... + } if( this.gridProxy.isActive() ) + { this.state |= 0x80000000; + } else + { this.state &= ~0x80000000; + } for( int x = 0; x < this.getCellCount(); x++ ) + { this.state |= ( this.getCellStatus( x ) << ( 3 * x ) ); + } data.writeInt( this.state ); } @@ -110,25 +120,33 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior public int getCellStatus( int slot ) { if( Platform.isClient() ) + { return ( this.state >> ( slot * 3 ) ) & 3; + } ItemStack cell = this.inv.getStackInSlot( 2 ); ICellHandler ch = this.handlersBySlot[slot]; MEInventoryHandler handler = this.invBySlot[slot]; if( handler == null ) + { return 0; + } if( handler.getChannel() == StorageChannel.ITEMS ) { if( ch != null ) + { return ch.getStatusForCell( cell, handler.getInternal() ); + } } if( handler.getChannel() == StorageChannel.FLUIDS ) { if( ch != null ) + { return ch.getStatusForCell( cell, handler.getInternal() ); + } } return 0; @@ -138,7 +156,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior public boolean isPowered() { if( Platform.isClient() ) + { return ( this.state & 0x80000000 ) == 0x80000000; + } return this.gridProxy.isActive(); } @@ -148,7 +168,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior { long now = this.worldObj.getTotalWorldTime(); if( now - this.lastStateChange > 8 ) + { return false; + } return ( ( this.state >> ( slot * 3 + 2 ) ) & 0x01 ) == 0x01; } @@ -187,9 +209,13 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior boolean currentActive = this.gridProxy.isActive(); if( currentActive ) + { this.state |= 0x80000000; + } else + { this.state &= ~0x80000000; + } if( this.wasActive != currentActive ) { @@ -205,10 +231,14 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior } for( int x = 0; x < this.getCellCount(); x++ ) + { this.state |= ( this.getCellStatus( x ) << ( 3 * x ) ); + } if( oldState != this.state ) + { this.markForUpdate(); + } } @MENetworkEventSubscribe @@ -374,7 +404,9 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior { long now = this.worldObj.getTotalWorldTime(); if( now - this.lastStateChange > 8 ) + { this.state = 0; + } this.lastStateChange = now; this.state |= 1 << ( slot * 3 + 2 ); diff --git a/src/main/java/appeng/tile/storage/TileIOPort.java b/src/main/java/appeng/tile/storage/TileIOPort.java index 7777fe06..9c2d9e2e 100644 --- a/src/main/java/appeng/tile/storage/TileIOPort.java +++ b/src/main/java/appeng/tile/storage/TileIOPort.java @@ -135,7 +135,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC this.cells.readFromNBT( data, "cells" ); this.upgrades.readFromNBT( data, "upgrades" ); if( data.hasKey( "lastRedstoneState" ) ) + { this.lastRedstoneState = YesNo.values()[data.getInteger( "lastRedstoneState" )]; + } } @Override @@ -155,9 +157,13 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC try { if( this.hasWork() ) + { this.gridProxy.getTick().wakeDevice( this.gridProxy.getNode() ); + } else + { this.gridProxy.getTick().sleepDevice( this.gridProxy.getNode() ); + } } catch( GridAccessException e ) { @@ -178,7 +184,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC public boolean getRedstoneState() { if( this.lastRedstoneState == YesNo.UNDECIDED ) + { this.updateRedstoneState(); + } return this.lastRedstoneState == YesNo.YES; } @@ -186,11 +194,15 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC private boolean isEnabled() { if( this.getInstalledUpgrades( Upgrades.REDSTONE ) == 0 ) + { return true; + } RedstoneMode rs = (RedstoneMode) this.manager.getSetting( Settings.REDSTONE_CONTROLLED ); if( rs == RedstoneMode.HIGH_SIGNAL ) + { return this.getRedstoneState(); + } return !this.getRedstoneState(); } @@ -204,10 +216,14 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC public IInventory getInventoryByName( String name ) { if( name.equals( "upgrades" ) ) + { return this.upgrades; + } if( name.equals( "cells" ) ) + { return this.cells; + } return null; } @@ -223,8 +239,12 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC if( this.isEnabled() ) { for( int x = 0; x < 6; x++ ) + { if( this.cells.getStackInSlot( x ) != null ) + { return true; + } + } } return false; @@ -277,7 +297,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC public int[] getAccessibleSlotsBySide( ForgeDirection d ) { if( d == ForgeDirection.UP || d == ForgeDirection.DOWN ) + { return this.input; + } return this.output; } @@ -292,7 +314,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC public TickRateModulation tickingRequest( IGridNode node, int TicksSinceLastCall ) { if( !this.gridProxy.isActive() ) + { return TickRateModulation.IDLE; + } long ItemsToMove = 256; @@ -327,25 +351,37 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY ) { if( itemInv != null ) + { ItemsToMove = this.transferContents( energy, itemInv, itemNet, ItemsToMove, StorageChannel.ITEMS ); + } if( fluidInv != null ) + { ItemsToMove = this.transferContents( energy, fluidInv, fluidNet, ItemsToMove, StorageChannel.FLUIDS ); + } } else { if( itemInv != null ) + { ItemsToMove = this.transferContents( energy, itemNet, itemInv, ItemsToMove, StorageChannel.ITEMS ); + } if( fluidInv != null ) + { ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove, StorageChannel.FLUIDS ); + } } if( ItemsToMove > 0 && this.shouldMove( itemInv, fluidInv ) && !this.moveSlot( x ) ) + { return TickRateModulation.IDLE; + } return TickRateModulation.URGENT; } else + { return TickRateModulation.URGENT; + } } } } @@ -374,7 +410,9 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC } if( StorageChannel.ITEMS == chan ) + { return this.cachedItem; + } return this.cachedFluid; } @@ -383,9 +421,13 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC { IItemList myList; if( src instanceof IMEMonitor ) + { myList = ( (IMEMonitor) src ).getStorageList(); + } else + { myList = src.getAvailableItems( src.getChannel().createList() ); + } boolean didStuff; @@ -402,9 +444,13 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC long possible = 0; if( stack == null ) + { possible = totalStackSize; + } else + { possible = totalStackSize - stack.getStackSize(); + } if( possible > 0 ) { @@ -445,11 +491,17 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC FullnessMode fm = (FullnessMode) this.manager.getSetting( Settings.FULLNESS_MODE ); if( itemInv != null && fluidInv != null ) + { return this.matches( fm, itemInv ) && this.matches( fm, fluidInv ); + } else if( itemInv != null ) + { return this.matches( fm, itemInv ); + } else if( fluidInv != null ) + { return this.matches( fm, fluidInv ); + } return true; } @@ -471,17 +523,25 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC private boolean matches( FullnessMode fm, IMEInventory src ) { if( fm == FullnessMode.HALF ) + { return true; + } IItemList myList; if( src instanceof IMEMonitor ) + { myList = ( (IMEMonitor) src ).getStorageList(); + } else + { myList = src.getAvailableItems( src.getChannel().createList() ); + } if( fm == FullnessMode.EMPTY ) + { return myList.isEmpty(); + } IAEStack test = myList.getFirstItem(); if( test != null ) diff --git a/src/main/java/appeng/tile/storage/TileSkyChest.java b/src/main/java/appeng/tile/storage/TileSkyChest.java index ca8f902a..4f2bccc9 100644 --- a/src/main/java/appeng/tile/storage/TileSkyChest.java +++ b/src/main/java/appeng/tile/storage/TileSkyChest.java @@ -57,7 +57,9 @@ public class TileSkyChest extends AEBaseInvTile this.playerOpen = data.readBoolean() ? 1 : 0; if( wasOpen != this.playerOpen ) + { this.lastEvent = System.currentTimeMillis(); + } return false; // TESR yo! } @@ -78,7 +80,9 @@ public class TileSkyChest extends AEBaseInvTile public void openInventory() { if( Platform.isClient() ) + { return; + } this.playerOpen++; @@ -93,12 +97,16 @@ public class TileSkyChest extends AEBaseInvTile public void closeInventory() { if( Platform.isClient() ) + { return; + } this.playerOpen--; if( this.playerOpen < 0 ) + { this.playerOpen = 0; + } if( this.playerOpen == 0 ) { diff --git a/src/main/java/appeng/transformer/asm/ASMIntegration.java b/src/main/java/appeng/transformer/asm/ASMIntegration.java index 14bd8aef..fa2a4194 100644 --- a/src/main/java/appeng/transformer/asm/ASMIntegration.java +++ b/src/main/java/appeng/transformer/asm/ASMIntegration.java @@ -72,7 +72,9 @@ public final class ASMIntegration implements IClassTransformer public byte[] transform( String name, String transformedName, byte[] basicClass ) { if( basicClass == null || transformedName.startsWith( "appeng.transformer" ) ) + { return basicClass; + } if( transformedName.startsWith( "appeng." ) ) { @@ -110,14 +112,18 @@ public final class ASMIntegration implements IClassTransformer if( this.hasAnnotation( an, Integration.Interface.class ) ) { if( this.stripInterface( classNode, Integration.Interface.class, an ) ) + { changed = true; + } } else if( this.hasAnnotation( an, Integration.InterfaceList.class ) ) { for( Object o : ( (Iterable) an.values.get( 1 ) ) ) { if( this.stripInterface( classNode, Integration.InterfaceList.class, (AnnotationNode) o ) ) + { changed = true; + } } } } @@ -135,14 +141,18 @@ public final class ASMIntegration implements IClassTransformer if( this.hasAnnotation( an, Integration.Method.class ) ) { if( this.stripMethod( classNode, mn, i, Integration.Method.class, an ) ) + { changed = true; + } } } } } if( changed ) + { this.log( "Updated " + classNode.name ); + } return changed; } @@ -155,20 +165,30 @@ public final class ASMIntegration implements IClassTransformer private boolean stripInterface( ClassNode classNode, Class class1, AnnotationNode an ) { if( an.values.size() != 4 ) + { throw new IllegalArgumentException( "Unable to handle Interface annotation on " + classNode.name ); + } String iFace = null; String iName = null; if( an.values.get( 0 ).equals( "iface" ) ) + { iFace = (String) an.values.get( 1 ); + } else if( an.values.get( 2 ).equals( "iface" ) ) + { iFace = (String) an.values.get( 3 ); + } if( an.values.get( 0 ).equals( "iname" ) ) + { iName = (String) an.values.get( 1 ); + } else if( an.values.get( 2 ).equals( "iname" ) ) + { iName = (String) an.values.get( 3 ); + } if( iName != null && iFace != null ) { @@ -180,10 +200,14 @@ public final class ASMIntegration implements IClassTransformer return true; } else + { this.log( "Allowing Interface " + iFace + " from " + classNode.name + " because " + iName + " integration is enabled." ); + } } else + { throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name ); + } return false; } @@ -191,12 +215,16 @@ public final class ASMIntegration implements IClassTransformer private boolean stripMethod( ClassNode classNode, MethodNode mn, Iterator i, Class class1, AnnotationNode an ) { if( an.values.size() != 2 ) + { throw new IllegalArgumentException( "Unable to handle Method annotation on " + classNode.name ); + } String iName = null; if( an.values.get( 0 ).equals( "iname" ) ) + { iName = (String) an.values.get( 1 ); + } if( iName != null ) { @@ -208,10 +236,14 @@ public final class ASMIntegration implements IClassTransformer return true; } else + { this.log( "Allowing Method " + mn.name + " from " + classNode.name + " because " + iName + " integration is enabled." ); + } } else + { throw new IllegalStateException( "Unable to handle Method annotation on " + classNode.name ); + } return false; } diff --git a/src/main/java/appeng/transformer/asm/ASMTweaker.java b/src/main/java/appeng/transformer/asm/ASMTweaker.java index 76c15e5b..c37d8e4c 100644 --- a/src/main/java/appeng/transformer/asm/ASMTweaker.java +++ b/src/main/java/appeng/transformer/asm/ASMTweaker.java @@ -69,7 +69,9 @@ public final class ASMTweaker implements IClassTransformer public byte[] transform( String name, String transformedName, byte[] basicClass ) { if( basicClass == null ) + { return null; + } try { diff --git a/src/main/java/appeng/util/BlockUpdate.java b/src/main/java/appeng/util/BlockUpdate.java index 9d208927..b199e7ab 100644 --- a/src/main/java/appeng/util/BlockUpdate.java +++ b/src/main/java/appeng/util/BlockUpdate.java @@ -44,7 +44,9 @@ public class BlockUpdate implements Callable public Object call() throws Exception { if( this.w.blockExists( this.x, this.y, this.z ) ) + { this.w.notifyBlocksOfNeighborChange( this.x, this.y, this.z, Platform.AIR ); + } return true; } diff --git a/src/main/java/appeng/util/ClassInstantiation.java b/src/main/java/appeng/util/ClassInstantiation.java index 7c9f4681..af3ae018 100644 --- a/src/main/java/appeng/util/ClassInstantiation.java +++ b/src/main/java/appeng/util/ClassInstantiation.java @@ -54,7 +54,9 @@ public class ClassInstantiation { Class cz = this.args[idx].getClass(); if( !this.isClassMatch( paramTypes[idx], cz, this.args[idx] ) ) + { valid = false; + } } if( valid ) @@ -86,7 +88,9 @@ public class ClassInstantiation private boolean isClassMatch( Class expected, Class got, Object value ) { if( value == null && !expected.isPrimitive() ) + { return true; + } expected = this.condense( expected, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class ); got = this.condense( got, Boolean.class, Character.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class ); @@ -103,7 +107,9 @@ public class ClassInstantiation try { if( expected == clz.getField( "TYPE" ).get( null ) ) + { return clz; + } } catch( Throwable t ) { diff --git a/src/main/java/appeng/util/ConfigManager.java b/src/main/java/appeng/util/ConfigManager.java index 65f3a8c2..8b505fd5 100644 --- a/src/main/java/appeng/util/ConfigManager.java +++ b/src/main/java/appeng/util/ConfigManager.java @@ -60,7 +60,9 @@ public final class ConfigManager implements IConfigManager Enum oldValue = this.settings.get( settingName ); if( oldValue != null ) + { return oldValue; + } throw new IllegalStateException( "Invalid Config setting. Expected a non-null value for " + settingName ); } diff --git a/src/main/java/appeng/util/InventoryAdaptor.java b/src/main/java/appeng/util/InventoryAdaptor.java index 22e96ac7..00c08978 100644 --- a/src/main/java/appeng/util/InventoryAdaptor.java +++ b/src/main/java/appeng/util/InventoryAdaptor.java @@ -47,7 +47,9 @@ public abstract class InventoryAdaptor implements Iterable public static InventoryAdaptor getAdaptor( Object te, ForgeDirection d ) { if( te == null ) + { return null; + } IBetterStorage bs = (IBetterStorage) ( AppEng.instance.isIntegrationEnabled( IntegrationType.BetterStorage ) ? AppEng.instance.getIntegration( IntegrationType.BetterStorage ) : null ); @@ -75,13 +77,17 @@ public abstract class InventoryAdaptor implements Iterable ISidedInventory si = (ISidedInventory) te; int[] slots = si.getAccessibleSlotsFromSide( d.ordinal() ); if( si.getSizeInventory() > 0 && slots != null && slots.length > 0 ) + { return new AdaptorIInventory( new WrapperMCISidedInventory( si, d ) ); + } } else if( te instanceof IInventory ) { IInventory i = (IInventory) te; if( i.getSizeInventory() > 0 ) + { return new AdaptorIInventory( i ); + } } return null; diff --git a/src/main/java/appeng/util/ItemSorters.java b/src/main/java/appeng/util/ItemSorters.java index 4df2faf6..e6562450 100644 --- a/src/main/java/appeng/util/ItemSorters.java +++ b/src/main/java/appeng/util/ItemSorters.java @@ -40,7 +40,9 @@ public class ItemSorters public int compare( IAEItemStack o1, IAEItemStack o2 ) { if( Direction == SortDir.ASCENDING ) + { return Platform.getItemDisplayName( o1 ).compareToIgnoreCase( Platform.getItemDisplayName( o2 ) ); + } return Platform.getItemDisplayName( o2 ).compareToIgnoreCase( Platform.getItemDisplayName( o1 ) ); } }; @@ -54,14 +56,18 @@ public class ItemSorters AEItemStack op2 = (AEItemStack) o2; if( Direction == SortDir.ASCENDING ) + { return this.secondarySort( op2.getModID().compareToIgnoreCase( op1.getModID() ), o1, o2 ); + } return this.secondarySort( op1.getModID().compareToIgnoreCase( op2.getModID() ), o2, o1 ); } private int secondarySort( int compareToIgnoreCase, IAEItemStack o1, IAEItemStack o2 ) { if( compareToIgnoreCase == 0 ) + { return Platform.getItemDisplayName( o2 ).compareToIgnoreCase( Platform.getItemDisplayName( o1 ) ); + } return compareToIgnoreCase; } @@ -73,7 +79,9 @@ public class ItemSorters public int compare( IAEItemStack o1, IAEItemStack o2 ) { if( Direction == SortDir.ASCENDING ) + { return compareLong( o2.getStackSize(), o1.getStackSize() ); + } return compareLong( o1.getStackSize(), o2.getStackSize() ); } }; @@ -85,12 +93,16 @@ public class ItemSorters public int compare( IAEItemStack o1, IAEItemStack o2 ) { if( api == null ) + { return CONFIG_BASED_SORT_BY_NAME.compare( o1, o2 ); + } int cmp = api.compareItems( o1.getItemStack(), o2.getItemStack() ); if( Direction == SortDir.ASCENDING ) + { return cmp; + } return -cmp; } }; @@ -98,38 +110,56 @@ public class ItemSorters public static void init() { if( api != null ) + { return; + } if( AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks ) ) + { api = (IInvTweaks) AppEng.instance.getIntegration( IntegrationType.InvTweaks ); + } else + { api = null; + } } public static int compareInt( int a, int b ) { if( a == b ) + { return 0; + } if( a < b ) + { return -1; + } return 1; } public static int compareLong( long a, long b ) { if( a == b ) + { return 0; + } if( a < b ) + { return -1; + } return 1; } public static int compareDouble( double a, double b ) { if( a == b ) + { return 0; + } if( a < b ) + { return -1; + } return 1; } } diff --git a/src/main/java/appeng/util/Platform.java b/src/main/java/appeng/util/Platform.java index 275daf25..eb049756 100644 --- a/src/main/java/appeng/util/Platform.java +++ b/src/main/java/appeng/util/Platform.java @@ -196,10 +196,14 @@ public class Platform String unitName = displayUnits.name(); if( displayUnits == PowerUnits.WA ) + { unitName = "J"; + } if( displayUnits == PowerUnits.MK ) + { unitName = "J"; + } while( p > 1000 && offset < preFixes.length ) { @@ -244,9 +248,13 @@ public class Platform do { if( backwards ) + { ce = prevEnum( ce ); + } else + { ce = nextEnum( ce ); + } } while( !ValidOptions.contains( ce ) || isNotValidSetting( ce ) ); @@ -262,16 +270,22 @@ public class Platform int pLoc = ce.ordinal() - 1; if( pLoc < 0 ) + { pLoc = valList.size() - 1; + } if( pLoc < 0 || pLoc >= valList.size() ) + { pLoc = 0; + } int pos = 0; for( Object g : valList ) { if( pos == pLoc ) + { return (T) g; + } pos++; } @@ -287,16 +301,22 @@ public class Platform int pLoc = ce.ordinal() + 1; if( pLoc >= valList.size() ) + { pLoc = 0; + } if( pLoc < 0 || pLoc >= valList.size() ) + { pLoc = 0; + } int pos = 0; for( Object g : valList ) { if( pos == pLoc ) + { return (T) g; + } pos++; } @@ -306,13 +326,19 @@ public class Platform private static boolean isNotValidSetting( Enum e ) { if( e == SortOrder.INVTWEAKS && !AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks ) ) + { return true; + } if( e == SearchBoxMode.NEI_AUTOSEARCH && !AppEng.instance.isIntegrationEnabled( IntegrationType.NEI ) ) + { return true; + } if( e == SearchBoxMode.NEI_MANUAL_SEARCH && !AppEng.instance.isIntegrationEnabled( IntegrationType.NEI ) ) + { return true; + } return false; } @@ -320,7 +346,9 @@ public class Platform public static void openGUI( @Nonnull EntityPlayer p, @Nullable TileEntity tile, @Nullable ForgeDirection side, @Nonnull GuiBridge type ) { if( isClient() ) + { return; + } int x = (int) p.posX; int y = (int) p.posY; @@ -335,11 +363,17 @@ public class Platform if( ( type.getType().isItem() && tile == null ) || type.hasPermissions( tile, x, y, z, side, p ) ) { if( tile == null && type.getType() == GuiHostType.ITEM ) + { p.openGui( AppEng.instance, type.ordinal() << 4 | ( 0 << 3 ), p.getEntityWorld(), p.inventory.currentItem, 0, 0 ); + } else if( tile == null || type.getType() == GuiHostType.ITEM ) + { p.openGui( AppEng.instance, type.ordinal() << 4 | ( 1 << 3 ), p.getEntityWorld(), x, y, z ); + } else + { p.openGui( AppEng.instance, type.ordinal() << 4 | ( side.ordinal() ), tile.getWorldObj(), x, y, z ); + } } } @@ -378,22 +412,34 @@ public class Platform public static boolean sameStackStags( ItemStack a, ItemStack b ) { if( a == null && b == null ) + { return true; + } if( a == null || b == null ) + { return false; + } if( a == b ) + { return true; + } NBTTagCompound ta = a.getTagCompound(); NBTTagCompound tb = b.getTagCompound(); if( ta == tb ) + { return true; + } if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) ) + { return true; + } if( ( ta == null && tb != null ) || ( ta != null && tb == null ) ) + { return false; + } // if both tags are shared this is easy... if( AESharedNBT.isShared( ta ) && AESharedNBT.isShared( tb ) ) @@ -426,7 +472,9 @@ public class Platform Set cB = ctB.func_150296_c(); if( cA.size() != cB.size() ) + { return false; + } for( String name : cA ) { @@ -451,20 +499,28 @@ public class Platform NBTTagList lA = (NBTTagList) A; NBTTagList lB = (NBTTagList) B; if( lA.tagCount() != lB.tagCount() ) + { return false; + } List tag = tagList( lA ); List aTag = tagList( lB ); if( tag.size() != aTag.size() ) + { return false; + } for( int x = 0; x < tag.size(); x++ ) { if( aTag.get( x ) == null ) + { return false; + } if( !NBTEqualityTest( tag.get( x ), aTag.get( x ) ) ) + { return false; + } } return true; @@ -624,7 +680,9 @@ public class Platform } if( out == null ) + { return new ItemStack[0]; + } return out.toArray( new ItemStack[out.size()] ); } @@ -739,7 +797,9 @@ public class Platform { teB = teA.getWorldObj().getTileEntity( teA.xCoord + 1, teA.yCoord, teA.zCoord ); if( !( teB instanceof TileEntityChest ) ) + { teB = null; + } } if( teB == null ) @@ -748,7 +808,9 @@ public class Platform { teB = teA.getWorldObj().getTileEntity( teA.xCoord - 1, teA.yCoord, teA.zCoord ); if( !( teB instanceof TileEntityChest ) ) + { teB = null; + } else { TileEntityChest x = teA; @@ -764,7 +826,9 @@ public class Platform { teB = teA.getWorldObj().getTileEntity( teA.xCoord, teA.yCoord, teA.zCoord + 1 ); if( !( teB instanceof TileEntityChest ) ) + { teB = null; + } } } @@ -774,7 +838,9 @@ public class Platform { teB = teA.getWorldObj().getTileEntity( teA.xCoord, teA.yCoord, teA.zCoord - 1 ); if( !( teB instanceof TileEntityChest ) ) + { teB = null; + } else { TileEntityChest x = teA; @@ -785,7 +851,9 @@ public class Platform } if( teB == null ) + { return teA; + } return new InventoryLargeChest( "", teA, (TileEntityChest) teB ); } @@ -820,7 +888,9 @@ public class Platform public static List getTooltip( Object o ) { if( o == null ) + { return new ArrayList(); + } ItemStack itemStack = null; if( o instanceof AEItemStack ) @@ -829,9 +899,13 @@ public class Platform return ais.getToolTip(); } else if( o instanceof ItemStack ) + { itemStack = (ItemStack) o; + } else + { return new ArrayList(); + } try { @@ -846,7 +920,9 @@ public class Platform public static String getModId( IAEItemStack is ) { if( is == null ) + { return "** Null"; + } String n = ( (AEItemStack) is ).getModID(); return n == null ? "** Null" : n; @@ -855,7 +931,9 @@ public class Platform public static String getItemDisplayName( Object o ) { if( o == null ) + { return "** Null"; + } ItemStack itemStack = null; if( o instanceof AEItemStack ) @@ -864,15 +942,21 @@ public class Platform return n == null ? "** Null" : n; } else if( o instanceof ItemStack ) + { itemStack = (ItemStack) o; + } else + { return "**Invalid Object"; + } try { String name = itemStack.getDisplayName(); if( name == null || name.isEmpty() ) + { name = itemStack.getItem().getUnlocalizedName( itemStack ); + } return name == null ? "** Null" : name; } catch( Exception errA ) @@ -892,10 +976,14 @@ public class Platform public static boolean hasSpecialComparison( IAEItemStack willAdd ) { if( willAdd == null ) + { return false; + } IAETagCompound tag = willAdd.getTagCompound(); if( tag != null && tag.getSpecialComparison() != null ) + { return true; + } return false; } @@ -904,7 +992,9 @@ public class Platform if( AESharedNBT.isShared( willAdd.getTagCompound() ) ) { if( ( (AESharedNBT) willAdd.getTagCompound() ).getSpecialComparison() != null ) + { return true; + } } return false; } @@ -938,7 +1028,9 @@ public class Platform public static boolean isChargeable( ItemStack i ) { if( i == null ) + { return false; + } Item it = i.getItem(); if( it instanceof IAEItemPowerStorage ) { @@ -950,11 +1042,15 @@ public class Platform public static EntityPlayer getPlayer( WorldServer w ) { if( w == null ) + { throw new InvalidParameterException( "World is null." ); + } EntityPlayer wrp = FAKE_PLAYERS.get( w ); if( wrp != null ) + { return wrp; + } EntityPlayer p = FakePlayerFactory.getMinecraft( w ); FAKE_PLAYERS.put( w, p ); @@ -998,7 +1094,9 @@ public class Platform for( int x = 0; x < l.length; x++ ) { if( l[x] == null ) + { return x; + } } return -1; } @@ -1014,14 +1112,18 @@ public class Platform } index--; if( i.hasNext() ) + { return i.next(); + } return null; // wtf? } public static ForgeDirection rotateAround( ForgeDirection forward, ForgeDirection axis ) { if( axis == ForgeDirection.UNKNOWN || forward == ForgeDirection.UNKNOWN ) + { return forward; + } switch( forward ) { @@ -1201,7 +1303,9 @@ public class Platform OreReference bOR = OreHelper.INSTANCE.isOre( b ); if( OreHelper.INSTANCE.sameOre( aOR, bOR ) ) + { return true; + } /* * // test ore dictionary.. int OreID = getOreID( a ); if ( OreID != -1 ) return OreID == getOreID( b ); @@ -1286,7 +1390,9 @@ public class Platform { // prevent killing / flying of mounts. if( entity1.riddenByEntity == p ) + { continue; + } f1 = 0.3F; AxisAlignedBB boundingBox = entity1.boundingBox.expand( f1, f1, f1 ); @@ -1341,7 +1447,9 @@ public class Platform long retrieved = 0; if( possible != null ) + { retrieved = possible.getStackSize(); + } double availablePower = energy.extractAEPower( retrieved, Actionable.SIMULATE, PowerMultiplier.CONFIG ); @@ -1371,7 +1479,9 @@ public class Platform long stored = input.getStackSize(); if( possible != null ) + { stored -= possible.getStackSize(); + } double availablePower = energy.extractAEPower( stored, Actionable.SIMULATE, PowerMultiplier.CONFIG ); @@ -1424,7 +1534,9 @@ public class Platform if( myItems != null ) { for( IAEItemStack is : myItems.getAvailableItems( itemChanges ) ) + { is.setStackSize( -is.getStackSize() ); + } } IMEInventory myFluids = AEApi.instance().registries().cell().getCellInventory( removed, null, StorageChannel.FLUIDS ); @@ -1432,7 +1544,9 @@ public class Platform if( myFluids != null ) { for( IAEFluidStack is : myFluids.getAvailableItems( fluidChanges ) ) + { is.setStackSize( -is.getStackSize() ); + } } } @@ -1441,12 +1555,16 @@ public class Platform IMEInventory myItems = AEApi.instance().registries().cell().getCellInventory( added, null, StorageChannel.ITEMS ); if( myItems != null ) + { myItems.getAvailableItems( itemChanges ); + } IMEInventory myFluids = AEApi.instance().registries().cell().getCellInventory( added, null, StorageChannel.FLUIDS ); if( myFluids != null ) + { myFluids.getAvailableItems( fluidChanges ); + } } gs.postAlterationOfStoredItems( StorageChannel.ITEMS, itemChanges, src ); @@ -1457,10 +1575,14 @@ public class Platform LinkedList changes = new LinkedList(); for( T is : before ) + { is.setStackSize( -is.getStackSize() ); + } for( T is : after ) + { before.add( is ); + } for( T is : before ) { @@ -1471,30 +1593,44 @@ public class Platform } if( !changes.isEmpty() ) + { meMonitorPassthrough.postChange( null, changes, source ); + } } public static int generateTileHash( TileEntity target ) { if( target == null ) + { return 0; + } int hash = target.hashCode(); if( target instanceof ITileStorageMonitorable ) + { return 0; + } else if( target instanceof TileEntityChest ) { TileEntityChest chest = (TileEntityChest) target; chest.checkForAdjacentChests(); if( chest.adjacentChestZNeg != null ) + { hash ^= chest.adjacentChestZNeg.hashCode(); + } else if( chest.adjacentChestZPos != null ) + { hash ^= chest.adjacentChestZPos.hashCode(); + } else if( chest.adjacentChestXPos != null ) + { hash ^= chest.adjacentChestXPos.hashCode(); + } else if( chest.adjacentChestXNeg != null ) + { hash ^= chest.adjacentChestXNeg.hashCode(); + } } else if( target instanceof IInventory ) { @@ -1509,7 +1645,9 @@ public class Platform int[] sides = ( (ISidedInventory) target ).getAccessibleSlotsFromSide( dir.ordinal() ); if( sides == null ) + { return 0; + } for( Integer Side : sides ) { @@ -1527,9 +1665,13 @@ public class Platform public static boolean securityCheck( GridNode a, GridNode b ) { if( a.lastSecurityKey == -1 && b.lastSecurityKey == -1 ) + { return false; + } else if( a.lastSecurityKey == b.lastSecurityKey ) + { return false; + } boolean a_isSecure = isPowered( a.getGrid() ) && a.lastSecurityKey != -1; boolean b_isSecure = isPowered( b.getGrid() ) && b.lastSecurityKey != -1; @@ -1541,13 +1683,19 @@ public class Platform // can't do that son... if( a_isSecure && b_isSecure ) + { return true; + } if( !a_isSecure && b_isSecure ) + { return checkPlayerPermissions( b.getGrid(), a.playerID ); + } if( a_isSecure && !b_isSecure ) + { return checkPlayerPermissions( a.getGrid(), b.playerID ); + } return false; } @@ -1555,7 +1703,9 @@ public class Platform private static boolean isPowered( IGrid grid ) { if( grid == null ) + { return false; + } IEnergyGrid eg = grid.getCache( IEnergyGrid.class ); return eg.isNetworkPowered(); @@ -1564,15 +1714,21 @@ public class Platform private static boolean checkPlayerPermissions( IGrid grid, int playerID ) { if( grid == null ) + { return false; + } ISecurityGrid gs = grid.getCache( ISecurityGrid.class ); if( gs == null ) + { return false; + } if( !gs.isAvailable() ) + { return false; + } return !gs.hasPermission( playerID, SecurityPermissions.BUILD ); } @@ -1629,13 +1785,17 @@ public class Platform IActionHost te = ( (MachineSource) src ).via; IGridNode n = te.getActionableNode(); if( n == null ) + { return false; + } int playerID = n.getPlayerID(); return gridProxy.getSecurity().hasPermission( playerID, SecurityPermissions.BUILD ); } else + { return false; + } } catch( GridAccessException gae ) { @@ -1648,7 +1808,9 @@ public class Platform if( energySrc.extractAEPower( 1, Actionable.SIMULATE, PowerMultiplier.CONFIG ) > 0.9 ) { if( providedTemplate == null ) + { return null; + } AEItemStack ae_req = AEItemStack.create( providedTemplate ); ae_req.setStackSize( 1 ); @@ -1706,7 +1868,9 @@ public class Platform if( ol != null && op != null && ol.getItem() == op.getItem() ) { if( ol.isItemStackDamageable() ) + { return true; + } return ol.getItemDamage() == ol.getItemDamage(); } return false; @@ -1725,7 +1889,9 @@ public class Platform public static ItemStack getContainerItem( ItemStack stackInSlot ) { if( stackInSlot == null ) + { return null; + } Item i = stackInSlot.getItem(); if( i == null || !i.hasContainerItem( stackInSlot ) ) @@ -1740,7 +1906,9 @@ public class Platform ItemStack ci = i.getContainerItem( stackInSlot.copy() ); if( ci != null && ci.isItemStackDamageable() && ci.getItemDamage() == ci.getMaxDamage() ) + { ci = null; + } return ci; } @@ -1748,13 +1916,17 @@ public class Platform public static void notifyBlocksOfNeighbors( World worldObj, int xCoord, int yCoord, int zCoord ) { if( !worldObj.isRemote ) + { TickHandler.INSTANCE.addCallable( worldObj, new BlockUpdate( worldObj, xCoord, yCoord, zCoord ) ); + } } public static boolean canRepair( AEFeature type, ItemStack a, ItemStack b ) { if( b == null || a == null ) + { return false; + } if( type == AEFeature.CertusQuartzTools ) { @@ -1764,7 +1936,9 @@ public class Platform } if( type == AEFeature.NetherQuartzTools ) + { return Items.quartz == b.getItem(); + } return false; } @@ -1824,7 +1998,9 @@ public class Platform } if( sendToAllPlayersWatchingChunk != null ) + { sendToAllPlayersWatchingChunk.invoke( playerInstance, new S21PacketChunkData( c, false, verticalBits ) ); + } } } } diff --git a/src/main/java/appeng/util/ReadableNumberConverter.java b/src/main/java/appeng/util/ReadableNumberConverter.java index 4a6404e2..91ae1e19 100644 --- a/src/main/java/appeng/util/ReadableNumberConverter.java +++ b/src/main/java/appeng/util/ReadableNumberConverter.java @@ -66,7 +66,9 @@ public enum ReadableNumberConverter implements ISlimReadableNumberConverter, IWi final String numberString = Long.toString( number ); int numberSize = numberString.length(); if( numberSize <= width ) + { return numberString; + } long base = number; double last = base * 1000; diff --git a/src/main/java/appeng/util/inv/AdaptorBCPipe.java b/src/main/java/appeng/util/inv/AdaptorBCPipe.java index 16ca23a0..2169928c 100644 --- a/src/main/java/appeng/util/inv/AdaptorBCPipe.java +++ b/src/main/java/appeng/util/inv/AdaptorBCPipe.java @@ -84,14 +84,22 @@ public class AdaptorBCPipe extends InventoryAdaptor public ItemStack addItems( ItemStack toBeAdded ) { if( this.i == null ) + { return toBeAdded; + } if( toBeAdded == null ) + { return null; + } if( toBeAdded.stackSize == 0 ) + { return null; + } if( this.bc.addItemsToPipe( this.i, toBeAdded, this.d ) ) + { return null; + } return toBeAdded; } @@ -99,7 +107,9 @@ public class AdaptorBCPipe extends InventoryAdaptor public ItemStack simulateAdd( ItemStack toBeSimulated ) { if( this.i == null ) + { return toBeSimulated; + } return null; } diff --git a/src/main/java/appeng/util/inv/AdaptorIInventory.java b/src/main/java/appeng/util/inv/AdaptorIInventory.java index ad5a0a5d..309255b1 100644 --- a/src/main/java/appeng/util/inv/AdaptorIInventory.java +++ b/src/main/java/appeng/util/inv/AdaptorIInventory.java @@ -54,9 +54,13 @@ public class AdaptorIInventory extends InventoryAdaptor { int boundAmounts = amount; if( boundAmounts > is.stackSize ) + { boundAmounts = is.stackSize; + } if( destination != null && !destination.canInsert( is ) ) + { boundAmounts = 0; + } if( boundAmounts > 0 ) { @@ -108,9 +112,13 @@ public class AdaptorIInventory extends InventoryAdaptor { int boundAmount = amount; if( boundAmount > is.stackSize ) + { boundAmount = is.stackSize; + } if( destination != null && !destination.canInsert( is ) ) + { boundAmount = 0; + } if( boundAmount > 0 ) { @@ -143,9 +151,13 @@ public class AdaptorIInventory extends InventoryAdaptor { int newAmount = amount; if( newAmount > is.stackSize ) + { newAmount = is.stackSize; + } if( destination != null && !destination.canInsert( is ) ) + { newAmount = 0; + } ItemStack rv = null; if( newAmount > 0 ) @@ -189,9 +201,13 @@ public class AdaptorIInventory extends InventoryAdaptor { int boundAmount = amount; if( boundAmount > is.stackSize ) + { boundAmount = is.stackSize; + } if( destination != null && !destination.canInsert( is ) ) + { boundAmount = 0; + } if( boundAmount > 0 ) { @@ -223,7 +239,9 @@ public class AdaptorIInventory extends InventoryAdaptor for( int x = 0; x < s; x++ ) { if( this.i.getStackInSlot( x ) != null ) + { return true; + } } return false; } @@ -302,7 +320,9 @@ public class AdaptorIInventory extends InventoryAdaptor boolean canRemoveStackFromSlot( int x, ItemStack is ) { if( this.wrapperEnabled ) + { return ( (IInventoryWrapper) this.i ).canRemoveItemFromSlot( x, is ); + } return true; } diff --git a/src/main/java/appeng/util/inv/AdaptorList.java b/src/main/java/appeng/util/inv/AdaptorList.java index 58b1f423..ade92397 100644 --- a/src/main/java/appeng/util/inv/AdaptorList.java +++ b/src/main/java/appeng/util/inv/AdaptorList.java @@ -50,9 +50,13 @@ public class AdaptorList extends InventoryAdaptor if( is != null && ( filter == null || Platform.isSameItemPrecise( is, filter ) ) ) { if( amount > is.stackSize ) + { amount = is.stackSize; + } if( destination != null && !destination.canInsert( is ) ) + { amount = 0; + } if( amount > 0 ) { @@ -62,7 +66,9 @@ public class AdaptorList extends InventoryAdaptor // remove it.. if( is.stackSize <= 0 ) + { this.i.remove( x ); + } return rv; } @@ -108,9 +114,13 @@ public class AdaptorList extends InventoryAdaptor if( is != null && ( filter == null || Platform.isSameItemFuzzy( is, filter, fuzzyMode ) ) ) { if( how_many > is.stackSize ) + { how_many = is.stackSize; + } if( destination != null && !destination.canInsert( is ) ) + { how_many = 0; + } if( how_many > 0 ) { @@ -120,7 +130,9 @@ public class AdaptorList extends InventoryAdaptor // remove it.. if( is.stackSize <= 0 ) + { this.i.remove( x ); + } return rv; } @@ -160,9 +172,13 @@ public class AdaptorList extends InventoryAdaptor public ItemStack addItems( ItemStack toBeAdded ) { if( toBeAdded == null ) + { return null; + } if( toBeAdded.stackSize == 0 ) + { return null; + } ItemStack left = toBeAdded.copy(); diff --git a/src/main/java/appeng/util/inv/AdaptorPlayerHand.java b/src/main/java/appeng/util/inv/AdaptorPlayerHand.java index 2722aa03..0155f7fa 100644 --- a/src/main/java/appeng/util/inv/AdaptorPlayerHand.java +++ b/src/main/java/appeng/util/inv/AdaptorPlayerHand.java @@ -48,7 +48,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor { ItemStack hand = this.p.inventory.getItemStack(); if( hand == null ) + { return null; + } if( filter == null || Platform.isSameItemPrecise( filter, hand ) ) { @@ -56,7 +58,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor result.stackSize = hand.stackSize > amount ? amount : hand.stackSize; hand.stackSize -= amount; if( hand.stackSize <= 0 ) + { this.p.inventory.setItemStack( null ); + } return result; } @@ -69,7 +73,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor ItemStack hand = this.p.inventory.getItemStack(); if( hand == null ) + { return null; + } if( filter == null || Platform.isSameItemPrecise( filter, hand ) ) { @@ -86,7 +92,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor { ItemStack hand = this.p.inventory.getItemStack(); if( hand == null ) + { return null; + } if( Filter == null || Platform.isSameItemFuzzy( Filter, hand, fuzzyMode ) ) { @@ -94,7 +102,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor result.stackSize = hand.stackSize > how_many ? how_many : hand.stackSize; hand.stackSize -= how_many; if( hand.stackSize <= 0 ) + { this.p.inventory.setItemStack( null ); + } return result; } @@ -107,7 +117,9 @@ public class AdaptorPlayerHand extends InventoryAdaptor ItemStack hand = this.p.inventory.getItemStack(); if( hand == null ) + { return null; + } if( Filter == null || Platform.isSameItemFuzzy( Filter, hand, fuzzyMode ) ) { @@ -124,23 +136,35 @@ public class AdaptorPlayerHand extends InventoryAdaptor { if( toBeAdded == null ) + { return null; + } if( toBeAdded.stackSize == 0 ) + { return null; + } if( this.p == null ) + { return toBeAdded; + } if( this.p.inventory == null ) + { return toBeAdded; + } ItemStack hand = this.p.inventory.getItemStack(); if( hand != null && !Platform.isSameItemPrecise( toBeAdded, hand ) ) + { return toBeAdded; + } int original = 0; ItemStack newHand = null; if( hand == null ) + { newHand = toBeAdded.copy(); + } else { newHand = hand; @@ -166,15 +190,21 @@ public class AdaptorPlayerHand extends InventoryAdaptor { ItemStack hand = this.p.inventory.getItemStack(); if( toBeSimulated == null ) + { return null; + } if( hand != null && !Platform.isSameItem( toBeSimulated, hand ) ) + { return toBeSimulated; + } int original = 0; ItemStack newHand = null; if( hand == null ) + { newHand = toBeSimulated.copy(); + } else { newHand = hand.copy(); diff --git a/src/main/java/appeng/util/inv/AdaptorPlayerInventory.java b/src/main/java/appeng/util/inv/AdaptorPlayerInventory.java index 2117b13f..57e79a38 100644 --- a/src/main/java/appeng/util/inv/AdaptorPlayerInventory.java +++ b/src/main/java/appeng/util/inv/AdaptorPlayerInventory.java @@ -35,9 +35,13 @@ public class AdaptorPlayerInventory implements IInventory { if( swap ) + { this.src = new WrapperChainedInventory( new WrapperInventoryRange( playerInv, 9, this.size - 9, false ), new WrapperInventoryRange( playerInv, 0, 9, false ) ); + } else + { this.src = playerInv; + } } @Override diff --git a/src/main/java/appeng/util/inv/IMEAdaptor.java b/src/main/java/appeng/util/inv/IMEAdaptor.java index 155e036f..d042090c 100644 --- a/src/main/java/appeng/util/inv/IMEAdaptor.java +++ b/src/main/java/appeng/util/inv/IMEAdaptor.java @@ -74,10 +74,14 @@ public class IMEAdaptor extends InventoryAdaptor { IItemList list = this.getList(); if( !list.isEmpty() ) + { req = list.getFirstItem(); + } } else + { req = AEItemStack.create( Filter ); + } IAEItemStack out = null; @@ -88,7 +92,9 @@ public class IMEAdaptor extends InventoryAdaptor } if( out != null ) + { return out.getItemStack(); + } return null; } @@ -103,7 +109,9 @@ public class IMEAdaptor extends InventoryAdaptor public ItemStack removeSimilarItems( int how_many, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ) { if( filter == null ) + { return this.doRemoveItems( how_many, null, destination, Actionable.MODULATE ); + } return this.doRemoveItemsFuzzy( how_many, filter, destination, Actionable.MODULATE, fuzzyMode ); } @@ -111,7 +119,9 @@ public class IMEAdaptor extends InventoryAdaptor { IAEItemStack reqFilter = AEItemStack.create( Filter ); if( reqFilter == null ) + { return null; + } IAEItemStack out = null; @@ -122,7 +132,9 @@ public class IMEAdaptor extends InventoryAdaptor req.setStackSize( how_many ); out = this.target.extractItems( req, type, this.src ); if( out != null ) + { return out.getItemStack(); + } } } @@ -133,7 +145,9 @@ public class IMEAdaptor extends InventoryAdaptor public ItemStack simulateSimilarRemove( int amount, ItemStack filter, FuzzyMode fuzzyMode, IInventoryDestination destination ) { if( filter == null ) + { return this.doRemoveItems( amount, null, destination, Actionable.SIMULATE ); + } return this.doRemoveItemsFuzzy( amount, filter, destination, Actionable.SIMULATE, fuzzyMode ); } @@ -145,7 +159,9 @@ public class IMEAdaptor extends InventoryAdaptor { IAEItemStack out = this.target.injectItems( in, Actionable.MODULATE, this.src ); if( out != null ) + { return out.getItemStack(); + } } return null; } @@ -158,7 +174,9 @@ public class IMEAdaptor extends InventoryAdaptor { IAEItemStack out = this.target.injectItems( in, Actionable.SIMULATE, this.src ); if( out != null ) + { return out.getItemStack(); + } } return null; } diff --git a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java index c22092a0..ff06f7d6 100644 --- a/src/main/java/appeng/util/inv/IMEAdaptorIterator.java +++ b/src/main/java/appeng/util/inv/IMEAdaptorIterator.java @@ -57,7 +57,9 @@ public final class IMEAdaptorIterator implements Iterator this.slot.isExtractable = true; if( this.parent.maxSlots < this.offset ) + { this.parent.maxSlots = this.offset; + } if( this.hasNext ) { diff --git a/src/main/java/appeng/util/inv/IMEInventoryDestination.java b/src/main/java/appeng/util/inv/IMEInventoryDestination.java index 681e02ad..bd08144d 100644 --- a/src/main/java/appeng/util/inv/IMEInventoryDestination.java +++ b/src/main/java/appeng/util/inv/IMEInventoryDestination.java @@ -42,12 +42,16 @@ public class IMEInventoryDestination implements IInventoryDestination { if( stack == null ) + { return false; + } IAEItemStack failed = this.me.injectItems( AEItemStack.create( stack ), Actionable.SIMULATE, null ); if( failed == null ) + { return true; + } return failed.getStackSize() != stack.stackSize; } } diff --git a/src/main/java/appeng/util/inv/WrapperChainedInventory.java b/src/main/java/appeng/util/inv/WrapperChainedInventory.java index eb9b20d1..c1a833c4 100644 --- a/src/main/java/appeng/util/inv/WrapperChainedInventory.java +++ b/src/main/java/appeng/util/inv/WrapperChainedInventory.java @@ -89,7 +89,9 @@ public class WrapperChainedInventory implements IInventory List newOrder = new ArrayList( this.l.size() ); newOrder.add( this.l.get( this.l.size() - 1 ) ); for( int x = 0; x < this.l.size() - 1; x++ ) + { newOrder.add( this.l.get( x ) ); + } this.setInventory( newOrder ); } } @@ -181,7 +183,9 @@ public class WrapperChainedInventory implements IInventory int smallest = 64; for( IInventory i : this.l ) + { smallest = Math.min( smallest, i.getInventoryStackLimit() ); + } return smallest; } diff --git a/src/main/java/appeng/util/inv/WrapperInventoryRange.java b/src/main/java/appeng/util/inv/WrapperInventoryRange.java index bb3520b6..3f9a25fb 100644 --- a/src/main/java/appeng/util/inv/WrapperInventoryRange.java +++ b/src/main/java/appeng/util/inv/WrapperInventoryRange.java @@ -37,7 +37,9 @@ public class WrapperInventoryRange implements IInventory this.slots = s; if( this.slots == null ) + { this.slots = new int[0]; + } this.ignoreValidItems = ignoreValid; } @@ -47,7 +49,9 @@ public class WrapperInventoryRange implements IInventory this.src = a; this.slots = new int[_size]; for( int x = 0; x < _size; x++ ) + { this.slots[x] = _min + x; + } this.ignoreValidItems = ignoreValid; } @@ -145,7 +149,9 @@ public class WrapperInventoryRange implements IInventory public boolean isItemValidForSlot( int i, ItemStack itemstack ) { if( this.ignoreValidItems ) + { return true; + } return this.src.isItemValidForSlot( this.slots[i], itemstack ); } diff --git a/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java b/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java index e55a3d7c..7e695220 100644 --- a/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java +++ b/src/main/java/appeng/util/inv/WrapperMCISidedInventory.java @@ -41,7 +41,9 @@ public class WrapperMCISidedInventory extends WrapperInventoryRange implements I public ItemStack decrStackSize( int var1, int var2 ) { if( this.canRemoveItemFromSlot( var1, this.getStackInSlot( var1 ) ) ) + { return super.decrStackSize( var1, var2 ); + } return null; } @@ -50,10 +52,14 @@ public class WrapperMCISidedInventory extends WrapperInventoryRange implements I { if( this.ignoreValidItems ) + { return true; + } if( this.side.isItemValidForSlot( this.slots[i], itemstack ) ) + { return this.side.canInsertItem( this.slots[i], itemstack, this.dir.ordinal() ); + } return false; } @@ -62,7 +68,9 @@ public class WrapperMCISidedInventory extends WrapperInventoryRange implements I public boolean canRemoveItemFromSlot( int i, ItemStack is ) { if( is == null ) + { return false; + } return this.side.canExtractItem( this.slots[i], is, this.dir.ordinal() ); } diff --git a/src/main/java/appeng/util/item/AEFluidStack.java b/src/main/java/appeng/util/item/AEFluidStack.java index b845d8dd..d99894a0 100644 --- a/src/main/java/appeng/util/item/AEFluidStack.java +++ b/src/main/java/appeng/util/item/AEFluidStack.java @@ -66,7 +66,9 @@ public final class AEFluidStack extends AEStack implements IAEFlu this.fluid = is.getFluid(); if( this.fluid == null ) + { throw new IllegalArgumentException( "Fluid is null." ); + } this.stackSize = is.amount; this.setCraftable( false ); @@ -79,7 +81,9 @@ public final class AEFluidStack extends AEStack implements IAEFlu { ItemStack itemstack = ItemStack.loadItemStackFromNBT( i ); if( itemstack == null ) + { return null; + } AEFluidStack fluid = AEFluidStack.create( itemstack ); // fluid.priority = i.getInteger( "Priority" ); fluid.stackSize = i.getLong( "Cnt" ); @@ -91,11 +95,17 @@ public final class AEFluidStack extends AEStack implements IAEFlu public static AEFluidStack create( Object a ) { if( a == null ) + { return null; + } if( a instanceof AEFluidStack ) + { ( (AEFluidStack) a ).copy(); + } if( a instanceof FluidStack ) + { return new AEFluidStack( (FluidStack) a ); + } return null; } @@ -135,7 +145,9 @@ public final class AEFluidStack extends AEStack implements IAEFlu FluidStack fluidStack = FluidStack.loadFluidStackFromNBT( d ); if( fluidStack == null ) + { return null; + } AEFluidStack fluid = AEFluidStack.create( fluidStack ); // fluid.priority = (int) priority; @@ -149,7 +161,9 @@ public final class AEFluidStack extends AEStack implements IAEFlu public void add( IAEFluidStack option ) { if( option == null ) + { return; + } // if ( priority < ((AEFluidStack) option).priority ) // priority = ((AEFluidStack) option).priority; @@ -199,9 +213,13 @@ public final class AEFluidStack extends AEStack implements IAEFlu i.setBoolean( "Craft", this.isCraftable() ); if( this.tagCompound != null ) + { i.setTag( "tag", (NBTTagCompound) this.tagCompound ); + } else + { i.removeTag( "tag" ); + } } @Override @@ -287,16 +305,24 @@ public final class AEFluidStack extends AEStack implements IAEFlu NBTTagCompound ta = (NBTTagCompound) this.tagCompound; NBTTagCompound tb = is.tag; if( ta == tb ) + { return true; + } if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) ) + { return true; + } if( ( ta == null && tb != null ) || ( ta != null && tb == null ) ) + { return false; + } if( AESharedNBT.isShared( tb ) ) + { return ta == tb; + } return Platform.NBTEqualityTest( ta, tb ); } @@ -319,7 +345,9 @@ public final class AEFluidStack extends AEStack implements IAEFlu { FluidStack is = new FluidStack( this.fluid, (int) Math.min( Integer.MAX_VALUE, this.stackSize ) ); if( this.tagCompound != null ) + { is.tag = this.tagCompound.getNBTTagCompoundCopy(); + } return is; } diff --git a/src/main/java/appeng/util/item/AEItemDef.java b/src/main/java/appeng/util/item/AEItemDef.java index a643ad74..619eed74 100644 --- a/src/main/java/appeng/util/item/AEItemDef.java +++ b/src/main/java/appeng/util/item/AEItemDef.java @@ -75,9 +75,13 @@ public class AEItemDef public boolean equals( Object obj ) { if( obj == null ) + { return false; + } if( this.getClass() != obj.getClass() ) + { return false; + } AEItemDef other = (AEItemDef) obj; return other.damageValue == this.damageValue && other.item == this.item && this.tagCompound == other.tagCompound; } @@ -90,10 +94,14 @@ public class AEItemDef if( this.item == otherStack.getItem() && dmg == this.damageValue ) { if( ( this.tagCompound != null ) == otherStack.hasTagCompound() ) + { return true; + } if( this.tagCompound != null && otherStack.hasTagCompound() ) + { return Platform.NBTEqualityTest( this.tagCompound, otherStack.getTagCompound() ); + } return true; } diff --git a/src/main/java/appeng/util/item/AEItemStack.java b/src/main/java/appeng/util/item/AEItemStack.java index 47c55b32..e9a64694 100644 --- a/src/main/java/appeng/util/item/AEItemStack.java +++ b/src/main/java/appeng/util/item/AEItemStack.java @@ -76,7 +76,9 @@ public final class AEItemStack extends AEStack implements IAEItemS this.def = new AEItemDef( item ); if( this.def.item == null ) + { throw new InvalidParameterException( "This ItemStack is bad, it has a null item." ); + } /* * Prevent an Item from changing the damage value on me... Either, this or a core mod. @@ -97,7 +99,9 @@ public final class AEItemStack extends AEStack implements IAEItemS NBTTagCompound tagCompound = is.getTagCompound(); if( tagCompound != null ) + { this.def.tagCompound = (AESharedNBT) AESharedNBT.getSharedTagCompound( tagCompound, is ); + } this.stackSize = is.stackSize; this.setCraftable( false ); @@ -110,11 +114,15 @@ public final class AEItemStack extends AEStack implements IAEItemS public static IAEItemStack loadItemStackFromNBT( NBTTagCompound i ) { if( i == null ) + { return null; + } ItemStack itemstack = ItemStack.loadItemStackFromNBT( i ); if( itemstack == null ) + { return null; + } AEItemStack item = AEItemStack.create( itemstack ); // item.priority = i.getInteger( "Priority" ); @@ -168,7 +176,9 @@ public final class AEItemStack extends AEStack implements IAEItemS ItemStack itemstack = ItemStack.loadItemStackFromNBT( d ); if( itemstack == null ) + { return null; + } AEItemStack item = AEItemStack.create( itemstack ); // item.priority = (int) priority; @@ -182,7 +192,9 @@ public final class AEItemStack extends AEStack implements IAEItemS public void add( IAEItemStack option ) { if( option == null ) + { return; + } // if ( priority < ((AEItemStack) option).priority ) // priority = ((AEItemStack) option).priority; @@ -237,9 +249,13 @@ public final class AEItemStack extends AEStack implements IAEItemS i.setShort( "Damage", (short) this.def.damageValue ); if( this.def.tagCompound != null ) + { i.setTag( "tag", this.def.tagCompound ); + } else + { i.removeTag( "tag" ); + } } @Override @@ -250,7 +266,9 @@ public final class AEItemStack extends AEStack implements IAEItemS IAEItemStack o = (IAEItemStack) st; if( this.sameOre( o ) ) + { return true; + } if( o.getItem() == this.getItem() ) { @@ -401,7 +419,9 @@ public final class AEItemStack extends AEStack implements IAEItemS { ItemStack is = new ItemStack( this.def.item, (int) Math.min( Integer.MAX_VALUE, this.stackSize ), this.def.damageValue ); if( this.def.tagCompound != null ) + { is.setTagCompound( this.def.tagCompound.getNBTTagCompoundCopy() ); + } return is; } @@ -428,7 +448,9 @@ public final class AEItemStack extends AEStack implements IAEItemS public boolean isSameType( IAEItemStack otherStack ) { if( otherStack == null ) + { return false; + } return this.def.equals( ( (AEItemStack) otherStack ).def ); } @@ -437,7 +459,9 @@ public final class AEItemStack extends AEStack implements IAEItemS public boolean isSameType( ItemStack otherStack ) { if( otherStack == null ) + { return false; + } return this.def.isItem( otherStack ); } @@ -464,16 +488,24 @@ public final class AEItemStack extends AEStack implements IAEItemS NBTTagCompound ta = this.def.tagCompound; NBTTagCompound tb = is.getTagCompound(); if( ta == tb ) + { return true; + } if( ( ta == null && tb == null ) || ( ta != null && ta.hasNoTags() && tb == null ) || ( tb != null && tb.hasNoTags() && ta == null ) || ( ta != null && ta.hasNoTags() && tb != null && tb.hasNoTags() ) ) + { return true; + } if( ( ta == null && tb != null ) || ( ta != null && tb == null ) ) + { return false; + } if( AESharedNBT.isShared( tb ) ) + { return ta == tb; + } return Platform.NBTEqualityTest( ta, tb ); } @@ -492,15 +524,21 @@ public final class AEItemStack extends AEStack implements IAEItemS { int id = this.def.itemID - b.def.itemID; if( id != 0 ) + { return id; + } int damageValue = this.def.damageValue - b.def.damageValue; if( damageValue != 0 ) + { return damageValue; + } int displayDamage = this.def.displayDamage - b.def.displayDamage; if( displayDamage != 0 ) + { return displayDamage; + } return ( this.def.tagCompound == b.def.tagCompound ) ? 0 : this.compareNBT( b.def ); } @@ -509,7 +547,9 @@ public final class AEItemStack extends AEStack implements IAEItemS { int nbt = this.compare( ( this.def.tagCompound == null ? 0 : this.def.tagCompound.getHash() ), ( b.tagCompound == null ? 0 : b.tagCompound.getHash() ) ); if( nbt == 0 ) + { return this.compare( System.identityHashCode( this.def.tagCompound ), System.identityHashCode( b.tagCompound ) ); + } return nbt; } @@ -522,7 +562,9 @@ public final class AEItemStack extends AEStack implements IAEItemS public List getToolTip() { if( this.def.tooltip != null ) + { return this.def.tooltip; + } return this.def.tooltip = Platform.getTooltip( this.getItemStack() ); } @@ -531,7 +573,9 @@ public final class AEItemStack extends AEStack implements IAEItemS public String getDisplayName() { if( this.def.displayName != null ) + { return this.def.displayName; + } return this.def.displayName = Platform.getItemDisplayName( this.getItemStack() ); } @@ -540,7 +584,9 @@ public final class AEItemStack extends AEStack implements IAEItemS public String getModID() { if( this.def.uniqueID != null ) + { return this.getModName( this.def.uniqueID ); + } return this.getModName( this.def.uniqueID = GameRegistry.findUniqueIdentifierFor( this.def.item ) ); } @@ -548,7 +594,9 @@ public final class AEItemStack extends AEStack implements IAEItemS private String getModName( UniqueIdentifier uniqueIdentifier ) { if( uniqueIdentifier == null ) + { return "** Null"; + } return uniqueIdentifier.modId == null ? "** Null" : uniqueIdentifier.modId; } @@ -574,9 +622,13 @@ public final class AEItemStack extends AEStack implements IAEItemS else if( fuzzy == FuzzyMode.PERCENT_99 ) { if( this.def.damageValue == 0 ) + { newDef.displayDamage = 0; + } else + { newDef.displayDamage = 1; + } } else { @@ -613,9 +665,13 @@ public final class AEItemStack extends AEStack implements IAEItemS else if( fuzzy == FuzzyMode.PERCENT_99 ) { if( this.def.damageValue == 0 ) + { newDef.displayDamage = 0; + } else + { newDef.displayDamage = this.def.maxDamage + 1; + } } else { diff --git a/src/main/java/appeng/util/item/AESharedNBT.java b/src/main/java/appeng/util/item/AESharedNBT.java index edea1ae8..5bf5c5d4 100644 --- a/src/main/java/appeng/util/item/AESharedNBT.java +++ b/src/main/java/appeng/util/item/AESharedNBT.java @@ -77,15 +77,21 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound public static synchronized NBTTagCompound getSharedTagCompound( NBTTagCompound tagCompound, ItemStack s ) { if( tagCompound.hasNoTags() ) + { return null; + } Item item = s.getItem(); int meta = -1; if( s.getItem() != null && s.isItemStackDamageable() && s.getHasSubtypes() ) + { meta = s.getItemDamage(); + } if( isShared( tagCompound ) ) + { return tagCompound; + } SharedSearchObject sso = new SharedSearchObject( item, meta, tagCompound ); @@ -94,7 +100,9 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound { SharedSearchObject cg = c.get(); if( cg != null ) + { return cg.shared; // I don't think I really need to check this + } // as its already certain to exist.. } @@ -160,7 +168,9 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound public boolean equals( Object par1Obj ) { if( par1Obj instanceof AESharedNBT ) + { return this == par1Obj; + } return super.equals( par1Obj ); } @@ -172,7 +182,9 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound public boolean comparePreciseWithRegistry( AESharedNBT tagCompound ) { if( this == tagCompound ) + { return true; + } if( this.comp != null && tagCompound.comp != null ) { @@ -185,12 +197,18 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound public boolean compareFuzzyWithRegistry( AESharedNBT tagCompound ) { if( this == tagCompound ) + { return true; + } if( tagCompound == null ) + { return false; + } if( this.comp == tagCompound.comp ) + { return true; + } if( this.comp != null ) { diff --git a/src/main/java/appeng/util/item/AEStack.java b/src/main/java/appeng/util/item/AEStack.java index f79a0078..24ee614c 100644 --- a/src/main/java/appeng/util/item/AEStack.java +++ b/src/main/java/appeng/util/item/AEStack.java @@ -154,13 +154,21 @@ public abstract class AEStack implements IAEStack implements IAEStack implements IItemList implements IItemList implements IItemList implements IItemList findFuzzy( StackType filter, FuzzyMode fuzzy ) { if( this.checkStackType( filter ) ) + { return new ArrayList(); + } if( filter instanceof IAEFluidStack ) { @@ -131,7 +141,9 @@ public final class ItemList implements IItemList output = new LinkedList(); for( IAEItemStack is : or.getAEEquivalents() ) + { output.addAll( this.findFuzzyDamage( (AEItemStack) is, fuzzy, is.getItemDamage() == OreDictionary.WILDCARD_VALUE ) ); + } return output; } @@ -158,7 +170,9 @@ public final class ItemList implements IItemList implements IItemList implements IItemList implements IItemList { over = this.backingStore.findPrecise( option ); if( over == null ) + { this.overrides.add( option ); + } else { option.add( over ); @@ -54,7 +56,9 @@ public class ItemModList implements IItemContainer } } else + { this.overrides.add( option ); + } } @Override @@ -62,7 +66,9 @@ public class ItemModList implements IItemContainer { IAEItemStack over = this.overrides.findPrecise( i ); if( over == null ) + { return this.backingStore.findPrecise( i ); + } return over; } diff --git a/src/main/java/appeng/util/item/OreHelper.java b/src/main/java/appeng/util/item/OreHelper.java index 3bc7d475..9bb1c6f5 100644 --- a/src/main/java/appeng/util/item/OreHelper.java +++ b/src/main/java/appeng/util/item/OreHelper.java @@ -100,9 +100,13 @@ public class OreHelper } if( !set.isEmpty() ) + { this.references.put( ir, ref ); + } else + { this.references.put( ir, null ); + } } return this.references.get( ir ); @@ -119,16 +123,22 @@ public class OreHelper public boolean sameOre( OreReference a, OreReference b ) { if( a == null || b == null ) + { return false; + } if( a == b ) + { return true; + } Collection bOres = b.getOres(); for( Integer ore : a.getOres() ) { if( bOres.contains( ore ) ) + { return true; + } } return false; @@ -138,14 +148,18 @@ public class OreHelper { OreReference a = aeItemStack.def.isOre; if( a == null ) + { return false; + } for( String oreName : a.getEquivalents() ) { for( ItemStack oreItem : this.oreDictCache.getUnchecked( oreName ) ) { if( OreDictionary.itemMatches( oreItem, o, false ) ) + { return true; + } } } @@ -169,9 +183,13 @@ public class OreHelper this.ref = stack.getItem(); if( stack.getItem().isDamageable() ) + { this.damage = 0; // IGNORED + } else + { this.damage = stack.getItemDamage(); // might be important... + } this.hash = this.ref.hashCode() ^ this.damage; } @@ -186,9 +204,13 @@ public class OreHelper public boolean equals( Object obj ) { if( obj == null ) + { return false; + } if( this.getClass() != obj.getClass() ) + { return false; + } ItemRef other = (ItemRef) obj; return this.damage == other.damage && this.ref == other.ref; } diff --git a/src/main/java/appeng/util/item/SharedSearchObject.java b/src/main/java/appeng/util/item/SharedSearchObject.java index e7883fa8..2926e3de 100644 --- a/src/main/java/appeng/util/item/SharedSearchObject.java +++ b/src/main/java/appeng/util/item/SharedSearchObject.java @@ -50,9 +50,13 @@ public class SharedSearchObject public boolean equals( Object obj ) { if( obj == null ) + { return false; + } if( this.getClass() != obj.getClass() ) + { return false; + } SharedSearchObject other = (SharedSearchObject) obj; if( this.def == other.def && this.hash == other.hash ) { diff --git a/src/main/java/appeng/util/prioitylist/MergedPriorityList.java b/src/main/java/appeng/util/prioitylist/MergedPriorityList.java index 5a162303..4eb746f2 100644 --- a/src/main/java/appeng/util/prioitylist/MergedPriorityList.java +++ b/src/main/java/appeng/util/prioitylist/MergedPriorityList.java @@ -34,23 +34,35 @@ public final class MergedPriorityList> implements IPartiti public void addNewList( IPartitionList list, boolean isWhitelist ) { if( isWhitelist ) + { this.positive.add( list ); + } else + { this.negative.add( list ); + } } @Override public boolean isListed( T input ) { for( IPartitionList l : this.negative ) + { if( l.isListed( input ) ) + { return false; + } + } if( !this.positive.isEmpty() ) { for( IPartitionList l : this.positive ) + { if( l.isListed( input ) ) + { return true; + } + } return false; } diff --git a/src/main/java/appeng/worldgen/MeteoritePlacer.java b/src/main/java/appeng/worldgen/MeteoritePlacer.java index a5258bbc..261feee9 100644 --- a/src/main/java/appeng/worldgen/MeteoritePlacer.java +++ b/src/main/java/appeng/worldgen/MeteoritePlacer.java @@ -124,23 +124,33 @@ public final class MeteoritePlacer Block blk = Block.getBlockById( this.settings.getInteger( "blk" ) ); if( blk == Blocks.sand ) + { this.type = new FalloutSand( w, x, y, z, this.putter, this.skyStoneDefinition ); + } else if( blk == Blocks.hardened_clay ) + { this.type = new FalloutCopy( w, x, y, z, this.putter, this.skyStoneDefinition ); + } else if( blk == Blocks.ice || blk == Blocks.snow ) + { this.type = new FalloutSnow( w, x, y, z, this.putter, this.skyStoneDefinition ); + } int skyMode = this.settings.getInteger( "skyMode" ); // creator if( skyMode > 10 ) + { this.placeCrater( w, x, y, z ); + } this.placeMeteorite( w, x, y, z ); // collapse blocks... if( skyMode > 3 ) + { this.decay( w, x, y, z ); + } w.done(); return true; @@ -161,6 +171,7 @@ public final class MeteoritePlacer boolean changed = false; for( int i = minX; i < maxX; i++ ) + { for( int k = minZ; k < maxZ; k++ ) { double dx = i - x; @@ -174,12 +185,17 @@ public final class MeteoritePlacer if( lava && j < y && w.getBlock( x, y - 1, z ).isBlockSolid( w.getWorld(), i, j, k, 0 ) ) { if( j > h + distanceFrom * 0.02 ) + { this.putter.put( w, i, j, k, Blocks.lava ); + } } else + { changed = this.putter.put( w, i, j, k, Platform.AIR ) || changed; + } } } + } } for( Object o : w.getWorld().getEntitiesWithinAABB( EntityItem.class, AxisAlignedBB.getBoundingBox( w.minX( x - 30 ), y - 5, w.minZ( z - 30 ), w.maxX( x + 30 ), y + 30, w.maxZ( z + 30 ) ) ) ) @@ -198,7 +214,9 @@ public final class MeteoritePlacer // spawn meteor for( int i = meteorXLength; i < meteorXHeight; i++ ) + { for( int j = y - 8; j < y + 8; j++ ) + { for( int k = meteorZLength; k < meteorZHeight; k++ ) { double dx = i - x; @@ -213,6 +231,8 @@ public final class MeteoritePlacer } } } + } + } if( AEConfig.instance.isFeatureEnabled( AEFeature.SpawnPressesInMeteorites ) ) { @@ -229,7 +249,9 @@ public final class MeteoritePlacer int primary = Math.max( 1, (int) ( Math.random() * 4 ) ); if( primary > 3 ) // in case math breaks... + { primary = 3; + } for( int zz = 0; zz < primary; zz++ ) { @@ -241,9 +263,13 @@ public final class MeteoritePlacer duplicate = false; if( Math.random() > PRESSES_SPAWN_CHANCE ) + { r = WorldSettings.getInstance().getNextOrderedValue( "presses" ); + } else + { r = (int) ( Math.random() * 1000 ); + } ItemStack toAdd = null; final IMaterials materials = AEApi.instance().definitions().materials(); @@ -280,9 +306,13 @@ public final class MeteoritePlacer if( toAdd != null ) { if( ap.simulateRemove( 1, toAdd, null ) == null ) + { ap.addItems( toAdd ); + } else + { duplicate = true; + } } } while( duplicate ); @@ -337,12 +367,16 @@ public final class MeteoritePlacer int meteorZHeight = w.maxZ( z + 30 ); for( int i = meteorXLength; i < meteorXHeight; i++ ) + { for( int k = meteorZLength; k < meteorZHeight; k++ ) + { for( int j = y - 9; j < y + 30; j++ ) { Block blk = w.getBlock( i, j, k ); if( blk == Blocks.lava ) + { continue; + } if( blk.isReplaceable( w.getWorld(), i, j, k ) ) { @@ -397,6 +431,8 @@ public final class MeteoritePlacer } } } + } + } } public double getSqDistance( int x, int z ) @@ -412,11 +448,15 @@ public final class MeteoritePlacer int validBlocks = 0; if( !w.hasNoSky() ) + { return false; + } Block blk = w.getBlock( x, y, z ); if( !this.validSpawn.contains( blk ) ) + { return false; // must spawn on a valid block.. + } this.settings = new NBTTagCompound(); this.settings.setInteger( "x", x ); @@ -432,33 +472,53 @@ public final class MeteoritePlacer this.settings.setBoolean( "lava", Math.random() > 0.9 ); if( blk == Blocks.sand ) + { this.type = new FalloutSand( w, x, y, z, this.putter, this.skyStoneDefinition ); + } else if( blk == Blocks.hardened_clay ) + { this.type = new FalloutCopy( w, x, y, z, this.putter, this.skyStoneDefinition ); + } else if( blk == Blocks.ice || blk == Blocks.snow ) + { this.type = new FalloutSnow( w, x, y, z, this.putter, this.skyStoneDefinition ); + } int realValidBlocks = 0; for( int i = x - 6; i < x + 6; i++ ) + { for( int j = y - 6; j < y + 6; j++ ) + { for( int k = z - 6; k < z + 6; k++ ) { blk = w.getBlock( i, j, k ); if( this.validSpawn.contains( blk ) ) + { realValidBlocks++; + } } + } + } for( int i = x - 15; i < x + 15; i++ ) + { for( int j = y - 15; j < y + 15; j++ ) + { for( int k = z - 15; k < z + 15; k++ ) { blk = w.getBlock( i, j, k ); if( this.invalidSpawn.contains( blk ) ) + { return false; + } if( this.validSpawn.contains( blk ) ) + { validBlocks++; + } } + } + } int minBLocks = 200; if( validBlocks > minBLocks && realValidBlocks > 80 ) @@ -468,32 +528,46 @@ public final class MeteoritePlacer int skyMode = 0; for( int i = x - 15; i < x + 15; i++ ) + { for( int j = y - 15; j < y + 11; j++ ) + { for( int k = z - 15; k < z + 15; k++ ) { if( w.canBlockSeeTheSky( i, j, k ) ) + { skyMode++; + } } + } + } boolean solid = true; for( int j = y - 15; j < y - 1; j++ ) { if( w.getBlock( x, j, z ) == Platform.AIR ) + { solid = false; + } } if( !solid ) + { skyMode = 0; + } // creator if( skyMode > 10 ) + { this.placeCrater( w, x, y, z ); + } this.placeMeteorite( w, x, y, z ); // collapse blocks... if( skyMode > 3 ) + { this.decay( w, x, y, z ); + } this.settings.setInteger( "skyMode", skyMode ); w.done(); diff --git a/src/main/java/appeng/worldgen/MeteoriteWorldGen.java b/src/main/java/appeng/worldgen/MeteoriteWorldGen.java index f2e0bfe7..6320c06e 100644 --- a/src/main/java/appeng/worldgen/MeteoriteWorldGen.java +++ b/src/main/java/appeng/worldgen/MeteoriteWorldGen.java @@ -55,10 +55,14 @@ public final class MeteoriteWorldGen implements IWorldGenerator TickHandler.INSTANCE.addCallable( w, new MeteoriteSpawn( x, depth, z, w ) ); } else + { TickHandler.INSTANCE.addCallable( w, new MeteoriteSpawn( chunkX << 4, 128, chunkZ << 4, w ) ); + } } else + { WorldSettings.getInstance().getCompass().updateArea( w, chunkX, chunkZ ); + } } private boolean tryMeteorite( World w, int depth, int x, int z ) @@ -73,12 +77,15 @@ public final class MeteoriteWorldGen implements IWorldGenerator int pz = z >> 4; for( int cx = px - 6; cx < px + 6; cx++ ) + { for( int cz = pz - 6; cz < pz + 6; cz++ ) { if( w.getChunkProvider().chunkExists( cx, cz ) ) { if( px == cx && pz == cz ) + { continue; + } if( WorldSettings.getInstance().hasGenerated( w.provider.dimensionId, cx, cz ) ) { @@ -87,13 +94,16 @@ public final class MeteoriteWorldGen implements IWorldGenerator } } } + } return true; } depth -= 15; if( depth < 40 ) + { return false; + } } return false; @@ -140,7 +150,9 @@ public final class MeteoriteWorldGen implements IWorldGenerator boolean isCluster = ( minSqDist < 30 * 30 ) && Platform.getRandomFloat() < AEConfig.instance.meteoriteClusterChance; if( minSqDist > AEConfig.instance.minMeteoriteDistanceSq || isCluster ) + { MeteoriteWorldGen.this.tryMeteorite( this.w, this.depth, this.x, this.z ); + } WorldSettings.getInstance().setGenerated( this.w.provider.dimensionId, chunkX, chunkZ ); WorldSettings.getInstance().getCompass().updateArea( this.w, chunkX, chunkZ ); diff --git a/src/main/java/appeng/worldgen/QuartzWorldGen.java b/src/main/java/appeng/worldgen/QuartzWorldGen.java index 6bface26..d8393d46 100644 --- a/src/main/java/appeng/worldgen/QuartzWorldGen.java +++ b/src/main/java/appeng/worldgen/QuartzWorldGen.java @@ -68,7 +68,9 @@ public final class QuartzWorldGen implements IWorldGenerator } if( this.oreNormal == null || this.oreCharged == null ) + { return; + } double oreDepthMultiplier = AEConfig.instance.quartzOresClusterAmount * seaLevel / 64; int scale = (int) Math.round( r.nextGaussian() * Math.sqrt( oreDepthMultiplier ) + oreDepthMultiplier ); diff --git a/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java b/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java index 8df15672..6bc54346 100644 --- a/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java +++ b/src/main/java/appeng/worldgen/meteorite/ChunkOnly.java @@ -52,7 +52,9 @@ public class ChunkOnly extends StandardWorld public int getBlockMetadata( int x, int y, int z ) { if( this.range( x, y, z ) ) + { return this.target.getBlockMetadata( x & 0xF, y, z & 0xF ); + } return 0; } @@ -60,7 +62,9 @@ public class ChunkOnly extends StandardWorld public Block getBlock( int x, int y, int z ) { if( this.range( x, y, z ) ) + { return this.target.getBlock( x & 0xF, y, z & 0xF ); + } return Platform.AIR; } @@ -88,7 +92,9 @@ public class ChunkOnly extends StandardWorld public void done() { if( this.verticalBits != 0 ) + { Platform.sendChunk( this.target, this.verticalBits ); + } } @Override diff --git a/src/main/java/appeng/worldgen/meteorite/Fallout.java b/src/main/java/appeng/worldgen/meteorite/Fallout.java index 008e143b..213daf49 100644 --- a/src/main/java/appeng/worldgen/meteorite/Fallout.java +++ b/src/main/java/appeng/worldgen/meteorite/Fallout.java @@ -28,24 +28,38 @@ public class Fallout { double a = Math.random(); if( a > 0.9 ) + { this.putter.put( w, x, y, z, Blocks.stone ); + } else if( a > 0.8 ) + { this.putter.put( w, x, y, z, Blocks.cobblestone ); + } else if( a > 0.7 ) + { this.putter.put( w, x, y, z, Blocks.dirt ); + } else + { this.putter.put( w, x, y, z, Blocks.gravel ); + } } public void getRandomInset( IMeteoriteWorld w, int x, int y, int z ) { double a = Math.random(); if( a > 0.9 ) + { this.putter.put( w, x, y, z, Blocks.cobblestone ); + } else if( a > 0.8 ) + { this.putter.put( w, x, y, z, Blocks.stone ); + } else if( a > 0.7 ) + { this.putter.put( w, x, y, z, Blocks.grass ); + } else if( a > 0.6 ) { for( Block skyStoneBlock : this.skyStoneDefinition.maybeBlock().asSet() ) @@ -54,8 +68,12 @@ public class Fallout } } else if( a > 0.5 ) + { this.putter.put( w, x, y, z, Blocks.gravel ); + } else + { this.putter.put( w, x, y, z, Platform.AIR ); + } } } diff --git a/src/main/java/appeng/worldgen/meteorite/FalloutSand.java b/src/main/java/appeng/worldgen/meteorite/FalloutSand.java index de677d1a..c9a08877 100644 --- a/src/main/java/appeng/worldgen/meteorite/FalloutSand.java +++ b/src/main/java/appeng/worldgen/meteorite/FalloutSand.java @@ -27,6 +27,8 @@ public class FalloutSand extends FalloutCopy public void getOther( IMeteoriteWorld w, int x, int y, int z, double a ) { if( a > GLASS_THRESHOLD ) + { this.putter.put( w, x, y, z, Blocks.glass ); + } } } \ No newline at end of file diff --git a/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java b/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java index 692e6404..7e3a679e 100644 --- a/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java +++ b/src/main/java/appeng/worldgen/meteorite/MeteoriteBlockPutter.java @@ -12,7 +12,9 @@ public class MeteoriteBlockPutter Block original = w.getBlock( i, j, k ); if( original == Blocks.bedrock || original == blk ) + { return false; + } w.setBlock( i, j, k, blk ); return true; diff --git a/src/main/java/appeng/worldgen/meteorite/StandardWorld.java b/src/main/java/appeng/worldgen/meteorite/StandardWorld.java index 8337bc01..441f3081 100644 --- a/src/main/java/appeng/worldgen/meteorite/StandardWorld.java +++ b/src/main/java/appeng/worldgen/meteorite/StandardWorld.java @@ -52,7 +52,9 @@ public class StandardWorld implements IMeteoriteWorld public int getBlockMetadata( int x, int y, int z ) { if( this.range( x, y, z ) ) + { return this.w.getBlockMetadata( x, y, z ); + } return 0; } @@ -60,7 +62,9 @@ public class StandardWorld implements IMeteoriteWorld public Block getBlock( int x, int y, int z ) { if( this.range( x, y, z ) ) + { return this.w.getBlock( x, y, z ); + } return Platform.AIR; } @@ -68,7 +72,9 @@ public class StandardWorld implements IMeteoriteWorld public boolean canBlockSeeTheSky( int x, int y, int z ) { if( this.range( x, y, z ) ) + { return this.w.canBlockSeeTheSky( x, y, z ); + } return false; } @@ -76,7 +82,9 @@ public class StandardWorld implements IMeteoriteWorld public TileEntity getTileEntity( int x, int y, int z ) { if( this.range( x, y, z ) ) + { return this.w.getTileEntity( x, y, z ); + } return null; } @@ -90,14 +98,18 @@ public class StandardWorld implements IMeteoriteWorld public void setBlock( int x, int y, int z, Block blk ) { if( this.range( x, y, z ) ) + { this.w.setBlock( x, y, z, blk ); + } } @Override public void setBlock( int x, int y, int z, Block blk, int metadata, int flags ) { if( this.range( x, y, z ) ) + { this.w.setBlock( x, y, z, blk, metadata, flags ); + } } @Override