mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-07 16:00:31 +00:00
Remove NetworkMessage.fromBytes
Always build packets using a PacketBuffer constructor instead.
This commit is contained in:
parent
a735f23e1f
commit
2227845658
@ -43,17 +43,17 @@ public final class NetworkHandler
|
|||||||
.simpleChannel();
|
.simpleChannel();
|
||||||
|
|
||||||
// Server messages
|
// Server messages
|
||||||
registerMainThread( 0, NetworkDirection.PLAY_TO_SERVER, ComputerActionServerMessage::new );
|
registerMainThread( 0, NetworkDirection.PLAY_TO_SERVER, ComputerActionServerMessage.class, ComputerActionServerMessage::new );
|
||||||
registerMainThread( 1, NetworkDirection.PLAY_TO_SERVER, QueueEventServerMessage::new );
|
registerMainThread( 1, NetworkDirection.PLAY_TO_SERVER, QueueEventServerMessage.class, QueueEventServerMessage::new );
|
||||||
registerMainThread( 2, NetworkDirection.PLAY_TO_SERVER, RequestComputerMessage::new );
|
registerMainThread( 2, NetworkDirection.PLAY_TO_SERVER, RequestComputerMessage.class, RequestComputerMessage::new );
|
||||||
registerMainThread( 3, NetworkDirection.PLAY_TO_SERVER, KeyEventServerMessage::new );
|
registerMainThread( 3, NetworkDirection.PLAY_TO_SERVER, KeyEventServerMessage.class, KeyEventServerMessage::new );
|
||||||
registerMainThread( 4, NetworkDirection.PLAY_TO_SERVER, MouseEventServerMessage::new );
|
registerMainThread( 4, NetworkDirection.PLAY_TO_SERVER, MouseEventServerMessage.class, MouseEventServerMessage::new );
|
||||||
|
|
||||||
// Client messages
|
// Client messages
|
||||||
registerMainThread( 10, NetworkDirection.PLAY_TO_CLIENT, ChatTableClientMessage::new );
|
registerMainThread( 10, NetworkDirection.PLAY_TO_CLIENT, ChatTableClientMessage.class, ChatTableClientMessage::new );
|
||||||
registerMainThread( 11, NetworkDirection.PLAY_TO_CLIENT, ComputerDataClientMessage::new );
|
registerMainThread( 11, NetworkDirection.PLAY_TO_CLIENT, ComputerDataClientMessage.class, ComputerDataClientMessage::new );
|
||||||
registerMainThread( 12, NetworkDirection.PLAY_TO_CLIENT, ComputerDeletedClientMessage::new );
|
registerMainThread( 12, NetworkDirection.PLAY_TO_CLIENT, ComputerDeletedClientMessage.class, ComputerDeletedClientMessage::new );
|
||||||
registerMainThread( 13, NetworkDirection.PLAY_TO_CLIENT, ComputerTerminalClientMessage::new );
|
registerMainThread( 13, NetworkDirection.PLAY_TO_CLIENT, ComputerTerminalClientMessage.class, ComputerTerminalClientMessage::new );
|
||||||
registerMainThread( 14, NetworkDirection.PLAY_TO_CLIENT, PlayRecordClientMessage.class, PlayRecordClientMessage::new );
|
registerMainThread( 14, NetworkDirection.PLAY_TO_CLIENT, PlayRecordClientMessage.class, PlayRecordClientMessage::new );
|
||||||
registerMainThread( 15, NetworkDirection.PLAY_TO_CLIENT, MonitorClientMessage.class, MonitorClientMessage::new );
|
registerMainThread( 15, NetworkDirection.PLAY_TO_CLIENT, MonitorClientMessage.class, MonitorClientMessage::new );
|
||||||
registerMainThread( 16, NetworkDirection.PLAY_TO_CLIENT, SpeakerPlayClientMessage.class, SpeakerPlayClientMessage::new );
|
registerMainThread( 16, NetworkDirection.PLAY_TO_CLIENT, SpeakerPlayClientMessage.class, SpeakerPlayClientMessage::new );
|
||||||
@ -90,24 +90,6 @@ public final class NetworkHandler
|
|||||||
network.send( PacketDistributor.TRACKING_CHUNK.with( () -> chunk ), packet );
|
network.send( PacketDistributor.TRACKING_CHUNK.with( () -> chunk ), packet );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* /**
|
|
||||||
* Register packet, and a thread-unsafe handler for it.
|
|
||||||
*
|
|
||||||
* @param <T> The type of the packet to send.
|
|
||||||
* @param id The identifier for this packet type.
|
|
||||||
* @param direction A network direction which will be asserted before any processing of this message occurs.
|
|
||||||
* @param factory The factory for this type of packet.
|
|
||||||
*/
|
|
||||||
private static <T extends NetworkMessage> void registerMainThread( int id, NetworkDirection direction, Supplier<T> factory )
|
|
||||||
{
|
|
||||||
registerMainThread( id, direction, getType( factory ), buf -> {
|
|
||||||
T instance = factory.get();
|
|
||||||
instance.fromBytes( buf );
|
|
||||||
return instance;
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* /**
|
* /**
|
||||||
* Register packet, and a thread-unsafe handler for it.
|
* Register packet, and a thread-unsafe handler for it.
|
||||||
|
@ -27,18 +27,6 @@ public interface NetworkMessage
|
|||||||
*/
|
*/
|
||||||
void toBytes( @Nonnull PacketBuffer buf );
|
void toBytes( @Nonnull PacketBuffer buf );
|
||||||
|
|
||||||
/**
|
|
||||||
* Read this packet from a buffer.
|
|
||||||
*
|
|
||||||
* This may be called on any thread, so this should be a pure operation.
|
|
||||||
*
|
|
||||||
* @param buf The buffer to read data from.
|
|
||||||
*/
|
|
||||||
default void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
throw new IllegalStateException( "Should have been registered using a \"from bytes\" method" );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle this {@link NetworkMessage}.
|
* Handle this {@link NetworkMessage}.
|
||||||
*
|
*
|
||||||
|
@ -16,7 +16,7 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
public class ChatTableClientMessage implements NetworkMessage
|
public class ChatTableClientMessage implements NetworkMessage
|
||||||
{
|
{
|
||||||
private TableBuilder table;
|
private final TableBuilder table;
|
||||||
|
|
||||||
public ChatTableClientMessage( TableBuilder table )
|
public ChatTableClientMessage( TableBuilder table )
|
||||||
{
|
{
|
||||||
@ -24,32 +24,7 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
this.table = table;
|
this.table = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatTableClientMessage()
|
public ChatTableClientMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
buf.writeVarInt( table.getId() );
|
|
||||||
buf.writeVarInt( table.getColumns() );
|
|
||||||
buf.writeBoolean( table.getHeaders() != null );
|
|
||||||
if( table.getHeaders() != null )
|
|
||||||
{
|
|
||||||
for( ITextComponent header : table.getHeaders() ) buf.writeComponent( header );
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.writeVarInt( table.getRows().size() );
|
|
||||||
for( ITextComponent[] row : table.getRows() )
|
|
||||||
{
|
|
||||||
for( ITextComponent column : row ) buf.writeComponent( column );
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.writeVarInt( table.getAdditional() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
{
|
||||||
int id = buf.readVarInt();
|
int id = buf.readVarInt();
|
||||||
int columns = buf.readVarInt();
|
int columns = buf.readVarInt();
|
||||||
@ -77,6 +52,26 @@ public class ChatTableClientMessage implements NetworkMessage
|
|||||||
this.table = table;
|
this.table = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toBytes( @Nonnull PacketBuffer buf )
|
||||||
|
{
|
||||||
|
buf.writeVarInt( table.getId() );
|
||||||
|
buf.writeVarInt( table.getColumns() );
|
||||||
|
buf.writeBoolean( table.getHeaders() != null );
|
||||||
|
if( table.getHeaders() != null )
|
||||||
|
{
|
||||||
|
for( ITextComponent header : table.getHeaders() ) buf.writeComponent( header );
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.writeVarInt( table.getRows().size() );
|
||||||
|
for( ITextComponent[] row : table.getRows() )
|
||||||
|
{
|
||||||
|
for( ITextComponent column : row ) buf.writeComponent( column );
|
||||||
|
}
|
||||||
|
|
||||||
|
buf.writeVarInt( table.getAdditional() );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
|
@ -17,15 +17,16 @@ import javax.annotation.Nonnull;
|
|||||||
*/
|
*/
|
||||||
public abstract class ComputerClientMessage implements NetworkMessage
|
public abstract class ComputerClientMessage implements NetworkMessage
|
||||||
{
|
{
|
||||||
private int instanceId;
|
private final int instanceId;
|
||||||
|
|
||||||
public ComputerClientMessage( int instanceId )
|
public ComputerClientMessage( int instanceId )
|
||||||
{
|
{
|
||||||
this.instanceId = instanceId;
|
this.instanceId = instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerClientMessage()
|
public ComputerClientMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
instanceId = buf.readVarInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInstanceId()
|
public int getInstanceId()
|
||||||
@ -39,12 +40,6 @@ public abstract class ComputerClientMessage implements NetworkMessage
|
|||||||
buf.writeVarInt( instanceId );
|
buf.writeVarInt( instanceId );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
instanceId = buf.readVarInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClientComputer getComputer()
|
public ClientComputer getComputer()
|
||||||
{
|
{
|
||||||
ClientComputer computer = ComputerCraft.clientComputerRegistry.get( instanceId );
|
ClientComputer computer = ComputerCraft.clientComputerRegistry.get( instanceId );
|
||||||
|
@ -18,8 +18,8 @@ import javax.annotation.Nonnull;
|
|||||||
*/
|
*/
|
||||||
public class ComputerDataClientMessage extends ComputerClientMessage
|
public class ComputerDataClientMessage extends ComputerClientMessage
|
||||||
{
|
{
|
||||||
private ComputerState state;
|
private final ComputerState state;
|
||||||
private CompoundNBT userData;
|
private final CompoundNBT userData;
|
||||||
|
|
||||||
public ComputerDataClientMessage( ServerComputer computer )
|
public ComputerDataClientMessage( ServerComputer computer )
|
||||||
{
|
{
|
||||||
@ -28,8 +28,11 @@ public class ComputerDataClientMessage extends ComputerClientMessage
|
|||||||
userData = computer.getUserData();
|
userData = computer.getUserData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerDataClientMessage()
|
public ComputerDataClientMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
super( buf );
|
||||||
|
state = buf.readEnum( ComputerState.class );
|
||||||
|
userData = buf.readNbt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -40,14 +43,6 @@ public class ComputerDataClientMessage extends ComputerClientMessage
|
|||||||
buf.writeNbt( userData );
|
buf.writeNbt( userData );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
super.fromBytes( buf );
|
|
||||||
state = buf.readEnum( ComputerState.class );
|
|
||||||
userData = buf.readNbt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
package dan200.computercraft.shared.network.client;
|
package dan200.computercraft.shared.network.client;
|
||||||
|
|
||||||
import dan200.computercraft.ComputerCraft;
|
import dan200.computercraft.ComputerCraft;
|
||||||
|
import net.minecraft.network.PacketBuffer;
|
||||||
import net.minecraftforge.fml.network.NetworkEvent;
|
import net.minecraftforge.fml.network.NetworkEvent;
|
||||||
|
|
||||||
public class ComputerDeletedClientMessage extends ComputerClientMessage
|
public class ComputerDeletedClientMessage extends ComputerClientMessage
|
||||||
@ -15,8 +16,9 @@ public class ComputerDeletedClientMessage extends ComputerClientMessage
|
|||||||
super( instanceId );
|
super( instanceId );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerDeletedClientMessage()
|
public ComputerDeletedClientMessage( PacketBuffer buffer )
|
||||||
{
|
{
|
||||||
|
super( buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,7 +12,7 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
public class ComputerTerminalClientMessage extends ComputerClientMessage
|
public class ComputerTerminalClientMessage extends ComputerClientMessage
|
||||||
{
|
{
|
||||||
private TerminalState state;
|
private final TerminalState state;
|
||||||
|
|
||||||
public ComputerTerminalClientMessage( int instanceId, TerminalState state )
|
public ComputerTerminalClientMessage( int instanceId, TerminalState state )
|
||||||
{
|
{
|
||||||
@ -20,8 +20,10 @@ public class ComputerTerminalClientMessage extends ComputerClientMessage
|
|||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerTerminalClientMessage()
|
public ComputerTerminalClientMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
super( buf );
|
||||||
|
state = new TerminalState( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -31,13 +33,6 @@ public class ComputerTerminalClientMessage extends ComputerClientMessage
|
|||||||
state.write( buf );
|
state.write( buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
super.fromBytes( buf );
|
|
||||||
state = new TerminalState( buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
public class ComputerActionServerMessage extends ComputerServerMessage
|
public class ComputerActionServerMessage extends ComputerServerMessage
|
||||||
{
|
{
|
||||||
private Action action;
|
private final Action action;
|
||||||
|
|
||||||
public ComputerActionServerMessage( int instanceId, Action action )
|
public ComputerActionServerMessage( int instanceId, Action action )
|
||||||
{
|
{
|
||||||
@ -21,8 +21,10 @@ public class ComputerActionServerMessage extends ComputerServerMessage
|
|||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerActionServerMessage()
|
public ComputerActionServerMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
super( buf );
|
||||||
|
action = buf.readEnum( Action.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,13 +34,6 @@ public class ComputerActionServerMessage extends ComputerServerMessage
|
|||||||
buf.writeEnum( action );
|
buf.writeEnum( action );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
super.fromBytes( buf );
|
|
||||||
action = buf.readEnum( Action.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
||||||
{
|
{
|
||||||
|
@ -22,15 +22,16 @@ import javax.annotation.Nonnull;
|
|||||||
*/
|
*/
|
||||||
public abstract class ComputerServerMessage implements NetworkMessage
|
public abstract class ComputerServerMessage implements NetworkMessage
|
||||||
{
|
{
|
||||||
private int instanceId;
|
private final int instanceId;
|
||||||
|
|
||||||
public ComputerServerMessage( int instanceId )
|
public ComputerServerMessage( int instanceId )
|
||||||
{
|
{
|
||||||
this.instanceId = instanceId;
|
this.instanceId = instanceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ComputerServerMessage()
|
public ComputerServerMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
instanceId = buf.readVarInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -39,12 +40,6 @@ public abstract class ComputerServerMessage implements NetworkMessage
|
|||||||
buf.writeVarInt( instanceId );
|
buf.writeVarInt( instanceId );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
instanceId = buf.readVarInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
|
@ -18,8 +18,8 @@ public class KeyEventServerMessage extends ComputerServerMessage
|
|||||||
public static final int TYPE_REPEAT = 1;
|
public static final int TYPE_REPEAT = 1;
|
||||||
public static final int TYPE_UP = 2;
|
public static final int TYPE_UP = 2;
|
||||||
|
|
||||||
private int type;
|
private final int type;
|
||||||
private int key;
|
private final int key;
|
||||||
|
|
||||||
public KeyEventServerMessage( int instanceId, int type, int key )
|
public KeyEventServerMessage( int instanceId, int type, int key )
|
||||||
{
|
{
|
||||||
@ -28,8 +28,11 @@ public class KeyEventServerMessage extends ComputerServerMessage
|
|||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyEventServerMessage()
|
public KeyEventServerMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
super( buf );
|
||||||
|
type = buf.readByte();
|
||||||
|
key = buf.readVarInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -40,14 +43,6 @@ public class KeyEventServerMessage extends ComputerServerMessage
|
|||||||
buf.writeVarInt( key );
|
buf.writeVarInt( key );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
super.fromBytes( buf );
|
|
||||||
type = buf.readByte();
|
|
||||||
key = buf.readVarInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
||||||
{
|
{
|
||||||
|
@ -19,10 +19,10 @@ public class MouseEventServerMessage extends ComputerServerMessage
|
|||||||
public static final int TYPE_UP = 2;
|
public static final int TYPE_UP = 2;
|
||||||
public static final int TYPE_SCROLL = 3;
|
public static final int TYPE_SCROLL = 3;
|
||||||
|
|
||||||
private int type;
|
private final int type;
|
||||||
private int x;
|
private final int x;
|
||||||
private int y;
|
private final int y;
|
||||||
private int arg;
|
private final int arg;
|
||||||
|
|
||||||
public MouseEventServerMessage( int instanceId, int type, int arg, int x, int y )
|
public MouseEventServerMessage( int instanceId, int type, int arg, int x, int y )
|
||||||
{
|
{
|
||||||
@ -33,8 +33,13 @@ public class MouseEventServerMessage extends ComputerServerMessage
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MouseEventServerMessage()
|
public MouseEventServerMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
super( buf );
|
||||||
|
type = buf.readByte();
|
||||||
|
arg = buf.readVarInt();
|
||||||
|
x = buf.readVarInt();
|
||||||
|
y = buf.readVarInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,16 +52,6 @@ public class MouseEventServerMessage extends ComputerServerMessage
|
|||||||
buf.writeVarInt( y );
|
buf.writeVarInt( y );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
super.fromBytes( buf );
|
|
||||||
type = buf.readByte();
|
|
||||||
arg = buf.readVarInt();
|
|
||||||
x = buf.readVarInt();
|
|
||||||
y = buf.readVarInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
||||||
{
|
{
|
||||||
|
@ -22,8 +22,8 @@ import javax.annotation.Nullable;
|
|||||||
*/
|
*/
|
||||||
public class QueueEventServerMessage extends ComputerServerMessage
|
public class QueueEventServerMessage extends ComputerServerMessage
|
||||||
{
|
{
|
||||||
private String event;
|
private final String event;
|
||||||
private Object[] args;
|
private final Object[] args;
|
||||||
|
|
||||||
public QueueEventServerMessage( int instanceId, @Nonnull String event, @Nullable Object[] args )
|
public QueueEventServerMessage( int instanceId, @Nonnull String event, @Nullable Object[] args )
|
||||||
{
|
{
|
||||||
@ -32,8 +32,13 @@ public class QueueEventServerMessage extends ComputerServerMessage
|
|||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueueEventServerMessage()
|
public QueueEventServerMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
super( buf );
|
||||||
|
event = buf.readUtf( Short.MAX_VALUE );
|
||||||
|
|
||||||
|
CompoundNBT args = buf.readNbt();
|
||||||
|
this.args = args == null ? null : NBTUtil.decodeObjects( args );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,16 +49,6 @@ public class QueueEventServerMessage extends ComputerServerMessage
|
|||||||
buf.writeNbt( args == null ? null : NBTUtil.encodeObjects( args ) );
|
buf.writeNbt( args == null ? null : NBTUtil.encodeObjects( args ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
super.fromBytes( buf );
|
|
||||||
event = buf.readUtf( Short.MAX_VALUE );
|
|
||||||
|
|
||||||
CompoundNBT args = buf.readNbt();
|
|
||||||
this.args = args == null ? null : NBTUtil.decodeObjects( args );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
protected void handle( @Nonnull ServerComputer computer, @Nonnull IContainerComputer container )
|
||||||
{
|
{
|
||||||
|
@ -15,15 +15,16 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
public class RequestComputerMessage implements NetworkMessage
|
public class RequestComputerMessage implements NetworkMessage
|
||||||
{
|
{
|
||||||
private int instance;
|
private final int instance;
|
||||||
|
|
||||||
public RequestComputerMessage( int instance )
|
public RequestComputerMessage( int instance )
|
||||||
{
|
{
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequestComputerMessage()
|
public RequestComputerMessage( @Nonnull PacketBuffer buf )
|
||||||
{
|
{
|
||||||
|
instance = buf.readVarInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -32,12 +33,6 @@ public class RequestComputerMessage implements NetworkMessage
|
|||||||
buf.writeVarInt( instance );
|
buf.writeVarInt( instance );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes( @Nonnull PacketBuffer buf )
|
|
||||||
{
|
|
||||||
instance = buf.readVarInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle( NetworkEvent.Context context )
|
public void handle( NetworkEvent.Context context )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user