本文整理汇总了Java中net.minecraft.item.ItemStack.getHasSubtypes方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getHasSubtypes方法的具体用法?Java ItemStack.getHasSubtypes怎么用?Java ItemStack.getHasSubtypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getHasSubtypes方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canItemStacksStackRelaxed
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* A relaxed version of canItemStacksStack that stacks itemstacks with different metadata if they don't have subtypes.
* This usually only applies when players pick up items.
*/
public static boolean canItemStacksStackRelaxed(ItemStack a, ItemStack b)
{
if (a == null || b == null || a.getItem() != b.getItem())
return false;
if (!a.isStackable())
return false;
// Metadata value only matters when the item has subtypes
// Vanilla stacks non-subtype items with different metadata together
// e.g. a stick with metadata 0 and a stick with metadata 1 stack
if (a.getHasSubtypes() && a.getMetadata() != b.getMetadata())
return false;
return ItemStack.areItemStackTagsEqual(a, b);
}
示例2: updateItemUse
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Plays sounds and makes particles for item in use state
*/
protected void updateItemUse(ItemStack itemStackIn, int p_71010_2_)
{
if (itemStackIn.getItemUseAction() == EnumAction.DRINK)
{
this.playSound("random.drink", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (itemStackIn.getItemUseAction() == EnumAction.EAT)
{
for (int i = 0; i < p_71010_2_; ++i)
{
Vec3 vec3 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3 = vec3.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
vec3 = vec3.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
Vec3 vec31 = new Vec3(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec31 = vec31.rotatePitch(-this.rotationPitch * (float)Math.PI / 180.0F);
vec31 = vec31.rotateYaw(-this.rotationYaw * (float)Math.PI / 180.0F);
vec31 = vec31.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
if (itemStackIn.getHasSubtypes())
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, new int[] {Item.getIdFromItem(itemStackIn.getItem()), itemStackIn.getMetadata()});
}
else
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec31.xCoord, vec31.yCoord, vec31.zCoord, vec3.xCoord, vec3.yCoord + 0.05D, vec3.zCoord, new int[] {Item.getIdFromItem(itemStackIn.getItem())});
}
}
this.playSound("random.eat", 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
}
}
示例3: combineSlots
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
static void combineSlots(EntityPlayerMP player, int dst, int add)
{
InventoryPlayer inv = player.inventory;
ItemStack dstStack = inv.getStackInSlot(dst);
ItemStack addStack = inv.getStackInSlot(add);
if (addStack == null)
return; // Combination is a no-op.
if (dstStack == null) // Do a straight move - nothing to combine with.
{
inv.setInventorySlotContents(dst, addStack);
inv.setInventorySlotContents(add, null);
return;
}
// Check we can combine. This logic comes from InventoryPlayer.storeItemStack():
boolean itemsMatch = dstStack.getItem() == addStack.getItem();
boolean dstCanStack = dstStack.isStackable() && dstStack.stackSize < dstStack.getMaxStackSize() && dstStack.stackSize < inv.getInventoryStackLimit();
boolean subTypesMatch = !dstStack.getHasSubtypes() || dstStack.getMetadata() == addStack.getMetadata();
boolean tagsMatch = ItemStack.areItemStackTagsEqual(dstStack, addStack);
if (itemsMatch && dstCanStack && subTypesMatch && tagsMatch)
{
// We can combine, so figure out how much we have room for:
int limit = Math.min(dstStack.getMaxStackSize(), inv.getInventoryStackLimit());
int room = limit - dstStack.stackSize;
if (addStack.stackSize > room)
{
// Not room for all of it, so shift across as much as possible.
addStack.stackSize -= room;
dstStack.stackSize += room;
}
else
{
// Room for the whole lot, so empty out the add slot.
dstStack.stackSize += addStack.stackSize;
inv.setInventorySlotContents(add, null);
}
}
}
示例4: isItemEqual
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean isItemEqual(final ItemStack a, final ItemStack b) {
if (a == ItemStack.EMPTY || b == ItemStack.EMPTY)
return false;
if (a.getItem() != b.getItem())
return false;
if (!ItemStack.areItemStackTagsEqual(a, b))
return false;
if (a.getHasSubtypes()) {
if (a.getItemDamage() != b.getItemDamage())
return false;
}
return true;
}
示例5: updateItemUse
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Plays sounds and makes particles for item in use state
*/
protected void updateItemUse(ItemStack stack, int eatingParticleCount)
{
if (!stack.func_190926_b() && this.isHandActive())
{
if (stack.getItemUseAction() == EnumAction.DRINK)
{
this.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5F, this.world.rand.nextFloat() * 0.1F + 0.9F);
}
if (stack.getItemUseAction() == EnumAction.EAT)
{
for (int i = 0; i < eatingParticleCount; ++i)
{
Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F);
double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F);
vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
if (stack.getHasSubtypes())
{
this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem()), stack.getMetadata()});
}
else
{
this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())});
}
}
this.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
}
}
}
示例6: updateItemUse
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Plays sounds and makes particles for item in use state
*/
protected void updateItemUse(@Nullable ItemStack stack, int eatingParticleCount)
{
if (stack != null && this.isHandActive())
{
if (stack.getItemUseAction() == EnumAction.DRINK)
{
this.playSound(SoundEvents.ENTITY_GENERIC_DRINK, 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F);
}
if (stack.getItemUseAction() == EnumAction.EAT)
{
for (int i = 0; i < eatingParticleCount; ++i)
{
Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F);
double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D;
Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F);
vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F);
vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ);
if (stack.getHasSubtypes())
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem()), stack.getMetadata()});
}
else
{
this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())});
}
}
this.playSound(SoundEvents.ENTITY_GENERIC_EAT, 0.5F + 0.5F * (float)this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
}
}
}
示例7: isItemStackConsideredEqual
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean isItemStackConsideredEqual(ItemStack result, ItemStack itemstack1) {
return ItemStackTools.isValid(itemstack1) && itemstack1.getItem() == result.getItem() && (!result.getHasSubtypes() || result.getItemDamage() == itemstack1.getItemDamage()) && ItemStack.areItemStackTagsEqual(result, itemstack1);
}
示例8: getDrawItemFromItemStack
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/** Attempt to break the item on this itemstack into a type/variant/colour which we can use for communication with the Malmo platform.
* @param is the ItemStack containing the item we are attempting to deconstruct.
* @return an XML DrawItem object containing the item's type, variant, colour etc.
*/
public static DrawItem getDrawItemFromItemStack(ItemStack is)
{
if (is == null)
return null;
DrawItem di = new DrawItem();
String name = is.getUnlocalizedName(); // Get unlocalised name from the stack, not the stack's item - this ensures we keep the metadata.
if (is.getHasSubtypes())
{
// If the item has subtypes, then there are varieties - eg different colours, types, etc.
// Attempt to map from these subtypes back to variant/colour.
// Do this by decomposing the unlocalised name:
List<String> itemParts = new ArrayList<String>(Arrays.asList(name.split("\\.")));
if (is.getItem() instanceof ItemMonsterPlacer)
{
// Special case for eggs:
itemParts.add(ItemMonsterPlacer.getEntityName(is));
}
// First part will be "tile" or "item".
// Second part will be the item itself (eg "dyePowder" or "stainedGlass" etc).
// Third part will be the variant, colour etc.
Colour col = null;
Variation var = null;
for (int part = 2; part < itemParts.size(); part++)
{
String section = itemParts.get(part);
// First see if this matches a colour:
if (col == null)
{
col = attemptToGetAsColour(section);
if (col == null && var == null) // If it wasn't a colour, check to see if it was a variant:
var = attemptToGetAsVariant(section, is);
}
else if (var == null)
var = attemptToGetAsVariant(section, is);
}
di.setColour(col);
di.setVariant(var);
}
// Use the item registry name for the item - this is what we use in Types.XSD
Object obj = Item.itemRegistry.getNameForObject(is.getItem());
String publicName;
if (obj instanceof ResourceLocation)
publicName = ((ResourceLocation)obj).getResourcePath();
else
publicName = obj.toString();
di.setType(publicName);
return di;
}
示例9: stackEqualExact
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Checks item, NBT, and meta if the item is not damageable
*/
private boolean stackEqualExact(ItemStack stack1, ItemStack stack2)
{
return stack1.getItem() == stack2.getItem() && (!stack1.getHasSubtypes() || stack1.getMetadata() == stack2.getMetadata()) && ItemStack.areItemStackTagsEqual(stack1, stack2);
}
示例10: areItemStacksEqual
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private static boolean areItemStacksEqual(ItemStack stackA, ItemStack stackB)
{
return stackB.getItem() == stackA.getItem() && (!stackA.getHasSubtypes() || stackA.getMetadata() == stackB.getMetadata()) && ItemStack.areItemStackTagsEqual(stackA, stackB);
}