本文整理汇总了Java中net.minecraft.init.Items.written_book方法的典型用法代码示例。如果您正苦于以下问题:Java Items.written_book方法的具体用法?Java Items.written_book怎么用?Java Items.written_book使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.init.Items
的用法示例。
在下文中一共展示了Items.written_book方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayGUIBook
import net.minecraft.init.Items; //导入方法依赖的package包/类
/**
* Displays the GUI for interacting with a book.
*/
public void displayGUIBook(ItemStack bookStack)
{
Item item = bookStack.getItem();
if (item == Items.written_book)
{
this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|BOpen", new PacketBuffer(Unpooled.buffer())));
}
}
示例2: matches
import net.minecraft.init.Items; //导入方法依赖的package包/类
/**
* Used to check if a recipe matches current crafting inventory
*/
public boolean matches(InventoryCrafting inv, World worldIn)
{
int i = 0;
ItemStack itemstack = null;
for (int j = 0; j < inv.getSizeInventory(); ++j)
{
ItemStack itemstack1 = inv.getStackInSlot(j);
if (itemstack1 != null)
{
if (itemstack1.getItem() == Items.written_book)
{
if (itemstack != null)
{
return false;
}
itemstack = itemstack1;
}
else
{
if (itemstack1.getItem() != Items.writable_book)
{
return false;
}
++i;
}
}
}
return itemstack != null && i > 0;
}
示例3: handleCustomPayload
import net.minecraft.init.Items; //导入方法依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla
* implemented channels are "MC|TrList" to acquire a MerchantRecipeList trades
* for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate
* the identifier of the default server resourcepack for the client to load.
*/
public void handleCustomPayload(S3FPacketCustomPayload packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName())) {
PacketBuffer packetbuffer = packetIn.getBufferData();
try {
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant
&& i == this.gameController.thePlayer.openContainer.windowId) {
IMerchant imerchant = ((GuiMerchant) guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
} catch (IOException ioexception) {
logger.error((String) "Couldn\'t load trade info", (Throwable) ioexception);
} finally {
packetbuffer.release();
}
} else if ("MC|Brand".equals(packetIn.getChannelName())) {
this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
} else if ("MC|BOpen".equals(packetIn.getChannelName())) {
ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();
if (itemstack != null && itemstack.getItem() == Items.written_book) {
this.gameController
.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
}
}
}
示例4: getCraftingResult
import net.minecraft.init.Items; //导入方法依赖的package包/类
/**
* Returns an Item that is the result of this recipe
*/
public ItemStack getCraftingResult(InventoryCrafting inv)
{
int i = 0;
ItemStack itemstack = null;
for (int j = 0; j < inv.getSizeInventory(); ++j)
{
ItemStack itemstack1 = inv.getStackInSlot(j);
if (itemstack1 != null)
{
if (itemstack1.getItem() == Items.written_book)
{
if (itemstack != null)
{
return null;
}
itemstack = itemstack1;
}
else
{
if (itemstack1.getItem() != Items.writable_book)
{
return null;
}
++i;
}
}
}
if (itemstack != null && i >= 1 && ItemEditableBook.getGeneration(itemstack) < 2)
{
ItemStack itemstack2 = new ItemStack(Items.written_book, i);
itemstack2.setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
itemstack2.getTagCompound().setInteger("generation", ItemEditableBook.getGeneration(itemstack) + 1);
if (itemstack.hasDisplayName())
{
itemstack2.setStackDisplayName(itemstack.getDisplayName());
}
return itemstack2;
}
else
{
return null;
}
}
示例5: handleCustomPayload
import net.minecraft.init.Items; //导入方法依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
* acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
* resourcepack for the client to load.
*/
public void handleCustomPayload(S3FPacketCustomPayload packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer = packetIn.getBufferData();
try
{
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
logger.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
}
finally
{
packetbuffer.release();
}
}
else if ("MC|Brand".equals(packetIn.getChannelName()))
{
this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
}
else if ("MC|BOpen".equals(packetIn.getChannelName()))
{
ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();
if (itemstack != null && itemstack.getItem() == Items.written_book)
{
this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
}
}
}
示例6: isNameOnWhitelist
import net.minecraft.init.Items; //导入方法依赖的package包/类
public static boolean isNameOnWhitelist(Entity_AA turret, String nameOrCmd)
{
if (turret.storage == null) { return false; } // Has no space to store anything in
int counter = 0;
// Step 1, find a book in our inventory
while (counter < turret.storage.length)
{
if (turret.storage[counter] != null)
{
if (turret.storage[counter].getItem() == Items.writable_book || turret.storage[counter].getItem() == Items.written_book)
{
//System.out.println("[TURRET] Checking writable book for whitelist against " + playerName);
if (turret.storage[counter].hasTagCompound())
{
NBTTagList pageList = turret.storage[counter].getTagCompound().getTagList("pages", 8);
int pageCount = 0;
String currentPage = pageList.getStringTagAt(pageCount);
while (currentPage != null && !currentPage.isEmpty())
{
String[] lines = currentPage.split("\n");
int lineCount = 0;
while (lineCount < lines.length)
{
//System.out.println("[TURRET] Book page " + pageCount + " - line " + lineCount + ": " + lines[lineCount]);
if (lines[lineCount].equals(nameOrCmd)) { return true; } // Found it!
// else, not on this line
lineCount += 1;
}
pageCount += 1;
currentPage = pageList.getStringTagAt(pageCount); // Next!
}
// Done with all known pages (will stop when there's empty pages inbetween)
}
// else, no tag, so can't have anything in it
}
// else, not a book
}
// else, nothing in that slot
counter += 1;
}
return false; // Fallback. Didn't find a book with this name
}