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
@@ -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;