From 4a1ae2fa02ca00fef9785c831c978b6839b29704 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Wed, 31 Jan 2024 20:08:05 +1100 Subject: [PATCH] SPIGOT-3071, #1345: Add entity spawn method with spawn reason By: DerFrZocker --- .../src/main/java/org/bukkit/craftbukkit/CraftWorld.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 71b8fd19de..3faf9a9a7c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -117,6 +117,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.LightningStrike; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.SpawnCategory; import org.bukkit.entity.SpectralArrow; @@ -144,6 +145,7 @@ import org.bukkit.util.RayTraceResult; import org.bukkit.util.StructureSearchResult; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class CraftWorld extends CraftRegionAccessor implements World { public static final int CUSTOM_DIMENSION_OFFSET = 10; @@ -732,6 +734,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { return populators; } + @NotNull + @Override + public T spawn(@NotNull Location location, @NotNull Class clazz, @NotNull SpawnReason spawnReason, boolean randomizeData, @Nullable Consumer function) throws IllegalArgumentException { + Preconditions.checkArgument(spawnReason != null, "Spawn reason cannot be null"); + return spawn(location, clazz, function, spawnReason, randomizeData); + } + @Override public Block getHighestBlockAt(int x, int z) { return getBlockAt(x, getHighestBlockYAt(x, z), z);