mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Fire LivingSpawnEvents for MobSpawners. Closes #2079
This commit is contained in:
1 parent
357d2f8d86
commit
debe0ffdf8
3 files changed
+30
-11
No files matched your search
@@ -135,6 +135,8 @@ public class ForgeEventFactory
|
||||
|
||||
public static Result canEntitySpawn(EntityLiving entity, World world, float x, float y, float z)
|
||||
{
|
||||
if (entity == null)
|
||||
return Result.DEFAULT;
|
||||
LivingSpawnEvent.CheckSpawn event = new LivingSpawnEvent.CheckSpawn(entity, world, x, y, z);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getResult();
|
||||
|
||||
@@ -6,8 +6,8 @@ import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* LivingSpawnEvent is fired whenever a living Entity is spawned. <br>
|
||||
* If a method utilizes this {@link Event} as its parameter, the method will
|
||||
* LivingSpawnEvent is fired for any events associated with Living Enttnies spawn status. <br>
|
||||
* If a method utilizes this {@link Event} as its parameter, the method will
|
||||
* receive every child event of this class.<br>
|
||||
* <br>
|
||||
* {@link #world} contains the world in which this living Entity is being spawned.<br>
|
||||
@@ -23,7 +23,7 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
private final float x;
|
||||
private final float y;
|
||||
private final float z;
|
||||
|
||||
|
||||
public LivingSpawnEvent(EntityLiving entity, World world, float x, float y, float z)
|
||||
{
|
||||
super(entity);
|
||||
@@ -39,7 +39,7 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
public float getZ() { return z; }
|
||||
/**
|
||||
* Fires before mob spawn events.
|
||||
*
|
||||
*
|
||||
* Result is significant:
|
||||
* DEFAULT: use vanilla spawn rules
|
||||
* ALLOW: allow the spawn
|
||||
@@ -56,9 +56,8 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* SpecialSpawn is fired when an Entity is to be spawned from a mob spawner.<br>
|
||||
* This event is fired whenever an Entity is spawned in a mob spawner in<br>
|
||||
* SpawnerAnimals#findChunksForSpawning(WorldServer, boolean, boolean, boolean).<br>
|
||||
* SpecialSpawn is fired when an Entity is to be spawned.<br>
|
||||
* This allows you to do special inializers in the new entity.<br>
|
||||
* <br>
|
||||
* This event is fired via the {@link ForgeHooks#doSpecialSpawn(EntityLiving, World, float, float, float)}.<br>
|
||||
* <br>
|
||||
@@ -77,17 +76,17 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
super(entity, world, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fired each tick for despawnable mobs to allow control over despawning.
|
||||
* {@link Result#DEFAULT} will pass the mob on to vanilla despawn mechanics.
|
||||
* {@link Result#ALLOW} will force the mob to despawn.
|
||||
* {@link Result#DENY} will force the mob to remain.
|
||||
* This is fired every tick for every despawnable entity. Be efficient in your handlers.
|
||||
*
|
||||
*
|
||||
* Note: this is not fired <em>if</em> the mob is definitely going to otherwise despawn. It is fired to check if
|
||||
* the mob can be allowed to despawn. See {@link EntityLiving#despawnEntity}
|
||||
*
|
||||
*
|
||||
* @author cpw
|
||||
*
|
||||
*/
|
||||
@@ -98,6 +97,6 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
{
|
||||
super(entity, entity.worldObj, (float)entity.posX, (float)entity.posY, (float)entity.posZ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user