1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| public class FrostEffect extends StatusEffect { private static final int DAMAGE_INTERVAL_TICKS = 60;
protected FrostEffect(StatusEffectCategory category, int color) { super(category, color); }
@Override public boolean canApplyUpdateEffect(int duration, int amplifier) { return true; }
@Override public void applyUpdateEffect(LivingEntity entity, int amplifier) { World world = entity.getWorld(); StatusEffectInstance effect = entity.getStatusEffect(this); if (effect != null && effect.getDuration() % DAMAGE_INTERVAL_TICKS == 0) { entity.damage(entity.getDamageSources().magic(), 2.0f + amplifier); }
this.addAttributeModifier( EntityAttributes.GENERIC_MOVEMENT_SPEED, "662A6B8D-DA3E-4C1C-8813-96EA6097278D", -0.20f * (amplifier + 1), EntityAttributeModifier.Operation.MULTIPLY_TOTAL );
if (world.isClient) { Random random = world.getRandom(); if (random.nextFloat() < 0.3f) { double px = entity.getX(); double py = entity.getY() + entity.getHeight() * 0.5; double pz = entity.getZ(); double vx = MathHelper.nextBetween(random, -0.05f, 0.05f); double vy = 0.05f; double vz = MathHelper.nextBetween(random, -0.05f, 0.05f);
world.addParticle(ParticleTypes.SNOWFLAKE, px, py, pz, vx, vy, vz); } }
entity.setInPowderSnow(true);
if (!world.isClient && entity.isOnFire()) { entity.setOnFire(false); } } }
|