本文整理汇总了Java中net.minecraft.item.ItemStack.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getMetadata方法的具体用法?Java ItemStack.getMetadata怎么用?Java ItemStack.getMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getMetadata方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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
*/
public void smeltItem()
{
if (this.canSmelt())
{
ItemStack itemstack = (ItemStack)this.furnaceItemStacks.get(0);
ItemStack itemstack1 = FurnaceRecipes.instance().getSmeltingResult(itemstack);
ItemStack itemstack2 = (ItemStack)this.furnaceItemStacks.get(2);
if (itemstack2.func_190926_b())
{
this.furnaceItemStacks.set(2, itemstack1.copy());
}
else if (itemstack2.getItem() == itemstack1.getItem())
{
itemstack2.func_190917_f(1);
}
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && itemstack.getMetadata() == 1 && !((ItemStack)this.furnaceItemStacks.get(1)).func_190926_b() && ((ItemStack)this.furnaceItemStacks.get(1)).getItem() == Items.BUCKET)
{
this.furnaceItemStacks.set(1, new ItemStack(Items.WATER_BUCKET));
}
itemstack.func_190918_g(1);
}
}
示例2: matches
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
boolean key = false;
ItemStack crate = ItemStack.EMPTY;
for (int x = 0; x < inv.getSizeInventory(); x++) {
ItemStack stack = inv.getStackInSlot(x);
if (!stack.isEmpty())
if (stack.getItem() == TF2weapons.itemTF2 && stack.getMetadata() == 7) {
if (!key)
key = true;
else
return false;
} else if (crate.isEmpty() && stack.getItem() instanceof ItemCrate)
crate = stack;
else
return false;
}
// System.out.println("matches "+(australium&&stack2!=null));
return key && crate != null;
}
示例3: getUnlocalizedName
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public String getUnlocalizedName(ItemStack stack) {
if (stack.getMetadata() == 1)
return this.getUnlocalizedName()+"_blank";
else
return this.getUnlocalizedName();
}
示例4: isHittingPosition
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private boolean isHittingPosition(BlockPos pos)
{
ItemStack itemstack = this.mc.player.getHeldItemMainhand();
boolean flag = this.currentItemHittingBlock.func_190926_b() && itemstack.func_190926_b();
if (!this.currentItemHittingBlock.func_190926_b() && !itemstack.func_190926_b())
{
flag = itemstack.getItem() == this.currentItemHittingBlock.getItem() && ItemStack.areItemStackTagsEqual(itemstack, this.currentItemHittingBlock) && (itemstack.isItemStackDamageable() || itemstack.getMetadata() == this.currentItemHittingBlock.getMetadata());
}
return pos.equals(this.currentBlock) && flag;
}
示例5: matches
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting inv, World worldIn)
{
List<ItemStack> list = Lists.newArrayList(this.recipeItems);
for (int i = 0; i < inv.getHeight(); ++i)
{
for (int j = 0; j < inv.getWidth(); ++j)
{
ItemStack itemstack = inv.getStackInRowAndColumn(j, i);
if (itemstack != null)
{
boolean flag = false;
for (ItemStack itemstack1 : list)
{
if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getMetadata() == 32767 || itemstack.getMetadata() == itemstack1.getMetadata()))
{
flag = true;
list.remove(itemstack1);
break;
}
}
if (!flag)
{
return false;
}
}
}
}
return list.isEmpty();
}
示例6: getPacket
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public Packet getPacket(ItemStack stack)
{
if (this.field_176105_d)
{
this.field_176105_d = false;
return new S34PacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.mapDecorations.values(), MapData.this.colors, this.minX, this.minY, this.maxX + 1 - this.minX, this.maxY + 1 - this.minY);
}
else
{
return this.field_176109_i++ % 5 == 0 ? new S34PacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.mapDecorations.values(), MapData.this.colors, 0, 0, 0, 0) : null;
}
}
示例7: getRealOredictedItems
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static NonNullList<ItemStack> getRealOredictedItems(String oredit) {
NonNullList<ItemStack> stacks = NonNullList.create();
for (ItemStack ore : OreDictionary.getOres(oredit)) {
if (ore.getMetadata() == OreDictionary.WILDCARD_VALUE && ore.getItem().getCreativeTab() != null)
ore.getItem().getSubItems(ore.getItem().getCreativeTab(), stacks);
else {
stacks.add(ore);
break;
}
}
return stacks;
}
示例8: storeItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* stores an itemstack in the users inventory
*/
private int storeItemStack(ItemStack itemStackIn)
{
for (int i = 0; i < this.mainInventory.length; ++i)
{
if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemStackIn.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].stackSize < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].stackSize < this.getInventoryStackLimit() && (!this.mainInventory[i].getHasSubtypes() || this.mainInventory[i].getMetadata() == itemStackIn.getMetadata()) && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemStackIn))
{
return i;
}
}
return -1;
}
示例9: getTypeInt
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public int getTypeInt(ItemStack stack) {
return stack.getMetadata();
}
示例10: canDispenserPlace
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean canDispenserPlace(World worldIn, BlockPos pos, ItemStack stack)
{
return stack.getMetadata() == 1 && pos.getY() >= 2 && worldIn.getDifficulty() != EnumDifficulty.PEACEFUL && !worldIn.isRemote ? this.getWitherBasePattern().match(worldIn, pos) != null : false;
}
示例11: getBaseColor
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static int getBaseColor(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
return nbttagcompound != null && nbttagcompound.hasKey("Base") ? nbttagcompound.getInteger("Base") : stack.getMetadata();
}
示例12: canCombine
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static boolean canCombine(ItemStack stack1, ItemStack stack2)
{
return stack1.getItem() != stack2.getItem() ? false : (stack1.getMetadata() != stack2.getMetadata() ? false : (stack1.stackSize > stack1.getMaxStackSize() ? false : ItemStack.areItemStackTagsEqual(stack1, stack2)));
}
示例13: checkMatch
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Checks if the region of a crafting inventory is match for the recipe.
*/
private boolean checkMatch(InventoryCrafting p_77573_1_, int p_77573_2_, int p_77573_3_, boolean p_77573_4_)
{
for (int i = 0; i < 3; ++i)
{
for (int j = 0; j < 3; ++j)
{
int k = i - p_77573_2_;
int l = j - p_77573_3_;
ItemStack itemstack = null;
if (k >= 0 && l >= 0 && k < this.recipeWidth && l < this.recipeHeight)
{
if (p_77573_4_)
{
itemstack = this.recipeItems[this.recipeWidth - k - 1 + l * this.recipeWidth];
}
else
{
itemstack = this.recipeItems[k + l * this.recipeWidth];
}
}
ItemStack itemstack1 = p_77573_1_.getStackInRowAndColumn(i, j);
if (itemstack1 != null || itemstack != null)
{
if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
{
return false;
}
if (itemstack.getItem() != itemstack1.getItem())
{
return false;
}
if (itemstack.getMetadata() != 32767 && itemstack.getMetadata() != itemstack1.getMetadata())
{
return false;
}
}
}
}
return true;
}
示例14: processCreativeInventoryAction
import net.minecraft.item.ItemStack; //导入方法依赖的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();
}
}
}
}
示例15: storePartialItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* This function stores as many items of an ItemStack as possible in a matching slot and returns the quantity of
* left over items.
*/
private int storePartialItemStack(ItemStack itemStackIn)
{
Item item = itemStackIn.getItem();
int i = itemStackIn.stackSize;
int j = this.storeItemStack(itemStackIn);
if (j < 0)
{
j = this.getFirstEmptyStack();
}
if (j < 0)
{
return i;
}
else
{
if (this.mainInventory[j] == null)
{
this.mainInventory[j] = new ItemStack(item, 0, itemStackIn.getMetadata());
if (itemStackIn.hasTagCompound())
{
this.mainInventory[j].setTagCompound((NBTTagCompound)itemStackIn.getTagCompound().copy());
}
}
int k = i;
if (i > this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].stackSize)
{
k = this.mainInventory[j].getMaxStackSize() - this.mainInventory[j].stackSize;
}
if (k > this.getInventoryStackLimit() - this.mainInventory[j].stackSize)
{
k = this.getInventoryStackLimit() - this.mainInventory[j].stackSize;
}
if (k == 0)
{
return i;
}
else
{
i = i - k;
this.mainInventory[j].stackSize += k;
this.mainInventory[j].animationsToGo = 5;
return i;
}
}
}