From 763c7a28938a5148f65602e40e7e6616ec1c6dff Mon Sep 17 00:00:00 2001 From: Pub4Game Date: Wed, 27 Jan 2016 20:43:44 +0400 Subject: [PATCH] fix effect --- src/main/java/cn/nukkit/entity/Effect.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/cn/nukkit/entity/Effect.java b/src/main/java/cn/nukkit/entity/Effect.java index e7a1b4d8b6..d04242e044 100644 --- a/src/main/java/cn/nukkit/entity/Effect.java +++ b/src/main/java/cn/nukkit/entity/Effect.java @@ -187,7 +187,7 @@ public boolean canTick() { return true; case Effect.SPEED: case Effect.SLOWNESS: - return true; + return (this.duration % 20) == 0; } return false; } @@ -247,6 +247,14 @@ public void add(Entity entity, boolean modify) { } ((Player) entity).dataPacket(pk); + + if (this.id == Effect.SPEED) { + ((Player) entity).setMovementSpeed(0.1f + (this.amplifier + 1) * 0.01f); + } + + if (this.id == Effect.SLOWNESS) { + ((Player) entity).setMovementSpeed(0.1f - (this.amplifier + 1) * 0.01f); + } } if (this.id == Effect.INVISIBILITY) { @@ -263,6 +271,10 @@ public void remove(Entity entity) { pk.eventId = MobEffectPacket.EVENT_REMOVE; ((Player) entity).dataPacket(pk); + + if (this.id == Effect.SPEED || this.id == Effect.SLOWNESS) { + ((Player) entity).setMovementSpeed(0.1f); + } } if (this.id == Effect.INVISIBILITY) {