From a03610401be3b612dea19d9ad62aa913d09286a7 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 15 Sep 2021 14:52:42 -0700 Subject: [PATCH] config for disabling entity tag tags --- .../world/entity/EntityType.java.patch | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index b8a966fe0f..bb085c1cad 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -34,14 +34,14 @@ + // CraftBukkit start + return this.spawn(world, stack, player, pos, spawnReason, alignPosition, invertY, spawnReason == EntitySpawnReason.DISPENSER ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // Paper - use correct spawn reason for dispenser spawn eggs + } - -- if (stack != null) { -- consumer = EntityType.createDefaultStackConfig(world, stack, player); ++ + @Nullable + public T spawn(ServerLevel worldserver, @Nullable ItemStack itemstack, @Nullable Player entityhuman, BlockPos blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end + Consumer consumer; // CraftBukkit - decompile error -+ + +- if (stack != null) { +- consumer = EntityType.createDefaultStackConfig(world, stack, player); + if (itemstack != null) { + consumer = EntityType.createDefaultStackConfig(worldserver, itemstack, entityhuman); } else { @@ -82,7 +82,7 @@ + // CraftBukkit start + return this.spawn(world, afterConsumer, pos, reason, alignPosition, invertY, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } - ++ + @Nullable + public T spawn(ServerLevel worldserver, @Nullable Consumer consumer, BlockPos blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end @@ -97,7 +97,7 @@ + } + // Paper end - PreCreatureSpawnEvent + T t0 = this.create(worldserver, consumer, blockposition, entityspawnreason, flag, flag1); -+ + if (t0 != null) { - world.addFreshEntityWithPassengers(t0); + // CraftBukkit start @@ -109,7 +109,23 @@ if (t0 instanceof Mob) { Mob entityinsentient = (Mob) t0; -@@ -657,7 +694,7 @@ +@@ -542,6 +579,15 @@ + + if (entity.getType() == entitytypes) { + if (world.isClientSide || !entity.getType().onlyOpCanSetNbt() || player != null && minecraftserver.getPlayerList().isOp(player.getGameProfile())) { ++ // Paper start - filter out protected tags ++ if (player == null || !player.getBukkitEntity().hasPermission("minecraft.nbt.place")) { ++ nbt = nbt.update((compound) -> { ++ for (net.minecraft.commands.arguments.NbtPathArgument.NbtPath tag : world.paperConfig().entities.spawning.filteredEntityTagNbtPaths) { ++ tag.remove(compound); ++ } ++ }); ++ } ++ // Paper end - filter out protected tags + nbt.loadInto(entity); + } + } +@@ -657,7 +703,7 @@ } return entity; @@ -118,7 +134,7 @@ } public static Stream loadEntitiesRecursive(final List entityNbtList, final Level world, final EntitySpawnReason reason) { -@@ -718,7 +755,7 @@ +@@ -718,7 +764,7 @@ @Nullable public T tryCast(Entity obj) { @@ -127,7 +143,7 @@ } @Override -@@ -791,7 +828,7 @@ +@@ -791,7 +837,7 @@ this.canSpawnFarFromPlayer = spawnGroup == MobCategory.CREATURE || spawnGroup == MobCategory.MISC; }