Java Code Examples for net.minecraft.entity.player.EntityPlayer.isPotionActive()
The following are Jave code examples for showing how to use
isPotionActive() of the
net.minecraft.entity.player.EntityPlayer
class.
You can vote up the examples you like. Your votes will be used in our system to get
more good examples.
+ Save this method
Example 1
Project: FirstAid File: ArmorUtils.java View Source Code | 6 votes |
/** * Changed copy of the first part from {@link EnchantmentHelper#applyEnchantmentModifier(EnchantmentHelper.IModifier, ItemStack)} */ public static float applyGlobalPotionModifiers(EntityPlayer player, DamageSource source, float damage) { if (source.isDamageAbsolute()) return damage; if (player.isPotionActive(MobEffects.RESISTANCE) && source != DamageSource.OUT_OF_WORLD) { @SuppressWarnings("ConstantConditions") int i = (player.getActivePotionEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int j = 25 - i; float f = damage * (float) j; damage = f / 25.0F; } if (damage <= 0.0F) return 0.0F; return damage; }
Example 2
Project: TextDisplayer File: ServerParser.java View Source Code | 5 votes |
public String getPlayerCount() { if (mc.theWorld == null) return "0"; int players = 0; for (EntityPlayer player : mc.theWorld.playerEntities) { if (!player.isInvisibleToPlayer(mc.thePlayer) && !player.isPotionActive(14) && player.getUniqueID().toString().charAt(14) == '4') { players += 1; } } return String.valueOf(players); }
Example 3
Project: Lanolin File: EventHandlerCommon.java View Source Code | 4 votes |
@SubscribeEvent public void breakSpeed(PlayerEvent.BreakSpeed event){ // Check if the break speed has been modified due to water // prevent the modification if there is lanolin on the tool being used // decrement the lanolin when the block is successfully broken EntityPlayer player = event.getEntityPlayer(); IBlockState state = event.getState(); BlockPos pos = event.getPos(); if(player.isInsideOfMaterial(Material.WATER)) { //Player is inside water, check for lanolin if(player.getHeldItemMainhand().hasTagCompound() && player.getHeldItemMainhand().getTagCompound().hasKey("lanolin")){ // Recalculate ala EntityPlayer.getDigSpeed(), but skip the water portion float f = player.inventory.getStrVsBlock(state); if (f > 1.0F) { int i = EnchantmentHelper.getEfficiencyModifier(player); ItemStack itemstack = player.getHeldItemMainhand(); if (i > 0 && !itemstack.isEmpty()) { f += (float)(i * i + 1); } } if (player.isPotionActive(MobEffects.HASTE)) { f *= 1.0F + (float)(player.getActivePotionEffect(MobEffects.HASTE).getAmplifier() + 1) * 0.2F; } if (player.isPotionActive(MobEffects.MINING_FATIGUE)) { float f1; switch (player.getActivePotionEffect(MobEffects.MINING_FATIGUE).getAmplifier()) { case 0: f1 = 0.3F; break; case 1: f1 = 0.09F; break; case 2: f1 = 0.0027F; break; case 3: default: f1 = 8.1E-4F; } f *= f1; } if(f > event.getNewSpeed()){ event.setNewSpeed(f < 0 ? 0 : f); } } } }