From 5726431d0220b1b859cc4b7e5e039c3ddd22c1c3 Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Thu, 10 Oct 2024 22:17:02 +0200 Subject: [PATCH] feat: Update to Minecraft 1.21.2 --- CHANGELOG.md | 3 +- .../trashslot/client/TrashSlotGuiHandler.java | 56 ++++++++++------- .../client/gui/TrashSlotComponent.java | 62 +++++++++---------- gradle.properties | 16 ++--- repositories.gradle | 19 ++++++ settings.gradle | 4 +- 6 files changed, 92 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c98542a..9e3c07f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1 @@ -- Updated to Minecraft 1.21.1 -- Changed the way key mappings are handled to avoid conflicts with vanilla key mappings \ No newline at end of file +- Updated to Minecraft 1.21.2 diff --git a/common/src/main/java/net/blay09/mods/trashslot/client/TrashSlotGuiHandler.java b/common/src/main/java/net/blay09/mods/trashslot/client/TrashSlotGuiHandler.java index 7014b77..70d0d6c 100644 --- a/common/src/main/java/net/blay09/mods/trashslot/client/TrashSlotGuiHandler.java +++ b/common/src/main/java/net/blay09/mods/trashslot/client/TrashSlotGuiHandler.java @@ -19,14 +19,19 @@ import net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen; import net.minecraft.client.gui.screens.inventory.InventoryScreen; import net.minecraft.client.player.LocalPlayer; +import net.minecraft.client.renderer.RenderType; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.MutableComponent; +import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.Slot; import net.minecraft.world.item.ItemStack; public class TrashSlotGuiHandler { + private static final ResourceLocation SLOT_HIGHLIGHT_BACK_SPRITE = ResourceLocation.withDefaultNamespace("container/slot_highlight_back"); + private static final ResourceLocation SLOT_HIGHLIGHT_FRONT_SPRITE = ResourceLocation.withDefaultNamespace("container/slot_highlight_front"); + private static final TrashSlotSlot trashSlot = new TrashSlotSlot(); private static TrashSlotComponent trashSlotComponent; private static ContainerSettings currentContainerSettings = ContainerSettings.NONE; @@ -43,7 +48,6 @@ public static void initialize() { Balm.getEvents().onEvent(ScreenMouseEvent.Click.Pre.class, TrashSlotGuiHandler::onMouseClick); Balm.getEvents().onEvent(ScreenKeyEvent.Press.Post.class, TrashSlotGuiHandler::onKeyPress); Balm.getEvents().onEvent(ContainerScreenDrawEvent.Background.class, TrashSlotGuiHandler::onBackgroundDrawn); - Balm.getEvents().onEvent(ContainerScreenDrawEvent.Background.class, TrashSlotGuiHandler::onScreenDrawn); } private static void onScreenInit(ScreenInitEvent.Post event) { @@ -274,17 +278,38 @@ public static void onBackgroundDrawn(ContainerScreenDrawEvent.Background event) trashSlotComponent.update(event.getMouseX(), event.getMouseY()); trashSlotComponent.drawBackground(event.getGuiGraphics()); - if (((AbstractContainerScreenAccessor) screen).callIsHovering(trashSlot, event.getMouseX(), event.getMouseY())) { - var poseStack = event.getGuiGraphics().pose(); + final var poseStack = event.getGuiGraphics().pose(); + final var screenAccessor = (AbstractContainerScreenAccessor) screen; + final var hovering = screenAccessor.callIsHovering(trashSlot, event.getMouseX(), event.getMouseY()); + if (hovering) { poseStack.pushPose(); - poseStack.translate(((AbstractContainerScreenAccessor) screen).getLeftPos(), ((AbstractContainerScreenAccessor) screen).getTopPos(), 0); - AbstractContainerScreen.renderSlotHighlight(event.getGuiGraphics(), trashSlot.x, trashSlot.y, 0); + poseStack.translate(screenAccessor.getLeftPos(), screenAccessor.getTopPos(), 1); + event.getGuiGraphics().blitSprite(RenderType::guiTextured, SLOT_HIGHLIGHT_BACK_SPRITE, trashSlot.x - 4, trashSlot.y - 4, 24, 24); poseStack.popPose(); } + + // TODO bit ugly for now since renderSlot ignores the pose stack translation + TrashSlotSlot trashSlot = TrashSlotGuiHandler.trashSlot; + SlotAccessor slotAccessor = (SlotAccessor) trashSlot; + slotAccessor.setX(trashSlot.x + screenAccessor.getLeftPos()); + slotAccessor.setY(trashSlot.y + screenAccessor.getTopPos()); + screenAccessor.callRenderSlot(event.getGuiGraphics(), trashSlot); + slotAccessor.setX(trashSlot.x - screenAccessor.getLeftPos()); + slotAccessor.setY(trashSlot.y - screenAccessor.getTopPos()); + + if (hovering) { + poseStack.pushPose(); + poseStack.translate(screenAccessor.getLeftPos(), screenAccessor.getTopPos(), 300); + event.getGuiGraphics().blitSprite(RenderType::guiTextured, SLOT_HIGHLIGHT_FRONT_SPRITE, trashSlot.x - 4, trashSlot.y - 4, 24, 24); + poseStack.popPose(); + } + + boolean isMouseSlot = screenAccessor.callIsHovering(trashSlot, event.getMouseX(), event.getMouseY()); + if (isMouseSlot && screen.getMenu().getCarried().isEmpty() && trashSlot.hasItem()) { + event.getGuiGraphics().renderTooltip(Minecraft.getInstance().font, trashSlot.getItem(), event.getMouseX(), event.getMouseY()); + } } - } - public static void onScreenDrawn(ContainerScreenDrawEvent.Background event) { if (currentHint != null) { currentHint.render(event.getScreen(), event.getGuiGraphics()); if (currentHint.isComplete()) { @@ -294,25 +319,8 @@ public static void onScreenDrawn(ContainerScreenDrawEvent.Background event) { } } - DeletionProvider deletionProvider = TrashSlotConfig.getDeletionProvider(); - if (deletionProvider == null || !currentContainerSettings.isEnabled()) { - return; - } - if (event.getScreen() instanceof AbstractContainerScreen screen && trashSlotComponent != null) { - // TODO bit ugly for now since renderSlot ignores the pose stack translation - TrashSlotSlot trashSlot = TrashSlotGuiHandler.trashSlot; - SlotAccessor slotAccessor = (SlotAccessor) trashSlot; - slotAccessor.setX(trashSlot.x + ((AbstractContainerScreenAccessor) screen).getLeftPos()); - slotAccessor.setY(trashSlot.y + ((AbstractContainerScreenAccessor) screen).getTopPos()); - ((AbstractContainerScreenAccessor) screen).callRenderSlot(event.getGuiGraphics(), trashSlot); - slotAccessor.setX(trashSlot.x - ((AbstractContainerScreenAccessor) screen).getLeftPos()); - slotAccessor.setY(trashSlot.y - ((AbstractContainerScreenAccessor) screen).getTopPos()); - boolean isMouseSlot = ((AbstractContainerScreenAccessor) screen).callIsHovering(trashSlot, event.getMouseX(), event.getMouseY()); - if (isMouseSlot && screen.getMenu().getCarried().isEmpty() && trashSlot.hasItem()) { - event.getGuiGraphics().renderTooltip(Minecraft.getInstance().font, trashSlot.getItem(), event.getMouseX(), event.getMouseY()); - } } } diff --git a/common/src/main/java/net/blay09/mods/trashslot/client/gui/TrashSlotComponent.java b/common/src/main/java/net/blay09/mods/trashslot/client/gui/TrashSlotComponent.java index 0495f58..0fcf47f 100644 --- a/common/src/main/java/net/blay09/mods/trashslot/client/gui/TrashSlotComponent.java +++ b/common/src/main/java/net/blay09/mods/trashslot/client/gui/TrashSlotComponent.java @@ -1,7 +1,5 @@ package net.blay09.mods.trashslot.client.gui; -import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.PoseStack; import net.blay09.mods.balm.mixin.AbstractContainerScreenAccessor; import net.blay09.mods.balm.mixin.SlotAccessor; import net.blay09.mods.trashslot.TrashSlot; @@ -19,6 +17,7 @@ import net.minecraft.client.gui.screens.Screen; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.client.renderer.Rect2i; +import net.minecraft.client.renderer.RenderType; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.Mth; @@ -145,7 +144,6 @@ public void drawBackground(GuiGraphics guiGraphics) { poseStack.pushPose(); poseStack.translate(0, 0, 1); - guiGraphics.setColor(1f, 1f, 1f, 1f); renderX += renderStyle.getRenderOffsetX() + layout.getSlotOffsetX(screen, renderStyle); renderY += renderStyle.getRenderOffsetY() + layout.getSlotOffsetY(screen, renderStyle); DeletionProvider deletionProvider = TrashSlotConfig.getDeletionProvider(); @@ -154,58 +152,58 @@ public void drawBackground(GuiGraphics guiGraphics) { texOffsetX = 64; } switch (renderStyle) { - case LONE -> guiGraphics.blit(texture, renderX, renderY, texOffsetX, 56, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); + case LONE -> guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX, 56, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); case ATTACH_BOTTOM_CENTER -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 50, 29, 4, 4); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 54, 29, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 50, 29, 4, 4, 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 54, 29, 4, 4, 256, 256); } case ATTACH_BOTTOM_LEFT -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 54, 29, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 54, 29, 4, 4, 256, 256); } case ATTACH_BOTTOM_RIGHT -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 50, 29, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 50, 29, 4, 4, 256, 256); } case ATTACH_TOP_CENTER -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 32, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 25, 4, 4); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 25, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 32, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 25, 4, 4, 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 25, 4, 4, 256, 256); } case ATTACH_TOP_LEFT -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 32, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 25, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 32, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 25, 4, 4, 256, 256); } case ATTACH_TOP_RIGHT -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 32, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 25, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 32, 0, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 25, 4, 4, 256, 256); } case ATTACH_LEFT_CENTER -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 25, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 50, 33, 4, 4); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 37, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 25, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 50, 33, 4, 4, 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 37, 4, 4, 256, 256); } case ATTACH_LEFT_TOP -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 25, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 37, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 25, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 50, 37, 4, 4, 256, 256); } case ATTACH_LEFT_BOTTOM -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 25, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 50, 33, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 25, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX + renderStyle.getRenderWidth() - 4, renderY, texOffsetX + 50, 33, 4, 4, 256, 256); } case ATTACH_RIGHT_CENTER -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 54, 33, 4, 4); - guiGraphics.blit(texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 37, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 54, 33, 4, 4, 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 37, 4, 4, 256, 256); } case ATTACH_RIGHT_TOP -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 37, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY + renderStyle.getRenderHeight() - 4, texOffsetX + 54, 37, 4, 4, 256, 256); } case ATTACH_RIGHT_BOTTOM -> { - guiGraphics.blit(texture, renderX, renderY, texOffsetX, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight()); - guiGraphics.blit(texture, renderX, renderY, texOffsetX + 54, 33, 4, 4); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX, 25, renderStyle.getRenderWidth(), renderStyle.getRenderHeight(), 256, 256); + guiGraphics.blit(RenderType::guiTextured, texture, renderX, renderY, texOffsetX + 54, 33, 4, 4, 256, 256); } } diff --git a/gradle.properties b/gradle.properties index 689bb27..f7abf57 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ mod_id = trashslot mod_name = TrashSlot mod_main=TrashSlot description=Adds a trash slot to the inventory screen that allows deletion of unwanted items. -version = 21.1.1 +version = 21.2.0 group = net.blay09.mods homepage=https://mods.twelveiterations.com/mc/trashslot sources=https://github.com/TwelveIterationMods/TrashSlot @@ -18,16 +18,16 @@ modrinth_release_type = release modrinth_project_id = vRYk0bv7 # Minecraft -minecraft_version = 1.21.1 +minecraft_version = 1.21.2-pre1 minimum_minecraft_version = 1.21 -minecraft_versions = 1.21,1.21.1 +minecraft_versions = 1.21,1.21.1,1.21.2-pre1 minecraft_version_range = [1.21,) pack_format_number = 18 java_version = 21 # Balm -balm_version = 21.0.14-SNAPSHOT -balm_version_range = [21.0.0,) +balm_version = 21.2.1-SNAPSHOT +balm_version_range = [21.2.0,) # Forge forge_version = 52.0.2 @@ -40,8 +40,8 @@ neoforge_version_range = [21-beta,) neoforge_loader_version_range = [1,) # Fabric -fabric_version = 0.102.1+1.21.1 -fabric_loader_version = 0.15.11 +fabric_version = 0.105.3+1.21.2 +fabric_loader_version = 0.16.5 # Dependencies jei_minecraft_version=1.19.2 @@ -56,6 +56,6 @@ org.gradle.daemon=false mod_author = BlayTheNinth credits = BlayTheNinth kuma_version = [21.0,22) -neo_form_version = 1.21.1-20240808.144430 +neo_form_version = 1.21.2-pre1-20241008.174159 parchment_minecraft = 1.21 parchment_version = 2024.06.23 \ No newline at end of file diff --git a/repositories.gradle b/repositories.gradle index 0fa21f4..d4e1b68 100644 --- a/repositories.gradle +++ b/repositories.gradle @@ -49,6 +49,7 @@ repositories { url = 'https://jitpack.io' content { includeGroup "com.github.BlueMap-Minecraft" + includeGroup "com.github.mattidragon" } } @@ -65,4 +66,22 @@ repositories { includeGroup "de.siphalor" } } + + maven { + url = "https://dl.cloudsmith.io/public/novamachina-mods/release/maven/" + content { + includeGroup "novamachina.novacore" + includeGroup "novamachina.exnihilosequentia" + } + } + + exclusiveContent { + forRepository { + maven { + name = 'Minecraft' + url = 'https://libraries.minecraft.net/' + } + } + filter { includeGroupAndSubgroups("com.mojang") } + } } \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index bce959e..f5a6464 100644 --- a/settings.gradle +++ b/settings.gradle @@ -45,5 +45,5 @@ plugins { include("common") include("fabric") -include("neoforge") -include("forge") +//include("neoforge") +//include("forge")