Clean packet registration, misc compile things
This commit is contained in:
@@ -19,12 +19,13 @@
|
||||
package appeng.core.sync;
|
||||
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.jodah.typetools.TypeResolver;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
@@ -57,84 +58,73 @@ public class AppEngPacketHandlerBase
|
||||
{
|
||||
private static final Map<Class<? extends AppEngPacket>, PacketTypes> REVERSE_LOOKUP = new HashMap<>();
|
||||
|
||||
|
||||
public enum PacketTypes
|
||||
{
|
||||
PACKET_COMPASS_REQUEST( PacketCompassRequest.class ),
|
||||
PACKET_COMPASS_REQUEST( PacketCompassRequest::new ),
|
||||
|
||||
PACKET_COMPASS_RESPONSE( PacketCompassResponse.class ),
|
||||
PACKET_COMPASS_RESPONSE( PacketCompassResponse::new ),
|
||||
|
||||
PACKET_INVENTORY_ACTION( PacketInventoryAction.class ),
|
||||
PACKET_INVENTORY_ACTION( PacketInventoryAction::new ),
|
||||
|
||||
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate.class ),
|
||||
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate::new ),
|
||||
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate.class ),
|
||||
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate::new ),
|
||||
|
||||
PACKET_CONFIG_BUTTON( PacketConfigButton.class ),
|
||||
PACKET_CONFIG_BUTTON( PacketConfigButton::new ),
|
||||
|
||||
PACKET_PART_PLACEMENT( PacketPartPlacement.class ),
|
||||
PACKET_PART_PLACEMENT( PacketPartPlacement::new ),
|
||||
|
||||
PACKET_LIGHTNING( PacketLightning.class ),
|
||||
PACKET_LIGHTNING( PacketLightning::new ),
|
||||
|
||||
PACKET_MATTER_CANNON( PacketMatterCannon.class ),
|
||||
PACKET_MATTER_CANNON( PacketMatterCannon::new ),
|
||||
|
||||
PACKET_MOCK_EXPLOSION( PacketMockExplosion.class ),
|
||||
PACKET_MOCK_EXPLOSION( PacketMockExplosion::new ),
|
||||
|
||||
PACKET_VALUE_CONFIG( PacketValueConfig.class ),
|
||||
PACKET_VALUE_CONFIG( PacketValueConfig::new ),
|
||||
|
||||
PACKET_TRANSITION_EFFECT( PacketTransitionEffect.class ),
|
||||
PACKET_TRANSITION_EFFECT( PacketTransitionEffect::new ),
|
||||
|
||||
PACKET_PROGRESS_VALUE( PacketProgressBar.class ),
|
||||
PACKET_PROGRESS_VALUE( PacketProgressBar::new ),
|
||||
|
||||
PACKET_CLICK( PacketClick.class ),
|
||||
PACKET_CLICK( PacketClick::new ),
|
||||
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis.class ),
|
||||
PACKET_SWITCH_GUIS( PacketSwitchGuis::new ),
|
||||
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots.class ),
|
||||
PACKET_SWAP_SLOTS( PacketSwapSlots::new ),
|
||||
|
||||
PACKET_PATTERN_SLOT( PacketPatternSlot.class ),
|
||||
PACKET_PATTERN_SLOT( PacketPatternSlot::new ),
|
||||
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe.class ),
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe::new ),
|
||||
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack.class ),
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack::new ),
|
||||
|
||||
PACKET_TARGET_FLUID( PacketTargetFluidStack.class ),
|
||||
PACKET_TARGET_FLUID( PacketTargetFluidStack::new ),
|
||||
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest.class ),
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest::new ),
|
||||
|
||||
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation.class ),
|
||||
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation::new ),
|
||||
|
||||
PACKET_COMPRESSED_NBT( PacketCompressedNBT.class ),
|
||||
PACKET_COMPRESSED_NBT( PacketCompressedNBT::new ),
|
||||
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity.class ),
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity::new ),
|
||||
|
||||
PACKET_FLUID_TANK( PacketFluidSlot.class );
|
||||
PACKET_FLUID_TANK( PacketFluidSlot::new );
|
||||
|
||||
private final Class<? extends AppEngPacket> packetClass;
|
||||
private final Constructor<? extends AppEngPacket> packetConstructor;
|
||||
private final Function<PacketBuffer, AppEngPacket> factory;
|
||||
|
||||
PacketTypes( final Class<? extends AppEngPacket> c )
|
||||
PacketTypes( Function<PacketBuffer, AppEngPacket> factory )
|
||||
{
|
||||
this.packetClass = c;
|
||||
Type c = TypeResolver.resolveGenericType( Function.class, factory.getClass() );
|
||||
if( c == TypeResolver.Unknown.class )
|
||||
{
|
||||
throw new IllegalStateException("Failed to resolve type for AE packet type: " + factory.toString());
|
||||
}
|
||||
this.packetClass = (Class<? extends AppEngPacket>) c;
|
||||
this.factory = factory;
|
||||
|
||||
Constructor<? extends AppEngPacket> x = null;
|
||||
try
|
||||
{
|
||||
x = this.packetClass.getConstructor( ByteBuf.class );
|
||||
}
|
||||
catch( final NoSuchMethodException ignored )
|
||||
{
|
||||
}
|
||||
catch( final SecurityException ignored )
|
||||
{
|
||||
}
|
||||
|
||||
this.packetConstructor = x;
|
||||
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( final int id )
|
||||
@@ -147,9 +137,9 @@ public class AppEngPacketHandlerBase
|
||||
return REVERSE_LOOKUP.get( c );
|
||||
}
|
||||
|
||||
public AppEngPacket parsePacket( final ByteBuf in ) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
||||
public AppEngPacket parsePacket( final PacketBuffer in ) throws IllegalArgumentException
|
||||
{
|
||||
return this.packetConstructor.newInstance( in );
|
||||
return this.factory.apply( in );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -46,8 +47,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
public final byte rate;
|
||||
public final IAEItemStack is;
|
||||
|
||||
// automatic.
|
||||
public PacketAssemblerAnimation( final ByteBuf stream ) throws IOException
|
||||
public PacketAssemblerAnimation( final ByteBuf stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
@@ -60,7 +60,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
public PacketAssemblerAnimation( final BlockPos pos, final byte rate, final IAEItemStack is ) throws IOException
|
||||
{
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeInt( this.x = pos.getX() );
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -55,8 +56,7 @@ public class PacketClick extends AppEngPacket
|
||||
private Hand hand;
|
||||
private final boolean leftClick;
|
||||
|
||||
// automatic.
|
||||
public PacketClick( final ByteBuf stream )
|
||||
public PacketClick( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
|
||||
@@ -23,7 +23,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -43,8 +44,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
|
||||
private PlayerEntity talkBackTo;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassRequest( final ByteBuf stream )
|
||||
public PacketCompassRequest( final PacketBuffer stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
@@ -70,7 +70,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
|
||||
@Override
|
||||
public void calculatedDirection( final boolean hasResult, final boolean spin, final double radians, final double dist )
|
||||
{
|
||||
NetworkHandler.instance().sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (PlayerEntityMP) this.talkBackTo );
|
||||
NetworkHandler.instance().sendTo( new PacketCompassResponse( this, hasResult, spin, radians ), (ServerPlayerEntity) this.talkBackTo );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
@@ -40,8 +41,7 @@ public class PacketCompassResponse extends AppEngPacket
|
||||
|
||||
private CompassResult cr;
|
||||
|
||||
// automatic.
|
||||
public PacketCompassResponse( final ByteBuf stream )
|
||||
public PacketCompassResponse( final PacketBuffer stream )
|
||||
{
|
||||
this.attunement = stream.readLong();
|
||||
this.cx = stream.readInt();
|
||||
|
||||
@@ -31,10 +31,11 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -43,6 +44,7 @@ import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
|
||||
//TODO, this is pointless, NBT is already compressed when written to a PacketBuffer.
|
||||
public class PacketCompressedNBT extends AppEngPacket
|
||||
{
|
||||
|
||||
@@ -52,13 +54,12 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
private final ByteBuf data;
|
||||
private final GZIPOutputStream compressFrame;
|
||||
|
||||
// automatic.
|
||||
public PacketCompressedNBT( final ByteBuf stream ) throws IOException
|
||||
public PacketCompressedNBT( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
|
||||
final GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
|
||||
try( DataInputStream inStream = new DataInputStream( new GZIPInputStream( new InputStream()
|
||||
{
|
||||
|
||||
@Override
|
||||
@@ -71,11 +72,14 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
|
||||
return stream.readByte() & 0xff;
|
||||
}
|
||||
} );
|
||||
|
||||
final DataInputStream inStream = new DataInputStream( gzReader );
|
||||
this.in = CompressedStreamTools.read( inStream );
|
||||
inStream.close();
|
||||
} ) ) )
|
||||
{
|
||||
this.in = CompressedStreamTools.read( inStream );
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
@@ -107,7 +111,7 @@ public class PacketCompressedNBT extends AppEngPacket
|
||||
@OnlyIn( Dist.CLIENT )
|
||||
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
|
||||
{
|
||||
final GuiScreen gs = Minecraft.getInstance().currentScreen;
|
||||
final Screen gs = Minecraft.getInstance().currentScreen;
|
||||
|
||||
if( gs instanceof GuiInterfaceTerminal )
|
||||
{
|
||||
|
||||
@@ -23,7 +23,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.util.IConfigManager;
|
||||
@@ -31,7 +32,6 @@ import appeng.api.util.IConfigurableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.Reflected;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
@@ -40,9 +40,7 @@ public final class PacketConfigButton extends AppEngPacket
|
||||
private final Settings option;
|
||||
private final boolean rotationDirection;
|
||||
|
||||
// automatic.
|
||||
@Reflected
|
||||
public PacketConfigButton( final ByteBuf stream )
|
||||
public PacketConfigButton( final PacketBuffer stream )
|
||||
{
|
||||
this.option = Settings.values()[stream.readInt()];
|
||||
this.rotationDirection = stream.readBoolean();
|
||||
@@ -66,7 +64,7 @@ public final class PacketConfigButton extends AppEngPacket
|
||||
@Override
|
||||
public void serverPacketData( final INetworkInfo manager, final PlayerEntity player )
|
||||
{
|
||||
final PlayerEntityMP sender = (PlayerEntityMP) player;
|
||||
final ServerPlayerEntity sender = (ServerPlayerEntity) player;
|
||||
if( sender.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
final AEBaseContainer baseContainer = (AEBaseContainer) sender.openContainer;
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -48,8 +49,7 @@ public class PacketCraftRequest extends AppEngPacket
|
||||
private final long amount;
|
||||
private final boolean heldShift;
|
||||
|
||||
// automatic.
|
||||
public PacketCraftRequest( final ByteBuf stream )
|
||||
public PacketCraftRequest( final PacketBuffer stream )
|
||||
{
|
||||
this.heldShift = stream.readBoolean();
|
||||
this.amount = stream.readLong();
|
||||
|
||||
@@ -28,6 +28,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
@@ -41,7 +42,7 @@ public class PacketFluidSlot extends AppEngPacket
|
||||
{
|
||||
private final Map<Integer, IAEFluidStack> list;
|
||||
|
||||
public PacketFluidSlot( final ByteBuf stream )
|
||||
public PacketFluidSlot( final PacketBuffer stream )
|
||||
{
|
||||
this.list = new HashMap<>();
|
||||
CompoundNBT tag = ByteBufUtils.readTag( stream );
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -50,8 +51,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
private final long id;
|
||||
private final IAEItemStack slotItem;
|
||||
|
||||
// automatic.
|
||||
public PacketInventoryAction( final ByteBuf stream ) throws IOException
|
||||
public PacketInventoryAction( final PacketBuffer stream )
|
||||
{
|
||||
this.action = InventoryAction.values()[stream.readInt()];
|
||||
this.slot = stream.readInt();
|
||||
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompressedStreamTools;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
@@ -64,12 +65,9 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
|
||||
private ItemStack[][] recipe;
|
||||
|
||||
// automatic.
|
||||
public PacketJEIRecipe( final ByteBuf stream ) throws IOException
|
||||
public PacketJEIRecipe( final PacketBuffer stream )
|
||||
{
|
||||
final ByteArrayInputStream bytes = this.getPacketByteArray( stream );
|
||||
bytes.skip( stream.readerIndex() );
|
||||
final CompoundNBT comp = CompressedStreamTools.readCompressed( bytes );
|
||||
final CompoundNBT comp = stream.readCompoundTag();
|
||||
if( comp != null )
|
||||
{
|
||||
this.recipe = new ItemStack[9][];
|
||||
@@ -91,15 +89,11 @@ public class PacketJEIRecipe extends AppEngPacket
|
||||
// api
|
||||
public PacketJEIRecipe( final CompoundNBT recipe ) throws IOException
|
||||
{
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
final DataOutputStream outputStream = new DataOutputStream( bytes );
|
||||
final PacketBuffer data = new PacketBuffer(Unpooled.buffer());
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
CompressedStreamTools.writeCompressed( recipe, outputStream );
|
||||
data.writeBytes( bytes.toByteArray() );
|
||||
data.writeCompoundTag( recipe );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@@ -42,8 +43,7 @@ public class PacketLightning extends AppEngPacket
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
// automatic.
|
||||
public PacketLightning( final ByteBuf stream )
|
||||
public PacketLightning( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
|
||||
@@ -27,18 +27,16 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
@@ -77,8 +75,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
|
||||
// automatic.
|
||||
public PacketMEFluidInventoryUpdate( final ByteBuf stream ) throws IOException
|
||||
public PacketMEFluidInventoryUpdate( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
@@ -120,6 +117,10 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
this.list.add( AEFluidStack.fromPacket( uncompressed ) );
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
|
||||
this.empty = this.list.isEmpty();
|
||||
}
|
||||
@@ -183,7 +184,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
|
||||
|
||||
public void appendFluid( final IAEFluidStack fs ) throws IOException, BufferOverflowException
|
||||
{
|
||||
final ByteBuf tmp = Unpooled.buffer( OPERATION_BYTE_LIMIT );
|
||||
final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
|
||||
fs.writeToPacket( tmp );
|
||||
|
||||
this.compressFrame.flush();
|
||||
|
||||
@@ -27,7 +27,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -37,7 +36,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.IPacket;
|
||||
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.fml.network.NetworkDirection;
|
||||
@@ -74,8 +73,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
private int writtenBytes = 0;
|
||||
private boolean empty = true;
|
||||
|
||||
// automatic.
|
||||
public PacketMEInventoryUpdate( final ByteBuf stream ) throws IOException
|
||||
public PacketMEInventoryUpdate( final PacketBuffer stream )
|
||||
{
|
||||
this.data = null;
|
||||
this.compressFrame = null;
|
||||
@@ -116,9 +114,12 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
this.list.add( AEItemStack.fromPacket( uncompressed ) );
|
||||
}
|
||||
}
|
||||
catch( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Failed to decompress packet.", e );
|
||||
}
|
||||
|
||||
this.empty = this.list.isEmpty();
|
||||
|
||||
}
|
||||
|
||||
// api
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -46,8 +47,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
private final double dz;
|
||||
private final byte len;
|
||||
|
||||
// automatic.
|
||||
public PacketMatterCannon( final ByteBuf stream )
|
||||
public PacketMatterCannon( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
@@ -40,8 +41,7 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
private final double y;
|
||||
private final double z;
|
||||
|
||||
// automatic.
|
||||
public PacketMockExplosion( final ByteBuf stream )
|
||||
public PacketMockExplosion( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readDouble();
|
||||
this.y = stream.readDouble();
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -38,8 +39,7 @@ public class PacketPaintedEntity extends AppEngPacket
|
||||
private final int entityId;
|
||||
private int ticks;
|
||||
|
||||
// automatic.
|
||||
public PacketPaintedEntity( final ByteBuf stream )
|
||||
public PacketPaintedEntity( final PacketBuffer stream )
|
||||
{
|
||||
this.entityId = stream.readInt();
|
||||
this.myColor = AEColor.values()[stream.readByte()];
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -44,8 +45,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
private float eyeHeight;
|
||||
private Hand hand;
|
||||
|
||||
// automatic.
|
||||
public PacketPartPlacement( final ByteBuf stream )
|
||||
public PacketPartPlacement( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readInt();
|
||||
this.y = stream.readInt();
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.PlayerEntityMP;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
@@ -45,8 +46,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
|
||||
public final boolean shift;
|
||||
|
||||
// automatic.
|
||||
public PacketPatternSlot( final ByteBuf stream ) throws IOException
|
||||
public PacketPatternSlot( final PacketBuffer stream )
|
||||
{
|
||||
|
||||
this.shift = stream.readBoolean();
|
||||
@@ -59,7 +59,7 @@ public class PacketPatternSlot extends AppEngPacket
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack readItem( final ByteBuf stream ) throws IOException
|
||||
private IAEItemStack readItem( final ByteBuf stream )
|
||||
{
|
||||
final boolean hasItem = stream.readBoolean();
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -36,8 +37,7 @@ public class PacketProgressBar extends AppEngPacket
|
||||
private final short id;
|
||||
private final long value;
|
||||
|
||||
// automatic.
|
||||
public PacketProgressBar( final ByteBuf stream )
|
||||
public PacketProgressBar( final PacketBuffer stream )
|
||||
{
|
||||
this.id = stream.readShort();
|
||||
this.value = stream.readLong();
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -35,8 +36,7 @@ public class PacketSwapSlots extends AppEngPacket
|
||||
private final int slotA;
|
||||
private final int slotB;
|
||||
|
||||
// automatic.
|
||||
public PacketSwapSlots( final ByteBuf stream )
|
||||
public PacketSwapSlots( final PacketBuffer stream )
|
||||
{
|
||||
this.slotA = stream.readInt();
|
||||
this.slotB = stream.readInt();
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
@@ -39,8 +40,7 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
|
||||
private final GuiBridge newGui;
|
||||
|
||||
// automatic.
|
||||
public PacketSwitchGuis( final ByteBuf stream )
|
||||
public PacketSwitchGuis( final PacketBuffer stream )
|
||||
{
|
||||
this.newGui = GuiBridge.values()[stream.readInt()];
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
@@ -40,8 +41,7 @@ public class PacketTargetFluidStack extends AppEngPacket
|
||||
{
|
||||
private AEFluidStack stack;
|
||||
|
||||
// automatic.
|
||||
public PacketTargetFluidStack( final ByteBuf stream )
|
||||
public PacketTargetFluidStack( final PacketBuffer stream )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AELog;
|
||||
@@ -35,8 +36,7 @@ public class PacketTargetItemStack extends AppEngPacket
|
||||
{
|
||||
private AEItemStack stack;
|
||||
|
||||
// automatic.
|
||||
public PacketTargetItemStack( final ByteBuf stream )
|
||||
public PacketTargetItemStack( final PacketBuffer stream )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
@@ -50,8 +51,7 @@ public class PacketTransitionEffect extends AppEngPacket
|
||||
private final double z;
|
||||
private final AEPartLocation d;
|
||||
|
||||
// automatic.
|
||||
public PacketTransitionEffect( final ByteBuf stream )
|
||||
public PacketTransitionEffect( final PacketBuffer stream )
|
||||
{
|
||||
this.x = stream.readFloat();
|
||||
this.y = stream.readFloat();
|
||||
|
||||
@@ -19,12 +19,8 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -32,6 +28,7 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.Hand;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
@@ -64,12 +61,10 @@ public class PacketValueConfig extends AppEngPacket
|
||||
private final String Name;
|
||||
private final String Value;
|
||||
|
||||
// automatic.
|
||||
public PacketValueConfig( final ByteBuf stream ) throws IOException
|
||||
public PacketValueConfig( final PacketBuffer stream )
|
||||
{
|
||||
final DataInputStream dis = new DataInputStream( this.getPacketByteArray( stream, stream.readerIndex(), stream.readableBytes() ) );
|
||||
this.Name = dis.readUTF();
|
||||
this.Value = dis.readUTF();
|
||||
this.Name = stream.readString();
|
||||
this.Value = stream.readString();
|
||||
// dis.close();
|
||||
}
|
||||
|
||||
@@ -79,17 +74,12 @@ public class PacketValueConfig extends AppEngPacket
|
||||
this.Name = name;
|
||||
this.Value = value;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
final DataOutputStream dos = new DataOutputStream( bos );
|
||||
dos.writeUTF( name );
|
||||
dos.writeUTF( value );
|
||||
// dos.close();
|
||||
|
||||
data.writeBytes( bos.toByteArray() );
|
||||
data.writeString( name );
|
||||
data.writeString( value );
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
@@ -99,9 +89,7 @@ public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
final Container c = player.openContainer;
|
||||
|
||||
if( this.Name.equals( "Item" ) && ( ( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND )
|
||||
.getItem() instanceof IMouseWheelItem ) || ( !player.getHeldItem( Hand.OFF_HAND )
|
||||
.isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem ) ) )
|
||||
if( this.Name.equals( "Item" ) && ( ( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem ) || ( !player.getHeldItem( Hand.OFF_HAND ).isEmpty() && player.getHeldItem( Hand.OFF_HAND ).getItem() instanceof IMouseWheelItem ) ) )
|
||||
{
|
||||
final Hand hand;
|
||||
if( !player.getHeldItem( Hand.MAIN_HAND ).isEmpty() && player.getHeldItem( Hand.MAIN_HAND ).getItem() instanceof IMouseWheelItem )
|
||||
|
||||
Reference in New Issue
Block a user