Search in sources :

Example 86 with CraftEntity

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

the class CompatibilityUtils method magicDamage.

@Override
public void magicDamage(Damageable target, double amount, Entity source) {
    try {
        if (target == null || target.isDead())
            return;
        // Might need to config-drive this, or just go back to defaulting to normal damage
        if (!USE_MAGIC_DAMAGE || target instanceof Witch || target instanceof Enderman || target instanceof ArmorStand || !(target instanceof LivingEntity)) {
            damage(target, amount, source);
            return;
        }
        net.minecraft.world.entity.Entity targetHandle = ((CraftEntity) target).getHandle();
        if (targetHandle == null)
            return;
        net.minecraft.world.entity.Entity sourceHandle = source == null ? null : ((CraftEntity) source).getHandle();
        // Bukkit won't allow magic damage from anything but a potion..
        if (sourceHandle != null && source instanceof LivingEntity) {
            Location location = target.getLocation();
            ThrownPotion potion = getOrCreatePotionEntity(location);
            net.minecraft.world.entity.Entity potionHandle = ((CraftEntity) potion).getHandle();
            potion.setShooter((LivingEntity) source);
            DamageSource magicSource = DamageSource.indirectMagic(potionHandle, sourceHandle);
            // This is a bit of hack that lets us damage the ender dragon, who is a weird and annoying collection
            // of various non-living entity pieces.
            ((EntityDamageSource) magicSource).setThorns();
            try (EnteredStateTracker.Touchable damaging = isDamaging.enter()) {
                damaging.touch();
                targetHandle.hurt(magicSource, (float) amount);
            }
        } else {
            try (EnteredStateTracker.Touchable damaging = isDamaging.enter()) {
                damaging.touch();
                targetHandle.hurt(DamageSource.MAGIC, (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) EntityDamageSource(net.minecraft.world.damagesource.EntityDamageSource) CraftLivingEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) ArmorStand(org.bukkit.entity.ArmorStand) CraftArmorStand(org.bukkit.craftbukkit.v1_17_R1.entity.CraftArmorStand) Enderman(org.bukkit.entity.Enderman) ThrownPotion(org.bukkit.entity.ThrownPotion) EnteredStateTracker(com.elmakers.mine.bukkit.utility.EnteredStateTracker) Witch(org.bukkit.entity.Witch) Location(org.bukkit.Location)

Example 87 with CraftEntity

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

the class CompatibilityUtils method magicDamage.

@Override
public void magicDamage(Damageable target, double amount, Entity source) {
    try {
        if (target == null || target.isDead())
            return;
        // Might need to config-drive this, or just go back to defaulting to normal damage
        if (!USE_MAGIC_DAMAGE || target instanceof Witch || target instanceof Enderman || target instanceof ArmorStand || !(target instanceof LivingEntity)) {
            damage(target, amount, source);
            return;
        }
        net.minecraft.world.entity.Entity targetHandle = ((CraftEntity) target).getHandle();
        if (targetHandle == null)
            return;
        net.minecraft.world.entity.Entity sourceHandle = source == null ? null : ((CraftEntity) source).getHandle();
        // Bukkit won't allow magic damage from anything but a potion..
        if (sourceHandle != null && source instanceof LivingEntity) {
            Location location = target.getLocation();
            ThrownPotion potion = getOrCreatePotionEntity(location);
            net.minecraft.world.entity.Entity potionHandle = ((CraftEntity) potion).getHandle();
            potion.setShooter((LivingEntity) source);
            DamageSource magicSource = DamageSource.indirectMagic(potionHandle, sourceHandle);
            // This is a bit of hack that lets us damage the ender dragon, who is a weird and annoying collection
            // of various non-living entity pieces.
            ((EntityDamageSource) magicSource).setThorns();
            try (EnteredStateTracker.Touchable damaging = isDamaging.enter()) {
                damaging.touch();
                targetHandle.hurt(magicSource, (float) amount);
            }
        } else {
            try (EnteredStateTracker.Touchable damaging = isDamaging.enter()) {
                damaging.touch();
                targetHandle.hurt(DamageSource.MAGIC, (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_18_R2.entity.CraftEntity) EntityDamageSource(net.minecraft.world.damagesource.EntityDamageSource) CraftLivingEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) ArmorStand(org.bukkit.entity.ArmorStand) CraftArmorStand(org.bukkit.craftbukkit.v1_18_R2.entity.CraftArmorStand) Enderman(org.bukkit.entity.Enderman) ThrownPotion(org.bukkit.entity.ThrownPotion) EnteredStateTracker(com.elmakers.mine.bukkit.utility.EnteredStateTracker) Witch(org.bukkit.entity.Witch) Location(org.bukkit.Location)

Example 88 with CraftEntity

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

the class CompatibilityUtils method getHitbox.

@Override
public BoundingBox getHitbox(Entity entity) {
    net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
    AABB aabb = nmsEntity.getBoundingBox();
    if (aabb == null) {
        return null;
    }
    return new BoundingBox(aabb.minX, aabb.maxX, aabb.minY, aabb.maxY, aabb.minZ, aabb.maxZ);
}
Also used : BoundingBox(com.elmakers.mine.bukkit.utility.BoundingBox) CraftEntity(org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity) AABB(net.minecraft.world.phys.AABB)

Example 89 with CraftEntity

use of org.bukkit.craftbukkit.v1_8_R1.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_R2.entity.CraftEntity) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Example 90 with CraftEntity

use of org.bukkit.craftbukkit.v1_8_R1.entity.CraftEntity in project ComplexMobs by AmirBohd.

the class Riposte method attackFrame.

protected void attackFrame() {
    LothricKnight mob = (LothricKnight) getMob();
    Player victim = mob.getVictim();
    if (victim == null && getTick() < 90) {
        mob.setAction("idle");
        return;
    } else if (victim.isDead() && getTick() < 90) {
        mob.setAction("idle");
        return;
    }
    Part part;
    Vector weaponMid = new Vector(0, 0, 0);
    if (getTick() < 64)
        part = mob.getParts().get("left_hand");
    else {
        part = mob.getParts().get("sword");
        weaponMid = new Vector(0, 0, .9);
    }
    EulerAngle weaponAngle = part.getHeadPose();
    weaponMid.rotateAroundX(weaponAngle.getX());
    weaponMid.rotateAroundY(-weaponAngle.getY());
    weaponMid.rotateAroundZ(-weaponAngle.getZ());
    weaponMid.rotateAroundAxis(new Vector(0, 1, 0), part.getArmorStand().getLocation().getYaw() / -57.29);
    Vector victimPosition = part.getArmorStand().getLocation().add(weaponMid).add(0, .4, 0).toVector();
    double x = victimPosition.getX();
    double y = victimPosition.getY();
    double z = victimPosition.getZ();
    victim.setFallDistance(0);
    if (getTick() < 90)
        ((CraftEntity) victim).getHandle().setPosition(x, y, z);
    if (getTick() < 90)
        victim.setVelocity(new Vector(.15 - Math.random() * .3, .15 - Math.random() * .3, .15 - Math.random() * .3));
    else if (getTick() == 90) {
        victim.setVelocity(mob.getMain().getLocation().getDirection().multiply(4).rotateAroundY(-80 / 57.29).setY(-1));
    } else if (getTick() < 110) {
        victim.getWorld().spawnParticle(Particle.BLOCK_CRACK, getMob().getVictim().getLocation().add(0, 1, 0), 4, 0, 0, 0, .5, Material.REDSTONE_WIRE.createBlockData(), true);
    }
    if (getTick() == 100) {
        victim.damage(20, getMob().getMain());
    }
    if (getTick() == 64) {
        victim.setHealth(victim.getHealth() * .25);
        victim.damage(1);
    }
}
Also used : Player(org.bukkit.entity.Player) Part(complexMobs.object.Part) CraftEntity(org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity) EulerAngle(org.bukkit.util.EulerAngle) Vector(org.bukkit.util.Vector) LothricKnight(complexMobs.mob.LothricKnight)

Aggregations

Location (org.bukkit.Location)48 Entity (org.bukkit.entity.Entity)39 LivingEntity (org.bukkit.entity.LivingEntity)37 Entity (net.minecraft.world.entity.Entity)32 CraftEntity (org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity)30 CraftEntity (org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity)28 CraftEntity (org.bukkit.craftbukkit.v1_16_R3.entity.CraftEntity)25 Iterator (java.util.Iterator)21 List (java.util.List)21 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)21 UUID (java.util.UUID)20 CraftEntity (org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity)19 Vector (org.bukkit.util.Vector)18 CraftEntity (org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity)17 Player (org.bukkit.entity.Player)17 EntityAttachmentHelper (com.denizenscript.denizen.utilities.entity.EntityAttachmentHelper)14 CraftEntity (org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity)13 CraftEntity (org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity)13 Vec3 (net.minecraft.world.phys.Vec3)12 CraftEntity (org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity)12