use of net.minecraft.entity.attribute.EntityAttributeInstance in project EnvironmentZ by Globox1997.
the class ColdEffect method onApplied.
@Override
public void onApplied(LivingEntity entity, AttributeContainer attributes, int amplifier) {
EntityAttributeInstance entityAttributeInstance = attributes.getCustomInstance((EntityAttributes.GENERIC_MOVEMENT_SPEED));
if (entityAttributeInstance != null) {
EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(this.getTranslationKey(), -0.15D, EntityAttributeModifier.Operation.MULTIPLY_TOTAL);
entityAttributeInstance.removeModifier(entityAttributeModifier);
entityAttributeInstance.addPersistentModifier(new EntityAttributeModifier(COLDNESS, this.getTranslationKey() + " " + entityAttributeModifier.getValue(), this.adjustModifierAmount(amplifier, entityAttributeModifier), entityAttributeModifier.getOperation()));
}
}
use of net.minecraft.entity.attribute.EntityAttributeInstance in project EnvironmentZ by Globox1997.
the class OverheatingEffect method onApplied.
@Override
public void onApplied(LivingEntity entity, AttributeContainer attributes, int amplifier) {
EntityAttributeInstance entityAttributeInstance = attributes.getCustomInstance((EntityAttributes.GENERIC_MOVEMENT_SPEED));
if (entityAttributeInstance != null) {
EntityAttributeModifier entityAttributeModifier = new EntityAttributeModifier(this.getTranslationKey(), -0.15D, EntityAttributeModifier.Operation.MULTIPLY_TOTAL);
entityAttributeInstance.removeModifier(entityAttributeModifier);
entityAttributeInstance.addPersistentModifier(new EntityAttributeModifier(DEHYDRATION, this.getTranslationKey() + " " + entityAttributeModifier.getValue(), this.adjustModifierAmount(0, entityAttributeModifier), entityAttributeModifier.getOperation()));
}
}
use of net.minecraft.entity.attribute.EntityAttributeInstance in project bewitchment by MoriyaShiine.
the class PlayerEntityMixin method tick.
@Inject(method = "tick", at = @At("TAIL"))
private void tick(CallbackInfo callbackInfo) {
if (!world.isClient) {
boolean shouldHave = BewitchmentAPI.getFamiliar((PlayerEntity) (Object) this) == EntityType.WOLF;
EntityAttributeInstance armorAttribute = getAttributeInstance(EntityAttributes.GENERIC_ARMOR);
EntityAttributeInstance armorToughnessAttribute = getAttributeInstance(EntityAttributes.GENERIC_ARMOR_TOUGHNESS);
if (shouldHave && !armorAttribute.hasModifier(WOLF_FAMILIAR_ARMOR_MODIFIER)) {
armorAttribute.addPersistentModifier(WOLF_FAMILIAR_ARMOR_MODIFIER);
armorToughnessAttribute.addPersistentModifier(WOLF_FAMILIAR_ARMOR_TOUGHNESS_MODIFIER);
} else if (!shouldHave && armorAttribute.hasModifier(WOLF_FAMILIAR_ARMOR_MODIFIER)) {
armorAttribute.removeModifier(WOLF_FAMILIAR_ARMOR_MODIFIER);
armorToughnessAttribute.removeModifier(WOLF_FAMILIAR_ARMOR_TOUGHNESS_MODIFIER);
}
}
}
use of net.minecraft.entity.attribute.EntityAttributeInstance in project Biome-Makeover by Lemonszz.
the class BMEnchantment method addAttributes.
public boolean addAttributes(LivingEntity entity, ItemStack stack, EquipmentSlot slot, int level) {
if (attributeModifiers.size() <= 0 || stack.isEmpty())
return false;
for (Map.Entry<EntityAttribute, EntityAttributeModifier> attributeEntry : this.attributeModifiers.entrySet()) {
UUID id = MathUtils.uuidFromString(slot.toString());
EntityAttributeInstance entityAttributeInstance = entity.getAttributes().getCustomInstance(attributeEntry.getKey());
if (entityAttributeInstance != null) {
EntityAttributeModifier mod = attributeEntry.getValue();
entityAttributeInstance.removeModifier(mod);
entityAttributeInstance.addTemporaryModifier(new EntityAttributeModifier(id, this.getTranslationKey() + " " + level, this.adjustModifierAmount(level, mod), mod.getOperation()));
}
}
return true;
}
use of net.minecraft.entity.attribute.EntityAttributeInstance in project Biome-Makeover by Lemonszz.
the class WitchEntityMixin method tickMovement.
@Inject(at = @At("TAIL"), method = "tickMovement")
public void tickMovement(CallbackInfo cbi) {
if (!isDrinking()) {
if (random.nextFloat() < 0.10) {
boolean found = false;
for (StatusEffectInstance effect : getStatusEffects()) if (((StatusEffectAccess) effect.getEffectType()).bm_getType() == StatusEffectType.HARMFUL) {
found = true;
break;
}
if (found) {
this.equipStack(EquipmentSlot.MAINHAND, PotionUtil.setPotion(new ItemStack(Items.POTION), BMPotions.ANTIDOTE_POT));
this.drinkTimeLeft = this.getMainHandStack().getMaxUseTime();
this.setDrinking(true);
if (!this.isSilent()) {
this.world.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F);
}
EntityAttributeInstance entityAttributeInstance = this.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
entityAttributeInstance.removeModifier(DRINKING_SPEED_PENALTY_MODIFIER);
entityAttributeInstance.addTemporaryModifier(DRINKING_SPEED_PENALTY_MODIFIER);
}
}
}
}
Aggregations