summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2012-11-04 12:14:40 -0600
committerTravis Watkins <amaranth@ubuntu.com>2012-11-13 21:42:36 -0600
commit5a999a26608572df6b3ed461c3f6c95129de484a (patch)
tree4f66603bc3a6c7e4119445f9a342cfe14d5bc8eb
parent7f7192f8fd8357e664e7e2d6e7c5f65fd0fcd2f7 (diff)
downloadcraftbukkit-5a999a26608572df6b3ed461c3f6c95129de484a.tar
craftbukkit-5a999a26608572df6b3ed461c3f6c95129de484a.tar.gz
craftbukkit-5a999a26608572df6b3ed461c3f6c95129de484a.tar.lz
craftbukkit-5a999a26608572df6b3ed461c3f6c95129de484a.tar.xz
craftbukkit-5a999a26608572df6b3ed461c3f6c95129de484a.zip
Correct digging behavior. Fixes BUKKIT-2780
If a block is air we return immediately so miss the cleanup work that would normally happen in this case in vanilla. This causes us to get in to a situation where, due to odd packet sending from the client, we never properly stop an attempt by the client to break a block and thus it eventually breaks. We also use our own variable for block damage and never sync it up with the vanilla one so damage reporting to other clients is not always correct.
-rw-r--r--src/main/java/net/minecraft/server/ItemInWorldManager.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/main/java/net/minecraft/server/ItemInWorldManager.java b/src/main/java/net/minecraft/server/ItemInWorldManager.java
index 78ab6f26..389a3ed9 100644
--- a/src/main/java/net/minecraft/server/ItemInWorldManager.java
+++ b/src/main/java/net/minecraft/server/ItemInWorldManager.java
@@ -131,10 +131,6 @@ public class ItemInWorldManager {
float f = 1.0F;
int i1 = this.world.getTypeId(i, j, k);
// CraftBukkit start - Swings at air do *NOT* exist.
- if (i1 <= 0) {
- return;
- }
-
if (event.useInteractedBlock() == Event.Result.DENY) {
// If we denied a door from opening, we need to send a correcting update to the client, as it already opened the door.
if (i1 == Block.WOODEN_DOOR.id) {
@@ -145,22 +141,25 @@ public class ItemInWorldManager {
} else if (i1 == Block.TRAP_DOOR.id) {
((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
}
- } else {
+ } else if (i1 > 0) {
Block.byId[i1].attack(this.world, i, j, k, this.player);
// Allow fire punching to be blocked
this.world.douseFire((EntityHuman) null, i, j, k, l);
}
// Handle hitting a block
- float toolDamage = Block.byId[i1].getDamage(this.player, this.world, i, j, k);
+ if (i1 > 0) {
+ f = Block.byId[i1].getDamage(this.player, this.world, i, j, k);
+ }
+
if (event.useItemInHand() == Event.Result.DENY) {
// If we 'insta destroyed' then the client needs to be informed.
- if (toolDamage > 1.0f) {
+ if (f > 1.0f) {
((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
}
return;
}
- org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), toolDamage >= 1.0f);
+ org.bukkit.event.block.BlockDamageEvent blockEvent = CraftEventFactory.callBlockDamageEvent(this.player, i, j, k, this.player.inventory.getItemInHand(), f >= 1.0f);
if (blockEvent.isCancelled()) {
// Let the client know the block still exists
@@ -169,11 +168,11 @@ public class ItemInWorldManager {
}
if (blockEvent.getInstaBreak()) {
- toolDamage = 2.0f;
+ f = 2.0f;
}
+ // CraftBukkit end
- if (toolDamage >= 1.0F) {
- // CraftBukkit end
+ if (i1 > 0 && f >= 1.0F) {
this.breakBlock(i, j, k);
} else {
this.d = true;