net.minecraftforge.event.entity.living.LivingSpawnEvent Java Examples
The following examples show how to use
net.minecraftforge.event.entity.living.LivingSpawnEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityEvents.java From patchwork-api with GNU Lesser General Public License v2.1 | 5 votes |
public static Result canEntitySpawn(MobEntity entity, IWorld world, double x, double y, double z, MobSpawnerLogic spawner, SpawnType spawnType) { if (entity == null) { return Result.DEFAULT; } LivingSpawnEvent.CheckSpawn event = new LivingSpawnEvent.CheckSpawn(entity, world, x, y, z, spawner, spawnType); MinecraftForge.EVENT_BUS.post(event); return event.getResult(); }
Example #2
Source File: EntitySpawnHandler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void onEntitySpawn(LivingSpawnEvent.SpecialSpawn event) { EntityLivingBase entity = event.getEntityLiving(); EnumDifficulty difficulty = entity.world.getDifficulty(); if (difficulty == EnumDifficulty.HARD && entity.getRNG().nextFloat() <= 0.03f) { if (entity instanceof EntityZombie) { ItemStack itemStack = MetaItems.NANO_SABER.getInfiniteChargedStack(); ToggleEnergyConsumerBehavior.setItemActive(itemStack, true); entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, itemStack); ((EntityZombie) entity).setDropChance(EntityEquipmentSlot.MAINHAND, 0.0f); } } }
Example #3
Source File: EventHandlerEntity.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public void on(LivingSpawnEvent.CheckSpawn event) { if(event.entityLiving.isCreatureType(EnumCreatureType.monster, false)) { double rangeSq = AuraEffects.LUX.getRange() * AuraEffects.LUX.getRange(); Vector3 entityPos = MiscUtils.getPositionVector(event.entity); for(ChunkCoordinates luxPylons : registeredLuxPylons) { Vector3 pylon = Vector3.fromCC(luxPylons); if(entityPos.distanceSquared(pylon) <= rangeSq) { event.setResult(Event.Result.DENY); return; } } } }
Example #4
Source File: ProtectionHandlers.java From MyTown2 with The Unlicense | 5 votes |
@SubscribeEvent public void checkSpawn(LivingSpawnEvent.CheckSpawn ev) { if (ev.getResult() == Event.Result.DENY) { return; } if(ProtectionManager.checkExist(ev.entity, true)) { ev.setResult(Event.Result.DENY); } }
Example #5
Source File: EntityWitherWitch.java From EnderZoo with Creative Commons Zero v1.0 Universal | 5 votes |
private void spawnCat(Point3i spawnLoc) { EntityWitherCat cat = new EntityWitherCat(world); cat.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(this)), null); cat.setOwner(this); cat.setPositionAndRotation(spawnLoc.x + 0.5, spawnLoc.y + 0.5, spawnLoc.z + 0.5, rotationYaw, 0); if (MinecraftForge.EVENT_BUS.post(new LivingSpawnEvent.CheckSpawn(cat, world, (float)cat.posX, (float)cat.posY, (float)cat.posZ, false))) { return; } if(!cat.getCanSpawnHere()) { return; } cats.add(cat); world.spawnEntity(cat); }
Example #6
Source File: EntityEvents.java From patchwork-api with GNU Lesser General Public License v2.1 | 4 votes |
public static boolean doSpecialSpawn(MobEntity entity, IWorld world, double x, double y, double z, MobSpawnerLogic spawner, SpawnType spawnType) { return MinecraftForge.EVENT_BUS.post(new LivingSpawnEvent.SpecialSpawn(entity, world, x, y, z, spawner, spawnType)); }
Example #7
Source File: ProtectionHandlers.java From MyTown2 with The Unlicense | 4 votes |
@SubscribeEvent public void specialSpawn(LivingSpawnEvent.SpecialSpawn ev) { if (ev.isCanceled()) return; ProtectionManager.checkExist(ev.entity, true); }
Example #8
Source File: DebugUtil.java From EnderZoo with Creative Commons Zero v1.0 Universal | 4 votes |
@SubscribeEvent public void onMonsterSpawn(LivingSpawnEvent evt) { if (evt.getEntityLiving() != null) { //&& !evt.entityLiving.getClass().getName().contains("enderzoo")) { evt.setResult(Result.DENY); } }