Java Code Examples for org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason

The following are top voted examples for showing how to use org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 7 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_8_R1.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R1.CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final net.minecraft.server.v1_8_R1.NBTTagCompound compound = new net.minecraft.server.v1_8_R1.NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.rabbit.getEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 2
Project: Uranium   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 3
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 4
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 5
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 6
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 7
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 8
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 9
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R3.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 10
Project: BlockBall   File: CustomArmorstand.java   Source Code and License 6 votes vote down vote up
@Override
public void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    final NBTTagCompound compound = new NBTTagCompound();
    compound.setBoolean("invulnerable", true);
    compound.setBoolean("Invisible", true);
    compound.setBoolean("PersistenceRequired", true);
    compound.setBoolean("NoBasePlate", true);
    this.a(compound);
    this.slime = new CustomRabbit(location.getWorld(), true, this);
    this.slime.spawn(location);
    this.getSpigotEntity().setHeadPose(new EulerAngle(0, 0, 0));
    this.getSpigotEntity().setBodyPose(new EulerAngle(0, 0, 2778));
    this.getSpigotEntity().setRightArmPose(new EulerAngle(2778, 0, 0));
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 11
Project: ADR   File: mobs.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawnerEggs") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER_EGG) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySpawners") == true) {
  if (event.getSpawnReason() == SpawnReason.SPAWNER) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
 if (getConfig().getBoolean("Config.Mode.BlockPayEntitiesSpawnedBySummonCommand") == true) {
  if (event.getSpawnReason() == SpawnReason.DEFAULT) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
  if (event.getSpawnReason() == SpawnReason.CUSTOM) {
	  this.DisabledEntitiesHashMap.put(event.getEntity().getUniqueId(), true);
  }
 }
}
 
Example 12
Project: GriefPreventionFlags   File: FlagDef_NoMonsterSpawns.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    LivingEntity entity = event.getEntity();
    if(!this.isMonster(entity)) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG)
    {
        entity.setMetadata(this.ALLOW_TARGET_TAG, new FixedMetadataValue(GPFlags.instance, new Boolean(true)));
        return;
    }
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
Example 13
Project: GriefPreventionFlags   File: FlagDef_NoMobSpawns.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
    if(!(event.getEntity() instanceof LivingEntity)) return;
    
    if(event.getLocation() == null) return;
    
    EntityType type = event.getEntityType();
    if(type == EntityType.PLAYER) return;
    if(type == EntityType.ARMOR_STAND) return;
    
    SpawnReason reason = event.getSpawnReason();
    if(reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) return;
    
    
    Flag flag = this.GetFlagInstanceAtLocation(event.getLocation(), null);
    if(flag == null) return;
    
    event.setCancelled(true);
}
 
Example 14
Project: ThermosRebased   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 15
Project: BloodMoon   File: MoreSpawningListener.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() != SpawnReason.NATURAL) { //TODO: Should check for Custom instead of checking against natural?
        return;
    }

    EntityType type = event.getEntityType();
    World world = event.getLocation().getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.MORE_SPAWNING) && worldConfig.getStringList(Config.FEATURE_MORE_SPAWNING_MOBS).contains(type.getName().toUpperCase())) {
        for (int i = 0; i < Math.max(worldConfig.getInt(Config.FEATURE_MORE_SPAWNING_MULTIPLIER), 1); ++i) {
            for (BloodMoonEntityType bloodMoonEntity : BloodMoonEntityType.values()) {
                if (type == bloodMoonEntity.getEntityType()) {
                    bloodMoonEntity.spawnEntity(event.getLocation().add((random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5, (random.nextDouble() * 3) - 1.5));
                    return;
                }
            }
        }
    }
}
 
Example 16
Project: Thermos   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 17
Project: KCauldron   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 18
Project: CauldronGit   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 19
Project: Cauldron-Old   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 20
Project: GriefPreventionPlus   File: EntityEventHandler.java   Source Code and License 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event)
{
	//these rules apply only to creative worlds
	if(!GriefPrevention.instance.creativeRulesApply(event.getLocation())) return;
	
	//chicken eggs and breeding could potentially make a mess in the wilderness, once griefers get involved
	SpawnReason reason = event.getSpawnReason();
	if(reason != SpawnReason.SPAWNER_EGG && reason != SpawnReason.BUILD_IRONGOLEM && reason != SpawnReason.BUILD_SNOWMAN)
	{
		event.setCancelled(true);
		return;
	}

	//otherwise, just apply the limit on total entities per claim (and no spawning in the wilderness!)
	Claim claim = this.dataStore.getClaimAt(event.getLocation(), false, null);
	if(claim == null || claim.allowMoreEntities() != null)
	{
		event.setCancelled(true);
		return;
	}
}
 
