From 55eba5640417b9be6f400b13ca45d8ca802145b1 Mon Sep 17 00:00:00 2001 From: Petteri Date: Sun, 15 Jul 2018 13:41:53 +0300 Subject: [PATCH] Make items float on water (#265) --- src/main/java/cn/nukkit/entity/item/EntityItem.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/cn/nukkit/entity/item/EntityItem.java b/src/main/java/cn/nukkit/entity/item/EntityItem.java index 00845421318..76656002f0a 100644 --- a/src/main/java/cn/nukkit/entity/item/EntityItem.java +++ b/src/main/java/cn/nukkit/entity/item/EntityItem.java @@ -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;