Search in sources :

Example 6 with CitizenDataView

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

the class ClientEventHandler method renderWorldLastEvent.

/**
 * Used to catch the renderWorldLastEvent in order to draw the debug nodes for pathfinding.
 *
 * @param event the catched event.
 */
@SubscribeEvent
public void renderWorldLastEvent(@NotNull final RenderWorldLastEvent event) {
    Pathfinding.debugDraw(event.getPartialTicks());
    final Structure structure = Settings.instance.getActiveStructure();
    final WorldClient world = Minecraft.getMinecraft().world;
    final EntityPlayer player = Minecraft.getMinecraft().player;
    if (structure != null) {
        final BlockPos position = Settings.instance.getPosition();
        if (Settings.instance.getStructureName().contains(AbstractEntityAIStructure.WAYPOINT_STRING)) {
            RenderUtils.renderWayPoints(position, world, event.getPartialTicks());
        } else {
            RenderUtils.renderColonyBorder(position, world, event.getPartialTicks(), player, colonyBorder);
        }
        return;
    } else {
        if (citizen != null) {
            final Entity entityCitizen = world.getEntityByID(citizen.getEntityId());
            if (entityCitizen instanceof EntityCitizen) {
                RenderUtils.renderSigns(world, event.getPartialTicks(), citizen, player, entityCitizen.getPosition());
                ticksPassed += event.getPartialTicks();
                if (ticksPassed > Constants.TICKS_SECOND * SECONDS_TO_SHOW) {
                    ticksPassed = 0;
                    citizen = null;
                }
            } else {
                citizen = null;
                ticksPassed = 0;
            }
            return;
        }
        final ColonyView colony = ColonyManager.getClosestColonyView(world, player.getPosition());
        if (colony != null && player != null && colony.getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
            for (final CitizenDataView citizenDataView : new ArrayList<CitizenDataView>(colony.getCitizens().values())) {
                final Entity entityCitizen = world.getEntityByID(citizenDataView.getEntityId());
                if (entityCitizen instanceof EntityCitizen && entityCitizen.getPosition().distanceSq(player.getPosition()) <= 2) {
                    RenderUtils.renderSigns(world, event.getPartialTicks(), citizenDataView, player, entityCitizen.getPosition());
                    citizen = citizenDataView;
                    return;
                }
            }
        }
    }
    colonyBorder.clear();
}
Also used : Entity(net.minecraft.entity.Entity) ColonyView(com.minecolonies.coremod.colony.ColonyView) ArrayList(java.util.ArrayList) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) Structure(com.minecolonies.structures.helpers.Structure) AbstractEntityAIStructure(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructure) EntityCitizen(com.minecolonies.coremod.entity.EntityCitizen) WorldClient(net.minecraft.client.multiplayer.WorldClient) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with CitizenDataView

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

the class WindowAssignCitizen method onButtonClicked.

/**
 * Called when any button has been clicked.
 *
 * @param button the clicked button.
 */
@Override
public void onButtonClicked(@NotNull final Button button) {
    if (button.getID().equals(BUTTON_DONE)) {
        final int row = citizenList.getListElementIndexByPane(button);
        final CitizenDataView data = citizens.get(row);
        if (building instanceof BuildingHome.View) {
            ((BuildingHome.View) building).addResident(data.getId());
        }
        MineColonies.getNetwork().sendToServer(new AssignUnassignMessage(this.building, true, data.getId()));
    } else if (!button.getID().equals(BUTTON_CANCEL)) {
        return;
    }
    if (colony.getTownHall() != null) {
        building.openGui(false);
    }
}
Also used : AssignUnassignMessage(com.minecolonies.coremod.network.messages.AssignUnassignMessage) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) ColonyView(com.minecolonies.coremod.colony.ColonyView) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)

Example 8 with CitizenDataView

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

the class WindowHireWorker method onOpened.

/**
 * Called when the GUI has been opened.
 * Will fill the fields and lists.
 */
@Override
public void onOpened() {
    updateCitizens();
    final ScrollingList citizenList = findPaneOfTypeByID(CITIZEN_LIST, ScrollingList.class);
    citizenList.enable();
    citizenList.show();
    // Creates a dataProvider for the unemployed citizenList.
    citizenList.setDataProvider(new ScrollingList.DataProvider() {

        /**
         * The number of rows of the list.
         * @return the number.
         */
        @Override
        public int getElementCount() {
            return citizens.size();
        }

        /**
         * Inserts the elements into each row.
         * @param index the index of the row/list element.
         * @param rowPane the parent Pane for the row, containing the elements to update.
         */
        @Override
        public void updateElement(final int index, @NotNull final Pane rowPane) {
            @NotNull final CitizenDataView citizen = citizens.get(index);
            final AbstractBuildingWorker.Skill primary = building.getPrimarySkill();
            final AbstractBuildingWorker.Skill secondary = building.getSecondarySkill();
            if (citizen.getWorkBuilding() == null) {
                rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).show();
                rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).hide();
            } else {
                rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).hide();
                rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).show();
            }
            @NotNull final String strength = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.STRENGTH), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_STRENGTH, citizen.getStrength()));
            @NotNull final String charisma = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.CHARISMA), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_CHARISMA, citizen.getCharisma()));
            @NotNull final String dexterity = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.DEXTERITY), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_DEXTERITY, citizen.getDexterity()));
            @NotNull final String endurance = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.ENDURANCE), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_ENDURANCE, citizen.getEndurance()));
            @NotNull final String intelligence = createAttributeText(createColor(primary, secondary, AbstractBuildingWorker.Skill.INTELLIGENCE), LanguageHandler.format(COM_MINECOLONIES_COREMOD_GUI_CITIZEN_SKILLS_INTELLIGENCE, citizen.getIntelligence()));
            // Creates the list of attributes for each citizen
            @NotNull final String attributes = strength + charisma + dexterity + endurance + intelligence;
            rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Label.class).setLabelText(citizen.getName());
            rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Label.class).setLabelText(attributes);
            // Invisible id textContent.
            rowPane.findPaneOfTypeByID(ID_LABEL, Label.class).setLabelText(Integer.toString(citizen.getId()));
        }
    });
}
Also used : CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) ScrollingList(com.minecolonies.blockout.views.ScrollingList) Pane(com.minecolonies.blockout.Pane)

Aggregations

CitizenDataView (com.minecolonies.coremod.colony.CitizenDataView)8 Pane (com.minecolonies.blockout.Pane)3 ScrollingList (com.minecolonies.blockout.views.ScrollingList)3 ColonyView (com.minecolonies.coremod.colony.ColonyView)2 TextComponentString (net.minecraft.util.text.TextComponentString)2 Button (com.minecolonies.blockout.controls.Button)1 Label (com.minecolonies.blockout.controls.Label)1 Group (com.minecolonies.blockout.views.Group)1 WorkOrderView (com.minecolonies.coremod.colony.WorkOrderView)1 AbstractBuildingView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)1 EntityCitizen (com.minecolonies.coremod.entity.EntityCitizen)1 AbstractEntityAIStructure (com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructure)1 AssignUnassignMessage (com.minecolonies.coremod.network.messages.AssignUnassignMessage)1 Structure (com.minecolonies.structures.helpers.Structure)1 DecimalFormat (java.text.DecimalFormat)1 ArrayList (java.util.ArrayList)1 WorldClient (net.minecraft.client.multiplayer.WorldClient)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1