Search in sources :

Example 36 with CraftEntity

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method damage.

@Override
public void damage(Damageable target, double amount, Entity source, String damageType) {
    if (target == null || target.isDead())
        return;
    if (damageType.equalsIgnoreCase("direct")) {
        double health = target.getHealth() - amount;
        target.setHealth(Math.max(health, 0));
        return;
    }
    if (damageType.equalsIgnoreCase("magic")) {
        magicDamage(target, amount, source);
        return;
    }
    DamageSource damageSource = getDamageSource(damageType);
    if (damageSource == null) {
        magicDamage(target, amount, source);
        return;
    }
    net.minecraft.world.entity.Entity targetHandle = ((CraftEntity) target).getHandle();
    if (targetHandle == null)
        return;
    try (EnteredStateTracker.Touchable damaging = isDamaging.enter()) {
        damaging.touch();
        targetHandle.hurt(damageSource, (float) amount);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : EntityDamageSource(net.minecraft.world.damagesource.EntityDamageSource) DamageSource(net.minecraft.world.damagesource.DamageSource) CraftEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity) EnteredStateTracker(com.elmakers.mine.bukkit.utility.EnteredStateTracker)

Example 37 with CraftEntity

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method addToWorld.

@Override
public boolean addToWorld(World world, Entity entity, CreatureSpawnEvent.SpawnReason reason) {
    ServerLevel level = ((CraftWorld) world).getHandle();
    net.minecraft.world.entity.Entity entityHandle = ((CraftEntity) entity).getHandle();
    level.addEntity(entityHandle, reason);
    return true;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) CraftEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 38 with CraftEntity

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity in project MagicPlugin by elBukkit.

the class MobUtils method setPathfinderTarget.

@Override
public boolean setPathfinderTarget(Entity entity, Entity target, double speed) {
    if (entity == null || target == null)
        return false;
    net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
    net.minecraft.world.entity.Entity nmstarget = ((CraftEntity) target).getHandle();
    if (!(nmsEntity instanceof Mob)) {
        return false;
    }
    Mob mob = (Mob) nmsEntity;
    mob.getNavigation().moveTo(nmstarget, speed);
    return true;
}
Also used : PathfinderMob(net.minecraft.world.entity.PathfinderMob) Mob(net.minecraft.world.entity.Mob) CraftEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity)

Example 39 with CraftEntity

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity in project MagicPlugin by elBukkit.

the class MobUtils method setPathfinderTarget.

@Override
public boolean setPathfinderTarget(Entity entity, Entity target, double speed) {
    if (entity == null || target == null)
        return false;
    net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
    net.minecraft.world.entity.Entity nmstarget = ((CraftEntity) target).getHandle();
    if (!(nmsEntity instanceof Mob)) {
        return false;
    }
    Mob mob = (Mob) nmsEntity;
    mob.getNavigation().moveTo(nmstarget, speed);
    return true;
}
Also used : PathfinderMob(net.minecraft.world.entity.PathfinderMob) Mob(net.minecraft.world.entity.Mob) CraftEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity)

Example 40 with CraftEntity

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity in project MagicPlugin by elBukkit.

the class CompatibilityUtils method addToWorld.

@Override
public boolean addToWorld(World world, Entity entity, CreatureSpawnEvent.SpawnReason reason) {
    ServerLevel level = ((CraftWorld) world).getHandle();
    net.minecraft.world.entity.Entity entityHandle = ((CraftEntity) entity).getHandle();
    level.addFreshEntity(entityHandle, reason);
    return true;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) CraftEntity(org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Aggregations

Entity (org.bukkit.entity.Entity)29 Iterator (java.util.Iterator)21 List (java.util.List)21 LivingEntity (org.bukkit.entity.LivingEntity)21 CraftEntity (org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity)17 CraftEntity (org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity)16 UUID (java.util.UUID)12 Location (org.bukkit.Location)11 EnteredStateTracker (com.elmakers.mine.bukkit.utility.EnteredStateTracker)10 DamageSource (net.minecraft.world.damagesource.DamageSource)10 EntityDamageSource (net.minecraft.world.damagesource.EntityDamageSource)10 CraftEntity (org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity)10 HashSet (java.util.HashSet)8 Set (java.util.Set)8 CraftEntity (org.bukkit.craftbukkit.v1_11_R1.entity.CraftEntity)8 CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)8 CraftEntity (org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity)7 CraftEntity (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity)6 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)6 EntityAttachmentHelper (com.denizenscript.denizen.utilities.entity.EntityAttachmentHelper)5