本文整理汇总了Java中net.minecraft.item.ItemBook类的典型用法代码示例。如果您正苦于以下问题:Java ItemBook类的具体用法?Java ItemBook怎么用?Java ItemBook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ItemBook类属于net.minecraft.item包,在下文中一共展示了ItemBook类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: runUnenchant
import net.minecraft.item.ItemBook; //导入依赖的package包/类
public static void runUnenchant(EntityPlayerMP playerEntity, BlockPos pos)
{
System.out.println("Run");
System.out.println("Pos: " + pos);
World world = playerEntity.worldObj;
IInventory te = (IInventory) world.getTileEntity(pos);
if (te instanceof TileEntityUnenchantingTable) {
ItemStack stack = te.getStackInSlot(0);
if (stack != null && stack.getEnchantmentTagList() != null) {
NBTTagList enchantmentList = stack.getEnchantmentTagList();
Enchantment enchantment = Enchantment.getEnchantmentByID(enchantmentList.getCompoundTagAt(0).getShort("id"));
int xp = (int) Math.floor(enchantment.getMinEnchantability(enchantmentList.getCompoundTagAt(0).getShort("lvl")) / 2);
if (playerEntity.experienceLevel < xp && !playerEntity.isCreative())
return;
ItemStack books = te.getStackInSlot(1);
if ((books != null && books.getItem() instanceof ItemBook) && te.getStackInSlot(2) == null) {
NBTTagList list = stack.getEnchantmentTagList();
NBTTagCompound enchTag = list.getCompoundTagAt(0);
ItemStack book = new ItemStack(Items.enchanted_book);
NBTTagCompound baseTag = new NBTTagCompound();
NBTTagList enchList = new NBTTagList();
enchList.appendTag(enchTag);
baseTag.setTag("StoredEnchantments", enchList);
book.setTagCompound(baseTag);
te.setInventorySlotContents(2, book);
--books.stackSize;
list.removeTag(0);
if (list.tagCount() == 0) {
stack.getTagCompound().removeTag("ench");
if (stack.getTagCompound().hasNoTags()) {
stack.setTagCompound(null);
}
}
if (stack.isItemStackDamageable()) {
int damage = world.rand.nextInt(1 + (stack.getMaxDamage() / 4));
int m = stack.getMaxDamage();
damage = Math.min(m, damage + 1 + (m / 10)) + (m == 1 ? 1 : 0);
if (stack.attemptDamageItem(damage, world.rand)) {
te.setInventorySlotContents(0, null);
stack = null;
}
}
if (stack != null)
te.setInventorySlotContents(0, stack);
if (!playerEntity.isCreative()) {
playerEntity.removeExperienceLevel(xp);
}
}
}
}
}
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:61,代码来源:BlockUnenchantingTable.java
示例2: isItemValid
import net.minecraft.item.ItemBook; //导入依赖的package包/类
@Override
public boolean isItemValid(ItemStack stack)
{
return stack.getItem() instanceof ItemBook;
}
开发者ID:GamingsModding,项目名称:LittleThings-old,代码行数:6,代码来源:ContainerUnenchantingTable.java
示例3: canApply
import net.minecraft.item.ItemBook; //导入依赖的package包/类
@Override
public boolean canApply(ItemStack stack) {
return stack.getItem() instanceof IBoneHoe || stack.getItem() instanceof ItemBook;
}
开发者ID:NightKosh,项目名称:Gravestone-mod-Extended,代码行数:5,代码来源:EnchantmentBoneRain.java
示例4: canApply
import net.minecraft.item.ItemBook; //导入依赖的package包/类
@Override
public boolean canApply(ItemStack stack) {
return stack.getItem() instanceof IBoneShiled || stack.getItem() instanceof ItemBook;
}
开发者ID:NightKosh,项目名称:Gravestone-mod-Extended,代码行数:5,代码来源:EnchantmentPainMirror.java
示例5: determineRespawnInventory
import net.minecraft.item.ItemBook; //导入依赖的package包/类
public static InventoryPlayer determineRespawnInventory(InventoryPlayer plai_inv, boolean do_drop) {
boolean drop_main = true;
for (int i = 0; i < plai_inv.mainInventory.length; ++i)
if (plai_inv.mainInventory[i] != null) {
final ItemStack is = plai_inv.mainInventory[i];
if (is.getItem() instanceof NyxItemBoneSanctified && is.isItemDamaged()) {
drop_main = false;
}
}
for (int i = 0; i < plai_inv.mainInventory.length; ++i)
if (plai_inv.mainInventory[i] != null) {
final Item it = plai_inv.mainInventory[i].getItem();
if (it instanceof IIaSOnDeathRuin) {
plai_inv.mainInventory[i] = null;
continue;
}
final EnumRarity rarity = it.getRarity(plai_inv.mainInventory[i]);
if (rarity == EnumRarity.uncommon || rarity == EnumRarity.epic) {
plai_inv.player.dropPlayerItemWithRandomChoice(plai_inv.mainInventory[i], true);
plai_inv.mainInventory[i] = null;
continue;
}
if (rarity == EnumRarity.rare || it instanceof ItemBook) {
if (i < 9) {
continue;
}
plai_inv.player.dropPlayerItemWithRandomChoice(plai_inv.mainInventory[i], true);
plai_inv.mainInventory[i] = null;
}
if (!drop_main) {
continue;
}
if (i < 9)
if (it == Items.arrow || it instanceof ItemSword || it instanceof ItemBow || it instanceof ItemTool) {
continue;
}
plai_inv.player.dropPlayerItemWithRandomChoice(plai_inv.mainInventory[i], true);
plai_inv.mainInventory[i] = null;
}
return plai_inv;
}
开发者ID:TheDaemoness,项目名称:IceAndShadow2,代码行数:42,代码来源:NyxDeathSystem.java
示例6: isBook
import net.minecraft.item.ItemBook; //导入依赖的package包/类
public static boolean isBook(Item item) {
return bookshelfAllowedItems.contains(item.getUnlocalizedName().substring(5, item.getUnlocalizedName().length())) || bookshelfAllowedItems.contains(String.valueOf(item.itemID)) || (item instanceof ItemBook);
}
开发者ID:arilotter,项目名称:EnhancedBooks,代码行数:4,代码来源:Utils.java
注:本文中的net.minecraft.item.ItemBook类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论