2013-12-27 23:59:59 +01:00
|
|
|
package appeng.core.sync.packets;
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import io.netty.buffer.Unpooled;
|
|
|
|
|
2013-12-27 23:59:59 +01:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2014-01-05 09:39:48 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-27 23:59:59 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
2014-08-03 06:53:34 +02:00
|
|
|
import appeng.core.CommonHelper;
|
2013-12-27 23:59:59 +01:00
|
|
|
import appeng.core.sync.AppEngPacket;
|
2014-02-09 02:34:52 +01:00
|
|
|
import appeng.core.sync.network.INetworkInfo;
|
2014-03-02 09:35:11 +01:00
|
|
|
import appeng.parts.PartPlacement;
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
public class PacketPartPlacement extends AppEngPacket
|
|
|
|
{
|
|
|
|
|
|
|
|
int x, y, z, face;
|
|
|
|
|
|
|
|
// automatic.
|
2014-02-09 02:34:52 +01:00
|
|
|
public PacketPartPlacement(ByteBuf stream) throws IOException {
|
2013-12-27 23:59:59 +01:00
|
|
|
x = stream.readInt();
|
|
|
|
y = stream.readInt();
|
|
|
|
z = stream.readInt();
|
|
|
|
face = stream.readByte();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-02-09 02:34:52 +01:00
|
|
|
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
|
2013-12-27 23:59:59 +01:00
|
|
|
{
|
|
|
|
EntityPlayerMP sender = (EntityPlayerMP) player;
|
2014-08-03 06:53:34 +02:00
|
|
|
CommonHelper.proxy.updateRenderMode( sender );
|
2013-12-27 23:59:59 +01:00
|
|
|
PartPlacement.place( sender.getHeldItem(), x, y, z, face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
|
2014-08-03 06:53:34 +02:00
|
|
|
CommonHelper.proxy.updateRenderMode( null );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// api
|
|
|
|
public PacketPartPlacement(int x, int y, int z, int face) throws IOException {
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
ByteBuf data = Unpooled.buffer();
|
2013-12-27 23:59:59 +01:00
|
|
|
|
|
|
|
data.writeInt( getPacketID() );
|
|
|
|
data.writeInt( x );
|
|
|
|
data.writeInt( y );
|
|
|
|
data.writeInt( z );
|
|
|
|
data.writeByte( face );
|
|
|
|
|
2014-02-09 02:34:52 +01:00
|
|
|
configureWrite( data );
|
2013-12-27 23:59:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|