Java Code Examples for net.minecraft.entity.player.EntityPlayer#isPotionActive()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#isPotionActive() .
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: DataHelper.java From GokiStats with MIT License | 6 votes |
public static float getDamageDealt(EntityPlayer player, Entity target, DamageSource source) { float damage = (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue(); float bonusDamage = 0.0F; boolean targetIsLiving = target instanceof EntityLivingBase; boolean critical; ItemStack stack = player.getHeldItemMainhand(); if (targetIsLiving) { bonusDamage = EnchantmentHelper.getModifierForCreature(stack, ((EntityLivingBase) target).getCreatureAttribute()); } if ((damage > 0.0F) || (bonusDamage > 0.0F)) { critical = (player.fallDistance > 0.0F) && (!player.onGround) && (!player.isOnLadder()) && (!player.isInWater()) && (!player.isPotionActive(Potion.getPotionFromResourceLocation("blindness"))) && (player.getRidingEntity() == null) && (targetIsLiving); if ((critical) && (damage > 0.0F)) { damage *= 1.5F; } damage += bonusDamage; } return damage; }
Example 2
Source File: ItemThiefArmor.java From HexxitGear with GNU General Public License v3.0 | 6 votes |
@Override public String getArmorTexture(ItemStack stack, Entity entity, int slot, int layer) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; if (player.isPotionActive(Potion.invisibility)) return "/textures/armor/invisible.png"; } // If the helmet slot, return helmet texture map if (slot == 0) return "/textures/maps/HoodHelmet.png"; if (stack.itemID == HexxitGear.thiefLeggings.itemID) return "/textures/armor/thief2.png"; return "/textures/armor/thief.png"; }
Example 3
Source File: InfernalWandUpdate.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 6 votes |
public void onUpdate(ItemStack itemstack, EntityPlayer player) { if(player.ticksExisted % 100 == 0){ if(player.worldObj.provider.dimensionId == -1){ for(int x = 0;x < primals.length;x++){ if(((ItemWandCasting)itemstack.getItem()).getVis(itemstack, primals[x]) < ((ItemWandCasting)itemstack.getItem()).getMaxVis(itemstack) / 10) { ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, primals[x], 1, true); } } } if(((ItemWandCasting)itemstack.getItem()).getVis(itemstack, Aspect.FIRE) < ((ItemWandCasting)itemstack.getItem()).getMaxVis(itemstack) / 5) { ((ItemWandCasting)itemstack.getItem()).addVis(itemstack, Aspect.FIRE, 1, true); } } if(player.isBurning()) player.extinguish(); if(player.isPotionActive(Potion.wither.id)) { if(player.worldObj.isRemote) player.removePotionEffectClient(Potion.wither.id); else player.removePotionEffect(Potion.wither.id); } }
Example 4
Source File: FMEventHandler.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 6 votes |
@SubscribeEvent public void onEntityUpdate(LivingUpdateEvent event){ if(Compat.bm && event.entityLiving != null && event.entityLiving instanceof EntityPlayer && !event.entityLiving.worldObj.isRemote){ EntityPlayer player = (EntityPlayer)event.entityLiving; String name = player.getDisplayName(); if(player.isPotionActive(DarkPotions.bloodSeal)){ try { if (lastLP.containsKey(name)) { if (SoulNetworkHandler.getCurrentEssence(name) > lastLP.get(name)) SoulNetworkHandler.setCurrentEssence(name, lastLP.get(name)); else lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name)); } else lastLP.put(name, SoulNetworkHandler.getCurrentEssence(name)); } catch(Throwable e){ Compat.bm = false; } } else if(lastLP.containsKey(name)) lastLP.remove(name); } }
Example 5
Source File: WitherProtectionRing.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 6 votes |
@Override public void onWornTick(ItemStack arg0, EntityLivingBase pEntity) { if (!(pEntity instanceof EntityPlayer)) { return; } if (_mRnd.nextInt(20) == 0) { EntityPlayer tPlayer = (EntityPlayer)pEntity; InventoryBaubles tBaubles = PlayerHandler.getPlayerBaubles(tPlayer); //PotionEffect tEff = getNBTPotionEffect(arg0); //int tStoredVictus = GetNBTVictusVis(arg0); /*if (tEff == null || tStoredVictus < 1) { return; } */ Potion tPot = Potion.wither; if (tPlayer.isPotionActive(tPot)) { tPlayer.removePotionEffect(tPot.id); //DamageItem(arg0); } } }
Example 6
Source File: DrinkSoymilkRamune.java From TofuCraftReload with MIT License | 6 votes |
@Override protected void onFoodEaten(ItemStack stack, World worldIn, EntityPlayer player) { if(!worldIn.isRemote){ if(getEffectList()!=null&&getEffectList().length>0){ Random rand = worldIn.rand; PotionEffect effect1 = getEffectList()[rand.nextInt(getEffectList().length)]; if (effect1 != null && effect1.getPotion() != null) { Potion por = effect1.getPotion(); int amp = effect1.getAmplifier(); int dur = effect1.getDuration(); if (player.isPotionActive(effect1.getPotion())) { PotionEffect check = player.getActivePotionEffect(por); dur += check.getDuration(); amp ++; } player.addPotionEffect(new PotionEffect(effect1.getPotion(), dur, amp)); } } } }
Example 7
Source File: ArmorLogicRebreather.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null); if (electricItem.getCharge() >= energyUsagePerTick) { if (player.isInsideOfMaterial(Material.WATER) && world.isRemote && world.getTotalWorldTime() % 20 == 0L) { Vec3d pos = player.getPositionVector().add(new Vec3d(0.0, player.getEyeHeight(), 0.0)); Particle particle = new ParticleBubble.Factory().createParticle(0, world, pos.x, pos.y, pos.z, 0.0, 0.0, 0.0); particle.setMaxAge(Integer.MAX_VALUE); Minecraft.getMinecraft().effectRenderer.addEffect(particle); } if (player.isInsideOfMaterial(Material.WATER) && !player.isPotionActive(MobEffects.WATER_BREATHING)) { if (player.getAir() < 300 && drainActivationEnergy(electricItem)) { player.setAir(Math.min(player.getAir() + 1, 300)); } } } }
Example 8
Source File: VanillaEnhancementsHud.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
private double getArmorPotentional(boolean getProj) { EntityPlayer player = mc.thePlayer; double armor = 0.0; int epf = 0; int resistance = 0; if (player.isPotionActive(Potion.resistance)) { resistance = player.getActivePotionEffect(Potion.resistance).getAmplifier() + 1; } for (ItemStack stack : player.inventory.armorInventory) { if (stack != null) { if (stack.getItem() instanceof ItemArmor) { ItemArmor armorItem = (ItemArmor) stack.getItem(); armor += armorItem.damageReduceAmount * 0.04; } if (stack.isItemEnchanted()) { epf += getEffProtPoints(EnchantmentHelper.getEnchantmentLevel(0, stack)); } if (getProj && stack.isItemEnchanted()) { epf += getEffProtPoints(EnchantmentHelper.getEnchantmentLevel(4, stack)); } } } epf = (Math.min(epf, 25)); double avgDef = addArmorProtResistance(armor, calcProtection(epf), resistance); return roundDouble(avgDef * 100.0); }
Example 9
Source File: GTItemSpringBoots.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void onArmorTick(World world, EntityPlayer player, ItemStack stack) { Potion jump = MobEffects.JUMP_BOOST; if (!player.isPotionActive(jump)) { player.addPotionEffect(new PotionEffect(jump, 10, 2, false, false)); } if (player.onGround && player.isSprinting()) { player.jump(); player.playSound(GTSounds.SPRING, 1.0F, 1.0F + world.rand.nextFloat()); if (world.rand.nextInt(2) == 0) { stack.damageItem(1, player); } } }
Example 10
Source File: PotionCannon.java From Sakura_mod with MIT License | 5 votes |
@SubscribeEvent public void onAttacking(ArrowLooseEvent event) { EntityPlayer player = event.getEntityPlayer(); if(player.isPotionActive(this)){ event.setCharge(event.getCharge()+player.getActivePotionEffect(this).getAmplifier()*25); event.setResult(Result.ALLOW); } }
Example 11
Source File: EntityLivingHandler.java From TFC2 with GNU General Public License v3.0 | 5 votes |
public void setThirsty(EntityPlayer player, boolean b) { if (b) { player.setSprinting(false); if(!player.isPotionActive(PotionTFC.THIRST_POTION)) player.addPotionEffect(new PotionEffect(PotionTFC.THIRST_POTION, Integer.MAX_VALUE, 0, false, false)); } else { player.removePotionEffect(PotionTFC.THIRST_POTION); } }
Example 12
Source File: PotionExp.java From Sakura_mod with MIT License | 5 votes |
@SubscribeEvent public void onDropExp(LivingExperienceDropEvent event) { if(event.getAttackingPlayer()!=null){ EntityPlayer player = event.getAttackingPlayer(); if(player.isPotionActive(this)){ int exp =(event.getOriginalExperience()/2)*player.getActivePotionEffect(this).getAmplifier(); event.setDroppedExperience(event.getOriginalExperience()+exp); } } }
Example 13
Source File: PotionAttackPotion.java From Sakura_mod with MIT License | 5 votes |
@SubscribeEvent public void onAttacking(AttackEntityEvent event) { if(event.getTarget() instanceof EntityLivingBase){ EntityLivingBase target = (EntityLivingBase) event.getTarget(); EntityPlayer player = event.getEntityPlayer(); if(player.isPotionActive(this)){ target.addPotionEffect(new PotionEffect(potion,lvl*300, lvl)); } } }
Example 14
Source File: PotionFire.java From Sakura_mod with MIT License | 5 votes |
@SubscribeEvent public void onAttacking(AttackEntityEvent event) { if(event.getTarget() instanceof EntityLivingBase){ EntityLivingBase target = (EntityLivingBase) event.getTarget(); EntityPlayer player = event.getEntityPlayer(); if(player.isPotionActive(this)){ target.setFire(600); } } }
Example 15
Source File: OvenGlove.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 4 votes |
private boolean isResistActive ( EntityPlayer tPlayer ) { return tPlayer.isPotionActive(Potion.fireResistance.id); }
Example 16
Source File: EventHandlerRedirect.java From Gadomancy with GNU Lesser General Public License v3.0 | 4 votes |
public static int getAdditionalVisDiscount(EntityPlayer player, Aspect aspect, int currentTotalDiscount) { if(player.isPotionActive(RegisteredPotions.VIS_DISCOUNT)) { currentTotalDiscount += (player.getActivePotionEffect(RegisteredPotions.VIS_DISCOUNT).getAmplifier() + 1) * 8; } return currentTotalDiscount; }
Example 17
Source File: EntityLivingHandler.java From TFC2 with GNU General Public License v3.0 | 4 votes |
public void updateEncumb(EntityPlayer player) { float encumb = Core.getEncumbrance(player.inventory.mainInventory) / 80f; if(encumb >= 1.0) { if(player.isPotionActive(PotionTFC.ENCUMB_HEAVY_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_HEAVY_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_MEDIUM_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_MEDIUM_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_MAX_POTION)) return; player.addPotionEffect(new PotionEffect(PotionTFC.ENCUMB_MAX_POTION, Integer.MAX_VALUE, 0, false, false)); } else if(encumb >= 0.75) { if(player.isPotionActive(PotionTFC.ENCUMB_MAX_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_MAX_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_MEDIUM_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_MEDIUM_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_HEAVY_POTION)) return; player.addPotionEffect(new PotionEffect(PotionTFC.ENCUMB_HEAVY_POTION, Integer.MAX_VALUE, 0, false, false)); } else if(encumb >= 0.5) { if(player.isPotionActive(PotionTFC.ENCUMB_MAX_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_MAX_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_HEAVY_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_HEAVY_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_MEDIUM_POTION)) return; player.addPotionEffect(new PotionEffect(PotionTFC.ENCUMB_MEDIUM_POTION, Integer.MAX_VALUE, 0, false, false)); } else { if(player.isPotionActive(PotionTFC.ENCUMB_MAX_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_MAX_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_HEAVY_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_HEAVY_POTION); if(player.isPotionActive(PotionTFC.ENCUMB_MEDIUM_POTION)) player.removeActivePotionEffect(PotionTFC.ENCUMB_MEDIUM_POTION); } }