2018-07-15 02:00:00 +02:00
--- a/net/minecraft/server/EntityTypes.java
+++ b/net/minecraft/server/EntityTypes.java
2020-06-25 02:00:00 +02:00
@@ -12,7 +12,7 @@
public class EntityTypes<T extends Entity> {
2018-08-26 04:00:00 +02:00
2020-06-25 02:00:00 +02:00
private static final Logger LOGGER = LogManager.getLogger();
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(Integer.MAX_VALUE));
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10));
public static final EntityTypes<EntityTippedArrow> ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20));
public static final EntityTypes<EntityBat> BAT = a("bat", EntityTypes.Builder.a(EntityBat::new, EnumCreatureType.AMBIENT).a(0.5F, 0.9F).trackingRange(5));
@@ -136,7 +136,7 @@
private MinecraftKey bp;
private final EntitySize bq;
- private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder<T> entitytypes_builder) {
+ private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s));
2018-08-26 04:00:00 +02:00
}
2020-06-25 02:00:00 +02:00
@@ -168,10 +168,16 @@
2018-07-15 02:00:00 +02:00
@Nullable
2019-04-23 04:00:00 +02:00
public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
2018-07-15 02:00:00 +02:00
+ // CraftBukkit start
2019-04-23 04:00:00 +02:00
+ return this.spawnCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
2018-07-15 02:00:00 +02:00
+ }
+
+ @Nullable
2019-04-23 04:00:00 +02:00
+ public T spawnCreature(World world, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
2020-01-21 22:00:00 +01:00
T t0 = this.createCreature(world, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1);
2018-07-15 02:00:00 +02:00
2018-12-25 22:00:00 +01:00
- world.addEntity(t0);
- return t0;
+ return world.addEntity(t0, spawnReason) ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled
2018-07-15 02:00:00 +02:00
+ // CraftBukkit end
}
@Nullable
2020-06-25 02:00:00 +02:00
@@ -204,7 +210,7 @@
2020-04-10 03:16:58 +02:00
t0.setCustomName(ichatbasecomponent);
}
- a(world, entityhuman, t0, nbttagcompound);
+ try { a(world, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
return t0;
}
}
2020-06-25 02:00:00 +02:00
@@ -347,7 +353,7 @@
2019-04-23 04:00:00 +02:00
}
2018-07-15 02:00:00 +02:00
2019-04-23 04:00:00 +02:00
return entity;
- }).orElse((Object) null);
+ }).orElse(null); // CraftBukkit - decompile error
2018-07-15 02:00:00 +02:00
}
2019-04-23 04:00:00 +02:00
private static Optional<Entity> b(NBTTagCompound nbttagcompound, World world) {
2020-06-25 02:00:00 +02:00
@@ -399,7 +405,7 @@
this.g = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
2019-04-23 04:00:00 +02:00
}
2020-06-25 02:00:00 +02:00
- public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) {
+ public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error
return new EntityTypes.Builder<>(entitytypes_b, enumcreaturetype);
2019-04-23 04:00:00 +02:00
}