/** * 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); } } }
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; }
private void manageHasPower() { IAttributeInstance speed = player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (speed.getModifier(outOfPowerSpeedModifier.getID()) != null) { speed.removeModifier(outOfPowerSpeedModifier); } }
public static double getMaxHealth(EntityLivingBase living) { IAttributeInstance healthAttribute = living.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH); double maxHealth = healthAttribute.getBaseValue(); AttributeModifier modifier = healthAttribute.getModifier(HEALTH_MODIFIER_ID); if (modifier != null) { maxHealth += modifier.getAmount(); } return maxHealth; }
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 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 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 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())); }
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); } }
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(); } }
private void manageOutOfPower() { IAttributeInstance speed = player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED); if (speed.getModifier(outOfPowerSpeedModifier.getID()) == null) { speed.applyModifier(outOfPowerSpeedModifier); } if (player.world.getWorldTime() % 60 == 0) { androidEffects.updateEffect(EFFECT_GLITCH_TIME, 5); playGlitchSound(this, player.getRNG(), 0.2f); } }
tag.setLastMotions(Pair.of(entity.posX, entity.posZ)); 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); stack.getTagCompound().setInteger("TicksUntilSteamDrain", ticksLeft); if (armor == 4) { if (entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getModifier(uuid) == null) { entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).applyModifier(exoBoost); if (entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).getModifier(uuid) == null) { entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(exoBoost); if (entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getModifier(uuid2) == null) { entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).applyModifier(exoBoostBad); if (entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).getModifier(uuid2) == null) { entity.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).applyModifier(exoBoostBad);