3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-16 19:40:07 +01:00
Paper/Spigot-Server-Patches/0521-Ensure-Entity-AABB-s-are-never-invalid.patch
Aikar ab347c4c96
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
42d5a714 SPIGOT-5899: Hoglins API similar to Piglins
2c1ee10e SPIGOT-5887: ClickType doesn't include off hand swaps
5ff7c7ce SPIGOT-5886: Missing BlockData

CraftBukkit Changes:
7560f5f5 SPIGOT-5905: Fix hex colours not being allowed in MOTD
d47c47ee SPIGOT-5889: Villager using composter should call EntityChangeBlockEvent
2fe6b4a3 SPIGOT-5899: Hoglins API similar to Piglins
e09dbeca SPIGOT-5887: ClickType doesn't include off hand swaps
23aac2a5 SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously
92cbf656 SPIGOT-5884: Tab completions lost on reloadData / minecraft:reload
fb4e54ad SPIGOT-5902: PlayerRespawnEvent places player at spawn before event is called
aa8f3d5a SPIGOT-5901: Structures are generated in all worlds based on the setting for the main world
a0c35937 SPIGOT-5895: PlayerChangedWorldEvent#getFrom is incorrect
89c0a5c3 SPIGOT-5886: Missing BlockData

Spigot Changes:
0287a20d SPIGOT-5903: EntityDismountEvent cannot be triggered asynchronously
2020-06-30 01:20:29 -04:00

130 Zeilen
5.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 10 May 2020 22:12:46 -0400
Subject: [PATCH] Ensure Entity AABB's are never invalid
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 3bbacebc3397f2c1d695f64bf3f4eb2b89b112b6..e5edd801c57e6f678c661193814ce9de07f83b95 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1,53 +1,54 @@
package net.minecraft.server;
+import co.aikar.timings.MinecraftTimings;
+import co.aikar.timings.Timing;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import it.unimi.dsi.fastutil.objects.Object2DoubleArrayMap;
import it.unimi.dsi.fastutil.objects.Object2DoubleMap;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Optional;
-import java.util.Random;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Stream;
-import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-
-// CraftBukkit start
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Hanging;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Vehicle;
-import co.aikar.timings.MinecraftTimings; // Paper
-import co.aikar.timings.Timing; // Paper
-import org.bukkit.event.entity.EntityCombustByEntityEvent;
-import org.bukkit.event.hanging.HangingBreakByEntityEvent;
-import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
-import org.bukkit.event.vehicle.VehicleEnterEvent;
-import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Hanging;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Pose;
+import org.bukkit.entity.Vehicle;
import org.bukkit.event.entity.EntityAirChangeEvent;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.entity.EntityCombustEvent;
import org.bukkit.event.entity.EntityDropItemEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.EntityPoseChangeEvent;
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
+import org.bukkit.event.vehicle.VehicleEnterEvent;
+import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.plugin.PluginManager;
+
+import javax.annotation.Nullable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Optional;
+import java.util.Random;
+import java.util.Set;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Stream;
+
+// CraftBukkit start
// CraftBukkit end
public abstract class Entity implements INamableTileEntity, ICommandListener, KeyedObject { // Paper
@@ -425,10 +426,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
public void setPosition(double d0, double d1, double d2) {
this.setPositionRaw(d0, d1, d2);
- float f = this.size.width / 2.0F;
- float f1 = this.size.height;
+ // Paper start - move into setPositionRaw
+ //float f = this.size.width / 2.0F;
+ //float f1 = this.size.height;
- this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f));
+ //this.a(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f));
+ // Paper end
if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
}
@@ -2907,6 +2910,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
return new AxisAlignedBB(vec3d, vec3d1);
}
+ public final void setBoundingBox(AxisAlignedBB axisalignedbb) { a(axisalignedbb); } // Paper - OBFHELPER
public void a(AxisAlignedBB axisalignedbb) {
// CraftBukkit start - block invalid bounding boxes
double minX = axisalignedbb.minX,
@@ -3345,6 +3349,14 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public void setPositionRaw(double d0, double d1, double d2) {
+ // Paper start - never allow AABB to become desynced from position
+ // hanging has its own special logic
+ if (!(this instanceof EntityHanging) && (this.loc.x != d0 || this.loc.y != d1 || this.loc.z != d2)) {
+ float f = this.size.width / 2.0F;
+ float f1 = this.size.height;
+ this.setBoundingBox(new AxisAlignedBB(d0 - (double) f, d1, d2 - (double) f, d0 + (double) f, d1 + (double) f1, d2 + (double) f));
+ }
+ // Paper end
if (this.loc.x != d0 || this.loc.y != d1 || this.loc.z != d2) {
this.loc = new Vec3D(d0, d1, d2);
int i = MathHelper.floor(d0);