From 8f540ffc0f2e6dc90f8c9a1ac249ff9185243d3c Mon Sep 17 00:00:00 2001 From: Rime <81419447+Emirlol@users.noreply.github.com> Date: Fri, 21 Jun 2024 07:38:03 +0300 Subject: A lot of stuff. - Refactored SlotTextAdders to take in ItemStack and int slotId rather than Slot - Refactored the renderSlotText method from HandledScreenMixin into SlotTextManager and added an overloading function that takes in the itemstack, slot id, x and y and the previous function with the Slot parameter just delegates to it with the relevant fields from that Slot object - As a result of the above 2 changes the logic in CommunityShopAdder had to be changed too, now it figures out the screen from the method calls to `getText` rather than the Slot's inventory. - Fixed slot text not being rendered in backpack preview - Added private constructor for BackpackPreview (because it's all static methods anyway) --- .../hysky/skyblocker/utils/container/AbstractContainerSolver.java | 1 - .../de/hysky/skyblocker/utils/container/AbstractSlotTextAdder.java | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main/java/de/hysky/skyblocker/utils') diff --git a/src/main/java/de/hysky/skyblocker/utils/container/AbstractContainerSolver.java b/src/main/java/de/hysky/skyblocker/utils/container/AbstractContainerSolver.java index 38bc32dd..d4c52212 100644 --- a/src/main/java/de/hysky/skyblocker/utils/container/AbstractContainerSolver.java +++ b/src/main/java/de/hysky/skyblocker/utils/container/AbstractContainerSolver.java @@ -9,7 +9,6 @@ import net.minecraft.item.ItemStack; import java.util.List; public interface AbstractContainerSolver extends AbstractContainerMatcher { - List getColors(Int2ObjectMap slots); default void start(GenericContainerScreen screen) {} diff --git a/src/main/java/de/hysky/skyblocker/utils/container/AbstractSlotTextAdder.java b/src/main/java/de/hysky/skyblocker/utils/container/AbstractSlotTextAdder.java index 4034e88d..fce3fcf5 100644 --- a/src/main/java/de/hysky/skyblocker/utils/container/AbstractSlotTextAdder.java +++ b/src/main/java/de/hysky/skyblocker/utils/container/AbstractSlotTextAdder.java @@ -1,7 +1,7 @@ package de.hysky.skyblocker.utils.container; import de.hysky.skyblocker.skyblock.item.slottext.SlotText; -import net.minecraft.screen.slot.Slot; +import net.minecraft.item.ItemStack; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -9,7 +9,7 @@ import java.util.List; public interface AbstractSlotTextAdder extends AbstractContainerMatcher { /** - * This method will be called for each rendered slot. Consider using a switch statement on {@link Slot#id} if you wish to add different text to different slots. + * This method will be called for each rendered slot. Consider using a switch statement on {@code slotId} if you wish to limit the text to specific slots. * * @return A list of positioned text to be rendered. Return {@link List#of()} if no text should be rendered. * @implNote By minecraft's design, scaled text inexplicably moves around. @@ -17,5 +17,5 @@ public interface AbstractSlotTextAdder extends AbstractContainerMatcher { * So, limit your text to 3 characters (or roughly less than 20 width) if you want it to not look horrible. */ @NotNull - List getText(Slot slot); + List getText(@NotNull ItemStack itemStack, int slotId); } -- cgit