Fix handling of ItemStacks using getShareTag or Capabilites (#3171)
Temporary fix, ideally we would have a way to reference the original ItemStack so we don't need to send the full NBT data to the client.
This commit is contained in:
@@ -41,11 +41,11 @@ import appeng.core.sync.packets.PacketMatterCannon;
|
||||
import appeng.core.sync.packets.PacketMockExplosion;
|
||||
import appeng.core.sync.packets.PacketPaintedEntity;
|
||||
import appeng.core.sync.packets.PacketPartPlacement;
|
||||
import appeng.core.sync.packets.PacketPartialItem;
|
||||
import appeng.core.sync.packets.PacketPatternSlot;
|
||||
import appeng.core.sync.packets.PacketProgressBar;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketTargetItemStack;
|
||||
import appeng.core.sync.packets.PacketTransitionEffect;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
@@ -90,7 +90,7 @@ public class AppEngPacketHandlerBase
|
||||
|
||||
PACKET_RECIPE_JEI( PacketJEIRecipe.class ),
|
||||
|
||||
PACKET_PARTIAL_ITEM( PacketPartialItem.class ),
|
||||
PACKET_TARGET_ITEM( PacketTargetItemStack.class ),
|
||||
|
||||
PACKET_CRAFTING_REQUEST( PacketCraftRequest.class ),
|
||||
|
||||
|
||||
+36
-30
@@ -25,35 +25,56 @@ import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
|
||||
public class PacketPartialItem extends AppEngPacket
|
||||
public class PacketTargetItemStack extends AppEngPacket
|
||||
{
|
||||
|
||||
private final short pageNum;
|
||||
private final byte[] data;
|
||||
private AEItemStack stack;
|
||||
|
||||
// automatic.
|
||||
public PacketPartialItem( final ByteBuf stream )
|
||||
public PacketTargetItemStack( final ByteBuf stream )
|
||||
{
|
||||
this.pageNum = stream.readShort();
|
||||
stream.readBytes( this.data = new byte[stream.readableBytes()] );
|
||||
try
|
||||
{
|
||||
if( stream.readableBytes() > 0 )
|
||||
{
|
||||
this.stack = AEItemStack.fromPacket( stream );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
AELog.debug( ex );
|
||||
this.stack = null;
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketPartialItem( final int page, final int maxPages, final byte[] buf )
|
||||
public PacketTargetItemStack( AEItemStack stack )
|
||||
{
|
||||
|
||||
this.stack = stack;
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
this.pageNum = (short) ( page | ( maxPages << 8 ) );
|
||||
this.data = buf;
|
||||
data.writeInt( this.getPacketID() );
|
||||
data.writeShort( this.pageNum );
|
||||
data.writeBytes( buf );
|
||||
|
||||
if( stack != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
stack.writeToPacket( data );
|
||||
}
|
||||
catch( Exception ex )
|
||||
{
|
||||
AELog.debug( ex );
|
||||
}
|
||||
}
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@@ -62,23 +83,8 @@ public class PacketPartialItem extends AppEngPacket
|
||||
{
|
||||
if( player.openContainer instanceof AEBaseContainer )
|
||||
{
|
||||
( (AEBaseContainer) player.openContainer ).postPartial( this );
|
||||
( (AEBaseContainer) player.openContainer ).setTargetStack( this.stack );
|
||||
}
|
||||
}
|
||||
|
||||
public int getPageCount()
|
||||
{
|
||||
return this.pageNum >> 8;
|
||||
}
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return this.data.length;
|
||||
}
|
||||
|
||||
public int write( final byte[] buffer, final int cursor )
|
||||
{
|
||||
System.arraycopy( this.data, 0, buffer, cursor, this.data.length );
|
||||
return cursor + this.data.length;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user