From c933e7197ac590aa5d45ed6c7ebc60bac92ff99b Mon Sep 17 00:00:00 2001 From: nanobass Date: Tue, 2 Jul 2024 18:46:12 +0200 Subject: [PATCH] fixes for 0.1.38 --- gradle.properties | 4 ++-- .../java/dev/crmodders/flux/engine/BlockErrorScreen.java | 2 +- .../crmodders/flux/engine/stages/LoadingCosmicReach.java | 8 ++++++++ .../dev/crmodders/flux/generators/BlockGenerator.java | 1 + .../crmodders/flux/mixins/assets/BlockModelJsonMixin.java | 2 ++ .../dev/crmodders/flux/mixins/logging/BlockGameMixin.java | 2 +- .../crmodders/flux/mixins/registry/BlockRegisterer.java | 8 ++++++-- .../flux/mixins/registry/RegistryRegisterer.java | 7 ++++++- 8 files changed, 27 insertions(+), 7 deletions(-) diff --git a/gradle.properties b/gradle.properties index 33aa188..6d1f469 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,12 +1,12 @@ # Mod Properties id = fluxapi -version = 0.7.3 +version = 0.7.4 flux_desc = The central modding API for Cosmic Reach Fabric/Quilt group = dev.crmodders # Game & Loader -cosmic_reach_version = 0.1.37 +cosmic_reach_version = 0.1.38 cosmic_quilt_version = 2.1.1 fabric_loader_version = 0.15.7 diff --git a/src/main/java/dev/crmodders/flux/engine/BlockErrorScreen.java b/src/main/java/dev/crmodders/flux/engine/BlockErrorScreen.java index 58eff76..c1c95f7 100644 --- a/src/main/java/dev/crmodders/flux/engine/BlockErrorScreen.java +++ b/src/main/java/dev/crmodders/flux/engine/BlockErrorScreen.java @@ -72,7 +72,7 @@ public void create() { errorText .append("Error while loading Block (Class: ").append(className) .append(", File: \"").append(fileName) - .append(", Name: \"").append(blockName) + .append("\", Name: \"").append(blockName) .append("\", Id: \"").append(blockId) .append("\")\n") .append("\nError Stacktrace:\n"); diff --git a/src/main/java/dev/crmodders/flux/engine/stages/LoadingCosmicReach.java b/src/main/java/dev/crmodders/flux/engine/stages/LoadingCosmicReach.java index a065007..a99dba2 100644 --- a/src/main/java/dev/crmodders/flux/engine/stages/LoadingCosmicReach.java +++ b/src/main/java/dev/crmodders/flux/engine/stages/LoadingCosmicReach.java @@ -17,7 +17,9 @@ import dev.crmodders.flux.registries.AccessableRegistry; import dev.crmodders.flux.tags.Identifier; import dev.crmodders.flux.tags.ResourceLocation; +import finalforeach.cosmicreach.blockentities.BlockEntityCreator; import finalforeach.cosmicreach.blockevents.BlockEvents; +import finalforeach.cosmicreach.items.loot.Loot; import org.greenrobot.eventbus.Subscribe; import java.util.ArrayList; @@ -53,6 +55,10 @@ public void onEvent(OnRegisterBlockEvent event) { @Override public void doStage() { super.doStage(); + + BlockEvents.initBlockEvents(); + BlockEntityCreator.registerBlockEntityCreators(); + BlockEvents.registerBlockEventAction(OnPlaceTrigger.class); BlockEvents.registerBlockEventAction(OnBreakTrigger.class); BlockEvents.registerBlockEventAction(OnInteractTrigger.class); @@ -100,6 +106,8 @@ public List getGlTasks() { tasks.add( blockFinalizers.get(blockStateId) ); } + tasks.add(Loot::loadLoot); + return tasks; } } diff --git a/src/main/java/dev/crmodders/flux/generators/BlockGenerator.java b/src/main/java/dev/crmodders/flux/generators/BlockGenerator.java index 1059937..3c1180c 100644 --- a/src/main/java/dev/crmodders/flux/generators/BlockGenerator.java +++ b/src/main/java/dev/crmodders/flux/generators/BlockGenerator.java @@ -45,6 +45,7 @@ public static class State { public boolean isFluid = false; public String swapGroupId; + public String dropId; } diff --git a/src/main/java/dev/crmodders/flux/mixins/assets/BlockModelJsonMixin.java b/src/main/java/dev/crmodders/flux/mixins/assets/BlockModelJsonMixin.java index dbe850c..a0f5380 100644 --- a/src/main/java/dev/crmodders/flux/mixins/assets/BlockModelJsonMixin.java +++ b/src/main/java/dev/crmodders/flux/mixins/assets/BlockModelJsonMixin.java @@ -7,12 +7,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(BlockModelJson.class) public class BlockModelJsonMixin { + @Unique private static final Logger LOGGER = LoggerFactory.getLogger("BlockModelJson"); @Redirect(method = "getInstance", at = @At(value = "INVOKE", target = "Lfinalforeach/cosmicreach/GameAssetLoader;loadAsset(Ljava/lang/String;)Lcom/badlogic/gdx/files/FileHandle;")) diff --git a/src/main/java/dev/crmodders/flux/mixins/logging/BlockGameMixin.java b/src/main/java/dev/crmodders/flux/mixins/logging/BlockGameMixin.java index ea4f618..a41f99e 100644 --- a/src/main/java/dev/crmodders/flux/mixins/logging/BlockGameMixin.java +++ b/src/main/java/dev/crmodders/flux/mixins/logging/BlockGameMixin.java @@ -28,7 +28,7 @@ private void print1(PrintStream instance, String x) { logger.info("\u001B[36m{}\u001B[37m", x); } - @Redirect(method = "create", at = @At(value = "INVOKE", target = "Ljava/io/PrintStream;println(Ljava/lang/String;)V"), require = 0) + @Redirect(method = "printGLInfo", at = @At(value = "INVOKE", target = "Ljava/io/PrintStream;println(Ljava/lang/String;)V"), require = 0) private void print2(PrintStream instance, String x) { List lines = x.lines().toList(); for(String line : lines) { diff --git a/src/main/java/dev/crmodders/flux/mixins/registry/BlockRegisterer.java b/src/main/java/dev/crmodders/flux/mixins/registry/BlockRegisterer.java index 898286a..4e521b7 100644 --- a/src/main/java/dev/crmodders/flux/mixins/registry/BlockRegisterer.java +++ b/src/main/java/dev/crmodders/flux/mixins/registry/BlockRegisterer.java @@ -17,6 +17,10 @@ public class BlockRegisterer { @Shadow @Final public static Block AIR; + @Shadow @Final public static Block WATER; + + @Shadow @Final public static Block DIRT; + /** * @author nanobass * @reason is replaced by flux, allows for much more advanced features @@ -25,8 +29,8 @@ public class BlockRegisterer { @Overwrite public static Block getInstance(String blockName) { Block block = blocksByName.get(blockName); - if(block == null && AIR != null) { - LOGGER.warn("null-block returned by Block.getInstance, please report", new Exception()); + if(block == null && AIR != null && WATER != null && DIRT != null) { + LOGGER.warn("null-block returned by Block.getInstance, please report \"{}\"", blockName, new Exception()); } return block; } diff --git a/src/main/java/dev/crmodders/flux/mixins/registry/RegistryRegisterer.java b/src/main/java/dev/crmodders/flux/mixins/registry/RegistryRegisterer.java index d882450..fcb7adf 100644 --- a/src/main/java/dev/crmodders/flux/mixins/registry/RegistryRegisterer.java +++ b/src/main/java/dev/crmodders/flux/mixins/registry/RegistryRegisterer.java @@ -4,6 +4,7 @@ import finalforeach.cosmicreach.BlockGame; import finalforeach.cosmicreach.gamestates.GameState; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -11,9 +12,13 @@ @Mixin(BlockGame.class) public class RegistryRegisterer { - @Inject(method = "create", at = @At("TAIL")) + @Shadow public static boolean gameStarted; + + @Inject(method = "create", at = @At(value = "INVOKE", target = "Lfinalforeach/cosmicreach/ClientSingletons;create()V", shift = At.Shift.AFTER), cancellable = true) private void create(CallbackInfo ci) { GameState.switchToGameState(new GameLoader()); + ci.cancel(); + gameStarted = true; } }