private void writeTag(BufferedWriter out, NBTTagCompound tag) throws IOException { String line = JSON_PREFIX + tag.toString(); out.write(line); out.newLine(); }
private void loadData() { NBTTagCompound tag = this.settings.getCustomTag(); if (tag != null) { String[] splits = tag.toString().split("}"); for (String t : splits) { tagInput.add(t + "}"); } showAddTagButton = false; } }
@Override public int hashCode() { return oreID != -1 ? oreName.hashCode() : tag != null ? 17 + tag.toString().hashCode() * 31 + (metadata & 65535) + (getId() << 16) : (metadata & 65535) | getId() << 16; }
@Override public String apply(ItemStack itemStack) { NBTTagCompound nbtTagCompound = itemStack.getTagCompound(); if (nbtTagCompound == null || nbtTagCompound.isEmpty()) { return ISubtypeInterpreter.NONE; } return nbtTagCompound.toString(); } }
@Override public String serialize(P values) throws IValueTypeListProxyFactoryTypeRegistry.SerializationException { NBTTagCompound tag = new NBTTagCompound(); values.writeGeneratedFieldsToNBT(tag); return tag.toString(); }
private static void reviewInventory(TileWarehouse warehouse, Map<ItemStack, Integer> debugData) { HashMap<ItemStack, Integer> copy = new HashMap<>(debugData); for (Map.Entry<ItemQuantityMap.ItemHashEntry, Integer> entry : warehouse.cachedItemMap.getItemCounts().entrySet()) { reviewStackCount(warehouse.getPos(), debugData, copy, entry); } for (Map.Entry<ItemStack, Integer> entry : copy.entrySet()) { AncientWarfareAutomation.LOG.info("Warehouse {} misses {} of {} that is in debugData", warehouse.getPos(), entry.getValue(), entry.getKey().writeToNBT(new NBTTagCompound()).toString()); debugData.remove(entry.getKey()); } }
@Override public String serialize(ValueFluidStack value) { NBTTagCompound tag = new NBTTagCompound(); Optional<FluidStack> fluidStack = value.getRawValue(); if(fluidStack.isPresent()) fluidStack.get().writeToNBT(tag); return tag.toString(); }
@Override public String serialize(ValueIngredients value) { if(!value.getRawValue().isPresent()) return ""; return IMixedIngredients.serialize(value.getRawValue().get()).toString(); }
@Override public String serialize(ValueRecipe value) { if(!value.getRawValue().isPresent()) return ""; return IRecipeDefinition.serialize(value.getRawValue().get()).toString(); }
@Override public String serialize(ValueNbt value) { return isNull(value) ? "{}" : value.getRawValue().toString(); }
@Override public ITextComponent processStack(ItemStack stack) { return new TextComponentString((stack.getTagCompound() != null) ? stack.getTagCompound().toString() : null); } }, OreDict("oreNames", "oreName", "ores", "ore") {
@Override protected FixResult<String> fixData(String ruleName, String data) { if (!Json.isSerializedJSON(data)) { return new FixResult.NotModified<>(data); } NBTTagCompound tag = JsonTagReader.parseTagCompound(data); return new FixResult.Modified<>(TemplateRule.JSON_PREFIX + tag.toString(), "JsonSimplificationFixer"); } }
/** * Add a tooltip that also displays an itemStack on the tooltip directly. */ public void add(ItemStack itemStack, String string) { NBTTagCompound nbt = new NBTTagCompound(); itemStack.writeToNBT(nbt); nbt.setByte(NBT_TYPE_KEY, TYPE_ITEM); this.add(NBT_SEPARATOR + nbt.toString() + NBT_SEPARATOR + string); }
/** * Add a tooltip that also displays an fluidStack on the tooltip directly. */ public void add(FluidStack fluidStack, String string) { NBTTagCompound nbt = new NBTTagCompound(); fluidStack.writeToNBT(nbt); nbt.setByte(NBT_TYPE_KEY, TYPE_FLUID); this.add(NBT_SEPARATOR + nbt.toString() + NBT_SEPARATOR + string); }
@Inject(method = "addInfoToCrashReport", at = @At("TAIL")) private void onAddEntityCrashInfo(CrashReportCategory category, CallbackInfo ci) { if (!noNBT) { noNBT = true; // "Block Entity" to stay consistent with vanilla strings category.addDetail("Block Entity NBT", () -> ((TileEntity) (Object) this).writeToNBT(new NBTTagCompound()).toString()); noNBT = false; } } }
@Override public void registerItemSubtypes(@Nonnull ISubtypeRegistry subtypeRegistry) { subtypeRegistry.useNbtForSubtypes(AWNPCItems.NPC_SPAWNER); subtypeRegistry.useNbtForSubtypes(Item.getItemFromBlock(AWStructureBlocks.FIRE_PIT)); subtypeRegistry.useNbtForSubtypes(AWNPCItems.COIN); subtypeRegistry.useNbtForSubtypes(AWStructureItems.TOTEM_PART); //noinspection ConstantConditions subtypeRegistry.registerSubtypeInterpreter(AWVehicleItems.SPAWNER, itemStack -> Integer.toString(itemStack.getMetadata()) + ":" + (itemStack.hasTagCompound() ? itemStack.getTagCompound().toString() : "")); }
@Override public String serialize(ValueItemStack value) { NBTTagCompound tag = new NBTTagCompound(); ItemStack itemStack = value.getRawValue(); if(!itemStack.isEmpty()) { itemStack.writeToNBT(tag); tag.setInteger("Count", itemStack.getCount()); } return tag.toString(); }
@Override public String serialize(CombinedOperator operator) { OperatorsFunction function = (OperatorsFunction) operator.getFunction(); IOperator[] operators = function.getOperators(); NBTTagCompound tag = new NBTTagCompound(); NBTTagList list = new NBTTagList(); for (IOperator functionOperator : operators) { list.appendTag(new NBTTagString(Operators.REGISTRY.serialize(functionOperator))); } tag.setTag("operators", list); return tag.toString(); }
private void printSimpleMessage(EntityPlayer player, ItemStack stack) { //noinspection ConstantConditions player.sendMessage(new TextComponentString("Item name: " + stack.getItem().getRegistryName().toString())); player.sendMessage(new TextComponentString("Meta: " + stack.getMetadata())); if (stack.hasTagCompound()) { //noinspection ConstantConditions player.sendMessage(new TextComponentString("NBT: " + stack.getTagCompound().toString())); } }
private void requestItem(ItemStack stack, int amount) { sendServerCommand(RFToolsCtrlMessages.INSTANCE, CraftingStationTileEntity.CMD_REQUEST, TypedMap.builder() .put(PARAM_ITEMNAME, stack.getItem().getRegistryName().toString()) .put(PARAM_META, stack.getItemDamage()) .put(PARAM_NBT, stack.hasTagCompound() ? stack.serializeNBT().toString() : "") .put(PARAM_AMOUNT, amount) .build()); }