diff --git a/build.gradle b/build.gradle index cdee3752..f2b5efa8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ plugins { - id 'fabric-loom' version '1.2-SNAPSHOT' + id 'fabric-loom' version '1.6-SNAPSHOT' id 'maven-publish' id("com.github.bjornvester.xjc") version "1.6.0" } -sourceCompatibility = JavaVersion.VERSION_17 -targetCompatibility = JavaVersion.VERSION_17 +sourceCompatibility = JavaVersion.VERSION_21 +targetCompatibility = JavaVersion.VERSION_21 version = rootProject.file('VERSION').text.trim() archivesBaseName = project.archives_base_name + '-fabric_' + project.fabric_version @@ -62,8 +62,8 @@ processResources { } tasks.withType(JavaCompile).configureEach { - // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. - it.options.release = 17 + // Minecraft 1.21-rc1 uses Java 21. + it.options.release = 21 } java { diff --git a/gradle.properties b/gradle.properties index f2f4345a..dc714568 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,15 +2,15 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties - # check these on https://fabricmc.net/develop - minecraft_version=1.20.1 - yarn_mappings=1.20.1+build.2 - loader_version=0.14.21 + # check these on https://fabricmc.net/develop + minecraft_version=1.21 + yarn_mappings=1.21+build.2 + loader_version=0.15.11 # Mod Properties - mod_version = 1.0.0 - maven_group = io.singularitynet - archives_base_name = vereya + mod_version = 1.0.0 + maven_group = io.singularitynet + archives_base_name = vereya #Fabric api -fabric_version=0.83.1+1.20.1 +fabric_version=0.100.1+1.21 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0c85a1f7..509c4a29 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.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/io/singularitynet/Client/ClientStateMachine.java b/src/main/java/io/singularitynet/Client/ClientStateMachine.java index f84f3ab5..2dcfd49b 100755 --- a/src/main/java/io/singularitynet/Client/ClientStateMachine.java +++ b/src/main/java/io/singularitynet/Client/ClientStateMachine.java @@ -1224,10 +1224,10 @@ protected void execute() { } } */ - boolean isConnectedToRealm = MinecraftClient.getInstance().isConnectedToRealms(); +// boolean isConnectedToRealm = MinecraftClient.getInstance().isConnectedToRealms(); boolean isConnectedToLocal = MinecraftClient.getInstance().isConnectedToLocalServer(); boolean isIntegratedServerRunning = MinecraftClient.getInstance().isIntegratedServerRunning(); - LOGGER.debug("isConnectedToRealm: " + isConnectedToRealm); +// LOGGER.debug("isConnectedToRealm: " + isConnectedToRealm); LOGGER.debug("isConnectedToLocal: " + isConnectedToLocal); LOGGER.debug("isIntegratedServerRunning: " + isIntegratedServerRunning); if (isIntegratedServerRunning) { diff --git a/src/main/java/io/singularitynet/MissionHandlers/ObservationFromBlocksDropsImplementation.java b/src/main/java/io/singularitynet/MissionHandlers/ObservationFromBlocksDropsImplementation.java index 8f83242b..aa93b58c 100644 --- a/src/main/java/io/singularitynet/MissionHandlers/ObservationFromBlocksDropsImplementation.java +++ b/src/main/java/io/singularitynet/MissionHandlers/ObservationFromBlocksDropsImplementation.java @@ -4,9 +4,18 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import com.google.gson.*; +import com.mojang.serialization.Lifecycle; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import net.minecraft.data.server.loottable.LootTableGenerator; +import net.minecraft.registry.*; +import net.minecraft.registry.entry.RegistryEntryInfo; +import net.minecraft.util.ErrorReporter; +import net.minecraft.util.Util; +import net.minecraft.util.math.random.RandomSeed; +import net.minecraft.util.math.random.RandomSequence; import org.jetbrains.annotations.Nullable; -import net.minecraft.loot.LootDataKey; -import net.minecraft.loot.LootDataLookup; +//import net.minecraft.loot.LootDataKey; +//import net.minecraft.loot.LootDataLookup; import net.minecraft.loot.LootDataType; import net.minecraft.loot.LootTable; import org.apache.logging.log4j.LogManager; @@ -26,7 +35,6 @@ import net.minecraft.loot.LootTableReporter; import net.minecraft.loot.context.LootContextType; import net.minecraft.loot.context.LootContextTypes; -import net.minecraft.registry.Registry; import net.minecraft.registry.tag.TagKey; import net.minecraft.util.Identifier; import io.singularitynet.mixin.LootTableProviderMixin; @@ -215,54 +223,59 @@ else if (predicate.toString().contains("items")) return result; } - private Dictionary> parseLottable(List lootTypeGenerators, Set lootTableIds) { + private Dictionary> parseLottable(List lootTypeGenerators, Set lootTableIds, RegistryWrapper.WrapperLookup registryLookup) { + MutableRegistry mutableRegistry = new SimpleRegistry(RegistryKeys.LOOT_TABLE, Lifecycle.experimental()); + Map map = new Object2ObjectOpenHashMap(); Dictionary> result = new Hashtable<>(); - Map map = Maps.newHashMap(); - lootTypeGenerators.forEach((lootTypeGenerator) -> lootTypeGenerator.provider().get().accept((id, builder) -> { - if (map.put(id, builder.type(lootTypeGenerator.paramSet()).build()) != null) { - throw new IllegalStateException("Duplicate loot table " + id); - } - })); - LootContextType var10002 = LootContextTypes.GENERIC; - Function var10003 = (id) -> null; - Objects.requireNonNull(map); - LootTableReporter lootTableReporter = new LootTableReporter(LootContextTypes.GENERIC, new LootDataLookup(){ - - @Override - @Nullable - public T getElement(LootDataKey lootDataKey) { - if (lootDataKey.type() == LootDataType.LOOT_TABLES) { - return (T)map.get(lootDataKey.id()); + + + lootTypeGenerators.forEach((lootTypeGenerator) -> { + ((LootTableGenerator)lootTypeGenerator.provider().apply(registryLookup)).accept((lootTable, builder) -> { + Identifier identifier = lootTable.getValue(); + Identifier identifier2 = (Identifier)map.put(RandomSequence.createSeed(identifier), identifier); + if (identifier2 != null) { + String var10000 = String.valueOf(identifier2); + Util.error("Loot table random sequence seed collision on " + var10000 + " and " + String.valueOf(lootTable.getValue())); } - return null; - } + + builder.randomSequenceId(identifier); + LootTable lootTable2 = builder.type(lootTypeGenerator.paramSet()).build(); + mutableRegistry.add(lootTable, lootTable2, RegistryEntryInfo.DEFAULT); + }); }); - Set set = Sets.difference(lootTableIds, map.keySet()); - Iterator var5 = set.iterator(); - while (var5.hasNext()) { - Identifier identifier = (Identifier) var5.next(); - lootTableReporter.report("Missing built-in table: " + identifier); + mutableRegistry.freeze(); + ErrorReporter.Impl impl = new ErrorReporter.Impl(); + RegistryEntryLookup.RegistryLookup registryLookup2 = (new DynamicRegistryManager.ImmutableImpl(List.of(mutableRegistry))).toImmutable().createRegistryLookup(); + LootTableReporter lootTableReporter = new LootTableReporter(impl, LootContextTypes.GENERIC, registryLookup2); + Iterator var9 = Sets.difference(lootTableIds, mutableRegistry.getKeys()).iterator(); + + while(var9.hasNext()) { + RegistryKey registryKey = (RegistryKey)var9.next(); + impl.report("Missing built-in table: " + String.valueOf(registryKey.getValue())); } - map.forEach((id, table) -> table.validate(lootTableReporter.withContextType(table.getType()).makeChild("{" + id + "}", new LootDataKey(LootDataType.LOOT_TABLES, (Identifier)id)))); - Multimap multimap = lootTableReporter.getMessages(); + mutableRegistry.streamEntries().forEach((entry) -> { + ((LootTable)entry.value()).validate(lootTableReporter.withContextType(((LootTable)entry.value()).getType()).makeChild("{" + String.valueOf(entry.registryKey().getValue()) + "}", entry.registryKey())); + }); + Multimap multimap = impl.getErrors(); + if (!multimap.isEmpty()) { multimap.forEach((name, message) -> { LOGGER.warn("Found validation problem in {}: {}", name, message); }); throw new IllegalStateException("Failed to validate loot tables, see logs"); } else { - for (Map.Entry entry : map.entrySet()) { - Identifier identifier = entry.getKey(); + for (Map.Entry entry : map.entrySet()) { + RandomSeed.XoroshiroSeed identifier = entry.getKey(); if (!identifier.toString().contains("block")) continue; String block_name = identifier.toString().replace("minecraft:blocks/", ""); - LootTable loottable = entry.getValue(); - JsonElement jel = LootDataType.LOOT_TABLES.getGson().toJsonTree(loottable); + Identifier loottable = entry.getValue(); +// JsonElement jel = LootDataType.LOOT_TABLES.getGson().toJsonTree(loottable); // JsonElement jel = LootManager.toJson(loottable); - List parsed_one_table = this.parseOneTable(jel, block_name); - result.put(block_name, parsed_one_table); +// List parsed_one_table = this.parseOneTable(jel, block_name); +// result.put(block_name, parsed_one_table); } } return result; @@ -287,83 +300,83 @@ public void writeObservationsToJSON(JsonObject json, MissionInit currentMissionI if (!this.sendRec){ return; } - this.sendRec = false; - LOGGER.debug("ObservationFromBlocksDrops -- start"); - Path pth = Path.of(System.getProperty("java.io.tmpdir")); - DataOutput doutput = new DataOutput(pth); - DataWriter writer = DataWriter.UNCACHED; - LootTableProvider provider = VanillaLootTableProviders.createVanillaProvider(doutput); - provider.run(writer); - - Set loottables = ((LootTableProviderMixin)provider).getlootTableIds(); - List lootTypeGenerators = ((LootTableProviderMixin)provider).getlootTypeGenerators(); - Dictionary> parsed_loottable = this.parseLottable(lootTypeGenerators, loottables); - - Registry str_ent = MinecraftClient.getInstance().world.getRegistryManager().get(ITEM.getKey()); - List list_ent = str_ent.stream().toList(); - JsonArray triple_array = new JsonArray(); - Map from_block = list_ent.get(0).BLOCK_ITEMS; - for (Map.Entry entry : from_block.entrySet()) { - Block en_block = entry.getKey(); - Item en_item = entry.getValue(); - String block_name = en_block.getLootTableId().toString(); - if (Objects.equals(block_name, "minecraft:empty")) { - continue; - } - boolean is_tool_required = en_block.getDefaultState().isToolRequired(); - String tool_name = ""; - if (is_tool_required) - { - boolean wooden_required = true; - String tool_q = ""; - String tool_t = ""; - List> block_tags = en_block.getRegistryEntry().streamTags().toList(); - for (TagKey block_tag: block_tags) - { - String tag_string = block_tag.id().toString(); - if (tag_string.contains("mineable")) - { - tool_t = tag_string.split("/")[1]; - } - else if (tag_string.contains("tool")) - { - tool_q = tag_string.split("_")[1]; - wooden_required = false; - } - } - if (wooden_required) - tool_q = "wooden"; - if (!tool_q.equals("") && tool_t.equals("")) - tool_name = tool_q + "_" + "AnyTool"; - else - tool_name = tool_q+"_"+tool_t; - } - - block_name = block_name.split("/")[1]; - if (((Hashtable)parsed_loottable).containsKey(block_name)) - { - List p_items = parsed_loottable.get(block_name); - for (int i = 0 ; i < p_items.size(); i+=2) - { - String item_name = p_items.get(i); - String tool_suff = p_items.get(i+1); - if (tool_suff.equals("") || tool_suff.equals("silkt_")) - updateTripleArray(triple_array, block_name, item_name, tool_suff+tool_name); - else if (tool_suff.equals("pickaxe") && tool_name.equals("")) - { - updateTripleArray(triple_array, block_name, item_name, "AnyTool"); - } - else - updateTripleArray(triple_array, block_name, item_name, tool_suff); - } - } - else - { - String item_name = en_item.toString(); - updateTripleArray(triple_array, block_name, item_name, tool_name); - } - } - json.add("block_item_tool_triple", triple_array); - LOGGER.debug("ObservationFromBlocksDrops -- end"); +// this.sendRec = false; +// LOGGER.debug("ObservationFromBlocksDrops -- start"); +// Path pth = Path.of(System.getProperty("java.io.tmpdir")); +// DataOutput doutput = new DataOutput(pth); +// DataWriter writer = DataWriter.UNCACHED; +// LootTableProvider provider = VanillaLootTableProviders.createVanillaProvider(doutput); +// provider.run(writer); +// +// Set loottables = ((LootTableProviderMixin)provider).getlootTableIds(); +// List lootTypeGenerators = ((LootTableProviderMixin)provider).getlootTypeGenerators(); +// Dictionary> parsed_loottable = this.parseLottable(lootTypeGenerators, loottables); +// +// Registry str_ent = MinecraftClient.getInstance().world.getRegistryManager().get(ITEM.getKey()); +// List list_ent = str_ent.stream().toList(); +// JsonArray triple_array = new JsonArray(); +// Map from_block = list_ent.get(0).BLOCK_ITEMS; +// for (Map.Entry entry : from_block.entrySet()) { +// Block en_block = entry.getKey(); +// Item en_item = entry.getValue(); +// String block_name = en_block.getLootTableId().toString(); +// if (Objects.equals(block_name, "minecraft:empty")) { +// continue; +// } +// boolean is_tool_required = en_block.getDefaultState().isToolRequired(); +// String tool_name = ""; +// if (is_tool_required) +// { +// boolean wooden_required = true; +// String tool_q = ""; +// String tool_t = ""; +// List> block_tags = en_block.getRegistryEntry().streamTags().toList(); +// for (TagKey block_tag: block_tags) +// { +// String tag_string = block_tag.id().toString(); +// if (tag_string.contains("mineable")) +// { +// tool_t = tag_string.split("/")[1]; +// } +// else if (tag_string.contains("tool")) +// { +// tool_q = tag_string.split("_")[1]; +// wooden_required = false; +// } +// } +// if (wooden_required) +// tool_q = "wooden"; +// if (!tool_q.equals("") && tool_t.equals("")) +// tool_name = tool_q + "_" + "AnyTool"; +// else +// tool_name = tool_q+"_"+tool_t; +// } +// +// block_name = block_name.split("/")[1]; +// if (((Hashtable)parsed_loottable).containsKey(block_name)) +// { +// List p_items = parsed_loottable.get(block_name); +// for (int i = 0 ; i < p_items.size(); i+=2) +// { +// String item_name = p_items.get(i); +// String tool_suff = p_items.get(i+1); +// if (tool_suff.equals("") || tool_suff.equals("silkt_")) +// updateTripleArray(triple_array, block_name, item_name, tool_suff+tool_name); +// else if (tool_suff.equals("pickaxe") && tool_name.equals("")) +// { +// updateTripleArray(triple_array, block_name, item_name, "AnyTool"); +// } +// else +// updateTripleArray(triple_array, block_name, item_name, tool_suff); +// } +// } +// else +// { +// String item_name = en_item.toString(); +// updateTripleArray(triple_array, block_name, item_name, tool_name); +// } +// } +// json.add("block_item_tool_triple", triple_array); +// LOGGER.debug("ObservationFromBlocksDrops -- end"); } } diff --git a/src/main/java/io/singularitynet/mixin/ClientWorldMixinAccess.java b/src/main/java/io/singularitynet/mixin/ClientWorldMixinAccess.java index f9ed395e..4b341a79 100644 --- a/src/main/java/io/singularitynet/mixin/ClientWorldMixinAccess.java +++ b/src/main/java/io/singularitynet/mixin/ClientWorldMixinAccess.java @@ -1,6 +1,6 @@ package io.singularitynet.mixin; -import net.minecraft.client.world.ClientEntityManager; +import net.minecraft.world.entity.ClientEntityManager; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.Entity; import net.minecraft.world.entity.EntityLookup; diff --git a/src/main/java/io/singularitynet/mixin/SessionMixin.java b/src/main/java/io/singularitynet/mixin/SessionMixin.java index 00afa147..a55a0bc4 100644 --- a/src/main/java/io/singularitynet/mixin/SessionMixin.java +++ b/src/main/java/io/singularitynet/mixin/SessionMixin.java @@ -1,6 +1,6 @@ package io.singularitynet.mixin; -import net.minecraft.client.util.Session; +import net.minecraft.client.session.Session; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.gen.Accessor;