Search in sources :

Example 11 with Creature

use of org.bukkit.entity.Creature in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applySenseSummoned.

private void applySenseSummoned(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    try {
        for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
            if (!(e instanceof LivingEntity))
                continue;
            if (!(e instanceof Creature))
                continue;
            ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
            if (!solEntity.isPet())
                continue;
            Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
            Location loc = getLivingEntity().getLocation().setDirection(dir);
            getLivingEntity().teleport(loc);
        }
    } catch (CoreStateInitException e) {
    }
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) CraftCreature(org.bukkit.craftbukkit.v1_12_R1.entity.CraftCreature) Creature(org.bukkit.entity.Creature) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 12 with Creature

use of org.bukkit.entity.Creature in project Towny by ElgarL.

the class TownyEntityListener method onEntityInteract.

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEntityInteract(EntityInteractEvent event) {
    if (plugin.isError()) {
        event.setCancelled(true);
        return;
    }
    Block block = event.getBlock();
    Entity entity = event.getEntity();
    Entity passenger = entity.getPassenger();
    TownyWorld World = null;
    try {
        World = TownyUniverse.getDataSource().getWorld(block.getLocation().getWorld().getName());
        if (!World.isUsingTowny())
            return;
    } catch (NotRegisteredException e) {
        // World not registered with Towny.
        e.printStackTrace();
        return;
    }
    try {
        TownyWorld townyWorld = TownyUniverse.getDataSource().getWorld(block.getLocation().getWorld().getName());
        if (townyWorld.isUsingTowny()) {
            // Prevent creatures trampling crops
            if (townyWorld.isDisableCreatureTrample()) {
                if ((block.getType() == Material.SOIL) || (block.getType() == Material.CROPS)) {
                    if (entity instanceof Creature) {
                        event.setCancelled(true);
                        return;
                    }
                }
            }
            /*
				 * Allow players in vehicles to activate pressure plates if they
				 * are permitted.
				 */
            if (passenger != null && passenger instanceof Player) {
                if (TownySettings.isSwitchMaterial(block.getType().name())) {
                    if (!plugin.getPlayerListener().onPlayerSwitchEvent((Player) passenger, block, null, World))
                        return;
                }
            }
            // Prevent creatures triggering stone pressure plates
            if (TownySettings.isCreatureTriggeringPressurePlateDisabled()) {
                if (block.getType() == Material.STONE_PLATE) {
                    if (entity instanceof Creature) {
                        event.setCancelled(true);
                        return;
                    }
                }
            }
        }
    } catch (NotRegisteredException e) {
        // Failed to fetch world
        e.printStackTrace();
    }
}
Also used : Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) Creature(org.bukkit.entity.Creature) NotRegisteredException(com.palmergames.bukkit.towny.exceptions.NotRegisteredException) Block(org.bukkit.block.Block) TownBlock(com.palmergames.bukkit.towny.object.TownBlock) TownyWorld(com.palmergames.bukkit.towny.object.TownyWorld) EventHandler(org.bukkit.event.EventHandler)

Example 13 with Creature

use of org.bukkit.entity.Creature in project Glowstone by GlowstoneMC.

the class BlockBed method blockInteract.

