diff --git a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch index 86f322534f..d6cfa8ad4b 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/item/EntityFallingBlock.patch @@ -14,17 +14,17 @@ public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata) { + // CraftBukkit start -+ return fall(world, blockposition, iblockdata, false); ++ return fall(world, blockposition, iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata, boolean isCustom) { ++ public static EntityFallingBlock fall(World world, BlockPosition blockposition, IBlockData iblockdata, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + // CraftBukkit end EntityFallingBlock entityfallingblock = new EntityFallingBlock(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockProperties.WATERLOGGED) ? (IBlockData) iblockdata.setValue(BlockProperties.WATERLOGGED, false) : iblockdata); + if (CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) return entityfallingblock; // CraftBukkit world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3); - world.addFreshEntity(entityfallingblock); -+ world.addFreshEntity(entityfallingblock, (isCustom) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CUSTOM : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); // CraftBukkit - keep logic in SpawnReason if the method is use by API ++ world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit return entityfallingblock; } diff --git a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch index 34c2cdc20d..7192f5ecd9 100644 --- a/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch +++ b/paper-server/nms-patches/net/minecraft/world/entity/monster/EntityZombie.patch @@ -103,12 +103,12 @@ EntityVillager entityvillager = (EntityVillager) entityliving; - EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false); + // CraftBukkit start -+ zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), false); ++ zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION); + } + } -+ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, boolean custom) { -+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, (custom) ? CreatureSpawnEvent.SpawnReason.CUSTOM : CreatureSpawnEvent.SpawnReason.INFECTION); ++ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) { ++ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason); + if (entityzombievillager != null) { + // CraftBukkit end entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 6248636fed..7e66df390e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -1145,7 +1145,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(material, "Material cannot be null"); Validate.isTrue(material.isBlock(), "Material must be a block"); - EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), true); + EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), CraftMagicNumbers.getBlock(material).defaultBlockState(), SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); } @@ -1154,7 +1154,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Validate.notNull(location, "Location cannot be null"); Validate.notNull(data, "BlockData cannot be null"); - EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), true); + EntityFallingBlock entity = EntityFallingBlock.fall(world, new BlockPosition(location.getX(), location.getY(), location.getZ()), ((CraftBlockData) data).getState(), SpawnReason.CUSTOM); return (FallingBlock) entity.getBukkitEntity(); } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index c67ecdbe8e..72aa1ecd9a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -17,6 +17,7 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.entity.EntityType; import org.bukkit.entity.Villager; import org.bukkit.entity.ZombieVillager; +import org.bukkit.event.entity.CreatureSpawnEvent; public class CraftVillager extends CraftAbstractVillager implements Villager { @@ -124,7 +125,7 @@ public class CraftVillager extends CraftAbstractVillager implements Villager { @Override public ZombieVillager zombify() { - EntityZombieVillager entityzombievillager = EntityZombie.zombifyVillager(getHandle().level.getMinecraftWorld(), getHandle(), getHandle().blockPosition(), isSilent(), true); + EntityZombieVillager entityzombievillager = EntityZombie.zombifyVillager(getHandle().level.getMinecraftWorld(), getHandle(), getHandle().blockPosition(), isSilent(), CreatureSpawnEvent.SpawnReason.CUSTOM); return (entityzombievillager != null) ? (ZombieVillager) entityzombievillager.getBukkitEntity() : null; }