2022-09-27 02:24:56 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 25 Sep 2022 11:21:01 -0700
Subject: [PATCH] Fixes and additions to the SpawnReason API
Fixes some wrong reasons, and adds missing spawn reasons for entities.
Co-authored-by: Doc <nachito94@msn.com>
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
2023-12-06 17:21:56 +01:00
index 823f3b3093cffb49ccdcbcfbe6d348009a553ad7..e754a294645e1af9e39bde32dd1387cd54335e7e 100644
2022-09-27 02:24:56 +02:00
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
2023-12-06 17:21:56 +01:00
@@ -353,7 +353,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
2022-09-27 02:24:56 +02:00
@Nullable
2022-12-08 17:51:06 +01:00
public T spawn(ServerLevel world, @Nullable ItemStack stack, @Nullable Player player, BlockPos pos, MobSpawnType spawnReason, boolean alignPosition, boolean invertY) {
2022-09-27 02:24:56 +02:00
// CraftBukkit start
2022-12-08 17:51:06 +01:00
- return this.spawn(world, stack, player, pos, spawnReason, alignPosition, invertY, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
+ return this.spawn(world, stack, player, pos, spawnReason, alignPosition, invertY, spawnReason == MobSpawnType.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
2022-09-27 02:24:56 +02:00
}
@Nullable
diff --git a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
2024-01-16 12:41:40 +01:00
index 9652e3385ad10e5d825dd141f6be3522c596916d..baea154a24d1b888af18b9b792db9edebe60ebc6 100644
2022-09-27 02:24:56 +02:00
--- a/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/DragonFireball.java
@@ -54,7 +54,7 @@ public class DragonFireball extends AbstractHurtingProjectile {
if (new com.destroystokyo.paper.event.entity.EnderDragonFireballHitEvent((org.bukkit.entity.DragonFireball) this.getBukkitEntity(), list.stream().map(LivingEntity::getBukkitLivingEntity).collect(java.util.stream.Collectors.toList()), (org.bukkit.entity.AreaEffectCloud) areaEffectCloud.getBukkitEntity()).callEvent()) { // Paper
2023-06-08 10:47:19 +02:00
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
- this.level().addFreshEntity(areaEffectCloud);
2024-01-16 12:41:40 +01:00
+ this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper - use correct spawn reason
2022-09-27 02:24:56 +02:00
} else areaEffectCloud.discard(); // Paper
this.discard();
}
diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
2024-01-16 12:41:40 +01:00
index 0a2de99c22cfcc96a664dc2afe7379987ea815db..452b3070e68dda1a4c7ba99cbefcaab5c5958bdd 100644
2022-09-27 02:24:56 +02:00
--- a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
2023-12-06 17:21:56 +01:00
@@ -117,7 +117,7 @@ public class FrogspawnBlock extends Block {
2022-12-08 17:51:06 +01:00
int k = random.nextInt(1, 361);
tadpole.moveTo(d, (double)pos.getY() - 0.5D, e, (float)k, 0.0F);
tadpole.setPersistenceRequired();
- world.addFreshEntity(tadpole);
2024-01-16 12:41:40 +01:00
+ world.addFreshEntity(tadpole, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // Paper - use correct spawn reason
2022-12-08 17:51:06 +01:00
}
2022-09-27 02:24:56 +02:00
}
2023-08-26 22:12:46 +02:00
diff --git a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
2024-01-16 12:41:40 +01:00
index 3cedc349e79665d3d471c92b5dca25c9e66ca0bf..4d3dc58750f80d4aacb46c98a8ffc66acb4a2edc 100644
2023-08-26 22:12:46 +02:00
--- a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
2023-12-06 17:21:56 +01:00
@@ -88,7 +88,7 @@ public class SnifferEggBlock extends Block {
2023-08-26 22:12:46 +02:00
Vec3 vec3 = pos.getCenter();
sniffer.setBaby(true);
sniffer.moveTo(vec3.x(), vec3.y(), vec3.z(), Mth.wrapDegrees(world.random.nextFloat() * 360.0F), 0.0F);
- world.addFreshEntity(sniffer);
2024-01-16 12:41:40 +01:00
+ world.addFreshEntity(sniffer, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // Paper - use correct spawn reason
2023-08-26 22:12:46 +02:00
}
}