mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 06:24:06 +01:00
85 lines
5.7 KiB
Diff
85 lines
5.7 KiB
Diff
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
|
|
index 5981b2bd5745ac32cdb377c15c4384d074a47680..0d38fe5a88af0afce85b8be7051d0e2f43f0ac34 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
|
@@ -349,7 +349,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
|
@Nullable
|
|
public T spawn(ServerLevel world, @Nullable ItemStack stack, @Nullable Player player, BlockPos pos, MobSpawnType spawnReason, boolean alignPosition, boolean invertY) {
|
|
// CraftBukkit start
|
|
- 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
|
|
}
|
|
|
|
@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
|
|
index 52eb930c5425bc4db32e65ac2b1fb07300617725..09ae4e30445354f7628e3368321700a119f3eeef 100644
|
|
--- 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
|
|
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
|
|
- this.level().addFreshEntity(areaEffectCloud);
|
|
+ this.level().addFreshEntity(areaEffectCloud, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EXPLOSION); // Paper
|
|
} else areaEffectCloud.discard(); // Paper
|
|
this.discard();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java b/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java
|
|
index 41a74780ce9edc8442732b04785396c245ee5c32..23c487e295b3b736d8800f0c884324c9b18a5373 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/CarvedPumpkinBlock.java
|
|
@@ -85,7 +85,17 @@ public class CarvedPumpkinBlock extends HorizontalDirectionalBlock {
|
|
// clearPatternBlocks(world, shapedetector_shapedetectorcollection); // CraftBukkit - moved down
|
|
entity.moveTo((double) pos.getX() + 0.5D, (double) pos.getY() + 0.05D, (double) pos.getZ() + 0.5D, 0.0F, 0.0F);
|
|
// CraftBukkit start
|
|
- if (!world.addFreshEntity(entity, SpawnReason.BUILD_IRONGOLEM)) {
|
|
+ // Paper start - correct spawn reason
|
|
+ final SpawnReason spawnReason;
|
|
+ if (entity.getType() == EntityType.SNOW_GOLEM) {
|
|
+ spawnReason = SpawnReason.BUILD_SNOWMAN;
|
|
+ } else if (entity.getType() == EntityType.IRON_GOLEM) {
|
|
+ spawnReason = SpawnReason.BUILD_IRONGOLEM;
|
|
+ } else {
|
|
+ spawnReason = SpawnReason.DEFAULT;
|
|
+ }
|
|
+ if (!world.addFreshEntity(entity, spawnReason)) {
|
|
+ // Paper end
|
|
return;
|
|
}
|
|
CarvedPumpkinBlock.clearPatternBlocks(world, patternResult); // CraftBukkit - from above
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
|
|
index ceb896583630c096429e70d4c37c0c8542b342a4..4f4cec646c058e9da43b1f0a7a7fc5efff563641 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/FrogspawnBlock.java
|
|
@@ -110,7 +110,7 @@ public class FrogspawnBlock extends Block {
|
|
int k = random.nextInt(1, 361);
|
|
tadpole.moveTo(d, (double)pos.getY() - 0.5D, e, (float)k, 0.0F);
|
|
tadpole.setPersistenceRequired();
|
|
- world.addFreshEntity(tadpole);
|
|
+ world.addFreshEntity(tadpole, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // Paper
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
|
|
index a7d1b55d380d8665de9f8ea55ffb3b6a84b39ca3..eb9ded37f98aa97f754ac1d02529d19ea101bb8b 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/SnifferEggBlock.java
|
|
@@ -81,7 +81,7 @@ public class SnifferEggBlock extends Block {
|
|
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);
|
|
+ world.addFreshEntity(sniffer, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // Paper
|
|
}
|
|
|
|
}
|