aboutsummaryrefslogtreecommitdiffhomepage
path: root/paper-server/patches/unapplied/net/minecraft/world/item/MinecartItem.java.patch
blob: f97004f5f926c30e8adac26f1cb114a83bdb4988 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
--- a/net/minecraft/world/item/MinecartItem.java
+++ b/net/minecraft/world/item/MinecartItem.java
@@ -67,7 +67,13 @@
                 if (world instanceof ServerLevel) {
                     ServerLevel worldserver = (ServerLevel) world;
 
-                    worldserver.addFreshEntity(entityminecartabstract);
+                    // CraftBukkit start
+                    if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, entityminecartabstract).isCancelled()) {
+                    if (context.getPlayer() != null) context.getPlayer().containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync
+                        return InteractionResult.FAIL;
+                    }
+                    // CraftBukkit end
+                    if (!worldserver.addFreshEntity(entityminecartabstract)) return InteractionResult.PASS; // CraftBukkit
                     worldserver.gameEvent((Holder) GameEvent.ENTITY_PLACE, blockposition, GameEvent.Context.of(context.getPlayer(), worldserver.getBlockState(blockposition.below())));
                 }