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