initial commit
This commit is contained in:
parent
3c9ee26b06
commit
22186c33b9
1458 changed files with 282792 additions and 0 deletions
95
java/src/game/packet/CPacketPlace.java
Executable file
95
java/src/game/packet/CPacketPlace.java
Executable file
|
@ -0,0 +1,95 @@
|
|||
package game.packet;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import game.item.ItemStack;
|
||||
import game.network.NetHandlerPlayServer;
|
||||
import game.network.Packet;
|
||||
import game.network.PacketBuffer;
|
||||
import game.world.BlockPos;
|
||||
|
||||
public class CPacketPlace implements Packet<NetHandlerPlayServer>
|
||||
{
|
||||
private static final BlockPos DUMMY_POS = new BlockPos(-1, -1, -1);
|
||||
|
||||
private BlockPos position;
|
||||
private int placedBlockDirection;
|
||||
private ItemStack stack;
|
||||
private float facingX;
|
||||
private float facingY;
|
||||
private float facingZ;
|
||||
|
||||
public CPacketPlace()
|
||||
{
|
||||
}
|
||||
|
||||
public CPacketPlace(ItemStack stackIn)
|
||||
{
|
||||
this(DUMMY_POS, 255, stackIn, 0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
public CPacketPlace(BlockPos positionIn, int placedBlockDirectionIn, ItemStack stackIn, float facingXIn, float facingYIn, float facingZIn)
|
||||
{
|
||||
this.position = positionIn;
|
||||
this.placedBlockDirection = placedBlockDirectionIn;
|
||||
this.stack = stackIn != null ? stackIn.copy() : null;
|
||||
this.facingX = facingXIn;
|
||||
this.facingY = facingYIn;
|
||||
this.facingZ = facingZIn;
|
||||
}
|
||||
|
||||
public void readPacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
this.position = buf.readBlockPos();
|
||||
this.placedBlockDirection = buf.readUnsignedByte();
|
||||
this.stack = buf.readItemStackFromBuffer();
|
||||
this.facingX = (float)buf.readUnsignedByte() / 16.0F;
|
||||
this.facingY = (float)buf.readUnsignedByte() / 16.0F;
|
||||
this.facingZ = (float)buf.readUnsignedByte() / 16.0F;
|
||||
}
|
||||
|
||||
public void writePacketData(PacketBuffer buf) throws IOException
|
||||
{
|
||||
buf.writeBlockPos(this.position);
|
||||
buf.writeByte(this.placedBlockDirection);
|
||||
buf.writeItemStackToBuffer(this.stack);
|
||||
buf.writeByte((int)(this.facingX * 16.0F));
|
||||
buf.writeByte((int)(this.facingY * 16.0F));
|
||||
buf.writeByte((int)(this.facingZ * 16.0F));
|
||||
}
|
||||
|
||||
public void processPacket(NetHandlerPlayServer handler)
|
||||
{
|
||||
handler.processPlace(this);
|
||||
}
|
||||
|
||||
public BlockPos getPosition()
|
||||
{
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public int getPlacedBlockDirection()
|
||||
{
|
||||
return this.placedBlockDirection;
|
||||
}
|
||||
|
||||
public ItemStack getStack()
|
||||
{
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
public float getPlacedBlockOffsetX()
|
||||
{
|
||||
return this.facingX;
|
||||
}
|
||||
|
||||
public float getPlacedBlockOffsetY()
|
||||
{
|
||||
return this.facingY;
|
||||
}
|
||||
|
||||
public float getPlacedBlockOffsetZ()
|
||||
{
|
||||
return this.facingZ;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue