mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 02:20:01 +03:00
35 lines
1.9 KiB
Diff
35 lines
1.9 KiB
Diff
--- ../src-base/minecraft/net/minecraft/item/ItemMonsterPlacer.java
|
|
+++ ../src-work/minecraft/net/minecraft/item/ItemMonsterPlacer.java
|
|
@@ -220,6 +220,11 @@
|
|
@Nullable
|
|
public static Entity spawnCreature(World worldIn, @Nullable ResourceLocation entityID, double x, double y, double z)
|
|
{
|
|
+ return spawnCreature(worldIn, entityID, x, y, z, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public static Entity spawnCreature(World worldIn, @Nullable ResourceLocation entityID, double x, double y, double z, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
|
if (entityID != null && EntityList.ENTITY_EGGS.containsKey(entityID))
|
|
{
|
|
Entity entity = null;
|
|
@@ -234,9 +239,17 @@
|
|
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(worldIn.rand.nextFloat() * 360.0F), 0.0F);
|
|
entityliving.rotationYawHead = entityliving.rotationYaw;
|
|
entityliving.renderYawOffset = entityliving.rotationYaw;
|
|
+ if (net.minecraftforge.event.ForgeEventFactory.doSpecialSpawn(entityliving, worldIn, (float) x, (float) y, (float) z, null)) return null;
|
|
entityliving.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityliving)), (IEntityLivingData)null);
|
|
- worldIn.spawnEntity(entity);
|
|
- entityliving.playLivingSound();
|
|
+ // worldIn.spawnEntity(entity);
|
|
+ // entityliving.playLivingSound();
|
|
+ // CraftBukkit start - don't return an entity when CreatureSpawnEvent is canceled
|
|
+ if (!worldIn.addEntity(entity, spawnReason)) {
|
|
+ entity = null;
|
|
+ } else {
|
|
+ entityliving.playLivingSound();
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
|