当前位置: 首页>>代码示例>>Java>>正文


Java PotionUtils.addPotionToItemStack方法代码示例

本文整理汇总了Java中net.minecraft.potion.PotionUtils.addPotionToItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java PotionUtils.addPotionToItemStack方法的具体用法?Java PotionUtils.addPotionToItemStack怎么用?Java PotionUtils.addPotionToItemStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.potion.PotionUtils的用法示例。


在下文中一共展示了PotionUtils.addPotionToItemStack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCraftingResult

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = inv.getStackInRowAndColumn(1, 1);

    if (itemstack.getItem() != Items.LINGERING_POTION)
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        ItemStack itemstack1 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(itemstack1, PotionUtils.getPotionFromItem(itemstack));
        PotionUtils.appendEffects(itemstack1, PotionUtils.getFullEffectsFromItem(itemstack));
        return itemstack1;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:RecipeTippedArrow.java

示例2: getCraftingResult

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Returns an Item that is the result of this recipe
 */
@Nullable
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = inv.getStackInRowAndColumn(1, 1);

    if (itemstack != null && itemstack.getItem() == Items.LINGERING_POTION)
    {
        ItemStack itemstack1 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(itemstack1, PotionUtils.getPotionFromItem(itemstack));
        PotionUtils.appendEffects(itemstack1, PotionUtils.getFullEffectsFromItem(itemstack));
        return itemstack1;
    }
    else
    {
        return null;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:RecipeTippedArrow.java

示例3: finishUse

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@SubscribeEvent
public void finishUse(LivingEntityUseItemEvent.Finish event){
	EntityLivingBase entity = event.getEntityLiving();
	ItemStack stack = event.getItem();
	
	if(entity.isInsideOfMaterial(Material.WATER)){
		if(ItemStackTools.isValid(stack) && stack.getItem() == Items.GLASS_BOTTLE){
			//Restore to full air
			entity.setAir(300);
			ItemStack waterbottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
			if(ItemStackTools.getStackSize(stack) > 1){
 			event.setResultStack(ItemUtil.consumeItem(stack));
 			if(entity instanceof EntityPlayer){
 				if(!((EntityPlayer)entity).inventory.addItemStackToInventory(waterbottle)){
 					ItemUtil.spawnItemInWorldWithoutMotion(entity.getEntityWorld(), waterbottle, new BlockPos(entity));
 				}
 			} else {
 				ItemUtil.spawnItemInWorldWithoutMotion(entity.getEntityWorld(), waterbottle, new BlockPos(entity));
 			}
			} else {
				event.setResultStack(waterbottle);
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:26,代码来源:EventHandler.java

示例4: getArrowStack

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
protected ItemStack getArrowStack()
{
    ItemStack dart = new ItemStack(ModItems.dart, 1, getType().getMetadata());
    if(potion !=PotionTypes.EMPTY){
    	PotionUtils.addPotionToItemStack(dart, this.potion);
        PotionUtils.appendEffects(dart, this.customPotionEffects);

        if (this.hasColor)
        {
            NBTTagCompound nbttagcompound = dart.getTagCompound();

            if (nbttagcompound == null)
            {
                nbttagcompound = new NBTTagCompound();
                dart.setTagCompound(nbttagcompound);
            }

            nbttagcompound.setInteger("CustomPotionColor", this.getColor());
        }
    }
    return dart;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:23,代码来源:EntityDart.java

示例5: attackWithPotion

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
protected void attackWithPotion(EntityLivingBase target) {
	double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D;
	double targetX = target.posX + target.motionX - this.posX;
	double d2 = targetY - this.posY;
	double targetZ = target.posZ + target.motionZ - this.posZ;

	float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ);
	PotionType potiontype = PotionTypes.HARMING;

	if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) {
		potiontype = PotionTypes.SLOWNESS;
	} else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) {
		potiontype = PotionTypes.POISON;
	} else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) {
		potiontype = PotionTypes.WEAKNESS;
	}

	EntityPotion entitypotion = new EntityPotion(this.world, this,
			PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
	entitypotion.rotationPitch -= -20.0F;
	entitypotion.setThrowableHeading(targetX, d2 + (double) (f * 0.2F), targetZ, 0.75F, 8.0F);

	this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F,
			0.8F + this.rand.nextFloat() * 0.4F);
	this.world.spawnEntity(entitypotion);
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:27,代码来源:EntityMage.java

示例6: getCraftingGrid

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
@Override
public NonNullList<ItemStack> getCraftingGrid(IRecipe r)
{
	NonNullList<ItemStack> recipeItems = NonNullList.<ItemStack>create();

	for ( int i = 0 ; i < 9 ; i++ )
	{
		if (i != 4)
		{
			recipeItems.add(new ItemStack(Items.ARROW, 1));
		}
		else
		{
			ItemStack stack = new ItemStack(Items.LINGERING_POTION, 1);
            PotionUtils.addPotionToItemStack(stack, PotionUtils.getPotionFromItem(inputStack));
            PotionUtils.appendEffects(stack, PotionUtils.getFullEffectsFromItem(inputStack));
			recipeItems.add(stack);
		}
	}

	return recipeItems;
}
 
开发者ID:crazysnailboy,项目名称:UncraftingTable,代码行数:23,代码来源:NBTSensitiveRecipeHandlers.java

示例7: attackEntityWithRangedAttack

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Attack the specified entity using a ranged attack.
 *  
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
    if (!this.isDrinkingPotion())
    {
        double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
        double d1 = target.posX + target.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = target.posZ + target.motionZ - this.posZ;
        float f = MathHelper.sqrt(d1 * d1 + d3 * d3);
        PotionType potiontype = PotionTypes.HARMING;

        if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
        {
            potiontype = PotionTypes.SLOWNESS;
        }
        else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
        {
            potiontype = PotionTypes.POISON;
        }
        else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
        {
            potiontype = PotionTypes.WEAKNESS;
        }

        EntityPotion entitypotion = new EntityPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -20.0F;
        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
        this.world.spawnEntityInWorld(entitypotion);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:37,代码来源:EntityWitch.java

示例8: getArrowStack

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
protected ItemStack getArrowStack()
{
    if (this.customPotionEffects.isEmpty() && this.potion == PotionTypes.EMPTY)
    {
        return new ItemStack(Items.ARROW);
    }
    else
    {
        ItemStack itemstack = new ItemStack(Items.TIPPED_ARROW);
        PotionUtils.addPotionToItemStack(itemstack, this.potion);
        PotionUtils.appendEffects(itemstack, this.customPotionEffects);
        return itemstack;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:EntityTippedArrow.java

示例9: attackEntityWithRangedAttack

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Attack the specified entity using a ranged attack.
 *  
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
    if (!this.isDrinkingPotion())
    {
        double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
        double d1 = target.posX + target.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = target.posZ + target.motionZ - this.posZ;
        float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);
        PotionType potiontype = PotionTypes.HARMING;

        if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
        {
            potiontype = PotionTypes.SLOWNESS;
        }
        else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
        {
            potiontype = PotionTypes.POISON;
        }
        else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
        {
            potiontype = PotionTypes.WEAKNESS;
        }

        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -20.0F;
        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:EntityWitch.java

示例10: addTippedArrowRecipes

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public void addTippedArrowRecipes(ArrayList<DrawableRecipe> list) {
    ItemStack arrow = new ItemStack(Items.ARROW);

    for (PotionType type : PotionType.REGISTRY) {
        ItemStack input = new ItemStack(Items.LINGERING_POTION);
        PotionUtils.addPotionToItemStack(input, type);

        ItemStack output = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(output, type);

        list.add(new DrawableRecipeCrafting(output, new ItemStack[]{arrow, arrow, arrow, arrow, input, arrow, arrow, arrow, arrow}, 3));
    }
}
 
开发者ID:Creysys,项目名称:GuideBook,代码行数:14,代码来源:RecipeHandlerCrafting.java

示例11: addVanillaBrewingRecipes

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public void addVanillaBrewingRecipes(ArrayList<DrawableRecipe> recipes) {
    ArrayList<ItemStack> ingredients = new ArrayList<ItemStack>();

    ArrayList<Object> typeConversions = ReflectionHelper.getPrivateValue(PotionHelper.class, null, 0);
    ArrayList<Object> itemConversions = ReflectionHelper.getPrivateValue(PotionHelper.class, null, 1);

    addIngredients(ingredients, typeConversions);
    addIngredients(ingredients, itemConversions);

    ArrayList<ItemStack> knownPotions = new ArrayList<ItemStack>();
    ItemStack waterBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
    knownPotions.add(waterBottle);

    int brewingStep = 1;
    boolean foundNewPotions;
    do {
        List<ItemStack> newPotions = getNewPotions(knownPotions, ingredients, recipes);
        foundNewPotions = !newPotions.isEmpty();
        knownPotions.addAll(newPotions);

        brewingStep++;
        if (brewingStep > 100) {
            FMLCommonHandler.instance().raiseException(null, "Calculation of vanilla brewing recipes is broken, aborting after 100 brewing steps.", false);
            return;
        }
    } while (foundNewPotions);
}
 
开发者ID:Creysys,项目名称:GuideBook,代码行数:28,代码来源:RecipeHandlerBrewing.java

示例12: spawnLingeringPotion

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
private void spawnLingeringPotion(EntityPlayer player, PotionType ptype) {
  World world = player.getEntityWorld();
  ItemStack potion = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), ptype);
  EntityPotion entitypotion = new EntityPotion(world, player, potion);
  entitypotion.setHeadingFromThrower(player, player.rotationPitch - 20, player.rotationYaw, 0, 1.6F, 0.5F);
  if (world.isRemote == false) {
    world.spawnEntity(entitypotion);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:10,代码来源:ItemPowerSword.java

示例13: rightClickBlock

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
private void rightClickBlock(BlockPos targetPos) {
  if (rightClickFluidAttempt(targetPos)) {
    return;
  }
  if (world.isAirBlock(targetPos)) {
    return;
  }
  //dont ever place a block. they want to use it on an entity
  EnumActionResult r = fakePlayer.get().interactionManager.processRightClickBlock(fakePlayer.get(), world, fakePlayer.get().getHeldItemMainhand(), EnumHand.MAIN_HAND, targetPos, EnumFacing.UP, .5F, .5F, .5F);
  if (r != EnumActionResult.SUCCESS) {
    //if its a throwable item, it happens on this line down below, the process right click
    r = fakePlayer.get().interactionManager.processRightClick(fakePlayer.get(), world, fakePlayer.get().getHeldItemMainhand(), EnumHand.MAIN_HAND);
    //if throw has happened, success is true
    if (r != EnumActionResult.SUCCESS) {
      ActionResult<ItemStack> res = fakePlayer.get().getHeldItemMainhand().getItem().onItemRightClick(world, fakePlayer.get(), EnumHand.MAIN_HAND);
      if (res == null || res.getType() != EnumActionResult.SUCCESS) {
        //this item onrightclick would/should/could work for GLASS_BOTTLE...except
        //it uses player Ray Trace to get target. which is null for fakes
        //TODO: maybe one solution is to extend FakePlayer to run a rayrace somehow
        //but how to set/manage current lookpos
        //so hakcy time
        if (fakePlayer.get().getHeldItemMainhand().getItem() == Items.GLASS_BOTTLE && world.getBlockState(targetPos).getMaterial() == Material.WATER) {
          ItemStack itemstack = fakePlayer.get().getHeldItemMainhand();
          EntityPlayer p = fakePlayer.get();
          world.playSound(p, p.posX, p.posY, p.posZ, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.NEUTRAL, 1.0F, 1.0F);
          itemstack.shrink(1);
          ItemStack is = new ItemStack(Items.POTIONITEM);
          PotionUtils.addPotionToItemStack(is, PotionTypes.WATER);
          this.tryDumpStacks(Arrays.asList(is));
        }
      }
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:35,代码来源:TileEntityUser.java

示例14: attackEntityWithRangedAttack

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_)
{
    if (!this.isDrinkingPotion())
    {
        double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
        double d1 = target.posX + target.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = target.posZ + target.motionZ - this.posZ;
        float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);
        PotionType potiontype = PotionTypes.HARMING;

        if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
        {
            potiontype = PotionTypes.SLOWNESS;
        }
        else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
        {
            potiontype = PotionTypes.POISON;
        }
        else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
        {
            potiontype = PotionTypes.WEAKNESS;
        }

        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -20.0F;
        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
 
开发者ID:BlazeAxtrius,项目名称:ExpandedRailsMod,代码行数:35,代码来源:EntityWitch.java

示例15: getEmptyPotion

import net.minecraft.potion.PotionUtils; //导入方法依赖的package包/类
public static ItemStack getEmptyPotion(boolean isSplash){
  //in 1.11.2 brewing must start with potiontypes water
  //this was created to mimic vanilla ItemPotion.getDefaultInstance()
  ItemStack res;
  if(isSplash) {
    res = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), PotionTypes.WATER);
  } else {
    res = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
  }
  return res;
}
 
开发者ID:SleepyTrousers,项目名称:EnderZoo,代码行数:12,代码来源:BrewingUtil.java


注:本文中的net.minecraft.potion.PotionUtils.addPotionToItemStack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。