Keep the plan on this client; the host does not need the mod.
Build / build (push) Failing after 28s
Build / build (push) Failing after 28s
Replace player attachments with client-owned files. Singleplayer writes satistaskory.dat next to the world. Remote writes satistaskory/remote/<address>.dat. displayTest IGNORE_ALL_VERSION. No packets, no server jar.
This commit is contained in:
@@ -40,8 +40,8 @@ Read [[🧠 Philosophy]] before changing the vault. The Bookshelf Principle, Pre
|
|||||||
|
|
||||||
## Code
|
## Code
|
||||||
|
|
||||||
The first slice is in code and has been played (ADRs 012–017): [[▶️ Create Goal]], [[🔌 Recipe Provider]] via `RecipeManager`, overlay HUD, capture = tooltip + rebindable Add key, player world save.
|
The first slice is in code and has been played (ADRs 012–018): [[▶️ Create Goal]], [[🔌 Recipe Provider]] via `RecipeManager`, overlay HUD, capture = tooltip + rebindable Add key, client-owned plan files.
|
||||||
|
|
||||||
Do not start EMI/JEI/REI. Recipe source is `RecipeManager` (ADR-016). Persistence is the player in this world (ADR-017). Project waits until settled. Do not rewrite the overlay as a `Screen` unless the HUD path fails.
|
Do not start EMI/JEI/REI. Recipe source is `RecipeManager` (ADR-016). The host does not need this mod (ADR-018). Project waits until settled. Do not rewrite the overlay as a `Screen` unless the HUD path fails.
|
||||||
|
|
||||||
The NeoForge template example block/item is gone. Do not put it back.
|
The NeoForge template example block/item is gone. Do not put it back.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ Those may be integrated with later. They are not owned by Satistaskory.
|
|||||||
|
|
||||||
## Status
|
## Status
|
||||||
|
|
||||||
First slice is in `src/` and has been played: domain, `VanillaRecipeProvider` (`RecipeManager`, one level), player world save, overlay on the right, hover + Add key (default `=`).
|
First slice is in `src/` and has been played: domain, `VanillaRecipeProvider` (`RecipeManager`, one level), client-owned plan files, overlay on the right, hover + Add key (default `=`). The host does not need this mod.
|
||||||
|
|
||||||
`/satistaskory add minecraft:furnace` is a debug command. Not EMI. Template example block/item is gone.
|
`/satistaskory add minecraft:furnace` is a debug command. Not EMI. Template example block/item is gone.
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ RefreshProgress
|
|||||||
missing = required − available
|
missing = required − available
|
||||||
```
|
```
|
||||||
|
|
||||||
Persistence: the player in this world's save (ADR-017). Leave the world and the overlay unloads; come back and the goals load.
|
Persistence: a file this client owns (ADR-018). Leave the world and the overlay unloads; come back and the goals load. The host does not need this mod.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ First use case: [[▶️ Create Goal]]. In code this slice is one `Planner` faca
|
|||||||
|
|
||||||
Mark Goal Complete is named. It is not in the first slice.
|
Mark Goal Complete is named. It is not in the first slice.
|
||||||
|
|
||||||
The application layer calls infrastructure through ports (`RecipeProvider`, inventory snapshot, `GoalStore`). It does not contain domain rules. It loads what the use case needs, asks the domain to decide, and presents the result. Persistence is the player in this world's save (ADR-017).
|
The application layer calls infrastructure through ports (`RecipeProvider`, inventory snapshot, `GoalStore`). It does not contain domain rules. It loads what the use case needs, asks the domain to decide, and presents the result. Persistence is a client-owned file (ADR-018).
|
||||||
|
|
||||||
Packages: [[📦 Packages]].
|
Packages: [[📦 Packages]].
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ Examples:
|
|||||||
- Save data storage
|
- Save data storage
|
||||||
- Inventory scanning
|
- Inventory scanning
|
||||||
|
|
||||||
Shipped this slice: `VanillaRecipeProvider` (`RecipeManager`, all types, one level), player-inventory snapshot, HUD overlay, tooltip+key capture, player world save. `StubRecipeProvider` is unit tests only. EMI/JEI/REI are not dependencies.
|
Shipped this slice: `VanillaRecipeProvider` (`RecipeManager`, all types, one level), player-inventory snapshot, HUD overlay, tooltip+key capture, client-owned plan files. `StubRecipeProvider` is unit tests only. EMI/JEI/REI are not dependencies. The host does not need this mod.
|
||||||
|
|
||||||
Infrastructure is never the source of domain truth.
|
Infrastructure is never the source of domain truth.
|
||||||
|
|
||||||
@@ -147,7 +147,7 @@ Possible implementations:
|
|||||||
- Server Save
|
- Server Save
|
||||||
- Future Cloud Sync
|
- Future Cloud Sync
|
||||||
|
|
||||||
Shipped: player attachment in this world's save. Survives quit and death. Remote multiplayer stays RAM-only until a server adapter exists. See [[💾 Persistence]] and ADR-017.
|
Shipped: client-owned files. Singleplayer lives next to the world; remote lives under the game directory keyed by address. See [[💾 Persistence]] and ADR-018. The host does not need this mod.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -21,18 +21,21 @@ Play uses `PersistingGoalStore`: RAM plus a write after each change.
|
|||||||
|
|
||||||
## Shipped implementation
|
## Shipped implementation
|
||||||
|
|
||||||
Player attachment in **this world's save** (ADR-017).
|
Client-owned files (ADR-018). The host does not need this mod.
|
||||||
|
|
||||||
|
| Where | File |
|
||||||
|
|-------|------|
|
||||||
|
| Singleplayer | `<world>/satistaskory.dat` |
|
||||||
|
| Remote / LAN guest | `satistaskory/remote/<address>.dat` in the game directory |
|
||||||
|
|
||||||
| Event | Result |
|
| Event | Result |
|
||||||
|-------|--------|
|
|-------|--------|
|
||||||
| Join world | Load this player's goals |
|
| Join world | Load this client's file for that world or address |
|
||||||
| Create / + / − / Clear | Write the attachment |
|
| Create / + / − / Clear | Write that file |
|
||||||
| Leave world | Unload RAM. Do not write empty (that would wipe the save) |
|
| Leave world | Unload RAM. Do not write empty (that would wipe the save) |
|
||||||
| Death | Plan is copied. It is not loot |
|
| Death | Irrelevant. The plan is not on the player entity |
|
||||||
|
|
||||||
Singleplayer and LAN host. Remote dedicated server: RAM-only this slice.
|
A later server or cloud adapter is still allowed. It does not change `GoalStore`. It is not required for the prosthetic to function.
|
||||||
|
|
||||||
Server save and cloud remain possible later. They do not change `GoalStore`.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -297,12 +297,37 @@ The port remains. The **order** was wrong.
|
|||||||
|
|
||||||
The first slice is a prosthetic the player can quit and resume. ADR-004 named world save, server save, and cloud. World save is the one they play.
|
The first slice is a prosthetic the player can quit and resume. ADR-004 named world save, server save, and cloud. World save is the one they play.
|
||||||
|
|
||||||
**Status:** ✅ Accepted
|
**Status:** ⚠️ Superseded by ADR-018
|
||||||
|
|
||||||
**Refines:** ADR-004. **Supersedes** ADR-013’s “Persistence: in-memory” freeze for this slice.
|
**Refines:** ADR-004. **Supersedes** ADR-013’s “Persistence: in-memory” freeze for this slice.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### ADR-018 — Client-only; the host does not need this mod
|
||||||
|
|
||||||
|
**Date:** 2026-09-08
|
||||||
|
|
||||||
|
**Decision:** Satistaskory is a **client** mod. A dedicated server, LAN host, or singleplayer integrated server does not need it installed for the prosthetic to work.
|
||||||
|
|
||||||
|
Persistence is a file this client owns:
|
||||||
|
|
||||||
|
- Singleplayer: `<world>/satistaskory.dat` (travels with the world backup)
|
||||||
|
- Remote / LAN guest: `satistaskory/remote/<address>.dat` under the game directory
|
||||||
|
|
||||||
|
`displayTest="IGNORE_ALL_VERSION"`. No player attachment. No server packet. No server jar.
|
||||||
|
|
||||||
|
The overlay, capture, inventory snapshot, and `RecipeManager` lookup already run on the client. ADR-017’s player attachment was the only thing that required the mod on the host. That was the wrong persistence for this product.
|
||||||
|
|
||||||
|
**Reason:**
|
||||||
|
|
||||||
|
The player carries the plan. The server is not a Satistaskory collaborator. Requiring the jar on a friend’s server, a modpack host, or a dedicated box would make the prosthetic a pack dependency instead of a personal tool.
|
||||||
|
|
||||||
|
**Status:** ✅ Accepted
|
||||||
|
|
||||||
|
**Supersedes:** ADR-017 (player attachment in the world save)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Related Documents
|
## Related Documents
|
||||||
|
|
||||||
[[🏛️ Architecture]]
|
[[🏛️ Architecture]]
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ com.sufficient.satistaskory
|
|||||||
persistence/
|
persistence/
|
||||||
GoalPlan # NBT codec
|
GoalPlan # NBT codec
|
||||||
PersistingGoalStore
|
PersistingGoalStore
|
||||||
PlayerGoalPersistence # player attachment in this world
|
ClientGoalPersistence # client files; host does not need this mod
|
||||||
|
ClientSaveKeys
|
||||||
client/
|
client/
|
||||||
PlayOverlay # Screen 2 HUD (not a Screen)
|
PlayOverlay # Screen 2 HUD (not a Screen)
|
||||||
CaptureHook # tooltip + KeyMapping ADD_GOAL
|
CaptureHook # tooltip + KeyMapping ADD_GOAL
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ What exists, and what is next. Implementation detail will live in an Implementat
|
|||||||
|
|
||||||
## ✅ Now (docs)
|
## ✅ Now (docs)
|
||||||
|
|
||||||
- Philosophy Rules #1–#10; ADRs **001–017**
|
- Philosophy Rules #1–#10; ADRs **001–018**
|
||||||
- Vision, ubiquitous language, bounded context (one: Goal Planning)
|
- Vision, ubiquitous language, bounded context (one: Goal Planning)
|
||||||
- Goal invariants: one per ItemId, quantity ≥ 1, create at 1 / +1, `[-]` at 1 removes
|
- Goal invariants: one per ItemId, quantity ≥ 1, create at 1 / +1, `[-]` at 1 removes
|
||||||
- Packages named; [[🔌 Recipe Provider]] sketched; [[▶️ Create Goal]] written
|
- Packages named; [[🔌 Recipe Provider]] sketched; [[▶️ Create Goal]] written
|
||||||
- Experience: capture in place; overlay on the right (goals + aggregated needed counts)
|
- Experience: capture in place; overlay on the right (goals + aggregated needed counts)
|
||||||
|
|
||||||
First slice **code exists** and has been played: domain, `VanillaRecipeProvider` (`RecipeManager`, all types, one level), player world save, player inventory, play overlay, hover + Add key.
|
First slice **code exists** and has been played: domain, `VanillaRecipeProvider` (`RecipeManager`, all types, one level), client-owned plan files, player inventory, play overlay, hover + Add key. Host does not need this mod.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -381,6 +381,20 @@ Do not open Project because that feels like "what's next." Listen.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 📜 2026-09-08 (client-only)
|
||||||
|
|
||||||
|
Greetings, Wayfinder.
|
||||||
|
|
||||||
|
The player attachment was the wrong save. It made Satistaskory a host mod.
|
||||||
|
|
||||||
|
ADR-018: client-only. Overlay, capture, recipes, inventory were already client. Persistence is a file this client owns. Singleplayer writes `satistaskory.dat` next to the world. Remote writes `satistaskory/remote/<address>.dat`. `displayTest=IGNORE_ALL_VERSION`. No packet. No server jar.
|
||||||
|
|
||||||
|
If they playtested the attachment build, those goals will not come back. Re-add once.
|
||||||
|
|
||||||
|
The prosthetic travels with the player, not with the pack.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Related Documents
|
## Related Documents
|
||||||
|
|
||||||
[[🌟 Project Vision]]
|
[[🌟 Project Vision]]
|
||||||
|
|||||||
@@ -4,32 +4,17 @@ import org.slf4j.Logger;
|
|||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
|
||||||
import com.sufficient.satistaskory.infrastructure.persistence.GoalPlan;
|
import net.neoforged.api.distmarker.Dist;
|
||||||
|
|
||||||
import net.neoforged.bus.api.IEventBus;
|
import net.neoforged.bus.api.IEventBus;
|
||||||
import net.neoforged.fml.ModContainer;
|
import net.neoforged.fml.ModContainer;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.neoforge.attachment.AttachmentType;
|
|
||||||
import net.neoforged.neoforge.registries.DeferredHolder;
|
|
||||||
import net.neoforged.neoforge.registries.DeferredRegister;
|
|
||||||
import net.neoforged.neoforge.registries.NeoForgeRegistries;
|
|
||||||
|
|
||||||
@Mod(Satistaskory.MODID)
|
@Mod(value = Satistaskory.MODID, dist = Dist.CLIENT)
|
||||||
public class Satistaskory {
|
public class Satistaskory {
|
||||||
public static final String MODID = "satistaskory";
|
public static final String MODID = "satistaskory";
|
||||||
public static final Logger LOGGER = LogUtils.getLogger();
|
public static final Logger LOGGER = LogUtils.getLogger();
|
||||||
|
|
||||||
public static final DeferredRegister<AttachmentType<?>> ATTACHMENT_TYPES =
|
|
||||||
DeferredRegister.create(NeoForgeRegistries.Keys.ATTACHMENT_TYPES, MODID);
|
|
||||||
|
|
||||||
public static final DeferredHolder<AttachmentType<?>, AttachmentType<GoalPlan>> PLAYER_GOALS =
|
|
||||||
ATTACHMENT_TYPES.register("player_goals", () -> AttachmentType.builder(GoalPlan::empty)
|
|
||||||
.serialize(GoalPlan.CODEC)
|
|
||||||
.copyOnDeath()
|
|
||||||
.build());
|
|
||||||
|
|
||||||
public Satistaskory(IEventBus modEventBus, ModContainer modContainer) {
|
public Satistaskory(IEventBus modEventBus, ModContainer modContainer) {
|
||||||
ATTACHMENT_TYPES.register(modEventBus);
|
LOGGER.info("Satistaskory loaded. Client-only. Goals are the domain.");
|
||||||
LOGGER.info("Satistaskory loaded. Goals are the domain.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,14 @@ import com.sufficient.satistaskory.domain.ProgressCalculation;
|
|||||||
import com.sufficient.satistaskory.domain.RecipeResolution;
|
import com.sufficient.satistaskory.domain.RecipeResolution;
|
||||||
import com.sufficient.satistaskory.infrastructure.inventory.PlayerInventoryAdapter;
|
import com.sufficient.satistaskory.infrastructure.inventory.PlayerInventoryAdapter;
|
||||||
import com.sufficient.satistaskory.infrastructure.persistence.PersistingGoalStore;
|
import com.sufficient.satistaskory.infrastructure.persistence.PersistingGoalStore;
|
||||||
import com.sufficient.satistaskory.infrastructure.persistence.PlayerGoalPersistence;
|
import com.sufficient.satistaskory.infrastructure.persistence.ClientGoalPersistence;
|
||||||
import com.sufficient.satistaskory.infrastructure.recipe.VanillaRecipeProvider;
|
import com.sufficient.satistaskory.infrastructure.recipe.VanillaRecipeProvider;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.player.LocalPlayer;
|
import net.minecraft.client.player.LocalPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client plan for the current world. Written to the player in this world's save.
|
* Client plan for the current world. Written to a file this client owns.
|
||||||
*/
|
*/
|
||||||
public final class PlannerSession {
|
public final class PlannerSession {
|
||||||
private static PersistingGoalStore store;
|
private static PersistingGoalStore store;
|
||||||
@@ -41,7 +41,7 @@ public final class PlannerSession {
|
|||||||
|
|
||||||
public static void onJoinWorld() {
|
public static void onJoinWorld() {
|
||||||
bootstrap();
|
bootstrap();
|
||||||
store.loadFromWorld(PlayerGoalPersistence.load());
|
store.loadFromWorld(ClientGoalPersistence.load());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onLeaveWorld() {
|
public static void onLeaveWorld() {
|
||||||
|
|||||||
+92
@@ -0,0 +1,92 @@
|
|||||||
|
package com.sufficient.satistaskory.infrastructure.persistence;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.mojang.serialization.DataResult;
|
||||||
|
|
||||||
|
import com.sufficient.satistaskory.Satistaskory;
|
||||||
|
import com.sufficient.satistaskory.domain.Goal;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.multiplayer.ServerData;
|
||||||
|
import net.minecraft.client.server.IntegratedServer;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.NbtAccounter;
|
||||||
|
import net.minecraft.nbt.NbtIo;
|
||||||
|
import net.minecraft.nbt.NbtOps;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.world.level.storage.LevelResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Client-owned files. The server does not need this mod.
|
||||||
|
* Singleplayer: {@code <world>/satistaskory.dat}. Remote: {@code satistaskory/remote/<address>.dat}.
|
||||||
|
*/
|
||||||
|
public final class ClientGoalPersistence {
|
||||||
|
private ClientGoalPersistence() {}
|
||||||
|
|
||||||
|
public static List<Goal> load() {
|
||||||
|
Path file = currentFile();
|
||||||
|
if (file == null || !Files.isRegularFile(file)) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
CompoundTag root = NbtIo.readCompressed(file, NbtAccounter.unlimitedHeap());
|
||||||
|
Tag planTag = root.get("Plan");
|
||||||
|
if (planTag == null) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
DataResult<GoalPlan> parsed = GoalPlan.CODEC.parse(NbtOps.INSTANCE, planTag);
|
||||||
|
return parsed.result().map(GoalPlan::toGoals).orElseGet(() -> {
|
||||||
|
Satistaskory.LOGGER.warn("Ignoring unreadable Satistaskory plan at {}", file);
|
||||||
|
return List.of();
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
Satistaskory.LOGGER.warn("Could not read Satistaskory plan at {}", file, e);
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save(List<Goal> goals) {
|
||||||
|
Path file = currentFile();
|
||||||
|
if (file == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DataResult<Tag> encoded = GoalPlan.CODEC.encodeStart(NbtOps.INSTANCE, GoalPlan.fromGoals(goals));
|
||||||
|
Tag planTag = encoded.result().orElse(null);
|
||||||
|
if (planTag == null) {
|
||||||
|
Satistaskory.LOGGER.warn("Could not encode Satistaskory plan");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CompoundTag root = new CompoundTag();
|
||||||
|
root.putInt("DataVersion", 1);
|
||||||
|
root.put("Plan", planTag);
|
||||||
|
try {
|
||||||
|
Path parent = file.getParent();
|
||||||
|
if (parent != null) {
|
||||||
|
Files.createDirectories(parent);
|
||||||
|
}
|
||||||
|
NbtIo.writeCompressed(root, file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Satistaskory.LOGGER.warn("Could not write Satistaskory plan at {}", file, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Path currentFile() {
|
||||||
|
Minecraft minecraft = Minecraft.getInstance();
|
||||||
|
IntegratedServer integrated = minecraft.getSingleplayerServer();
|
||||||
|
if (integrated != null) {
|
||||||
|
return integrated.getWorldPath(LevelResource.ROOT).resolve("satistaskory.dat");
|
||||||
|
}
|
||||||
|
ServerData server = minecraft.getCurrentServer();
|
||||||
|
if (server != null && server.ip != null && !server.ip.isBlank()) {
|
||||||
|
return minecraft.gameDirectory.toPath()
|
||||||
|
.resolve("satistaskory")
|
||||||
|
.resolve("remote")
|
||||||
|
.resolve(ClientSaveKeys.remoteFileName(server.ip));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.sufficient.satistaskory.infrastructure.persistence;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File names for remote-server plans on this client. Not a domain type.
|
||||||
|
*/
|
||||||
|
public final class ClientSaveKeys {
|
||||||
|
private ClientSaveKeys() {}
|
||||||
|
|
||||||
|
public static String remoteFileName(String address) {
|
||||||
|
String cleaned = address.toLowerCase(Locale.ROOT).replaceAll("[^a-z0-9._-]+", "_");
|
||||||
|
cleaned = cleaned.replaceAll("^_+|_+$", "");
|
||||||
|
if (cleaned.isEmpty()) {
|
||||||
|
cleaned = "unknown";
|
||||||
|
}
|
||||||
|
if (cleaned.length() > 80) {
|
||||||
|
cleaned = cleaned.substring(0, 80);
|
||||||
|
}
|
||||||
|
return cleaned + ".dat";
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -9,7 +9,7 @@ import com.sufficient.satistaskory.domain.Goal;
|
|||||||
import com.sufficient.satistaskory.domain.ItemId;
|
import com.sufficient.satistaskory.domain.ItemId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RAM store that writes the player's world save after each change.
|
* RAM store that writes this client's plan file after each change.
|
||||||
* Load and leave-world must not write; otherwise logout would wipe the save.
|
* Load and leave-world must not write; otherwise logout would wipe the save.
|
||||||
*/
|
*/
|
||||||
public final class PersistingGoalStore implements GoalStore {
|
public final class PersistingGoalStore implements GoalStore {
|
||||||
@@ -61,7 +61,7 @@ public final class PersistingGoalStore implements GoalStore {
|
|||||||
|
|
||||||
private void persist() {
|
private void persist() {
|
||||||
if (persist) {
|
if (persist) {
|
||||||
PlayerGoalPersistence.save(inner.all());
|
ClientGoalPersistence.save(inner.all());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-49
@@ -1,49 +0,0 @@
|
|||||||
package com.sufficient.satistaskory.infrastructure.persistence;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.sufficient.satistaskory.Satistaskory;
|
|
||||||
import com.sufficient.satistaskory.domain.Goal;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.server.IntegratedServer;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Player attachment in this world's save. Singleplayer and LAN host.
|
|
||||||
* A remote server has no integrated save; the session stays RAM-only there.
|
|
||||||
*/
|
|
||||||
public final class PlayerGoalPersistence {
|
|
||||||
private PlayerGoalPersistence() {}
|
|
||||||
|
|
||||||
public static List<Goal> load() {
|
|
||||||
Minecraft minecraft = Minecraft.getInstance();
|
|
||||||
IntegratedServer server = minecraft.getSingleplayerServer();
|
|
||||||
if (server == null || minecraft.player == null) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
ServerPlayer player = server.getPlayerList().getPlayer(minecraft.player.getUUID());
|
|
||||||
if (player == null) {
|
|
||||||
return List.of();
|
|
||||||
}
|
|
||||||
return player.getData(Satistaskory.PLAYER_GOALS).toGoals();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void save(List<Goal> goals) {
|
|
||||||
Minecraft minecraft = Minecraft.getInstance();
|
|
||||||
IntegratedServer server = minecraft.getSingleplayerServer();
|
|
||||||
if (server == null || minecraft.player == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UUID id = minecraft.player.getUUID();
|
|
||||||
GoalPlan plan = GoalPlan.fromGoals(goals);
|
|
||||||
server.execute(() -> {
|
|
||||||
ServerPlayer player = server.getPlayerList().getPlayer(id);
|
|
||||||
if (player == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.setData(Satistaskory.PLAYER_GOALS, plan);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -44,6 +44,10 @@ displayName="${mod_name}" #mandatory
|
|||||||
# The authors of the mod, displayed in the mod UI (optional)
|
# The authors of the mod, displayed in the mod UI (optional)
|
||||||
authors="sufficient"
|
authors="sufficient"
|
||||||
|
|
||||||
|
# Client-only. The server must not require this mod to be installed.
|
||||||
|
# IGNORE_ALL_VERSION: joining a host that does not have Satistaskory is allowed.
|
||||||
|
displayTest="IGNORE_ALL_VERSION"
|
||||||
|
|
||||||
# The description text for the mod (multi line!) (#mandatory)
|
# The description text for the mod (multi line!) (#mandatory)
|
||||||
description='''
|
description='''
|
||||||
A Satisfactory-inspired crafting planner and goal tracker
|
A Satisfactory-inspired crafting planner and goal tracker
|
||||||
@@ -75,7 +79,7 @@ A Satisfactory-inspired crafting planner and goal tracker
|
|||||||
# AFTER - This mod is loaded AFTER the dependency
|
# AFTER - This mod is loaded AFTER the dependency
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT, or SERVER
|
||||||
side="BOTH"
|
side="CLIENT"
|
||||||
|
|
||||||
# Here's another dependency
|
# Here's another dependency
|
||||||
[[dependencies.${mod_id}]]
|
[[dependencies.${mod_id}]]
|
||||||
@@ -84,7 +88,7 @@ A Satisfactory-inspired crafting planner and goal tracker
|
|||||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||||
versionRange="${minecraft_version_range}"
|
versionRange="${minecraft_version_range}"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="CLIENT"
|
||||||
|
|
||||||
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
# Features are specific properties of the game environment, that you may want to declare you require. This example declares
|
||||||
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
# that your mod requires GL version 3.2 or higher. Other features will be added. They are side aware so declaring this won't
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.sufficient.satistaskory.infrastructure.persistence;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class ClientSaveKeysTest {
|
||||||
|
@Test
|
||||||
|
void sanitizesHostAndPort() {
|
||||||
|
assertEquals("127.0.0.1_25565.dat", ClientSaveKeys.remoteFileName("127.0.0.1:25565"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void keepsHostnameDots() {
|
||||||
|
assertEquals("play.hypixel.net.dat", ClientSaveKeys.remoteFileName("play.hypixel.net"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void emptyBecomesUnknown() {
|
||||||
|
assertEquals("unknown.dat", ClientSaveKeys.remoteFileName(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user