Java Code Examples for net.minecraft.potion.PotionUtils#addPotionToItemStack()
The following examples show how to use
net.minecraft.potion.PotionUtils#addPotionToItemStack() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityMage.java From ToroQuest with GNU General Public License v3.0 | 6 votes |
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.shoot(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); }
Example 2
Source File: GlassBottleFluidHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
private int fillImpl(FluidStack resource, boolean doFill) { PotionType potionType = PotionFluids.getPotionForFluid(resource.getFluid()); if (potionType != null && potionType != PotionTypes.EMPTY && resource.amount >= PotionFluids.POTION_ITEM_FLUID_AMOUNT) { if(doFill) { this.itemStack = new ItemStack(Items.POTIONITEM); PotionUtils.addPotionToItemStack(itemStack, potionType); } return PotionFluids.POTION_ITEM_FLUID_AMOUNT; } return 0; }
Example 3
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
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; }
Example 4
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static ItemStack createWitherPotion(boolean isProlonged, boolean isSplash) { ItemStack res = getEmptyPotion(isSplash); if(isProlonged) { PotionUtils.addPotionToItemStack(res, EnderZoo.potions.getWitheringLong()); } else { PotionUtils.addPotionToItemStack(res, EnderZoo.potions.getWithering()); } return res; }
Example 5
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static ItemStack createHealthPotion(boolean isProlonged, boolean isAugmented, boolean isSplash) { ItemStack res = getEmptyPotion(isSplash); if(isProlonged || isAugmented) { PotionUtils.addPotionToItemStack(res, PotionTypes.STRONG_HEALING); } else { PotionUtils.addPotionToItemStack(res, PotionTypes.HEALING); } return res; }
Example 6
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
public static ItemStack createRegenerationPotion(boolean isProlonged, boolean isAugmented, boolean isSplash) { ItemStack res = getEmptyPotion(isSplash); if(isAugmented) { PotionUtils.addPotionToItemStack(res, PotionTypes.STRONG_REGENERATION); } else if(isProlonged) { PotionUtils.addPotionToItemStack(res, PotionTypes.LONG_REGENERATION); } else { PotionUtils.addPotionToItemStack(res, PotionTypes.REGENERATION); } return res; }
Example 7
Source File: RecipeMapBrewer.java From GregTech with GNU Lesser General Public License v3.0 | 4 votes |
@Nullable @Override public Recipe findRecipe(long voltage, List<ItemStack> inputs, List<FluidStack> fluidInputs, int outputFluidTankCapacity) { Recipe recipe = super.findRecipe(voltage, inputs, fluidInputs, outputFluidTankCapacity); if (recipe != null || GTUtility.amountOfNonNullElements(fluidInputs) < 1 || GTUtility.amountOfNonEmptyStacks(inputs) < 1) { return recipe; } ItemStack ingredientStack = inputs.get(0); FluidStack potionFluid = fluidInputs.get(0); PotionType potionType = PotionFluids.getPotionForFluid(potionFluid.getFluid()); if (potionType == null || potionFluid.amount < POTION_PER_INGREDIENT) { return null; //do not return recipes if not enough fluid or fluid doesn't match } ItemStack potionStack = new ItemStack(Items.POTIONITEM); PotionUtils.addPotionToItemStack(potionStack, potionType); ItemStack resultStack = BrewingRecipeRegistry.getOutput(potionStack, ingredientStack); if (resultStack.isEmpty() || resultStack.getItem() != Items.POTIONITEM) { return null; //if no recipe matches, or output is not a simple potion, return null } PotionType resultingType = PotionUtils.getPotionFromItem(resultStack); if (resultingType == null || resultingType == PotionTypes.EMPTY) { return null; //if output is not a simple potion or empty potion, return null } Fluid outputFluid = PotionFluids.getFluidForPotion(resultingType); if(outputFluid == null) { return null; } //otherwise, return recipe for fluid potion + ingredient -> new fluid potion return recipeBuilder() .inputs(new CountableIngredient(new NBTIngredient(ingredientStack), 1)) //we can reuse recipe only if ingredient fully matches, //because IBrewingRecipe logic is totally implementation-dependent and can easily depend on NBT for some recipes .fluidInputs(GTUtility.copyAmount(POTION_PER_INGREDIENT, potionFluid)) .fluidOutputs(new FluidStack(outputFluid, POTION_PER_INGREDIENT)) .build().getResult(); }
Example 8
Source File: PotionRecipeHelper.java From NotEnoughItems with MIT License | 4 votes |
public static void addNormalRecipe(Item potionItem, PotionType input, Ingredient ingredient, PotionType output) { IPotionRecipe recipe = new PotionTypeRecipe(PotionUtils.addPotionToItemStack(new ItemStack(potionItem), input), ingredient, output); normalRecipes.add(recipe); allRecipes.add(recipe); }
Example 9
Source File: PotionRecipeHelper.java From NotEnoughItems with MIT License | 4 votes |
public static void addSplashRecipe(Item potionItem, PotionType input, Ingredient ingredient, PotionType output) { IPotionRecipe recipe = new PotionTypeRecipe(PotionUtils.addPotionToItemStack(new ItemStack(potionItem), input), ingredient, output); splashRecipes.add(recipe); allRecipes.add(recipe); }
Example 10
Source File: PotionRecipeHelper.java From NotEnoughItems with MIT License | 4 votes |
public static void addLingeringRecipe(Item potionItem, PotionType input, Ingredient ingredient, PotionType output) { IPotionRecipe recipe = new PotionTypeRecipe(PotionUtils.addPotionToItemStack(new ItemStack(potionItem), input), ingredient, output); lingeringRecipes.add(recipe); allRecipes.add(recipe); }
Example 11
Source File: PotionTypeRecipe.java From NotEnoughItems with MIT License | 4 votes |
public PotionTypeRecipe(ItemStack input, Ingredient ingredient, PotionType outputType) { this.ingredient = ingredient; this.input = input.copy(); this.output = PotionUtils.addPotionToItemStack(input, outputType); }
Example 12
Source File: BrewingUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
public static ItemStack createHarmingPotion(boolean isAugmented, boolean isSplash) { ItemStack res = getEmptyPotion(isSplash); PotionUtils.addPotionToItemStack(res, PotionTypes.HARMING); return res; }