net.minecraft.item.ItemStack.setTagCompound()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中net.minecraft.item.ItemStack.setTagCompound()方法的一些代码示例,展示了ItemStack.setTagCompound()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ItemStack.setTagCompound()方法的具体详情如下:
包路径:net.minecraft.item.ItemStack
类名称:ItemStack
方法名:setTagCompound

ItemStack.setTagCompound介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

@Override
public ItemStack getItemStack( final PartItemStack type )
{
  if( type == PartItemStack.NETWORK )
  {
    final ItemStack copy = this.is.copy();
    copy.setTagCompound( null );
    return copy;
  }
  return this.is;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public void setFluidStack( ItemStack is, FluidStack fs )
{
  if( fs == null )
  {
    is.setTagCompound( null );
  }
  else
  {
    NBTTagCompound tag = new NBTTagCompound();
    fs.writeToNBT( tag );
    is.setTagCompound( tag );
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public static NBTTagCompound openNbtData( final ItemStack i )
{
  NBTTagCompound compound = i.getTagCompound();
  if( compound == null )
  {
    i.setTagCompound( compound = new NBTTagCompound() );
  }
  return compound;
}

代码示例来源:origin: Vazkii/Botania

/** Gets the NBTTagCompound in an ItemStack. Tries to init it
 * previously in case there isn't one present **/
public static NBTTagCompound getNBT(ItemStack stack) {
  if(!stack.hasTagCompound())
    stack.setTagCompound(new NBTTagCompound());
  return stack.getTagCompound();
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

private void clearCard( final EntityPlayer player, final World w, final EnumHand hand )
  {
    final IMemoryCard mem = (IMemoryCard) player.getHeldItem( hand ).getItem();
    mem.notifyUser( player, MemoryCardMessages.SETTINGS_CLEARED );
    player.getHeldItem( hand ).setTagCompound( null );
  }
}

代码示例来源:origin: Vazkii/Botania

public void populateDropStackNBTs(List<ItemStack> drops) {
  if(isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) {
    ItemStack drop = drops.get(0);
    if(!drop.isEmpty()) {
      if(!drop.hasTagCompound())
        drop.setTagCompound(new NBTTagCompound());
      NBTTagCompound cmp = drop.getTagCompound();
      cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks);
    }
  }
}

代码示例来源:origin: Vazkii/Botania

@Nonnull
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float xOffset, float yOffset, float zOffset) {
  ItemStack itemstack = player.getHeldItem(hand);
  if(getEntityId(itemstack) == null) {
    if(world.getBlockState(pos).getBlock() == Blocks.MOB_SPAWNER) {
      if(!world.isRemote) {
        TileEntity te = world.getTileEntity(pos);
        NBTTagCompound tag = new NBTTagCompound();
        tag.setTag(TAG_SPAWNER, new NBTTagCompound());
        te.writeToNBT(tag.getCompoundTag(TAG_SPAWNER));
        player.getCooldownTracker().setCooldown(this, 20);
        itemstack.setTagCompound(tag);
        world.setBlockToAir(pos);
        UseItemSuccessTrigger.INSTANCE.trigger((EntityPlayerMP) player, itemstack, (WorldServer) world, pos.getX(), pos.getY(), pos.getZ());
        player.renderBrokenItemStack(itemstack);
      } else {
        for(int i = 0; i < 50; i++) {
          float red = (float) Math.random();
          float green = (float) Math.random();
          float blue = (float) Math.random();
          Botania.proxy.wispFX(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, red, green, blue, (float) Math.random() * 0.1F + 0.05F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F, (float) (Math.random() - 0.5F) * 0.15F);
        }
      }
      return EnumActionResult.SUCCESS;
    } else return EnumActionResult.PASS;
  } else {
    return placeBlock(itemstack, player, world, pos, side, xOffset, yOffset, zOffset) ? EnumActionResult.SUCCESS : EnumActionResult.PASS;
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

newDef.setTagCompound( tag );
newDef.setTagCompound( LOW_TAG );

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public ItemStack createFromIDs( final int[] ids )
{
  ItemStack facadeStack = AEApi.instance()
      .definitions()
      .items()
      .facade()
      .maybeStack( 1 )
      .orElseThrow( () -> new MissingDefinitionException( "Tried to create a facade, while facades are being deactivated." ) );
  // Convert back to a registry name...
  Item item = Item.REGISTRY.getObjectById( ids[0] );
  if( item == null )
  {
    return ItemStack.EMPTY;
  }
  final NBTTagCompound facadeTag = new NBTTagCompound();
  facadeTag.setString( TAG_ITEM_ID, item.getRegistryName().toString() );
  facadeTag.setInteger( TAG_DAMAGE, ids[1] );
  facadeStack.setTagCompound( facadeTag );
  return facadeStack;
}

代码示例来源:origin: Vazkii/Botania

@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
  if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(TAG_ITEMS)) {
    NBTTagList oldData = stack.getTagCompound().getTagList(TAG_ITEMS, Constants.NBT.TAG_COMPOUND);
    IItemHandler newInv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(newInv, null, oldData);
    stack.getTagCompound().removeTag(TAG_ITEMS);
    if(stack.getTagCompound().getSize() == 0)
      stack.setTagCompound(null);
  }
}

代码示例来源:origin: Vazkii/Botania

@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean selected) {
  if(stack.getTagCompound() != null && stack.getTagCompound().hasKey(TAG_ITEMS)) {
    NBTTagList oldData = stack.getTagCompound().getTagList(TAG_ITEMS, Constants.NBT.TAG_COMPOUND);
    IItemHandler newInv = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(newInv, null, oldData);
    stack.getTagCompound().removeTag(TAG_ITEMS);
    if(stack.getTagCompound().getSize() == 0)
      stack.setTagCompound(null);
  }
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

newDef.setTagCompound( tag );
newDef.setTagCompound( HIGH_TAG );

代码示例来源:origin: SleepyTrousers/EnderIO

public @Nonnull ItemStack toStack(@Nonnull Block block, int meta, int amount) {
 ItemStack stack = new ItemStack(block, amount, meta);
 stack.setTagCompound(toNbt(null));
 return stack;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

encodedValue.setBoolean( "substitute", this.isSubstitute() );
output.setTagCompound( encodedValue );

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

if( tag != null )
  ol.setTagCompound( tag );

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

is.setTagCompound( null );

代码示例来源:origin: SleepyTrousers/EnderIO

@SuppressWarnings("null")
public @Nonnull ItemStack setBoolean(@Nonnull ItemStack stack, boolean value) {
 if (Prep.isValid(stack)) {
  if (!stack.hasTagCompound()) {
   stack.setTagCompound(new NBTTagCompound());
  }
  stack.getTagCompound().setBoolean(key, value);
 }
 return stack;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

data.setString( TAG_ITEM_ID, itemStack.getItem().getRegistryName().toString() );
data.setInteger( TAG_DAMAGE, itemStack.getItemDamage() );
is.setTagCompound( data );
return is;

代码示例来源:origin: SleepyTrousers/EnderIO

@SuppressWarnings("null")
public @Nonnull ItemStack setString(@Nonnull ItemStack stack, String value) {
 if (Prep.isValid(stack) && value != null) {
  if (!stack.hasTagCompound()) {
   stack.setTagCompound(new NBTTagCompound());
  }
  stack.getTagCompound().setString(key, value);
 } else {
  removeTag(stack);
 }
 return stack;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

tag.setInteger( "side", side.ordinal() );
tag.setInteger( "dimid", world.provider.getDimension() );
player.getHeldItem( hand ).setTagCompound( tag );

相关文章

微信公众号

最新文章

更多

ItemStack类方法