本文整理汇总了Java中net.minecraft.init.Items.BOOK属性的典型用法代码示例。如果您正苦于以下问题:Java Items.BOOK属性的具体用法?Java Items.BOOK怎么用?Java Items.BOOK使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类net.minecraft.init.Items
的用法示例。
在下文中一共展示了Items.BOOK属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
boolean book = false;
boolean head = false;
List<ItemStack> items = new ArrayList<ItemStack>();
for (int i = 0; i < inv.getSizeInventory(); i++) {
if (!inv.getStackInSlot(i).isEmpty()) {
if (inv.getStackInSlot(i).getItem() instanceof ItemToolHead) {
head = true;
} else if (inv.getStackInSlot(i).getItem() == Items.BOOK) {
book = true;
}
items.add(inv.getStackInSlot(i));
}
}
if (items.size() != 2) {
return false;
}
return book && head;
}
示例2: getEnchantmentDatas
public static List<EnchantmentData> getEnchantmentDatas(int p_185291_0_, ItemStack p_185291_1_, boolean allowTreasure)
{
List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
Item item = p_185291_1_.getItem();
boolean flag = p_185291_1_.getItem() == Items.BOOK;
for (Enchantment enchantment : Enchantment.REGISTRY)
{
if ((!enchantment.isTreasureEnchantment() || allowTreasure) && (enchantment.type.canEnchantItem(item) || flag))
{
for (int i = enchantment.getMaxLevel(); i > enchantment.getMinLevel() - 1; --i)
{
if (p_185291_0_ >= enchantment.getMinEnchantability(i) && p_185291_0_ <= enchantment.getMaxEnchantability(i))
{
list.add(new EnchantmentData(enchantment, i));
break;
}
}
}
}
return list;
}
示例3: canDiffuse
private boolean canDiffuse()
{
boolean foundBook = false;
boolean foundEnchItem = false;
for(int s = 0; s < mainHandler.getSlots(); s++)
{
ItemStack stack = mainHandler.getStackInSlot(s);
if(Prep1_11.isValid(stack))
{
if(stack.getItem() == Items.BOOK)
foundBook = true;
else if(stack.isItemEnchanted())
foundEnchItem = true;
}
}
return foundBook && foundEnchItem;
}
示例4: addRandomEnchantment
/**
* Applys a random enchantment to the specified item.
*/
public static ItemStack addRandomEnchantment(Random random, ItemStack p_77504_1_, int p_77504_2_, boolean allowTreasure)
{
boolean flag = p_77504_1_.getItem() == Items.BOOK;
List<EnchantmentData> list = buildEnchantmentList(random, p_77504_1_, p_77504_2_, allowTreasure);
if (flag)
{
p_77504_1_.setItem(Items.ENCHANTED_BOOK);
}
for (EnchantmentData enchantmentdata : list)
{
if (flag)
{
Items.ENCHANTED_BOOK.addEnchantment(p_77504_1_, enchantmentdata);
}
else
{
p_77504_1_.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel);
}
}
return p_77504_1_;
}
示例5: getEnchantmentDatas
public static List<EnchantmentData> getEnchantmentDatas(int p_185291_0_, ItemStack p_185291_1_, boolean allowTreasure)
{
List<EnchantmentData> list = Lists.<EnchantmentData>newArrayList();
Item item = p_185291_1_.getItem();
boolean flag = p_185291_1_.getItem() == Items.BOOK;
for (Enchantment enchantment : Enchantment.REGISTRY)
{
if ((!enchantment.isTreasureEnchantment() || allowTreasure) && (enchantment.canApplyAtEnchantingTable(p_185291_1_) || (flag && enchantment.isAllowedOnBooks())))
{
for (int i = enchantment.getMaxLevel(); i > enchantment.getMinLevel() - 1; --i)
{
if (p_185291_0_ >= enchantment.getMinEnchantability(i) && p_185291_0_ <= enchantment.getMaxEnchantability(i))
{
list.add(new EnchantmentData(enchantment, i));
break;
}
}
}
}
return list;
}
示例6: getEnchantmentList
private List<EnchantmentData> getEnchantmentList(net.minecraft.item.ItemStack stack, int p_178148_2_, int p_178148_3_) {
this.rand.setSeed((long) (this.xpSeed + p_178148_2_));
List<EnchantmentData> list = EnchantmentHelper.buildEnchantmentList(this.rand, stack, p_178148_3_, false);
if (stack.getItem() == Items.BOOK && list.size() > 1) {
list.remove(this.rand.nextInt(list.size()));
}
return list;
}
示例7: getEnchantmentList
private List<EnchantmentData> getEnchantmentList(ItemStack stack, int p_178148_2_, int p_178148_3_)
{
this.rand.setSeed((long)(this.xpSeed + p_178148_2_));
List<EnchantmentData> list = EnchantmentHelper.buildEnchantmentList(this.rand, stack, p_178148_3_, false);
if (stack.getItem() == Items.BOOK && list.size() > 1)
{
list.remove(this.rand.nextInt(list.size()));
}
return list;
}
示例8: getItemDropped
/**
* Get the Item that this Block should drop when harvested.
*/
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.BOOK;
}
示例9: tryAbsorbDroppedItem
private boolean tryAbsorbDroppedItem(EntityItem item, IBlockState state)
{
ItemStack newStack = Prep1_11.getEmptyStack();
ItemStack stack = item.getItem();
switch(mode)
{
case DIFFUSION:
if(isIngredientPresent(stack)) return false;
if(stack.getItem() == Items.BOOK || stack.isItemEnchanted())
{
newStack = stack.copy();
newStack.setCount(1);
if(!world.isRemote) stack.shrink(1);
}
break;
case REPAIR:
if(pendingIngredients.isEmpty()) return false;
RecipeElement currentIngredient = pendingIngredients.peek();
if(currentIngredient.matches(stack))
{
newStack = stack.copy();
newStack.setCount(Math.min(currentIngredient.getStackSize(), stack.getCount()));
currentIngredient.setStackSize(currentIngredient.getStackSize() - Math.min(currentIngredient.getStackSize(), stack.getCount()));
if(currentIngredient.getStackSize() <= 0)
{
pendingIngredients.pop();
}
if(!world.isRemote) stack.shrink(newStack.getCount());
markDirty();
}
break;
default:
break;
}
if(newStack == null) return false;
boolean slotFound = false;
if(newStack.isItemEnchanted())
{
mainHandler.setStackInSlot(SLOT_ENCH_ITEM, newStack);
slotFound = true;
}
else
{
//attempt to insert stacks into inv
for(int s = SLOT_ENCH_ITEM + 1; s < mainHandler.getSlots(); s++)
{
ItemStack slotStack = mainHandler.getStackInSlot(s);
if (ItemHandlerHelper.canItemStacksStack(newStack, slotStack))
{
CapUtils.incrementStack(mainHandler, s, newStack.getCount());
slotFound = true;
break;
}
if(Prep1_11.isEmpty(slotStack))
{
mainHandler.setStackInSlot(s, newStack);
slotFound = true;
break;
}
}
}
return slotFound;
}
示例10: getItemDropped
/**
* Get the Item that this Block should drop when harvested.
*/
@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
return Items.BOOK;
}
示例11: enchantItem
/**
* Handles the given Button-click on the server, currently only used by enchanting. Name is for legacy.
*/
public boolean enchantItem(EntityPlayer playerIn, int id)
{
ItemStack itemstack = this.tableInventory.getStackInSlot(0);
ItemStack itemstack1 = this.tableInventory.getStackInSlot(1);
int i = id + 1;
if ((itemstack1 == null || itemstack1.stackSize < i) && !playerIn.capabilities.isCreativeMode)
{
return false;
}
else if (this.enchantLevels[id] > 0 && itemstack != null && (playerIn.experienceLevel >= i && playerIn.experienceLevel >= this.enchantLevels[id] || playerIn.capabilities.isCreativeMode))
{
if (!this.worldPointer.isRemote)
{
List<EnchantmentData> list = this.getEnchantmentList(itemstack, id, this.enchantLevels[id]);
boolean flag = itemstack.getItem() == Items.BOOK;
if (list != null)
{
playerIn.removeExperienceLevel(i);
if (flag)
{
itemstack.setItem(Items.ENCHANTED_BOOK);
}
for (int j = 0; j < list.size(); ++j)
{
EnchantmentData enchantmentdata = (EnchantmentData)list.get(j);
if (flag)
{
Items.ENCHANTED_BOOK.addEnchantment(itemstack, enchantmentdata);
}
else
{
itemstack.addEnchantment(enchantmentdata.enchantmentobj, enchantmentdata.enchantmentLevel);
}
}
if (!playerIn.capabilities.isCreativeMode)
{
itemstack1.stackSize -= i;
if (itemstack1.stackSize <= 0)
{
this.tableInventory.setInventorySlotContents(1, (ItemStack)null);
}
}
playerIn.addStat(StatList.ITEM_ENCHANTED);
this.tableInventory.markDirty();
this.xpSeed = playerIn.getXPSeed();
this.onCraftMatrixChanged(this.tableInventory);
this.worldPointer.playSound((EntityPlayer)null, this.position, SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.BLOCKS, 1.0F, this.worldPointer.rand.nextFloat() * 0.1F + 0.9F);
}
}
return true;
}
else
{
return false;
}
}