net.minecraft.nbt.NBTTagString Java Examples
The following examples show how to use
net.minecraft.nbt.NBTTagString.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BookBase.java From minecraft-roguelike with GNU General Public License v3.0 | 6 votes |
@Override public ItemStack get(){ ItemStack book = new ItemStack(Items.WRITTEN_BOOK, 1); NBTTagList nbtPages = new NBTTagList(); for(String page : this.pages){ ITextComponent text = new TextComponentString(page); String json = ITextComponent.Serializer.componentToJson(text); NBTTagString nbtPage = new NBTTagString(json); nbtPages.appendTag(nbtPage); } book.setTagInfo("pages", nbtPages); book.setTagInfo("author", new NBTTagString(this.author == null ? "Anonymous" : this.author)); book.setTagInfo("title", new NBTTagString(this.title == null ? "Book" : this.title)); return book; }
Example #2
Source File: GuiPythonBook.java From pycode-minecraft with MIT License | 6 votes |
private void sendBookToServer() throws IOException { if (!this.bookIsModified || this.bookPages == null) { return; } while (this.bookPages.tagCount() > 1) { String s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1); if (!s.trim().isEmpty()) { break; } this.bookPages.removeTag(this.bookPages.tagCount() - 1); } this.bookObj.setTagInfo("pages", this.bookPages); String title = this.bookTitle; if (title.equals(TITLE_PLACEHOLDER)) title = ""; this.bookObj.setTagInfo("title", new NBTTagString(title)); PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer()); packetbuffer.writeItemStackToBuffer(this.bookObj); this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|BEdit", packetbuffer)); }
Example #3
Source File: TileMotor.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); tag.setBoolean("redstoneInput", redstoneInput); tag.setInteger("face", getFace().ordinal()); NBTTagCompound movement = new NBTTagCompound(); getMovement().writeToNBT(movement); tag.setTag("movement", movement); NBTTagList l = new NBTTagList(); for (MotorSetting s : settings) l.appendTag(new NBTTagString(s.ordinal() + "")); tag.setTag("settings", l); tag.setDouble("power", getEnergyBuffer()); }
Example #4
Source File: TileMotor.java From Framez with GNU General Public License v3.0 | 6 votes |
protected void readFromPacketNBT(NBTTagCompound tag) { face = ForgeDirection.getOrientation(tag.getInteger("face")); getMovement().readFromNBT(tag.getCompoundTag("movement")); settings.clear(); NBTTagList l = tag.getTagList("settings", new NBTTagString().getId()); for (int i = 0; i < l.tagCount(); i++) settings.add(MotorSetting.values()[Integer.parseInt(l.getStringTagAt(i))]); blocking = new ArrayList<Vec3i>(); if (tag.hasKey("blocking")) { NBTTagList blocking = tag.getTagList("blocking", new NBTTagCompound().getId()); for (int i = 0; i < blocking.tagCount(); i++) { NBTTagCompound t = blocking.getCompoundTagAt(i); this.blocking.add(new Vec3i(t.getInteger("x"), t.getInteger("y"), t.getInteger("z"))); } } storedPower = tag.getDouble("power"); markForRenderUpdate(); }
Example #5
Source File: PartFrame.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public void save(NBTTagCompound tag) { if (hidden == null) hidden = new boolean[6]; super.save(tag); for (int i = 0; i < 6; i++) { tag.setBoolean("hidden_" + i, hidden[i]); NBTTagList l = new NBTTagList(); for (IFrameSideModifier m : getSideModifiers(ForgeDirection.getOrientation(i))) l.appendTag(new NBTTagString(m.getType())); tag.setTag("sidemods_" + i, l); } }
Example #6
Source File: SpellUtils.java From Wizardry with GNU Lesser General Public License v3.0 | 6 votes |
public static List<List<ModuleInstance>> deserializeModuleList(@Nonnull NBTTagList list) { List<List<ModuleInstance>> modules = new ArrayList<>(); List<ModuleInstance> moduleList = new ArrayList<>(); for (int i = 0; i < list.tagCount(); i++) { NBTBase base = list.get(i); if (!(base instanceof NBTTagString)) continue; NBTTagString string = (NBTTagString) base; if (string.isEmpty()) { if (!moduleList.isEmpty()) modules.add(moduleList); moduleList = new ArrayList<>(); } ModuleInstance module = ModuleInstance.deserialize(string); if (module == null) continue; moduleList.add(module); } if (!moduleList.isEmpty()) modules.add(moduleList); return modules; }
Example #7
Source File: BookBot.java From ForgeHax with MIT License | 6 votes |
private void sendBook(ItemStack stack) { NBTTagList pages = new NBTTagList(); // page tag list // copy pages into NBT for (int i = 0; i < MAX_PAGES && parser.hasNext(); i++) { pages.appendTag(new NBTTagString(parser.next().trim())); page++; } // set our client side book if (stack.hasTagCompound()) { stack.getTagCompound().setTag("pages", pages); } else { stack.setTagInfo("pages", pages); } // publish the book stack.setTagInfo("author", new NBTTagString(getLocalPlayer().getName())); stack.setTagInfo( "title", new NBTTagString(parent.name.get().replaceAll(NUMBER_TOKEN, "" + getBook()).trim())); PacketBuffer buff = new PacketBuffer(Unpooled.buffer()); buff.writeItemStack(stack); MC.getConnection().sendPacket(new CPacketCustomPayload("MC|BSign", buff)); }
Example #8
Source File: ItemBookCode.java From Minecoprocessors with GNU General Public License v3.0 | 6 votes |
/** * Store the data to the specified NBT tag. * * @param nbt the tag to save the data to. */ public void writeToNBT(final NBTTagCompound nbt) { final NBTTagList pagesNbt = new NBTTagList(); int removed = 0; for (int index = 0; index < pages.size(); index++) { final List<String> program = pages.get(index); if (program.size() > 1 || program.get(0).length() > 0) { pagesNbt.appendTag(new NBTTagString(String.join("\n", program))); } else if (index < selectedPage) { removed++; } } nbt.setTag(TAG_PAGES, pagesNbt); nbt.setInteger(TAG_SELECTED, selectedPage - removed); }
Example #9
Source File: PartFrame.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public void load(NBTTagCompound tag) { if (hidden == null) hidden = new boolean[6]; super.load(tag); for (int i = 0; i < 6; i++) { hidden[i] = tag.getBoolean("hidden_" + i); NBTTagList l = tag.getTagList("sidemods_" + i, new NBTTagString().getId()); Collection<IFrameSideModifier> c = getSideModifiers(ForgeDirection.getOrientation(i)); c.clear(); for (int j = 0; j < l.tagCount(); j++) c.add((IFrameSideModifier) FrameModifierRegistry.instance().findModifier(l.getStringTagAt(j))); } }
Example #10
Source File: BookCreator.java From Minecoprocessors with GNU General Public License v3.0 | 6 votes |
private static ItemStack loadBook(String name) throws IOException { ItemStack book = new ItemStack(Items.WRITTEN_BOOK); String line; int lineNumber = 1; StringBuilder page = newPage(); try (BufferedReader reader = openBookReader(name)) { while ((line = reader.readLine()) != null) { if (lineNumber == 1) { book.setTagInfo("title", new NBTTagString(line)); } else if (lineNumber == 2) { book.setTagInfo("author", new NBTTagString(line)); } else if (PAGE_DELIMITER.equals(line)) { writePage(book, page); page = newPage(); } else { page.append(line).append("\n"); } lineNumber++; } } writePage(book, page); return book; }
Example #11
Source File: ItemPartFrame.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord loc, int side, Vector3 hit) { NBTTagCompound tag = item.getTagCompound(); if (tag == null) return null; if (!tag.hasKey("modifiers")) return null; NBTTagList l = tag.getTagList("modifiers", new NBTTagString().getId()); List<IFrameModifier> mods = new ArrayList<IFrameModifier>(); for (int i = 0; i < l.tagCount(); i++) { IFrameModifier mod = FrameModifierRegistry.instance().findModifier(l.getStringTagAt(i)); if (mod != null) mods.add(mod); } return FrameFactory.createFrame(PartFrame.class, mods); }
Example #12
Source File: ItemPartFrame.java From Framez with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void addInformation(ItemStack stack, EntityPlayer player, List tip, boolean shift) { NBTTagCompound tag = stack.getTagCompound(); if (tag == null) return; if (!tag.hasKey("modifiers")) return; tip.add(I18n.format("tooltip." + ModInfo.MODID + ":modifiers") + ":"); NBTTagList l = tag.getTagList("modifiers", new NBTTagString().getId()); for (int i = 0; i < l.tagCount(); i++) { String type = l.getStringTagAt(i); IFrameModifier mod = FrameModifierRegistry.instance().findModifier(type); boolean found = mod != null; tip.add((!found ? EnumChatFormatting.RED : "") + " - " + I18n.format("tooltip." + ModInfo.MODID + ":modifier." + type + ".name") + (mod != null && mod instanceof IFrameModifierMaterial ? " [" + I18n.format("tooltip." + ModInfo.MODID + ":modifier.material") + "]" : "")); } }
Example #13
Source File: CommandOutputs.java From Electro-Magic-Tools with GNU General Public License v3.0 | 6 votes |
public void addOutputsBook(String title, String text, ICommandSender command, String[] astring) { ItemStack book = new ItemStack(Items.written_book); book.setTagInfo("author", new NBTTagString("Tombenpotter")); book.setTagInfo("title", new NBTTagString(title)); NBTTagCompound nbttagcompound = book.getTagCompound(); NBTTagList bookPages = new NBTTagList(); bookPages.appendTag(new NBTTagString(text.substring(0, 237))); bookPages.appendTag(new NBTTagString(text.substring(237, 476))); bookPages.appendTag(new NBTTagString(text.substring(476, 709))); bookPages.appendTag(new NBTTagString(text.substring(709))); nbttagcompound.setTag("pages", bookPages); System.out.println(text.length()); if (!command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).inventory.addItemStackToInventory(book)) command.getEntityWorld().getPlayerEntityByName(command.getCommandSenderName()).entityDropItem(book, 0); }
Example #14
Source File: GuiEditNBT.java From NBTEdit with GNU General Public License v3.0 | 6 votes |
private static void setValidValue(Node<NamedNBT> node, String value){ NamedNBT named = node.getObject(); NBTBase base = named.getNBT(); if (base instanceof NBTTagByte) named.setNBT(new NBTTagByte(ParseHelper.parseByte(value))); if (base instanceof NBTTagShort) named.setNBT(new NBTTagShort(ParseHelper.parseShort(value))); if (base instanceof NBTTagInt) named.setNBT(new NBTTagInt(ParseHelper.parseInt(value))); if (base instanceof NBTTagLong) named.setNBT(new NBTTagLong(ParseHelper.parseLong(value))); if(base instanceof NBTTagFloat) named.setNBT(new NBTTagFloat(ParseHelper.parseFloat(value))); if(base instanceof NBTTagDouble) named.setNBT(new NBTTagDouble(ParseHelper.parseDouble(value))); if(base instanceof NBTTagByteArray) named.setNBT(new NBTTagByteArray(ParseHelper.parseByteArray(value))); if(base instanceof NBTTagIntArray) named.setNBT(new NBTTagIntArray(ParseHelper.parseIntArray(value))); if (base instanceof NBTTagString) named.setNBT(new NBTTagString(value)); }
Example #15
Source File: CraftMetaMap.java From Kettle with GNU General Public License v3.0 | 6 votes |
@Override void applyToItem(NBTTagCompound tag) { super.applyToItem(tag); if (hasScaling()) { tag.setBoolean(MAP_SCALING.NBT, isScaling()); } if (hasLocationName()) { setDisplayTag(tag, MAP_LOC_NAME.NBT, new NBTTagString(getLocationName())); } if (hasColor()) { setDisplayTag(tag, MAP_COLOR.NBT, new NBTTagInt(color.asRGB())); } }
Example #16
Source File: ItemPartFrame.java From Framez with GNU General Public License v3.0 | 6 votes |
@Override public String getUnlocalizedName(ItemStack stack) { NBTTagCompound tag = stack.getTagCompound(); if (tag == null) return super.getUnlocalizedName(stack); if (!tag.hasKey("modifiers")) return super.getUnlocalizedName(stack); NBTTagList l = tag.getTagList("modifiers", new NBTTagString().getId()); for (int i = 0; i < l.tagCount(); i++) { String type = l.getStringTagAt(i); IFrameModifier mod = FrameModifierRegistry.instance().findModifier(type); if (mod != null && mod instanceof IFrameModifierMaterial) return super.getUnlocalizedName(stack) + "." + type; } return super.getUnlocalizedName(stack); }
Example #17
Source File: ItemPartFrame.java From Framez with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void getSubItems(Item i, CreativeTabs t, List l) { for (List<IFrameModifier> mods : FrameModifierRegistry.instance().getAllCombinations(PartFrame.class)) { NBTTagList tagList = new NBTTagList(); for (IFrameModifier mod : mods) tagList.appendTag(new NBTTagString(mod.getType())); NBTTagCompound tag = new NBTTagCompound(); tag.setTag("modifiers", tagList); ItemStack is = new ItemStack(this); is.setTagCompound(tag); l.add(is); } }
Example #18
Source File: NBTStringHelper.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
public static NBTBase newTag(byte type){ switch (type) { case 0: return new NBTTagEnd(); case 1: return new NBTTagByte((byte) 0); case 2: return new NBTTagShort(); case 3: return new NBTTagInt(0); case 4: return new NBTTagLong(0); case 5: return new NBTTagFloat(0); case 6: return new NBTTagDouble(0); case 7: return new NBTTagByteArray(new byte[0]); case 8: return new NBTTagString(""); case 9: return new NBTTagList(); case 10: return new NBTTagCompound(); case 11: return new NBTTagIntArray(new int[0]); default: return null; } }
Example #19
Source File: TileUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public static ItemStack storeTileEntityNBTInStack(ItemStack stack, NBTTagCompound nbt, boolean addNBTLore) { nbt.removeTag("x"); nbt.removeTag("y"); nbt.removeTag("z"); if (stack.getItem() == Items.SKULL && nbt.hasKey("Owner")) { NBTTagCompound tagOwner = nbt.getCompoundTag("Owner"); NBTTagCompound nbtOwner2 = new NBTTagCompound(); nbtOwner2.setTag("SkullOwner", tagOwner); stack.setTagCompound(nbtOwner2); } else { stack.setTagInfo("BlockEntityTag", nbt); if (addNBTLore) { NBTTagCompound tagDisplay = new NBTTagCompound(); NBTTagList tagLore = new NBTTagList(); tagLore.appendTag(new NBTTagString("(+NBT)")); tagDisplay.setTag("Lore", tagLore); stack.setTagInfo("display", tagDisplay); } } return stack; }
Example #20
Source File: NBTStringHelper.java From NBTEdit with GNU General Public License v3.0 | 5 votes |
public static String toString(NBTBase base) { switch(base.getId()) { case 1: return "" + ((NBTTagByte)base).func_150290_f(); case 2: return "" + ((NBTTagShort)base).func_150289_e(); case 3: return "" + ((NBTTagInt)base).func_150287_d(); case 4: return "" + ((NBTTagLong)base).func_150291_c(); case 5: return "" + ((NBTTagFloat)base).func_150288_h(); case 6: return "" + ((NBTTagDouble)base).func_150286_g(); case 7: return base.toString(); case 8: return ((NBTTagString)base).func_150285_a_(); case 9: return "(TagList)"; case 10: return "(TagCompound)"; case 11: return base.toString(); default: return "?"; } }
Example #21
Source File: PartFrame.java From Framez with GNU General Public License v3.0 | 5 votes |
public ItemStack getItem() { NBTTagList tagList = new NBTTagList(); for (IFrameModifier mod : getModifiers()) tagList.appendTag(new NBTTagString(mod.getType())); NBTTagCompound tag = new NBTTagCompound(); tag.setTag("modifiers", tagList); ItemStack is = new ItemStack(FramezItems.frame); is.setTagCompound(tag); return is; }
Example #22
Source File: TerminalUtils.java From OpenPeripheral-Addons with MIT License | 5 votes |
public static Long extractGuid(NBTTagCompound tag) { NBTBase guidTag = tag.getTag("guid"); if (guidTag instanceof NBTTagString) { String value = ((NBTTagString)guidTag).func_150285_a_(); return Long.parseLong(value.toLowerCase(), 36); } else if (guidTag instanceof NBTTagLong) return ((NBTPrimitive)guidTag).func_150291_c(); return null; }
Example #23
Source File: TileEntityQuantumComputer.java From qcraft-mod with Apache License 2.0 | 5 votes |
public NBTTagCompound encode() { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger( "xmin", m_shape.m_xMin ); nbttagcompound.setInteger( "xmax", m_shape.m_xMax ); nbttagcompound.setInteger( "ymin", m_shape.m_yMin ); nbttagcompound.setInteger( "ymax", m_shape.m_yMax ); nbttagcompound.setInteger( "zmin", m_shape.m_zMin ); nbttagcompound.setInteger( "zmax", m_shape.m_zMax ); NBTTagList blockNames = new NBTTagList(); for( int i=0; i<m_blocks.length; ++i ) { String name = null; Block block = m_blocks[i]; if( block != null ) { name = Block.blockRegistry.getNameForObject( block ); } if( name != null && name.length() > 0 ) { blockNames.appendTag( new NBTTagString( name ) ); } else { blockNames.appendTag( new NBTTagString( "null" ) ); } } nbttagcompound.setTag( "blockNames", blockNames ); nbttagcompound.setIntArray( "metaData", m_metaData ); return nbttagcompound; }
Example #24
Source File: ItemExtendedNodeJar.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public void setNodeAttributes(ItemStack itemstack, NodeType type, NodeModifier mod, ExtendedNodeType extendedNodeType, String id) { if (!itemstack.hasTagCompound()) { itemstack.setTagCompound(new NBTTagCompound()); } itemstack.setTagInfo("nodetype", new NBTTagInt(type.ordinal())); if (mod != null) { itemstack.setTagInfo("nodemod", new NBTTagInt(mod.ordinal())); } if(extendedNodeType != null) { itemstack.setTagInfo("nodeExMod", new NBTTagInt(extendedNodeType.ordinal())); } itemstack.setTagInfo("nodeid", new NBTTagString(id)); }
Example #25
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reads an unknown object withPriority a known name from NBT * @param tag - tag to read the value from * @param key - name of the value * @return object or suggestionValue if nothing is found */ public Object load(NBTTagCompound tag, String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); if (saveTag instanceof NBTTagFloat) { return tag.getFloat(key); } else if (saveTag instanceof NBTTagDouble) { return tag.getDouble(key); } else if (saveTag instanceof NBTTagInt) { return tag.getInteger(key); } else if (saveTag instanceof NBTTagString) { if (tag.getBoolean(key + "::nova.isBigInteger")) { return new BigInteger(tag.getString(key)); } else if (tag.getBoolean(key + "::nova.isBigDecimal")) { return new BigDecimal(tag.getString(key)); } else { return tag.getString(key); } } else if (saveTag instanceof NBTTagShort) { return tag.getShort(key); } else if (saveTag instanceof NBTTagByte) { if (tag.getBoolean(key + "::nova.isBoolean")) { return tag.getBoolean(key); } else { return tag.getByte(key); } } else if (saveTag instanceof NBTTagLong) { return tag.getLong(key); } else if (saveTag instanceof NBTTagByteArray) { return tag.getByteArray(key); } else if (saveTag instanceof NBTTagIntArray) { return tag.getIntArray(key); } else if (saveTag instanceof NBTTagCompound) { NBTTagCompound innerTag = tag.getCompoundTag(key); return toNova(innerTag); } } return null; }
Example #26
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reads an unknown object withPriority a known name from NBT * @param tag - tag to read the value from * @param key - name of the value * @return object or suggestionValue if nothing is found */ public Object load(NBTTagCompound tag, String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); if (saveTag instanceof NBTTagFloat) { return tag.getFloat(key); } else if (saveTag instanceof NBTTagDouble) { return tag.getDouble(key); } else if (saveTag instanceof NBTTagInt) { return tag.getInteger(key); } else if (saveTag instanceof NBTTagString) { if (tag.getBoolean(key + "::nova.isBigInteger")) { return new BigInteger(tag.getString(key)); } else if (tag.getBoolean(key + "::nova.isBigDecimal")) { return new BigDecimal(tag.getString(key)); } else { return tag.getString(key); } } else if (saveTag instanceof NBTTagShort) { return tag.getShort(key); } else if (saveTag instanceof NBTTagByte) { if (tag.getBoolean(key + "::nova.isBoolean")) { return tag.getBoolean(key); } else { return tag.getByte(key); } } else if (saveTag instanceof NBTTagLong) { return tag.getLong(key); } else if (saveTag instanceof NBTTagByteArray) { return tag.getByteArray(key); } else if (saveTag instanceof NBTTagIntArray) { return tag.getIntArray(key); } else if (saveTag instanceof NBTTagCompound) { NBTTagCompound innerTag = tag.getCompoundTag(key); return toNova(innerTag); } } return null; }
Example #27
Source File: DataConverter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 5 votes |
/** * Reads an unknown object withPriority a known name from NBT * @param tag - tag to read the value from * @param key - name of the value * @return object or suggestionValue if nothing is found */ @Nullable public Object load(@Nullable NBTTagCompound tag, @Nullable String key) { if (tag != null && key != null) { NBTBase saveTag = tag.getTag(key); if (saveTag instanceof NBTTagFloat) { return tag.getFloat(key); } else if (saveTag instanceof NBTTagDouble) { return tag.getDouble(key); } else if (saveTag instanceof NBTTagInt) { return tag.getInteger(key); } else if (saveTag instanceof NBTTagString) { return tag.getString(key); } else if (saveTag instanceof NBTTagShort) { return tag.getShort(key); } else if (saveTag instanceof NBTTagByte) { if (tag.getBoolean("isBoolean")) { return tag.getBoolean(key); } else { return tag.getByte(key); } } else if (saveTag instanceof NBTTagLong) { return tag.getLong(key); } else if (saveTag instanceof NBTTagByteArray) { return tag.getByteArray(key); } else if (saveTag instanceof NBTTagIntArray) { return tag.getIntArray(key); } else if (saveTag instanceof NBTTagCompound) { NBTTagCompound innerTag = tag.getCompoundTag(key); return toNova(innerTag); } } return null; }
Example #28
Source File: SignBookCommand.java From seppuku with GNU General Public License v3.0 | 5 votes |
@Override public void exec(String input) { if (!this.clamp(input, 2, 2)) { this.printUsage(); return; } final Minecraft mc = Minecraft.getMinecraft(); if (!mc.player.isCreative()) { Seppuku.INSTANCE.errorChat("Creative mode is required to use this command."); return; } final ItemStack itemStack = mc.player.inventory.getCurrentItem(); final String[] split = input.split(" "); if(itemStack.getItem() instanceof ItemWrittenBook) { final NBTTagCompound tagCompound = (itemStack.hasTagCompound()) ? itemStack.getTagCompound() : new NBTTagCompound(); tagCompound.setTag("author", new NBTTagString(split[1])); mc.player.connection.sendPacket(new CPacketCreativeInventoryAction(36 + mc.player.inventory.currentItem, itemStack)); Seppuku.INSTANCE.logChat("Signed book with username " + split[1]); }else{ Seppuku.INSTANCE.errorChat("Please hold a signed book"); } }
Example #29
Source File: GuiPythonBook.java From pycode-minecraft with MIT License | 5 votes |
/** * Sets the text of the current page as determined by currPage */ private void pageSetCurrent(String text) { if (this.bookPages != null && this.currPage >= 0 && this.currPage < this.bookPages.tagCount()) { this.bookPages.set(this.currPage, new NBTTagString(text)); this.bookIsModified = true; } }
Example #30
Source File: GuiPythonBook.java From pycode-minecraft with MIT License | 5 votes |
public GuiPythonBook(EntityPlayer player, ItemStack book) { this.bookObj = book; this.bookIsModified = false; if (book.hasTagCompound()) { NBTTagCompound nbttagcompound = book.getTagCompound(); this.bookPages = nbttagcompound.getTagList("pages", 8); this.bookTitle = nbttagcompound.getString("title"); this.bookPages = this.bookPages.copy(); this.bookTotalPages = this.bookPages.tagCount(); if (this.bookTotalPages < 1) { this.bookTotalPages = 1; } } else { this.bookPages = new NBTTagList(); this.bookPages.appendTag(new NBTTagString("\n")); this.bookTitle = ""; this.bookTotalPages = 1; } if (this.bookTitle.isEmpty()) { this.bookTitle = TITLE_PLACEHOLDER; } this.code = new PythonCode(); this.codeException = null; this.oldContent = ""; this.codeChecked = false; }