Puts everywhere brackets
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ICraftingJob> futureJob = null;
|
||||
|
||||
@@ -115,7 +119,9 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
catch( Throwable e )
|
||||
{
|
||||
if( futureJob != null )
|
||||
{
|
||||
futureJob.cancel( true );
|
||||
}
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,9 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
this.newGui = newGui;
|
||||
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
AEBaseGui.switchingGuis = true;
|
||||
}
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user