Skip to content

Commit

Permalink
Fixed more bugs after further playtesting. PREPARING FOR THE RELEASE …
Browse files Browse the repository at this point in the history
…FINALLY
  • Loading branch information
remmintan committed Jan 9, 2025
1 parent e9998d5 commit fd95f39
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ class FortressBuildingBlockEntity(pos: BlockPos?, state: BlockState?) :
private val attackers: MutableSet<HostileEntity> = HashSet()
var selectedTabIndex = 0

private val automationArea: IAutomationArea by lazy {
BuildingAutomationArea(start!!, end!!, metadata.requirement)
}

override fun getAutomationArea(): Optional<IAutomationArea> {
return Optional.ofNullable(
if (start != null && end != null) {
BuildingAutomationArea(start!!, end!!, metadata.requirement)
automationArea
} else {
null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ internal class InfoTab(private val handler: IInfoTabHandler, private val textRen
val villagersCapacity: Int = metadata.capacity
if (villagersCapacity > 0) {
val capacityLabel = Text.literal("Capacity: ").formatted(Formatting.DARK_GRAY)
val capacityText = Text.literal("+$villagersCapacity").formatted(Formatting.DARK_PURPLE)
val capacityText = Text.literal("$villagersCapacity").formatted(Formatting.DARK_PURPLE)

texts.add(capacityLabel to capacityText)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ class WorkforceTabHandler(private val provider: IBuildingProvider) : IWorkforceT
}

override fun getMaxCount(professionId: String): Int {
return handler.getHireProgress(professionId).maxCount
val maxCount = handler.getHireProgress(professionId).maxCount

val bookedCapacity = getProfessions().filter { it != professionId }.sumOf {
this.getCurrentCount(it) + this.getHireQueue(it)
}

return maxCount - bookedCapacity
}

override fun increaseAmount(professionId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.remmintan.mods.minefortress.core.ModLogger;
import net.remmintan.mods.minefortress.core.interfaces.server.IFortressModServerManager;
import net.remmintan.mods.minefortress.core.interfaces.server.IServerFortressManager;
import net.remmintan.mods.minefortress.core.interfaces.server.IServerManagersProvider;
Expand Down Expand Up @@ -91,12 +92,16 @@ public void load() {
final var keys = nbtCompound.getKeys();
notEmpty = !keys.isEmpty();
for (String key : keys) {
final var managerNbt = nbtCompound.getCompound(key);
final var masterPlayerId = UUID.fromString(key);
final var manager = new ServerFortressManager(server);
manager.readFromNbt(managerNbt);

serverManagers.put(masterPlayerId, manager);
try {
final var managerNbt = nbtCompound.getCompound(key);
final var masterPlayerId = UUID.fromString(key);
final var manager = new ServerFortressManager(server);
manager.readFromNbt(managerNbt);

serverManagers.put(masterPlayerId, manager);
} catch (RuntimeException exp) {
ModLogger.LOGGER.warn("Failed to load server manager for player with id " + key, exp);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void onMouseButton(long window, int button, int action, int mods, Callba
}
}

if(isPress && button == 0 && client.currentScreen == null) {
if (!isPress && button == 0 && client.currentScreen == null) {
fortressClient.get_FortressHud().onClick(mouseX, mouseY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,20 @@ public void updateProfessions(List<IProfessionEssentialInfo> info) {
@Override
public void openBuildingHireScreen(String professionId) {
final var profession = this.getProfession(professionId);
final var hasBuilding = fortressManagerSupplier.get().hasRequiredBuilding(profession.getRequirementType(), profession.getRequirementLevel(), 0);
final var requirementType = profession.getRequirementType();
final var requirementLevel = profession.getRequirementLevel();

if (requirementLevel < 0 || requirementType == null) {
return;
}

final var hasBuilding = fortressManagerSupplier.get().hasRequiredBuilding(requirementType, requirementLevel, 0);
if (hasBuilding) {
final var packet = new C2SOpenBuildingHireScreen(professionId);
FortressClientNetworkHelper.send(C2SOpenBuildingHireScreen.CHANNEL, packet);
} else {
final var type = profession.getRequirementType();
final var level = profession.getRequirementLevel();
final var type = requirementType;
final var level = requirementLevel;
final var blueprintId = type.getBlueprintIds().get(level);
CoreModUtils.getBlueprintManager()
.getBlueprintMetadataManager()
Expand Down

0 comments on commit fd95f39

Please sign in to comment.