aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0872-Ensure-entity-passenger-world-matches-ridden-entity.patch
blob: 16d39906af6af5aa8503b1ada39dfd4211029249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Thu, 31 Mar 2022 05:11:37 -0700
Subject: [PATCH] Ensure entity passenger world matches ridden entity

Bad plugins doing this would cause some obvious problems...

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index f1e471fee49d0213a97251be1b6793d5fb2165f2..a0c84b3fc264ef25ef1bcdeba482ac23461411f3 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2684,6 +2684,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
     }
 
     protected boolean addPassenger(Entity entity) { // CraftBukkit
+        // Paper start
+        if (entity.level != this.level) {
+            LOGGER.error("Entity passenger world must match, cannot add " + entity + " as passenger to " + this, new Throwable());
+            return false;
+        }
+        // Paper end
         if (entity == this) throw new IllegalArgumentException("Entities cannot become a passenger of themselves"); // Paper - issue 572
         if (entity.getVehicle() != this) {
             throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");