diff --git a/src/main/java/astrinox/stellum/Stellum.java b/src/main/java/astrinox/stellum/Stellum.java index 7e3c75a..2207d6f 100644 --- a/src/main/java/astrinox/stellum/Stellum.java +++ b/src/main/java/astrinox/stellum/Stellum.java @@ -2,14 +2,11 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; -import net.fabricmc.fabric.api.resource.ResourceManagerHelper; -import net.minecraft.resource.ResourceType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import astrinox.stellum.command.StellumDebugCommand; -import astrinox.stellum.resource.StellumResourceReloadListener; public class Stellum implements ModInitializer { public static final String MOD_ID = "stellum"; @@ -20,6 +17,5 @@ public void onInitialize() { LOGGER.info("✨"); CommandRegistrationCallback.EVENT.register(StellumDebugCommand::register); - ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new StellumResourceReloadListener()); } } \ No newline at end of file diff --git a/src/main/java/astrinox/stellum/command/StellumDebugCommand.java b/src/main/java/astrinox/stellum/command/StellumDebugCommand.java index 290b855..af64fc7 100644 --- a/src/main/java/astrinox/stellum/command/StellumDebugCommand.java +++ b/src/main/java/astrinox/stellum/command/StellumDebugCommand.java @@ -8,7 +8,9 @@ import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.SimpleCommandExceptionType; +import com.mojang.serialization.JsonOps; +import astrinox.stellum.Stellum; import astrinox.stellum.handlers.explosion.BurnMap; import astrinox.stellum.handlers.explosion.BurnZone; import astrinox.stellum.handlers.explosion.Burnable; @@ -16,6 +18,7 @@ import astrinox.stellum.handlers.explosion.ExplosionHandler; import astrinox.stellum.handlers.screenshake.Screenshake; import astrinox.stellum.handlers.screenshake.ScreenshakeHandler; +import astrinox.stellum.registry.BurnMapRegistry; import astrinox.stellum.util.PerlinNoiseHelper; import net.minecraft.block.Blocks; import net.minecraft.command.CommandRegistryAccess; @@ -211,10 +214,9 @@ public static int executeBurnzone(CommandContext context) t .getDefaultState()))) .addBurnables( new BurnableIO( - new Burnable().addTag( - BlockTags.BASE_STONE_OVERWORLD), - new Burnable().addBlock(Blocks.COBBLESTONE - .getDefaultState()) + new Burnable().addTag(BlockTags.BASE_STONE_OVERWORLD), + new Burnable().addBlock( + Blocks.COBBLESTONE.getDefaultState()) .addBlock(Blocks.COBBLED_DEEPSLATE .getDefaultState()) .addBlock(Blocks.MAGMA_BLOCK @@ -227,9 +229,8 @@ public static int executeBurnzone(CommandContext context) t .addBurnables( new BurnableIO( new Burnable().addTag(BlockTags.DIRT), - new Burnable().addBlock( - Blocks.DEAD_FIRE_CORAL_BLOCK - .getDefaultState()) + new Burnable().addBlock(Blocks.DEAD_FIRE_CORAL_BLOCK + .getDefaultState()) .addBlock(Blocks.COARSE_DIRT .getDefaultState()) .addBlock(Blocks.MAGMA_BLOCK @@ -263,7 +264,7 @@ public static int executeBurnzone(CommandContext context) t burnzone.trigger(world); } catch (Exception e) { source.sendError(Text.literal( - "An error occurred while executing the burnzone command: " + e.getMessage())); + "An error occurred while executing the burnzone command: " + e.toString())); } return 1; diff --git a/src/main/java/astrinox/stellum/registry/BurnMapRegistry.java b/src/main/java/astrinox/stellum/registry/BurnMapRegistry.java index 42d3bf1..f9a7236 100644 --- a/src/main/java/astrinox/stellum/registry/BurnMapRegistry.java +++ b/src/main/java/astrinox/stellum/registry/BurnMapRegistry.java @@ -3,6 +3,7 @@ import java.util.HashMap; import java.util.Map; +import astrinox.stellum.Stellum; import astrinox.stellum.handlers.explosion.BurnMap; public class BurnMapRegistry { @@ -10,6 +11,7 @@ public class BurnMapRegistry { public static void registerBurnMap(String id, BurnMap burnMap) { burnMapRegistry.put(id, burnMap); + Stellum.LOGGER.info("Registered burnmap: " + id); } public static BurnMap getBurnMap(String id) { diff --git a/src/main/java/astrinox/stellum/resource/StellumResourceReloadListener.java b/src/main/java/astrinox/stellum/resource/StellumResourceReloadListener.java deleted file mode 100644 index 9a3f36f..0000000 --- a/src/main/java/astrinox/stellum/resource/StellumResourceReloadListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package astrinox.stellum.resource; - -import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; - -import java.io.InputStream; - -import com.google.gson.Gson; -import com.google.gson.JsonObject; - -import astrinox.stellum.Stellum; - -public class StellumResourceReloadListener implements SimpleSynchronousResourceReloadListener { - - @Override - public Identifier getFabricId() { - return Identifier.of(Stellum.MOD_ID, "stellum_resources"); - } - - @Override - public void reload(ResourceManager manager) { - Stellum.LOGGER.info("Reloading resources"); - for (Identifier id : manager.findResources("burnmap", path -> path.getPath().endsWith(".json")).keySet()) { - try (InputStream stream = manager.getResourceOrThrow(id).getInputStream()) { - Stellum.LOGGER.info("Loaded burnmap: " + id.toString()); - Gson gson = new Gson(); - JsonObject jsonObject = gson.fromJson(new String(stream.readAllBytes()), JsonObject.class); - } catch (Exception e) { - Stellum.LOGGER.error("Error occurred while loading resource json" + id.toString(), e); - } - } - } - -} diff --git a/src/main/resources/data/stellum/burnmap/test.json b/src/main/resources/data/stellum/burnmap/test.json deleted file mode 100644 index 62b9a4d..0000000 --- a/src/main/resources/data/stellum/burnmap/test.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "burnmap": { "test": "yippe it laoded" } -}