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