mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-17 08:05:25 +01:00
Re-fix the breaking of a block just below the player
This commit is contained in:
parent
6c301ff205
commit
c3b1e88b83
@ -329,17 +329,6 @@ public class InstanceContainer extends Instance {
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
final boolean solid = Block.fromStateId(blockStateId).isSolid();
|
||||
if (solid) {
|
||||
final BlockPosition playerBlockPosition = player.getPosition().toBlockPosition();
|
||||
|
||||
// Teleport the player back if he broke a solid block just below him
|
||||
if (playerBlockPosition.subtract(0, 1, 0).equals(blockPosition)) {
|
||||
player.teleport(player.getPosition());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allowed;
|
||||
@ -353,7 +342,7 @@ public class InstanceContainer extends Instance {
|
||||
if (callback != null)
|
||||
callback.accept(chunk);
|
||||
} else {
|
||||
// Retrieve chunk from somewhere else (file or create a new use using the ChunkGenerator)
|
||||
// Retrieve chunk from somewhere else (file or create a new one using the ChunkGenerator)
|
||||
retrieveChunk(chunkX, chunkZ, callback);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import net.minestom.server.item.StackingRule;
|
||||
import net.minestom.server.network.packet.client.play.ClientPlayerDiggingPacket;
|
||||
import net.minestom.server.network.packet.server.play.AcknowledgePlayerDiggingPacket;
|
||||
import net.minestom.server.network.packet.server.play.EntityEffectPacket;
|
||||
import net.minestom.server.network.packet.server.play.PlayerPositionAndLookPacket;
|
||||
import net.minestom.server.potion.PotionType;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
|
||||
@ -132,6 +133,22 @@ public class PlayerDiggingListener {
|
||||
// Send acknowledge packet to allow or cancel the digging process
|
||||
sendAcknowledgePacket(player, blockPosition, updatedBlockId,
|
||||
status, result);
|
||||
|
||||
if (!result) {
|
||||
final boolean solid = Block.fromStateId((short) blockStateId).isSolid();
|
||||
if (solid) {
|
||||
final BlockPosition playerBlockPosition = player.getPosition().toBlockPosition();
|
||||
|
||||
// Teleport the player back if he broke a solid block just below him
|
||||
if (playerBlockPosition.subtract(0, 1, 0).equals(blockPosition)) {
|
||||
PlayerPositionAndLookPacket positionAndLookPacket = new PlayerPositionAndLookPacket();
|
||||
positionAndLookPacket.position = player.getPosition().clone().add(0, 0.25f, 0);
|
||||
positionAndLookPacket.flags = 0x00;
|
||||
positionAndLookPacket.teleportId = 999;
|
||||
player.getPlayerConnection().sendPacket(positionAndLookPacket);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void dropItem(Player player, ItemStack droppedItem, ItemStack handItem) {
|
||||
|
@ -14,10 +14,8 @@ public class BlockPosition {
|
||||
}
|
||||
|
||||
public BlockPosition(float x, float y, float z) {
|
||||
final int castedY = (int) y;
|
||||
|
||||
this.x = (int) Math.floor(x);
|
||||
this.y = (y == castedY) ? castedY : castedY + 1;
|
||||
this.y = (int) Math.floor(y);
|
||||
this.z = (int) Math.floor(z);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user