use of com.minecolonies.api.colony.buildings.views.IBuildingView in project minecolonies by Minecolonies.
the class GuardTaskSetting method render.
@Override
public void render(final ISettingKey<?> key, final Pane pane, final ISettingsModuleView settingsModuleView, final IBuildingView building, final Window window) {
final String setting = getSettings().get(getCurrentIndex());
final ButtonImage targetButton = pane.findPaneOfTypeByID("setTarget", ButtonImage.class);
final Text mineLabel = pane.findPaneOfTypeByID("minePos", Text.class);
if (setting.equals(PATROL_MINE) && building instanceof AbstractBuildingGuards.View) {
mineLabel.setVisible(true);
if (((AbstractBuildingGuards.View) building).getMinePos() != null) {
mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.worherhuts.patrollingmine", ((AbstractBuildingGuards.View) building).getMinePos().toShortString()));
} else {
mineLabel.setText(new TranslationTextComponent("com.minecolonies.coremod.job.guard.assignmine"));
}
targetButton.setVisible(false);
} else if (!setting.equals(FOLLOW)) {
mineLabel.setVisible(false);
targetButton.setVisible(true);
if (setting.equals(PATROL)) {
if (!settingsModuleView.getSetting(AbstractBuildingGuards.PATROL_MODE).getValue().equals(PatrolModeSetting.MANUAL)) {
targetButton.setVisible(false);
} else {
targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetpatrol"));
}
} else {
targetButton.setText(new TranslationTextComponent("com.minecolonies.coremod.gui.workerhuts.targetguard"));
}
targetButton.setHandler(button -> building.getModuleView(ToolModuleView.class).getWindow().open());
} else {
mineLabel.setVisible(false);
targetButton.setVisible(false);
}
pane.findPaneOfTypeByID("trigger", ButtonImage.class).setText(new TranslationTextComponent(setting));
}
use of com.minecolonies.api.colony.buildings.views.IBuildingView in project minecolonies by Minecolonies.
the class BuildingDataManager method createViewFrom.
@Override
public IBuildingView createViewFrom(final IColonyView colony, final BlockPos position, final PacketBuffer networkBuffer) {
final ResourceLocation buildingName = new ResourceLocation(networkBuffer.readUtf(32767));
final BuildingEntry entry = IBuildingRegistry.getInstance().getValue(buildingName);
if (entry == null) {
Log.getLogger().error(String.format("Unknown building type '%s'.", buildingName), new Exception());
return null;
}
final IBuildingView view = entry.produceBuildingView(position, colony);
if (view != null) {
view.deserialize(networkBuffer);
}
return view;
}
use of com.minecolonies.api.colony.buildings.views.IBuildingView in project minecolonies by ldtteam.
the class AbstractBlockHut method use.
@NotNull
@Override
public ActionResultType use(final BlockState state, final World worldIn, final BlockPos pos, final PlayerEntity player, final Hand hand, final BlockRayTraceResult ray) {
/*
If the world is client, open the gui of the building
*/
if (worldIn.isClientSide) {
@Nullable final IBuildingView building = IColonyManager.getInstance().getBuildingView(worldIn.dimension(), pos);
if (building == null) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.gui.nobuilding");
return ActionResultType.FAIL;
}
if (building.getColony() == null) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.gui.nocolony");
return ActionResultType.FAIL;
}
if (!building.getColony().getPermissions().hasPermission(player, Action.ACCESS_HUTS)) {
LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.permission.no");
return ActionResultType.FAIL;
}
building.openGui(player.isShiftKeyDown());
}
return ActionResultType.SUCCESS;
}
use of com.minecolonies.api.colony.buildings.views.IBuildingView in project minecolonies by ldtteam.
the class CitizenWindowUtils method updateJobPage.
/**
* Update the job page of the citizen.
*
* @param citizen the citizen.
* @param windowCitizen the window.
* @param colony the colony.
*/
public static void updateJobPage(final ICitizenDataView citizen, final JobWindowCitizen windowCitizen, final IColonyView colony) {
final IBuildingView building = colony.getBuilding(citizen.getWorkBuilding());
if (building instanceof AbstractBuildingView && building.getBuildingType() != ModBuildings.library && citizen.getJobView() != null) {
final WorkerBuildingModuleView moduleView = building.getModuleViewMatching(WorkerBuildingModuleView.class, m -> m.getJobEntry() == citizen.getJobView().getEntry());
if (moduleView == null) {
return;
}
windowCitizen.findPaneOfTypeByID(JOB_TITLE_LABEL, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.label", LanguageHandler.format(citizen.getJob())));
windowCitizen.findPaneOfTypeByID(JOB_DESC_LABEL, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.desc"));
final Skill primary = moduleView.getPrimarySkill();
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_LABEL, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.skills." + primary.name().toLowerCase(Locale.US)) + " (100% XP)");
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_LABEL + IMAGE_APPENDIX, Image.class).setImage(BASE_IMG_SRC + primary.name().toLowerCase(Locale.US) + ".png");
if (primary.getComplimentary() != null && primary.getAdverse() != null) {
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_COM, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.skills." + primary.getComplimentary().name().toLowerCase(Locale.US)) + " (" + PRIMARY_DEPENDENCY_SHARE + "% XP)");
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_COM + IMAGE_APPENDIX, Image.class).setImage(BASE_IMG_SRC + primary.getComplimentary().name().toLowerCase(Locale.US) + ".png");
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_ADV, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.skills." + primary.getAdverse().name().toLowerCase(Locale.US)) + " (-" + PRIMARY_DEPENDENCY_SHARE + "% XP)");
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_ADV + IMAGE_APPENDIX, Image.class).setImage(BASE_IMG_SRC + primary.getAdverse().name().toLowerCase(Locale.US) + ".png");
}
final Skill secondary = moduleView.getSecondarySkill();
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_LABEL, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.skills." + secondary.name().toLowerCase(Locale.US)) + " (50% XP)");
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_LABEL + IMAGE_APPENDIX, Image.class).setImage(BASE_IMG_SRC + secondary.name().toLowerCase(Locale.US) + ".png");
if (secondary.getComplimentary() != null && secondary.getAdverse() != null) {
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_COM, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.skills." + secondary.getComplimentary().name().toLowerCase(Locale.US)) + " (" + SECONDARY_DEPENDENCY_SHARE + "% XP)");
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_COM + IMAGE_APPENDIX, Image.class).setImage(BASE_IMG_SRC + secondary.getComplimentary().name().toLowerCase(Locale.US) + ".png");
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_ADV, Text.class).setText(LanguageHandler.format("com.minecolonies.coremod.gui.citizen.job.skills." + secondary.getAdverse().name().toLowerCase(Locale.US)) + " (-" + SECONDARY_DEPENDENCY_SHARE + "% XP)");
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_ADV + IMAGE_APPENDIX, Image.class).setImage(BASE_IMG_SRC + secondary.getAdverse().name().toLowerCase(Locale.US) + ".png");
}
} else {
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_LABEL + IMAGE_APPENDIX, Image.class).hide();
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_COM + IMAGE_APPENDIX, Image.class).hide();
windowCitizen.findPaneOfTypeByID(PRIMARY_SKILL_ADV + IMAGE_APPENDIX, Image.class).hide();
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_LABEL + IMAGE_APPENDIX, Image.class).hide();
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_COM + IMAGE_APPENDIX, Image.class).hide();
windowCitizen.findPaneOfTypeByID(SECONDARY_SKILL_ADV + IMAGE_APPENDIX, Image.class).hide();
}
}
use of com.minecolonies.api.colony.buildings.views.IBuildingView in project minecolonies by ldtteam.
the class ClientEventHandler method handleRenderScepterGuard.
/**
* Renders the guard scepter objects into the world.
*
* @param event The caught event
* @param world The world in which to render
* @param player The player for which to render
*/
private static void handleRenderScepterGuard(@NotNull final RenderWorldLastEvent event, final ClientWorld world, final PlayerEntity player) {
final PlacementSettings settings = new PlacementSettings(Settings.instance.getMirror(), BlockPosUtil.getRotationFromRotations(Settings.instance.getRotation()));
final ItemStack stack = player.getMainHandItem();
if (!stack.hasTag()) {
return;
}
final CompoundNBT compound = stack.getTag();
final IColonyView colony = IColonyManager.getInstance().getColonyView(compound.getInt(TAG_ID), player.level.dimension());
if (colony == null) {
return;
}
final BlockPos guardTower = BlockPosUtil.read(compound, TAG_POS);
final IBuildingView hut = colony.getBuilding(guardTower);
if (hut == null) {
return;
}
if (partolPointTemplate == null) {
partolPointTemplate = new LoadOnlyStructureHandler(world, hut.getPosition(), "schematics/infrastructure/patrolpoint", settings, true).getBluePrint();
}
if (hut instanceof AbstractBuildingGuards.View) {
StructureClientHandler.renderStructureAtPosList(partolPointTemplate, event.getPartialTicks(), ((AbstractBuildingGuards.View) hut).getPatrolTargets().stream().map(BlockPos::above).collect(Collectors.toList()), event.getMatrixStack());
}
}
Aggregations