use of thpmc.vanilla_source.api.world.cache.EngineWorld in project VanillaSource by TheHollowPlanetMC.
the class EntityFollowGoal method run.
@Override
public void run(GoalSelector goalSelector, Navigator navigator) {
tick++;
if (tick % TRACK_INTERVAL != 0) {
goalSelector.setFinished(true);
return;
}
INMSHandler nmsHandler = VanillaSourceAPI.getInstance().getNMSHandler();
EngineWorld world = navigator.getEntity().getWorld();
if (!world.getName().equals(target.getWorld().getName()))
return;
Location location = target.getLocation();
EngineChunk chunk = world.getChunkAt(location.getBlockX() >> 4, location.getBlockZ() >> 4);
if (chunk == null)
return;
for (int dy = 0; dy < 5; dy++) {
Location l = location.clone().add(new Vector(0, -dy, 0));
Object nmsBlockData = world.getNMSBlockData(l.getBlockX(), l.getBlockY(), l.getBlockZ());
if (nmsBlockData == null)
continue;
if (nmsHandler.hasCollision(new EngineBlock(world, chunk, l.getBlockX(), l.getBlockY(), l.getBlockZ(), nmsBlockData), navigator.getEntity().getMovementCollideOption())) {
// Goal set
navigator.setNavigationGoal(new BlockPosition(l.getBlockX(), l.getBlockY() + 1, l.getBlockZ()));
break;
}
}
goalSelector.setFinished(true);
}
use of thpmc.vanilla_source.api.world.cache.EngineWorld in project VanillaSource by TheHollowPlanetMC.
the class NMSHandler method checkUpperBlockHasFluid.
private boolean checkUpperBlockHasFluid(Fluid fluid, EngineBlock block) {
EngineWorld world = block.getWorld();
IBlockData upperBlockData = (IBlockData) world.getNMSBlockData(block.getX(), block.getY() + 1, block.getZ());
if (upperBlockData == null)
return false;
return fluid.getType().a(upperBlockData.getFluid().getType());
}
Aggregations