/** * Removes existing modifiers * * @param att Attribute * @param uuid UUID of modifier to remove */ private static void rmMod(IAttributeInstance att, UUID uuid) { AttributeModifier m = att.getModifier(uuid); if (m != null) { att.removeModifier(m); } } }
private void removeModifiers() { horse.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(moveSpeedModifier); horse.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).removeModifier(followRangeModifier); }
public static @Nullable IAttributeInstance removeModifier(@Nonnull EntityLivingBase ent, @Nonnull IAttribute p, @Nonnull UUID u) { IAttributeInstance att = ent.getEntityAttribute(p); AttributeModifier curmod = att.getModifier(u); if (curmod != null) { att.removeModifier(curmod); } return att; }
@Override public void onDisable(EntityTameableDragon dragon) { dragon.getAttributeMap().getAttributeInstance(EntityTameableDragon.MOVEMENT_SPEED_AIR).removeModifier(MODIFIER); }
@Override public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player) { if (player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).hasModifier(SPEED_BOOST)) { player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(SPEED_BOOST); } return true; }
@Override public boolean onDroppedByPlayer(ItemStack item, EntityPlayer player) { if (player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).hasModifier(SPEED_BOOST)) { player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(SPEED_BOOST); } return true; }
private void removeBadExoBoost(EntityLivingBase entity) { if (entity.ticksExisted % 20 == 0) { if (entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getModifier(uuid2) != null) { entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(exoBoostBad); } if (entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).getModifier(uuid2) != null) { entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).removeModifier(exoBoostBad); } } }
private void manageHasPower() { IAttributeInstance speed = player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (speed.getModifier(outOfPowerSpeedModifier.getID()) != null) { speed.removeModifier(outOfPowerSpeedModifier); } }
private static boolean clearModifiers(@Nonnull EntityPlayer player) { IAttributeInstance moveInst = player.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MOVEMENT_SPEED); UUID uuid = DarkSteelAttributeModifiers.getWalkSpeed(false, 1, 0).getID(); AttributeModifier modifier = moveInst.getModifier(uuid); if (modifier != null) { moveInst.removeModifier(modifier); return true; } return false; }
public void setChild (boolean isChild) { this.getDataManager().set(IS_CHILD, Boolean.valueOf(isChild)); if (this.world != null && !this.world.isRemote) { final IAttributeInstance speed = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); speed.removeModifier(BABY_SPEED_BOOST); if (isChild) { speed.applyModifier(BABY_SPEED_BOOST); } } this.setChildSize(isChild); } }
@Override public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn) { super.setAttackTarget(entitylivingbaseIn); IAttributeInstance iattributeinstance = getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (entitylivingbaseIn == null) { targetChangeTime = 0; this.dataManager.set(SCREAMING, Boolean.valueOf(false)); iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST); } else { targetChangeTime = ticksExisted; this.dataManager.set(SCREAMING, Boolean.valueOf(true)); if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) { iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST); } } }
@Override public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn) { super.setAttackTarget(entitylivingbaseIn); IAttributeInstance iattributeinstance = getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (entitylivingbaseIn == null) { targetChangeTime = 0; this.dataManager.set(SCREAMING, Boolean.valueOf(false)); iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST); } else { targetChangeTime = ticksExisted; this.dataManager.set(SCREAMING, Boolean.valueOf(true)); if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST)) { iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST); } } }
/** * Resets the task */ @Override public void resetTask() { targetPlayer = null; enderminy.setScreaming(false); IAttributeInstance iattributeinstance = enderminy.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); iattributeinstance.removeModifier(EntityEnderminy.getAttackingspeedboostmodifier()); super.resetTask(); }
private void applyScaleModifier(IAttribute attribute) { IAttributeInstance instance = dragon.getEntityAttribute(attribute); AttributeModifier oldModifier = instance.getModifier(DragonScaleModifier.ID); if (oldModifier != null) { instance.removeModifier(oldModifier); } instance.applyModifier(new DragonScaleModifier(getScale())); }
public static void setMaxHealth(EntityLivingBase living, double max) { IAttributeInstance healthAttribute = living.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); double amount = max - healthAttribute.getBaseValue(); AttributeModifier modifier = healthAttribute.getModifier(HEALTH_MODIFIER_ID); // Need to remove modifier to apply a new one if (modifier != null) { healthAttribute.removeModifier(modifier); } // Operation 0 is a flat increase modifier = new AttributeModifier(HEALTH_MODIFIER_ID, HEALTH_MODIFIER_NAME, amount, 0); healthAttribute.applyModifier(modifier); }
private void removeGoodExoBoost(EntityLivingBase entity) { if (entity.ticksExisted % 20 == 0) { if (entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getModifier(uuid) != null) { entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(exoBoost); } if (entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).getModifier(uuid) != null) { entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).removeModifier(exoBoost); } if (entity instanceof EntityPlayer) { PlayerData tag = entity.getCapability(EsteemedInnovation.PLAYER_DATA, null); if (tag.getPreviousStepHeight() != null) { entity.stepHeight = tag.getPreviousStepHeight(); tag.setPreviousStepHeight(null); } } } }
@Override public void onPlayerTick(TickEvent.PlayerTickEvent event, @Nonnull ItemStack armorStack, EntityEquipmentSlot slot) { EntityPlayer player = event.player; IAttributeInstance attributes = player.getEntityAttribute(MOVEMENT_SPEED); AttributeModifier modifierFromAttributes = attributes.getModifier(modifierID); if (canWalkOnFluid(player, modifierFromAttributes)) { beforeFluidWalk(player); IBlockState underState = EntityHelper.getBlockUnderEntity(player); if (underState.getMaterial() == requiredMaterial) { handleFluidWalk(player, attributes); } afterFluidWalk(player); } else { attributes.removeModifier(modifier); } }
/** * Remove healthmodifier by name. * @param modifierName Name of the modifier to remove, see e.g. GUARD_HEALTH_MOD_LEVEL_NAME */ public void removeHealthModifier(final String modifierName) { for (final AttributeModifier mod : getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getModifiers()) { if (mod.getName().equals(modifierName)) { getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).removeModifier(mod); } } if (getHealth() > getMaxHealth()) { setHealth(getMaxHealth()); } }
/** * Remove all healthmodifiers from a citizen */ public void removeAllHealthModifiers() { for (final AttributeModifier mod : getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getModifiers()) { getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).removeModifier(mod); } if (getHealth() > getMaxHealth()) { setHealth(getMaxHealth()); } }
private void setModifier(EntityPlayer player, boolean enabled) { if (enabled) { IAttributeInstance health = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); if (health.getModifier(healthModifierUUID) == null) { health.applyModifier(new AttributeModifier(healthModifierUUID, "Bat Health Reduction", -0.9, 2).setSaved(false)); } player.capabilities.allowFlying = true; player.capabilities.isFlying = true; setFlightSpeed(player, (float) Balance.vpa.BAT_FLIGHT_SPEED); player.sendPlayerAbilities(); } else { // Health modifier IAttributeInstance health = player.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); AttributeModifier m = health.getModifier(healthModifierUUID); if (m != null) { health.removeModifier(m); } if (!player.capabilities.isCreativeMode) { player.capabilities.allowFlying = false; } player.capabilities.isFlying = false; setFlightSpeed(player, 0.05F); player.sendPlayerAbilities(); } }