diff --git a/fabric-client/build.gradle b/fabric-client/build.gradle index 97ff0dd..70612fc 100644 --- a/fabric-client/build.gradle +++ b/fabric-client/build.gradle @@ -27,7 +27,7 @@ dependencies { modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") // YACL (for configuring the mod in-game) - modImplementation(include("dev.isxander:yet-another-config-lib:${project.yacl_version}")) + modImplementation(include("dev.isxander.yacl:yet-another-config-lib-fabric:${project.yacl_version}")) } diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/ConfigScreen.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/ConfigScreen.java index f685e79..22ad5be 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/ConfigScreen.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/ConfigScreen.java @@ -1,14 +1,10 @@ package org.samo_lego.clientstorage.fabric_client.config; -import dev.isxander.yacl.api.ButtonOption; -import dev.isxander.yacl.api.ConfigCategory; -import dev.isxander.yacl.api.Option; -import dev.isxander.yacl.api.YetAnotherConfigLib; -import dev.isxander.yacl.gui.controllers.ActionController; -import dev.isxander.yacl.gui.controllers.TickBoxController; -import dev.isxander.yacl.gui.controllers.cycling.EnumController; -import dev.isxander.yacl.gui.controllers.slider.DoubleSliderController; -import dev.isxander.yacl.gui.controllers.slider.IntegerSliderController; +import dev.isxander.yacl3.api.*; +import dev.isxander.yacl3.impl.controller.DoubleSliderControllerBuilderImpl; +import dev.isxander.yacl3.impl.controller.EnumControllerBuilderImpl; +import dev.isxander.yacl3.impl.controller.IntegerSliderControllerBuilderImpl; +import dev.isxander.yacl3.impl.controller.TickBoxControllerBuilderImpl; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; import net.minecraft.server.network.ServerGamePacketListenerImpl; @@ -57,111 +53,111 @@ public static Screen createConfigScreen(@Nullable Screen parent) { var storagePresetsCategory = ConfigCategory.createBuilder() .name(Component.translatable("category.clientstorage.storage_presets")); - mainCategory.option(Option.createBuilder(boolean.class) + mainCategory.option(Option.createBuilder() .name(Component.translatable("key.clientstorage.toggle_mod")) .binding(true, () -> config.enabled, value -> config.enabled = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); - mainCategory.option(Option.createBuilder(boolean.class) + mainCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.enable_caching")) - .tooltip(Component.translatable("tooltip.clientstorage.enable_caching")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.enable_caching"))) .binding(true, () -> config.enableCaching, value -> config.enableCaching = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); - mainCategory.option(Option.createBuilder(boolean.class) + mainCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.focus_search")) - .tooltip(Component.translatable("tooltip.clientstorage.focus_search")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.focus_search"))) .binding(false, () -> config.focusSearchBar, value -> config.focusSearchBar = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); - mainCategory.option(Option.createBuilder(double.class) + mainCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.max_distance")) - .tooltip(Component.translatable("tooltip.clientstorage.max_distance")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.max_distance"))) .binding(Math.sqrt(ServerGamePacketListenerImpl.MAX_INTERACTION_DISTANCE), () -> config.maxDist, value -> config.maxDist = value) - .controller(opt -> new DoubleSliderController(opt, 1, 6, 0.5)) + .controller(opt -> new DoubleSliderControllerBuilderImpl(opt).range(1.0, 6.0).step(0.5)) .build()); - mainCategory.option(Option.createBuilder(boolean.class) + mainCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.allow_item_transfers")) - .tooltip(Component.translatable("tooltip.clientstorage.allow_item_transfers")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.allow_item_transfers"))) .binding(true, () -> config.enableItemTransfers, value -> config.enableItemTransfers = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); - mainCategory.option(Option.createBuilder(boolean.class) + mainCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.enable_block_search")) - .tooltip(Component.translatable("tooltip.clientstorage.enable_block_search")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.enable_block_search"))) .binding(true, () -> config.enableBlocks, value -> config.enableBlocks = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); - mainCategory.option(Option.createBuilder(boolean.class) + mainCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.enable_entity_search")) - .tooltip(Component.translatable("tooltip.clientstorage.enable_entity_search")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.enable_entity_search"))) .binding(true, () -> config.enableEntities, value -> config.enableEntities = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); // Display - displayCategory.option(Option.createBuilder(ItemBehaviour.ItemDisplayType.class) + displayCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.merge_same_stacks")) - .tooltip(Component.translatable("tooltip.clientstorage.merge_same_stacks")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.merge_same_stacks"))) .binding(ItemBehaviour.ItemDisplayType.MERGE_ALL, () -> config.itemDisplayType, value -> config.itemDisplayType = value) - .controller(EnumController::new) + .controller(EnumControllerBuilderImpl::new) .build()); - displayCategory.option(Option.createBuilder(ItemBehaviour.ItemDataTooltip.class) + displayCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.additional_tooltip")) - .tooltip(Component.translatable("tooltip.clientstorage.additional_tooltip")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.additional_tooltip"))) .binding(ItemBehaviour.ItemDataTooltip.ALWAYS_SHOW, () -> config.locationTooltip, value -> config.locationTooltip = value) - .controller(EnumController::new) + .controller(EnumControllerBuilderImpl::new) .build()); displayCategory.option(ButtonOption.createBuilder() .name(Component.translatable("settings.clientstorage.clear_esps")) - .tooltip(Component.translatable("tooltip.clientstorage.clear_esps")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.clear_esps"))) .action((yaclScreen, buttonOption) -> ESPRender.reset()) - .controller(ActionController::new) .build()); // Messages - messageCategory.option(Option.createBuilder(boolean.class) + messageCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.inform_server_type")) - .tooltip(Component.translatable("tooltip.clientstorage.inform_server_type")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.inform_server_type"))) .binding(true, () -> config.informServerType, value -> config.informServerType = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); - messageCategory.option(Option.createBuilder(boolean.class) + messageCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.inform_search")) .binding(true, () -> config.informSearch, value -> config.informSearch = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); - messageCategory.option(Option.createBuilder(boolean.class) + messageCategory.option(Option.createBuilder() .name(Component.translatable("generator.minecraft.debug_all_block_states")) .binding(false, () -> config.debug, value -> config.debug = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); // Server sync - final var serverSyncOption = Option.createBuilder(boolean.class) + final var serverSyncOption = Option.createBuilder() .name(Component.translatable("settings.clientstorage.sync_server_config")) - .tooltip(Component.translatable("tooltip.clientstorage.sync_server_config")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.sync_server_config"))) .binding(true, () -> config.allowSyncServer(), config::setAllowSyncServer) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build(); serverSyncOption.setAvailable(FabricConfig.isNotOnServer()); // Only allow in main menu serverSyncCategory.option(serverSyncOption); @@ -174,11 +170,11 @@ public static Screen createConfigScreen(@Nullable Screen parent) { // Look through blocks boolean allowThroughBlocks = allowSettings || config.allowEditLookThroughBlocks(); String key = allowThroughBlocks ? "tooltip.clientstorage.through_block" : "tooltip.clientstorage.server_setting"; - Option throughBlocks = Option.createBuilder(boolean.class) + Option throughBlocks = Option.createBuilder() .name(Component.translatable("settings.clientstorage.through_block")) - .tooltip(Component.translatable(key)) + .description(OptionDescription.of(Component.translatable(key))) .binding(true, config::lookThroughBlocks, config::setLookThroughBlocks) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build(); throughBlocks.setAvailable(allowThroughBlocks); @@ -186,21 +182,21 @@ public static Screen createConfigScreen(@Nullable Screen parent) { // Custom limiter - final var customDelayOption = Option.createBuilder(int.class) + final var customDelayOption = Option.createBuilder() .name(Component.translatable("settings.clientstorage.custom_delay")) - .tooltip(Component.translatable("tooltip.clientstorage.custom_delay")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.custom_delay"))) .binding(300, PacketLimiter.CUSTOM::getDelay, PacketLimiter.CUSTOM::setDelay) - .controller(opt -> new IntegerSliderController(opt, 0, 600, 1)) + .controller(opt -> new IntegerSliderControllerBuilderImpl(opt).range(0, 600).step(1)) .build(); - final var thresholdOption = Option.createBuilder(int.class) + final var thresholdOption = Option.createBuilder() .name(Component.translatable("settings.clientstorage.packet_threshold")) - .tooltip(Component.translatable("tooltip.clientstorage.packet_threshold")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.packet_threshold"))) .binding(4, PacketLimiter.CUSTOM::getThreshold, PacketLimiter.CUSTOM::setThreshold) - .controller(opt -> new IntegerSliderController(opt, 1, 8, 1)) + .controller(opt -> new IntegerSliderControllerBuilderImpl(opt).range(1, 8).step(1)) .build(); - customLimiterCategory.option(Option.createBuilder(PacketLimiter.class) + customLimiterCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.limiter_type")) .binding(PacketLimiter.getServerLimiter(), () -> FabricConfig.limiter, value -> { FabricConfig.limiter = value; @@ -214,7 +210,7 @@ public static Screen createConfigScreen(@Nullable Screen parent) { thresholdOption.setAvailable(true); } }) - .controller(EnumController::new) + .controller(EnumControllerBuilderImpl::new) .build()); customDelayOption.setAvailable(FabricConfig.limiter == PacketLimiter.CUSTOM); @@ -225,25 +221,23 @@ public static Screen createConfigScreen(@Nullable Screen parent) { // Storage presets - storagePresetsCategory.option(Option.createBuilder(boolean.class) + storagePresetsCategory.option(Option.createBuilder() .name(Component.translatable("settings.clientstorage.enable_presets")) - .tooltip(Component.translatable("tooltip.clientstorage.enable_presets")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.enable_presets"))) .binding(true, () -> config.storageMemory.enabled, value -> config.storageMemory.enabled = value) - .controller(TickBoxController::new) + .controller(TickBoxControllerBuilderImpl::new) .build()); storagePresetsCategory.option(ButtonOption.createBuilder() .name(Component.translatable("settings.clientstorage.delete_preset")) - .tooltip(Component.translatable("tooltip.clientstorage.delete_preset")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.delete_preset"))) .action((yaclScreen, buttonOption) -> config.storageMemory.clearForCurrentWorld()) - .controller(ActionController::new) .build()); storagePresetsCategory.option(ButtonOption.createBuilder() .name(Component.translatable("settings.clientstorage.delete_presets")) - .tooltip(Component.translatable("tooltip.clientstorage.delete_presets")) + .description(OptionDescription.of(Component.translatable("tooltip.clientstorage.delete_presets"))) .action((yaclScreen, buttonOption) -> config.storageMemory.clearAll()) - .controller(ActionController::new) .build()); diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/storage_memory/StorageMemoryConfig.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/storage_memory/StorageMemoryConfig.java index cc04b33..0dc4454 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/storage_memory/StorageMemoryConfig.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/config/storage_memory/StorageMemoryConfig.java @@ -32,7 +32,7 @@ private static String getSaveId() { final Minecraft mc = Minecraft.getInstance(); if (mc.isSingleplayer()) { // get current world name; not optimal, but is something - final String worldName = mc.getSingleplayerServer().getLevel(mc.player.getLevel().dimension()).toString(); + final String worldName = mc.getSingleplayerServer().getLevel(mc.player.level().dimension()).toString(); return worldName.substring("ServerLevel[".length(), worldName.length() - 1); } return mc.getCurrentServer().ip; diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MAbstractContainerScreen.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MAbstractContainerScreen.java index 9db5439..b71279d 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MAbstractContainerScreen.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MAbstractContainerScreen.java @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.Tesselator; import net.minecraft.ChatFormatting; import net.minecraft.client.gui.Font; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.renderer.MultiBufferSource; @@ -40,12 +41,12 @@ protected MAbstractContainerScreen(Component component) { /** * Stores current slot being rendered. * - * @param matrices + * @param guiGraphics * @param slot * @param ci */ @Inject(method = "renderSlot", at = @At("HEAD")) - private void onSlotRender(PoseStack matrices, Slot slot, CallbackInfo ci) { + private void onSlotRender(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) { this.slot = slot; } @@ -73,29 +74,29 @@ private String changeItemCountLabel(String label) { return label; } - @Redirect(method = "renderSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/ItemRenderer;renderGuiItemDecorations(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V")) - private void renderGuiItemDecorationsWithDifferentTextSize(ItemRenderer itemRenderer, PoseStack poseStack, Font fontRenderer, ItemStack stack, int x, int y, @Nullable String countLabel) { + @Redirect(method = "renderSlot", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiGraphics;renderItemDecorations(Lnet/minecraft/client/gui/Font;Lnet/minecraft/world/item/ItemStack;IILjava/lang/String;)V")) + private void renderGuiItemDecorationsWithDifferentTextSize(GuiGraphics graphics, Font fontRenderer, ItemStack stack, int x, int y, @Nullable String countLabel) { if (!stack.isEmpty()) { // Ensure ItemStack isn't empty before decorating if (this.renderWithSmallText) { - itemRenderer.renderGuiItemDecorations(poseStack, fontRenderer, stack, x, y, ""); // Render other Decorations + graphics.renderItemDecorations(fontRenderer, stack, x, y, ""); // Render other Decorations if (stack.getCount() > 1) { // Only render amount text if stack has more than 1 item countLabel = countLabel == null ? String.valueOf(stack.getCount()) : countLabel; // Get count string if countLabel is null - PoseStack textMatrixStack = new PoseStack(); // Create new matrix stack for transforming text size - poseStack.scale(0.5F, 0.5F, 1); // Scale matrix stack to make text smaller + PoseStack textMatrixStack = graphics.pose(); // Create new matrix stack for transforming text size + textMatrixStack.scale(0.5F, 0.5F, 1); // Scale matrix stack to make text smaller // todo - poseStack.translate(0, 0, /*itemRenderer.blitOffset +*/ ItemRenderer.ITEM_COUNT_BLIT_OFFSET); // Offset text z position so that it is in front of item + textMatrixStack.translate(0, 0, /*itemRenderer.blitOffset +*/ ItemRenderer.ITEM_COUNT_BLIT_OFFSET); // Offset text z position so that it is in front of item //fontRenderer.drawShadow(textMatrixStack, countLabel, x * 2 + 31 - fontRenderer.width(countLabel), y * 2 + 23, ChatFormatting.WHITE.getColor()); // Render count label - poseStack.pushPose(); + textMatrixStack.pushPose(); MultiBufferSource.BufferSource bufferSource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); - this.font.drawInBatch(countLabel, (x * 2 + 31 - this.font.width(countLabel)), (y * 2 + 23), ChatFormatting.WHITE.getColor(), true, poseStack.last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880); + this.font.drawInBatch(countLabel, (x * 2 + 31 - this.font.width(countLabel)), (y * 2 + 23), ChatFormatting.WHITE.getColor(), true, textMatrixStack.last().pose(), bufferSource, Font.DisplayMode.NORMAL, 0, 15728880); bufferSource.endBatch(); - poseStack.popPose(); + textMatrixStack.popPose(); } } else { - itemRenderer.renderGuiItemDecorations(poseStack, fontRenderer, stack, x, y, countLabel); // Render Decorations Normally + graphics.renderItemDecorations(fontRenderer, stack, x, y, countLabel); // Render Decorations Normally } } } diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MCraftingScreen.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MCraftingScreen.java index 626ccb3..bdb0681 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MCraftingScreen.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/MCraftingScreen.java @@ -1,10 +1,9 @@ package org.samo_lego.clientstorage.fabric_client.mixin.screen; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.EditBox; import net.minecraft.client.gui.components.ImageButton; import net.minecraft.client.gui.components.Renderable; @@ -55,9 +54,6 @@ public abstract class MCraftingScreen extends AbstractContainerScreen 3; - blit(matrices, topX, topY + (int) ((float) (k - topY - 17) * RemoteInventory.getInstance().scrollOffset()), 232 + (canScroll ? 0 : 12), 0, 12, 15); + graphics.blit(CREATIVE_TABS_LOCATION(), topX, topY + (int) ((float) (k - topY - 17) * RemoteInventory.getInstance().scrollOffset()), 232 + (canScroll ? 0 : 12), 0, 12, 15); } @Inject(method = "", at = @At("TAIL")) diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/gui_armour/MAbstractContainerScreen.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/gui_armour/MAbstractContainerScreen.java index 9722d34..ab3e748 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/gui_armour/MAbstractContainerScreen.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/gui_armour/MAbstractContainerScreen.java @@ -1,7 +1,7 @@ package org.samo_lego.clientstorage.fabric_client.mixin.screen.gui_armour; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.renderer.GameRenderer; @@ -29,36 +29,37 @@ public abstract class MAbstractContainerScreen { protected Slot hoveredSlot; @Shadow - protected abstract void renderSlot(PoseStack poseStack, Slot slot); + protected abstract boolean isHovering(Slot slot, double d, double e); @Shadow - protected abstract boolean isHovering(Slot slot, double d, double e); + protected abstract void renderSlot(GuiGraphics guiGraphics, Slot slot); @Inject(method = "render", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderBg(Lcom/mojang/blaze3d/vertex/PoseStack;FII)V", + target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderBg(Lnet/minecraft/client/gui/GuiGraphics;FII)V", shift = At.Shift.AFTER)) - private void addArmorSlotBg(PoseStack poseStack, int x, int y, float f, CallbackInfo ci) { - if (!config.enabled || self instanceof InventoryScreen) return; + private void addArmorSlotBg(GuiGraphics graphics, int x, int y, float f, CallbackInfo ci) { + if (!config.enabled || self instanceof InventoryScreen) { + } // Draw background } @Inject(method = "render", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderLabels(Lcom/mojang/blaze3d/vertex/PoseStack;II)V")) - private void addArmorSlots(PoseStack poseStack, int x, int y, float f, CallbackInfo ci) { + target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;renderLabels(Lnet/minecraft/client/gui/GuiGraphics;II)V")) + private void addArmorSlots(GuiGraphics graphics, int x, int y, float f, CallbackInfo ci) { if (!config.enabled || self instanceof InventoryScreen) return; // Draw 5 armor slots NonNullList armorSlots = ((IArmorMenu) this.self.getMenu()).cs_getArmorSlots(); for (Slot slot : armorSlots) { if (slot.isActive()) { RenderSystem.setShader(GameRenderer::getPositionTexShader); - this.renderSlot(poseStack, slot); + this.renderSlot(graphics, slot); if (this.isHovering(slot, x, y)) { this.hoveredSlot = slot; - AbstractContainerScreen.renderSlotHighlight(poseStack, slot.x, slot.y, 0); + AbstractContainerScreen.renderSlotHighlight(graphics, slot.x, slot.y, 0); } } } diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/storage_memory/MAbstractContainerScreen.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/storage_memory/MAbstractContainerScreen.java index 3c20994..cec3d43 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/storage_memory/MAbstractContainerScreen.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/screen/storage_memory/MAbstractContainerScreen.java @@ -1,10 +1,10 @@ package org.samo_lego.clientstorage.fabric_client.mixin.screen.storage_memory; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.Tooltip; import net.minecraft.client.gui.screens.Screen; @@ -90,27 +90,15 @@ private void constructor(AbstractContainerMenu abstractContainerMenu, Inventory } - /** - * Just there to save current rendered slot - * - * @param poseStack - * @param slot - * @param ci - */ - @Inject(method = "renderSlot", at = @At("HEAD")) - private void saveSlot(PoseStack poseStack, Slot slot, CallbackInfo ci) { - this.activeSlot = slot; - } - @Inject(method = "renderSlotHighlight", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/gui/screens/inventory/AbstractContainerScreen;fillGradient(Lcom/mojang/blaze3d/vertex/PoseStack;IIIIIII)V"), + target = "Lnet/minecraft/client/gui/GuiGraphics;fillGradient(Lnet/minecraft/client/renderer/RenderType;IIIIIII)V"), cancellable = true) - private static void renderSlotHighlight(PoseStack poseStack, int x, int y, int blitOffset, CallbackInfo ci) { + private static void renderSlotHighlight(GuiGraphics graphics, int x, int y, int blitOffset, CallbackInfo ci) { if (usingFakeSlot) { final int color = 0x7F_FF_F7_00; - AbstractContainerScreen.fillGradient(poseStack, x, y, x + 16, y + 16, color, color, blitOffset); + graphics.fillGradient(x, y, x + 16, y + 16, color, color, blitOffset); RenderSystem.colorMask(true, true, true, true); RenderSystem.enableDepthTest(); @@ -118,27 +106,39 @@ private static void renderSlotHighlight(PoseStack poseStack, int x, int y, int b } } + /** + * Just there to save current rendered slot + * + * @param guiGraphics + * @param slot + * @param ci + */ + @Inject(method = "renderSlot", at = @At("HEAD")) + private void saveSlot(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) { + this.activeSlot = slot; + } + /** * Takes care of item rendering transparency. * It renders the item to a framebuffer and then * draws framebuffer texture over the slot with transparency. * - * @param poseStack matrix stack - * @param slot slot being rendered + * @param guiGraphics graphics + * @param slot slot being rendered * @param ci */ @Inject(method = "renderSlot", at = @At("TAIL")) - private void postRenderItem(PoseStack poseStack, Slot slot, CallbackInfo ci) { + private void postRenderItem(GuiGraphics guiGraphics, Slot slot, CallbackInfo ci) { if (this.fakeSlot == slot.index) { TransparencyBuffer.preInject(); // Align the matrix stack - poseStack.pushPose(); - poseStack.translate(-this.leftPos, -this.topPos, 0.0f); + //poseStack.pushPose(); + //poseStack.translate(-this.leftPos, -this.topPos, 0.0f); // Draw the framebuffer texture - TransparencyBuffer.drawExtraFramebuffer(poseStack); - poseStack.popPose(); + TransparencyBuffer.drawExtraFramebuffer(guiGraphics); + //poseStack.popPose(); TransparencyBuffer.postInject(); } diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/storage/MAbstractChestedHorse.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/storage/MAbstractChestedHorse.java index 8387ddb..43a9a53 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/storage/MAbstractChestedHorse.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/mixin/storage/MAbstractChestedHorse.java @@ -58,12 +58,12 @@ public int getContainerSize() { @Override public boolean isEmpty() { - return this.empty || !this.level.isClientSide(); + return this.empty || !this.level().isClientSide(); } @Override public ItemStack getItem(int slot) { - if (!this.level.isClientSide()) return FULL_AIR; + if (!this.level().isClientSide()) return FULL_AIR; final var stack = this.inv[slot]; if (stack == null) { @@ -74,7 +74,7 @@ public ItemStack getItem(int slot) { @Override public ItemStack removeItemNoUpdate(int slot) { - if (!this.level.isClientSide()) return FULL_AIR; + if (!this.level().isClientSide()) return FULL_AIR; final ItemStack stack = this.inv[slot]; this.inv[slot] = ItemStack.EMPTY; @@ -89,7 +89,7 @@ public ItemStack removeItemNoUpdate(int slot) { @Override public void setItem(int slot, ItemStack itemStack) { - if (!this.level.isClientSide()) return; + if (!this.level().isClientSide()) return; this.inv[slot] = itemStack; this.updateEmpty(); @@ -106,12 +106,12 @@ public void setChanged() { @Override public boolean stillValid(Player player) { - return this.level.isClientSide(); + return this.level().isClientSide(); } @Override public boolean canPlaceItem(int i, ItemStack itemStack) { - return this.level.isClientSide(); + return this.level().isClientSide(); } } diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/render/TransparencyBuffer.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/render/TransparencyBuffer.java index 69696ab..7efa258 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/render/TransparencyBuffer.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/render/TransparencyBuffer.java @@ -5,9 +5,8 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.platform.Window; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiComponent; +import net.minecraft.client.gui.GuiGraphics; import org.lwjgl.opengl.GL30; /** @@ -39,7 +38,7 @@ public static void preInject() { RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.5f); } - public static void drawExtraFramebuffer(PoseStack matrices) { + public static void drawExtraFramebuffer(GuiGraphics matrices) { // Restore the original framebuffer GlStateManager._glBindFramebuffer(GL30.GL_FRAMEBUFFER, previousFramebuffer); @@ -47,8 +46,8 @@ public static void drawExtraFramebuffer(PoseStack matrices) { RenderSystem.setShaderTexture(0, framebuffer.getColorTextureId()); Window window = Minecraft.getInstance().getWindow(); // Create new matrix stack to prevent the transparency from affecting the rest of the GUI - GuiComponent.blit( - matrices, + /*matrices.blit( + framebuffer.getColorTextureId(), 0, // x 0, // y window.getGuiScaledWidth(), // width @@ -59,7 +58,7 @@ public static void drawExtraFramebuffer(PoseStack matrices) { -framebuffer.height, // height of the texture region framebuffer.width, // width of the entire texture framebuffer.height // height of the entire texture - ); + );*/ } public static void postInject() { diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/ContainerUtil.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/ContainerUtil.java index ac1bfc4..7ed435e 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/ContainerUtil.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/ContainerUtil.java @@ -74,7 +74,7 @@ public static boolean shouldIncludeContainer(BlockEntity containerBE, Player pla if (containerBE instanceof ChestBlockEntity) { // Check for ceiling - boolean canOpen = !ChestBlock.isChestBlockedAt(player.getLevel(), blockPos); + boolean canOpen = !ChestBlock.isChestBlockedAt(player.level(), blockPos); // Check if chest is double chest if (canOpen) { @@ -85,7 +85,7 @@ public static boolean shouldIncludeContainer(BlockEntity containerBE, Player pla BlockPos otherChestPos = blockPos.relative(ChestBlock.getConnectedDirection(containerState)); // Check if other part can be opened - canOpen = !ChestBlock.isChestBlockedAt(player.getLevel(), otherChestPos); + canOpen = !ChestBlock.isChestBlockedAt(player.level(), otherChestPos); // Only allow one chest to be opened canOpen &= chestType == DoubleBlockCombiner.BlockType.FIRST; @@ -101,7 +101,7 @@ public static boolean shouldIncludeContainer(BlockEntity containerBE, Player pla } else { AABB aABB = Shulker.getProgressDeltaAabb(containerState.getValue(ShulkerBoxBlock.FACING), 0.0F, 0.5F).move(blockPos).deflate(1.0E-6); - for (var shape : player.getLevel().getBlockCollisions(null, aABB)) { + for (var shape : player.level().getBlockCollisions(null, aABB)) { if (!shape.isEmpty() && !shape.bounds().deflate(1.0E-6).equals(aABB)) { return false; } diff --git a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/PlayerLookUtil.java b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/PlayerLookUtil.java index 3912777..63ae071 100644 --- a/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/PlayerLookUtil.java +++ b/fabric-client/src/main/java/org/samo_lego/clientstorage/fabric_client/util/PlayerLookUtil.java @@ -19,7 +19,7 @@ public class PlayerLookUtil { public static BlockHitResult raycastTo(Vec3 target) { var player = Minecraft.getInstance().player; var from = player.getEyePosition(); - return player.getLevel().clip(new ClipContext(from, target, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)); + return player.level().clip(new ClipContext(from, target, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, player)); } @@ -62,6 +62,6 @@ public static void lookAt(BlockPos blockPos) { float yaw = (float) Math.toDegrees(Math.atan2(zDiff, xDiff)); float pitch = (float) Math.toDegrees(Math.atan2(blockPos.getY() - player.getY(), Math.sqrt(xDiff * xDiff + zDiff * zDiff))); - player.connection.send(new ServerboundMovePlayerPacket.Rot(yaw, pitch, player.isOnGround())); + player.connection.send(new ServerboundMovePlayerPacket.Rot(yaw, pitch, player.onGround())); } } diff --git a/fabric-client/src/main/resources/fabric.mod.json b/fabric-client/src/main/resources/fabric.mod.json index 3a105a0..3a4dde0 100644 --- a/fabric-client/src/main/resources/fabric.mod.json +++ b/fabric-client/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ "depends": { "fabricloader": ">=0.7.4", "fabric-api": "*", - "yet-another-config-lib": ">=1.0.0" + "yet_another_config_lib_v3": ">=3.0.1+1.20" }, "custom": { "loom:injected_interfaces": { diff --git a/gradle.properties b/gradle.properties index fd53d2b..fc1871a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx1G # Fabric Properties -minecraft_version=1.19.4 -yarn_mappings=1.19.4+build.1 -loader_version=0.14.17 +minecraft_version=1.20.1 +yarn_mappings=1.20.1+build.1 +loader_version=0.14.21 #Fabric api -fabric_version=0.76.0+1.19.4 +fabric_version=0.83.1+1.20.1 # Mod Properties -mod_version=2.2.1 +mod_version=2.2.2 maven_group=org.samo_lego archives_base_name=clientstorage # Dependencies -modmenu_version=4.0.6 -yacl_version=2.3.0 +modmenu_version=7.0.0 +yacl_version=3.0.1+1.20