本文整理汇总了Java中net.minecraft.item.ItemStack.isItemEnchanted方法的典型用法代码示例。如果您正苦于以下问题:Java ItemStack.isItemEnchanted方法的具体用法?Java ItemStack.isItemEnchanted怎么用?Java ItemStack.isItemEnchanted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemStack
的用法示例。
在下文中一共展示了ItemStack.isItemEnchanted方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecipeIngredients
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private ItemStack[] getRecipeIngredients(ItemStackHandler inputStacks) {
List<ItemStack> enchantedBooks = new ItemStackHandlerIterable(inputStacks)
.stream()
.filter(book -> book.getItem() == Items.ENCHANTED_BOOK)
.collect(Collectors.toList());
if (enchantedBooks.isEmpty()) return null;
for (ItemStack inputStack : new ItemStackHandlerIterable(inputStacks)) {
if ((inputStack.isItemEnchantable() || inputStack.isItemEnchanted()) && inputStack.getItem() != Items.ENCHANTED_BOOK) {
for (ItemStack enchantedBook : enchantedBooks) {
Map<Enchantment, Integer> bookMap = EnchantmentHelper.getEnchantments(enchantedBook);
for (Map.Entry<Enchantment, Integer> entry : bookMap.entrySet()) {
if (entry.getKey().canApply(inputStack)) {
return new ItemStack[]{ inputStack, enchantedBook};
}
}
}
}
}
return null;
}
示例2: performWork
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
protected float performWork() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
ItemStack stack = getFirstItem();
if (stack.isEmpty()) {
return 0;
}
ItemStack out = stack.copy();
out.setCount(1);
if (stack.isItemEnchanted() || stack.getItem().equals(Items.ENCHANTED_BOOK)) {
if (ItemHandlerHelper.insertItem(outputEnch, out, true).isEmpty()) {
ItemHandlerHelper.insertItem(outputEnch, out, false);
stack.setCount(stack.getCount() - 1);
return 500;
}
} else if (ItemHandlerHelper.insertItem(outputNoEnch, out, true).isEmpty()) {
ItemHandlerHelper.insertItem(outputNoEnch, out, false);
stack.setCount(stack.getCount() - 1);
return 500;
}
return 0;
}
示例3: canDiffuse
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
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: addInformation
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, ITooltipFlag advanced) {
if (!stack.isItemEnchanted()) {
tooltip.add(TextFormatting.AQUA + I18n.format("witch.tooltip.talismans_description.name"));
}
}
示例5: onItemUse
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote&&worldIn.getBlockState(pos).getBlock()==ModBlocks.chalkBase)
{
TileEntityChalkBase te = (TileEntityChalkBase)worldIn.getTileEntity(pos);
DefaultDustSymbol startDust = te.getDustAt(hitX,hitZ);
if(startDust instanceof DustSymbolStart)
{
System.out.println("start script compilation");
ItemStack enchantItem = te.getItem();
if(enchantItem==null)return EnumActionResult.SUCCESS;
if(enchantItem.isItemEnchanted())return EnumActionResult.SUCCESS;
if (enchantItem.getTagCompound()==null)enchantItem.setTagCompound(new NBTTagCompound());
enchantItem.getTagCompound().setByteArray("omniScript",ModDust.getFormationArray((DustSymbolStart)startDust));
enchantItem.addEnchantment(ModEnchantment.runicenchantment, 1);
CompiledSymbol[] script = ModDust.getScriptFromItem(enchantItem);
//InventoryHelper.dropInventoryItems(worldIn, te.getPos(), te);
te.updateRendering();
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
示例6: renderLayer
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
private void renderLayer(EntityLivingBase entitylivingbaseIn, float p_177182_2_, float p_177182_3_, float p_177182_4_, float p_177182_5_, float p_177182_6_, float p_177182_7_, float p_177182_8_, int armorSlot)
{
ItemStack itemstack = this.getCurrentArmor(entitylivingbaseIn, armorSlot);
if (itemstack != null && itemstack.getItem() instanceof ItemArmor)
{
ItemArmor itemarmor = (ItemArmor)itemstack.getItem();
T t = this.func_177175_a(armorSlot);
t.setModelAttributes(this.renderer.getMainModel());
t.setLivingAnimations(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_4_);
this.func_177179_a(t, armorSlot);
boolean flag = this.isSlotForLeggings(armorSlot);
this.renderer.bindTexture(this.getArmorResource(itemarmor, flag));
switch (itemarmor.getArmorMaterial())
{
case LEATHER:
int i = itemarmor.getColor(itemstack);
float f = (float)(i >> 16 & 255) / 255.0F;
float f1 = (float)(i >> 8 & 255) / 255.0F;
float f2 = (float)(i & 255) / 255.0F;
GlStateManager.color(this.colorR * f, this.colorG * f1, this.colorB * f2, this.alpha);
t.render(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
this.renderer.bindTexture(this.getArmorResource(itemarmor, flag, "overlay"));
case CHAIN:
case IRON:
case GOLD:
case DIAMOND:
GlStateManager.color(this.colorR, this.colorG, this.colorB, this.alpha);
t.render(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
default:
if (!this.field_177193_i && itemstack.isItemEnchanted())
{
this.func_177183_a(entitylivingbaseIn, t, p_177182_2_, p_177182_3_, p_177182_4_, p_177182_5_, p_177182_6_, p_177182_7_, p_177182_8_);
}
}
}
}
示例7: doRenderLayer
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void doRenderLayer(AbstractClientPlayer entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack != null && itemstack.getItem() == Items.ELYTRA)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
if (entitylivingbaseIn.isPlayerInfoSet() && entitylivingbaseIn.getLocationElytra() != null)
{
this.renderPlayer.bindTexture(entitylivingbaseIn.getLocationElytra());
}
else if (entitylivingbaseIn.hasPlayerInfo() && entitylivingbaseIn.getLocationCape() != null && entitylivingbaseIn.isWearing(EnumPlayerModelParts.CAPE))
{
this.renderPlayer.bindTexture(entitylivingbaseIn.getLocationCape());
}
else
{
this.renderPlayer.bindTexture(TEXTURE_ELYTRA);
}
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.0F, 0.125F);
this.modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entitylivingbaseIn);
this.modelElytra.render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
if (itemstack.isItemEnchanted())
{
LayerArmorBase.renderEnchantedGlint(this.renderPlayer, entitylivingbaseIn, this.modelElytra, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
}
GlStateManager.popMatrix();
}
}
示例8: doRenderLayer
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale)
{
ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
if (itemstack.getItem() == Items.ELYTRA)
{
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.enableBlend();
GlStateManager.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
if (entitylivingbaseIn instanceof AbstractClientPlayer)
{
AbstractClientPlayer abstractclientplayer = (AbstractClientPlayer)entitylivingbaseIn;
if (abstractclientplayer.isPlayerInfoSet() && abstractclientplayer.getLocationElytra() != null)
{
this.renderPlayer.bindTexture(abstractclientplayer.getLocationElytra());
}
else if (abstractclientplayer.hasElytraCape() && abstractclientplayer.hasPlayerInfo() && abstractclientplayer.getLocationCape() != null && abstractclientplayer.isWearing(EnumPlayerModelParts.CAPE))
{
this.renderPlayer.bindTexture(abstractclientplayer.getLocationCape());
}
else
{
ResourceLocation resourcelocation1 = TEXTURE_ELYTRA;
if (Config.isCustomItems())
{
resourcelocation1 = CustomItems.getCustomElytraTexture(itemstack, resourcelocation1);
}
this.renderPlayer.bindTexture(resourcelocation1);
}
}
else
{
ResourceLocation resourcelocation = TEXTURE_ELYTRA;
if (Config.isCustomItems())
{
resourcelocation = CustomItems.getCustomElytraTexture(itemstack, resourcelocation);
}
this.renderPlayer.bindTexture(resourcelocation);
}
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.0F, 0.125F);
this.modelElytra.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entitylivingbaseIn);
this.modelElytra.render(entitylivingbaseIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
if (itemstack.isItemEnchanted())
{
LayerArmorBase.renderEnchantedGlint(this.renderPlayer, entitylivingbaseIn, this.modelElytra, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale);
}
GlStateManager.disableBlend();
GlStateManager.popMatrix();
}
}
示例9: activate
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
public void activate(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
if(player.isSneaking())
{
if(Prep1_11.isEmpty(heldItem))
{
if(hasEnchItem())
{
if(!world.isRemote)
{
world.spawnEntity(new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), mainHandler.getStackInSlot(SLOT_ENCH_ITEM)));
}
mainHandler.setStackInSlot(SLOT_ENCH_ITEM, null);
mode = Mode.NONE;
pendingIngredients.clear();
markDirty();
world.notifyBlockUpdate(pos, state, state, 8);
}
else if(world.isRemote)
{
ITextComponent link1 = new TextComponentString("Infusion Repair");
link1.setStyle(new Style().setBold(true).setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/einsteinsci/betterbeginnings/wiki/Infusion-Repair")));
ITextComponent link2 = new TextComponentString("Enchantment Diffusion");
link2.setStyle(new Style().setBold(true).setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "https://github.com/einsteinsci/betterbeginnings/wiki/Enchantment-Diffusion")));
ITextComponent message = new TextComponentString("See the BB wiki articles on ");
message.appendSibling(link1);
player.sendMessage(message);
player.sendMessage(new TextComponentString("and ").appendSibling(link2));
}
}
}
else
{
if(Prep1_11.isEmpty(heldItem) || hasEnchItem() || mode != Mode.NONE) return;
if(heldItem.getItem() == RegisterItems.cloth)
{
mode = Mode.DIFFUSION;
}
else if(heldItem.isItemEnchanted())
{
if(heldItem.getEnchantmentTagList().tagCount() > 8)
{
player.sendMessage(new TextComponentTranslation("diffusion.toomanyenchants"));
mode = Mode.NONE;
return;
}
mode = Mode.REPAIR;
pendingIngredients.clear();
pendingIngredients.addAll(InfusionRepairUtil.getRequiredStacks(heldItem));
xpLevelsNeeded = InfusionRepairUtil.getTakenLevels(heldItem);
markDirty();
}
else
return;
ItemStack newStack = heldItem.copy();
newStack.setCount(1);
mainHandler.setStackInSlot(heldItem.isItemEnchanted() ? SLOT_ENCH_ITEM : 1, newStack);
heldItem.shrink(1);
}
}
示例10: tryAbsorbDroppedItem
import net.minecraft.item.ItemStack; //导入方法依赖的package包/类
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;
}