|
48 | 48 | blockSource.level().gameEvent(null, GameEvent.ENTITY_PLACE, blockSource.pos());
|
49 | 49 | return item;
|
50 | 50 | }
|
51 |
| -@@ -110,8 +_,20 @@ |
| 51 | +@@ -110,12 +_,38 @@ |
52 | 52 | Direction direction = blockSource.state().getValue(DispenserBlock.FACING);
|
53 | 53 | BlockPos blockPos = blockSource.pos().relative(direction);
|
54 | 54 | ServerLevel serverLevel = blockSource.level();
|
|
63 | 63 | + if (event.isCancelled()) {
|
64 | 64 | + return item;
|
65 | 65 | + }
|
| 66 | ++ |
| 67 | ++ boolean shrink = true; |
| 68 | ++ if (!event.getItem().equals(craftItem)) { |
| 69 | ++ shrink = false; |
| 70 | ++ // Chain to handler for new item |
| 71 | ++ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); |
| 72 | ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); |
| 73 | ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { |
| 74 | ++ dispenseBehavior.dispense(blockSource, eventStack); |
| 75 | ++ return item; |
| 76 | ++ } |
| 77 | ++ } |
| 78 | ++ // CraftBukkit end |
| 79 | ++ |
66 | 80 | + final ItemStack newStack = org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getItem()); // Paper - use event itemstack (unwrap is fine here because the stack won't be modified)
|
67 | 81 | Consumer<ArmorStand> consumer = EntityType.appendDefaultStackConfig(
|
68 | 82 | - armorStand1 -> armorStand1.setYRot(direction.toYRot()), serverLevel, item, null
|
69 | 83 | + armorStand1 -> armorStand1.setYRot(direction.toYRot()), serverLevel, newStack, null // Paper - track changed items in the dispense event
|
70 | 84 | );
|
71 | 85 | ArmorStand armorStand = EntityType.ARMOR_STAND.spawn(serverLevel, consumer, blockPos, EntitySpawnReason.DISPENSER, false, false);
|
72 | 86 | if (armorStand != null) {
|
| 87 | +- item.shrink(1); |
| 88 | ++ if (shrink) item.shrink(1); // Paper |
| 89 | + } |
| 90 | + |
| 91 | + return item; |
73 | 92 | @@ -135,8 +_,35 @@
|
74 | 93 | new AABB(blockPos),
|
75 | 94 | abstractChestedHorse1 -> abstractChestedHorse1.isAlive() && !abstractChestedHorse1.hasChest()
|
|
289 | 308 | - serverLevel.gameEvent(null, GameEvent.ENTITY_PLACE, blockPos);
|
290 | 309 | - item.shrink(1);
|
291 | 310 | + serverLevel.gameEvent(null, GameEvent.ENTITY_PLACE, org.bukkit.craftbukkit.util.CraftVector.toBlockPos(event.getVelocity())); // Paper - update game event position
|
292 |
| -+ if (shrink) item.shrink(1); |
| 311 | ++ if (shrink) item.shrink(1); // Paper |
293 | 312 | this.setSuccess(true);
|
294 | 313 | return item;
|
295 | 314 | }
|
|
0 commit comments