mirror of
https://github.com/PaperMC/Paper.git
synced 2024-08-23 04:53:42 +02:00
Updated Upstream (Bukkit/CraftBukkit/Spigot) Bukkit Changes: 2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields e0fc6572 SPIGOT-4309: Add "forced" display of particles efeeab2f Add index to README.md for easier navigation f502bc6f Update to Minecraft 1.13.1 CraftBukkit Changes:d0bb0a1d
Fix some tests randomly failing997d378d
Fix client stall in specific teleportation scenariosb3dc2366
SPIGOT-4307: Fix hacky API for banners on shields2a271162
SPIGOT-4301: Fix more invalid enchants5d0d83bb
SPIGOT-4309: Add "forced" display of particlesa6772578
Add additional tests for CraftBlockDatace1af0c3
Update to Minecraft 1.13.1 Spigot Changes: 2440e189 Rebuild patches 4ecffced Update to Minecraft 1.13.1
97 lines
5.9 KiB
Diff
97 lines
5.9 KiB
Diff
From 0dcf8a51fa0da99cd6365c7cd376aa77b7e3074a Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 14 Jan 2018 17:01:31 -0500
|
|
Subject: [PATCH] PreCreatureSpawnEvent
|
|
|
|
Adds an event to fire before an Entity is created, so that plugins that need to cancel
|
|
CreatureSpawnEvent can do so from this event instead.
|
|
|
|
Cancelling CreatureSpawnEvent rapidly causes a lot of garbage collection and CPU waste
|
|
as it's done after the Entity object has been fully created.
|
|
|
|
Mob Limiting plugins and blanket "ban this type of monster" plugins should use this event
|
|
instead and save a lot of server resources.
|
|
|
|
See: https://github.com/PaperMC/Paper/issues/917
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
index e4598d8314..6ee069cd12 100644
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
@@ -1,6 +1,7 @@
|
|
package net.minecraft.server;
|
|
|
|
import com.google.common.collect.Lists;
|
|
+
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import javax.annotation.Nullable;
|
|
@@ -94,6 +95,28 @@ public abstract class MobSpawnerAbstract {
|
|
double d3 = j >= 1 ? nbttaglist.k(0) : (double) blockposition.getX() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawnRange + 0.5D;
|
|
double d4 = j >= 2 ? nbttaglist.k(1) : (double) (blockposition.getY() + world.random.nextInt(3) - 1);
|
|
double d5 = j >= 3 ? nbttaglist.k(2) : (double) blockposition.getZ() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawnRange + 0.5D;
|
|
+ // Paper start
|
|
+ if (this.getMobName() == null) {
|
|
+ return;
|
|
+ }
|
|
+ String key = this.getMobName().getKey();
|
|
+ org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(key);
|
|
+ if (type != null) {
|
|
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
|
+ MCUtil.toLocation(world, d3, d4, d5),
|
|
+ type,
|
|
+ org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER
|
|
+ );
|
|
+ if (!event.callEvent()) {
|
|
+ flag = true;
|
|
+ if (event.shouldAbortSpawn()) {
|
|
+ break;
|
|
+ }
|
|
+ continue;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
Entity entity = ChunkRegionLoader.a(nbttagcompound, world, d3, d4, d5, false);
|
|
|
|
if (entity == null) {
|
|
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
index f32191c5a2..4a2153b68f 100644
|
|
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
|
|
@@ -160,10 +160,30 @@ public final class SpawnerCreature {
|
|
|
|
if (worldserver.a(enumcreaturetype, biomebase_biomemeta, (BlockPosition) blockposition_mutableblockposition)) {
|
|
EntityPositionTypes.Surface entitypositiontypes_surface = EntityPositionTypes.a(biomebase_biomemeta.b);
|
|
-
|
|
if (entitypositiontypes_surface != null && a(entitypositiontypes_surface, worldserver, blockposition_mutableblockposition, biomebase_biomemeta.b)) {
|
|
EntityInsentient entityinsentient;
|
|
|
|
+ // Paper start
|
|
+ com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event;
|
|
+ EntityTypes<? extends EntityInsentient> cls = biomebase_biomemeta.b;
|
|
+ org.bukkit.entity.EntityType type = EntityTypes.clsToTypeMap.get(cls);
|
|
+ if (type != null) {
|
|
+ event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent(
|
|
+ MCUtil.toLocation(worldserver, blockposition_mutableblockposition),
|
|
+ type, SpawnReason.NATURAL
|
|
+ );
|
|
+ if (!event.callEvent()) {
|
|
+ if (event.shouldAbortSpawn()) {
|
|
+ continue label128; // right above the iterator for c (Chunk Pos Set)
|
|
+ }
|
|
+ j1 += l2;
|
|
+ ++j4;
|
|
+ continue;
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
+
|
|
try {
|
|
entityinsentient = (EntityInsentient) biomebase_biomemeta.b.a((World) worldserver);
|
|
} catch (Exception exception) {
|
|
--
|
|
2.18.0
|
|
|