本文整理汇总了Java中net.minecraft.item.ItemStack.isItemEqual方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.isItemEqual方法的具体用法?Java ItemStack.isItemEqual怎么用?Java ItemStack.isItemEqual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.isItemEqual方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns true if the specified ItemStack exists in the inventory.
*/
public boolean hasItemStack(ItemStack itemStackIn)
{
for (ItemStack[] aitemstack : this.allInventories)
{
for (ItemStack itemstack : aitemstack)
{
if (itemstack != null && itemstack.isItemEqual(itemStackIn))
{
return true;
}
}
}
return false;
}
示例2: setInventorySlotContents
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
public void setInventorySlotContents(int index, @Nullable ItemStack stack)
{
boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]);
this.furnaceItemStacks[index] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
if (index == 0 && !flag)
{
this.totalCookTime = this.getCookTime(stack);
this.cookTime = 0;
this.markDirty();
}
}
示例3: getRemainingItems
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
NonNullList<ItemStack> nonnulllist = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
for (int i = 0; i < nonnulllist.size(); ++i) {
ItemStack itemstack = inv.getStackInSlot(i);
if (itemstack.isItemEqual(new ItemStack(Items.POTIONITEM))) {
nonnulllist.set(i, new ItemStack(Items.GLASS_BOTTLE, 1));
continue;
}
nonnulllist.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack));
}
return nonnulllist;
}
示例4: setInventorySlotContents
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*/
public void setInventorySlotContents(int index, ItemStack stack)
{
boolean flag = stack != null && stack.isItemEqual(this.furnaceItemStacks[index]) && ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks[index]);
this.furnaceItemStacks[index] = stack;
if (stack != null && stack.stackSize > this.getInventoryStackLimit())
{
stack.stackSize = this.getInventoryStackLimit();
}
if (index == 0 && !flag)
{
this.totalCookTime = this.getCookTime(stack);
this.cookTime = 0;
this.markDirty();
}
}
示例5: importFromChamber
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void importFromChamber(TileEntityPressureChamberValve core) {
ItemStackHandler chamberStacks = core.getStacksInChamber();
for (ItemStack chamberStack : new ItemStackHandlerIterable(chamberStacks)) {
ItemStack inputStack = inventory.getStackInSlot(0);
if ((inputStack.isEmpty() || inputStack.isItemEqual(chamberStack)) && filterHandler.doesItemMatchFilter(chamberStack)) {
int maxAllowedItems = Math.abs(core.getAirHandler(null).getAir()) / PneumaticValues.USAGE_CHAMBER_INTERFACE;
if (maxAllowedItems > 0) {
if (!inputStack.isEmpty()) {
maxAllowedItems = Math.min(maxAllowedItems, chamberStack.getMaxStackSize() - inputStack.getCount());
}
int transferredItems = Math.min(chamberStack.getCount(), maxAllowedItems);
ItemStack toTransferStack = chamberStack.copy().splitStack(transferredItems);
ItemStack excess = inventory.insertItem(0, toTransferStack, true);
if (excess.getCount() < toTransferStack.getCount()) {
// we can transfer at least some of the items
transferredItems = toTransferStack.getCount() - excess.getCount();
core.addAir((core.getAirHandler(null).getAir() > 0 ? -1 : 1) * transferredItems * PneumaticValues.USAGE_CHAMBER_INTERFACE);
toTransferStack.setCount(transferredItems);
inventory.insertItem(0, toTransferStack, false);
chamberStack.shrink(transferredItems);
}
}
}
}
}
示例6: setInventorySlotContents
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Sets the given item stack to the specified slot in the inventory (can be
* crafting or armor sections).
*/
@Override
public void setInventorySlotContents(int index, @Nullable ItemStack stack) {
boolean flag = !stack.isEmpty() && stack.isItemEqual(this.furnaceItemStacks.get(index))
&& ItemStack.areItemStackTagsEqual(stack, this.furnaceItemStacks.get(index));
this.furnaceItemStacks.set(index, stack);
if (!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit())
stack.setCount( this.getInventoryStackLimit());
if (index < 9 && !flag) {
this.totalCookTime = this.getCookTime(stack);
this.cookTime = 0;
this.markDirty();
}
}
示例7: getItemAmount
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public int getItemAmount() {
List<ItemStack> stacks = new ArrayList<>();
for (int i = 0; i < input.getSlots(); ++i) {
if (!input.getStackInSlot(i).isEmpty()) {
boolean isItNew = true;
for (ItemStack stack : stacks) {
if (stack.isItemEqual(input.getStackInSlot(i))) {
isItNew = false;
break;
}
}
if (isItNew) stacks.add(input.getStackInSlot(i));
}
}
return stacks.size();
}
示例8: canSmelt
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't full, etc.
*/
private boolean canSmelt()
{
if (((ItemStack)this.furnaceItemStacks.get(0)).func_190926_b())
{
return false;
}
else
{
ItemStack itemstack = FurnaceRecipes.instance().getSmeltingResult((ItemStack)this.furnaceItemStacks.get(0));
if (itemstack.func_190926_b())
{
return false;
}
else
{
ItemStack itemstack1 = (ItemStack)this.furnaceItemStacks.get(2);
return itemstack1.func_190926_b() ? true : (!itemstack1.isItemEqual(itemstack) ? false : (itemstack1.func_190916_E() < this.getInventoryStackLimit() && itemstack1.func_190916_E() < itemstack1.getMaxStackSize() ? true : itemstack1.func_190916_E() < itemstack.getMaxStackSize()));
}
}
}
示例9: isSameStackForFuel
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean isSameStackForFuel(ItemStack fuel, ItemStack stack)
{
boolean itemEqual = stack.getMetadata() == OreDictionary.WILDCARD_VALUE
? fuel.isItemEqualIgnoreDurability(stack)
: fuel.isItemEqual(stack);
boolean nbtEqual = !stack.hasTagCompound() || ItemStack.areItemStackTagsEqual(stack, fuel);
return itemEqual && nbtEqual;
}
示例10: hasItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Returns true if the specified ItemStack exists in the inventory.
*/
public boolean hasItemStack(ItemStack itemStackIn)
{
label19:
for (List<ItemStack> list : this.allInventories)
{
Iterator iterator = list.iterator();
while (true)
{
if (!iterator.hasNext())
{
continue label19;
}
ItemStack itemstack = (ItemStack)iterator.next();
if (!itemstack.func_190926_b() && itemstack.isItemEqual(itemStackIn))
{
break;
}
}
return true;
}
return false;
}
示例11: isValidRecipe
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean isValidRecipe(FluidStack fluidStack, @Nonnull ItemStack inputItem) {
if (inputLiquid != null) {
if (fluidStack == null) return false;
if (!Fluids.areFluidsEqual(fluidStack.getFluid(), inputLiquid.getFluid())) return false;
if (fluidStack.amount < inputLiquid.amount) return false;
}
if (!this.inputItem.isEmpty()) {
if (inputItem.isEmpty()) return false;
if (!inputItem.isItemEqual(this.inputItem) && !PneumaticCraftUtils.isSameOreDictStack(inputItem, this.inputItem))
return false;
if (inputItem.getCount() < this.inputItem.getCount()) return false;
}
return true;
}
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:16,代码来源:BasicThermopneumaticProcessingPlantRecipe.java
示例12: canItemStacksStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean canItemStacksStack(ItemStack a, ItemStack b)
{
if (a == null || !a.isItemEqual(b))
return false;
return ItemStack.areItemStackTagsEqual(a, b);
}
示例13: smeltItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Turn one item from the furnace source stack into the appropriate smelted item in the furnace result stack
*/
private void smeltItem(int id)
{
if (this.canSmelt(id))
{
int inputIndex = type.getFirstInputSlot(id);
int outputIndex = type.getFirstOutputSlot(id);
ItemStack input = itemHandler.getStackInSlot(inputIndex);
ItemStack output = itemHandler.getStackInSlot(outputIndex);
ItemStack result = FurnaceRecipes.instance().getSmeltingResult(input);
if (output.isEmpty())
{
itemHandler.setStackInSlot(outputIndex, result.copy());
} else if (output.isItemEqual(result))
{
output.grow(result.getCount());
}
if (input.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && input.getMetadata() == 1)
{
fillBucketInFuelSlots();
}
input.shrink(1);
if (input.isEmpty())
{
itemHandler.setStackInSlot(inputIndex, ItemStack.EMPTY);
}
}
}
示例14: doesItemMatchFilter
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
boolean doesItemMatchFilter(ItemStack itemStack) {
if (itemStack.isEmpty()) return true;
switch (filterMode) {
case ITEM:
boolean filterEmpty = true;
for (int i = 0; i < 9; i++) {
ItemStack filterStack = getStackInSlot(i);
if (!filterStack.isEmpty()) {
filterEmpty = false;
if (itemStack.isItemEqual(filterStack)) {
return true;
}
}
}
return filterEmpty;
case CREATIVE_TAB:
try {
int itemCreativeTabIndex = itemStack.getItem().getCreativeTab() != null ? itemStack.getItem().getCreativeTab().getTabIndex() : -1;
if (itemCreativeTabIndex == creativeTabID) {
return true;
}
} catch (Throwable e) {
//when we are SMP getCreativeTab() is client only.
filterMode = EnumFilterMode.NAME_BEGINS;
}
return false;
case NAME_BEGINS:
return itemStack.getDisplayName().toLowerCase().startsWith(itemNameFilter.toLowerCase());
case NAME_CONTAINS:
return itemStack.getDisplayName().toLowerCase().contains(itemNameFilter.toLowerCase());
}
return false;
}
示例15: setInventorySlotContents
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void setInventorySlotContents(int index, ItemStack stack) {
final boolean flag = !stack.isEmpty() && stack.isItemEqual(itemStacks.get(index)) && ItemStack.areItemStackTagsEqual(stack, itemStacks.get(index));
itemStacks.set(index, stack);
if (!stack.isEmpty() && stack.getCount() > this.getInventoryStackLimit()) {
stack.setCount(getInventoryStackLimit());
}
if (index == 0 && !flag) {
this.markDirty();
}
}