Skip to content

Commit

Permalink
Remove duplicate speed effect ID (#1346)
Browse files Browse the repository at this point in the history
* Remove duplicate speed effect ID

Originally, there were 2 speed IDs with different values, one of them being actual speed, and the other being swiftness. I removed the swiftness one & also replaced the swiftness effect initialization with haste.

* Fix level issues

* Change speed to swiftness

* Update speed to swiftness

* Update speed to swiftness
  • Loading branch information
JustTalDevelops authored Apr 16, 2020
1 parent 15d810b commit 4bce2d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/java/cn/nukkit/level/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -1631,8 +1631,8 @@ public Item useBreakOn(Vector3i pos, BlockFace face, Item item, Player player, b
breakTime = 0.15;
}

if (player.hasEffect(Effect.SWIFTNESS)) {
breakTime *= 1 - (0.2 * (player.getEffect(Effect.SWIFTNESS).getAmplifier() + 1));
if (player.hasEffect(Effect.HASTE)) {
breakTime *= 1 - (0.2 * (player.getEffect(Effect.HASTE).getAmplifier() + 1));
}

if (player.hasEffect(Effect.MINING_FATIGUE)) {
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/cn/nukkit/potion/Effect.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
*/
public class Effect implements Cloneable {

public static final int SPEED = 1;
public static final int SWIFTNESS = 1;
public static final int SLOWNESS = 2;
public static final int HASTE = 3;
public static final int SWIFTNESS = 3;
public static final int FATIGUE = 4;
public static final int MINING_FATIGUE = 4;
public static final int STRENGTH = 5;
Expand Down Expand Up @@ -63,9 +62,9 @@ public class Effect implements Cloneable {
public static void init() {
effects = new Effect[256];

effects[Effect.SPEED] = new Effect(Effect.SPEED, "%potion.moveSpeed", 124, 175, 198);
effects[Effect.SWIFTNESS] = new Effect(Effect.SWIFTNESS, "%potion.moveSpeed", 124, 175, 198);
effects[Effect.SLOWNESS] = new Effect(Effect.SLOWNESS, "%potion.moveSlowdown", 90, 108, 129, true);
effects[Effect.SWIFTNESS] = new Effect(Effect.SWIFTNESS, "%potion.digSpeed", 217, 192, 67);
effects[Effect.HASTE] = new Effect(Effect.HASTE, "%potion.digSpeed", 217, 192, 67);
effects[Effect.FATIGUE] = new Effect(Effect.FATIGUE, "%potion.digSlowDown", 74, 66, 23, true);
effects[Effect.STRENGTH] = new Effect(Effect.STRENGTH, "%potion.damageBoost", 147, 36, 35);
effects[Effect.HEALING] = new InstantEffect(Effect.HEALING, "%potion.heal", 248, 36, 35);
Expand Down Expand Up @@ -268,7 +267,7 @@ public void add(BaseEntity entity) {

player.sendPacket(packet);

if (this.id == Effect.SPEED) {
if (this.id == Effect.SWIFTNESS) {
if (oldEffect != null) {
player.setMovementSpeed(player.getMovementSpeed() / (1 + 0.2f * (oldEffect.amplifier + 1)), false);
}
Expand Down Expand Up @@ -303,7 +302,7 @@ public void remove(BaseEntity entity) {

((Player) entity).sendPacket(packet);

if (this.id == Effect.SPEED) {
if (this.id == Effect.SWIFTNESS) {
((Player) entity).setMovementSpeed(((Player) entity).getMovementSpeed() / (1 + 0.2f * (this.amplifier + 1)));
}
if (this.id == Effect.SLOWNESS) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/nukkit/potion/Potion.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static Effect getEffect(int potionType, boolean isSplash) {
case SPEED:
case SPEED_LONG:
case SPEED_II:
effect = Effect.getEffect(Effect.SPEED);
effect = Effect.getEffect(Effect.SWIFTNESS);
break;
case SLOWNESS:
case SLOWNESS_LONG:
Expand Down

0 comments on commit 4bce2d1

Please sign in to comment.