use of org.bukkit.craftbukkit.v1_8_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;
}
use of org.bukkit.craftbukkit.v1_8_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();
}
}
use of org.bukkit.craftbukkit.v1_8_R2.entity.CraftEntity in project MagicPlugin by elBukkit.
the class CompatibilityUtils method setEntityMotion.
@Override
public void setEntityMotion(Entity entity, Vector motion) {
net.minecraft.world.entity.Entity nms = ((CraftEntity) entity).getHandle();
nms.setDeltaMovement(new Vec3(motion.getX(), motion.getY(), motion.getZ()));
}
use of org.bukkit.craftbukkit.v1_8_R2.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_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;
}
Aggregations