Applied-Energistics-2-tiler.../core/sync/packets/PacketPartPlacement.java

56 lines
1.4 KiB
Java
Raw Normal View History

package appeng.core.sync.packets;
2014-02-09 02:34:52 +01:00
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 appeng.core.CommonHelper;
import appeng.core.sync.AppEngPacket;
2014-02-09 02:34:52 +01:00
import appeng.core.sync.network.INetworkInfo;
import appeng.parts.PartPlacement;
public class PacketPartPlacement extends AppEngPacket
{
int x, y, z, face;
float eyeHeight;
// automatic.
2014-02-09 02:34:52 +01:00
public PacketPartPlacement(ByteBuf stream) throws IOException {
x = stream.readInt();
y = stream.readInt();
z = stream.readInt();
face = stream.readByte();
eyeHeight = stream.readFloat();
}
@Override
2014-02-09 02:34:52 +01:00
public void serverPacketData(INetworkInfo manager, AppEngPacket packet, EntityPlayer player)
{
EntityPlayerMP sender = (EntityPlayerMP) player;
CommonHelper.proxy.updateRenderMode( sender );
PartPlacement.eyeHeight = eyeHeight;
PartPlacement.place( sender.getHeldItem(), x, y, z, face, sender, sender.worldObj, PartPlacement.PlaceType.INTERACT_FIRST_PASS, 0 );
CommonHelper.proxy.updateRenderMode( null );
}
// api
public PacketPartPlacement(int x, int y, int z, int face, float eyeHeight ) throws IOException {
2014-02-09 02:34:52 +01:00
ByteBuf data = Unpooled.buffer();
data.writeInt( getPacketID() );
data.writeInt( x );
data.writeInt( y );
data.writeInt( z );
data.writeByte( face );
data.writeFloat( eyeHeight );
2014-02-09 02:34:52 +01:00
configureWrite( data );
}
}