Ported to 1.7
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PacketConfigButton extends AppEngPacket
|
||||
@@ -22,13 +22,13 @@ public class PacketConfigButton extends AppEngPacket
|
||||
final public boolean rotationDirection;
|
||||
|
||||
// automatic.
|
||||
public PacketConfigButton(DataInputStream stream) throws IOException {
|
||||
public PacketConfigButton(ByteBuf stream) throws IOException {
|
||||
option = Settings.values()[stream.readInt()];
|
||||
rotationDirection = stream.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
AEBaseContainer aebc = (AEBaseContainer) sender.openContainer;
|
||||
@@ -45,14 +45,12 @@ public class PacketConfigButton extends AppEngPacket
|
||||
this.option = option;
|
||||
this.rotationDirection = rotationDirection;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( option.ordinal() );
|
||||
data.writeBoolean( rotationDirection );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
final public IAEItemStack slotItem;
|
||||
|
||||
// automatic.
|
||||
public PacketInventoryAction(DataInputStream stream) throws IOException {
|
||||
public PacketInventoryAction(ByteBuf stream) throws IOException {
|
||||
action = InventoryAction.values()[stream.readInt()];
|
||||
slot = stream.readInt();
|
||||
boolean hasItem = stream.readBoolean();
|
||||
@@ -33,7 +33,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
if ( sender.openContainer instanceof AEBaseContainer )
|
||||
@@ -49,8 +49,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
this.slot = slot;
|
||||
this.slotItem = slotItem;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( action.ordinal() );
|
||||
@@ -64,8 +63,7 @@ public class PacketInventoryAction extends AppEngPacket
|
||||
slotItem.writeToPacket( data );
|
||||
}
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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 net.minecraft.network.INetworkManager;
|
||||
import appeng.client.ClientHelper;
|
||||
import appeng.client.render.effects.LightningEffect;
|
||||
import appeng.core.Configuration;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -25,7 +25,7 @@ public class PacketLightning extends AppEngPacket
|
||||
final double z;
|
||||
|
||||
// automatic.
|
||||
public PacketLightning(DataInputStream stream) throws IOException {
|
||||
public PacketLightning(ByteBuf stream) throws IOException {
|
||||
x = stream.readFloat();
|
||||
y = stream.readFloat();
|
||||
z = stream.readFloat();
|
||||
@@ -33,7 +33,7 @@ public class PacketLightning extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkManager network, AppEngPacket packet, EntityPlayer player)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -55,16 +55,14 @@ public class PacketLightning extends AppEngPacket
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
data.writeFloat( (float) y );
|
||||
data.writeFloat( (float) z );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.util.ChatMessageComponent;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketLocalizedChatMsg extends AppEngPacket
|
||||
{
|
||||
|
||||
final public String msg;
|
||||
|
||||
// automatic.
|
||||
public PacketLocalizedChatMsg(DataInputStream stream) throws IOException {
|
||||
msg = stream.readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkManager network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
((EntityPlayer) player).sendChatToPlayer( ChatMessageComponent.createFromTranslationWithSubstitutions( msg ) );
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketLocalizedChatMsg(String msg) throws IOException {
|
||||
this.msg = msg;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeUTF( msg );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.BufferOverflowException;
|
||||
import java.util.LinkedList;
|
||||
@@ -11,13 +11,13 @@ import java.util.List;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.Packet250CustomPayload;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.implementations.GuiMEMonitorable;
|
||||
import appeng.client.gui.implementations.GuiNetworkStatus;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -25,8 +25,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
{
|
||||
|
||||
// output...
|
||||
final private ByteArrayOutputStream bytes;
|
||||
final private DataOutputStream data;
|
||||
final private ByteBuf data;
|
||||
int lastSize = 0;
|
||||
boolean empty = true;
|
||||
|
||||
@@ -34,18 +33,17 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
final List<IAEItemStack> list;
|
||||
|
||||
// automatic.
|
||||
public PacketMEInventoryUpdate(DataInputStream stream) throws IOException {
|
||||
bytes = null;
|
||||
public PacketMEInventoryUpdate(ByteBuf stream) throws IOException {
|
||||
data = null;
|
||||
list = new LinkedList();
|
||||
while (stream.available() > 0)
|
||||
while (stream.readableBytes() > 0)
|
||||
list.add( AEItemStack.loadItemStackFromPacket( stream ) );
|
||||
empty = list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkManager network, AppEngPacket packet, EntityPlayer player)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
GuiScreen gs = Minecraft.getMinecraft().currentScreen;
|
||||
|
||||
@@ -58,36 +56,34 @@ public class PacketMEInventoryUpdate extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet250CustomPayload getPacket()
|
||||
public FMLProxyPacket getProxy()
|
||||
{
|
||||
isChunkDataPacket = false;
|
||||
byte[] dataOut = new byte[lastSize];
|
||||
System.arraycopy( bytes.toByteArray(), 0, dataOut, 0, lastSize );
|
||||
configureWrite( dataOut );
|
||||
return super.getPacket();
|
||||
data.capacity( lastSize );
|
||||
configureWrite( data );
|
||||
return super.getProxy();
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMEInventoryUpdate() throws IOException {
|
||||
bytes = new ByteArrayOutputStream();
|
||||
data = new DataOutputStream( bytes );
|
||||
data = Unpooled.buffer( 2048 );
|
||||
list = null;
|
||||
data.writeInt( getPacketID() );
|
||||
lastSize = data.readableBytes();
|
||||
}
|
||||
|
||||
public void appendItem(IAEItemStack is) throws IOException, BufferOverflowException
|
||||
{
|
||||
is.writeToPacket( data );
|
||||
empty = false;
|
||||
if ( bytes.size() > 20000 )
|
||||
if ( data.readableBytes() > 20000 )
|
||||
throw new BufferOverflowException();
|
||||
else
|
||||
lastSize = bytes.size();
|
||||
lastSize = data.readableBytes();
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return data.size();
|
||||
return data.readableBytes();
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
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 net.minecraft.item.Item;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.client.render.effects.MatterCannonEffect;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@@ -29,7 +29,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
final byte len;
|
||||
|
||||
// automatic.
|
||||
public PacketMatterCannon(DataInputStream stream) throws IOException {
|
||||
public PacketMatterCannon(ByteBuf stream) throws IOException {
|
||||
x = stream.readFloat();
|
||||
y = stream.readFloat();
|
||||
z = stream.readFloat();
|
||||
@@ -41,7 +41,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkManager network, AppEngPacket packet, EntityPlayer player)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -49,7 +49,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
World world = FMLClientHandler.instance().getClient().theWorld;
|
||||
for (int a = 1; a < len; a++)
|
||||
{
|
||||
MatterCannonEffect fx = new MatterCannonEffect( world, x + dx * a, y + dy * a, z + dz * a, Item.diamond );
|
||||
MatterCannonEffect fx = new MatterCannonEffect( world, x + dx * a, y + dy * a, z + dz * a, Items.diamond );
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect( (EntityFX) fx );
|
||||
}
|
||||
@@ -72,8 +72,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
this.dz = dz / dlz;
|
||||
this.len = len;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeFloat( (float) x );
|
||||
@@ -84,8 +83,7 @@ public class PacketMatterCannon extends AppEngPacket
|
||||
data.writeFloat( (float) this.dz );
|
||||
data.writeByte( len );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.core.CommonHelper;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@@ -22,14 +22,14 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void clientPacketData(INetworkManager network, AppEngPacket packet, EntityPlayer player)
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
World world = CommonHelper.proxy.getWorld();
|
||||
world.spawnParticle( "largeexplode", this.x, this.y, this.z, 1.0D, 0.0D, 0.0D );
|
||||
}
|
||||
|
||||
// automatic.
|
||||
public PacketMockExplosion(DataInputStream stream) throws IOException {
|
||||
public PacketMockExplosion(ByteBuf stream) throws IOException {
|
||||
x = stream.readDouble();
|
||||
y = stream.readDouble();
|
||||
z = stream.readDouble();
|
||||
@@ -41,16 +41,14 @@ public class PacketMockExplosion extends AppEngPacket
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeDouble( x );
|
||||
data.writeDouble( y );
|
||||
data.writeDouble( z );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,42 +1,45 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.integration.modules.helpers.FMPPacketEvent;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.integration.abstraction.IFMP;
|
||||
|
||||
public class PacketMultiPart extends AppEngPacket
|
||||
{
|
||||
|
||||
// automatic.
|
||||
public PacketMultiPart(DataInputStream stream) throws IOException {
|
||||
public PacketMultiPart(ByteBuf stream) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
MinecraftForge.EVENT_BUS.post( new FMPPacketEvent( sender ) );
|
||||
IFMP fmp = (IFMP) AppEng.instance.getIntegration( "FMP" );
|
||||
if ( fmp != null )
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
MinecraftForge.EVENT_BUS.post( fmp.newFMPPacketEvent( sender ) ); // when received it just pots this event.
|
||||
}
|
||||
}
|
||||
|
||||
// api
|
||||
public PacketMultiPart() throws IOException {
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.helpers.PartPlacement;
|
||||
|
||||
public class PacketPartPlacement extends AppEngPacket
|
||||
@@ -17,7 +17,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
int x, y, z, face;
|
||||
|
||||
// automatic.
|
||||
public PacketPartPlacement(DataInputStream stream) throws IOException {
|
||||
public PacketPartPlacement(ByteBuf stream) throws IOException {
|
||||
x = stream.readInt();
|
||||
y = stream.readInt();
|
||||
z = stream.readInt();
|
||||
@@ -25,7 +25,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
EntityPlayerMP sender = (EntityPlayerMP) player;
|
||||
PartPlacement.place( sender.getHeldItem(), x, y, z, face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
|
||||
@@ -34,8 +34,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
// api
|
||||
public PacketPartPlacement(int x, int y, int z, int face) throws IOException {
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( x );
|
||||
@@ -43,8 +42,7 @@ public class PacketPartPlacement extends AppEngPacket
|
||||
data.writeInt( z );
|
||||
data.writeByte( face );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerOpenContext;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PacketSwitchGuis extends AppEngPacket
|
||||
@@ -21,12 +21,12 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
final GuiBridge newGui;
|
||||
|
||||
// automatic.
|
||||
public PacketSwitchGuis(DataInputStream stream) throws IOException {
|
||||
public PacketSwitchGuis(ByteBuf stream) throws IOException {
|
||||
newGui = GuiBridge.values()[stream.readInt()];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
if ( c instanceof AEBaseContainer )
|
||||
@@ -35,7 +35,7 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
ContainerOpenContext context = bc.openContext;
|
||||
if ( context != null )
|
||||
{
|
||||
TileEntity te = context.w.getBlockTileEntity( context.x, context.y, context.z );
|
||||
TileEntity te = context.w.getTileEntity( context.x, context.y, context.z );
|
||||
Platform.openGUI( player, te, context.side, newGui );
|
||||
}
|
||||
}
|
||||
@@ -46,13 +46,11 @@ public class PacketSwitchGuis extends AppEngPacket
|
||||
|
||||
this.newGui = newGui;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeInt( newGui.ordinal() );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
package appeng.core.sync.packets;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.core.sync.AppEngPacket;
|
||||
import appeng.core.sync.network.INetworkInfo;
|
||||
|
||||
import com.sun.xml.internal.messaging.saaj.util.ByteInputStream;
|
||||
import com.sun.xml.internal.messaging.saaj.util.ByteOutputStream;
|
||||
|
||||
public class PacketValueConfig extends AppEngPacket
|
||||
{
|
||||
@@ -22,13 +27,15 @@ public class PacketValueConfig extends AppEngPacket
|
||||
final public String Value;
|
||||
|
||||
// automatic.
|
||||
public PacketValueConfig(DataInputStream stream) throws IOException {
|
||||
Name = stream.readUTF();
|
||||
Value = stream.readUTF();
|
||||
public PacketValueConfig(ByteBuf stream) throws IOException {
|
||||
DataInputStream dis = new DataInputStream( new ByteInputStream( stream.array(), 0, stream.readableBytes() ) );
|
||||
Name = dis.readUTF();
|
||||
Value = dis.readUTF();
|
||||
dis.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverPacketData(INetworkManager manager, AppEngPacket packet, EntityPlayer player)
|
||||
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
@@ -77,14 +84,18 @@ public class PacketValueConfig extends AppEngPacket
|
||||
this.Name = Name;
|
||||
this.Value = Value;
|
||||
|
||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
DataOutputStream data = new DataOutputStream( bytes );
|
||||
ByteBuf data = Unpooled.buffer();
|
||||
|
||||
data.writeInt( getPacketID() );
|
||||
data.writeUTF( Name );
|
||||
data.writeUTF( Value );
|
||||
|
||||
isChunkDataPacket = false;
|
||||
configureWrite( bytes.toByteArray() );
|
||||
ByteOutputStream bos = new ByteOutputStream();
|
||||
DataOutputStream dos = new DataOutputStream( bos );
|
||||
data.writeBytes( Name.getBytes() );
|
||||
data.writeBytes( Value.getBytes() );
|
||||
dos.close();
|
||||
|
||||
data.writeBytes( bos.getBytes() );
|
||||
|
||||
configureWrite( data );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user