Skip to content

Commit

Permalink
Make items float on water (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 authored and SupremeMortal committed Jul 15, 2018
1 parent d23ab82 commit 55eba56
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/cn/nukkit/entity/item/EntityItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ public boolean onUpdate(int currentTick) {
}
}

this.motionY -= this.getGravity();
if (this.level.getBlockIdAt((int) this.x, (int) this.boundingBox.getMaxY(), (int) this.z) == 8 || this.level.getBlockIdAt((int) this.x, (int) this.boundingBox.getMaxY(), (int) this.z) == 9) { //item is fully in water or in still water
this.motionY -= this.getGravity() * -0.015;
} else if (this.isInsideOfWater()) {
this.motionY = this.getGravity() - 0.06; //item is going up in water, don't let it go back down too fast
} else {
this.motionY -= this.getGravity(); //item is not in water
}

if (this.checkObstruction(this.x, this.y, this.z)) {
hasUpdate = true;
Expand Down

0 comments on commit 55eba56

Please sign in to comment.