Search in sources :

Example 11 with ColonyView

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);
}
Also used : AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView) ColonyView(com.minecolonies.coremod.colony.ColonyView)

Example 12 with ColonyView

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);
}
Also used : IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) java.util(java.util) Button(com.minecolonies.blockout.controls.Button) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ItemIcon(com.minecolonies.blockout.controls.ItemIcon) ColonyView(com.minecolonies.coremod.colony.ColonyView) ItemStack(net.minecraft.item.ItemStack) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) ColonyManager(com.minecolonies.coremod.colony.ColonyManager) Minecraft(net.minecraft.client.Minecraft) IRetryingRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver) Constants(com.minecolonies.api.util.constant.Constants) RequestState(com.minecolonies.api.colony.requestsystem.request.RequestState) BlockPos(net.minecraft.util.math.BlockPos) ScrollingList(com.minecolonies.blockout.views.ScrollingList) Collectors(java.util.stream.Collectors) UpdateRequestStateMessage(com.minecolonies.coremod.network.messages.UpdateRequestStateMessage) IPlayerRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver) Nullable(org.jetbrains.annotations.Nullable) GuiScreen(net.minecraft.client.gui.GuiScreen) MineColonies(com.minecolonies.coremod.MineColonies) Image(com.minecolonies.blockout.controls.Image) Label(com.minecolonies.blockout.controls.Label) NotNull(org.jetbrains.annotations.NotNull) ColonyView(com.minecolonies.coremod.colony.ColonyView) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) IPlayerRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver) BlockPos(net.minecraft.util.math.BlockPos) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) IRetryingRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)

Example 13 with ColonyView

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());
    }
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) BlockPos(net.minecraft.util.math.BlockPos) Chunk(net.minecraft.world.chunk.Chunk)

Aggregations

ColonyView (com.minecolonies.coremod.colony.ColonyView)13 BlockPos (net.minecraft.util.math.BlockPos)5 ItemStack (net.minecraft.item.ItemStack)4 IColony (com.minecolonies.api.colony.IColony)2 Player (com.minecolonies.api.colony.permissions.Player)2 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)2 Image (com.minecolonies.blockout.controls.Image)2 ItemIcon (com.minecolonies.blockout.controls.ItemIcon)2 Label (com.minecolonies.blockout.controls.Label)2 ArrayList (java.util.ArrayList)2 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 RequestState (com.minecolonies.api.colony.requestsystem.request.RequestState)1 IRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver)1 IPlayerRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.player.IPlayerRequestResolver)1 IRetryingRequestResolver (com.minecolonies.api.colony.requestsystem.resolver.retrying.IRetryingRequestResolver)1 IToken (com.minecolonies.api.colony.requestsystem.token.IToken)1 Constants (com.minecolonies.api.util.constant.Constants)1 Button (com.minecolonies.blockout.controls.Button)1 Box (com.minecolonies.blockout.views.Box)1