当前位置: 首页>>代码示例>>Java>>正文


Java ItemWritableBook类代码示例

本文整理汇总了Java中net.minecraft.item.ItemWritableBook的典型用法代码示例。如果您正苦于以下问题:Java ItemWritableBook类的具体用法?Java ItemWritableBook怎么用?Java ItemWritableBook使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ItemWritableBook类属于net.minecraft.item包,在下文中一共展示了ItemWritableBook类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleItemInteraction

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
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;
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:27,代码来源:HandEntity.java

示例2: getCodeFromBook

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
@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;
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:27,代码来源:PythonWandItem.java

示例3: handleItemInteraction

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
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;
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:29,代码来源:PyCodeBlockTileEntity.java

示例4: finalizeChangesToItemStack

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
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();
			}
		}
	}	
}
 
开发者ID:WayofTime,项目名称:Hemomancy,代码行数:30,代码来源:ContainerSpellTinkerer.java

示例5: isItemValid

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
@Override
public boolean isItemValid(ItemStack itemstack)
{
    Item item = itemstack.getItem();
    
    return item instanceof ItemWritableBook || item instanceof ItemWarehouseBook; 
}
 
开发者ID:Aleksey-Terzi,项目名称:MerchantsTFC,代码行数:8,代码来源:SlotWarehouse.java

示例6: canItemAcceptSockets

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
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;
}
 
开发者ID:TTFTCUTS,项目名称:ShadowsOfPhysis,代码行数:34,代码来源:PhysisArtifacts.java

示例7: func_77828_a

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
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;
   }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:11,代码来源:ItemEditableBook.java

示例8: run

import net.minecraft.item.ItemWritableBook; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:80,代码来源:BookBot.java


注:本文中的net.minecraft.item.ItemWritableBook类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。