mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 08:17:35 +00:00
Add isSpawner parameter to the CheckSpawn event (#4075)
This commit is contained in:
1 parent
43be1f46a5
commit
e1a2bcf902
3 files changed
+37
-6
No files matched your search
@@ -164,18 +164,27 @@ public class ForgeEventFactory
|
||||
MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack, hand));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #canEntitySpawn(EntityLiving, World, float, float, float, boolean)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static Result canEntitySpawn(EntityLiving entity, World world, float x, float y, float z)
|
||||
{
|
||||
return canEntitySpawn(entity, world, x, y, z, true);
|
||||
}
|
||||
|
||||
public static Result canEntitySpawn(EntityLiving entity, World world, float x, float y, float z, boolean isSpawner)
|
||||
{
|
||||
if (entity == null)
|
||||
return Result.DEFAULT;
|
||||
LivingSpawnEvent.CheckSpawn event = new LivingSpawnEvent.CheckSpawn(entity, world, x, y, z);
|
||||
LivingSpawnEvent.CheckSpawn event = new LivingSpawnEvent.CheckSpawn(entity, world, x, y, z, isSpawner);
|
||||
MinecraftForge.EVENT_BUS.post(event);
|
||||
return event.getResult();
|
||||
}
|
||||
|
||||
public static boolean canEntitySpawnSpawner(EntityLiving entity, World world, float x, float y, float z)
|
||||
{
|
||||
Result result = canEntitySpawn(entity, world, x, y, z);
|
||||
Result result = canEntitySpawn(entity, world, x, y, z, true);
|
||||
if (result == Result.DEFAULT)
|
||||
{
|
||||
return entity.getCanSpawnHere() && entity.isNotColliding(); // vanilla logic
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package net.minecraftforge.event.entity.living;
|
||||
|
||||
import net.minecraft.world.WorldEntitySpawner;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeEventFactory;
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
@@ -72,10 +70,34 @@ public class LivingSpawnEvent extends LivingEvent
|
||||
@HasResult
|
||||
public static class CheckSpawn extends LivingSpawnEvent
|
||||
{
|
||||
public CheckSpawn(EntityLiving entity, World world, float x, float y, float z)
|
||||
private final boolean isSpawner;
|
||||
|
||||
/**
|
||||
* CheckSpawn is fired when an Entity is about to be spawned.
|
||||
* @param entity the spawning entity
|
||||
* @param world the world to spawn in
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param z z coordinate
|
||||
* @param isSpawner true if this spawn is done by a MobSpawner,
|
||||
* false if it this spawn is coming from a WorldSpawner
|
||||
*/
|
||||
public CheckSpawn(EntityLiving entity, World world, float x, float y, float z, boolean isSpawner)
|
||||
{
|
||||
super(entity, world, x, y, z);
|
||||
this.isSpawner = isSpawner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link CheckSpawn#CheckSpawn(EntityLiving, World, float, float, float, boolean)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public CheckSpawn(EntityLiving entity, World world, float x, float y, float z)
|
||||
{
|
||||
this(entity, world, x, y, z, true);
|
||||
}
|
||||
|
||||
public boolean isSpawner() { return isSpawner; }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user