Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Bedframe

## Premise
> [!WARNING]
> Bedframe is in early development, and you should *expect* problems. Batteries not included. See store for details.

Translation layer that converts textured/custom server-side Polymer blocks and items to native Bedrock representations.

> [!NOTE]
> If you are looking for general modding support on bedrock, see if [Hydraulic](https://github.com/GeyserMC/Hydraulic) works for you. Their conversion code is better than mine. Do note that Hydraulic *does not* support Polymer mods at the moment, and I haven't tested if both mods work at the same time.

## Requirements

- [Geyser-Fabric](https://geysermc.org/download)
Expand All @@ -13,22 +17,17 @@ You also probably want Polymer's Auto-Host feature, but Bedframe doesn't require

## Compatibility

- Works perfectly with [More Furnaces (Polymer)](https://modrinth.com/mod/morefurnaces)*
- Works perfectly with [Televator](https://modrinth.com/mod/televator)
- Will probably work with most simple Polymer Resource Pack mods

*technically there is an item display for upgrades, but its hardly noticeable
Polymer mods that use display entities are not supported at the moment. (Geyser simply doesn't support it). So far I've tested the following:

## Limitations & Goals
- [Tom's Server Additions](https://modrinth.com/mods?q=Tom%27s+Server+Additions) (EXCLUDING Decorations and Furniture)
- [More Furnaces](https://modrinth.com/mod/morefurnaces)
- [Televator](https://modrinth.com/mod/televator)
- [Navigation Compasses](https://modrinth.com/mod/navigation-compasses) (might be under review)

- Custom models (a.k.a non-full-block or cross-block) do not work
- Entities are not touched
- Mods that use block displays don't work
Bedframe does not touch non-textured blocks (so mods like [Server-Side Waystones](https://modrinth.com/mod/sswaystones) will work as expected)

### Mods
- [Borukva-Food](https://github.com/MykhailoOpryshok/Borukva-Food/tree/master) is missing many models/textures (mostly crops and 3D tools)
- [Tom's Server Additions](https://modrinth.com/mods?q=Tom%27s+Server+Additions) is quite *iffy*
Feel free to [make an issue](https://github.com/sylvxa/bedframe/issues/new) for incompatible mods.

## License

This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own project
This mod is available under the CC0 license. Feel free to learn from it and incorporate it in your own project
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ repositories {
maven {
url = uri("https://repo.opencollab.dev/main/")
}

// Serves "creative" library, needed for pack converter
maven {
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}

sourceSets {
Expand Down Expand Up @@ -75,6 +80,11 @@ dependencies {
// Geyser
compileOnly("org.geysermc.geyser:api:${project.geyser_version}")
compileOnly("org.geysermc.geyser:core:${project.geyser_version}")

include api("org.geysermc.pack:converter:${project.pack_converter_version}")
include api("org.geysermc.pack:pack-schema-api:${project.pack_converter_version}")
include api("team.unnamed:creative-api:1.8.2-SNAPSHOT")
include api("team.unnamed:creative-serializer-minecraft:1.8.2-SNAPSHOT")
}

processResources {
Expand Down
15 changes: 9 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.5
yarn_mappings=1.21.5+build.1
minecraft_version=1.21.6
yarn_mappings=1.21.6+build.1
loader_version=0.16.14
loom_version=1.10-SNAPSHOT

Expand All @@ -15,13 +15,16 @@ maven_group=lol.sylvie
archives_base_name=bedframe

# Dependencies
fabric_version=0.124.2+1.21.5
fabric_version=0.127.0+1.21.6

# Find updates at https://maven.nucleoid.xyz/eu/pb4/polymer-core/
polymer_version=0.12.6+1.21.5
polymer_version=0.13.3+1.21.6

# Find updates at https://maven.nucleoid.xyz/xyz/nucleoid/server-translations-api/
server_translations_version=2.5.0+1.21.5-rc1
server_translations_version=2.5.1+1.21.5

# Find updates at https://repo.opencollab.dev/#/maven-snapshots/org/geysermc/geyser/api
geyser_version=2.7.1-SNAPSHOT
geyser_version=2.8.0-SNAPSHOT

# Find updates at https://repo.opencollab.dev/#/maven-snapshots/org/geysermc/pack/converter
pack_converter_version=3.3.2-SNAPSHOT
8 changes: 8 additions & 0 deletions src/main/java/lol/sylvie/bedframe/BedframeInitializer.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package lol.sylvie.bedframe;

import eu.pb4.polymer.resourcepack.api.PolymerResourcePackUtils;
import eu.pb4.polymer.resourcepack.api.ResourcePackBuilder;
import lol.sylvie.bedframe.geyser.TranslationManager;
import lol.sylvie.bedframe.util.ResourceHelper;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.metadata.Person;

import java.nio.file.Path;
import java.util.function.Consumer;

import static lol.sylvie.bedframe.util.BedframeConstants.*;

Expand All @@ -22,5 +26,9 @@ public void onInitialize() {
TranslationManager manager = new TranslationManager();
manager.registerHooks();
});

PolymerResourcePackUtils.RESOURCE_PACK_AFTER_INITIAL_CREATION_EVENT.register(resourcePackBuilder -> {
ResourceHelper.PACK_BUILDER = resourcePackBuilder;
});
}
}
24 changes: 15 additions & 9 deletions src/main/java/lol/sylvie/bedframe/geyser/PackGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import lol.sylvie.bedframe.util.BedframeConstants;
import lol.sylvie.bedframe.util.PathHelper;
import lol.sylvie.bedframe.util.ResourceHelper;
import lol.sylvie.bedframe.util.ZipHelper;
import lol.sylvie.bedframe.util.*;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.Version;
import net.minecraft.text.Text;
import net.minecraft.util.Pair;
import org.geysermc.pack.converter.util.NioDirectoryFileTreeReader;
import team.unnamed.creative.ResourcePack;
import team.unnamed.creative.serialize.minecraft.MinecraftResourcePackReader;
import xyz.nucleoid.server.translations.api.language.TranslationAccess;
import xyz.nucleoid.server.translations.impl.ServerTranslations;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
import java.util.function.Function;

import static lol.sylvie.bedframe.util.BedframeConstants.GSON;
import static lol.sylvie.bedframe.util.BedframeConstants.METADATA;
Expand All @@ -24,6 +29,8 @@
* Compiles the output of the {@link Translator} classes into a Bedrock resource pack
*/
public class PackGenerator {
private static final HashMap<String, ResourcePack> RESOURCE_PACK_MAP = new HashMap<>();

private static JsonArray getVersionArray() {
// TODO: A regex would be more inclusive
Version version = BedframeConstants.METADATA.getVersion();
Expand Down Expand Up @@ -93,24 +100,23 @@ public void generatePack(Path packPath, File outputFile, List<Translator> transl
PathHelper.createDirectoryOrThrow(textsDir);

// TODO: I'm not sure if translations are even necessary
/*JsonArray languages = new JsonArray();
JsonArray languages = new JsonArray();

ArrayList<Pair<String, String>> allKeys = new ArrayList<>();
translators.forEach(t -> allKeys.addAll(t.getTranslations()));

TranslationHelper.LANGUAGES.forEach((code) -> {
TranslationAccess access = ServerTranslations.INSTANCE.getLanguage(code).serverTranslations();
try (FileWriter writer = new FileWriter(textsDir.resolve(code + ".lang").toFile())) {
for (Pair<String, String> keyPair : allKeys) {
writer.write(keyPair.getLeft() + "=" + access.get(keyPair.getRight()) + "\n");
writer.write(keyPair.getLeft() + "=" + Text.translatable(keyPair.getRight()).getString() + "\n");
}
} catch (IOException e) {
bedframe.getLogger().error("Couldn't write language file");
BedframeConstants.LOGGER.error("Couldn't write language file");
}

languages.add(code);
});
writeJsonToFile(languages, textsDir.resolve("languages.json").toFile());*/
writeJsonToFile(languages, textsDir.resolve("languages.json").toFile());

Optional<String> icon = METADATA.getIconPath(512);
Files.copy(ResourceHelper.getResource(icon.orElseThrow()), packPath.resolve("pack_icon.png"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public void registerHooks() {
}

event.register(ResourcePack.create(PackCodec.path(resourcePack)));
BedframeConstants.LOGGER.info("Registered resource pack");
} catch (IOException e) {
BedframeConstants.LOGGER.error("Couldn't generate resource pack", e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/lol/sylvie/bedframe/geyser/Translator.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected void writeOrThrow(FileWriter writer, String content) {
} catch (IOException e) { throw new RuntimeException(e); }
}

protected static void writeJsonToFile(JsonObject object, File file) {
protected static void writeJsonToFile(Object object, File file) {
try (FileWriter writer = new FileWriter(file)) {
GSON.toJson(object, writer);
} catch (IOException e) { throw new RuntimeException(e); }
Expand Down
Loading