Example 21
Project: Cauldron-Reloaded   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 22
Project: FFoKC   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 23
Project: civcraft   File: MobBaseZombie.java   Source Code and License 6 votes vote down vote up
public static Entity spawn(Location loc, ICustomMob iCustom, String name) {
	CraftWorld world = (CraftWorld) loc.getWorld();
	World mcWorld = world.getHandle();
	MobBaseZombie zombie = new MobBaseZombie(mcWorld, iCustom);
	
	if (name != null) {
		zombie.setCustomName(name);
		zombie.setCustomNameVisible(true);
	}
	iCustom.setEntity(zombie);
	
	zombie.setPosition(loc.getX(), loc.getY(), loc.getZ());
	mcWorld.addEntity(zombie, SpawnReason.CUSTOM);
	
	return zombie;
}
 
Example 24
Project: Cauldron   File: CraftWorld.java   Source Code and License 6 votes vote down vote up
public Entity spawnEntity(Location loc, EntityType entityType) {
    // Cauldron start - handle custom entity spawns from plugins
    if (EntityRegistry.entityClassMap.get(entityType.getName()) != null)
    {
        net.minecraft.entity.Entity entity = null;
        entity = getEntity(EntityRegistry.entityClassMap.get(entityType.getName()), world);
        if (entity != null)
        {
            entity.setLocationAndAngles(loc.getX(), loc.getY(), loc.getZ(), 0, 0);
            world.addEntity(entity, SpawnReason.CUSTOM);
            return entity.getBukkitEntity();
        }
    }
    // Cauldron end
    return spawn(loc, entityType.getEntityClass());
}
 
Example 25
Project: tregmine   File: ZoneEntityListener.java   Source Code and License 6 votes vote down vote up
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event)
{
    Entity entity = event.getEntity();

    Location location = event.getLocation();
    Point pos = new Point(location.getBlockX(), location.getBlockZ());

    ZoneWorld world = plugin.getWorld(entity.getWorld());
    Zone zone = world.findZone(pos);

    if (zone == null || zone.hasHostiles()) {
        return;
    }

    if (!allowedMobs.contains(event.getEntityType()) &&
        event.getSpawnReason() == SpawnReason.NATURAL) {

        event.setCancelled(true);
    }
}
 
