Java 类net.minecraft.item.ItemWritableBook 实例源码

项目:pycode-minecraft    文件:HandEntity.java   
public boolean handleItemInteraction(EntityPlayer player, ItemStack heldItem) {
    FMLLog.info("Hand Entity handleItemInteraction item=%s", heldItem);

    if (heldItem == null) {
        if (this.code.hasKey("run")) {
            this.code.put("hand", new HandMethods(this));
            this.code.setRunner(player);
            this.code.invoke("run", new MyEntityPlayer(player));
            this.code.setRunner(this);
        }
        return true;
    }

    Item item = heldItem.getItem();
    if (item instanceof PythonWandItem) {
        PythonWandItem.invokeOnEntity(player, this);
        return true;
    } else if (item instanceof PythonBookItem || item instanceof ItemWritableBook) {
        BlockPos pos = this.getPosition();
        this.code.put("hand", new HandMethods(this));
        this.code.setCodeFromBook(this.getEntityWorld(), player, this, pos, heldItem);
        return true;
    }
    FMLLog.info("... returning FALSE YEAH");
    return false;
}
项目:pycode-minecraft    文件:PythonWandItem.java   
@Nullable
static private PythonCode getCodeFromBook(EntityPlayer player) {
    ItemStack offhand = player.getHeldItemOffhand();
    if (offhand == null) {
        FMLLog.info("... nothing in off hand so pass");
        return null;
    }

    Item offitem = offhand.getItem();
    if (offitem instanceof PythonBookItem || offitem instanceof ItemWritableBook) {
        String content = PythonCode.bookAsString(offhand);
        if (content == null) {
            PythonCode.failz0r(player.worldObj, player.getPosition(), "Could not get pages from the book!?");
            return null;
        }

        PythonCode code = new PythonCode();
        code.setCodeString(content);

        // the following will actually run the code; TODO maybe setContext could be better-named?
        code.setContext(player.worldObj, player, player.getPosition());

        return code;
    }
    return null;
}
项目:pycode-minecraft    文件:PyCodeBlockTileEntity.java   
public boolean handleItemInteraction(EntityPlayer player, ItemStack heldItem) {
    FMLLog.info("Block Entity handleItemInteraction item=%s", heldItem);
    this.isPowered = this.worldObj.isBlockPowered(this.getPosition());

    if (heldItem == null) {
        // this is only ever invoked on the server
        if (this.code.hasKey("run")) {
            this.code.put("block", new BlockMethods(this));
            this.code.setContext(this.worldObj, player, this.getPosition() );
            this.code.invoke("run", new MyEntityPlayer(player));
            this.code.setRunner(this);
        }
        return true;
    }

    Item item = heldItem.getItem();
    if (item instanceof PythonWandItem) {
        PythonWandItem.invokeOnBlock(player, this.getPosition());
        return true;
    } else if (item instanceof PythonBookItem || item instanceof ItemWritableBook) {
        BlockPos pos = this.getPosition();
        this.code.put("block", new BlockMethods(this));
        this.code.setCodeFromBook(this.worldObj, player, this, pos, heldItem);
        return true;
    }

    return false;
}
项目:Hemomancy    文件:ContainerSpellTinkerer.java   
public void finalizeChangesToItemStack()
{
    if(SpellTokenRegistry.hasFocusToken(inventory.spellCueList))
    {
        ItemStack stack = inventory.getStackInSlot(0);
        if(stack != null && stack.getItem() instanceof ItemWritableBook)
        {
            IFocusToken focus = SpellTokenRegistry.getPreparedFocusFromList(inventory.spellCueList);
            if(focus != null)
            {
                ItemStack newStack = new ItemStack(ModItems.itemSimpleSpell);
                newStack = SpellTokenRegistry.writeSpellTokensToItemStack(newStack, inventory.spellCueList);
                newStack.setStackDisplayName("Spell~");

                Slot slotObject = (Slot) inventorySlots.get(0);
                slotObject.putStack(newStack);
                slotObject.onSlotChanged();
                if(player.worldObj.isRemote)
                {
                    sendItemStackToServer(newStack);
                }
                this.saveInventory(player);
                this.detectAndSendChanges();

                this.removeAllFromCue();
            }
        }
    }   
}
项目:MerchantsTFC    文件:SlotWarehouse.java   
@Override
public boolean isItemValid(ItemStack itemstack)
{
    Item item = itemstack.getItem();

    return item instanceof ItemWritableBook || item instanceof ItemWarehouseBook; 
}
项目:ShadowsOfPhysis    文件:PhysisArtifacts.java   
public static boolean canItemAcceptSockets(ItemStack stack) {
    Item item = stack.getItem();
    if (item == PhysisItems.socketable) {
        return false;
    }
    if (item instanceof ItemBlock
        || item instanceof ItemReed
        || item instanceof ItemBed
        || item instanceof ItemFood
        || item instanceof ItemPotion
        || item instanceof ItemMinecart
        || item instanceof ItemBoat
        || item instanceof ItemEnchantedBook
        || item instanceof ItemWritableBook
        || item instanceof ItemBucket
        || item instanceof ItemBucketMilk
        || item instanceof ItemDoor) {
        return false;
    }
    if (item.getItemStackLimit(stack) > 1) {
        return false;
    }
    if (item.hasContainerItem(stack)){
        ItemStack container = item.getContainerItem(stack);
        if (container != null && container.getItem() instanceof ItemBucket) {
            return false;
        }
    }
    if (item.getUnlocalizedName(stack).toLowerCase().contains("bucket")) {
        return false;
    }
    return true;
}
项目:RuneCraftery    文件:ItemEditableBook.java   
public static boolean func_77828_a(NBTTagCompound p_77828_0_) {
   if(!ItemWritableBook.func_77829_a(p_77828_0_)) {
      return false;
   } else if(!p_77828_0_.func_74764_b("title")) {
      return false;
   } else {
      String var1 = p_77828_0_.func_74779_i("title");
      return var1 != null && var1.length() <= 16?p_77828_0_.func_74764_b("author"):false;
   }
}
项目:ForgeHax    文件:BookBot.java   
@Override
public void run() {
    try {
        while (!stopped) {
            // check to see if we've finished the book
            if(!parser.hasNext()) {
                this.status = Status.FINISHED;
                break;
            }

            sleep();

            // wait for screen
            if (MC.currentScreen != null) {
                this.status = Status.AWAITING_GUI_CLOSE;
                continue;
            }

            // search for empty book
            int slot = -1;
            ItemStack selected = null;
            for (int i = 0; i < InventoryPlayer.getHotbarSize(); i++) {
                ItemStack stack = getLocalPlayer().inventory.getStackInSlot(i);
                if (stack != null
                        && !stack.equals(ItemStack.EMPTY)
                        && stack.getItem() instanceof ItemWritableBook) {
                    slot = i;
                    selected = stack;
                    break;
                }
            }

            // make sure we found a book
            if (slot == -1) {
                this.status = Status.NEED_EMPTY_BOOKS_IN_HOTBAR;
                continue;
            }

            // set selected item to that slot
            while(getLocalPlayer().inventory.currentItem != slot) {
                getLocalPlayer().inventory.currentItem = slot;
                this.status = Status.CHANGING_HELD_ITEM;
                sleep();
            }

            final ItemStack item = selected;

            // open the book gui screen
            this.status = Status.OPENING_BOOK;
            MC.addScheduledTask(() -> getLocalPlayer().openBook(item, EnumHand.MAIN_HAND));

            // wait for gui to open
            while(!(MC.currentScreen instanceof GuiScreenBook)) sleep();

            // send book to server
            this.status = Status.WRITING_BOOK;
            MC.addScheduledTask(() -> {
                sendBook(item);
                MC.displayGuiScreen(null);
            });

            // wait for screen to close
            while (MC.currentScreen != null) sleep();
        }
    } catch (Throwable t) {
        this.status = Status.ERROR;
    } finally {
        if(finalListener != null) {
            finalListener.accept(this);
            finalListener = null;
        }

        // set stopped to true
        this.stopped = true;

        if(!this.status.equals(Status.FINISHED) && !this.status.equals(Status.ERROR))
            this.status = Status.STOPPED;
    }
}