Skip to content

Commit 55eba56

Browse files
PetteriM1SupremeMortal
authored andcommitted
Make items float on water (#265)
1 parent d23ab82 commit 55eba56

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/cn/nukkit/entity/item/EntityItem.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@ public boolean onUpdate(int currentTick) {
152152
}
153153
}
154154

155-
this.motionY -= this.getGravity();
155+
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
156+
this.motionY -= this.getGravity() * -0.015;
157+
} else if (this.isInsideOfWater()) {
158+
this.motionY = this.getGravity() - 0.06; //item is going up in water, don't let it go back down too fast
159+
} else {
160+
this.motionY -= this.getGravity(); //item is not in water
161+
}
156162

157163
if (this.checkObstruction(this.x, this.y, this.z)) {
158164
hasUpdate = true;

0 commit comments

Comments
 (0)