Example 26
Project: NPlugins   File: EnderDragonListener.java   Source Code and License 6 votes vote down vote up
/**
 * - Prevents natural spawn of EnderDragon
 * - Prevents too many Dragons in the End world
 * - Handle custom health and take care of this new Dragon
 *
 * @param event a CreatureSpawnEvent
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEnderDragonSpawn(final CreatureSpawnEvent event) {
    if (event.getEntityType() == EntityType.ENDER_DRAGON) {
        final EndWorldHandler handler = this.plugin.getHandler(StringUtil.toLowerCamelCase(event.getLocation().getWorld().getName()));
        if (handler != null) {
            if (handler.getNumberOfAliveEnderDragons() >= handler.getConfig().getRespawnNumber()) {
                event.setCancelled(true);
            } else {
                if (event.getSpawnReason() != SpawnReason.CUSTOM && event.getSpawnReason() != SpawnReason.SPAWNER_EGG) {
                    event.setCancelled(true);
                } else {
                    if (!handler.getDragons().containsKey(event.getEntity().getUniqueId())) {
                        handler.getDragons().put(event.getEntity().getUniqueId(), new HashMap<String, Double>());
                        event.getEntity().setMaxHealth(handler.getConfig().getEdHealth());
                        event.getEntity().setHealth(event.getEntity().getMaxHealth());
                    }
                    handler.getLoadedDragons().add(event.getEntity().getUniqueId());
                }
            }
        }
    }
}
 
Example 27
Project: Uranium   File: CraftWorld.java   Source Code and License 5 votes vote down vote up
public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException {
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(material.isBlock(), "Material must be a block");

    double x = location.getBlockX() + 0.5;
    double y = location.getBlockY() + 0.5;
    double z = location.getBlockZ() + 0.5;

    net.minecraft.entity.item.EntityFallingBlock entity = new net.minecraft.entity.item.EntityFallingBlock(world, x, y, z, net.minecraft.block.Block.getBlockById(material.getId()), data);
    entity.field_145812_b = 1; // ticksLived

    world.addEntity(entity, SpawnReason.CUSTOM);
    return (FallingBlock) entity.getBukkitEntity();
}
 
Example 28
Project: Uranium   File: CauldronHooks.java   Source Code and License 5 votes vote down vote up
public static void logEntitySpawn(World world, Entity entity, SpawnReason spawnReason)
{
    if (MinecraftServer.cauldronConfig.entitySpawnLogging.getValue())
    {
        logInfo("Dim: {0} Spawning ({1}): {2}", world.provider.dimensionId, spawnReason, entity);
        logInfo("Dim: {0} Entities Last Tick: {1}", world.provider.dimensionId, world.entitiesTicked);
        logInfo("Dim: {0} Tiles Last Tick: {1}", world.provider.dimensionId, world.tilesTicked);
        //logInfo("Chunk Is Active: {0}", world.inActiveChunk(entity));
        logStack();
    }
}
 
Example 29
Project: ZentrelaRPG   File: EnvironmentManager.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.getSpawnReason() != SpawnReason.CUSTOM) {
        event.getEntity().setHealth(0);
        event.getEntity().remove();
    }
}
 
Example 30
Project: ZentrelaRPG   File: AoeArrowSpell.java   Source Code and License 5 votes vote down vote up
public void castSpell(final LivingEntity caster, final MobData md, Player target) {
    for (Entity p : RMath.getNearbyEntitiesCylinder(md.entity.getLocation(), md.ai.rangeDistance, 9)) {
        if (p instanceof Player && Spell.canDamage(p, false)) {
            EntityLiving e = (EntityLiving) ((CraftEntity) caster).getHandle();
            EntityArrow entityarrow = new EntityTippedArrow(e.world, e);
            EntityLiving etarget = (EntityLiving) (((CraftPlayer) p).getHandle());
            double d0 = etarget.locX - e.locX;
            double d1 = etarget.getBoundingBox().b + etarget.length / 3.0F - entityarrow.locY;
            double d2 = etarget.locZ - e.locZ;
            double d3 = MathHelper.sqrt(d0 * d0 + d2 * d2);
            entityarrow.shoot(d0, d1 + d3 * 0.2D, d2, md.ai.rangePower, 10);
            e.world.addEntity(entityarrow, SpawnReason.CUSTOM);
        }
    }
}
 
Example 31
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 32
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_9_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 33
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 5 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_9_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final NBTTagCompound compound = new NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 34
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_9_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 35
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 5 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_9_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final NBTTagCompound compound = new NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 36
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_10_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 37
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 5 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final NBTTagCompound compound = new NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 38
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_12_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 39
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 5 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final NBTTagCompound compound = new NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand) this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand) this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand) this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand) this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand) this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand) this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 40
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_11_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 41
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 5 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final NBTTagCompound compound = new NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 42
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R3.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 43
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 5 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_8_R3.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R3.CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final net.minecraft.server.v1_8_R3.NBTTagCompound compound = new net.minecraft.server.v1_8_R3.NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 44
Project: PetBlocks   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
/**
 * Spawns the entity at the given location
 *
 * @param mLocation location
 */
@Override
public void spawn(Object mLocation) {
    final Location location = (Location) mLocation;
    final LivingEntity entity = (LivingEntity) this.getEntity();
    final net.minecraft.server.v1_8_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    entity.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    entity.setMetadata("keep", this.getKeepField());
    entity.setCustomNameVisible(false);
    entity.setCustomName("PetBlockIdentifier");
}
 
