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
+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();