diff --git a/build.gradle.kts b/build.gradle.kts index cbcb7480..24614435 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -28,6 +28,18 @@ repositories { url = uri("https://maven.caffeinemc.net/releases") } + exclusiveContent { + forRepository { + maven { + name = "Cassian's Maven" + url = uri("https://maven.cassian.cc") + } + } + filter { + includeGroupAndSubgroups("cc.cassian") + } + } + mavenLocal() } @@ -52,6 +64,9 @@ dependencies { /*compileOnly(libs.emi) localRuntime(libs.emi)*/ + compileOnly(libs.rrv) + localRuntime(libs.rrv) + compileOnly(libs.modmenu) localRuntime(libs.modmenu) diff --git a/libs.versions.toml b/libs.versions.toml index 8b6c7371..623f3f2b 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -12,6 +12,7 @@ asm = "v2.3" placeholder = "3.0.0-beta.2+26.1" #polydex = "1.8.1+1.21.11" # emi = "1.1.19+1.21.1" +rrv = "8.1.1+26.1.2" modmenu = "18.0.0-alpha.6" sodium = "0.8.9+mc26.1.1" @@ -30,5 +31,6 @@ placeholder = { group = "eu.pb4", name = "placeholder-api", version.ref = "place kaleidoConfig = { group = "folk.sisby", name = "kaleido-config", version.ref = "kaleidoConfig" } # emi = { group = "dev.emi", name = "emi-fabric", version.ref = "emi" } +rrv = { group = "cc.cassian.rrv", name = "reliable-recipe-viewer-fabric", version.ref = "rrv" } modmenu = { group = "com.terraformersmc", name = "modmenu", version.ref = "modmenu" } sodium = { group = "net.caffeinemc", name = "sodium-fabric", version.ref = "sodium" } diff --git a/src/main/java/dev/hephaestus/glowcase/block/entity/RecipeBlockEntity.java b/src/main/java/dev/hephaestus/glowcase/block/entity/RecipeBlockEntity.java index c64ebe1c..7016328e 100644 --- a/src/main/java/dev/hephaestus/glowcase/block/entity/RecipeBlockEntity.java +++ b/src/main/java/dev/hephaestus/glowcase/block/entity/RecipeBlockEntity.java @@ -1,6 +1,8 @@ package dev.hephaestus.glowcase.block.entity; import dev.hephaestus.glowcase.Glowcase; +import dev.hephaestus.glowcase.client.GlowcaseClient; +import dev.hephaestus.glowcase.client.util.RRVClientUtils; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.core.BlockPos; @@ -25,9 +27,9 @@ public RecipeBlockEntity(BlockPos pos, BlockState state) { @Environment(EnvType.CLIENT) public void openRecipe() { Identifier rid = Identifier.tryParse(recipe); - /*if (GlowcaseClient.EMI_LOADED) { - EmiClientUtils.displayRecipe(rid); - }*/ + if (GlowcaseClient.RRV_LOADED) { + RRVClientUtils.displayRecipe(rid); + } } public void setRecipe(String newRecipe) { diff --git a/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClient.java b/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClient.java index b6674b48..d8b46846 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClient.java +++ b/src/main/java/dev/hephaestus/glowcase/client/GlowcaseClient.java @@ -28,7 +28,7 @@ import net.minecraft.world.item.ItemStack; public class GlowcaseClient implements ClientModInitializer { - public static final Boolean EMI_LOADED = FabricLoader.getInstance().isModLoaded("emi"); + public static final Boolean RRV_LOADED = FabricLoader.getInstance().isModLoaded("rrv"); public static final Identifier PROVIDER_CROSSHAIR_TEXTURE = Glowcase.id("hud/provider_crosshair"); public static final ScreenImageCache screenImageCache = new ScreenImageCache(); diff --git a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/RecipeBlockEditScreen.java b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/RecipeBlockEditScreen.java index 5a384986..576e11a6 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/RecipeBlockEditScreen.java +++ b/src/main/java/dev/hephaestus/glowcase/client/gui/screen/ingame/RecipeBlockEditScreen.java @@ -6,10 +6,10 @@ import dev.hephaestus.glowcase.client.GlowcaseClient; import dev.hephaestus.glowcase.client.gui.widget.ingame.GlowcaseEditBox; import dev.hephaestus.glowcase.client.gui.widget.ingame.SuggestionListWidget; -import dev.hephaestus.glowcase.client.util.EmiClientUtils; +import dev.hephaestus.glowcase.client.util.RRVClientUtils; import dev.hephaestus.glowcase.packet.C2SEditRecipeBlock; -import dev.hephaestus.glowcase.util.EmiUtils; -import dev.hephaestus.glowcase.util.RequiresEmiLoaded; +import dev.hephaestus.glowcase.util.RRVUtils; +import dev.hephaestus.glowcase.util.RequiresRRVLoaded; import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.EditBox; @@ -35,7 +35,7 @@ public class RecipeBlockEditScreen extends GlowcaseScreen { // Can't use GlowcaseWidgetHolder as that can crash if EMI is not present @NotNull - private final AtomicReference glowcaseWidgetHolder = new AtomicReference<>(null); + private final AtomicReference glowcaseWidgetHolder = new AtomicReference<>(null); private Button zOffsetToggle; private int fontHeight = -1; @@ -54,7 +54,7 @@ public void init() { if (fontHeight == -1) { fontHeight = this.minecraft.font.lineHeight; - baseY = height / 2 - ((2 * fontHeight + 95) / 2) + fontHeight - (GlowcaseClient.EMI_LOADED ? 46 : 0); + baseY = height / 2 - ((2 * fontHeight + 95) / 2) + fontHeight - (GlowcaseClient.RRV_LOADED ? 46 : 0); } @@ -97,10 +97,10 @@ public void init() { this.recipeBlockEntity.recipe = this.recipeWidget.getValue(); } - if (GlowcaseClient.EMI_LOADED) { - suggestionWidget.updateSuggestions(EmiUtils.RECIPE_LIST.get(), text, false, this); + if (GlowcaseClient.RRV_LOADED) { + suggestionWidget.updateSuggestions(RRVUtils.RECIPE_LIST.get(), text, false, this); - EmiClientUtils.updateWidgetHolder(recipeWidget.getValue(), glowcaseWidgetHolder); + RRVClientUtils.updateWidgetHolder(recipeWidget.getValue(), glowcaseWidgetHolder); } }); @@ -109,8 +109,8 @@ public void init() { this.addRenderableWidget(this.rotationYWidget); this.addRenderableWidget(this.zOffsetToggle); - if (GlowcaseClient.EMI_LOADED && glowcaseWidgetHolder.get() == null) { - EmiClientUtils.updateWidgetHolder(recipeWidget.getValue(), glowcaseWidgetHolder); + if (GlowcaseClient.RRV_LOADED && glowcaseWidgetHolder.get() == null) { + RRVClientUtils.updateWidgetHolder(recipeWidget.getValue(), glowcaseWidgetHolder); } } @@ -149,20 +149,20 @@ public void extractRenderState(GuiGraphicsExtractor graphics, int mouseX, int mo // render the list over everything suggestionWidget.extractRenderState(graphics, mouseX, mouseY, delta); - if (GlowcaseClient.EMI_LOADED && glowcaseWidgetHolder.get() != null) { + if (GlowcaseClient.RRV_LOADED && glowcaseWidgetHolder.get() != null) { int baseYForRecipe = (baseY + fontHeight + 95); int spaceForRecipe = height - baseYForRecipe; - RequiresEmiLoaded widgetHolder = glowcaseWidgetHolder.get(); + RequiresRRVLoaded widgetHolder = glowcaseWidgetHolder.get(); - int holderWidth = EmiClientUtils.getHolderWidth(widgetHolder); - int holderHeight = EmiClientUtils.getHolderHeight(widgetHolder); + int holderWidth = RRVClientUtils.getHolderWidth(widgetHolder); + int holderHeight = RRVClientUtils.getHolderHeight(widgetHolder); Matrix3x2fStack matrixStack = graphics.pose(); matrixStack.pushMatrix(); matrixStack.translate(width / 2f - holderWidth / 2f, baseYForRecipe + spaceForRecipe / 2f - holderHeight / 2f); - EmiClientUtils.renderEmiRecipe(widgetHolder, graphics, delta); + RRVClientUtils.renderEmiRecipe(widgetHolder, graphics, delta); matrixStack.popMatrix(); } diff --git a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/RecipeBlockEntityRenderer.java b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/RecipeBlockEntityRenderer.java index 42336dea..c417b8e5 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/RecipeBlockEntityRenderer.java +++ b/src/main/java/dev/hephaestus/glowcase/client/render/block/entity/RecipeBlockEntityRenderer.java @@ -39,9 +39,9 @@ public void extractRenderState(RecipeBlockEntity blockEntity, RecipeRenderState @Override public void submit(RecipeRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) { - if (BlockEntityRenderUtil.shouldRenderPlaceholder(state.blockPos)) { +// if (BlockEntityRenderUtil.shouldRenderPlaceholder(state.blockPos)) { BlockEntityRenderUtil.renderPlaceholderWithBlockRotation(state, state.rotation16, ITEM_TEXTURE, 1F, poseStack, submitNodeCollector, state.zOffset == TextBlockEntity.ZOffset.CENTER ? 0.01F : state.zOffset == TextBlockEntity.ZOffset.FRONT ? 0.4F : -0.4F); - } +// } } // FIXME 26.1 // public void render(RecipeBlockEntity entity, float f, PoseStack matrices, MultiBufferSource vertexConsumers, int light, int overlay, Vec3 cameraPos) { diff --git a/src/main/java/dev/hephaestus/glowcase/client/util/GlowcaseWidgetHolder.java b/src/main/java/dev/hephaestus/glowcase/client/util/GlowcaseWidgetHolder.java index 4f594a0f..7952f023 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/util/GlowcaseWidgetHolder.java +++ b/src/main/java/dev/hephaestus/glowcase/client/util/GlowcaseWidgetHolder.java @@ -1,13 +1,10 @@ package dev.hephaestus.glowcase.client.util; -import com.google.common.collect.Lists; //import dev.emi.emi.api.widget.Widget; //import dev.emi.emi.api.widget.WidgetHolder; -import dev.hephaestus.glowcase.util.RequiresEmiLoaded; +import dev.hephaestus.glowcase.util.RequiresRRVLoaded; -import java.util.List; - -public class GlowcaseWidgetHolder implements /*WidgetHolder,*/ RequiresEmiLoaded { +public class GlowcaseWidgetHolder implements /*WidgetHolder,*/ RequiresRRVLoaded { /*private final int width, height; private final List widgets = Lists.newArrayList(); diff --git a/src/main/java/dev/hephaestus/glowcase/client/util/EmiClientUtils.java b/src/main/java/dev/hephaestus/glowcase/client/util/RRVClientUtils.java similarity index 77% rename from src/main/java/dev/hephaestus/glowcase/client/util/EmiClientUtils.java rename to src/main/java/dev/hephaestus/glowcase/client/util/RRVClientUtils.java index d1fdac57..58f5b665 100644 --- a/src/main/java/dev/hephaestus/glowcase/client/util/EmiClientUtils.java +++ b/src/main/java/dev/hephaestus/glowcase/client/util/RRVClientUtils.java @@ -4,25 +4,22 @@ //import dev.emi.emi.api.recipe.EmiRecipe; //import dev.emi.emi.api.widget.Widget; //import dev.emi.emi.widget.RecipeBackground; -import dev.hephaestus.glowcase.util.RequiresEmiLoaded; +import cc.cassian.rrv.common.overlay.itemlist.view.ItemViewOverlay; +import dev.hephaestus.glowcase.util.RequiresRRVLoaded; import java.util.concurrent.atomic.AtomicReference; import net.minecraft.client.gui.GuiGraphicsExtractor; import net.minecraft.resources.Identifier; -public class EmiClientUtils { +public class RRVClientUtils { public static void displayRecipe(Identifier recipeId) { - /*if (recipeId == null) { + if (recipeId == null) { return; } - EmiRecipe recipe = EmiApi.getRecipeManager().getRecipe(recipeId); - if (recipe == null) { - return; - } - EmiApi.displayRecipe(recipe);*/ + ItemViewOverlay.INSTANCE.openRecipeView(recipeId, false); } - public static void updateWidgetHolder(String recipeId, AtomicReference widgetHolder) { + public static void updateWidgetHolder(String recipeId, AtomicReference widgetHolder) { /*EmiRecipe recipe = EmiUtils.getRecipe(recipeId); GlowcaseWidgetHolder glowcaseWidgetHolder = (GlowcaseWidgetHolder) widgetHolder.get(); @@ -46,7 +43,7 @@ public static void updateWidgetHolder(String recipeId, AtomicReference> RECIPE_LIST = new NotSoConstant<>(() -> List.of()/*EmiApi.getRecipeManager().getRecipes().stream().map(EmiRecipe::getId).filter(Objects::nonNull).toList(), list -> !list.isEmpty()*/); - /*public static EmiRecipe getRecipe(String recipeString) { + public static ReliableClientRecipe getRecipe(String recipeString) { Identifier recipeId = Identifier.tryParse(recipeString); if (recipeId == null) { return null; } - return EmiApi.getRecipeManager().getRecipe(recipeId); + return ClientRecipeCache.INSTANCE.getRecipe(recipeId); } public static void registerDevCommands() { + /* CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { dispatcher.register( CommandManager.literal("randomizerecipes").then( @@ -29,14 +30,14 @@ public static void registerDevCommands() { CommandManager.argument("to", BlockPosArgumentType.blockPos()).executes(context -> { ServerCommandSource source = context.getSource(); - List list = EmiUtils.RECIPE_LIST.get(); - ServerWorld world = source.getWorld(); + List list = ReliableRecipeViewerClient.LOCAL_RECIPES.values().stream().map(RecipeHolder::id).map(ResourceKey::identifier).toList(); + ServerLevel world = source.getWorld(); BlockBox range = BlockBox.create(BlockPosArgumentType.getLoadedBlockPos(context, "from"), BlockPosArgumentType.getLoadedBlockPos(context, "to")); for (BlockPos blockPos : BlockPos.iterate(range.getMinX(), range.getMinY(), range.getMinZ(), range.getMaxX(), range.getMaxY(), range.getMaxZ())) { BlockEntity blockEntity = world.getBlockEntity(blockPos); if (blockEntity instanceof RecipeBlockEntity recipeBlockEntity) { - recipeBlockEntity.setRecipe(list.get(world.random.nextInt(list.size())).toString()); + recipeBlockEntity.setRecipe(list.get(world.getRandom().nextInt(list.size())).toString()); } } @@ -46,5 +47,6 @@ public static void registerDevCommands() { ) ); }); - }*/ + */ + } } diff --git a/src/main/java/dev/hephaestus/glowcase/util/RequiresEmiLoaded.java b/src/main/java/dev/hephaestus/glowcase/util/RequiresRRVLoaded.java similarity index 86% rename from src/main/java/dev/hephaestus/glowcase/util/RequiresEmiLoaded.java rename to src/main/java/dev/hephaestus/glowcase/util/RequiresRRVLoaded.java index 45b68af1..b4c03ede 100644 --- a/src/main/java/dev/hephaestus/glowcase/util/RequiresEmiLoaded.java +++ b/src/main/java/dev/hephaestus/glowcase/util/RequiresRRVLoaded.java @@ -4,4 +4,4 @@ * Just a dummy class to make it harder to accidentally ClassCastException when passing to methods that expect a * specific class that can't be explicitly specified due to it being optionally loaded. */ -public interface RequiresEmiLoaded { } +public interface RequiresRRVLoaded { } diff --git a/src/main/resources/assets/glowcase/lang/en_us.json b/src/main/resources/assets/glowcase/lang/en_us.json index 02ed87cf..0aca5f10 100644 --- a/src/main/resources/assets/glowcase/lang/en_us.json +++ b/src/main/resources/assets/glowcase/lang/en_us.json @@ -49,7 +49,7 @@ "block.glowcase.popup_block.tooltip.0": "Displays formatted text when interacted", "block.glowcase.popup_block.tooltip.1": "Supports Placeholder QuickText", "block.glowcase.screen_block.tooltip.0": "Displays remotely configurable images", - "block.glowcase.recipe_block.tooltip.0": "Displays a recipe from EMI", + "block.glowcase.recipe_block.tooltip.0": "Displays a recipe from RRV", "block.glowcase.sprite_block.tooltip.0": "Displays a sprite", "block.glowcase.sprite_block.tooltip.1": "Can be extended with resource packs", "block.glowcase.outline_block.tooltip.0": "Displays an outline", diff --git a/src/main/resources/assets/glowcase/textures/item/recipe_block.png b/src/main/resources/assets/glowcase/textures/item/recipe_block.png index 98c8f4e6..2fac4f88 100644 Binary files a/src/main/resources/assets/glowcase/textures/item/recipe_block.png and b/src/main/resources/assets/glowcase/textures/item/recipe_block.png differ diff --git a/src/main/resources/assets/glowcase/textures/item/recipe_block_awakened.png b/src/main/resources/assets/glowcase/textures/item/recipe_block_awakened.png index 6bf6838c..0b229b5e 100644 Binary files a/src/main/resources/assets/glowcase/textures/item/recipe_block_awakened.png and b/src/main/resources/assets/glowcase/textures/item/recipe_block_awakened.png differ