added packets for missing items report
This commit is contained in:
@@ -24,34 +24,9 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import appeng.core.sync.packets.*;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import appeng.core.sync.packets.PacketAssemblerAnimation;
|
||||
import appeng.core.sync.packets.PacketClick;
|
||||
import appeng.core.sync.packets.PacketCompassRequest;
|
||||
import appeng.core.sync.packets.PacketCompassResponse;
|
||||
import appeng.core.sync.packets.PacketCompressedNBT;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketFluidSlot;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketJEIRecipe;
|
||||
import appeng.core.sync.packets.PacketLightning;
|
||||
import appeng.core.sync.packets.PacketMEFluidInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
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.PacketPatternSlot;
|
||||
import appeng.core.sync.packets.PacketProgressBar;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketTargetFluidStack;
|
||||
import appeng.core.sync.packets.PacketTargetItemStack;
|
||||
import appeng.core.sync.packets.PacketTransitionEffect;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
|
||||
public class AppEngPacketHandlerBase
|
||||
{
|
||||
@@ -107,7 +82,10 @@ public class AppEngPacketHandlerBase
|
||||
|
||||
PACKET_PAINTED_ENTITY( PacketPaintedEntity.class ),
|
||||
|
||||
PACKET_FLUID_TANK( PacketFluidSlot.class );
|
||||
PACKET_FLUID_TANK( PacketFluidSlot.class ),
|
||||
|
||||
PACKET_INFORM_PLAYER( PacketInformPlayer.class );
|
||||
|
||||
|
||||
private final Class<? extends AppEngPacket> packetClass;
|
||||
private final Constructor<? extends AppEngPacket> packetConstructor;
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PacketInformPlayer extends AppEngPacket
|
||||
{
|
||||
private IAEItemStack actualItem = null;
|
||||
private IAEItemStack reportedItem = null;
|
||||
private final InfoType type;
|
||||
|
||||
public PacketInformPlayer( ByteBuf stream ) throws IOException
|
||||
{
|
||||
this.type = InfoType.values()[stream.readInt()];
|
||||
if( type == InfoType.PARTIAL_ITEM_EXTRACTION )
|
||||
{
|
||||
this.reportedItem = AEItemStack.fromPacket( stream );
|
||||
this.actualItem = AEItemStack.fromPacket( stream );
|
||||
}
|
||||
else if( type == InfoType.NO_ITEMS_EXTRACTED )
|
||||
{
|
||||
this.reportedItem = AEItemStack.fromPacket( stream );
|
||||
}
|
||||
}
|
||||
|
||||
public PacketInformPlayer( final IAEItemStack iaeItemStack ) throws IOException
|
||||
{
|
||||
this( iaeItemStack, null );
|
||||
}
|
||||
|
||||
public PacketInformPlayer( IAEItemStack extra, IAEItemStack result ) throws IOException
|
||||
{
|
||||
this.reportedItem = extra;
|
||||
this.actualItem = result;
|
||||
if( actualItem == null )
|
||||
{
|
||||
this.type = InfoType.NO_ITEMS_EXTRACTED;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.type = InfoType.PARTIAL_ITEM_EXTRACTION;
|
||||
}
|
||||
|
||||
final ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( this.getPacketID() );
|
||||
|
||||
data.writeInt( type.ordinal() );
|
||||
|
||||
reportedItem.writeToPacket( data );
|
||||
if( actualItem != null )
|
||||
{
|
||||
actualItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
this.configureWrite( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final EntityPlayer player )
|
||||
{
|
||||
TextComponentString msg = null;
|
||||
|
||||
if( this.type == InfoType.PARTIAL_ITEM_EXTRACTION )
|
||||
{
|
||||
AppEng.proxy.getPlayers().get( 0 ).sendStatusMessage( new TextComponentString( "System reported " + reportedItem.getStackSize() + " " + reportedItem.getItem().getItemStackDisplayName( reportedItem.getDefinition() ) + " available but could only extract" + actualItem.getStackSize() ), false );
|
||||
}
|
||||
else if( this.type == InfoType.NO_ITEMS_EXTRACTED )
|
||||
{
|
||||
AppEng.proxy.getPlayers().get( 0 ).sendStatusMessage( new TextComponentString( "System reported " + reportedItem.getStackSize() + " " + reportedItem.getItem().getItemStackDisplayName( reportedItem.getDefinition() ) + " available but could not extract anything" ), false );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum InfoType
|
||||
{
|
||||
PARTIAL_ITEM_EXTRACTION,
|
||||
NO_ITEMS_EXTRACTED
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user