From d99c13dc1d45f53e7ef90fb29db8549508da2377 Mon Sep 17 00:00:00 2001 From: JohnBraham Date: Sun, 15 Nov 2026 21:45:27 +0000 Subject: [PATCH] Fix Base Minerals 1.13 mining drops and Eclipse launches Bring the ore drops and processing recipes back into line with the earlier branches, and restore the block properties, molten light and smith trades. Quote the generated Eclipse launcher paths so project folders with spaces work. Prepare 2.5.2.113021 with the mining regression probe and updated release notes. --- CHANGELOG.txt | 8 + README.md | 5 + build.gradle | 71 ++++- docs/BUILDING.md | 11 +- gradle.properties | 2 +- gradle/release-113.gradle | 1 + .../moddev/mc/baseminerals/BaseMinerals.java | 6 +- .../baseminerals/content/MineralContent.java | 49 +++- .../mc/baseminerals/trade/MineralTrades.java | 26 ++ .../recipes/lithium_block_crushing.json | 25 ++ .../recipes/lithium_ingot_crushing.json | 25 ++ .../recipes/lithium_nugget_crushing.json | 25 ++ .../recipes/lithium_ore_smelting.json | 9 + .../recipes/lithium_powder_smelting.json | 9 + .../recipes/lithium_smallpowder_smelting.json | 9 + .../recipes/niter_block_crushing.json | 25 ++ .../recipes/phosphorus_block_crushing.json | 25 ++ .../recipes/potash_block_crushing.json | 25 ++ .../recipes/salt_block_crushing.json | 25 ++ .../recipes/saltpeter_block_crushing.json | 25 ++ .../recipes/silicon_blend_smelting.json | 9 + .../recipes/silicon_block_crushing.json | 25 ++ .../recipes/silicon_ingot_crushing.json | 25 ++ .../recipes/silicon_nugget_crushing.json | 25 ++ .../recipes/silicon_powder_smelting.json | 2 +- .../recipes/silicon_smallblend_smelting.json | 9 + .../recipes/silicon_smallpowder_smelting.json | 9 + .../recipes/sulfur_block_crushing.json | 25 ++ .../java/test/MineralMiningProbe.java | 271 ++++++++++++++++++ .../mining-probe/resources/META-INF/mods.toml | 12 + .../mining-probe/resources/pack.mcmeta | 1 + tools/validation/legacy113/verify_mining.py | 39 +++ 32 files changed, 846 insertions(+), 12 deletions(-) create mode 100644 src/main/java/zone/moddev/mc/baseminerals/trade/MineralTrades.java create mode 100644 src/main/resources/data/baseminerals/recipes/lithium_block_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/lithium_ingot_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/lithium_nugget_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/lithium_ore_smelting.json create mode 100644 src/main/resources/data/baseminerals/recipes/lithium_powder_smelting.json create mode 100644 src/main/resources/data/baseminerals/recipes/lithium_smallpowder_smelting.json create mode 100644 src/main/resources/data/baseminerals/recipes/niter_block_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/phosphorus_block_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/potash_block_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/salt_block_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/saltpeter_block_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/silicon_blend_smelting.json create mode 100644 src/main/resources/data/baseminerals/recipes/silicon_block_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/silicon_ingot_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/silicon_nugget_crushing.json create mode 100644 src/main/resources/data/baseminerals/recipes/silicon_smallblend_smelting.json create mode 100644 src/main/resources/data/baseminerals/recipes/silicon_smallpowder_smelting.json create mode 100644 src/main/resources/data/baseminerals/recipes/sulfur_block_crushing.json create mode 100644 tools/validation/legacy113/mining-probe/java/test/MineralMiningProbe.java create mode 100644 tools/validation/legacy113/mining-probe/resources/META-INF/mods.toml create mode 100644 tools/validation/legacy113/mining-probe/resources/pack.mcmeta create mode 100644 tools/validation/legacy113/verify_mining.py diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b93b078..5095bf7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,11 @@ +2.5.2.113021 for Minecraft 1.13.2 + +This fixes the ore drops to match 1.10 to 1.12. Lithium drops one ore block; the other six ores drop 2–4 powders. Fortune increases the maximum, and Silk Touch returns the ore block. + +The missing lithium and silicon smelting recipes are back, along with block, ingot and nugget crushing. This also restores the earlier mining hardness, tool requirements, blast resistance, storage-block beacon support, molten-fluid light and smith ingot trades. + +Eclipse launches now work when the project path contains spaces. + 2.5.1.113021 for Minecraft 1.13.2 - Bring the eight minerals and seven ore deposits across to Forge 25, without MMDLib. diff --git a/README.md b/README.md index 450d8f6..2cce877 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ Use 3.0.3.113021 or a later compatible 1.13.2 build when installing the two toge Base Minerals shares its ore crushing recipes with Base Metals when installed. If Base Metals is absent, Modern Metals crackhammers can crush the ores instead. +Mining lithium returns one ore block. Niter, phosphorus, potash, salt, +saltpeter and sulfur drop 2–4 powders, with Fortune increasing the upper +limit by its level. Silk Touch returns one ore block. A Crack Hammer gives +two powders per ore, as on the earlier branches. + ## Upgrading a world Copy the whole save folder before opening it on 1.13.2, including level.dat diff --git a/build.gradle b/build.gradle index 4837a5d..5816a65 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,6 @@ import groovy.json.JsonSlurper +import groovy.xml.XmlParser +import groovy.xml.XmlUtil import java.security.MessageDigest plugins { @@ -10,7 +12,7 @@ plugins { } group = 'zone.moddev.mc.baseminerals' -version = '2.5.1.113021' +version = project.mod_version base.archivesName = 'BaseMinerals' java { @@ -139,6 +141,28 @@ tasks.register('verifyPinnedMods') { tasks.named('compileJava') { dependsOn 'verifyPinnedMods' } tasks.named('test') { useJUnitPlatform() } +sourceSets { + miningProbe { + java.srcDirs = ['tools/validation/legacy113/mining-probe/java'] + resources.srcDirs = ['tools/validation/legacy113/mining-probe/resources'] + compileClasspath += sourceSets.main.output + sourceSets.main.compileClasspath + } +} +def miningProbeJar = tasks.register('miningProbeJar', Jar) { + dependsOn tasks.named('miningProbeClasses') + from sourceSets.miningProbe.output + destinationDirectory = layout.buildDirectory.dir('test-mods') + archiveFileName = 'mineral-mining-probe-dev.jar' +} +def packagedMiningProbe = renamer.classes(miningProbeJar) { + map.from minecraft.dependency.toSrgFile + archiveClassifier = null + output = layout.buildDirectory.file('test-mods/mineral-mining-probe.jar') +} +tasks.register('packagedMiningProbeJar') { dependsOn packagedMiningProbe } +// Keep the executable test mod out of Eclipse's normal game launches. +eclipse.classpath.sourceSets = [sourceSets.main, sourceSets.test] + tasks.register('verifyFluidRegistration', Exec) { group = 'verification' description = 'Checks that fluid registration runs before blocks, outside parallel construction.' @@ -155,7 +179,50 @@ tasks.named('check') { dependsOn 'verifyFluidRegistration' } } } } -tasks.named('eclipse') { dependsOn 'genEclipseRuns', stageRunClasses } +// Eclipse splits bare launcher paths at spaces, unlike Gradle's JavaExec tasks. +def eclipseLauncherPath = ~/(--(?:cache|metadata|to-srg|to-obf) )("[^"]*"|.+?)(?= (?:--metadata |--to-srg |--to-obf |--(?: |$)))/ +tasks.matching { it.name.startsWith('genEclipseRun') && it.name.endsWith('ForForge') }.configureEach { + dependsOn stageRunClasses + String launchName = name.replaceFirst('^genEclipseRun', 'run').replaceFirst('ForForge$', '') + '.launch' + File launch = layout.projectDirectory.file(launchName).asFile + doLast { + Node configuration = new XmlParser().parse(launch) + Node programArguments = configuration.stringAttribute.find { + it.attribute('key') == 'org.eclipse.jdt.launching.PROGRAM_ARGUMENTS' + } + String arguments = programArguments.attribute('value') + String quoted = arguments.replaceAll(eclipseLauncherPath) { match, option, path -> + path.startsWith('"') ? match : option + '"' + path + '"' + } + if (quoted != arguments) { + programArguments.attributes().put('value', quoted) + launch.setText(XmlUtil.serialize(configuration), 'UTF-8') + } + } +} +eclipse { synchronizationTasks 'genEclipseRuns' } + +tasks.register('verifyEclipseLaunchArguments') { + group = 'verification' + description = 'Checks that generated Eclipse launcher paths stay intact when they contain spaces.' + dependsOn 'genEclipseRuns' + doLast { + ['runClient', 'runServer', 'runTestClient', 'runTestServer'].each { name -> + Node launch = new XmlParser().parse(file(name + '.launch')) + String arguments = launch.stringAttribute.find { + it.attribute('key') == 'org.eclipse.jdt.launching.PROGRAM_ARGUMENTS' + }.attribute('value') + ['cache', 'metadata', 'to-srg', 'to-obf'].each { flag -> + def path = arguments =~ /(?:^| )--${flag} "([^"]+)"/ + if (!path.find() || !file(path.group(1)).exists()) { + throw new GradleException("${name} needs a quoted, existing --${flag} path") + } + } + } + } +} +tasks.named('check') { dependsOn 'verifyEclipseLaunchArguments' } +tasks.named('eclipse') { dependsOn 'verifyEclipseLaunchArguments', stageRunClasses } tasks.named('processResources', ProcessResources) { inputs.property 'version', project.version diff --git a/docs/BUILDING.md b/docs/BUILDING.md index b40e05a..9c520c2 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -13,14 +13,23 @@ checked by SHA-256. It remains optional when playing. .\gradlew.bat check build genEclipseRuns eclipse "-PlegacyDependencyVerificationRepository=" On a configured machine, add --offline to rebuild from the same cache. -The reobfuscated player jar is build/libs/BaseMinerals-2.5.1.113021.jar. +The reobfuscated player jar is build/libs/BaseMinerals-2.5.2.113021.jar. Development output lives under build/libs-dev. Sources and Javadocs are separate. Import the inner checkout as an Eclipse Gradle project. The generated client and server launch files use the Java 8 game toolchain and staged mod output. +Gradle refresh regenerates them with quoted paths for checkouts containing spaces. For a terminal launch, use runClient or runServer. Use the published Base Metals jar with the packaged Forge profile when checking Crack Hammer integration. The test runners in tools/validation/legacy113 use an independently installed Forge server template. Install requirements.txt from that directory for the Anvil and NBT checks. + +Build the separate survival-mining test mod with packagedMiningProbeJar, then +run verify_mining.py --help for the packaged-server options. Add --processing +to check furnace and crushing recipes as well. Run with Base Minerals alone, +with Base Metals, with Modern Metals, and with both hammer mods. The probe +checks normal drops, Fortune, Silk Touch, weak tools, hammer drops, block +properties, fluid light and smith offers. Its jar stays under build/test-mods +and must not be installed in a normal game. diff --git a/gradle.properties b/gradle.properties index ddc1987..cbdc905 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ org.gradle.parallel=false net.minecraftforge.gradle.merge-source-sets=false minecraft_version=1.13.2 forge_version=25.0.223 -mod_version=2.5.1.113021 +mod_version=2.5.2.113021 diff --git a/gradle/release-113.gradle b/gradle/release-113.gradle index ddfe894..5892a4b 100644 --- a/gradle/release-113.gradle +++ b/gradle/release-113.gradle @@ -57,6 +57,7 @@ def audit = { File directory -> String path = entry.name.toLowerCase(Locale.ROOT) if (path.contains('agent-notes') || path.contains('agents.md') || path.contains('.codex') || path.startsWith('tools/') || path.startsWith('reference/') || path.contains('/testmod/') + || path.startsWith('test/') || path.contains('mineralminingprobe') || path.startsWith('com/mcmoddev/lib/') || path.startsWith('zone/moddev/mc/mmdlib/') || path.startsWith('zone/moddev/mc/basemetals/') || path.startsWith('com/mcmoddev/orespawn/') || path.startsWith('net/minecraft/') || path.startsWith('org/junit/')) { diff --git a/src/main/java/zone/moddev/mc/baseminerals/BaseMinerals.java b/src/main/java/zone/moddev/mc/baseminerals/BaseMinerals.java index ec1ec95..f85f222 100644 --- a/src/main/java/zone/moddev/mc/baseminerals/BaseMinerals.java +++ b/src/main/java/zone/moddev/mc/baseminerals/BaseMinerals.java @@ -10,6 +10,7 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import zone.moddev.mc.baseminerals.client.MineralFluidRenderer; import zone.moddev.mc.baseminerals.recipe.SharedCrushingSerializer; +import zone.moddev.mc.baseminerals.trade.MineralTrades; import zone.moddev.mc.baseminerals.worldgen.BaseMineralsWorldgenProvider; @Mod(BaseMinerals.MOD_ID) @@ -23,7 +24,10 @@ public BaseMinerals() { } private void setup(FMLCommonSetupEvent event) { - DeferredWorkQueue.runLater(() -> RecipeSerializers.register(new SharedCrushingSerializer())); + DeferredWorkQueue.runLater(() -> { + RecipeSerializers.register(new SharedCrushingSerializer()); + MineralTrades.register(); + }); } private void enqueueProvider(InterModEnqueueEvent event) { diff --git a/src/main/java/zone/moddev/mc/baseminerals/content/MineralContent.java b/src/main/java/zone/moddev/mc/baseminerals/content/MineralContent.java index f9aceac..e3edeb8 100644 --- a/src/main/java/zone/moddev/mc/baseminerals/content/MineralContent.java +++ b/src/main/java/zone/moddev/mc/baseminerals/content/MineralContent.java @@ -2,8 +2,10 @@ import java.util.LinkedHashMap; import java.util.Map; +import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockFlowingFluid; +import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.fluid.FlowingFluid; @@ -16,13 +18,18 @@ import net.minecraft.init.Items; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.IItemProvider; +import net.minecraft.util.math.BlockPos; import net.minecraft.util.registry.IRegistry; +import net.minecraft.world.IWorldReader; +import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ToolType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.registries.ForgeRegistries; import zone.moddev.mc.baseminerals.BaseMinerals; /** Registry names are kept from the 1.10–1.12 builds. */ @@ -58,12 +65,12 @@ private static void initializeFluids() { public static void registerBlocks(RegistryEvent.Register event) { initializeFluids(); for (String name : MATERIALS) { - putBlock(event, name + "_block", new MineralBlock(false)); - if (!"silicon".equals(name)) putBlock(event, name + "_ore", new MineralBlock(true)); + putBlock(event, name + "_block", new MineralBlock(name, false)); + if (!"silicon".equals(name)) putBlock(event, name + "_ore", new MineralBlock(name, true)); } MOLTEN.forEach((name, molten) -> { molten.block = new BlockFlowingFluid(molten.source, Block.Properties.create(Material.LAVA) - .doesNotBlockMovement().hardnessAndResistance(100.0F).variableOpacity()) {}; + .doesNotBlockMovement().hardnessAndResistance(100.0F).lightValue(10).variableOpacity()) {}; putBlock(event, name, molten.block); }); } @@ -109,14 +116,44 @@ static final class Molten { private static final class MineralBlock extends Block { private final boolean ore; + private final int harvestLevel; + private final ResourceLocation powder; - MineralBlock(boolean ore) { - super(Block.Properties.create(Material.ROCK).hardnessAndResistance(3.0F, 5.0F)); + MineralBlock(String material, boolean ore) { + super(properties(material, ore)); this.ore = ore; + this.harvestLevel = isMetal(material) ? 2 : 1; + this.powder = ore && !isMetal(material) ? id(material + "_powder") : null; + } + + private static boolean isMetal(String material) { + return "lithium".equals(material) || "silicon".equals(material); + } + + private static Block.Properties properties(String material, boolean ore) { + boolean metal = isMetal(material); + float hardness = ore ? 5.0F : metal ? 16.0F : 10.0F; + // The old library stored resistance at five times Minecraft's exposed value. + float resistance = (metal ? 4.0F : 1.0F) * (ore ? 0.75F : 1.0F); + return Block.Properties.create(metal && !ore ? Material.IRON : Material.ROCK) + .sound(metal && !ore ? SoundType.METAL : SoundType.STONE) + .hardnessAndResistance(hardness, resistance); } @Override public ToolType getHarvestTool(IBlockState state) { return ToolType.PICKAXE; } - @Override public int getHarvestLevel(IBlockState state) { return 1; } + @Override public int getHarvestLevel(IBlockState state) { return harvestLevel; } + @Override public IItemProvider getItemDropped(IBlockState state, World world, BlockPos pos, int fortune) { + return powder == null ? this : ForgeRegistries.ITEMS.getValue(powder); + } + @Override public int quantityDropped(IBlockState state, Random random) { + return getItemsToDropCount(state, 0, null, BlockPos.ORIGIN, random); + } + @Override public int getItemsToDropCount(IBlockState state, int fortune, World world, BlockPos pos, Random random) { + return powder == null ? 1 : 2 + random.nextInt(3 + fortune); + } + @Override public boolean isBeaconBase(IBlockState state, IWorldReader world, BlockPos pos, BlockPos beacon) { + return !ore; + } @Override @OnlyIn(Dist.CLIENT) public BlockRenderLayer getRenderLayer() { return ore ? BlockRenderLayer.CUTOUT_MIPPED : BlockRenderLayer.SOLID; diff --git a/src/main/java/zone/moddev/mc/baseminerals/trade/MineralTrades.java b/src/main/java/zone/moddev/mc/baseminerals/trade/MineralTrades.java new file mode 100644 index 0000000..6685a31 --- /dev/null +++ b/src/main/java/zone/moddev/mc/baseminerals/trade/MineralTrades.java @@ -0,0 +1,26 @@ +package zone.moddev.mc.baseminerals.trade; + +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraft.village.MerchantRecipe; +import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; +import net.minecraftforge.registries.ForgeRegistries; + +/** The old shared library offered one ingot for four or five emeralds at smith level two. */ +public final class MineralTrades { + private MineralTrades() {} + + public static void register() { + VillagerProfession smith = ForgeRegistries.VILLAGER_PROFESSIONS.getValue( + new ResourceLocation("minecraft", "smith")); + for (int career = 1; career <= 3; career++) { + for (String material : new String[] {"lithium", "silicon"}) { + Item ingot = ForgeRegistries.ITEMS.getValue(new ResourceLocation("baseminerals", material + "_ingot")); + smith.getCareer(career).addTrade(2, (merchant, recipes, random) -> recipes.add( + new MerchantRecipe(new ItemStack(Items.EMERALD, 4 + random.nextInt(2)), new ItemStack(ingot)))); + } + } + } +} diff --git a/src/main/resources/data/baseminerals/recipes/lithium_block_crushing.json b/src/main/resources/data/baseminerals/recipes/lithium_block_crushing.json new file mode 100644 index 0000000..4986fc5 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/lithium_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/lithium" + }, + "result": { + "item": "baseminerals:lithium_powder", + "count": 9 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/lithium_ingot_crushing.json b/src/main/resources/data/baseminerals/recipes/lithium_ingot_crushing.json new file mode 100644 index 0000000..059d216 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/lithium_ingot_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:ingots/lithium" + }, + "result": { + "item": "baseminerals:lithium_powder", + "count": 1 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/lithium_nugget_crushing.json b/src/main/resources/data/baseminerals/recipes/lithium_nugget_crushing.json new file mode 100644 index 0000000..6f3af30 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/lithium_nugget_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:nuggets/lithium" + }, + "result": { + "item": "baseminerals:lithium_smallpowder", + "count": 1 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/lithium_ore_smelting.json b/src/main/resources/data/baseminerals/recipes/lithium_ore_smelting.json new file mode 100644 index 0000000..c2e720c --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/lithium_ore_smelting.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "baseminerals:lithium_ore" + }, + "result": "baseminerals:lithium_ingot", + "experience": 0.45, + "cookingtime": 200 +} diff --git a/src/main/resources/data/baseminerals/recipes/lithium_powder_smelting.json b/src/main/resources/data/baseminerals/recipes/lithium_powder_smelting.json new file mode 100644 index 0000000..de5a1f5 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/lithium_powder_smelting.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "baseminerals:lithium_powder" + }, + "result": "baseminerals:lithium_ingot", + "experience": 0.45, + "cookingtime": 200 +} diff --git a/src/main/resources/data/baseminerals/recipes/lithium_smallpowder_smelting.json b/src/main/resources/data/baseminerals/recipes/lithium_smallpowder_smelting.json new file mode 100644 index 0000000..2ae5c5e --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/lithium_smallpowder_smelting.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "baseminerals:lithium_smallpowder" + }, + "result": "baseminerals:lithium_nugget", + "experience": 0.05, + "cookingtime": 200 +} diff --git a/src/main/resources/data/baseminerals/recipes/niter_block_crushing.json b/src/main/resources/data/baseminerals/recipes/niter_block_crushing.json new file mode 100644 index 0000000..b955a1b --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/niter_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/niter" + }, + "result": { + "item": "baseminerals:niter_powder", + "count": 9 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/phosphorus_block_crushing.json b/src/main/resources/data/baseminerals/recipes/phosphorus_block_crushing.json new file mode 100644 index 0000000..f06f3bf --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/phosphorus_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/phosphorus" + }, + "result": { + "item": "baseminerals:phosphorus_powder", + "count": 9 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/potash_block_crushing.json b/src/main/resources/data/baseminerals/recipes/potash_block_crushing.json new file mode 100644 index 0000000..383a4ba --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/potash_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/potash" + }, + "result": { + "item": "baseminerals:potash_powder", + "count": 9 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/salt_block_crushing.json b/src/main/resources/data/baseminerals/recipes/salt_block_crushing.json new file mode 100644 index 0000000..22ad3e1 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/salt_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/salt" + }, + "result": { + "item": "baseminerals:salt_powder", + "count": 9 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/saltpeter_block_crushing.json b/src/main/resources/data/baseminerals/recipes/saltpeter_block_crushing.json new file mode 100644 index 0000000..2bf9cfa --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/saltpeter_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/saltpeter" + }, + "result": { + "item": "baseminerals:saltpeter_powder", + "count": 9 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/silicon_blend_smelting.json b/src/main/resources/data/baseminerals/recipes/silicon_blend_smelting.json new file mode 100644 index 0000000..3320528 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/silicon_blend_smelting.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "baseminerals:silicon_blend" + }, + "result": "baseminerals:silicon_ingot", + "experience": 0.45, + "cookingtime": 200 +} diff --git a/src/main/resources/data/baseminerals/recipes/silicon_block_crushing.json b/src/main/resources/data/baseminerals/recipes/silicon_block_crushing.json new file mode 100644 index 0000000..2beeff1 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/silicon_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/silicon" + }, + "result": { + "item": "baseminerals:silicon_powder", + "count": 9 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/silicon_ingot_crushing.json b/src/main/resources/data/baseminerals/recipes/silicon_ingot_crushing.json new file mode 100644 index 0000000..1812643 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/silicon_ingot_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:ingots/silicon" + }, + "result": { + "item": "baseminerals:silicon_powder", + "count": 1 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/silicon_nugget_crushing.json b/src/main/resources/data/baseminerals/recipes/silicon_nugget_crushing.json new file mode 100644 index 0000000..5ca34e5 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/silicon_nugget_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:nuggets/silicon" + }, + "result": { + "item": "baseminerals:silicon_smallpowder", + "count": 1 + } +} diff --git a/src/main/resources/data/baseminerals/recipes/silicon_powder_smelting.json b/src/main/resources/data/baseminerals/recipes/silicon_powder_smelting.json index 879f1a8..ace8050 100644 --- a/src/main/resources/data/baseminerals/recipes/silicon_powder_smelting.json +++ b/src/main/resources/data/baseminerals/recipes/silicon_powder_smelting.json @@ -4,6 +4,6 @@ "item": "baseminerals:silicon_powder" }, "result": "baseminerals:silicon_ingot", - "experience": 0, + "experience": 0.45, "cookingtime": 200 } diff --git a/src/main/resources/data/baseminerals/recipes/silicon_smallblend_smelting.json b/src/main/resources/data/baseminerals/recipes/silicon_smallblend_smelting.json new file mode 100644 index 0000000..4b07462 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/silicon_smallblend_smelting.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "baseminerals:silicon_smallblend" + }, + "result": "baseminerals:silicon_nugget", + "experience": 0.05, + "cookingtime": 200 +} diff --git a/src/main/resources/data/baseminerals/recipes/silicon_smallpowder_smelting.json b/src/main/resources/data/baseminerals/recipes/silicon_smallpowder_smelting.json new file mode 100644 index 0000000..e2c90ae --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/silicon_smallpowder_smelting.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:smelting", + "ingredient": { + "item": "baseminerals:silicon_smallpowder" + }, + "result": "baseminerals:silicon_nugget", + "experience": 0.05, + "cookingtime": 200 +} diff --git a/src/main/resources/data/baseminerals/recipes/sulfur_block_crushing.json b/src/main/resources/data/baseminerals/recipes/sulfur_block_crushing.json new file mode 100644 index 0000000..f456018 --- /dev/null +++ b/src/main/resources/data/baseminerals/recipes/sulfur_block_crushing.json @@ -0,0 +1,25 @@ +{ + "type": "baseminerals:shared_crushing", + "conditions": [ + { + "type": "forge:or", + "values": [ + { + "type": "forge:mod_loaded", + "modid": "basemetals" + }, + { + "type": "forge:mod_loaded", + "modid": "modernmetals" + } + ] + } + ], + "ingredient": { + "tag": "forge:storage_blocks/sulfur" + }, + "result": { + "item": "baseminerals:sulfur_powder", + "count": 9 + } +} diff --git a/tools/validation/legacy113/mining-probe/java/test/MineralMiningProbe.java b/tools/validation/legacy113/mining-probe/java/test/MineralMiningProbe.java new file mode 100644 index 0000000..2c254f4 --- /dev/null +++ b/tools/validation/legacy113/mining-probe/java/test/MineralMiningProbe.java @@ -0,0 +1,271 @@ +package test; + +import com.google.gson.GsonBuilder; +import com.google.gson.JsonObject; +import com.mojang.authlib.GameProfile; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import net.minecraft.block.Block; +import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.init.Enchantments; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.FurnaceRecipe; +import net.minecraft.item.crafting.IRecipe; +import net.minecraft.inventory.InventoryBasic; +import net.minecraft.network.EnumPacketDirection; +import net.minecraft.network.NetHandlerPlayServer; +import net.minecraft.network.NetworkManager; +import net.minecraft.util.EnumHand; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.world.GameType; +import net.minecraft.world.WorldServer; +import net.minecraft.world.dimension.DimensionType; +import net.minecraft.village.MerchantRecipe; +import net.minecraft.village.MerchantRecipeList; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.event.server.FMLServerStartedEvent; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession; + +/** Exercises the installed jar through real survival harvesting. */ +@Mod("mineralminingprobe") +public final class MineralMiningProbe { + private static final String[] MINERALS = { + "lithium", "niter", "phosphorus", "potash", "salt", "saltpeter", "sulfur" + }; + private final List failures = new ArrayList<>(); + private final JsonObject drops = new JsonObject(); + private WorldServer world; + private FakePlayer player; + private int checks; + private int harvestIndex; + + public MineralMiningProbe() { MinecraftForge.EVENT_BUS.addListener(this::started); } + + private void started(FMLServerStartedEvent event) { + world = event.getServer().getWorld(DimensionType.OVERWORLD); + player = new FakePlayer(world, new GameProfile(UUID.randomUUID(), "MineralMiningProbe")); + new NetHandlerPlayServer(event.getServer(), new NetworkManager(EnumPacketDirection.SERVERBOUND), player); + player.interactionManager.setGameType(GameType.SURVIVAL); + player.onGround = true; + try { + for (String mineral : MINERALS) { + Block ore = block(mineral + "_ore"); + boolean lithium = "lithium".equals(mineral); + for (int fortune = 0; fortune <= 3; fortune++) { + ItemStack pickaxe = new ItemStack(Items.DIAMOND_PICKAXE); + if (fortune > 0) pickaxe.addEnchantment(Enchantments.FORTUNE, fortune); + int count = harvest(ore, pickaxe, item(mineral + (lithium ? "_ore" : "_powder"))); + check(lithium ? count == 1 : count >= 2 && count <= 4 + fortune, + mineral + " Fortune " + fortune + " yielded " + count); + drops.addProperty(mineral + ":fortune" + fortune, count); + IBlockState state = ore.getDefaultState(); + for (int sample = 0; sample < 256; sample++) { + Random random = new Random(sample); + int expected = lithium ? 1 : 2 + new Random(sample).nextInt(3 + fortune); + check(ore.getItemsToDropCount(state, fortune, world, BlockPos.ORIGIN, random) == expected, + mineral + " has different Fortune distribution at " + fortune); + } + } + ItemStack silk = new ItemStack(Items.DIAMOND_PICKAXE); + silk.addEnchantment(Enchantments.SILK_TOUCH, 1); + check(harvest(ore, silk, item(mineral + "_ore")) == 1, + mineral + " Silk Touch did not return one ore"); + check(harvest(ore, new ItemStack(Items.WOODEN_PICKAXE), null) == 0, + mineral + " dropped with an inadequate pickaxe"); + if (lithium) { + check(harvest(ore, new ItemStack(Items.STONE_PICKAXE), null) == 0, + "Lithium requires an iron-level pickaxe"); + } + check(ore.getExpDrop(ore.getDefaultState(), world, BlockPos.ORIGIN, 3) == 0, + mineral + " added mining XP"); + blockProperties(ore, 5.0F, lithium ? 3.0F : 0.75F, lithium ? 2 : 1, false); + } + for (String mineral : new String[] {"lithium", "niter", "phosphorus", "potash", "salt", + "saltpeter", "silicon", "sulfur"}) { + Block storage = block(mineral + "_block"); + check(harvest(storage, new ItemStack(Items.DIAMOND_PICKAXE), item(mineral + "_block")) == 1, + mineral + " storage-block drop changed"); + boolean metal = "lithium".equals(mineral) || "silicon".equals(mineral); + blockProperties(storage, metal ? 16.0F : 10.0F, metal ? 4.0F : 1.0F, metal ? 2 : 1, true); + } + if (Boolean.getBoolean("mineralprobe.processing")) { + processingRecipes(); + smithOffers(); + for (String material : new String[] {"lithium", "silicon"}) { + check(block(material).getDefaultState().getLightValue() == 10, material + " lost molten-fluid light"); + } + } + for (String owner : new String[] {"basemetals", "modernmetals"}) { + if (!ModList.get().isLoaded(owner)) continue; + ResourceLocation hammerId = new ResourceLocation(owner, + "basemetals".equals(owner) ? "iron_crackhammer" : "galvanizedsteel_crackhammer"); + check(ForgeRegistries.ITEMS.containsKey(hammerId), "Missing test hammer " + hammerId); + for (String mineral : MINERALS) { + ItemStack hammer = new ItemStack(ForgeRegistries.ITEMS.getValue(hammerId)); + int count = harvest(block(mineral + "_ore"), hammer, item(mineral + "_powder")); + check(count == 2 && hammer.getDamage() == 1, + owner + " hammer yielded " + count + " " + mineral + " powders, damage " + hammer.getDamage()); + } + if (Boolean.getBoolean("mineralprobe.processing")) { + for (String mineral : new String[] {"lithium", "niter", "phosphorus", "potash", "salt", + "saltpeter", "silicon", "sulfur"}) { + ItemStack hammer = new ItemStack(ForgeRegistries.ITEMS.getValue(hammerId)); + check(harvest(block(mineral + "_block"), hammer, item(mineral + "_powder")) == 9, + owner + " hammer did not crush " + mineral + " storage block to nine powders"); + check(hammer.getDamage() == 1, owner + " storage-block crushing did not damage hammer"); + } + } + } + } catch (Throwable error) { + failures.add(error.toString()); + error.printStackTrace(); + } finally { + JsonObject report = new JsonObject(); + report.addProperty("passed", failures.isEmpty()); + report.addProperty("checks", checks); + report.add("drops", drops); + report.add("failures", new com.google.gson.Gson().toJsonTree(failures)); + try { + Files.write(Paths.get("mining-results.json"), + new GsonBuilder().setPrettyPrinting().create().toJson(report).getBytes(StandardCharsets.UTF_8)); + } catch (java.io.IOException error) { + throw new IllegalStateException(error); + } finally { + System.out.println("MINERAL_MINING_PROBE " + (failures.isEmpty() ? "PASS" : "FAIL") + " checks=" + checks); + event.getServer().initiateShutdown(); + } + } + } + + private void blockProperties(Block block, float hardness, float resistance, int harvestLevel, boolean beacon) { + IBlockState state = block.getDefaultState(); + check(state.getBlockHardness(world, BlockPos.ORIGIN) == hardness, + block.getRegistryName() + " changed mining hardness"); + check(block.getExplosionResistance() == resistance, block.getRegistryName() + " changed blast resistance"); + check(state.getHarvestLevel() == harvestLevel, block.getRegistryName() + " changed harvest tier"); + check(block.isBeaconBase(state, world, BlockPos.ORIGIN, BlockPos.ORIGIN) == beacon, + block.getRegistryName() + " changed beacon support"); + } + + private void processingRecipes() { + for (String material : new String[] {"lithium", "silicon"}) { + furnace(material + "_powder", material + "_ingot", 0.45F); + furnace(material + "_smallpowder", material + "_nugget", 0.05F); + } + furnace("lithium_ore", "lithium_ingot", 0.45F); + furnace("silicon_blend", "silicon_ingot", 0.45F); + furnace("silicon_smallblend", "silicon_nugget", 0.05F); + boolean crushingLoaded = ModList.get().isLoaded("basemetals") || ModList.get().isLoaded("modernmetals"); + for (String material : new String[] {"lithium", "niter", "phosphorus", "potash", "salt", + "saltpeter", "silicon", "sulfur"}) { + crusher(material + "_block", material + "_powder", 9, crushingLoaded); + } + for (String material : new String[] {"lithium", "silicon"}) { + crusher(material + "_ingot", material + "_powder", 1, crushingLoaded); + crusher(material + "_nugget", material + "_smallpowder", 1, crushingLoaded); + } + } + + private void smithOffers() { + VillagerProfession smith = ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation("minecraft:smith")); + EntityVillager merchant = new EntityVillager(world); + for (int career = 1; career <= 3; career++) { + for (int seed = 0; seed < 32; seed++) { + MerchantRecipeList offers = new MerchantRecipeList(); + for (EntityVillager.ITradeList trade : smith.getCareer(career).getTrades(1)) { + trade.addMerchantRecipe(merchant, offers, new Random(seed)); + } + for (String material : new String[] {"lithium", "silicon"}) { + int matches = 0; + for (MerchantRecipe offer : offers) { + if (offer.getItemToSell().getItem() != item(material + "_ingot")) continue; + matches++; + check(offer.getItemToSell().getCount() == 1 && offer.getItemToBuy().getItem() == Items.EMERALD + && offer.getItemToBuy().getCount() >= 4 && offer.getItemToBuy().getCount() <= 5, + material + " smith offer changed"); + } + check(matches == 1, "Career " + career + " has " + matches + " " + material + " offers"); + } + } + } + } + + private void furnace(String input, String output, float xp) { + InventoryBasic inventory = new InventoryBasic(new TextComponentString("smelting"), 1); + inventory.setInventorySlotContents(0, new ItemStack(item(input))); + List matches = new ArrayList<>(); + for (IRecipe recipe : world.getRecipeManager().getRecipes()) { + if (recipe instanceof FurnaceRecipe && recipe.matches(inventory, world)) matches.add(recipe); + } + check(matches.size() == 1, input + " has " + matches.size() + " furnace recipes"); + for (IRecipe recipe : matches) { + ItemStack result = recipe.getRecipeOutput(); + check(result.getItem() == item(output) && result.getCount() == 1, input + " smelts to " + result); + check(((FurnaceRecipe) recipe).getExperience() == xp, input + " changed smelting XP"); + } + } + + private void crusher(String input, String output, int count, boolean enabled) { + InventoryBasic inventory = new InventoryBasic(new TextComponentString("crushing"), 1); + inventory.setInventorySlotContents(0, new ItemStack(item(input))); + List matches = new ArrayList<>(); + for (IRecipe recipe : world.getRecipeManager().getRecipes()) { + if ("crushing".equals(recipe.getSerializer().getName().getPath()) && recipe.matches(inventory, world)) { + matches.add(recipe); + } + } + check(matches.size() == (enabled ? 1 : 0), input + " has " + matches.size() + " crushing recipes"); + for (IRecipe recipe : matches) { + check(recipe.getRecipeOutput().getItem() == item(output) && recipe.getRecipeOutput().getCount() == count, + input + " crushes to " + recipe.getRecipeOutput()); + } + } + + private int harvest(Block block, ItemStack tool, Item expected) { + int index = harvestIndex++; + BlockPos pos = new BlockPos(128 + (index % 16) * 3, 180 + (index / 16) * 4, 128); + AxisAlignedBB area = new AxisAlignedBB(pos).grow(0.45); + world.getEntitiesWithinAABB(EntityItem.class, area).forEach(EntityItem::remove); + world.setBlockState(pos, block.getDefaultState(), 3); + player.setHeldItem(EnumHand.MAIN_HAND, tool); + player.interactionManager.tryHarvestBlock(pos); + int count = 0; + for (EntityItem drop : world.getEntitiesWithinAABB(EntityItem.class, area)) { + check(drop.getItem().getItem() == expected, + block.getRegistryName() + " dropped " + drop.getItem().getItem().getRegistryName()); + count += drop.getItem().getCount(); + drop.remove(); + } + world.removeBlock(pos); + return count; + } + + private static Block block(String name) { + return ForgeRegistries.BLOCKS.getValue(new ResourceLocation("baseminerals", name)); + } + + private static Item item(String name) { + return ForgeRegistries.ITEMS.getValue(new ResourceLocation("baseminerals", name)); + } + + private void check(boolean condition, String detail) { + checks++; + if (!condition) failures.add(detail); + } +} diff --git a/tools/validation/legacy113/mining-probe/resources/META-INF/mods.toml b/tools/validation/legacy113/mining-probe/resources/META-INF/mods.toml new file mode 100644 index 0000000..2ad76d3 --- /dev/null +++ b/tools/validation/legacy113/mining-probe/resources/META-INF/mods.toml @@ -0,0 +1,12 @@ +modLoader="javafml" +loaderVersion="[25,)" +[[mods]] +modId="mineralminingprobe" +version="1" +displayName="Base Minerals mining checks" +[[dependencies.mineralminingprobe]] +modId="baseminerals" +mandatory=true +versionRange="[2.5.1.113021,)" +ordering="AFTER" +side="BOTH" diff --git a/tools/validation/legacy113/mining-probe/resources/pack.mcmeta b/tools/validation/legacy113/mining-probe/resources/pack.mcmeta new file mode 100644 index 0000000..d583eef --- /dev/null +++ b/tools/validation/legacy113/mining-probe/resources/pack.mcmeta @@ -0,0 +1 @@ +{"pack":{"pack_format":4,"description":"Base Minerals mining test fixture"}} diff --git a/tools/validation/legacy113/verify_mining.py b/tools/validation/legacy113/verify_mining.py new file mode 100644 index 0000000..9e66dc4 --- /dev/null +++ b/tools/validation/legacy113/verify_mining.py @@ -0,0 +1,39 @@ +"""Run the isolated survival-mining probe against a packaged Base Minerals jar.""" +import argparse +import hashlib +import json +from pathlib import Path +import subprocess + +from run_forge import LAUNCHER, prepare + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + for name in ("java", "runtime", "output", "probe"): + parser.add_argument("--" + name, type=Path, required=True) + parser.add_argument("--mods", nargs="+", type=Path, required=True) + parser.add_argument("--processing", action="store_true") + args = parser.parse_args() + jars = [*args.mods, args.probe] + prepare(args.runtime, args.output, jars) + (args.output / "input-jars.json").write_text(json.dumps({ + jar.name: hashlib.sha256(jar.read_bytes()).hexdigest() for jar in jars + }, indent=2)) + with (args.output / "console.log").open("wb") as stream: + command = [str(args.java), "-Xmx2G"] + if args.processing: + command.append("-Dmineralprobe.processing=true") + result = subprocess.run([*command, "-jar", LAUNCHER, "nogui"], + cwd=args.output, stdout=stream, stderr=subprocess.STDOUT, timeout=240) + report = json.loads((args.output / "mining-results.json").read_text()) + log = (args.output / "console.log").read_text(encoding="utf-8", errors="replace") + for failure in ("Encountered an unexpected exception", "Error occurred applying transform of coremod", + "Couldn't read loot table baseminerals:", "Parsing error loading recipe baseminerals:"): + assert failure not in log, f"Forge startup error: {failure}" + print(args.output.name, "PASS" if report["passed"] else "FAIL", report["checks"], "checks", flush=True) + assert result.returncode == 0 and report["passed"], report["failures"][:12] + + +if __name__ == "__main__": + main()