本文整理汇总了Java中net.minecraft.network.play.client.CPacketCreativeInventoryAction.getStack方法的典型用法代码示例。如果您正苦于以下问题:Java CPacketCreativeInventoryAction.getStack方法的具体用法?Java CPacketCreativeInventoryAction.getStack怎么用?Java CPacketCreativeInventoryAction.getStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.network.play.client.CPacketCreativeInventoryAction
的用法示例。
在下文中一共展示了CPacketCreativeInventoryAction.getStack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCreativeInventoryAction
import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入方法依赖的package包/类
/**
* Update the server with an ItemStack in a slot.
*/
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (this.playerEntity.interactionManager.isCreative())
{
boolean flag = packetIn.getSlotId() < 0;
ItemStack itemstack = packetIn.getStack();
if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
{
NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");
if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
{
BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
TileEntity tileentity = this.playerEntity.world.getTileEntity(blockpos);
if (tileentity != null)
{
NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
nbttagcompound1.removeTag("x");
nbttagcompound1.removeTag("y");
nbttagcompound1.removeTag("z");
itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
}
}
}
boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45;
boolean flag2 = itemstack.func_190926_b() || itemstack.getMetadata() >= 0 && itemstack.func_190916_E() <= 64 && !itemstack.func_190926_b();
if (flag1 && flag2)
{
if (itemstack.func_190926_b())
{
this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), ItemStack.field_190927_a);
}
else
{
this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
}
this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
}
else if (flag && flag2 && this.itemDropThreshold < 200)
{
this.itemDropThreshold += 20;
EntityItem entityitem = this.playerEntity.dropItem(itemstack, true);
if (entityitem != null)
{
entityitem.setAgeToCreativeDespawnTime();
}
}
}
}
示例2: processCreativeInventoryAction
import net.minecraft.network.play.client.CPacketCreativeInventoryAction; //导入方法依赖的package包/类
/**
* Update the server with an ItemStack in a slot.
*/
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
if (this.playerEntity.interactionManager.isCreative())
{
boolean flag = packetIn.getSlotId() < 0;
ItemStack itemstack = packetIn.getStack();
if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
{
NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");
if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
{
BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos);
if (tileentity != null)
{
NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
nbttagcompound1.removeTag("x");
nbttagcompound1.removeTag("y");
nbttagcompound1.removeTag("z");
itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
}
}
}
boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45;
boolean flag2 = itemstack == null || itemstack.getItem() != null;
boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0;
if (flag1 && flag2 && flag3)
{
if (itemstack == null)
{
this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null);
}
else
{
this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
}
this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
}
else if (flag && flag2 && flag3 && this.itemDropThreshold < 200)
{
this.itemDropThreshold += 20;
EntityItem entityitem = this.playerEntity.dropItem(itemstack, true);
if (entityitem != null)
{
entityitem.setAgeToCreativeDespawnTime();
}
}
}
}