use of net.minecraft.server.v1_14_R1.EntityFishingHook in project Citizens2 by CitizensDev.
the class NMSImpl method removeHookIfNecessary.
@Override
public void removeHookIfNecessary(NPCRegistry npcRegistry, FishHook entity) {
EntityFishingHook hook = (EntityFishingHook) NMSImpl.getHandle(entity);
if (hook.hooked == null)
return;
NPC npc = npcRegistry.getNPC(hook.hooked.getBukkitEntity());
if (npc == null)
return;
if (npc.isProtected()) {
hook.hooked = null;
hook.die();
}
}
use of net.minecraft.server.v1_14_R1.EntityFishingHook in project Citizens2 by CitizensDev.
the class NMSImpl method removeHookIfNecessary.
@Override
public void removeHookIfNecessary(NPCRegistry npcRegistry, FishHook entity) {
EntityFishingHook hook = (EntityFishingHook) NMSImpl.getHandle(entity);
if (hook.hooked == null)
return;
NPC npc = npcRegistry.getNPC(hook.hooked.getBukkitEntity());
if (npc == null)
return;
if (npc.isProtected()) {
hook.hooked = null;
hook.die();
}
}
use of net.minecraft.server.v1_14_R1.EntityFishingHook in project Citizens2 by CitizensDev.
the class NMSImpl method removeHookIfNecessary.
@Override
public void removeHookIfNecessary(NPCRegistry npcRegistry, FishHook entity) {
EntityFishingHook hook = (EntityFishingHook) NMSImpl.getHandle(entity);
if (hook.hooked == null)
return;
NPC npc = npcRegistry.getNPC(hook.hooked.getBukkitEntity());
if (npc == null)
return;
if (npc.isProtected()) {
hook.hooked = null;
hook.die();
}
}
use of net.minecraft.server.v1_14_R1.EntityFishingHook in project PaperDev by Kamillaova.
the class CraftLivingEntity method launchProjectile.
@SuppressWarnings("unchecked")
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
net.minecraft.server.v1_12_R1.World world = ((CraftWorld) getWorld()).getHandle();
net.minecraft.server.v1_12_R1.Entity launch = null;
if (Snowball.class.isAssignableFrom(projectile)) {
launch = new EntitySnowball(world, getHandle());
// ItemSnowball
((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F);
} else if (Egg.class.isAssignableFrom(projectile)) {
launch = new EntityEgg(world, getHandle());
// ItemEgg
((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F);
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
launch = new EntityEnderPearl(world, getHandle());
// ItemEnderPearl
((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 1.5F, 1.0F);
} else if (Arrow.class.isAssignableFrom(projectile)) {
if (TippedArrow.class.isAssignableFrom(projectile)) {
launch = new EntityTippedArrow(world, getHandle());
((EntityTippedArrow) launch).setType(CraftPotionUtil.fromBukkit(new PotionData(PotionType.WATER, false, false)));
} else if (SpectralArrow.class.isAssignableFrom(projectile)) {
launch = new EntitySpectralArrow(world, getHandle());
} else {
launch = new EntityTippedArrow(world, getHandle());
}
// ItemBow
((EntityArrow) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, 0.0F, 3.0F, 1.0F);
} else if (ThrownPotion.class.isAssignableFrom(projectile)) {
if (LingeringPotion.class.isAssignableFrom(projectile)) {
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.LINGERING_POTION, 1)));
} else {
launch = new EntityPotion(world, getHandle(), CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.SPLASH_POTION, 1)));
}
// ItemSplashPotion
((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.5F, 1.0F);
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
launch = new EntityThrownExpBottle(world, getHandle());
// ItemExpBottle
((EntityProjectile) launch).a(getHandle(), getHandle().pitch, getHandle().yaw, -20.0F, 0.7F, 1.0F);
} else if (Fish.class.isAssignableFrom(projectile) && getHandle() instanceof EntityHuman) {
launch = new EntityFishingHook(world, (EntityHuman) getHandle());
} else if (Fireball.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
Vector direction = location.getDirection().multiply(10);
if (SmallFireball.class.isAssignableFrom(projectile)) {
launch = new EntitySmallFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else if (WitherSkull.class.isAssignableFrom(projectile)) {
launch = new EntityWitherSkull(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else if (DragonFireball.class.isAssignableFrom(projectile)) {
launch = new EntityDragonFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
} else {
launch = new EntityLargeFireball(world, getHandle(), direction.getX(), direction.getY(), direction.getZ());
}
((EntityFireball) launch).projectileSource = this;
launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
} else if (LlamaSpit.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
Vector direction = location.getDirection();
launch = new EntityLlamaSpit(world);
((EntityLlamaSpit) launch).shooter = getHandle();
// EntityLlama
((EntityLlamaSpit) launch).shoot(direction.getX(), direction.getY(), direction.getZ(), 1.5F, 10.0F);
launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
} else if (ShulkerBullet.class.isAssignableFrom(projectile)) {
Location location = getEyeLocation();
launch = new EntityShulkerBullet(world, getHandle(), null, null);
launch.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
}
Validate.notNull(launch, "Projectile not supported");
if (velocity != null) {
((T) launch.getBukkitEntity()).setVelocity(velocity);
}
world.addEntity(launch);
return (T) launch.getBukkitEntity();
}
Aggregations