Java Code Examples for net.minecraft.init.Items#WRITABLE_BOOK
The following examples show how to use
net.minecraft.init.Items#WRITABLE_BOOK .
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: CraftEventFactory.java From Kettle with GNU General Public License v3.0 | 6 votes |
public static void handleEditBookEvent(EntityPlayerMP player, ItemStack newBookItem) { int itemInHandIndex = player.inventory.currentItem; PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), player.inventory.currentItem, (BookMeta) CraftItemStack.getItemMeta(player.inventory.getCurrentItem()), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK); player.world.getServer().getPluginManager().callEvent(editBookEvent); ItemStack itemInHand = player.inventory.getStackInSlot(itemInHandIndex); // If they've got the same item in their hand, it'll need to be updated. if (itemInHand != null && itemInHand.getItem() == Items.WRITABLE_BOOK) { if (!editBookEvent.isCancelled()) { if (editBookEvent.isSigning()) { itemInHand.setItem(Items.WRITTEN_BOOK); } CraftMetaBook meta = (CraftMetaBook) editBookEvent.getNewBookMeta(); List<ITextComponent> pages = meta.pages; for (int i = 0; i < pages.size(); i++) { pages.set(i, stripEvents(pages.get(i))); } CraftItemStack.setItemMeta(itemInHand, meta); } // Client will have updated its idea of the book item; we need to overwrite that Slot slot = player.openContainer.getSlotFromInventory(player.inventory, itemInHandIndex); player.connection.sendPacket(new SPacketSetSlot(player.openContainer.windowId, slot.slotNumber, itemInHand)); } }
Example 2
Source File: RecipeCopyJournal.java From AgriCraft with MIT License | 5 votes |
@Override public boolean matches(InventoryCrafting invCrafting, World world) { boolean foundJournal = false; boolean foundBook = false; for (int i = 0; i < invCrafting.getSizeInventory(); i++) { ItemStack stackAtIndex = invCrafting.getStackInSlot(i); if (!stackAtIndex.isEmpty() && stackAtIndex.getItem() != null) { if (stackAtIndex.getItem() instanceof ItemJournal) { if (!foundJournal) { foundJournal = true; } else { // There can't be two journals! // Scandalous! return false; } } else if (stackAtIndex.getItem() == Items.WRITABLE_BOOK) { if (!foundBook) { foundBook = true; } else { // There can only be one true king! return false; } } } } return foundJournal && foundBook; }
Example 3
Source File: LaggerModule.java From seppuku with GNU General Public License v3.0 | 4 votes |
@Listener public void onUpdate(EventPlayerUpdate event) { if (event.getStage() == EventStageable.EventStage.PRE) { switch (this.mode.getValue()) { case BOXER: for (int i = 0; i <= this.packets.getValue(); i++) { mc.player.connection.sendPacket(new CPacketAnimation(EnumHand.MAIN_HAND)); } break; case SWAP: for (int i = 0; i <= this.packets.getValue(); i++) { mc.player.connection.sendPacket(new CPacketPlayerDigging(CPacketPlayerDigging.Action.SWAP_HELD_ITEMS, BlockPos.ORIGIN, mc.player.getHorizontalFacing())); } break; case MOVEMENT: for (int i = 0; i <= this.packets.getValue(); i++) { final Entity riding = mc.player.getRidingEntity(); if (riding != null) { riding.posX = mc.player.posX; riding.posY = mc.player.posY + 1337; riding.posZ = mc.player.posZ; mc.player.connection.sendPacket(new CPacketVehicleMove(riding)); } } break; case SIGN: for (TileEntity te : mc.world.loadedTileEntityList) { if (te instanceof TileEntitySign) { final TileEntitySign tileEntitySign = (TileEntitySign) te; for (int i = 0; i <= this.packets.getValue(); i++) { mc.player.connection.sendPacket(new CPacketUpdateSign(tileEntitySign.getPos(), new TextComponentString[]{new TextComponentString("give"), new TextComponentString("riga"), new TextComponentString("the"), new TextComponentString("green book")})); } } } break; case NBT: final ItemStack itemStack = new ItemStack(Items.WRITABLE_BOOK); final NBTTagList pages = new NBTTagList(); for (int page = 0; page < 50; page++) { pages.appendTag(new NBTTagString("192i9i1jr1fj8fj893fj84ujv8924jv2j4c8j248vj2498u2-894u10fuj0jhv20j204uv902jv90j209vj204vj")); } final NBTTagCompound tag = new NBTTagCompound(); tag.setString("author", mc.session.getUsername()); tag.setString("title", "Crash!"); tag.setTag("pages", pages); itemStack.setTagCompound(tag); for (int i = 0; i <= this.packets.getValue(); i++) { mc.player.connection.sendPacket(new CPacketCreativeInventoryAction(0, itemStack)); //mc.player.connection.sendPacket(new CPacketClickWindow(0, 0, 0, ClickType.PICKUP, itemStack, (short)0)); } break; } } }
Example 4
Source File: TileEntityMinecoprocessor.java From Minecoprocessors with GNU General Public License v3.0 | 4 votes |
public static boolean isBook(Item item) { return item == ItemBookCode.INSTANCE || item == Items.WRITABLE_BOOK || item == Items.WRITTEN_BOOK; }