Example 45
Project: PetBlocks   File: CustomGroundArmorstand.java   Source Code and License 5 votes vote down vote up
public void spawn(Location location) {
    final PetBlockSpawnEvent event = new PetBlockSpawnEvent(this);
    Bukkit.getPluginManager().callEvent(event);
    if (!event.isCanceled()) {
        NMSRegistry.accessWorldGuardSpawn(location);
        this.rabbit.spawn(location);
        final net.minecraft.server.v1_8_R2.World mcWorld = ((org.bukkit.craftbukkit.v1_8_R2.CraftWorld) location.getWorld()).getHandle();
        this.setPosition(location.getX(), location.getY(), location.getZ());
        mcWorld.addEntity(this, SpawnReason.CUSTOM);
        final net.minecraft.server.v1_8_R2.NBTTagCompound compound = new net.minecraft.server.v1_8_R2.NBTTagCompound();
        compound.setBoolean("invulnerable", true);
        compound.setBoolean("Invisible", true);
        compound.setBoolean("PersistenceRequired", true);
        compound.setBoolean("ShowArms", true);
        compound.setBoolean("NoBasePlate", true);
        this.a(compound);
        ((ArmorStand)this.getArmorStand()).setBodyPose(new EulerAngle(0, 0, 2878));
        ((ArmorStand)this.getArmorStand()).setLeftArmPose(new EulerAngle(2878, 0, 0));
        ((ArmorStand)this.getArmorStand()).setMetadata("keep", this.getKeepField());
        NMSRegistry.rollbackWorldGuardSpawn(location);
        ((ArmorStand)this.getArmorStand()).setCustomNameVisible(true);
        ((ArmorStand)this.getArmorStand()).setCustomName(this.petMeta.getPetDisplayName());
        ((ArmorStand)this.getArmorStand()).setRemoveWhenFarAway(false);
        ((LivingEntity) this.getEngineEntity()).setRemoveWhenFarAway(false);
        this.health = ConfigPet.getInstance().getCombat_health();
        if (this.petMeta == null)
            return;
        PetBlockHelper.setItemConsideringAge(this);
    }
}
 
Example 46
Project: SurvivalPlus   File: ChickenSpawn.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onChickenSpawn(CreatureSpawnEvent e)
{
	if(e.getEntityType() == EntityType.CHICKEN)
	{
		if(e.getSpawnReason() == SpawnReason.BREEDING)
		{
			e.setCancelled(true);
			Random rand = new Random();
			Location loc = e.getLocation();
			loc.getWorld().dropItem(loc, new ItemStack(Material.EGG, rand.nextInt(4) + 1));
        	loc.getWorld().playSound(loc, Sound.ENTITY_CHICKEN_EGG, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
		}
	}
}
 
Example 47
Project: mczone   File: Events.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) {
	if (event.getSpawnReason() == SpawnReason.CUSTOM || event.getSpawnReason() == SpawnReason.EGG)
		return;
	
	event.setCancelled(true);
}
 
Example 48
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R1.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 49
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 50
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 51
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 52
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 53
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 54
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R3.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 55
Project: BlockBall   File: CustomRabbit.java   Source Code and License 5 votes vote down vote up
void spawn(Location location) {
    NMSRegistry.accessWorldGuardSpawn(location);
    final net.minecraft.server.v1_8_R2.World mcWorld = ((CraftWorld) location.getWorld()).getHandle();
    this.setPosition(location.getX(), location.getY(), location.getZ());
    mcWorld.addEntity(this, SpawnReason.CUSTOM);
    this.getSpigotEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 9999999, 1));
    this.getSpigotEntity().setCustomNameVisible(false);
    this.getSpigotEntity().setCustomName("MyBallsIdentifier");
    NMSRegistry.rollbackWorldGuardSpawn(location);
}
 
Example 56
Project: NeverLag   File: SpawnRater.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void rateControler(CreatureSpawnEvent e) {
	if (!cm.spawnRateTweakerEnabled) {
		return;
	}
	// 获取刷怪原因(来源)
	SpawnReason spawnReason = e.getSpawnReason();
	switch (spawnReason) {
	// 特殊区块
	case CHUNK_GEN:
		if (cm.spawnRateChunkGen <= 0 || rnd.nextInt(100) > cm.spawnRateChunkGen) {
			e.setCancelled(true);
		}
		break;
	// 刷怪笼
	case SPAWNER:
		if (cm.spawnRateSpawner <= 0 || rnd.nextInt(100) > cm.spawnRateSpawner) {
			e.setCancelled(true);
		}
		break;
	// 刷铁塔
	case VILLAGE_DEFENSE:
		if (cm.spawnRateVillage <= 0 || rnd.nextInt(100) > cm.spawnRateVillage) {
			e.setCancelled(true);
		}
		break;
	// 自然条件
	case NATURAL:
		if (cm.spawnRateNatural <= 0 || rnd.nextInt(100) > cm.spawnRateNatural) {
			e.setCancelled(true);
		}
		break;
	// 下界传送门
	case NETHER_PORTAL:
		if (cm.spawnRatePortal <= 0 || rnd.nextInt(100) > cm.spawnRatePortal) {
			e.setCancelled(true);
		}
		break;
	}
}
 
