本文整理汇总了Java中net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.getPosition方法的典型用法代码示例。如果您正苦于以下问题:Java C08PacketPlayerBlockPlacement.getPosition方法的具体用法?Java C08PacketPlayerBlockPlacement.getPosition怎么用?Java C08PacketPlayerBlockPlacement.getPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
的用法示例。
在下文中一共展示了C08PacketPlayerBlockPlacement.getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processPlayerBlockPlacement
import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; //导入方法依赖的package包/类
/**
* Processes block placement and block activation (anvil, furnace, etc.)
*/
public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
boolean flag = false;
BlockPos blockpos = packetIn.getPosition();
EnumFacing enumfacing = EnumFacing.getFront(packetIn.getPlacedBlockDirection());
this.playerEntity.markPlayerActive();
if (packetIn.getPlacedBlockDirection() == 255)
{
if (itemstack == null)
{
return;
}
this.playerEntity.theItemInWorldManager.tryUseItem(this.playerEntity, worldserver, itemstack);
}
else if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
{
if (this.hasMoved && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
{
this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, blockpos, enumfacing, packetIn.getPlacedBlockOffsetX(), packetIn.getPlacedBlockOffsetY(), packetIn.getPlacedBlockOffsetZ());
}
flag = true;
}
else
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
this.playerEntity.playerNetServerHandler.sendPacket(new S02PacketChat(chatcomponenttranslation));
flag = true;
}
if (flag)
{
this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos));
this.playerEntity.playerNetServerHandler.sendPacket(new S23PacketBlockChange(worldserver, blockpos.offset(enumfacing)));
}
itemstack = this.playerEntity.inventory.getCurrentItem();
if (itemstack != null && itemstack.stackSize == 0)
{
this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = null;
itemstack = null;
}
if (itemstack == null || itemstack.getMaxItemUseDuration() == 0)
{
this.playerEntity.isChangingQuantityOnly = true;
this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack(this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]);
Slot slot = this.playerEntity.openContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
this.playerEntity.openContainer.detectAndSendChanges();
this.playerEntity.isChangingQuantityOnly = false;
if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), packetIn.getStack()))
{
this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
}
}
}