@Override
public boolean blockInteract(final GlowPlayer player, GlowBlock block, final BlockFace face, final Vector clickedLoc) {
    GlowWorld world = player.getWorld();
    MaterialData data = block.getState().getData();
    if (!(data instanceof Bed)) {
        warnMaterialData(Bed.class, data);
        return false;
    }
    block = getHead(block);
    // Disallow sleeping in nether and end biomes
    Biome biome = block.getBiome();
    if (EXPLOSIVE_IN_BIOMES.contains(biome)) {
        // Set off an explosion at the bed slightly stronger than TNT
        world.createExplosion(block.getLocation(), 5F, true);
        return true;
    }
    // Sleeping is only possible during the night or a thunderstorm
    // Tick values for day/night time taken from the minecraft wiki
    final long time = world.getTime();
    if ((time < 12541 || time > 23458) && !world.isThundering()) {
        GlowstoneMessages.Bed.DAY.send(player);
        return true;
    }
    if (isOccupied(block)) {
        GlowstoneMessages.Bed.OCCUPIED.send(player);
        return true;
    }
    if (!isWithinDistance(player, block, 3, 2, 3)) {
        // Distance between player and bed is too great, fail silently
        return true;
    }
    // (Don't use getEntitiesByType etc., because they copy the entire list of entities)
    for (Entity e : world.getEntityManager()) {
        if (e instanceof Creature && (e.getType() != EntityType.ZOMBIFIED_PIGLIN || ((PigZombie) e).isAngry()) && isWithinDistance(e, block.getRelative(BlockFace.DOWN), 8, 5, 8)) {
            GlowstoneMessages.Bed.MOB.send(player);
            return true;
        }
    }
    player.enterBed(block);
    return true;
}
Also used : Bed(org.bukkit.material.Bed) GlowBed(net.glowstone.block.entity.state.GlowBed) Entity(org.bukkit.entity.Entity) BedEntity(net.glowstone.block.entity.BedEntity) BlockEntity(net.glowstone.block.entity.BlockEntity) Biome(org.bukkit.block.Biome) Creature(org.bukkit.entity.Creature) PigZombie(org.bukkit.entity.PigZombie) GlowWorld(net.glowstone.GlowWorld) MaterialData(org.bukkit.material.MaterialData)

Example 14 with Creature

use of org.bukkit.entity.Creature in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applyMezSpellEffect.

private void applyMezSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    if (!(getLivingEntity() instanceof LivingEntity))
        return;
    try {
        LocalDateTime datetime = LocalDateTime.now();
        Timestamp expiretimestamp = Timestamp.valueOf(datetime.plus(6, ChronoUnit.SECONDS));
        StateManager.getInstance().getEntityManager().addMezzed(getLivingEntity(), expiretimestamp);
        if (getLivingEntity() instanceof Creature) {
            Creature creature = (Creature) getLivingEntity();
            creature.setTarget(null);
        }
        Utils.dismountEntity(getLivingEntity());
        Entity vehicle = getLivingEntity().getVehicle();
        if (vehicle != null) {
            vehicle.eject();
        }
        Utils.AddPotionEffect(getLivingEntity(), PotionEffectType.SLOW, 10);
        Utils.AddPotionEffect(getLivingEntity(), PotionEffectType.CONFUSION, 1);
    } catch (CoreStateInitException e) {
        return;
    }
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) LocalDateTime(java.time.LocalDateTime) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) CraftCreature(org.bukkit.craftbukkit.v1_12_R1.entity.CraftCreature) Creature(org.bukkit.entity.Creature) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Timestamp(java.sql.Timestamp)

Example 15 with Creature

use of org.bukkit.entity.Creature in project solinia3-core by mixxit.

the class SoliniaActiveSpell method applyTauntSpell.

private void applyTauntSpell(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
    if (!(getLivingEntity() instanceof Creature))
        return;
    Creature creature = (Creature) getLivingEntity();
    Entity source = Bukkit.getEntity(getSourceUuid());
    if (source instanceof LivingEntity)
        creature.setTarget((LivingEntity) source);
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) CraftEntity(org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity) LivingEntity(org.bukkit.entity.LivingEntity) PathEntity(net.minecraft.server.v1_12_R1.PathEntity) CraftCreature(org.bukkit.craftbukkit.v1_12_R1.entity.CraftCreature) Creature(org.bukkit.entity.Creature)

Aggregations

Creature (org.bukkit.entity.Creature)21 LivingEntity (org.bukkit.entity.LivingEntity)16 Entity (org.bukkit.entity.Entity)15 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)10 Player (org.bukkit.entity.Player)10 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)9 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)6 Timestamp (java.sql.Timestamp)5 ArrayList (java.util.ArrayList)5 CraftCreature (org.bukkit.craftbukkit.v1_12_R1.entity.CraftCreature)4 Location (org.bukkit.Location)3 World (org.bukkit.World)3 Biome (org.bukkit.block.Biome)3 Block (org.bukkit.block.Block)3 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)3 EventHandler (org.bukkit.event.EventHandler)3 ItemStack (org.bukkit.inventory.ItemStack)3 HashMultiset (com.google.common.collect.HashMultiset)2 Multiset (com.google.common.collect.Multiset)2 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)2