use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project Denizen-For-Bukkit by DenizenScript.
the class EntityHelper_v1_11_R1 method walkTo.
@Override
public void walkTo(final Entity entity, Location location, double speed, final Runnable callback) {
if (entity == null || location == null) {
return;
}
net.minecraft.server.v1_11_R1.Entity nmsEntityEntity = ((CraftEntity) entity).getHandle();
if (!(nmsEntityEntity instanceof EntityInsentient)) {
return;
}
final EntityInsentient nmsEntity = (EntityInsentient) nmsEntityEntity;
final NavigationAbstract entityNavigation = nmsEntity.getNavigation();
final PathEntity path;
final boolean aiDisabled = isAIDisabled(entity);
if (aiDisabled) {
toggleAI(entity, true);
nmsEntity.onGround = true;
}
path = entityNavigation.a(location.getX(), location.getY(), location.getZ());
if (path != null) {
entityNavigation.a(path, 1D);
entityNavigation.a(2D);
final double oldSpeed = nmsEntity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).b();
nmsEntity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(speed);
new BukkitRunnable() {
@Override
public void run() {
if (entityNavigation.n() || path.b()) {
if (callback != null) {
callback.run();
}
nmsEntity.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED).setValue(oldSpeed);
if (aiDisabled) {
toggleAI(entity, false);
}
cancel();
}
}
}.runTaskTimer(NMSHandler.getJavaPlugin(), 1, 1);
} else //if (!Utilities.checkLocation(location, entity.getLocation(), 20)) {
// TODO: generate waypoints to the target location?
{
entity.teleport(location);
}
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyBackstab.
private void applyBackstab(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
if (getLivingEntity().isDead())
return;
if (Bukkit.getEntity(getSourceUuid()) == null)
return;
Entity sourceEntity = Bukkit.getEntity(getSourceUuid());
if (sourceEntity == null)
return;
if (!(sourceEntity instanceof LivingEntity))
return;
LivingEntity sourceLivingEntity = (LivingEntity) sourceEntity;
try {
ISoliniaLivingEntity solSourceEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
if (solSourceEntity == null)
return;
int backstabSkill = solSourceEntity.getSkill("BACKSTAB");
if (backstabSkill < 1)
backstabSkill = 1;
EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) Bukkit.getEntity(getSourceUuid())).getHandle());
source.setMagic();
source.ignoresArmor();
int weaponDamage = 0;
// Offhand item only
ItemStack mainitem = sourceLivingEntity.getEquipment().getItemInOffHand();
if (mainitem != null) {
try {
ISoliniaItem item = SoliniaItemAdapter.Adapt(mainitem);
if (item != null)
if (item.getDamage() > 0) {
weaponDamage = item.getDamage();
}
} catch (SoliniaItemException e) {
}
}
if (weaponDamage < 1)
weaponDamage = 1;
int hpToRemove = weaponDamage;
// back stab formula
if (solSourceEntity.isBehindEntity(this.getLivingEntity()))
hpToRemove = (int) Math.floor((2 + backstabSkill / 50) * weaponDamage);
((CraftEntity) getLivingEntity()).getHandle().damageEntity(source, hpToRemove);
solSourceEntity.tryIncreaseSkill("BACKSTAB", 1);
} catch (CoreStateInitException e) {
}
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project Citizens2 by CitizensDev.
the class NMSImpl method removeFromWorld.
@Override
public void removeFromWorld(org.bukkit.entity.Entity entity) {
Preconditions.checkNotNull(entity);
Entity nmsEntity = ((CraftEntity) entity).getHandle();
nmsEntity.world.removeEntity(nmsEntity);
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project Citizens2 by CitizensDev.
the class ItemFrameController method createEntity.
@Override
protected Entity createEntity(Location at, NPC npc) {
Entity e = super.createEntity(at, npc);
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
item.setDirection(EnumDirection.EAST);
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
return e;
}
use of org.bukkit.craftbukkit.v1_4_5.entity.CraftEntity in project Citizens2 by CitizensDev.
the class ItemFrameController method createEntity.
@Override
protected Entity createEntity(Location at, NPC npc) {
Entity e = super.createEntity(at, npc);
EntityItemFrame item = (EntityItemFrame) ((CraftEntity) e).getHandle();
item.setDirection(EnumDirection.EAST);
item.blockPosition = new BlockPosition(at.getX(), at.getY(), at.getZ());
return e;
}
Aggregations