use of net.minecraft.entity.monster.GhastEntity in project Magma-1.16.x by magmafoundation.
the class CraftEventFactory method doEntityAddEventCalling.
public static boolean doEntityAddEventCalling(World world, Entity entity, SpawnReason spawnReason) {
if (entity == null)
return false;
org.bukkit.event.Cancellable event = null;
if (entity instanceof net.minecraft.entity.LivingEntity && !(entity instanceof ServerPlayerEntity)) {
boolean isAnimal = entity instanceof AnimalEntity || entity instanceof WaterMobEntity || entity instanceof GolemEntity;
boolean isMonster = entity instanceof MonsterEntity || entity instanceof GhastEntity || entity instanceof SlimeEntity;
boolean isNpc = entity instanceof INPC;
if (spawnReason != CreatureSpawnEvent.SpawnReason.CUSTOM) {
if (isAnimal && !world.getWorldCB().getAllowAnimals() || isMonster && !world.getWorldCB().getAllowMonsters() || isNpc && !world.getServer().getServer().isSpawningAnimals()) {
entity.removed = true;
return false;
}
}
event = CraftEventFactory.callCreatureSpawnEvent((net.minecraft.entity.LivingEntity) entity, spawnReason);
} else if (entity instanceof ItemEntity) {
event = CraftEventFactory.callItemSpawnEvent((ItemEntity) entity);
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
// Not all projectiles extend ThrowableEntity, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
} else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Vehicle) {
event = CraftEventFactory.callVehicleCreateEvent(entity);
// Spigot start
} else if (entity instanceof ExperienceOrbEntity) {
ExperienceOrbEntity xp = (ExperienceOrbEntity) entity;
double radius = world.spigotConfig.expMerge;
if (radius > 0) {
List<Entity> entities = world.getEntities(entity, entity.getBoundingBox().inflate(radius, radius, radius));
for (Entity e : entities) {
if (e instanceof ExperienceOrbEntity) {
ExperienceOrbEntity loopItem = (ExperienceOrbEntity) e;
if (!loopItem.removed) {
xp.value += loopItem.value;
loopItem.remove();
}
}
}
}
// Spigot end
} else if (!(entity instanceof ServerPlayerEntity)) {
event = CraftEventFactory.callEntitySpawnEvent(entity);
}
if (event != null && (event.isCancelled() || entity.removed)) {
Entity vehicle = entity.getVehicle();
if (vehicle != null) {
vehicle.removed = true;
}
for (Entity passenger : entity.getPassengers()) {
passenger.removed = true;
}
entity.removed = true;
return false;
}
return true;
}
use of net.minecraft.entity.monster.GhastEntity in project LoliServer by Loli-Server.
the class CraftEventFactory method doEntityAddEventCalling.
public static boolean doEntityAddEventCalling(World world, Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) {
if (entity == null)
return false;
Cancellable event = null;
if (entity instanceof LivingEntity && !(entity instanceof ServerPlayerEntity)) {
boolean isAnimal = entity instanceof AnimalEntity || entity instanceof WaterMobEntity || entity instanceof GolemEntity;
boolean isMonster = entity instanceof MonsterEntity || entity instanceof GhastEntity || entity instanceof SlimeEntity;
boolean isNpc = entity instanceof NPC;
if (spawnReason != CreatureSpawnEvent.SpawnReason.CUSTOM) {
if (isAnimal && !world.getWorld().getAllowAnimals() || isMonster && !world.getWorld().getAllowMonsters() || isNpc && !world.getServer().getServer().areNpcsEnabled()) {
entity.removed = true;
return false;
}
}
event = CraftEventFactory.callCreatureSpawnEvent((LivingEntity) entity, spawnReason);
} else if (entity instanceof ItemEntity) {
event = CraftEventFactory.callItemSpawnEvent((ItemEntity) entity);
} else if (entity.getBukkitEntity() instanceof Projectile) {
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
} else if (entity.getBukkitEntity() instanceof Vehicle) {
event = CraftEventFactory.callVehicleCreateEvent(entity);
} else if (entity.getBukkitEntity() instanceof LightningStrike) {
LightningStrikeEvent.Cause cause = (spawnReason == CreatureSpawnEvent.SpawnReason.COMMAND ? LightningStrikeEvent.Cause.COMMAND : LightningStrikeEvent.Cause.UNKNOWN);
event = CraftEventFactory.callLightningStrikeEvent((LightningStrike) entity.getBukkitEntity(), cause);
} else // Spigot start
if (entity instanceof ExperienceOrbEntity) {
ExperienceOrbEntity xp = (ExperienceOrbEntity) entity;
double radius = world.spigotConfig.expMerge;
if (radius > 0) {
List<Entity> entities = world.getEntities(entity, entity.getBoundingBox().inflate(radius, radius, radius));
for (Entity e : entities) {
if (e instanceof ExperienceOrbEntity) {
ExperienceOrbEntity loopItem = (ExperienceOrbEntity) e;
if (!loopItem.removed) {
xp.value += loopItem.value;
loopItem.remove();
}
}
}
}
// Spigot end
} else if (!(entity instanceof ServerPlayerEntity)) {
event = CraftEventFactory.callEntitySpawnEvent(entity);
}
if (event != null && (event.isCancelled() || entity.removed)) {
Entity vehicle = entity.getVehicle();
if (vehicle != null) {
vehicle.removed = true;
}
for (Entity passenger : entity.getIndirectPassengers()) {
passenger.removed = true;
}
entity.removed = true;
return false;
}
return true;
}
Aggregations