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) {
}
}
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();
}
}
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;
}
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;
}
}
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);
}
Aggregations