Commits

md_5 authored 744e1a177a0
Fix looting enchant using wrong variable
No tags

nms-patches/PlayerInteractManager.patch

Modified
116 116 this.j = this.lastDigTick;
117 117 }
118 118 }
119 119 + // CraftBukkit start - Force block reset to client
120 120 + } else {
121 121 + this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(this.world, blockposition));
122 122 + // CraftBukkit end
123 123 }
124 124
125 125 }
126 -@@ -192,13 +251,81 @@
126 +@@ -192,13 +251,80 @@
127 127 }
128 128
129 129 public boolean breakBlock(BlockPosition blockposition) {
130 130 - if (this.gamemode.isCreative() && this.player.getItemInMainHand() != null && this.player.getItemInMainHand().getItem() instanceof ItemSword) {
131 131 + // CraftBukkit start - fire BlockBreakEvent
132 132 + BlockBreakEvent event = null;
133 133 +
134 134 + if (this.player instanceof EntityPlayer) {
135 135 + org.bukkit.block.Block block = this.world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
136 136 +
152 152 +
153 153 + // Calculate default block experience
154 154 + IBlockData nmsData = this.world.getType(blockposition);
155 155 + Block nmsBlock = nmsData.getBlock();
156 156 +
157 157 + ItemStack itemstack = this.player.getEquipment(EnumItemSlot.MAINHAND);
158 158 +
159 159 + if (nmsBlock != null && !event.isCancelled() && !this.isCreative() && this.player.hasBlock(nmsBlock.getBlockData())) {
160 160 + // Copied from block.a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, TileEntity tileentity)
161 161 + // PAIL: checkme each update
162 -+ if (!(nmsBlock.p() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) {
163 -+ int data = block.getData();
162 ++ if (!(nmsBlock.o() && EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) > 0)) {
164 163 + int bonusLevel = EnchantmentManager.getEnchantmentLevel(Enchantments.LOOT_BONUS_BLOCKS, itemstack);
165 164 +
166 165 + event.setExpToDrop(nmsBlock.getExpDrop(this.world, nmsData, bonusLevel));
167 166 + }
168 167 + }
169 168 +
170 169 + this.world.getServer().getPluginManager().callEvent(event);
171 170 +
172 171 + if (event.isCancelled()) {
173 172 + if (isSwordNoBreak) {
199 198 + // CraftBukkit start - Special case skulls, their item data comes from a tile entity
200 199 + if (iblockdata.getBlock() == Blocks.SKULL && !this.isCreative()) {
201 200 + iblockdata.getBlock().dropNaturally(world, blockposition, iblockdata, 1.0F, 0);
202 201 + return this.c(blockposition);
203 202 + }
204 203 + // CraftBukkit end
205 204 +
206 205 if ((block instanceof BlockCommand || block instanceof BlockStructure) && !this.player.dh()) {
207 206 this.world.notify(blockposition, iblockdata, iblockdata, 3);
208 207 return false;
209 -@@ -243,6 +370,12 @@
208 +@@ -243,6 +369,12 @@
210 209 }
211 210 }
212 211
213 212 + // CraftBukkit start - Drop event experience
214 213 + if (flag && event != null) {
215 214 + iblockdata.getBlock().dropExperience(this.world, blockposition, event.getExpToDrop());
216 215 + }
217 216 + // CraftBukkit end
218 217 +
219 218 return flag;
220 219 }
221 220 }
222 -@@ -283,7 +416,13 @@
221 +@@ -283,7 +415,13 @@
223 222 }
224 223 }
225 224
226 225 + // CraftBukkit start
227 226 + public boolean interactResult = false;
228 227 + public boolean firedInteract = false;
229 228 + // CraftBukkit end
230 229 +
231 230 public EnumInteractionResult a(EntityHuman entityhuman, World world, @Nullable ItemStack itemstack, EnumHand enumhand, BlockPosition blockposition, EnumDirection enumdirection, float f, float f1, float f2) {
232 231 + /* CraftBukkit start - whole method
233 232 if (this.gamemode == EnumGamemode.SPECTATOR) {
234 233 TileEntity tileentity = world.getTileEntity(blockposition);
235 234
236 -@@ -340,6 +479,74 @@
235 +@@ -340,6 +478,74 @@
237 236 }
238 237 }
239 238 }
240 239 + // Interact event */
241 240 + IBlockData blockdata = world.getType(blockposition);
242 241 + EnumInteractionResult result = EnumInteractionResult.FAIL;
243 242 + if (blockdata.getBlock() != Blocks.AIR) {
244 243 + boolean cancelledBlock = false;
245 244 +
246 245 + if (this.gamemode == EnumGamemode.SPECTATOR) {

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut