Interface Terminal
Fixed bug with Assembler Packet Crashing the server.
This commit is contained in:
@@ -5,21 +5,22 @@ import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.render.effects.AssemblerFX;
|
||||
import appeng.client.EffectType;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketAssemblerAnimation extends AppEngPacket
|
||||
{
|
||||
|
||||
int x, y, z;
|
||||
byte rate;
|
||||
IAEItemStack is;
|
||||
final public int x, y, z;
|
||||
final public byte rate;
|
||||
final public IAEItemStack is;
|
||||
|
||||
// automatic.
|
||||
public PacketAssemblerAnimation(ByteBuf stream) throws IOException {
|
||||
@@ -31,14 +32,14 @@ public class PacketAssemblerAnimation extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
double d0 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
double d1 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
double d2 = 0.5d;// + ((double) (Platform.getRandomFloat() - 0.5F) * 0.26D);
|
||||
|
||||
AssemblerFX fx = new AssemblerFX( Minecraft.getMinecraft().theWorld, x + d0, y + d1, z + d2, 0.0D, 0.0D, 0.0D, rate, is );
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
CommonHelper.proxy.spawnEffect( EffectType.Assembler, player.getEntityWorld(), x + d0, y + d1, z + d2, this );
|
||||
}
|
||||
|
||||
// api
|
||||
|
||||
@@ -25,12 +25,14 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
|
||||
final public InventoryAction action;
|
||||
final public int slot;
|
||||
final public long id;
|
||||
final public IAEItemStack slotItem;
|
||||
|
||||
// automatic.
|
||||
public PacketInventoryAction(ByteBuf stream) throws IOException {
|
||||
action = InventoryAction.values()[stream.readInt()];
|
||||
slot = stream.readInt();
|
||||
id = stream.readLong();
|
||||
boolean hasItem = stream.readBoolean();
|
||||
if ( hasItem )
|
||||
slotItem = AEItemStack.loadItemStackFromPacket( stream );
|
||||
@@ -64,7 +66,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
}
|
||||
else
|
||||
{
|
||||
aebc.doAction( sender, action, slot );
|
||||
aebc.doAction( sender, action, slot, id );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,11 +86,12 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
// api
|
||||
public PacketInventoryAction(InventoryAction action, int slot, IAEItemStack slotItem) throws IOException {
|
||||
|
||||
if ( Platform.isClient() && slotItem != null )
|
||||
if ( Platform.isClient() )
|
||||
throw new RuntimeException( "invalid packet, client cannot post inv actions with stacks." );
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = 0;
|
||||
this.slotItem = slotItem;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
@@ -96,6 +99,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( id );
|
||||
|
||||
if ( slotItem == null )
|
||||
data.writeBoolean( false );
|
||||
@@ -108,4 +112,22 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketInventoryAction(InventoryAction action, int slot, long id) throws IOException {
|
||||
|
||||
this.action = action;
|
||||
this.slot = slot;
|
||||
this.id = id;
|
||||
this.slotItem = null;
|
||||
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
data.writeInt( slot );
|
||||
data.writeLong( id );
|
||||
data.writeBoolean( false );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user