本文整理汇总了Java中net.minecraft.item.ItemStack.areItemStacksEqual方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.areItemStacksEqual方法的具体用法?Java ItemStack.areItemStacksEqual怎么用?Java ItemStack.areItemStacksEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.areItemStacksEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detectAndSendChanges
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Looks for changes made in the container, sends them to every listener.
*/
public void detectAndSendChanges()
{
for (int i = 0; i < this.inventorySlots.size(); ++i)
{
ItemStack itemstack = ((Slot)this.inventorySlots.get(i)).getStack();
ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i);
if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
{
itemstack1 = itemstack == null ? null : itemstack.copy();
this.inventoryItemStacks.set(i, itemstack1);
for (int j = 0; j < this.crafters.size(); ++j)
{
((ICrafting)this.crafters.get(j)).sendSlotContents(this, i, itemstack1);
}
}
}
}
示例2: detectAndSendChanges
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Looks for changes made in the container, sends them to every listener.
*/
public void detectAndSendChanges()
{
for (int i = 0; i < this.inventorySlots.size(); ++i)
{
ItemStack itemstack = ((Slot)this.inventorySlots.get(i)).getStack();
ItemStack itemstack1 = (ItemStack)this.inventoryItemStacks.get(i);
if (!ItemStack.areItemStacksEqual(itemstack1, itemstack))
{
itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack.copy();
this.inventoryItemStacks.set(i, itemstack1);
for (int j = 0; j < this.listeners.size(); ++j)
{
((IContainerListener)this.listeners.get(j)).sendSlotContents(this, i, itemstack1);
}
}
}
}
示例3: equals
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean equals(Object obj)
{
if(this == obj) return true;
if(obj instanceof StackRecipeElement)
{
return ItemStack.areItemStacksEqual(((StackRecipeElement) obj).stack, this.stack);
}
return false;
}
示例4: playerTick
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@SubscribeEvent
public void playerTick(TickEvent.PlayerTickEvent event)
{
if(event.side == Side.CLIENT && event.phase == TickEvent.Phase.END)
{
EntityPlayer player = event.player;
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if(heldItem != currentTool.get(player.getName()) && (heldItem.isEmpty() || (Block.getBlockFromItem(heldItem.getItem()) == Blocks.AIR)))
{
if(currentTool.get(player.getName()) != null && (currentTool.get(player.getName()).getItem().isFull3D() || currentTool.get(player.getName()).getItem() instanceof ItemBow) && !BackTools.blacklist.contains(currentTool.get(player.getName()).getItem()))
{
ItemStack is = currentTool.get(player.getName()).copy();
IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelMesher().getItemModel(is);
if(!(model instanceof ModelBaseWrapper))
{
is.setItemDamage(0);
ItemStack prevTool = playerTool.get(player.getName());
if(prevTool == null || (prevTool.isEmpty() || !ItemStack.areItemStacksEqual(prevTool, is)))
{
playerTool.put(player.getName(), is);
}
}
}
currentTool.put(player.getName(), heldItem);
}
}
}
示例5: removeRecipe
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void removeRecipe(RecipeElement input, ItemStack output)
{
ItemStack result = instance().smeltingList.get(input);
if(instance().smeltingList.containsKey(input) && ItemStack.areItemStacksEqual(result, output)) return;
{
instance().experienceList.remove(result);
instance().smeltingList.remove(input);
}
}
示例6: getInventoryMatcher
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public Predicate<ItemStack> getInventoryMatcher() {
return stack -> {
for (ItemStack s : inventory) {
if (ItemStack.areItemStacksEqual(s, stack)) {
return true;
}
}
return false;
};
}
示例7: setStackInSlot
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void setStackInSlot(int slot, @Nonnull ItemStack stack) {
validateSlotIndex(slot);
if (ItemStack.areItemStacksEqual(stacks.get(slot), stack)) {
return;
}
stacks.set(slot, stack);
onContentsChanged(slot);
}
示例8: areItemStacksEqualForCrafting
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/** An unlimited type of areItemStacksEqual for crafting recipes (non-amount sensitive, cannot be null) */
public static boolean areItemStacksEqualForCrafting(ItemStack... stacks) {
ItemStack comp = stacks[0];
if(comp.isEmpty()) return false;
ItemStack comp1 = comp.copy(); comp1.setCount(1);
for(int n = 1; n < stacks.length; n++) {
if(stacks[n].isEmpty()) return false;
ItemStack comp2 = stacks[n].copy(); comp2.setCount(1);
if(!ItemStack.areItemStacksEqual(comp1, comp2)) return false;
}
return true;
}
示例9: fromSmelting
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static <T extends IRecipeWrapper> Supplied<CraftingControl> fromSmelting(ItemStack input)
{
return new Supplied<>(() ->
{
IRecipeCategory cat = PMJeiPlugin.RUNTIME.getRecipeRegistry().getRecipeCategory(VanillaRecipeCategoryUid.SMELTING);
List<T> lst = PMJeiPlugin.RUNTIME.getRecipeRegistry().getRecipeWrappers(cat);
T rec = null;
try
{
IIngredients holder = INGREDIENTS.newInstance();
recipeLoop:
for (T wr : lst)
{
wr.getIngredients(holder);
List<List<ItemStack>> inp = holder.getInputs(ItemStack.class);
if (inp.size() > 0)
{
List<ItemStack> i = inp.get(0);
for (ItemStack is : i)
{
if (ItemStack.areItemStacksEqual(is, input))
{
rec = wr;
break recipeLoop;
}
}
}
}
}
catch (InstantiationException | IllegalAccessException e)
{
throw new ReportedException(CrashReport.makeCrashReport(e, "Something went wrong when creating furnace recipe renderer"));
}
return new CraftingControl(cat, rec, BORDER_VANILLA, BORDER_VANILLA_SIZE);
});
}
示例10: shouldCauseReequipAnimation
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged)
{
return slotChanged || !ItemStack.areItemStacksEqual(oldStack, newStack);
}
示例11: appendItemInShop
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static void appendItemInShop ( Account acc, Shop s, int catId, int merchId ) {
ItemInfo ii = ( ItemInfo ) s . cats [ catId ] . getMerch ( merchId ) ;
if ( ii . limit < 10 && ItemStack . areItemStacksEqual ( ii . m_stack, acc . manageSession . currentItemStack ) ) {
acc . manageSession . setItemStack ( null ) ;
ii . limit ++ ;
s . cats [ catId ] . updateMerch ( merchId, ii ) ;
ModNetworkRegistry . sendToAllAddMerchPacket ( ii ) ;
}
}
示例12: shouldCauseReequipAnimation
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) {
return !ItemStack.areItemStacksEqual(oldStack, newStack) || slotChanged;
}
示例13: processClickWindow
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they
* didn't match the indicated result and prevents further manipulation by the player until he confirms that it has
* the same open container/inventory
*/
public void processClickWindow(CPacketClickWindow packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
this.playerEntity.markPlayerActive();
if (this.playerEntity.openContainer.windowId == packetIn.getWindowId() && this.playerEntity.openContainer.getCanCraft(this.playerEntity))
{
if (this.playerEntity.isSpectator())
{
NonNullList<ItemStack> nonnulllist = NonNullList.<ItemStack>func_191196_a();
for (int i = 0; i < this.playerEntity.openContainer.inventorySlots.size(); ++i)
{
nonnulllist.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(i)).getStack());
}
this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, nonnulllist);
}
else
{
ItemStack itemstack2 = this.playerEntity.openContainer.slotClick(packetIn.getSlotId(), packetIn.getUsedButton(), packetIn.getClickType(), this.playerEntity);
if (ItemStack.areItemStacksEqual(packetIn.getClickedItem(), itemstack2))
{
this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
this.playerEntity.isChangingQuantityOnly = true;
this.playerEntity.openContainer.detectAndSendChanges();
this.playerEntity.updateHeldItem();
this.playerEntity.isChangingQuantityOnly = false;
}
else
{
this.pendingTransactions.addKey(this.playerEntity.openContainer.windowId, Short.valueOf(packetIn.getActionNumber()));
this.playerEntity.connection.sendPacket(new SPacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), false));
this.playerEntity.openContainer.setCanCraft(this.playerEntity, false);
NonNullList<ItemStack> nonnulllist1 = NonNullList.<ItemStack>func_191196_a();
for (int j = 0; j < this.playerEntity.openContainer.inventorySlots.size(); ++j)
{
ItemStack itemstack = ((Slot)this.playerEntity.openContainer.inventorySlots.get(j)).getStack();
ItemStack itemstack1 = itemstack.func_190926_b() ? ItemStack.field_190927_a : itemstack;
nonnulllist1.add(itemstack1);
}
this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, nonnulllist1);
}
}
}
}
示例14: 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()));
}
}
}
示例15: processClickWindow
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Executes a container/inventory slot manipulation as indicated by the packet. Sends the serverside result if they
* didn't match the indicated result and prevents further manipulation by the player until he confirms that it has
* the same open container/inventory
*/
public void processClickWindow(C0EPacketClickWindow packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());
this.playerEntity.markPlayerActive();
if (this.playerEntity.openContainer.windowId == packetIn.getWindowId() && this.playerEntity.openContainer.getCanCraft(this.playerEntity))
{
if (this.playerEntity.isSpectator())
{
List<ItemStack> list = Lists.<ItemStack>newArrayList();
for (int i = 0; i < this.playerEntity.openContainer.inventorySlots.size(); ++i)
{
list.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(i)).getStack());
}
this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, list);
}
else
{
ItemStack itemstack = this.playerEntity.openContainer.slotClick(packetIn.getSlotId(), packetIn.getUsedButton(), packetIn.getMode(), this.playerEntity);
if (ItemStack.areItemStacksEqual(packetIn.getClickedItem(), itemstack))
{
this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), true));
this.playerEntity.isChangingQuantityOnly = true;
this.playerEntity.openContainer.detectAndSendChanges();
this.playerEntity.updateHeldItem();
this.playerEntity.isChangingQuantityOnly = false;
}
else
{
this.field_147372_n.addKey(this.playerEntity.openContainer.windowId, Short.valueOf(packetIn.getActionNumber()));
this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(packetIn.getWindowId(), packetIn.getActionNumber(), false));
this.playerEntity.openContainer.setCanCraft(this.playerEntity, false);
List<ItemStack> list1 = Lists.<ItemStack>newArrayList();
for (int j = 0; j < this.playerEntity.openContainer.inventorySlots.size(); ++j)
{
list1.add(((Slot)this.playerEntity.openContainer.inventorySlots.get(j)).getStack());
}
this.playerEntity.updateCraftingInventory(this.playerEntity.openContainer, list1);
}
}
}
}