本文整理汇总了Java中net.minecraft.item.ItemStack.getSubCompound方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.getSubCompound方法的具体用法?Java ItemStack.getSubCompound怎么用?Java ItemStack.getSubCompound使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.getSubCompound方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeBannerData
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Removes all the banner related data from a provided instance of ItemStack.
*/
public static void removeBannerData(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);
if (nbttaglist.tagCount() > 0)
{
nbttaglist.removeTag(nbttaglist.tagCount() - 1);
if (nbttaglist.hasNoTags())
{
stack.getTagCompound().removeTag("BlockEntityTag");
if (stack.getTagCompound().hasNoTags())
{
stack.setTagCompound((NBTTagCompound)null);
}
}
}
}
}
示例2: matches
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
int count = 0;
boolean forge = false;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if(!stack.isEmpty()) {
if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof CraftiniumForge) {
if(forge && !this.combining) {
return false;
} else {
forge = true;
if(!stack.hasTagCompound() || stack.getSubCompound("randores") == null || !stack.getSubCompound("randores").hasKey("furnace_speed")) {
return false;
}
}
} else if (this.upgrades.keySet().stream().noneMatch(k -> k.apply(stack))) {
return false;
}
count++;
}
}
return count >= 2 && forge;
}
示例3: removeBannerData
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Removes all the banner related data from a provided instance of ItemStack.
*/
public static void removeBannerData(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag");
if (nbttagcompound != null && nbttagcompound.hasKey("Patterns", 9))
{
NBTTagList nbttaglist = nbttagcompound.getTagList("Patterns", 10);
if (!nbttaglist.hasNoTags())
{
nbttaglist.removeTag(nbttaglist.tagCount() - 1);
if (nbttaglist.hasNoTags())
{
stack.getTagCompound().removeTag("BlockEntityTag");
if (stack.getTagCompound().hasNoTags())
{
stack.setTagCompound((NBTTagCompound)null);
}
}
}
}
}
示例4: hasData
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public static boolean hasData(ItemStack stack) {
if(stack.hasTagCompound()) {
NBTTagCompound randores = stack.getSubCompound("randores");
return randores != null && randores.hasKey("index") && randores.hasKey("idMost") && randores.hasKey("idLeast");
}
return false;
}
示例5: onBlockPlacedBy
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
if (!worldIn.isRemote) {
if (stack.getSubCompound("randores") != null && stack.getSubCompound("randores").hasKey("furnace_speed")) {
int speed = stack.getSubCompound("randores").getInteger("furnace_speed");
TileEntity entity = worldIn.getTileEntity(pos);
if (entity instanceof CraftiniumForgeTileEntity) {
((CraftiniumForgeTileEntity) entity).setDivisor(speed);
}
}
}
}
示例6: getCraftingResult
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public ItemStack getCraftingResult(InventoryCrafting inv)
{
ItemStack itemstack = ItemStack.field_190927_a;
ItemStack itemstack1 = ItemStack.field_190927_a;
for (int i = 0; i < inv.getSizeInventory(); ++i)
{
ItemStack itemstack2 = inv.getStackInSlot(i);
if (!itemstack2.func_190926_b())
{
if (itemstack2.getItem() == Items.BANNER)
{
itemstack = itemstack2;
}
else if (itemstack2.getItem() == Items.SHIELD)
{
itemstack1 = itemstack2.copy();
}
}
}
if (itemstack1.func_190926_b())
{
return itemstack1;
}
else
{
NBTTagCompound nbttagcompound = itemstack.getSubCompound("BlockEntityTag");
NBTTagCompound nbttagcompound1 = nbttagcompound == null ? new NBTTagCompound() : nbttagcompound.copy();
nbttagcompound1.setInteger("Base", itemstack.getMetadata() & 15);
itemstack1.setTagInfo("BlockEntityTag", nbttagcompound1);
return itemstack1;
}
}
示例7: handleStatusUpdate
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void handleStatusUpdate(byte id)
{
if (id == 17 && this.world.isRemote)
{
ItemStack itemstack = (ItemStack)this.dataManager.get(FIREWORK_ITEM);
NBTTagCompound nbttagcompound = itemstack.func_190926_b() ? null : itemstack.getSubCompound("Fireworks");
this.world.makeFireworks(this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, nbttagcompound);
}
super.handleStatusUpdate(id);
}
示例8: 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();
}
示例9: getPatterns
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Retrieves the amount of patterns stored on an ItemStack. If the tag does not exist this value will be 0.
*/
public static int getPatterns(ItemStack stack)
{
NBTTagCompound nbttagcompound = stack.getSubCompound("BlockEntityTag", false);
return nbttagcompound != null && nbttagcompound.hasKey("Patterns") ? nbttagcompound.getTagList("Patterns", 10).tagCount() : 0;
}
示例10: matches
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting inv, World worldIn)
{
ItemStack itemstack = null;
ItemStack itemstack1 = null;
for (int i = 0; i < inv.getSizeInventory(); ++i)
{
ItemStack itemstack2 = inv.getStackInSlot(i);
if (itemstack2 != null)
{
if (itemstack2.getItem() == Items.BANNER)
{
if (itemstack1 != null)
{
return false;
}
itemstack1 = itemstack2;
}
else
{
if (itemstack2.getItem() != Items.SHIELD)
{
return false;
}
if (itemstack != null)
{
return false;
}
if (itemstack2.getSubCompound("BlockEntityTag", false) != null)
{
return false;
}
itemstack = itemstack2;
}
}
}
if (itemstack != null && itemstack1 != null)
{
return true;
}
else
{
return false;
}
}
示例11: renderByItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void renderByItem(ItemStack itemStackIn)
{
if (itemStackIn.getItem() == Items.BANNER)
{
this.banner.setItemValues(itemStackIn);
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.banner, 0.0D, 0.0D, 0.0D, 0.0F);
}
else if (itemStackIn.getItem() == Items.SHIELD)
{
if (itemStackIn.getSubCompound("BlockEntityTag", false) != null)
{
this.banner.setItemValues(itemStackIn);
Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_DESIGNS.getResourceLocation(this.banner.getPatternResourceLocation(), this.banner.getPatternList(), this.banner.getColorList()));
}
else
{
Minecraft.getMinecraft().getTextureManager().bindTexture(BannerTextures.SHIELD_BASE_TEXTURE);
}
GlStateManager.pushMatrix();
GlStateManager.scale(1.0F, -1.0F, -1.0F);
this.modelShield.render();
GlStateManager.popMatrix();
}
else if (itemStackIn.getItem() == Items.SKULL)
{
GameProfile gameprofile = null;
if (itemStackIn.hasTagCompound())
{
NBTTagCompound nbttagcompound = itemStackIn.getTagCompound();
if (nbttagcompound.hasKey("SkullOwner", 10))
{
gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner"));
}
else if (nbttagcompound.hasKey("SkullOwner", 8) && !nbttagcompound.getString("SkullOwner").isEmpty())
{
GameProfile lvt_2_2_ = new GameProfile((UUID)null, nbttagcompound.getString("SkullOwner"));
gameprofile = TileEntitySkull.updateGameprofile(lvt_2_2_);
nbttagcompound.removeTag("SkullOwner");
nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile));
}
}
if (TileEntitySkullRenderer.instance != null)
{
GlStateManager.pushMatrix();
GlStateManager.disableCull();
TileEntitySkullRenderer.instance.renderSkull(0.0F, 0.0F, 0.0F, EnumFacing.UP, 0.0F, itemStackIn.getMetadata(), gameprofile, -1, 0.0F);
GlStateManager.enableCull();
GlStateManager.popMatrix();
}
}
else
{
Block block = Block.getBlockFromItem(itemStackIn.getItem());
if (block == Blocks.ENDER_CHEST)
{
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.enderChest, 0.0D, 0.0D, 0.0D, 0.0F);
}
else if (block == Blocks.TRAPPED_CHEST)
{
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestTrap, 0.0D, 0.0D, 0.0D, 0.0F);
}
else if (block != Blocks.CHEST) net.minecraftforge.client.ForgeHooksClient.renderTileItem(itemStackIn.getItem(), itemStackIn.getMetadata());
else
{
TileEntityRendererDispatcher.instance.renderTileEntityAt(this.chestBasic, 0.0D, 0.0D, 0.0D, 0.0F);
}
}
}
示例12: func_191510_k
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void func_191510_k()
{
float f = 0.0F;
ItemStack itemstack = (ItemStack)this.dataManager.get(FIREWORK_ITEM);
NBTTagCompound nbttagcompound = itemstack.func_190926_b() ? null : itemstack.getSubCompound("Fireworks");
NBTTagList nbttaglist = nbttagcompound != null ? nbttagcompound.getTagList("Explosions", 10) : null;
if (nbttaglist != null && !nbttaglist.hasNoTags())
{
f = (float)(5 + nbttaglist.tagCount() * 2);
}
if (f > 0.0F)
{
if (this.field_191513_e != null)
{
this.field_191513_e.attackEntityFrom(DamageSource.field_191552_t, (float)(5 + nbttaglist.tagCount() * 2));
}
double d0 = 5.0D;
Vec3d vec3d = new Vec3d(this.posX, this.posY, this.posZ);
for (EntityLivingBase entitylivingbase : this.world.getEntitiesWithinAABB(EntityLivingBase.class, this.getEntityBoundingBox().expandXyz(5.0D)))
{
if (entitylivingbase != this.field_191513_e && this.getDistanceSqToEntity(entitylivingbase) <= 25.0D)
{
boolean flag = false;
for (int i = 0; i < 2; ++i)
{
RayTraceResult raytraceresult = this.world.rayTraceBlocks(vec3d, new Vec3d(entitylivingbase.posX, entitylivingbase.posY + (double)entitylivingbase.height * 0.5D * (double)i, entitylivingbase.posZ), false, true, false);
if (raytraceresult == null || raytraceresult.typeOfHit == RayTraceResult.Type.MISS)
{
flag = true;
break;
}
}
if (flag)
{
float f1 = f * (float)Math.sqrt((5.0D - (double)this.getDistanceToEntity(entitylivingbase)) / 5.0D);
entitylivingbase.attackEntityFrom(DamageSource.field_191552_t, f1);
}
}
}
}
}
示例13: matches
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public boolean matches(InventoryCrafting inv, World worldIn)
{
ItemStack itemstack = ItemStack.field_190927_a;
ItemStack itemstack1 = ItemStack.field_190927_a;
for (int i = 0; i < inv.getSizeInventory(); ++i)
{
ItemStack itemstack2 = inv.getStackInSlot(i);
if (!itemstack2.func_190926_b())
{
if (itemstack2.getItem() == Items.BANNER)
{
if (!itemstack1.func_190926_b())
{
return false;
}
itemstack1 = itemstack2;
}
else
{
if (itemstack2.getItem() != Items.SHIELD)
{
return false;
}
if (!itemstack.func_190926_b())
{
return false;
}
if (itemstack2.getSubCompound("BlockEntityTag") != null)
{
return false;
}
itemstack = itemstack2;
}
}
}
if (!itemstack.func_190926_b() && !itemstack1.func_190926_b())
{
return true;
}
else
{
return false;
}
}