From 8fc798ee9496f964e9532fb823e6ac530ddccb92 Mon Sep 17 00:00:00 2001 From: morpheus Date: Sun, 2 Nov 2025 01:51:30 -0300 Subject: [PATCH] Fixed ore sim not working with emerald --- .../java/anticope/rejects/modules/OreSim.java | 59 +++++++++++++++---- src/main/resources/fabric.mod.json | 3 +- 2 files changed, 48 insertions(+), 14 deletions(-) diff --git a/src/main/java/anticope/rejects/modules/OreSim.java b/src/main/java/anticope/rejects/modules/OreSim.java index 6e13789..beec71e 100755 --- a/src/main/java/anticope/rejects/modules/OreSim.java +++ b/src/main/java/anticope/rejects/modules/OreSim.java @@ -17,7 +17,9 @@ import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.BlockState; import net.minecraft.client.world.ClientWorld; +import net.minecraft.registry.Registries; import net.minecraft.registry.RegistryKey; import net.minecraft.util.math.*; import net.minecraft.util.math.random.ChunkRandom; @@ -62,6 +64,13 @@ public class OreSim extends Module { .build() ); + private final Setting verifyOreBlocks = sgGeneral.add(new BoolSetting.Builder() + .name("verify-ore-blocks") + .description("Only show positions where actual ore blocks exist (recommended for accuracy).") + .defaultValue(true) + .build() + ); + private final Setting baritone = sgGeneral.add(new BoolSetting.Builder() .name("baritone") .description("Set baritone ore positions to the simulated ones.") @@ -270,9 +279,9 @@ public class OreSim extends Module { } if (ore.scattered) { - ores.addAll(generateHidden(world, random, origin, ore.size)); + ores.addAll(generateHidden(world, random, origin, ore.size, ore)); } else { - ores.addAll(generateNormal(world, random, origin, ore.size, ore.discardOnAirChance)); + ores.addAll(generateNormal(world, random, origin, ore.size, ore.discardOnAirChance, ore)); } } if (!ores.isEmpty()) { @@ -290,11 +299,23 @@ public class OreSim extends Module { } } + // Helper method to check if a block state is an ore + private boolean isOreBlock(BlockState state, Ore ore) { + if (!verifyOreBlocks.get()) { + return true; // Skip verification if disabled + } + + String blockId = Registries.BLOCK.getId(state.getBlock()).toString(); + + // Check for ore blocks - handles coal_ore, deepslate_coal_ore, emerald_ore, etc. + return blockId.contains("_ore") || blockId.contains("ancient_debris"); + } + // ==================================== - // Mojang code + // Mojang code (modified) // ==================================== - private ArrayList generateNormal(ClientWorld world, ChunkRandom random, BlockPos blockPos, int veinSize, float discardOnAir) { + private ArrayList generateNormal(ClientWorld world, ChunkRandom random, BlockPos blockPos, int veinSize, float discardOnAir, Ore ore) { float f = random.nextFloat() * 3.1415927F; float g = (float) veinSize / 8.0F; int i = MathHelper.ceil(((float) veinSize / 16.0F * 2.0F + 1.0F) / 2.0F); @@ -313,7 +334,7 @@ public class OreSim extends Module { for (int s = n; s <= n + q; ++s) { for (int t = p; t <= p + q; ++t) { if (o <= world.getTopY(Heightmap.Type.MOTION_BLOCKING, s, t)) { - return this.generateVeinPart(world, random, veinSize, d, e, h, j, l, m, n, o, p, q, r, discardOnAir); + return this.generateVeinPart(world, random, veinSize, d, e, h, j, l, m, n, o, p, q, r, discardOnAir, ore); } } } @@ -321,7 +342,7 @@ public class OreSim extends Module { return new ArrayList<>(); } - private ArrayList generateVeinPart(ClientWorld world, ChunkRandom random, int veinSize, double startX, double endX, double startZ, double endZ, double startY, double endY, int x, int y, int z, int size, int i, float discardOnAir) { + private ArrayList generateVeinPart(ClientWorld world, ChunkRandom random, int veinSize, double startX, double endX, double startZ, double endZ, double startY, double endY, int x, int y, int z, int size, int i, float discardOnAir, Ore ore) { BitSet bitSet = new BitSet(size * i * size); BlockPos.Mutable mutable = new BlockPos.Mutable(); @@ -393,9 +414,15 @@ public class OreSim extends Module { if (!bitSet.get(an)) { bitSet.set(an); mutable.set(ah, aj, al); - if (aj >= -64 && aj < 320 && (airCheck.get() == AirCheck.OFF || world.getBlockState(mutable).isOpaque())) { - if (shouldPlace(world, mutable, discardOnAir, random)) { - poses.add(new Vec3d(ah, aj, al)); + if (aj >= -64 && aj < 320) { + BlockState state = world.getBlockState(mutable); + boolean passesAirCheck = airCheck.get() == AirCheck.OFF || state.isOpaque(); + boolean passesOreCheck = isOreBlock(state, ore); + + if (passesAirCheck && passesOreCheck) { + if (shouldPlace(world, mutable, discardOnAir, random)) { + poses.add(new Vec3d(ah, aj, al)); + } } } } @@ -424,7 +451,7 @@ public class OreSim extends Module { return true; } - private ArrayList generateHidden(ClientWorld world, ChunkRandom random, BlockPos blockPos, int size) { + private ArrayList generateHidden(ClientWorld world, ChunkRandom random, BlockPos blockPos, int size, Ore ore) { ArrayList poses = new ArrayList<>(); @@ -435,8 +462,14 @@ public class OreSim extends Module { int x = this.randomCoord(random, size) + blockPos.getX(); int y = this.randomCoord(random, size) + blockPos.getY(); int z = this.randomCoord(random, size) + blockPos.getZ(); - if (airCheck.get() == AirCheck.OFF || world.getBlockState(new BlockPos(x, y, z)).isOpaque()) { - if (shouldPlace(world, new BlockPos(x, y, z), 1F, random)) { + BlockPos pos = new BlockPos(x, y, z); + BlockState state = world.getBlockState(pos); + + boolean passesAirCheck = airCheck.get() == AirCheck.OFF || state.isOpaque(); + boolean passesOreCheck = isOreBlock(state, ore); + + if (passesAirCheck && passesOreCheck) { + if (shouldPlace(world, pos, 1F, random)) { poses.add(new Vec3d(x, y, z)); } } @@ -448,4 +481,4 @@ public class OreSim extends Module { private int randomCoord(ChunkRandom random, int size) { return Math.round((random.nextFloat() - random.nextFloat()) * (float) size); } -} +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9d16aea..219871b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -7,7 +7,8 @@ "description": "An addon to Meteor Client that adds modules and commands that were too useless to be added to Meteor directly.", "authors": [ "Cloudburst", - "StormyBytes" + "StormyBytes", + "Morpheus Nox" ], "contact": { "issues": "https://github.com/AntiCope/meteor-rejects/issues",