use of com.google.cloud.videointelligence.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method getTargetNavigator.
private MCNavigator getTargetNavigator(final org.bukkit.entity.Entity entity, final NavigatorParameters params, final Function<NavigationAbstract, Boolean> function) {
net.minecraft.server.v1_11_R1.Entity raw = getHandle(entity);
raw.onGround = true;
// not sure of a better way around this - if onGround is false, then
// navigation won't execute, and calling entity.move doesn't
// entirely fix the problem.
final NavigationAbstract navigation = NMSImpl.getNavigation(entity);
return new MCNavigator() {
float lastSpeed;
CancelReason reason;
@Override
public CancelReason getCancelReason() {
return reason;
}
@Override
public Iterable<Vector> getPath() {
return new NavigationIterable(navigation);
}
@Override
public void stop() {
if (navigation.k() != null) {
for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.k().d(); i++) {
PathPoint pp = navigation.k().a(i);
org.bukkit.block.Block block = new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()).getBlock();
player.sendBlockChange(block.getLocation(), block.getType(), block.getData());
}
}
}
stopNavigation(navigation);
}
@Override
public boolean update() {
if (params.speed() != lastSpeed) {
if (Messaging.isDebugging()) {
Messaging.debug("Repathfinding " + ((NPCHolder) entity).getNPC().getId() + " due to speed change");
}
Entity handle = getHandle(entity);
float oldWidth = handle.width;
if (handle instanceof EntityHorse) {
handle.width = Math.min(0.99f, oldWidth);
}
if (!function.apply(navigation)) {
reason = CancelReason.STUCK;
}
// minecraft requires that an entity fit onto both blocks if width >= 1f,
handle.width = oldWidth;
// but we'd prefer to make it just fit on 1 so hack around it a bit.
lastSpeed = params.speed();
}
if (params.debug() && !NMSImpl.isNavigationFinished(navigation)) {
for (Player player : Bukkit.getOnlinePlayers()) {
for (int i = 0; i < navigation.k().d(); i++) {
PathPoint pp = navigation.k().a(i);
player.sendBlockChange(new Vector(pp.a, pp.b, pp.c).toLocation(player.getWorld()), Material.YELLOW_FLOWER, (byte) 0);
}
}
}
navigation.a(params.speed());
return NMSImpl.isNavigationFinished(navigation);
}
};
}
use of com.google.cloud.videointelligence.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method registerEntityClass.
@Override
public void registerEntityClass(Class<?> clazz) {
if (ENTITY_REGISTRY == null)
return;
Class<?> search = clazz;
while ((search = search.getSuperclass()) != null && Entity.class.isAssignableFrom(search)) {
MinecraftKey key = ENTITY_REGISTRY.b(search);
if (key == null)
continue;
int code = ENTITY_REGISTRY.a(search);
ENTITY_REGISTRY.put(code, key, (Class<? extends Entity>) clazz);
return;
}
throw new IllegalArgumentException("unable to find valid entity superclass for class " + clazz.toString());
}
use of com.google.cloud.videointelligence.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method getVehicle.
@Override
public org.bukkit.entity.Entity getVehicle(org.bukkit.entity.Entity entity) {
Entity handle = NMSImpl.getHandle(entity);
if (handle == null) {
return null;
}
Entity e = handle.getVehicle();
return (e == handle || e == null) ? null : e.getBukkitEntity();
}
use of com.google.cloud.videointelligence.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method tick.
@Override
public boolean tick(org.bukkit.entity.Entity next) {
Entity entity = NMSImpl.getHandle(next);
Entity entity1 = entity.bJ();
if (entity1 != null) {
if ((entity1.dead) || (!entity1.w(entity))) {
entity.stopRiding();
}
} else {
if (!entity.dead) {
try {
entity.world.entityJoinedWorld(entity, true);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Ticking player");
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Player being ticked");
entity.appendEntityCrashDetails(crashreportsystemdetails);
throw new ReportedException(crashreport);
}
}
boolean removeFromPlayerList = ((NPCHolder) entity).getNPC().data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
if (entity.dead) {
entity.world.removeEntity(entity);
return true;
} else if (!removeFromPlayerList) {
if (!entity.world.players.contains(entity)) {
entity.world.players.add((EntityHuman) entity);
}
return true;
} else {
entity.world.players.remove(entity);
}
}
return false;
}
use of com.google.cloud.videointelligence.v1.Entity in project Citizens2 by CitizensDev.
the class NMSImpl method look.
@Override
public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) {
Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to);
BAD_CONTROLLER_LOOK.add(EntityType.SHULKER);
if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) {
if (to instanceof LivingEntity) {
look(from, ((LivingEntity) to).getEyeLocation(), false, true);
} else {
look(from, to.getLocation(), false, true);
}
} else if (handle instanceof EntityInsentient) {
((EntityInsentient) handle).getControllerLook().a(target, ((EntityInsentient) handle).O(), ((EntityInsentient) handle).N());
while (((EntityLiving) handle).aP >= 180F) {
((EntityLiving) handle).aP -= 360F;
}
while (((EntityLiving) handle).aP < -180F) {
((EntityLiving) handle).aP += 360F;
}
} else if (handle instanceof EntityHumanNPC) {
((EntityHumanNPC) handle).setTargetLook(target, 10F, 40F);
}
}
Aggregations