use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.
the class WindowCitizen method getOpenRequestsOfCitizenFromBuilding.
@SuppressWarnings(RAWTYPES)
private ImmutableList<IRequest> getOpenRequestsOfCitizenFromBuilding(final BlockPos buildingPos) {
final ColonyView colonyView = ColonyManager.getClosestColonyView(FMLClientHandler.instance().getWorldClient(), buildingPos);
if (colonyView == null) {
return ImmutableList.of();
}
final AbstractBuildingView building = colonyView.getBuilding(buildingPos);
if (building == null) {
return ImmutableList.of();
}
return building.getOpenRequests(citizen);
}
use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.
the class WindowClipBoard method getOpenRequests.
private ImmutableList<IRequest> getOpenRequests() {
final ArrayList<IRequest> requests = Lists.newArrayList();
final ColonyView view = ColonyManager.getColonyView(colonyId);
if (view == null) {
return ImmutableList.of();
}
final IPlayerRequestResolver resolver = view.getRequestManager().getPlayerResolver();
final IRetryingRequestResolver retryingRequestResolver = view.getRequestManager().getRetryingRequestResolver();
final Set<IToken> requestTokens = new HashSet<>();
requestTokens.addAll(resolver.getAllAssignedRequests());
requestTokens.addAll(retryingRequestResolver.getAllAssignedRequests());
requests.addAll(requestTokens.stream().map(view.getRequestManager()::getRequestForToken).filter(Objects::nonNull).collect(Collectors.toSet()));
final BlockPos playerPos = Minecraft.getMinecraft().player.getPosition();
requests.sort(Comparator.comparing((IRequest request) -> request.getRequester().getDeliveryLocation().getInDimensionLocation().getDistance(playerPos.getX(), playerPos.getY(), playerPos.getZ())).thenComparingInt(request -> request.getToken().hashCode()));
return ImmutableList.copyOf(requests);
}
use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.
the class RenderUtils method calculateColonyBorder.
/**
* Calculate the colony border.
*
* @param theWorld in the world.
* @param thePlayer with the player.
* @param colonyBorder the border.
*/
private static void calculateColonyBorder(final WorldClient theWorld, final EntityPlayer thePlayer, final List<BlockPos> colonyBorder) {
final ColonyView colonyView = ColonyManager.getClosestColonyView(theWorld, thePlayer.getPosition());
if (colonyView == null) {
return;
}
final int distance = BLOCKS_PER_CHUNK * Configurations.gameplay.workingRangeTownHallChunks;
final BlockPos center = colonyView.getCenter();
final Chunk chunk = theWorld.getChunkFromBlockCoords(center);
int x = chunk.x;
int z = chunk.z;
int lowerEndX = x * BLOCKS_PER_CHUNK;
int lowerEndZ = z * BLOCKS_PER_CHUNK;
final int edgeX = lowerEndX - distance;
final int edgeZ = lowerEndZ - distance;
for (int i = 0; i <= distance * 2; i++) {
colonyBorder.add(BlockPosUtil.getFloor(new BlockPos(edgeX + i, center.getY(), lowerEndZ + BLOCKS_PER_CHUNK + distance), theWorld).up());
colonyBorder.add(BlockPosUtil.getFloor(new BlockPos(edgeX + i, center.getY(), lowerEndZ - distance), theWorld).up());
colonyBorder.add(BlockPosUtil.getFloor(new BlockPos(lowerEndX - distance, center.getY(), edgeZ + i), theWorld).up());
colonyBorder.add(BlockPosUtil.getFloor(new BlockPos(lowerEndX + BLOCKS_PER_CHUNK + distance, center.getY(), edgeZ + i), theWorld).up());
}
}
Aggregations