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);
}
}
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);
}
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);
}
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);
}
}
}
}
}
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", ""));
});
}
Aggregations