The method EntityPlayer.addPotionEffect() is used to apply a potion effect to a player entity in Minecraft. This method takes in an instance of the PotionEffect class, which contains a reference to the type of potion effect to apply and its duration and potency.
Example 1:
In this example, we are applying a potion effect of strength to the player entity for 1 minute with a potency of 2.
EntityPlayer player = ... ; // Get player entity PotionEffect strengthEffect = new PotionEffect(Potion.getPotionById(5), 1200, 2); // Create strength effect player.addPotionEffect(strengthEffect); // Apply effect to player
Example 2:
In this example, we are applying a potion effect of regeneration to the player entity for 10 seconds with a potency of 1.
EntityPlayer player = ... ; // Get player entity PotionEffect regenEffect = new PotionEffect(Potion.regeneration, 200, 1); // Create regeneration effect player.addPotionEffect(regenEffect); // Apply effect to player
The package library for this method is net.minecraft.entity.player.
Java EntityPlayer.addPotionEffect - 30 examples found. These are the top rated real world Java examples of net.minecraft.entity.player.EntityPlayer.addPotionEffect extracted from open source projects. You can rate examples to help us improve the quality of examples.