Example 57
Project: ZentrelaCore   File: REntities.java   Source Code and License 5 votes vote down vote up
public static LivingEntity createLivingEntity(Class<? extends Entity> type, Location loc) {
    net.minecraft.server.v1_10_R1.World world = ((CraftWorld) (loc.getWorld())).getHandle();
    net.minecraft.server.v1_10_R1.EntityLiving e = null;
    try {
        e = (EntityLiving) (type.getDeclaredConstructor(net.minecraft.server.v1_10_R1.World.class).newInstance(world));
    } catch (Exception e2) {
        e2.printStackTrace();
    }
    e.P = 2.5f;
    e.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    world.addEntity(e, SpawnReason.CUSTOM);
    LivingEntity le = (LivingEntity) (((net.minecraft.server.v1_10_R1.Entity) e).getBukkitEntity());
    le.setRemoveWhenFarAway(false);
    return le;
}
 
Example 58
Project: Damocles   File: EventCanceller.java   Source Code and License 5 votes vote down vote up
@EventHandler
public void onMobSpawnEgg(CreatureSpawnEvent event){
	if(event.getSpawnReason() == SpawnReason.SPAWNER_EGG){
		if(event.getEntity() instanceof Creature){
			Creature creature = (Creature) event.getEntity();
			creature.setAI(false);
		}
	}
}
 
Example 59
Project: world-of-icerealm   File: Frontier.java   Source Code and License 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL)
public void onMonsterSpawn(CreatureSpawnEvent event) {
	
	if (event.getSpawnReason() != SpawnReason.CUSTOM && _activated && event.getEntity() instanceof Monster) {
		
		double modifier = calculateGlobalModifier(event.getLocation());

		if (modifier > 0.0) {
			
			// boost le health
			Damageable entityDamage = event.getEntity();
			double maxHealth = entityDamage.getMaxHealth() + (int)(modifier * entityDamage.getMaxHealth());
			try {
				EntityReflection.setEntityPropertyValue(event.getEntity(), EntityReflection.HEALTH, maxHealth);
				ScenarioService.getInstance().updateDamageModifier(event.getEntity(), modifier);
			}
			catch (Exception ex) {
				_logger.info("exception on Frontier!");
			}
			
			// ajuste les rare drops, rien en diamant dans le premier palier
			if (LocationUtil.getDistanceBetween(event.getLocation(), event.getLocation().getWorld().getSpawnLocation()) <= _divider) {
				RareDropsMultiplierData.getInstance().addEntityRareDropsMultiplier(event.getEntity().getEntityId(), new RareDropsMultipliers(0.25, 0.25, 0.00));
			}
			else {
				RareDropsMultiplierData.getInstance().addEntityRareDropsMultiplier(event.getEntity().getEntityId(), new RareDropsMultipliers(modifier, modifier, modifier));
			}
		}
	}
}
 
Example 60
Project: ThermosRebased   File: CraftWorld.java   Source Code and License 5 votes vote down vote up
public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException {
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(material.isBlock(), "Material must be a block");

    double x = location.getBlockX() + 0.5;
    double y = location.getBlockY() + 0.5;
    double z = location.getBlockZ() + 0.5;

    net.minecraft.entity.item.EntityFallingBlock entity = new net.minecraft.entity.item.EntityFallingBlock(world, x, y, z, net.minecraft.block.Block.getBlockById(material.getId()), data);
    entity.field_145812_b = 1; // ticksLived

    world.addEntity(entity, SpawnReason.CUSTOM);
    return (FallingBlock) entity.getBukkitEntity();
}