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