@Override public void writePacketNBT(NBTTagCompound par1NBTTagCompound) { par1NBTTagCompound.merge(itemHandler.serializeNBT()); }
@Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.merge(nbtInfo); return nbt; }
private boolean compareStacks(ItemStack recipe, ItemStack supplied) { if(recipe.getItem() == supplied.getItem() && recipe.getItemDamage() == supplied.getItemDamage()) { //check that the user supplied nbt tag is a superset of the recipe item nbt tag //if the recipe doesn't have an NBT tag, the user supplied one doesn't matter, it is a superset if(!recipe.hasTagCompound()) return true; //if the recipe does have an NBT tag but the user supplied doesn't, also no way it's a superset if(!supplied.hasTagCompound()) return false; NBTTagCompound mergedNBT = supplied.getTagCompound().copy(); mergedNBT.merge(recipe.getTagCompound()); return supplied.getTagCompound().equals(mergedNBT); } return false; }
public NBTTagCompound writeToJson(NBTTagCompound nbt) { nbt.merge(tags); nbt.setString("uuid", uuid.toString()); // More of a legacy thing but also to enforce the original UUID return nbt; }
@Override public void readFromNBT(NBTTagCompound nbt) { nbtInfo = new NBTTagCompound(); nbtInfo.merge(nbt); }
/** * Create a new NBT tag that contains all entries from the given tags. * If multiple tags contain the same entry, the entry from the latest tag will be given preference. * If nested tags are present, these will be combined recursively. * @param tags NBT tags. * @return A new tag containing the combined entries from the given tags. */ public static NBTTagCompound union(NBTTagCompound... tags) { NBTTagCompound tag = new NBTTagCompound(); for (NBTTagCompound inputTag : tags) { tag.merge(inputTag); } return tag; }
@Nonnull @Override public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt = super.writeToNBT(nbt); nbt.merge(inventory.serializeNBT()); return nbt; }
public void readFromJson(NBTTagCompound nbt) { tags = new NBTTagCompound(); tags.merge(nbt); tags.removeTag("uuid"); // Remove unsafe UUID reference } }
@Nonnull @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { tag = super.writeToNBT(tag); tag.merge(inventory.serializeNBT()); tag.setBoolean("isActive", getActive()); tag.setInteger("activityCooldown", activityCooldown); tag.setBoolean("powered", previousRedstoneState); return tag; }
public static NBTTagCompound EntityToJson(Entity entity, NBTTagCompound json) { if(entity == null) { return json; } NBTTagCompound tags = new NBTTagCompound(); entity.writeToNBTOptional(tags); String id = EntityList.getEntityString(entity); tags.setString("id", id != null ? id : ""); // Some entities don't write this to file in certain cases json.merge(tags); return json; } }
private void setSeat(String seatID, String uuid) { NBTTagCompound comp = new NBTTagCompound(); comp.merge(this.dataManager.get(WATCHER_SEATS)); comp.setString(seatID, uuid); this.dataManager.set(WATCHER_SEATS, comp); if (seatID.equals("0")) { if (this.getControllingPassenger() == null) { if (this.getControlState() != (byte) 0) { this.setControlState((byte) 0); if(this.world.isRemote) JurassiCraft.NETWORK_WRAPPER.sendToServer(new UpdateVehicleControlMessage(this));//asd } } } }
private boolean nbtTagsMatch(ItemStack input) { if (!stack.hasTagCompound()) { return true; } if (!input.hasTagCompound()) { return false; } //noinspection ConstantConditions NBTTagCompound original = input.getTagCompound().copy(); NBTTagCompound merged = original.copy(); //noinspection ConstantConditions merged.merge(stack.getTagCompound()); //if all the NBT values of the ingredient were in the input stack's NBT the merged one will match the one before merge return original.equals(merged); }
public static boolean setMultipartTileNBT(EntityPlayer player, ItemStack stack, IPartInfo info) { World world = info.getActualWorld(); BlockPos pos = info.getPartPos(); MinecraftServer server = world.getMinecraftServer(); if (server == null) { return false; } else { NBTTagCompound tag = stack.getSubCompound("BlockEntityTag"); if (tag != null) { IMultipartTile tile = info.getTile(); if (tile != null) { if (!world.isRemote && tile.onlyOpsCanSetPartNbt() && (player == null || !player.canUseCommandBlock())) { return false; } NBTTagCompound tag1 = tile.writePartToNBT(new NBTTagCompound()); NBTTagCompound tag2 = tag1.copy(); tag1.merge(tag); tag1.setInteger("x", pos.getX()); tag1.setInteger("y", pos.getY()); tag1.setInteger("z", pos.getZ()); if (!tag1.equals(tag2)) { tile.readPartFromNBT(tag1); tile.markPartDirty(); return true; } } } return false; } }