Move from ByteBuf to PacketBuffer

This commit is contained in:
covers1624
2020-06-02 11:07:46 +09:30
parent d4c9e5c490
commit 19cdea7eb5
58 changed files with 158 additions and 295 deletions
+3 -4
View File
@@ -30,13 +30,12 @@ import java.util.Random;
import javax.annotation.Nonnull;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
@@ -148,7 +147,7 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
*
* @throws IOException
*/
void writeToStream( ByteBuf data ) throws IOException;
void writeToStream( PacketBuffer data ) throws IOException;
/**
* read data from bus packet.
@@ -159,7 +158,7 @@ public interface IPart extends IBoxProvider, ICustomCableConnection
*
* @throws IOException
*/
boolean readFromStream( ByteBuf data ) throws IOException;
boolean readFromStream( PacketBuffer data ) throws IOException;
/**
* get the Grid Node for the Bus, be sure your IGridBlock is NOT isWorldAccessible, if it is your going to cause
@@ -25,14 +25,12 @@ package appeng.api.storage;
import java.io.IOException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fluids.FluidStack;
import appeng.api.storage.data.IAEStack;
@@ -92,13 +90,12 @@ public interface IStorageChannel<T extends IAEStack<T>>
T createStack( @Nonnull Object input );
/**
*
* @param input
* @return
* @throws IOException
*/
@Nullable
T readFromPacket( @Nonnull ByteBuf input ) throws IOException;
T readFromPacket( @Nonnull PacketBuffer input ) throws IOException;
/**
* create from nbt data
@@ -27,11 +27,9 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
@@ -162,7 +160,7 @@ public class ApiStorage implements IStorageHelper
}
@Override
public IAEItemStack readFromPacket( ByteBuf input ) throws IOException
public IAEItemStack readFromPacket( PacketBuffer input ) throws IOException
{
Preconditions.checkNotNull( input );
@@ -209,7 +207,7 @@ public class ApiStorage implements IStorageHelper
}
else
{
return AEFluidStack.fromFluidStack( FluidUtil.getFluidContained( is ) );
return AEFluidStack.fromFluidStack( FluidUtil.getFluidContained( is ).orElse( null ) );
}
}
@@ -217,7 +215,7 @@ public class ApiStorage implements IStorageHelper
}
@Override
public IAEFluidStack readFromPacket( ByteBuf input ) throws IOException
public IAEFluidStack readFromPacket( PacketBuffer input ) throws IOException
{
Preconditions.checkNotNull( input );
@@ -19,12 +19,8 @@
package appeng.core.sync;
import java.io.ByteArrayInputStream;
import org.apache.commons.lang3.tuple.Pair;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.IPacket;
import net.minecraft.network.PacketBuffer;
@@ -56,10 +52,10 @@ public abstract class AppEngPacket
throw new UnsupportedOperationException( "This packet ( " + this.getPacketID() + " does not implement a client side handler." );
}
protected void configureWrite( final ByteBuf data )
protected void configureWrite( final PacketBuffer data )
{
data.capacity( data.readableBytes() );
this.p = new PacketBuffer( data );
this.p = data;
}
public IPacket<?> toPacket( NetworkDirection direction )
@@ -77,27 +73,4 @@ public abstract class AppEngPacket
// FIXME return direction.buildPacket( Pair.of( p, 0 ), NetworkHandler.instance().getChannel() ).getThis();
return null;
}
// TODO: Figure out why Forge/Minecraft on the server sets the stream data buffer to PooledUnsafeDirectByteBuf
public ByteArrayInputStream getPacketByteArray( ByteBuf stream, int readerIndex, int readableBytes )
{
final ByteArrayInputStream bytes;
if( stream.hasArray() )
{
bytes = new ByteArrayInputStream( stream.array(), readerIndex, readableBytes );
}
else
{
byte[] data = new byte[stream.capacity()];
stream.getBytes( readerIndex, data, 0, readableBytes );
bytes = new ByteArrayInputStream( data );
}
return bytes;
}
public ByteArrayInputStream getPacketByteArray( ByteBuf stream )
{
return this.getPacketByteArray( stream, 0, stream.readableBytes() );
}
}
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -47,7 +46,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
public final byte rate;
public final IAEItemStack is;
public PacketAssemblerAnimation( final ByteBuf stream )
public PacketAssemblerAnimation( final PacketBuffer stream )
{
this.x = stream.readInt();
this.y = stream.readInt();
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.block.Block;
@@ -82,7 +81,7 @@ public class PacketClick extends AppEngPacket
public PacketClick( final BlockPos pos, final Direction side, final float hitX, final float hitY, final float hitZ, final Hand hand, boolean leftClick )
{
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( this.x = pos.getX() );
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -55,7 +54,7 @@ public class PacketCompassRequest extends AppEngPacket implements ICompassCallba
public PacketCompassRequest( final long attunement, final int cx, final int cz, final int cdy )
{
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeLong( this.attunement = attunement );
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -55,7 +54,7 @@ public class PacketCompassResponse extends AppEngPacket
public PacketCompassResponse( final PacketCompassRequest req, final boolean hasResult, final boolean spin, final double radians )
{
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new ( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeLong( this.attunement = req.attunement );
@@ -27,7 +27,6 @@ import java.io.OutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft;
@@ -50,7 +49,7 @@ public class PacketCompressedNBT extends AppEngPacket
// input.
private final CompoundNBT in;
// output...
private final ByteBuf data;
private final PacketBuffer data;
private final GZIPOutputStream compressFrame;
public PacketCompressedNBT( final PacketBuffer stream )
@@ -85,7 +84,7 @@ public class PacketCompressedNBT extends AppEngPacket
public PacketCompressedNBT( final CompoundNBT din ) throws IOException
{
this.data = Unpooled.buffer( 2048 );
this.data = new PacketBuffer( Unpooled.buffer( 2048 ) );
this.data.writeInt( this.getPacketID() );
this.in = din;
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -51,7 +50,7 @@ public final class PacketConfigButton extends AppEngPacket
this.option = option;
this.rotationDirection = rotationDirection;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( option.ordinal() );
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
import java.util.concurrent.Future;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -34,6 +33,8 @@ import appeng.api.networking.crafting.ICraftingGrid;
import appeng.api.networking.crafting.ICraftingJob;
import appeng.api.networking.security.IActionHost;
import appeng.container.ContainerOpenContext;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.container.implementations.ContainerCraftConfirm;
import appeng.core.AELog;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.GuiBridge;
@@ -58,7 +59,7 @@ public class PacketCraftRequest extends AppEngPacket
this.amount = craftAmt;
this.heldShift = shift;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeBoolean( shift );
@@ -22,14 +22,12 @@ package appeng.core.sync.packets;
import java.util.HashMap;
import java.util.Map;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.container.Container;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import appeng.api.storage.data.IAEFluidStack;
import appeng.core.sync.AppEngPacket;
@@ -45,11 +43,11 @@ public class PacketFluidSlot extends AppEngPacket
public PacketFluidSlot( final PacketBuffer stream )
{
this.list = new HashMap<>();
CompoundNBT tag = ByteBufUtils.readTag( stream );
CompoundNBT tag = stream.readCompoundTag();
for( final String key : tag.getKeySet() )
for( final String key : tag.keySet() )
{
this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompoundTag( key ) ) );
this.list.put( Integer.parseInt( key ), AEFluidStack.fromNBT( tag.getCompound( key ) ) );
}
}
@@ -65,12 +63,12 @@ public class PacketFluidSlot extends AppEngPacket
{
fs.getValue().writeToNBT( tag );
}
sendTag.setTag( fs.getKey().toString(), tag );
sendTag.put( fs.getKey().toString(), tag );
}
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
ByteBufUtils.writeTag( data, sendTag );
data.writeCompoundTag( sendTag );
this.configureWrite( data );
}
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -81,7 +80,7 @@ public class PacketInventoryAction extends AppEngPacket
this.id = 0;
this.slotItem = slotItem;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( action.ordinal() );
@@ -109,7 +108,7 @@ public class PacketInventoryAction extends AppEngPacket
this.id = id;
this.slotItem = null;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( action.ordinal() );
@@ -19,19 +19,14 @@
package appeng.core.sync.packets;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.container.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.network.PacketBuffer;
@@ -48,6 +43,7 @@ import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.Api;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.helpers.IContainerCraftingPacket;
@@ -73,13 +69,13 @@ public class PacketJEIRecipe extends AppEngPacket
this.recipe = new ItemStack[9][];
for( int x = 0; x < this.recipe.length; x++ )
{
final ListNBT list = comp.getTagList( "#" + x, 10 );
if( list.tagCount() > 0 )
final ListNBT list = comp.getList( "#" + x, 10 );
if( list.size() > 0 )
{
this.recipe[x] = new ItemStack[list.tagCount()];
for( int y = 0; y < list.tagCount(); y++ )
this.recipe[x] = new ItemStack[list.size()];
for( int y = 0; y < list.size(); y++ )
{
this.recipe[x][y] = new ItemStack( list.getCompoundTagAt( y ) );
this.recipe[x][y] = ItemStack.read( list.getCompound( y ) );
}
}
}
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft;
@@ -30,7 +29,6 @@ import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.client.render.effects.LightningFX;
import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.Platform;
@@ -57,7 +55,7 @@ public class PacketLightning extends AppEngPacket
this.y = y;
this.z = z;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeFloat( (float) x );
@@ -75,8 +73,7 @@ public class PacketLightning extends AppEngPacket
{
if( Platform.isClient() && AEConfig.instance().isEnableEffects() )
{
final LightningFX fx = new LightningFX( AppEng.proxy.getWorld(), this.x, this.y, this.z, 0.0f, 0.0f, 0.0f );
Minecraft.getInstance().effectRenderer.addEffect( fx );
Minecraft.getInstance().world.addParticle( LightningFX.TYPE, this.x, this.y, this.z, 0.0f, 0.0f, 0.0f );
}
}
catch( final Exception ignored )
@@ -29,7 +29,6 @@ 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;
@@ -68,7 +67,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
private final byte ref;
@Nullable
private final ByteBuf data;
private final PacketBuffer data;
@Nullable
private final GZIPOutputStream compressFrame;
@@ -99,7 +98,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
} ) )
{
final ByteBuf uncompressed = Unpooled.buffer( stream.readableBytes() );
final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) );
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while( gzReader.available() != 0 )
@@ -135,7 +134,7 @@ public class PacketMEFluidInventoryUpdate extends AppEngPacket
public PacketMEFluidInventoryUpdate( final byte ref ) throws IOException
{
this.ref = ref;
this.data = Unpooled.buffer( OPERATION_BYTE_LIMIT );
this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
this.data.writeInt( this.getPacketID() );
this.data.writeByte( this.ref );
@@ -29,11 +29,10 @@ 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.minecraft.network.PacketBuffer;
@@ -66,7 +65,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
private final byte ref;
@Nullable
private final ByteBuf data;
private final PacketBuffer data;
@Nullable
private final GZIPOutputStream compressFrame;
@@ -96,7 +95,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
}
} ) )
{
final ByteBuf uncompressed = Unpooled.buffer( stream.readableBytes() );
final PacketBuffer uncompressed = new PacketBuffer( Unpooled.buffer( stream.readableBytes() ) );
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while( gzReader.available() != 0 )
@@ -132,7 +131,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
public PacketMEInventoryUpdate( final byte ref ) throws IOException
{
this.ref = ref;
this.data = Unpooled.buffer( OPERATION_BYTE_LIMIT );
this.data = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
this.data.writeInt( this.getPacketID() );
this.data.writeByte( this.ref );
@@ -152,7 +151,7 @@ public class PacketMEInventoryUpdate 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 GuiCraftConfirm )
{
@@ -196,7 +195,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
public void appendItem( final IAEItemStack is ) throws IOException, BufferOverflowException
{
final ByteBuf tmp = Unpooled.buffer( OPERATION_BYTE_LIMIT );
final PacketBuffer tmp = new PacketBuffer( Unpooled.buffer( OPERATION_BYTE_LIMIT ) );
is.writeToPacket( tmp );
this.compressFrame.flush();
@@ -19,15 +19,14 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
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;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -72,7 +71,7 @@ public class PacketMatterCannon extends AppEngPacket
this.dz = dz / dlz;
this.len = len;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeFloat( (float) x );
@@ -93,12 +92,12 @@ public class PacketMatterCannon extends AppEngPacket
try
{
final World world = FMLClientHandler.instance().getClient().world;
final World world = Minecraft.getInstance().world;
for( int a = 1; a < this.len; a++ )
{
final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, Items.DIAMOND );
final MatterCannonFX fx = new MatterCannonFX( world, this.x + this.dx * a, this.y + this.dy * a, this.z + this.dz * a, new ItemStack( Items.DIAMOND ) );
Minecraft.getInstance().effectRenderer.addEffect( fx );
Minecraft.getInstance().particles.addEffect( fx );
}
}
catch( final Exception ignored )
@@ -19,12 +19,11 @@
package appeng.core.sync.packets;
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.particles.ParticleTypes;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -55,7 +54,7 @@ public class PacketMockExplosion extends AppEngPacket
this.y = y;
this.z = z;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeDouble( x );
@@ -70,6 +69,6 @@ public class PacketMockExplosion extends AppEngPacket
public void clientPacketData( final INetworkInfo network, final PlayerEntity player )
{
final World world = AppEng.proxy.getWorld();
world.spawnParticle( EnumParticleTypes.EXPLOSION_LARGE, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D, new int[0] );
world.addParticle( ParticleTypes.EXPLOSION, this.x, this.y, this.z, 1.0D, 0.0D, 0.0D );
}
}
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -50,7 +49,7 @@ public class PacketPaintedEntity extends AppEngPacket
public PacketPaintedEntity( final int myEntity, final AEColor myColor, final int ticksLeft )
{
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( this.entityId = myEntity );
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -58,7 +57,7 @@ public class PacketPartPlacement extends AppEngPacket
// api
public PacketPartPlacement( final BlockPos pos, final Direction face, final float eyeHeight, final Hand hand )
{
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( pos.getX() );
@@ -21,7 +21,6 @@ package appeng.core.sync.packets;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -32,6 +31,7 @@ import net.minecraftforge.items.IItemHandler;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.Api;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEItemStack;
@@ -59,7 +59,7 @@ public class PacketPatternSlot extends AppEngPacket
}
}
private IAEItemStack readItem( final ByteBuf stream )
private IAEItemStack readItem( final PacketBuffer stream )
{
final boolean hasItem = stream.readBoolean();
@@ -78,7 +78,7 @@ public class PacketPatternSlot extends AppEngPacket
this.slotItem = slotItem;
this.shift = shift;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
@@ -94,7 +94,7 @@ public class PacketPatternSlot extends AppEngPacket
this.configureWrite( data );
}
private void writeItem( final IAEItemStack slotItem, final ByteBuf data ) throws IOException
private void writeItem( final IAEItemStack slotItem, final PacketBuffer data ) throws IOException
{
if( slotItem == null )
{
@@ -19,11 +19,10 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.container.Container;
import net.minecraft.network.PacketBuffer;
import appeng.container.AEBaseContainer;
@@ -49,7 +48,7 @@ public class PacketProgressBar extends AppEngPacket
this.id = (short) shortID;
this.value = value;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeShort( shortID );
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -45,7 +44,7 @@ public class PacketSwapSlots extends AppEngPacket
// api
public PacketSwapSlots( final int slotA, final int slotB )
{
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( this.slotA = slotA );
@@ -19,11 +19,10 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.container.Container;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
@@ -50,7 +49,7 @@ public class PacketSwitchGuis extends AppEngPacket
{
this.newGui = newGui;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeInt( newGui.ordinal() );
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -67,7 +66,7 @@ public class PacketTargetFluidStack extends AppEngPacket
this.stack = stack;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
if( stack != null )
{
@@ -19,7 +19,6 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.PlayerEntity;
@@ -62,7 +61,7 @@ public class PacketTargetItemStack extends AppEngPacket
this.stack = stack;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
if( stack != null )
{
@@ -86,5 +85,4 @@ public class PacketTargetItemStack extends AppEngPacket
( (AEBaseContainer) player.openContainer ).setTargetStack( this.stack );
}
}
}
@@ -19,12 +19,12 @@
package appeng.core.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SimpleSound;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Items;
import net.minecraft.network.PacketBuffer;
@@ -69,7 +69,7 @@ public class PacketTransitionEffect extends AppEngPacket
this.d = dir;
this.mode = wasBlock;
final ByteBuf data = Unpooled.buffer();
final PacketBuffer data = new PacketBuffer( Unpooled.buffer() );
data.writeInt( this.getPacketID() );
data.writeFloat( (float) x );
@@ -105,18 +105,20 @@ public class PacketTransitionEffect extends AppEngPacket
fx.setMotionY( -0.1f * this.d.yOffset );
fx.setMotionZ( -0.1f * this.d.zOffset );
Minecraft.getInstance().effectRenderer.addEffect( fx );
Minecraft.getInstance().particles.addEffect( fx );
}
}
if( this.mode )
{
final Block block = world.getBlockState( new BlockPos( (int) this.x, (int) this.y, (int) this.z ) ).getBlock();
final BlockPos pos = new BlockPos( (int) this.x, (int) this.y, (int) this.z );
final BlockState state = world.getBlockState( pos );
final SoundType sound = state.getSoundType( world, pos, null );
Minecraft.getInstance()
.getSoundHandler()
.playSound( new PositionedSoundRecord( block.getSoundType()
.getBreakSound(), SoundCategory.BLOCKS, ( block.getSoundType().getVolume() + 1.0F ) / 2.0F, block.getSoundType()
.play( new SimpleSound( sound
.getBreakSound(), SoundCategory.BLOCKS, ( sound.getVolume() + 1.0F ) / 2.0F, sound
.getPitch() * 0.8F, (float) this.x + 0.5F, (float) this.y + 0.5F, (float) this.z + 0.5F ) );
}
}
@@ -19,21 +19,12 @@
package appeng.fluids.util;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import javax.annotation.Nonnull;
import io.netty.buffer.ByteBuf;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.network.PacketBuffer;
import net.minecraftforge.fluids.FluidStack;
@@ -119,7 +110,7 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
return fluid;
}
public static IAEFluidStack fromPacket( final ByteBuf buffer ) throws IOException
public static IAEFluidStack fromPacket( final PacketBuffer buffer ) throws IOException
{
final byte mask = buffer.readByte();
final byte stackType = (byte) ( ( mask & 0x0C ) >> 2 );
@@ -130,22 +121,12 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
// don't send this...
final CompoundNBT d = new CompoundNBT();
final byte len2 = buffer.readByte();
final byte[] name = new byte[len2];
buffer.readBytes( name, 0, len2 );
d.putString( "FluidName", new String( name, "UTF-8" ) );
d.putByte( "Count", (byte) 0 );
d.putString( "FluidName", buffer.readString() );
d.putByte( "Amount", (byte) 0 );
if( hasTagCompound )
{
final int len = buffer.readInt();
final byte[] bd = new byte[len];
buffer.readBytes( bd );
final DataInputStream di = new DataInputStream( new ByteArrayInputStream( bd ) );
d.put( "Tag", CompressedStreamTools.read( di ) );
d.put( "Tag", buffer.readCompoundTag() );
}
final long stackSize = getPacketValue( stackType, buffer );
@@ -334,21 +315,10 @@ public final class AEFluidStack extends AEStack<IAEFluidStack> implements IAEFlu
private void writeToStream( final PacketBuffer buffer ) throws IOException
{
final byte[] name = this.fluid.getRegistryName().toString().getBytes(StandardCharsets.UTF_8);
buffer.writeByte( (byte) name.length );
buffer.writeBytes( name );
buffer.writeString( fluid.getRegistryName().toString() );
if( this.hasTagCompound() )
{
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
final DataOutputStream data = new DataOutputStream( bytes );
CompressedStreamTools.write( this.tagCompound, data );
final byte[] tagBytes = bytes.toByteArray();
final int size = tagBytes.length;
buffer.writeInt( size );
buffer.writeBytes( tagBytes );
buffer.writeCompoundTag( tagCompound );
}
}
}
+3 -4
View File
@@ -19,8 +19,7 @@
package appeng.helpers;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
import net.minecraft.util.math.Vec3d;
@@ -68,7 +67,7 @@ public class Splotch
this.side = side;
}
public Splotch( final ByteBuf data )
public Splotch( final PacketBuffer data )
{
this.pos = data.readByte();
@@ -79,7 +78,7 @@ public class Splotch
this.lumen = ( ( val >> 7 ) & 0x01 ) > 0;
}
public void writeToStream( final ByteBuf stream )
public void writeToStream( final PacketBuffer stream )
{
stream.writeByte( this.pos );
final int val = this.getSide().ordinal() | ( this.getColor().ordinal() << 3 ) | ( this.isLumen() ? 0x80 : 0x00 );
+4 -6
View File
@@ -28,14 +28,13 @@ import java.util.Random;
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
@@ -47,7 +46,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Upgrades;
import appeng.api.definitions.IDefinitions;
import appeng.api.implementations.IUpgradeableHost;
@@ -258,13 +256,13 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
return false;
}
@@ -538,4 +536,4 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
{
return this.is;
}
}
}
@@ -21,9 +21,8 @@ package appeng.parts;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import appeng.api.implementations.IPowerChannelState;
import appeng.api.networking.GridFlags;
@@ -60,7 +59,7 @@ public abstract class PartBasicState extends AEBasePart implements IPowerChannel
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
super.writeToStream( data );
@@ -94,7 +93,7 @@ public abstract class PartBasicState extends AEBasePart implements IPowerChannel
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean eh = super.readFromStream( data );
@@ -23,13 +23,12 @@ import java.io.IOException;
import java.util.List;
import java.util.Random;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
@@ -150,13 +149,13 @@ public class PartCableAnchor implements IPart
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
return false;
}
@@ -24,14 +24,12 @@ import java.util.EnumSet;
import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
import appeng.api.definitions.IParts;
import appeng.api.implementations.parts.IPartCable;
@@ -290,7 +288,7 @@ public class PartCable extends AEBasePart implements IPartCable
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
int flags = 0;
boolean[] writeSide = new boolean[Direction.values().length];
@@ -354,7 +352,7 @@ public class PartCable extends AEBasePart implements IPartCable
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
int cs = data.readByte();
final EnumSet<AEPartLocation> myC = this.getConnections().clone();
@@ -22,10 +22,9 @@ package appeng.parts.p2p;
import java.io.IOException;
import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
@@ -77,7 +76,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
super.writeToStream( data );
data.writeInt( this.isOutput() ? this.lastValue : 0 );
@@ -85,7 +84,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
super.readFromStream( data );
final int oldValue = this.lastValue;
@@ -24,15 +24,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Hand;
import net.minecraft.util.math.Vec3d;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.config.PowerUnits;
@@ -151,7 +149,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
}
@Override
public boolean readFromStream( ByteBuf data ) throws IOException
public boolean readFromStream( PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final short oldf = this.freq;
@@ -160,7 +158,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
}
@Override
public void writeToStream( ByteBuf data ) throws IOException
public void writeToStream( PacketBuffer data ) throws IOException
{
super.writeToStream( data );
data.writeShort( this.getFrequency() );
@@ -21,12 +21,10 @@ package appeng.parts.reporting;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.RayTraceResult;
@@ -34,7 +32,6 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.AEApi;
import appeng.api.implementations.parts.IPartStorageMonitor;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStackWatcher;
@@ -47,6 +44,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.client.render.TesrRenderHelper;
import appeng.core.Api;
import appeng.core.localization.PlayerMessages;
import appeng.helpers.Reflected;
import appeng.me.GridAccessException;
@@ -88,7 +86,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
this.isLocked = data.getBoolean( "isLocked" );
final CompoundNBT myItem = data.getCompoundTag( "configuredItem" );
final CompoundNBT myItem = data.getCompound( "configuredItem" );
this.configuredItem = AEItemStack.fromNBT( myItem );
}
@@ -102,14 +100,14 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
final CompoundNBT myItem = new CompoundNBT();
if( this.configuredItem != null )
{
this.configuredItem.write(myItem);
this.configuredItem.writeToNBT(myItem);
}
data.setTag( "configuredItem", myItem );
data.put( "configuredItem", myItem );
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
super.writeToStream( data );
@@ -122,7 +120,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
boolean needRedraw = super.readFromStream( data );
@@ -21,11 +21,10 @@ package appeng.parts.reporting;
import java.io.IOException;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
@@ -139,7 +138,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
}
@Override
public void writeToStream( final ByteBuf data ) throws IOException
public void writeToStream( final PacketBuffer data ) throws IOException
{
super.writeToStream( data );
this.clientFlags = this.getSpin() & 3;
@@ -171,7 +170,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
super.readFromStream( data );
final int oldFlags = this.getClientFlags();
+4 -4
View File
@@ -29,7 +29,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.core.AELog;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.block.BlockState;
@@ -199,7 +199,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
return data;
}
private boolean readUpdateData( ByteBuf stream )
private boolean readUpdateData( PacketBuffer stream )
{
boolean output = false;
@@ -248,7 +248,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
@Override
public void handleUpdateTag( CompoundNBT tag )
{
final ByteBuf stream = Unpooled.copiedBuffer( tag.getByteArray( "X" ) );
final PacketBuffer stream = new PacketBuffer( Unpooled.copiedBuffer( tag.getByteArray( "X" ) ) );
if( this.readUpdateData( stream ) )
{
@@ -256,7 +256,7 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
}
}
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
if( this.canBeRotated() )
{
@@ -22,8 +22,6 @@ package appeng.tile.crafting;
import java.io.IOException;
import java.util.Optional;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -51,7 +49,7 @@ public class TileCraftingMonitorTile extends TileCraftingTile implements IColora
private AEColor paintedColor = AEColor.TRANSPARENT;
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final AEColor oldPaintedColor = this.paintedColor;
@@ -22,8 +22,6 @@ package appeng.tile.crafting;
import java.io.IOException;
import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -197,7 +195,7 @@ public class TileMolecularAssembler extends AENetworkInvTile implements IUpgrade
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final boolean oldPower = this.isPowered;
@@ -23,8 +23,6 @@ import java.io.IOException;
import java.util.Collections;
import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.BlockState;
import net.minecraft.entity.Entity;
import net.minecraft.network.PacketBuffer;
@@ -91,7 +89,7 @@ public class TileCrank extends AEBaseTile implements ICustomCollision, ITickable
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
this.rotation = data.readInt();
@@ -24,8 +24,6 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
@@ -80,7 +78,7 @@ public class TileCharger extends AENetworkPowerTile implements ICrankable, IGrid
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
try
@@ -28,8 +28,6 @@ import javax.annotation.Nullable;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
@@ -149,7 +147,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable,
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final int slot = data.readByte();
@@ -27,8 +27,6 @@ import javax.annotation.Nullable;
import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import net.minecraft.inventory.CraftingInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -185,7 +183,7 @@ public class TileInterface extends AENetworkInvTile implements IGridTickable, II
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
boolean oldOmniDirectional = this.omniDirectional;
+16 -17
View File
@@ -26,7 +26,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.block.BlockState;
@@ -36,7 +35,7 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.LightType;
import appeng.api.util.AEColor;
import appeng.helpers.Splotch;
@@ -59,19 +58,19 @@ public class TilePaint extends AEBaseTile
}
@Override
public CompoundNBT writeToNBT( final CompoundNBT data )
public CompoundNBT write( final CompoundNBT data )
{
super.writeToNBT( data );
final ByteBuf myDat = Unpooled.buffer();
super.write( data );
final PacketBuffer myDat = new PacketBuffer( Unpooled.buffer() );
this.writeBuffer( myDat );
if( myDat.hasArray() )
{
data.setByteArray( "dots", myDat.array() );
data.putByteArray( "dots", myDat.array() );
}
return data;
}
private void writeBuffer( final ByteBuf out )
private void writeBuffer( final PacketBuffer out )
{
if( this.dots == null )
{
@@ -88,16 +87,16 @@ public class TilePaint extends AEBaseTile
}
@Override
public void readFromNBT( final CompoundNBT data )
public void read( final CompoundNBT data )
{
super.readFromNBT( data );
if( data.contains("dots") )
super.read( data );
if( data.contains( "dots" ) )
{
this.readBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) );
this.readBuffer( new PacketBuffer( Unpooled.copiedBuffer( data.getByteArray( "dots" ) ) ) );
}
}
private void readBuffer( final ByteBuf in )
private void readBuffer( final PacketBuffer in )
{
final byte howMany = in.readByte();
@@ -135,7 +134,7 @@ public class TilePaint extends AEBaseTile
if( this.world != null )
{
this.world.getLightFor( EnumSkyBlock.BLOCK, this.pos );
this.world.getLightFor( LightType.BLOCK, this.pos );
}
}
@@ -147,7 +146,7 @@ public class TilePaint extends AEBaseTile
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
super.readFromStream( data );
this.readBuffer( data );
@@ -176,7 +175,7 @@ public class TilePaint extends AEBaseTile
{
final BlockPos p = this.pos.offset( side );
final BlockState blk = this.world.getBlockState( p );
return blk.getBlock().isSideSolid( this.world.getBlockState( p ), this.world, p, side.getOpposite() );
return blk.isSolidSide( world, p, side.getOpposite() );
}
private void removeSide( final Direction side )
@@ -215,7 +214,7 @@ public class TilePaint extends AEBaseTile
if( this.dots == null )
{
this.world.removeBlock(this.pos, false);
this.world.removeBlock( this.pos, false );
}
}
@@ -241,7 +240,7 @@ public class TilePaint extends AEBaseTile
final BlockPos p = this.pos.offset( side );
final BlockState blk = this.world.getBlockState( p );
if( blk.getBlock().isSideSolid( this.world.getBlockState( p ), this.world, p, side.getOpposite() ) )
if( blk.isSolidSide( this.world, p, side.getOpposite() ) )
{
final ItemPaintBall ipb = (ItemPaintBall) type.getItem();
@@ -22,8 +22,6 @@ package appeng.tile.misc;
import java.io.IOException;
import java.util.EnumSet;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
@@ -63,7 +61,7 @@ public class TileQuartzGrowthAccelerator extends AENetworkTile implements IPower
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
public boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final boolean hadPower = this.isPowered();
@@ -24,8 +24,6 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -137,7 +135,7 @@ public class TileSecurityStation extends AENetworkTile implements ITerminalHost,
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final boolean wasActive = this.isActive;
@@ -23,8 +23,6 @@ import java.io.IOException;
import javax.annotation.Nonnull;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -81,7 +79,7 @@ public class TileVibrationChamber extends AENetworkInvTile implements IGridTicka
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final boolean wasOn = this.isOn;
@@ -25,8 +25,6 @@ import java.util.Set;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
@@ -81,7 +79,7 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
boolean ret = this.getCableBus().readFromStream( data );
@@ -22,8 +22,6 @@ package appeng.tile.networking;
import java.io.IOException;
import java.util.EnumSet;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
@@ -85,7 +83,7 @@ public class TileWireless extends AENetworkInvTile implements IWirelessAccessPoi
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final int old = this.getClientFlags();
@@ -23,8 +23,6 @@ import java.io.IOException;
import java.util.EnumSet;
import java.util.Optional;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -106,7 +104,7 @@ public class TileQuantumBridge extends AENetworkInvTile implements IAEMultiBlock
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final int oldValue = this.constructed;
@@ -22,8 +22,6 @@ package appeng.tile.spatial;
import java.io.IOException;
import java.util.EnumSet;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.Direction;
@@ -218,7 +216,7 @@ public class TileSpatialPylon extends AENetworkTile implements IAEMultiBlock
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final int old = this.displayBits;
@@ -26,8 +26,6 @@ import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
@@ -35,7 +33,6 @@ import net.minecraft.network.PacketBuffer;
import net.minecraft.tileentity.ITickableTileEntity;
import net.minecraft.util.Direction;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraft.fluid.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fluids.capability.FluidTankProperties;
@@ -415,7 +412,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
@@ -27,8 +27,6 @@ import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.PacketBuffer;
@@ -123,7 +121,7 @@ public class TileDrive extends AENetworkInvTile implements IChestOrDrive, IPrior
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final int oldState = this.state;
@@ -22,7 +22,6 @@ package appeng.tile.storage;
import java.io.IOException;
import appeng.block.storage.BlockSkyChest;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity;
@@ -64,7 +63,7 @@ public class TileSkyChest extends AEBaseInvTile implements ITickableTileEntity,
}
@Override
protected boolean readFromStream( final ByteBuf data ) throws IOException
protected boolean readFromStream( final PacketBuffer data ) throws IOException
{
final boolean c = super.readFromStream( data );
final int wasOpen = this.getPlayerOpen();
@@ -26,7 +26,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import appeng.core.Api;
import io.netty.buffer.ByteBuf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -38,7 +37,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.items.ItemHandlerHelper;
import appeng.api.AEApi;
import appeng.api.config.FuzzyMode;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
@@ -113,15 +111,14 @@ public final class AEItemStack extends AEStack<IAEItemStack> implements IAEItemS
i.putBoolean( "Craft", this.isCraftable() );
}
public static AEItemStack fromPacket( final ByteBuf data )
public static AEItemStack fromPacket( final PacketBuffer data )
{
final byte mask = data.readByte();
final byte stackType = (byte) ( ( mask & 0x0C ) >> 2 );
final byte countReqType = (byte) ( ( mask & 0x30 ) >> 4 );
final boolean isCraftable = ( mask & 0x40 ) > 0;
final PacketBuffer p = new PacketBuffer( data );
final ItemStack itemstack = p.readItemStack();
final ItemStack itemstack = data.readItemStack();
final long stackSize = getPacketValue( stackType, data );
final long countRequestable = getPacketValue( countReqType, data );
+3 -3
View File
@@ -19,7 +19,7 @@
package appeng.util.item;
import io.netty.buffer.ByteBuf;
import net.minecraft.network.PacketBuffer;
import appeng.api.storage.data.IAEStack;
@@ -31,7 +31,7 @@ public abstract class AEStack<StackType extends IAEStack<StackType>> implements
private long stackSize;
private long countRequestable;
protected static long getPacketValue( final byte type, final ByteBuf tag )
protected static long getPacketValue( final byte type, final PacketBuffer tag )
{
if( type == 0 )
{
@@ -164,7 +164,7 @@ public abstract class AEStack<StackType extends IAEStack<StackType>> implements
protected abstract boolean hasTagCompound();
protected void putPacketValue( final ByteBuf tag, final long num )
protected void putPacketValue( final PacketBuffer tag, final long num )
{
if( num <= 255 )
{