Search in sources :

Example 1 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class RenderUtils method renderWayPoints.

/**
 * Render all waypoints.
 *
 * @param position     the position of the build tool click.
 * @param clientWorld  the world.
 * @param partialTicks the partial ticks
 */
public static void renderWayPoints(final BlockPos position, final WorldClient clientWorld, final float partialTicks) {
    final ColonyView colonyView = ColonyManager.getClosestColonyView(clientWorld, position);
    if (colonyView == null) {
        return;
    }
    final Set<BlockPos> waypoints = colonyView.getWayPoints();
    for (final BlockPos pos : waypoints) {
        final EntityEnderCrystal crystal = new EntityEnderCrystal(clientWorld);
        crystal.setPosition(pos.getX() + HALF_BLOCK_OFFSET, pos.getY(), pos.getZ() + HALF_BLOCK_OFFSET);
        crystal.setBeamTarget(pos.up(FIX_POINT_OFFSET));
        crystal.setShowBottom(false);
        crystal.innerRotation = 0;
        Minecraft.getMinecraft().getRenderManager().renderEntityStatic(crystal, 0.0F, true);
    }
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class WindowCitizen method getOpenRequestTreeOfCitizen.

private ImmutableList<RequestWrapper> getOpenRequestTreeOfCitizen() {
    final ColonyView colonyView = ColonyManager.getClosestColonyView(FMLClientHandler.instance().getWorldClient(), (citizen.getWorkBuilding() != null) ? citizen.getWorkBuilding() : citizen.getHomeBuilding());
    if (colonyView == null) {
        return ImmutableList.of();
    }
    final List<RequestWrapper> treeElements = new ArrayList<>();
    getOpenRequestsOfCitizen().stream().forEach(r -> {
        constructTreeFromRequest(colonyView.getRequestManager(), r, treeElements, 0);
    });
    return ImmutableList.copyOf(treeElements);
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) ArrayList(java.util.ArrayList)

Example 3 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class WindowRequestDetail method onOpened.

/**
 * Called when the GUI has been opened.
 * Will fill the fields and lists.
 */
@Override
public void onOpened() {
    final String[] labels = new String[] { request.getLongDisplayString().getFormattedText() };
    final Box box = findPaneOfTypeByID(BOX_ID_REQUEST, Box.class);
    int y = Y_OFFSET_EACH_TEXTFIELD;
    final int availableLabelWidth = box.getInteriorWidth() - 1 - box.getX();
    for (final String s : labels) {
        final String labelText = "§r§0" + s;
        // Temporary workaround until Labels support multi-line rendering
        final List<String> multilineLabelStrings = mc.fontRenderer.listFormattedStringToWidth(labelText, availableLabelWidth);
        for (final String splitLabelText : multilineLabelStrings) {
            final Label descriptionLabel = new Label();
            descriptionLabel.setColor(BLACK, BLACK);
            descriptionLabel.setLabelText(splitLabelText);
            box.addChild(descriptionLabel);
            descriptionLabel.setPosition(1, y);
            y += Y_OFFSET_EACH_TEXTFIELD;
        }
    }
    final ItemIcon exampleStackDisplay = findPaneOfTypeByID(LIST_ELEMENT_ID_REQUEST_STACK, ItemIcon.class);
    final List<ItemStack> displayStacks = request.getDisplayStacks();
    if (!displayStacks.isEmpty()) {
        exampleStackDisplay.setItem(displayStacks.get((lifeCount / LIFE_COUNT_DIVIDER) % displayStacks.size()));
    } else {
        final Image logo = findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
        logo.setVisible(true);
        logo.setImage(request.getDisplayIcon());
    }
    final ColonyView view = ColonyManager.getColonyView(colonyId);
    findPaneOfTypeByID(REQUESTER, Label.class).setLabelText(request.getRequester().getDisplayName(view.getRequestManager(), request.getToken()).getFormattedText());
    final Label targetLabel = findPaneOfTypeByID(LIST_ELEMENT_ID_REQUEST_LOCATION, Label.class);
    targetLabel.setLabelText(request.getRequester().getDeliveryLocation().toString());
    final ColonyView colony = ColonyManager.getColonyView(colonyId);
    if (colony == null) {
        Log.getLogger().warn("---Colony Null in WindowRequestDetail---");
        return;
    }
    try {
        final IRequestResolver resolver = colony.getRequestManager().getResolverForRequest(request.getToken());
        if (resolver == null) {
            Log.getLogger().warn("---IRequestResolver Null in WindowRequestDetail---");
            return;
        }
        findPaneOfTypeByID(RESOLVER, Label.class).setLabelText("Resolver: " + resolver.getDisplayName(view.getRequestManager(), request.getToken()).getFormattedText());
    } catch (@SuppressWarnings(EXCEPTION_HANDLERS_SHOULD_PRESERVE_THE_ORIGINAL_EXCEPTIONS) final IllegalArgumentException e) {
        /**
         * Do nothing we just need to know if it has a resolver or not.
         */
        Log.getLogger().warn("---IRequestResolver Null in WindowRequestDetail---", e);
    }
    box.setSize(box.getWidth(), y);
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) IRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver) Box(com.minecolonies.blockout.views.Box) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class WindowTownHall method updateAllies.

