Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/main/generated/assets/galacticraft/docs/home.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"elements": [
{
"type": "text",
"align": "left",
"nmaxX": 0.62,
"nmaxY": 0.42,
"nminX": 0.04,
"nminY": 0.18,
"order": 0,
"textKey": "doc.gc.home.intro"
},
{
"type": "text",
"align": "left",
"nmaxX": 0.76,
"nmaxY": 0.52,
"nminX": 0.04,
"nminY": 0.46,
"order": 1,
"textKey": "doc.gc.home.category_label"
},
{
"type": "button",
"nh": 0.12,
"nw": 0.18,
"nx": 0.04,
"ny": 0.6,
"order": 2,
"target": "galacticraft:air_lock_controller",
"textKey": "doc.gc.home.btn.airlock"
},
{
"type": "text",
"align": "left",
"nmaxX": 0.38,
"nmaxY": 0.5,
"nminX": 0.06,
"nminY": 0.24,
"order": 3,
"textKey": "doc.gc.home.intro"
}
],
"schema": 2,
"titleKey": "doc.gc.home.title"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"bind": [
"galacticraft:air_lock_controller"
],
"elements": [
{
"type": "text",
"align": "left",
"nmaxX": 0.54,
"nmaxY": 0.61,
"nminX": 0.04,
"nminY": 0.28,
"order": 0,
"textKey": "doc.gc.airlock.overview"
},
{
"type": "button",
"nh": 0.1,
"nw": 0.24,
"nx": 0.04,
"ny": 0.7,
"order": 1,
"target": "galacticraft:home",
"textKey": "gc.docs.back"
}
],
"id": "galacticraft:air_lock_controller",
"schema": 2,
"sections": [
{
"type": "overview",
"bodyKey": "doc.gc.airlock.overview",
"headingKey": "doc.common.overview"
}
],
"titleKey": "doc.gc.airlock.title"
}
11 changes: 11 additions & 0 deletions src/main/generated/assets/galacticraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,13 @@
"death.attack.vine_poison": "%s succumbed to the poison of some vines",
"death.attack.vine_poison.player": "%s succumbed to the poison of some vines while trying to escape %s",
"disconnect.galacticraft.dimensiontp.invalidPacket": "Invalid planet teleport packet received.",
"doc.common.overview": "Overview",
"doc.gc.airlock.overview": "Place the Airlock Controller and connect frames. Power it with redstone to toggle the door.",
"doc.gc.airlock.title": "Airlock Controller",
"doc.gc.home.btn.airlock": "Airlock Controller",
"doc.gc.home.category_label": "Categories",
"doc.gc.home.intro": "Galacticraft 5 Rewoven. The number 1 space mod rewritten for the latest version of Minecraft.",
"doc.gc.home.title": "Galacticraft Documentation",
"entity.galacticraft.arch_grey": "Arch Grey",
"entity.galacticraft.bubble": "Bubble",
"entity.galacticraft.buggy": "Buggy",
Expand Down Expand Up @@ -521,6 +528,7 @@
"gas.galacticraft.ozone": "Ozone",
"gas.galacticraft.water_vapor": "Water Vapor",
"gas.galacticraft.xenon": "Xenon",
"gc.docs.back": "Back",
"gui.skeleton_boss.message": "Boss despawned, don't leave the boss room while fighting! Re-enter room to respawn boss.",
"item.galacticraft.advanced_wafer": "Advanced Wafer",
"item.galacticraft.aluminum_ingot": "Aluminum Ingot",
Expand Down Expand Up @@ -715,8 +723,10 @@
"jukebox_song.galacticraft.legacy_mimas": "Jackson Cordes - Mimas",
"jukebox_song.galacticraft.legacy_orbit": "Jackson Cordes - Orbit",
"jukebox_song.galacticraft.legacy_spacerace": "Jackson Cordes - Space Race",
"key.categories.galacticraft": "Galacticraft",
"key.galacticraft.open_celestial_screen": "Open Celestial Map",
"key.galacticraft.rocket.inventory": "Open Rocket Inventory",
"key.gc.inspect": "Inspect",
"planet.galacticraft.asteroid": "Asteroids",
"planet.galacticraft.asteroid.description": "",
"planet.galacticraft.earth": "Earth",
Expand Down Expand Up @@ -882,6 +892,7 @@
"tooltip.galacticraft.standard_wrench": "Most Galacticraft machines can be rotated by right-clicking with the Standard Wrench.",
"tooltip.galacticraft.time_until_cool": "Time Until Cool: %s",
"tooltip.galacticraft.waila_oxygen_tank": "O₂ Tank %s",
"tooltip.gc.inspect_hint": "Press %s to inspect",
"ui.galacticraft.airlock.owner": "%s's Airlock Controller",
"ui.galacticraft.airlock.redstone_signal": "Opens on Redstone Signal",
"ui.galacticraft.alpha_warning.content1": "Galacticraft is currently in ALPHA.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:air"
"name": "galacticraft:olivine_block"
}
],
"rolls": 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void generateDefaultTranslations(@NotNull HolderLookup.Provider regist

protected abstract void generateTranslations(@NotNull HolderLookup.Provider registries);

protected void add(String key, String translation) {
public void add(String key, String translation) {
this.translations.put(key, translation);
}

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/dev/galacticraft/mod/api/documentation/DocsApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2019-2025 Team Galacticraft
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package dev.galacticraft.mod.api.documentation;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;

public final class DocsApi {
private DocsApi() {}
public static ResourceLocation homeId() { return DocsManager.HOME_ID; }
public static void openHome() { DocsManager.openHome(); }
public static void open(ResourceLocation pageId) { DocsManager.open(pageId); }
public static ResourceLocation pageForItem(Item item) { return DocsManager.pageFor(item); }
}
171 changes: 171 additions & 0 deletions src/main/java/dev/galacticraft/mod/api/documentation/DocsManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/*
* Copyright (c) 2019-2025 Team Galacticraft
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package dev.galacticraft.mod.api.documentation;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import dev.galacticraft.mod.Constant;
import dev.galacticraft.mod.api.documentation.client.pages.BlankPageScreen;
import dev.galacticraft.mod.api.documentation.model.HomeDoc;
import dev.galacticraft.mod.api.documentation.model.SectionOverview;
import dev.galacticraft.mod.api.documentation.model.SubDoc;
import dev.galacticraft.mod.api.documentation.model.elements.ButtonElement;
import dev.galacticraft.mod.api.documentation.model.elements.Element;
import dev.galacticraft.mod.api.documentation.model.elements.ImageElement;
import dev.galacticraft.mod.api.documentation.model.elements.TextElement;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public final class DocsManager {
public static final ResourceLocation HOME_ID = Constant.id("home");

public static final Gson GSON = new GsonBuilder()
.registerTypeAdapter(ResourceLocation.class,
(com.google.gson.JsonDeserializer<ResourceLocation>) (json, t, ctx) ->
ResourceLocation.parse(json.getAsString()))
.registerTypeAdapter(ResourceLocation.class,
(com.google.gson.JsonSerializer<ResourceLocation>) (src, t, ctx) ->
new com.google.gson.JsonPrimitive(src.toString()))
.registerTypeAdapter(dev.galacticraft.mod.api.documentation.model.Section.class,
(com.google.gson.JsonDeserializer<dev.galacticraft.mod.api.documentation.model.Section>) (json, t, ctx) -> {
JsonObject obj = json.getAsJsonObject();
String type = obj.get("type").getAsString();
if ("overview".equals(type)) {
String headingKey = obj.has("headingKey") ? obj.get("headingKey").getAsString() : null;
String bodyKey = obj.has("bodyKey") ? obj.get("bodyKey").getAsString() : null;
return new SectionOverview(type, headingKey, bodyKey);
}
throw new JsonParseException("Unknown docs section type: " + type);
})
.registerTypeAdapter(Element.class,
(com.google.gson.JsonDeserializer<Element>) (json, t, ctx) -> {
com.google.gson.JsonObject obj = json.getAsJsonObject();
String type = obj.get("type").getAsString();

switch (type) {
case "button" -> {
float nx = obj.get("nx").getAsFloat();
float ny = obj.get("ny").getAsFloat();
float nw = obj.get("nw").getAsFloat();
float nh = obj.get("nh").getAsFloat();
String textKey = obj.get("textKey").getAsString();
String target = obj.get("target").getAsString();
int order = obj.get("order").getAsInt();
return new ButtonElement(type, nx, ny, nw, nh, textKey, target, order);
}
case "text" -> {
float nminX = obj.get("nminX").getAsFloat();
float nminY = obj.get("nminY").getAsFloat();
float nmaxX = obj.get("nmaxX").getAsFloat();
float nmaxY = obj.get("nmaxY").getAsFloat();
String textKey = obj.get("textKey").getAsString();
String align = obj.has("align") ? obj.get("align").getAsString() : null;
int order = obj.get("order").getAsInt();
return new TextElement(type, nminX, nminY, nmaxX, nmaxY, textKey, align, order);
}
case "image" -> {
float nx = obj.get("nx").getAsFloat();
float ny = obj.get("ny").getAsFloat();
float nw = obj.get("nw").getAsFloat();
float nh = obj.get("nh").getAsFloat();
String texture = obj.get("texture").getAsString();
int u = obj.get("u").getAsInt();
int v = obj.get("v").getAsInt();
int texW = obj.get("texW").getAsInt();
int texH = obj.get("texH").getAsInt();
int order = obj.get("order").getAsInt();
return new ImageElement(type, nx, ny, nw, nh, texture, u, v, texW, texH, order);
}
default -> throw new com.google.gson.JsonParseException("Unknown docs element type: " + type);
}
})
.setPrettyPrinting()
.create();
private static final Map<ResourceLocation, SubDoc> DOCS = new LinkedHashMap<>();
private static final Map<Item, ResourceLocation> ITEM_TO_PAGE = new HashMap<>();
private static final Map<ResourceLocation, ResourceLocation> PARENTS = new HashMap<>();
private static HomeDoc HOME;

private DocsManager() {
}

public static void clear() {
HOME = null;
DOCS.clear();
ITEM_TO_PAGE.clear();
PARENTS.clear();
}

public static void setHome(HomeDoc home) {
HOME = home;
}

public static void addDoc(SubDoc doc, Collection<Item> boundItems) {
DOCS.put(doc.id(), doc);

ResourceLocation parent = doc.parent() != null ? doc.parent() : HOME_ID;
PARENTS.put(doc.id(), parent);

for (Item it : boundItems) {
ITEM_TO_PAGE.put(it, doc.id());
}
}

public static ResourceLocation pageFor(Item item) {
return ITEM_TO_PAGE.get(item);
}

public static ResourceLocation parentOf(ResourceLocation id) {
return PARENTS.get(id);
}

public static HomeDoc getHomeDoc() {
return HOME;
}

public static SubDoc getDoc(ResourceLocation id) {
return DOCS.get(id);
}

public static void openHome() {
final String titleKey = (HOME != null) ? HOME.titleKey() : "doc.gc.home.title";
Minecraft.getInstance().setScreen(new BlankPageScreen(HOME_ID, titleKey));
}

public static void open(ResourceLocation id) {
SubDoc doc = DOCS.get(id);
if (doc != null) {
Minecraft.getInstance().setScreen(new BlankPageScreen(id, doc.titleKey()));
} else {
openHome();
}
}
}
Loading