Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
55d5c1650f
Upstream has released updates that appear 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: 17c35d6e SPIGOT-6637: Revert "#636: Add FurnaceStartSmeltEvent" 4b27230b SPIGOT-6623: Missing API reasons for entity freezing e1528c85 #636: Add FurnaceStartSmeltEvent CraftBukkit Changes: a6292cc3 SPIGOT-6637: Revert "#874: Add FurnaceStartSmeltEvent" f4066854 SPIGOT-6579: DragonFireBall movement with setDirection jumps around a lot 9add952b SPIGOT-6623: Missing API reasons for entity freezing 2ea359f1 #874: Add FurnaceStartSmeltEvent be8d625e SPIGOT-5560, SPIGOT-6574, SPIGOT-6632: Remove no longer needed tile entity fix Spigot Changes: eac3cd96 Rebuild patches
122 Zeilen
6.6 KiB
Diff
122 Zeilen
6.6 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 24 Mar 2019 00:24:52 -0400
|
|
Subject: [PATCH] Entity#getEntitySpawnReason
|
|
|
|
Allows you to return the SpawnReason for why an Entity Spawned
|
|
|
|
Pre existing entities will return NATURAL if it was a non
|
|
persistenting Living Entity, SPAWNER for spawners,
|
|
or DEFAULT since data was not stored.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 1bd378a60e761f9aeca347ebb80546ef4cf58eb4..4f53eb165616d690683a35d64abdf741f690a2a0 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -1072,6 +1072,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
return true;
|
|
}
|
|
// Paper end
|
|
+ if (entity.spawnReason == null) entity.spawnReason = spawnReason; // Paper
|
|
if (entity.isRemoved()) {
|
|
// Paper start
|
|
if (DEBUG_ENTITIES) {
|
|
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
index 2c17e723a1b1613c06b53c1e426c4ce1c072e8ad..abba62b7252c6d6ee92a4b1a9b23df7758ab6a77 100644
|
|
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
|
@@ -343,7 +343,7 @@ public abstract class PlayerList {
|
|
// CraftBukkit start
|
|
ServerLevel finalWorldServer = worldserver1;
|
|
Entity entity = EntityType.loadEntityRecursive(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> {
|
|
- return !finalWorldServer.addWithUUID(entity1) ? null : entity1;
|
|
+ return !finalWorldServer.addEntitySerialized(entity1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity1; // Paper
|
|
// CraftBukkit end
|
|
});
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index dbf002a6967812fd58ed9bcfa615dc525586c1a0..a8a91ed20c1b97368acdbb6ed7cd73ddaf7e1ea0 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -67,6 +67,8 @@ import net.minecraft.world.InteractionHand;
|
|
import net.minecraft.world.InteractionResult;
|
|
import net.minecraft.world.Nameable;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
+import net.minecraft.world.entity.animal.AbstractFish;
|
|
+import net.minecraft.world.entity.animal.Animal;
|
|
import net.minecraft.world.entity.item.ItemEntity;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.entity.vehicle.Boat;
|
|
@@ -166,6 +168,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
|
}
|
|
}
|
|
};
|
|
+ public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason;
|
|
// Paper end
|
|
|
|
public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
|
|
@@ -1865,6 +1868,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
|
}
|
|
nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ()));
|
|
}
|
|
+ if (spawnReason != null) {
|
|
+ nbt.putString("Paper.SpawnReason", spawnReason.name());
|
|
+ }
|
|
// Save entity's from mob spawner status
|
|
if (spawnedViaMobSpawner) {
|
|
nbt.putBoolean("Paper.FromMobSpawner", true);
|
|
@@ -2010,6 +2016,26 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
|
}
|
|
|
|
spawnedViaMobSpawner = nbt.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status
|
|
+ if (nbt.contains("Paper.SpawnReason")) {
|
|
+ String spawnReasonName = nbt.getString("Paper.SpawnReason");
|
|
+ try {
|
|
+ spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.valueOf(spawnReasonName);
|
|
+ } catch (Exception ignored) {
|
|
+ LogManager.getLogger().error("Unknown SpawnReason " + spawnReasonName + " for " + this);
|
|
+ }
|
|
+ }
|
|
+ if (spawnReason == null) {
|
|
+ if (spawnedViaMobSpawner) {
|
|
+ spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER;
|
|
+ } else if (this instanceof Mob && (this instanceof Animal || this instanceof AbstractFish) && !((Mob) this).removeWhenFarAway(0.0)) {
|
|
+ if (!nbt.getBoolean("PersistenceRequired")) {
|
|
+ spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ if (spawnReason == null) {
|
|
+ spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT;
|
|
+ }
|
|
// Paper end
|
|
|
|
} catch (Throwable throwable) {
|
|
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
|
index 494174608c0c6d0e0d9820ad4f263bef90c3dfdf..fe5e691ebbe930662f8a4f00811fdd8ed8ce1c52 100644
|
|
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
|
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
|
@@ -188,6 +188,7 @@ public abstract class BaseSpawner {
|
|
// Spigot End
|
|
}
|
|
entity.spawnedViaMobSpawner = true; // Paper
|
|
+ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; // Paper
|
|
flag = true; // Paper
|
|
// Spigot Start
|
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callSpawnerSpawnEvent(entity, pos).isCancelled()) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index 5178cd001064c089cb2e6a78696b4702c78bc37a..0b6720625b5fba07276972c484e032efdf9233c2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -1191,5 +1191,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
public boolean fromMobSpawner() {
|
|
return getHandle().spawnedViaMobSpawner;
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason getEntitySpawnReason() {
|
|
+ return getHandle().spawnReason;
|
|
+ }
|
|
// Paper end
|
|
}
|