Skip to content

Commit

Permalink
1.21.3 update
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsupermanhd committed Nov 17, 2024
1 parent 5443bc0 commit 0cb2d37
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<RegistryEntry<Enchantment>> 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);
Expand Down
36 changes: 20 additions & 16 deletions src/main/java/maxsuperman/addons/roller/modules/VillagerRoller.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -427,26 +427,26 @@ private void fillWidget(GuiTheme theme, WVerticalList list) {
searchingEnchants.sort(Comparator.comparing(o -> o.enchantment));
}

Registry<Enchantment> reg;
Optional<Registry<Enchantment>> 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<RegistryEntry.Reference<Enchantment>> en;
if (reg != null) {
en = reg.getEntry(e.enchantment);
if (reg.isPresent()) {
en = reg.get().getEntry(e.enchantment);
} else {
en = Optional.empty();
}
final int si = i;
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));
Expand Down Expand Up @@ -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<Enchantment> 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);
Expand All @@ -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);
Expand Down Expand Up @@ -591,13 +591,17 @@ public List<RegistryEntry<Enchantment>> 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<RegistryEntry<Enchantment>> 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;
Expand Down Expand Up @@ -653,7 +657,7 @@ public void triggerTradeCheck(TradeOfferList l) {

for (Pair<RegistryEntry<Enchantment>, 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());

Expand Down

0 comments on commit 0cb2d37

Please sign in to comment.