本文整理汇总了Java中net.minecraft.item.ItemStack.copyItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.copyItemStack方法的具体用法?Java ItemStack.copyItemStack怎么用?Java ItemStack.copyItemStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.copyItemStack方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPotionAttemptBrew
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean onPotionAttemptBrew(ItemStack[] stacks)
{
ItemStack[] tmp = new ItemStack[stacks.length];
for (int x = 0; x < tmp.length; x++)
tmp[x] = ItemStack.copyItemStack(stacks[x]);
PotionBrewEvent.Pre event = new PotionBrewEvent.Pre(tmp);
if (MinecraftForge.EVENT_BUS.post(event))
{
boolean changed = false;
for (int x = 0; x < stacks.length; x++)
{
changed |= ItemStack.areItemStacksEqual(tmp[x], stacks[x]);
stacks[x] = event.getItem(x);
}
if (changed)
onPotionBrewed(stacks);
return true;
}
return false;
}
示例2: copyInventory
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Copy the ItemStack contents from another InventoryPlayer instance
*/
public void copyInventory(InventoryPlayer playerInventory)
{
for (int i = 0; i < this.mainInventory.length; ++i)
{
this.mainInventory[i] = ItemStack.copyItemStack(playerInventory.mainInventory[i]);
}
for (int j = 0; j < this.armorInventory.length; ++j)
{
this.armorInventory[j] = ItemStack.copyItemStack(playerInventory.armorInventory[j]);
}
this.currentItem = playerInventory.currentItem;
}
示例3: copyStackWithSize
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static ItemStack copyStackWithSize(ItemStack itemStack, int size)
{
if (size == 0)
return null;
ItemStack copy = ItemStack.copyItemStack(itemStack);
if (copy != null)
copy.stackSize = size;
return copy;
}
示例4: addItemStackToInventory
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Adds the item stack to the inventory, returns false if it is impossible.
*/
public boolean addItemStackToInventory(final ItemStack itemStackIn)
{
if (itemStackIn != null && itemStackIn.stackSize != 0 && itemStackIn.getItem() != null)
{
try
{
if (itemStackIn.isItemDamaged())
{
int j = this.getFirstEmptyStack();
if (j >= 0)
{
this.mainInventory[j] = ItemStack.copyItemStack(itemStackIn);
this.mainInventory[j].animationsToGo = 5;
itemStackIn.stackSize = 0;
return true;
}
else if (this.player.capabilities.isCreativeMode)
{
itemStackIn.stackSize = 0;
return true;
}
else
{
return false;
}
}
else
{
int i;
while (true)
{
i = itemStackIn.stackSize;
itemStackIn.stackSize = this.storePartialItemStack(itemStackIn);
if (itemStackIn.stackSize <= 0 || itemStackIn.stackSize >= i)
{
break;
}
}
if (itemStackIn.stackSize == i && this.player.capabilities.isCreativeMode)
{
itemStackIn.stackSize = 0;
return true;
}
else
{
return itemStackIn.stackSize < i;
}
}
}
catch (Throwable throwable)
{
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added");
crashreportcategory.addCrashSection("Item ID", Integer.valueOf(Item.getIdFromItem(itemStackIn.getItem())));
crashreportcategory.addCrashSection("Item data", Integer.valueOf(itemStackIn.getMetadata()));
crashreportcategory.addCrashSectionCallable("Item name", new Callable<String>()
{
public String call() throws Exception
{
return itemStackIn.getDisplayName();
}
});
throw new ReportedException(crashreport);
}
}
else
{
return false;
}
}
示例5: processPlayerBlockPlacement
import net.minecraft.item.ItemStack; //导入方法依赖的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()));
}
}
}
示例6: getOutput
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public ItemStack getOutput(ItemStack input, ItemStack ingredient)
{
return isInput(input) && isIngredient(ingredient) ? ItemStack.copyItemStack(getOutput()) : null;
}
示例7: addItemStackToInventory
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Adds the item stack to the inventory, returns false if it is impossible.
*/
public boolean addItemStackToInventory(@Nullable final ItemStack itemStackIn)
{
if (itemStackIn != null && itemStackIn.stackSize != 0 && itemStackIn.getItem() != null)
{
try
{
if (itemStackIn.isItemDamaged())
{
int j = this.getFirstEmptyStack();
if (j >= 0)
{
this.mainInventory[j] = ItemStack.copyItemStack(itemStackIn);
this.mainInventory[j].animationsToGo = 5;
itemStackIn.stackSize = 0;
return true;
}
else if (this.player.capabilities.isCreativeMode)
{
itemStackIn.stackSize = 0;
return true;
}
else
{
return false;
}
}
else
{
int i;
while (true)
{
i = itemStackIn.stackSize;
itemStackIn.stackSize = this.storePartialItemStack(itemStackIn);
if (itemStackIn.stackSize <= 0 || itemStackIn.stackSize >= i)
{
break;
}
}
if (itemStackIn.stackSize == i && this.player.capabilities.isCreativeMode)
{
itemStackIn.stackSize = 0;
return true;
}
else
{
return itemStackIn.stackSize < i;
}
}
}
catch (Throwable throwable)
{
CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Adding item to inventory");
CrashReportCategory crashreportcategory = crashreport.makeCategory("Item being added");
crashreportcategory.addCrashSection("Item ID", Integer.valueOf(Item.getIdFromItem(itemStackIn.getItem())));
crashreportcategory.addCrashSection("Item data", Integer.valueOf(itemStackIn.getMetadata()));
crashreportcategory.setDetail("Item name", new ICrashReportDetail<String>()
{
public String call() throws Exception
{
return itemStackIn.getDisplayName();
}
});
throw new ReportedException(crashreport);
}
}
else
{
return false;
}
}