diff options
-rw-r--r-- | nms-patches/ItemStack.patch | 16 | ||||
-rw-r--r-- | nms-patches/PlayerInteractManager.patch | 32 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java | 4 |
3 files changed, 32 insertions, 20 deletions
diff --git a/nms-patches/ItemStack.patch b/nms-patches/ItemStack.patch index d7c50133..7fd816b5 100644 --- a/nms-patches/ItemStack.patch +++ b/nms-patches/ItemStack.patch @@ -85,7 +85,7 @@ EntityHuman entityhuman = itemactioncontext.getEntity(); BlockPosition blockposition = itemactioncontext.getClickPosition(); ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false); -@@ -106,12 +146,136 @@ +@@ -106,12 +146,142 @@ if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().E(), shapedetectorblock)) { return EnumInteractionResult.PASS; } else { @@ -156,6 +156,12 @@ + for (BlockState blockstate : blocks) { + blockstate.update(true, false); + } ++ ++ // Brute force all possible updates ++ BlockPosition placedPos = ((CraftBlock) placeEvent.getBlock()).getPosition(); ++ for (EnumDirection dir : EnumDirection.values()) { ++ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, placedPos.shift(dir))); ++ } + } else { + // Change the stack to its new contents if it hasn't been tampered with. + if (this.getCount() == oldCount) { @@ -223,7 +229,7 @@ return enuminteractionresult; } -@@ -135,7 +299,7 @@ +@@ -135,7 +305,7 @@ nbttagcompound.setString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString()); nbttagcompound.setByte("Count", (byte) this.count); if (this.tag != null) { @@ -232,7 +238,7 @@ } return nbttagcompound; -@@ -213,6 +377,11 @@ +@@ -213,6 +383,11 @@ if (this.isDamaged(i, entityliving.getRandom(), entityliving instanceof EntityPlayer ? (EntityPlayer) entityliving : null)) { entityliving.c(this); Item item = this.getItem(); @@ -244,7 +250,7 @@ this.subtract(1); if (entityliving instanceof EntityHuman) { -@@ -480,6 +649,14 @@ +@@ -480,6 +655,14 @@ } public void setRepairCost(int i) { @@ -259,7 +265,7 @@ this.getOrCreateTag().setInt("RepairCost", i); } -@@ -522,6 +699,13 @@ +@@ -522,6 +705,13 @@ nbttaglist.add((NBTBase) nbttagcompound); } diff --git a/nms-patches/PlayerInteractManager.patch b/nms-patches/PlayerInteractManager.patch index c16937cd..2e031eb3 100644 --- a/nms-patches/PlayerInteractManager.patch +++ b/nms-patches/PlayerInteractManager.patch @@ -53,7 +53,7 @@ if (this.isCreative()) { if (!this.world.douseFire((EntityHuman) null, blockposition, enumdirection)) { this.breakBlock(blockposition); -@@ -122,15 +144,49 @@ +@@ -122,16 +144,50 @@ } } @@ -96,15 +96,16 @@ + // Let the client know the block still exists + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); + return; -+ } -+ + } + + if (blockEvent.getInstaBreak()) { + f = 2.0f; - } ++ } + // CraftBukkit end - ++ if (!iblockdata.isAir() && f >= 1.0F) { this.breakBlock(blockposition); + } else { @@ -149,6 +205,7 @@ public void a(BlockPosition blockposition) { @@ -124,7 +125,7 @@ } } -@@ -190,13 +251,88 @@ +@@ -190,13 +251,89 @@ public boolean breakBlock(BlockPosition blockposition) { IBlockData iblockdata = this.world.getType(blockposition); @@ -165,21 +166,22 @@ + event.setExpToDrop(nmsBlock.getExpDrop(nmsData, this.world, blockposition, bonusLevel)); + } + } ++ ++ this.world.getServer().getPluginManager().callEvent(event); - if (!this.player.getItemInMainHand().getItem().a(iblockdata, this.world, blockposition, (EntityHuman) this.player)) { -+ this.world.getServer().getPluginManager().callEvent(event); -+ + if (event.isCancelled()) { + if (isSwordNoBreak) { + return false; + } + // Let the client know the block still exists + ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition)); -+ // Send other half of the door -+ if (nmsBlock instanceof BlockDoor) { -+ boolean bottom = nmsData.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER; -+ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, bottom ? blockposition.up() : blockposition.down())); ++ ++ // Brute force all possible updates ++ for (EnumDirection dir : EnumDirection.values()) { ++ ((EntityPlayer) this.player).playerConnection.sendPacket(new PacketPlayOutBlockChange(world, blockposition.shift(dir))); + } ++ + // Update any tile entity data for this block + TileEntity tileentity = this.world.getTileEntity(blockposition); + if (tileentity != null) { @@ -214,7 +216,7 @@ if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.isCreativeAndOp()) { this.world.notify(blockposition, iblockdata, iblockdata, 3); return false; -@@ -221,19 +357,36 @@ +@@ -221,19 +358,36 @@ } } @@ -252,7 +254,7 @@ return flag; } -@@ -277,11 +430,40 @@ +@@ -277,11 +431,40 @@ } } @@ -293,7 +295,7 @@ if (tileentity instanceof ITileInventory) { Block block = iblockdata.getBlock(); -@@ -305,24 +487,26 @@ +@@ -305,24 +488,26 @@ boolean flag = !entityhuman.getItemInMainHand().isEmpty() || !entityhuman.getItemInOffHand().isEmpty(); boolean flag1 = entityhuman.isSneaking() && flag; diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index f5dc63f2..c48b394d 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -49,6 +49,10 @@ public class CraftBlock implements Block { return world.getType(position); } + public BlockPosition getPosition() { + return position; + } + public World getWorld() { return world.getMinecraftWorld().getWorld(); } |