Fixed ore sim not working with emerald

This commit is contained in:
2025-11-02 01:51:30 -03:00
parent 4a822e773c
commit 8fc798ee94
2 changed files with 48 additions and 14 deletions

View File

@@ -17,7 +17,9 @@ import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.player.PlayerUtils; import meteordevelopment.meteorclient.utils.player.PlayerUtils;
import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.BlockState;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKey;
import net.minecraft.util.math.*; import net.minecraft.util.math.*;
import net.minecraft.util.math.random.ChunkRandom; import net.minecraft.util.math.random.ChunkRandom;
@@ -62,6 +64,13 @@ public class OreSim extends Module {
.build() .build()
); );
private final Setting<Boolean> 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<Boolean> baritone = sgGeneral.add(new BoolSetting.Builder() private final Setting<Boolean> baritone = sgGeneral.add(new BoolSetting.Builder()
.name("baritone") .name("baritone")
.description("Set baritone ore positions to the simulated ones.") .description("Set baritone ore positions to the simulated ones.")
@@ -270,9 +279,9 @@ public class OreSim extends Module {
} }
if (ore.scattered) { if (ore.scattered) {
ores.addAll(generateHidden(world, random, origin, ore.size)); ores.addAll(generateHidden(world, random, origin, ore.size, ore));
} else { } 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()) { 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<Vec3d> generateNormal(ClientWorld world, ChunkRandom random, BlockPos blockPos, int veinSize, float discardOnAir) { private ArrayList<Vec3d> generateNormal(ClientWorld world, ChunkRandom random, BlockPos blockPos, int veinSize, float discardOnAir, Ore ore) {
float f = random.nextFloat() * 3.1415927F; float f = random.nextFloat() * 3.1415927F;
float g = (float) veinSize / 8.0F; float g = (float) veinSize / 8.0F;
int i = MathHelper.ceil(((float) veinSize / 16.0F * 2.0F + 1.0F) / 2.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 s = n; s <= n + q; ++s) {
for (int t = p; t <= p + q; ++t) { for (int t = p; t <= p + q; ++t) {
if (o <= world.getTopY(Heightmap.Type.MOTION_BLOCKING, s, 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<>(); return new ArrayList<>();
} }
private ArrayList<Vec3d> 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<Vec3d> 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); BitSet bitSet = new BitSet(size * i * size);
BlockPos.Mutable mutable = new BlockPos.Mutable(); BlockPos.Mutable mutable = new BlockPos.Mutable();
@@ -393,9 +414,15 @@ public class OreSim extends Module {
if (!bitSet.get(an)) { if (!bitSet.get(an)) {
bitSet.set(an); bitSet.set(an);
mutable.set(ah, aj, al); mutable.set(ah, aj, al);
if (aj >= -64 && aj < 320 && (airCheck.get() == AirCheck.OFF || world.getBlockState(mutable).isOpaque())) { if (aj >= -64 && aj < 320) {
if (shouldPlace(world, mutable, discardOnAir, random)) { BlockState state = world.getBlockState(mutable);
poses.add(new Vec3d(ah, aj, al)); 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; return true;
} }
private ArrayList<Vec3d> generateHidden(ClientWorld world, ChunkRandom random, BlockPos blockPos, int size) { private ArrayList<Vec3d> generateHidden(ClientWorld world, ChunkRandom random, BlockPos blockPos, int size, Ore ore) {
ArrayList<Vec3d> poses = new ArrayList<>(); ArrayList<Vec3d> poses = new ArrayList<>();
@@ -435,8 +462,14 @@ public class OreSim extends Module {
int x = this.randomCoord(random, size) + blockPos.getX(); int x = this.randomCoord(random, size) + blockPos.getX();
int y = this.randomCoord(random, size) + blockPos.getY(); int y = this.randomCoord(random, size) + blockPos.getY();
int z = this.randomCoord(random, size) + blockPos.getZ(); int z = this.randomCoord(random, size) + blockPos.getZ();
if (airCheck.get() == AirCheck.OFF || world.getBlockState(new BlockPos(x, y, z)).isOpaque()) { BlockPos pos = new BlockPos(x, y, z);
if (shouldPlace(world, new BlockPos(x, y, z), 1F, random)) { 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)); poses.add(new Vec3d(x, y, z));
} }
} }
@@ -448,4 +481,4 @@ public class OreSim extends Module {
private int randomCoord(ChunkRandom random, int size) { private int randomCoord(ChunkRandom random, int size) {
return Math.round((random.nextFloat() - random.nextFloat()) * (float) size); return Math.round((random.nextFloat() - random.nextFloat()) * (float) size);
} }
} }

View File

@@ -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.", "description": "An addon to Meteor Client that adds modules and commands that were too useless to be added to Meteor directly.",
"authors": [ "authors": [
"Cloudburst", "Cloudburst",
"StormyBytes" "StormyBytes",
"Morpheus Nox"
], ],
"contact": { "contact": {
"issues": "https://github.com/AntiCope/meteor-rejects/issues", "issues": "https://github.com/AntiCope/meteor-rejects/issues",