/**
 * Clears and resets all allies.
 */
private void updateAllies() {
    allies.clear();
    final ColonyView colony = building.getColony();
    for (final Player player : colony.getPermissions().getPlayersByRank(Rank.OFFICER)) {
        final IColony col = ColonyManager.getIColonyByOwner(Minecraft.getMinecraft().world, player.getID());
        if (col instanceof ColonyView) {
            for (final Player owner : colony.getPermissions().getPlayersByRank(Rank.OWNER)) {
                if (col.getPermissions().getRank(owner.getID()) == Rank.OFFICER) {
                    allies.add((ColonyView) col);
                }
            }
        }
    }
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) Player(com.minecolonies.api.colony.permissions.Player) IColony(com.minecolonies.api.colony.IColony)

Example 5 with ColonyView

use of com.minecolonies.coremod.colony.ColonyView in project minecolonies by Minecolonies.

the class WindowClipBoard method onOpened.

/**
 * Called when the window is opened.
 * Sets up the buttons for either hut mode or decoration mode.
 */
@Override
public void onOpened() {
    resourceList.setDataProvider(() -> getOpenRequests().size(), (index, rowPane) -> {
        final ImmutableList<IRequest> openRequests = getOpenRequests();
        if (index < 0 || index >= openRequests.size()) {
            return;
        }
        final IRequest request = openRequests.get(index);
        final ItemIcon exampleStackDisplay = rowPane.findPaneOfTypeByID(LIST_ELEMENT_ID_REQUEST_STACK, ItemIcon.class);
        final List<ItemStack> displayStacks = request.getDisplayStacks();
        if (!displayStacks.isEmpty()) {
            if (exampleStackDisplay != null) {
                exampleStackDisplay.setItem(displayStacks.get((lifeCount / LIFE_COUNT_DIVIDER) % displayStacks.size()));
            }
        } else {
            final Image logo = findPaneOfTypeByID(DELIVERY_IMAGE, Image.class);
            logo.setVisible(true);
            logo.setImage(request.getDisplayIcon());
        }
        final ColonyView view = ColonyManager.getColonyView(colonyId);
        rowPane.findPaneOfTypeByID(REQUESTER, Label.class).setLabelText(request.getRequester().getDisplayName(view.getRequestManager(), request.getToken()).getFormattedText());
        rowPane.findPaneOfTypeByID(REQUEST_SHORT_DETAIL, Label.class).setLabelText(request.getShortDisplayString().getFormattedText().replace("§f", ""));
    });
}
Also used : ColonyView(com.minecolonies.coremod.colony.ColonyView) ItemIcon(com.minecolonies.blockout.controls.ItemIcon) Label(com.minecolonies.blockout.controls.Label) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) ItemStack(net.minecraft.item.ItemStack) Image(com.minecolonies.blockout.controls.Image)

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