diff --git a/common/src/main/java/com/github/khanshoaib3/minecraft_access/features/inventory_controls/SlotItem.java b/common/src/main/java/com/github/khanshoaib3/minecraft_access/features/inventory_controls/SlotItem.java index 4d2fd5ca..92718ae1 100644 --- a/common/src/main/java/com/github/khanshoaib3/minecraft_access/features/inventory_controls/SlotItem.java +++ b/common/src/main/java/com/github/khanshoaib3/minecraft_access/features/inventory_controls/SlotItem.java @@ -5,6 +5,7 @@ import com.github.khanshoaib3.minecraft_access.mixin.StonecutterScreenAccessor; import net.minecraft.block.entity.BannerPattern; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.LoomScreen; import net.minecraft.client.gui.screen.ingame.MerchantScreen; import net.minecraft.client.gui.screen.ingame.StonecutterScreen; @@ -72,7 +73,7 @@ public SlotItem(int x, int y, String text) { public String getNarratableText() { if (MinecraftClient.getInstance().currentScreen instanceof LoomScreen loomScreen) { List> list = loomScreen.getScreenHandler().getBannerPatterns(); - if (list.size() == 0) return ""; + if (list.isEmpty()) return ""; int p = row + ((LoomScreenAccessor) loomScreen).getVisibleTopRow(); int q = p * 4 + column; @@ -82,11 +83,11 @@ public String getNarratableText() { if (MinecraftClient.getInstance().currentScreen instanceof StonecutterScreen stonecutterScreen) { List> list = stonecutterScreen.getScreenHandler().getAvailableRecipes(); - if (list.size() == 0) return ""; + if (list.isEmpty()) return ""; int scrollOffset = ((StonecutterScreenAccessor) stonecutterScreen).getScrollOffset(); ItemStack item = list.get(recipeOrTradeIndex + scrollOffset).value().getResult(DynamicRegistryManager.EMPTY); - List toolTip = MinecraftClient.getInstance().currentScreen.getTooltipFromItem(MinecraftClient.getInstance(),item); + List toolTip = Screen.getTooltipFromItem(MinecraftClient.getInstance(),item); StringBuilder toolTipString = new StringBuilder(); for (Text text : toolTip) { toolTipString.append(text.getString()).append("\n"); diff --git a/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonAccessor.java b/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonAccessor.java index 719aac7b..9bb3371a 100644 --- a/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonAccessor.java +++ b/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonAccessor.java @@ -2,7 +2,7 @@ import net.minecraft.client.gui.screen.recipebook.AnimatedResultButton; import net.minecraft.client.gui.screen.recipebook.RecipeResultCollection; -import net.minecraft.recipe.Recipe; +import net.minecraft.recipe.RecipeEntry; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; @@ -11,8 +11,9 @@ @Mixin(AnimatedResultButton.class) public interface AnimatedResultButtonAccessor { + // pre 1.20.4: List> callGetResults(); @Invoker - List> callGetResults(); + List> callGetResults(); @Accessor RecipeResultCollection getResultCollection(); diff --git a/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonMixin.java b/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonMixin.java index 8ef00264..20b21e2f 100644 --- a/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonMixin.java +++ b/common/src/main/java/com/github/khanshoaib3/minecraft_access/mixin/AnimatedResultButtonMixin.java @@ -7,6 +7,7 @@ import net.minecraft.client.gui.screen.recipebook.AnimatedResultButton; import net.minecraft.client.resource.language.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.recipe.RecipeEntry; import net.minecraft.registry.DynamicRegistryManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Unique; @@ -14,6 +15,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import java.util.List; + @Mixin(AnimatedResultButton.class) public class AnimatedResultButtonMixin { @Unique @@ -28,7 +31,9 @@ public class AnimatedResultButtonMixin { // @Inject(at = @At("HEAD"), method = "appendNarrations", cancellable = true) // Pre 1.19.3 @Inject(at = @At("HEAD"), method = "appendClickableNarrations", cancellable = true) // From 1.19.3 private void appendNarrations(NarrationMessageBuilder builder, CallbackInfo callbackInfo) { - ItemStack itemStack = ((AnimatedResultButtonAccessor) this).callGetResults().get(((AnimatedResultButtonAccessor) this).getCurrentResultIndex()).getResult(DynamicRegistryManager.EMPTY); + List> recipes = ((AnimatedResultButtonAccessor) this).callGetResults(); + RecipeEntry recipe = recipes.get(((AnimatedResultButtonAccessor) this).getCurrentResultIndex()); + ItemStack itemStack = recipe.value().getResult(DynamicRegistryManager.EMPTY); String itemName = itemStack.getName().getString(); boolean sameItem = itemName.equalsIgnoreCase(minecraft_access$previousItemName); diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 542053f2..47952ff4 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,14 +1,18 @@ -Release v1.5.1 (2024-01) +Release v1.5.2 (2024-01) --------------------------- -### Feature Changes - -* Add a new config "Speak Focused Slot Changes" with default "true" value for "Inventory Controls" feature. Close this config if you hear the mod is continuously repeating changes of item name. [#242](https://github.com/khanshoaib3/minecraft_access/issues/242) - ### Bug Fixes * Fix the bug that locking on Entity will immediately unlock [#248](https://github.com/khanshoaib3/minecraft_access/issues/248) * Fix the bug that mod's INFO log will be logged twice in console and log files [#247](https://github.com/khanshoaib3/minecraft_access/issues/247) +* Fix the bug that speaking recipes in Inventory Screen will cause the game crush. [#251](https://github.com/khanshoaib3/minecraft_access/issues/251) + +Release v1.5.1 (2024-01) +--------------------------- + +### Feature Changes + +* Add a new config "Speak Focused Slot Changes" with default "true" value for "Inventory Controls" feature. Close this config if you hear the mod is continuously repeating changes of item name. [#242](https://github.com/khanshoaib3/minecraft_access/issues/242) Release v1.5.0 (2024-01) --------------------------- diff --git a/gradle.properties b/gradle.properties index f30cb2cb..4ec891e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,7 +16,7 @@ fabric_yarn_version=1.20.4+build.1:v2 enabled_platforms=fabric,forge archives_base_name=minecraft-access -mod_version=1.5.1+1.20.4 +mod_version=1.5.2+1.20.4 maven_group=com.github.khanshoaib3.minecraft_access # https://maven.architectury.dev/dev/architectury/