From df6156518c9ea2bfd6b12c3d5d19d468d63e9995 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Mon, 15 Jan 2024 13:37:00 +0000 Subject: [PATCH 1/6] .locate command support added for 1.18-1.20.4 --- build.gradle | 7 +- .../rejects/commands/LocateCommand.java | 104 ++++++++++++------ .../anticope/rejects/utils/WorldGenUtils.java | 17 ++- 3 files changed, 93 insertions(+), 35 deletions(-) diff --git a/build.gradle b/build.gradle index 951e56f6..8f0e3755 100644 --- a/build.gradle +++ b/build.gradle @@ -16,14 +16,19 @@ repositories { maven { url "https://maven.seedfinding.com/" } maven { url "https://maven-snapshots.seedfinding.com/" } maven { url 'https://jitpack.io' } + maven { url 'https://maven.duti.dev/releases' } } - configurations { // configuration that holds jars to include in the jar extraLibs } dependencies { + // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. + extraLibs('dev.duti.acheong:cubiomes:1.21.4') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.21.4:linux64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.21.4:osx') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.21.4:windows64') { transitive = false } // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_version}:v2" diff --git a/src/main/java/anticope/rejects/commands/LocateCommand.java b/src/main/java/anticope/rejects/commands/LocateCommand.java index b1d131e2..89b6ba5f 100644 --- a/src/main/java/anticope/rejects/commands/LocateCommand.java +++ b/src/main/java/anticope/rejects/commands/LocateCommand.java @@ -2,8 +2,12 @@ import anticope.rejects.arguments.EnumArgumentType; import anticope.rejects.utils.WorldGenUtils; +import anticope.rejects.utils.seeds.Seeds; + import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.exceptions.DynamicCommandExceptionType; +import com.seedfinding.mccore.version.MCVersion; + import meteordevelopment.meteorclient.commands.Command; import meteordevelopment.meteorclient.utils.Utils; import meteordevelopment.meteorclient.utils.player.ChatUtils; @@ -12,43 +16,77 @@ import net.minecraft.text.Text; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import cubitect.Cubiomes; +import cubitect.Cubiomes.Pos; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; import static meteordevelopment.meteorclient.MeteorClient.mc; public class LocateCommand extends Command { - private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> { - if (o instanceof WorldGenUtils.Feature) { - return Text.literal(String.format( - "%s not found.", - Utils.nameToTitle(o.toString().replaceAll("_", "-"))) - ); - } - return Text.literal("Not found."); - }); - - public LocateCommand() { - super("locate", "Locates structures.", "loc"); - } - - @Override - public void build(LiteralArgumentBuilder builder) { - builder.then(literal("feature").then(argument("feature", EnumArgumentType.enumArgument(WorldGenUtils.Feature.stronghold)).executes(ctx -> { - WorldGenUtils.Feature feature = EnumArgumentType.getEnum(ctx, "feature", WorldGenUtils.Feature.stronghold); - BlockPos pos = WorldGenUtils.locateFeature(feature, mc.player.getBlockPos()); - if (pos != null) { - MutableText text = Text.literal(String.format( - "%s located at ", - Utils.nameToTitle(feature.toString().replaceAll("_", "-")) - )); - Vec3d coords = new Vec3d(pos.getX(), pos.getY(), pos.getZ()); - text.append(ChatUtils.formatCoords(coords)); - text.append("."); - info(text); - return SINGLE_SUCCESS; - } - throw NOT_FOUND.create(feature); - }))); - } + private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> { + if (o instanceof Cubiomes.StructureType) { + return Text.literal(String.format( + "%s not found.", + Utils.nameToTitle(o.toString().replaceAll("_", "-")))); + } + return Text.literal("Not found."); + }); + + public LocateCommand() { + super("locate", "Locates structures.", "loc"); + } + + @Override + public void build(LiteralArgumentBuilder builder) { + builder.then(literal("feature") + .then(argument("feature", EnumArgumentType.enumArgument(Cubiomes.StructureType.Village)).executes(ctx -> { + Cubiomes.StructureType feature = EnumArgumentType.getEnum(ctx, "feature", Cubiomes.StructureType.Village); + BlockPos playerPos = mc.player.getBlockPos(); + long seed = Seeds.get().getSeed().seed; + MCVersion version = Seeds.get().getSeed().version; + Cubiomes.MCVersion cubiomesVersion = null; + if (version.isNewerOrEqualTo(MCVersion.v1_20)) { + cubiomesVersion = Cubiomes.MCVersion.MC_1_20; + } else if (version.isNewerOrEqualTo(MCVersion.v1_19)) { + switch (version) { + case v1_19: + case v1_19_1: + cubiomesVersion = Cubiomes.MCVersion.MC_1_19; + break; + case v1_19_2: + case v1_19_3: + case v1_19_4: + cubiomesVersion = Cubiomes.MCVersion.MC_1_19_2; + break; + default: + throw new IllegalStateException("Unexpected value: " + version); + } + } else if (version.isNewerOrEqualTo(MCVersion.v1_18)) { + cubiomesVersion = Cubiomes.MCVersion.MC_1_18; + } + Pos pos = null; + if (cubiomesVersion != null) { + pos = Cubiomes.GetNearestStructure(feature, playerPos.getX(), playerPos.getZ(), seed, + Cubiomes.MCVersion.MC_1_20, 8); + } else { + BlockPos bpos = WorldGenUtils.locateFeature(feature, playerPos); + pos = new Pos(); + pos.x = bpos.getX(); + pos.z = bpos.getZ(); + + } + if (pos != null) { + MutableText text = Text.literal(String.format( + "%s located at ", + Utils.nameToTitle(feature.toString().replaceAll("_", "-")))); + Vec3d coords = new Vec3d(pos.x, 0, pos.z); + text.append(ChatUtils.formatCoords(coords)); + text.append("."); + info(text); + return SINGLE_SUCCESS; + } + throw NOT_FOUND.create(feature); + }))); + } } diff --git a/src/main/java/anticope/rejects/utils/WorldGenUtils.java b/src/main/java/anticope/rejects/utils/WorldGenUtils.java index d34ba83a..eae3db2b 100644 --- a/src/main/java/anticope/rejects/utils/WorldGenUtils.java +++ b/src/main/java/anticope/rejects/utils/WorldGenUtils.java @@ -3,6 +3,8 @@ import anticope.rejects.utils.seeds.Seed; import anticope.rejects.utils.seeds.Seeds; import baritone.api.BaritoneAPI; +import cubitect.Cubiomes; + import com.seedfinding.mcbiome.source.BiomeSource; import com.seedfinding.mcfeature.misc.SlimeChunk; import com.seedfinding.mcfeature.structure.*; @@ -126,7 +128,20 @@ public enum Feature { desert_pyramid } - public static BlockPos locateFeature(Feature feature, BlockPos center) { + public static BlockPos locateFeature(Cubiomes.StructureType cfeature, BlockPos center) { + Feature feature = switch (cfeature) { + case Treasure -> Feature.buried_treasure; + case Mansion -> Feature.mansion; + case Stronghold -> Feature.stronghold; + case Fortress -> Feature.nether_fortress; + case Monument -> Feature.ocean_monument; + case Bastion -> Feature.bastion_remnant; + case End_City -> Feature.end_city; + case Village -> Feature.village; + case Mineshaft -> Feature.mineshaft; + case Desert_Pyramid -> Feature.desert_pyramid; + default -> null; + }; Seed seed = Seeds.get().getSeed(); BlockPos pos = null; if (!checkIfInDimension(getDimension(feature))) { From 14c0b1a11ba9036111ef38a437cef01edabc77e0 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Tue, 16 Jan 2024 03:07:36 +0000 Subject: [PATCH 2/6] Improve search algorithm (spiral search) and improve accuracy of stronghold search. Also remember to actually use cubiomesVersion rather than hard coding MC_1_20 --- build.gradle | 8 ++++---- .../java/anticope/rejects/commands/LocateCommand.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 8f0e3755..006656c3 100644 --- a/build.gradle +++ b/build.gradle @@ -25,10 +25,10 @@ configurations { dependencies { // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. - extraLibs('dev.duti.acheong:cubiomes:1.21.4') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.21.4:linux64') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.21.4:osx') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.21.4:windows64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.0') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.0:linux64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.0:osx') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.0:windows64') { transitive = false } // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_version}:v2" diff --git a/src/main/java/anticope/rejects/commands/LocateCommand.java b/src/main/java/anticope/rejects/commands/LocateCommand.java index 89b6ba5f..2533133d 100644 --- a/src/main/java/anticope/rejects/commands/LocateCommand.java +++ b/src/main/java/anticope/rejects/commands/LocateCommand.java @@ -68,7 +68,7 @@ public void build(LiteralArgumentBuilder builder) { Pos pos = null; if (cubiomesVersion != null) { pos = Cubiomes.GetNearestStructure(feature, playerPos.getX(), playerPos.getZ(), seed, - Cubiomes.MCVersion.MC_1_20, 8); + cubiomesVersion); } else { BlockPos bpos = WorldGenUtils.locateFeature(feature, playerPos); pos = new Pos(); From b9c1ec1403476dacc533bbbdd4518d787ea94c37 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Tue, 16 Jan 2024 03:39:09 +0000 Subject: [PATCH 3/6] add slime chunk support (just a dep bump) --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 006656c3..c85d55fc 100644 --- a/build.gradle +++ b/build.gradle @@ -25,10 +25,10 @@ configurations { dependencies { // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. - extraLibs('dev.duti.acheong:cubiomes:1.22.0') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.0:linux64') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.0:osx') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.0:windows64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.1') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.1:linux64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.1:osx') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.1:windows64') { transitive = false } // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_version}:v2" From 2994d3061c02186e382fbc71b6ae8c1a8e76ce11 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Wed, 17 Jan 2024 05:55:58 +0000 Subject: [PATCH 4/6] fix end city locator and include distance in notification --- build.gradle | 8 ++++---- .../java/anticope/rejects/commands/LocateCommand.java | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index c85d55fc..afdc612b 100644 --- a/build.gradle +++ b/build.gradle @@ -25,10 +25,10 @@ configurations { dependencies { // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. - extraLibs('dev.duti.acheong:cubiomes:1.22.1') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.1:linux64') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.1:osx') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.1:windows64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2:linux64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2:osx') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.2:windows64') { transitive = false } // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_version}:v2" diff --git a/src/main/java/anticope/rejects/commands/LocateCommand.java b/src/main/java/anticope/rejects/commands/LocateCommand.java index 2533133d..0fb3e0e3 100644 --- a/src/main/java/anticope/rejects/commands/LocateCommand.java +++ b/src/main/java/anticope/rejects/commands/LocateCommand.java @@ -77,12 +77,17 @@ public void build(LiteralArgumentBuilder builder) { } if (pos != null) { + // Calculate distance + int distance = (int) Math.hypot(pos.x - playerPos.getX(), pos.z - playerPos.getZ()); MutableText text = Text.literal(String.format( "%s located at ", Utils.nameToTitle(feature.toString().replaceAll("_", "-")))); Vec3d coords = new Vec3d(pos.x, 0, pos.z); text.append(ChatUtils.formatCoords(coords)); text.append("."); + if (distance > 0) { + text.append(String.format(" (%d blocks away)", distance)); + } info(text); return SINGLE_SUCCESS; } From 61e8cf06c73a8b096411b2bb9177ed6f57de0061 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Fri, 8 Mar 2024 00:57:01 +0000 Subject: [PATCH 5/6] fix OreSim meteor-client breaking changes --- src/main/java/anticope/rejects/modules/OreSim.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/anticope/rejects/modules/OreSim.java b/src/main/java/anticope/rejects/modules/OreSim.java index d8f2e55a..6e137893 100755 --- a/src/main/java/anticope/rejects/modules/OreSim.java +++ b/src/main/java/anticope/rejects/modules/OreSim.java @@ -212,8 +212,7 @@ private void reload() { @EventHandler public void onChunkData(ChunkDataEvent event) { - doMathOnChunk(event.chunk); - ChunkDataEvent.returnChunkDataEvent(event); + doMathOnChunk(event.chunk()); } private void doMathOnChunk(Chunk chunk) { From 5357d01cb1b9beb1b88461424192c65a962be934 Mon Sep 17 00:00:00 2001 From: Antonio Cheong Date: Fri, 8 Mar 2024 01:58:14 +0000 Subject: [PATCH 6/6] bump cubiomes dependency: Add Java 17 support --- build.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index afdc612b..d5fe24cf 100644 --- a/build.gradle +++ b/build.gradle @@ -25,10 +25,10 @@ configurations { dependencies { // This will make it work on most platforms. It automatically chooses the right dependencies at runtime. - extraLibs('dev.duti.acheong:cubiomes:1.22.2') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.2:linux64') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.2:osx') { transitive = false } - extraLibs('dev.duti.acheong:cubiomes:1.22.2:windows64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.3') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.3:linux64') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.3:osx') { transitive = false } + extraLibs('dev.duti.acheong:cubiomes:1.22.3:windows64') { transitive = false } // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" mappings "net.fabricmc:yarn:${project.yarn_version}:v2"