@Nullable @Override public Entity createEntity(Location location, BaseEntity entity) { World world = getWorld(); net.minecraft.entity.Entity createdEntity = EntityList.createEntityByIDFromName(new ResourceLocation(entity.getType().getId()), world); if (createdEntity != null) { CompoundTag nativeTag = entity.getNbtData(); if (nativeTag != null) { NBTTagCompound tag = NBTConverter.toNative(entity.getNbtData()); for (String name : Constants.NO_COPY_ENTITY_NBT_FIELDS) { tag.removeTag(name); } createdEntity.readFromNBT(tag); } createdEntity.setLocationAndAngles(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); world.spawnEntity(createdEntity); return new ForgeEntity(createdEntity); } else { return null; } }
public static void removeEntry(ItemStack stack, String tag) { getNBT(stack).removeTag(tag); }
@Override public void removePermission( final ItemStack itemStack, final SecurityPermissions permission ) { final NBTTagCompound tag = Platform.openNbtData( itemStack ); if( tag.hasKey( permission.name() ) ) { tag.removeTag( permission.name() ); } }
@Override public void setProfile( final ItemStack itemStack, final GameProfile profile ) { final NBTTagCompound tag = Platform.openNbtData( itemStack ); if( profile != null ) { final NBTTagCompound pNBT = new NBTTagCompound(); NBTUtil.writeGameProfile( pNBT, profile ); tag.setTag( "profile", pNBT ); } else { tag.removeTag( "profile" ); } }
private void setColor( final ItemStack is, final ItemStack newColor ) { final NBTTagCompound data = Platform.openNbtData( is ); if( newColor.isEmpty() ) { data.removeTag( "color" ); } else { final NBTTagCompound color = new NBTTagCompound(); newColor.writeToNBT( color ); data.setTag( "color", color ); } }
@Nonnull @Override public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) { ItemStack stackToDisenchant = ItemStack.EMPTY; for(int i = 0; i < var1.getSizeInventory(); i++) { ItemStack stack = var1.getStackInSlot(i); if(!stack.isEmpty() && stack.isItemEnchanted()) { stackToDisenchant = stack.copy(); stackToDisenchant.setCount(1); break; } } if(stackToDisenchant.isEmpty()) return ItemStack.EMPTY; stackToDisenchant.getTagCompound().removeTag("ench"); // Remove enchantments return stackToDisenchant; }
@Override public void onEquipped(ItemStack stack, EntityLivingBase player) { super.onEquipped(stack, player); if(stack.getItemDamage() != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName(), SUPER_AWESOME_HASH)) { stack.setItemDamage(WING_TYPES); stack.getTagCompound().removeTag("display"); } }
@Override public void saveToNBT( final String name, final NBTTagCompound nodeData ) { if( this.myStorage != null ) { final NBTTagCompound node = new NBTTagCompound(); node.setInteger( "p", this.playerID ); node.setLong( "k", this.getLastSecurityKey() ); node.setLong( "g", this.myStorage.getID() ); nodeData.setTag( name, node ); } else { nodeData.removeTag( name ); } }
@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); } }
@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); } }
@Override public void writeToNBT( final NBTTagCompound data ) { data.setString( "FluidName", this.fluid.getName() ); data.setByte( "Count", (byte) 0 ); data.setLong( "Cnt", this.getStackSize() ); data.setLong( "Req", this.getCountRequestable() ); data.setBoolean( "Craft", this.isCraftable() ); if( this.hasTagCompound() ) { data.setTag( "Tag", this.tagCompound ); } else { data.removeTag( "Tag" ); } }
public @Nullable NBTTagCompound removeTag(@Nullable NBTTagCompound tag) { if (tag != null && tag.hasKey(key)) { tag.removeTag(key); } return tag; }
display.removeTag( "Name" );
@Override public @Nonnull Pair<ItemStack, Integer> removeFromItem(@Nonnull ItemStack stack, @Nonnull IDarkSteelItem item) { NbtValue.getOrCreateRoot(stack).removeTag(PROBETAG); return super.removeFromItem(stack, item); }
@Override protected void setContainerToEmpty() { if (Config.nonConsumableCapsules) { //default behaviour of FluidHandlerItemStack container.getTagCompound().removeTag(FLUID_NBT_KEY); } else { super.setContainerToEmpty(); } } }
@SuppressWarnings("null") public @Nonnull ItemStack removeTag(@Nonnull ItemStack stack) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey(key)) { stack.getTagCompound().removeTag(key); } return stack; }
public static void setTopActive(EntityPlayer player, boolean active) { ItemStack helmet = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (active) { ItemUtil.getOrCreateNBT(helmet).setInteger(TheOneProbeUpgrade.PROBETAG, 1); } else { ItemUtil.getOrCreateNBT(helmet).removeTag(TheOneProbeUpgrade.PROBETAG); } }
public static void setFluidIcon(ItemStack stack, @Nullable FluidStack icon) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } if (icon == null) { stack.getTagCompound().removeTag(NBT_FLUID_ICON); } else { stack.getTagCompound().setTag(NBT_FLUID_ICON, icon.writeToNBT(new NBTTagCompound())); } }