本文整理汇总了Java中net.minecraft.init.Items.writable_book方法的典型用法代码示例。如果您正苦于以下问题:Java Items.writable_book方法的具体用法?Java Items.writable_book怎么用?Java Items.writable_book使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.init.Items
的用法示例。
在下文中一共展示了Items.writable_book方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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.writable_book)
{
this.mc.displayGuiScreen(new GuiScreenBook(this, bookStack, true));
}
}
示例3: 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.writable_book) {
this.mc.displayGuiScreen(new GuiScreenBook(this, bookStack, true));
}
}
示例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: addItem
import net.minecraft.init.Items; //导入方法依赖的package包/类
public static void addItem(EntityPlayer player, Entity_AA turret, ItemStack playerStack)
{
int slot = 0;
while (slot < turret.storage.length)
{
if (turret.storage[slot] == null) // That spot is free
{
turret.storage[slot] = playerStack.copy(); // Stored
if (!player.capabilities.isCreativeMode) { player.setCurrentItemOrArmor(0, null); } // Empty
if (playerStack.getItem() == Items.writable_book && AI_Targeting.isNameOnWhitelist(turret, Commands.cmdStayStationary))
{
//System.out.println("[ARMS ASSISTANT] Received a book with STAY command. Setting target position");
turret.stationaryX = turret.posX;
turret.stationaryY = turret.posY;
turret.stationaryZ = turret.posZ;
}
// Informing the client about this change
NetHelper.sendTurretInventoryMessageToPlayersInRange(turret.worldObj, turret,
Item.getIdFromItem(turret.storage[slot].getItem()), slot, turret.storage[slot].getItemDamage());
return; // We're done here
}
// else, there's something in there
slot += 1;
}
// No free spot found. What about existing ones?
slot = 0;
while (slot < turret.storage.length)
{
if (turret.storage[slot] != null)
{
boolean skip = false;
if (!(turret.storage[slot].getItem() instanceof _AmmoBase)) { skip = true; } // Not ammunition, hm?
if (turret.storage[slot].getItemDamage() < turret.storage[slot].getMaxDamage()) { skip = true; } // Not empty
if (!skip)
{
// Has an empty magazine in there, so replacing that now
dropSingleItem(turret, turret.storage[slot].copy());
turret.storage[slot] = playerStack.copy(); // Stored
if (!player.capabilities.isCreativeMode) { player.setCurrentItemOrArmor(0, null); } // Empty
// Informing the client about this change
NetHelper.sendTurretInventoryMessageToPlayersInRange(turret.worldObj, turret,
Item.getIdFromItem(turret.storage[slot].getItem()), slot, turret.storage[slot].getItemDamage());
return;
}
// else, not a magazine
}
// else, no free spot found but this is null? Da fuq?
slot += 1;
}
}
示例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
}