From 0cb2d37152bf2d94b9da6e39b8168d92571e56df Mon Sep 17 00:00:00 2001 From: maxsupermanhd Date: Sun, 17 Nov 2024 23:54:27 +0300 Subject: [PATCH] 1.21.3 update --- build.gradle | 2 +- gradle.properties | 10 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../gui/screens/EnchantmentSelectScreen.java | 9 ++--- .../addons/roller/modules/VillagerRoller.java | 36 ++++++++++--------- 5 files changed, 30 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index a738863..e618428 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'org.ajoberstar.grgit' version '5.0.0' - id 'fabric-loom' version '1.7-SNAPSHOT' + id 'fabric-loom' version '1.8-SNAPSHOT' } base { diff --git a/gradle.properties b/gradle.properties index 5634935..d697d83 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ org.gradle.jvmargs=-Xmx4G # Fabric (https://fabricmc.net/versions.html) -minecraft_version=1.21.1 -yarn_mappings=1.21.1+build.3 -loader_version=0.15.11 +minecraft_version=1.21.3 +yarn_mappings=1.21.3+build.2 +loader_version=0.16.9 # Mod Properties -mod_version=1.4.8 +mod_version=1.4.9 maven_group=maxsuperman.addons archives_base_name=villager-roller -meteor_version=0.5.8-SNAPSHOT +meteor_version=0.5.9-SNAPSHOT diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a441313..9355b41 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/maxsuperman/addons/roller/gui/screens/EnchantmentSelectScreen.java b/src/main/java/maxsuperman/addons/roller/gui/screens/EnchantmentSelectScreen.java index 4e7f473..be6b374 100644 --- a/src/main/java/maxsuperman/addons/roller/gui/screens/EnchantmentSelectScreen.java +++ b/src/main/java/maxsuperman/addons/roller/gui/screens/EnchantmentSelectScreen.java @@ -71,14 +71,11 @@ private void fillTable(WTable table) { if (mc.world == null) { return; } - var reg = mc.world.getRegistryManager().get(RegistryKeys.ENCHANTMENT); + var reg = mc.world.getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT); List> available = new ArrayList<>(); if (this.onlyTradable) { - var l = reg.getEntryList(EnchantmentTags.TRADEABLE); - if (l.isEmpty()) { - return; - } - available = l.get().stream().toList(); + var l = reg.iterateEntries(EnchantmentTags.TRADEABLE); + l.forEach(available::add); } else { for (var a : reg.getIndexedEntries()) { available.add(a); diff --git a/src/main/java/maxsuperman/addons/roller/modules/VillagerRoller.java b/src/main/java/maxsuperman/addons/roller/modules/VillagerRoller.java index 78539ec..a7863b5 100644 --- a/src/main/java/maxsuperman/addons/roller/modules/VillagerRoller.java +++ b/src/main/java/maxsuperman/addons/roller/modules/VillagerRoller.java @@ -40,9 +40,9 @@ import net.minecraft.entity.Entity; import net.minecraft.entity.passive.VillagerEntity; import net.minecraft.entity.projectile.ProjectileUtil; -import net.minecraft.item.EnchantedBookItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.item.KnowledgeBookItem; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtElement; import net.minecraft.nbt.NbtIo; @@ -427,18 +427,18 @@ private void fillWidget(GuiTheme theme, WVerticalList list) { searchingEnchants.sort(Comparator.comparing(o -> o.enchantment)); } - Registry reg; + Optional> reg; if (mc.world != null) { - reg = mc.world.getRegistryManager().get(RegistryKeys.ENCHANTMENT); + reg = mc.world.getRegistryManager().getOptional(RegistryKeys.ENCHANTMENT); } else { - reg = null; + reg = Optional.empty(); } for (int i = 0; i < searchingEnchants.size(); i++) { RollingEnchantment e = searchingEnchants.get(i); Optional> en; - if (reg != null) { - en = reg.getEntry(e.enchantment); + if (reg.isPresent()) { + en = reg.get().getEntry(e.enchantment); } else { en = Optional.empty(); } @@ -446,7 +446,7 @@ private void fillWidget(GuiTheme theme, WVerticalList list) { ItemStack book = Items.ENCHANTED_BOOK.getDefaultStack(); int maxlevel = 255; if (en.isPresent()) { - book = EnchantedBookItem.forEnchantment(new EnchantmentLevelEntry(en.get(), en.get().value().getMaxLevel())); + book = EnchantmentHelper.getEnchantedBookWith(new EnchantmentLevelEntry(en.get(), en.get().value().getMaxLevel())); maxlevel = en.get().value().getMaxLevel(); } table.add(theme.item(book)); @@ -518,9 +518,9 @@ private void fillWidget(GuiTheme theme, WVerticalList list) { addAll.action = () -> { list.clear(); searchingEnchants.clear(); - if (reg != null) { + if (reg.isPresent()) { for (RegistryEntry e : getEnchants(onlyTradable.get())) { - searchingEnchants.add(new RollingEnchantment(reg.getId(e.value()), e.value().getMaxLevel(), getMinimumPrice(e), true)); + searchingEnchants.add(new RollingEnchantment(reg.get().getId(e.value()), e.value().getMaxLevel(), getMinimumPrice(e), true)); } } fillWidget(theme, list); @@ -530,9 +530,9 @@ private void fillWidget(GuiTheme theme, WVerticalList list) { WButton setOptimalForAll = controls.add(theme.button("Set optimal for all")).expandX().widget(); setOptimalForAll.action = () -> { list.clear(); - if (reg != null) { + if (reg.isPresent()) { for (RollingEnchantment e : searchingEnchants) { - reg.getEntry(e.enchantment).ifPresent(enchantmentReference -> e.maxCost = getMinimumPrice(enchantmentReference)); + reg.get().getEntry(e.enchantment).ifPresent(enchantmentReference -> e.maxCost = getMinimumPrice(enchantmentReference)); } } fillWidget(theme, list); @@ -591,13 +591,17 @@ public List> getEnchants(boolean onlyTradable) { if (mc.world == null) { return Collections.emptyList(); } - var reg = mc.world.getRegistryManager().get(RegistryKeys.ENCHANTMENT); + var reg = mc.world.getRegistryManager().getOptional(RegistryKeys.ENCHANTMENT); + if (reg.isEmpty()) { + return Collections.emptyList(); + } List> available = new ArrayList<>(); if (onlyTradable) { - var l = reg.getEntryList(EnchantmentTags.TRADEABLE); - return l.map(registryEntries -> registryEntries.stream().toList()).orElse(Collections.emptyList()); + var i = reg.get().iterateEntries(EnchantmentTags.TRADEABLE); + i.iterator().forEachRemaining(available::add); + return available; } else { - for (var a : reg.getIndexedEntries()) { + for (var a : reg.get().getIndexedEntries()) { available.add(a); } return available; @@ -653,7 +657,7 @@ public void triggerTradeCheck(TradeOfferList l) { for (Pair, Integer> enchant : getEnchants(sellItem)) { int enchantLevel = enchant.right(); - var reg = mc.world.getRegistryManager().get(RegistryKeys.ENCHANTMENT); + var reg = mc.world.getRegistryManager().getOrThrow(RegistryKeys.ENCHANTMENT); String enchantIdString = reg.getId(enchant.key().value()).toString(); String enchantName = Names.get(enchant.key());