|
26 | 26 | if (!p_40703_.isClientSide) { |
27 | 27 | CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)p_40704_, itemstack3); |
28 | 28 | } |
29 | | -@@ -72,8 +_,8 @@ |
| 29 | +@@ -72,8 +_,9 @@ |
30 | 30 | return InteractionResultHolder.fail(itemstack); |
31 | 31 | } else { |
32 | 32 | BlockState blockstate = p_40703_.getBlockState(blockpos); |
33 | 33 | - BlockPos blockpos2 = blockstate.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockpos : blockpos1; |
34 | 34 | - if (this.emptyContents(p_40704_, p_40703_, blockpos2, blockhitresult)) { |
35 | 35 | + BlockPos blockpos2 = canBlockContainFluid(p_40704_, p_40703_, blockpos, blockstate) ? blockpos : blockpos1; |
36 | | -+ if (this.emptyContents(p_40704_, p_40703_, blockpos2, blockhitresult, itemstack, blockhitresult.getDirection(), blockpos, itemstack, p_40705_)) { // CraftBukkit |
| 36 | ++ this.setCBContents(blockhitresult.getDirection(), blockpos, itemstack, p_40705_); // Magma |
| 37 | ++ if (this.emptyContents(p_40704_, p_40703_, blockpos2, blockhitresult, itemstack)) { |
37 | 38 | this.checkExtraContent(p_40704_, p_40703_, itemstack, blockpos2); |
38 | 39 | if (p_40704_ instanceof ServerPlayer) { |
39 | 40 | CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)p_40704_, blockpos2, itemstack); |
40 | | -@@ -98,7 +_,17 @@ |
| 41 | +@@ -98,7 +_,33 @@ |
41 | 42 | } |
42 | 43 |
|
43 | 44 | @Override |
44 | 45 | + @Deprecated // Neo: use the ItemStack sensitive version |
45 | 46 | public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_) { |
46 | 47 | + return this.emptyContents(p_150716_, p_150717_, p_150718_, p_150719_, null); |
47 | 48 | + } |
48 | | -+ public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container) { |
49 | | -+ // CraftBukkit start |
50 | | -+ return emptyContents(p_150716_, p_150717_, p_150718_, p_150719_,container, null, null, null, InteractionHand.MAIN_HAND); |
| 49 | ++ |
| 50 | ++ // Magma start - mixin support |
| 51 | ++ private Direction magma$enumdirection = null; |
| 52 | ++ private BlockPos magma$clicked = null; |
| 53 | ++ private ItemStack magma$itemstack = null; |
| 54 | ++ private InteractionHand magma$enumhand = net.minecraft.world.InteractionHand.MAIN_HAND; |
| 55 | ++ |
| 56 | ++ public void setCBContents(Direction enumdirection, BlockPos clicked, ItemStack itemstack, InteractionHand enumhand){ |
| 57 | ++ magma$enumdirection = enumdirection; |
| 58 | ++ magma$clicked = clicked; |
| 59 | ++ magma$itemstack = itemstack; |
| 60 | ++ magma$enumhand = enumhand; |
51 | 61 | + } |
52 | 62 | + |
53 | | -+ public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container, Direction enumdirection, BlockPos clicked, ItemStack itemstack, InteractionHand enumhand) { |
54 | | -+ // CraftBukkit end |
| 63 | ++ private void resetCB() { |
| 64 | ++ magma$enumdirection = null; |
| 65 | ++ magma$clicked = null; |
| 66 | ++ magma$itemstack = null; |
| 67 | ++ magma$enumhand = net.minecraft.world.InteractionHand.MAIN_HAND; |
| 68 | ++ } |
| 69 | ++ // Magma end |
| 70 | ++ |
| 71 | ++ public boolean emptyContents(@Nullable Player p_150716_, Level p_150717_, BlockPos p_150718_, @Nullable BlockHitResult p_150719_, @Nullable ItemStack container) { |
55 | 72 | if (!(this.content instanceof FlowingFluid flowingfluid)) { |
56 | 73 | return false; |
57 | 74 | } else { |
58 | | -@@ -125,8 +_,22 @@ |
| 75 | +@@ -125,8 +_,24 @@ |
59 | 76 | } |
60 | 77 |
|
61 | 78 | boolean flag1 = flag2; |
62 | 79 | + java.util.Optional<net.neoforged.neoforge.fluids.FluidStack> containedFluidStack = java.util.Optional.ofNullable(container).flatMap(net.neoforged.neoforge.fluids.FluidUtil::getFluidContained); |
63 | 80 | + // CraftBukkit start |
64 | 81 | + if (flag1 && p_150716_ != null) { |
65 | | -+ org.bukkit.event.player.PlayerBucketEmptyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent((net.minecraft.server.level.ServerLevel) p_150717_, p_150716_, p_150718_, clicked, enumdirection, itemstack, enumhand); |
| 82 | ++ org.bukkit.event.player.PlayerBucketEmptyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent((net.minecraft.server.level.ServerLevel) p_150717_, p_150716_, p_150718_, magma$clicked, magma$enumdirection, magma$itemstack, magma$enumhand); |
| 83 | ++ resetCB(); |
66 | 84 | + if (event.isCancelled()) { |
67 | 85 | + ((ServerPlayer) p_150716_).connection.send(new net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket(p_150717_, p_150718_)); // SPIGOT-4238: needed when looking through entity |
68 | 86 | + ((ServerPlayer) p_150716_).getBukkitEntity().updateInventory(); // SPIGOT-4541 |
|
72 | 90 | + // CraftBukkit end |
73 | 91 | if (!flag1) { |
74 | 92 | - return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null); |
75 | | -+ return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null, container, enumdirection, clicked, itemstack, enumhand); // CraftBukkit |
| 93 | ++ this.setCBContents(magma$enumdirection, magma$clicked, magma$itemstack, magma$enumhand); |
| 94 | ++ return p_150719_ != null && this.emptyContents(p_150716_, p_150717_, p_150719_.getBlockPos().relative(p_150719_.getDirection()), null, container); |
76 | 95 | + } else if (containedFluidStack.isPresent() && this.content.getFluidType().isVaporizedOnPlacement(p_150717_, p_150718_, containedFluidStack.get())) { |
77 | 96 | + this.content.getFluidType().onVaporize(p_150716_, p_150717_, p_150718_, containedFluidStack.get()); |
78 | 97 | + return true; |
|
0 commit comments