Skip to content

Commit a7c00c1

Browse files
committed
.locate command support added for 1.18-1.20.4
1 parent bf6f7c5 commit a7c00c1

File tree

3 files changed

+93
-35
lines changed

3 files changed

+93
-35
lines changed

build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,19 @@ repositories {
1616
maven { url "https://maven.seedfinding.com/" }
1717
maven { url "https://maven-snapshots.seedfinding.com/" }
1818
maven { url 'https://jitpack.io' }
19+
maven { url 'https://maven.duti.dev/releases' }
1920
}
20-
2121
configurations {
2222
// configuration that holds jars to include in the jar
2323
extraLibs
2424
}
2525

2626
dependencies {
27+
// This will make it work on most platforms. It automatically chooses the right dependencies at runtime.
28+
extraLibs('dev.duti.acheong:cubiomes:1.21.4') { transitive = false }
29+
extraLibs('dev.duti.acheong:cubiomes:1.21.4:linux64') { transitive = false }
30+
extraLibs('dev.duti.acheong:cubiomes:1.21.4:osx') { transitive = false }
31+
extraLibs('dev.duti.acheong:cubiomes:1.21.4:windows64') { transitive = false }
2732
// To change the versions see the gradle.properties file
2833
minecraft "com.mojang:minecraft:${project.minecraft_version}"
2934
mappings "net.fabricmc:yarn:${project.yarn_version}:v2"

src/main/java/anticope/rejects/commands/LocateCommand.java

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import anticope.rejects.arguments.EnumArgumentType;
44
import anticope.rejects.utils.WorldGenUtils;
5+
import anticope.rejects.utils.seeds.Seeds;
6+
57
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
68
import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
9+
import com.seedfinding.mccore.version.MCVersion;
10+
711
import meteordevelopment.meteorclient.commands.Command;
812
import meteordevelopment.meteorclient.utils.Utils;
913
import meteordevelopment.meteorclient.utils.player.ChatUtils;
@@ -12,43 +16,77 @@
1216
import net.minecraft.text.Text;
1317
import net.minecraft.util.math.BlockPos;
1418
import net.minecraft.util.math.Vec3d;
19+
import cubitect.Cubiomes;
20+
import cubitect.Cubiomes.Pos;
1521

1622
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
1723
import static meteordevelopment.meteorclient.MeteorClient.mc;
1824

1925
public class LocateCommand extends Command {
2026

21-
private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> {
22-
if (o instanceof WorldGenUtils.Feature) {
23-
return Text.literal(String.format(
24-
"%s not found.",
25-
Utils.nameToTitle(o.toString().replaceAll("_", "-")))
26-
);
27-
}
28-
return Text.literal("Not found.");
29-
});
30-
31-
public LocateCommand() {
32-
super("locate", "Locates structures.", "loc");
33-
}
34-
35-
@Override
36-
public void build(LiteralArgumentBuilder<CommandSource> builder) {
37-
builder.then(literal("feature").then(argument("feature", EnumArgumentType.enumArgument(WorldGenUtils.Feature.stronghold)).executes(ctx -> {
38-
WorldGenUtils.Feature feature = EnumArgumentType.getEnum(ctx, "feature", WorldGenUtils.Feature.stronghold);
39-
BlockPos pos = WorldGenUtils.locateFeature(feature, mc.player.getBlockPos());
40-
if (pos != null) {
41-
MutableText text = Text.literal(String.format(
42-
"%s located at ",
43-
Utils.nameToTitle(feature.toString().replaceAll("_", "-"))
44-
));
45-
Vec3d coords = new Vec3d(pos.getX(), pos.getY(), pos.getZ());
46-
text.append(ChatUtils.formatCoords(coords));
47-
text.append(".");
48-
info(text);
49-
return SINGLE_SUCCESS;
50-
}
51-
throw NOT_FOUND.create(feature);
52-
})));
53-
}
27+
private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> {
28+
if (o instanceof Cubiomes.StructureType) {
29+
return Text.literal(String.format(
30+
"%s not found.",
31+
Utils.nameToTitle(o.toString().replaceAll("_", "-"))));
32+
}
33+
return Text.literal("Not found.");
34+
});
35+
36+
public LocateCommand() {
37+
super("locate", "Locates structures.", "loc");
38+
}
39+
40+
@Override
41+
public void build(LiteralArgumentBuilder<CommandSource> builder) {
42+
builder.then(literal("feature")
43+
.then(argument("feature", EnumArgumentType.enumArgument(Cubiomes.StructureType.Village)).executes(ctx -> {
44+
Cubiomes.StructureType feature = EnumArgumentType.getEnum(ctx, "feature", Cubiomes.StructureType.Village);
45+
BlockPos playerPos = mc.player.getBlockPos();
46+
long seed = Seeds.get().getSeed().seed;
47+
MCVersion version = Seeds.get().getSeed().version;
48+
Cubiomes.MCVersion cubiomesVersion = null;
49+
if (version.isNewerOrEqualTo(MCVersion.v1_20)) {
50+
cubiomesVersion = Cubiomes.MCVersion.MC_1_20;
51+
} else if (version.isNewerOrEqualTo(MCVersion.v1_19)) {
52+
switch (version) {
53+
case v1_19:
54+
case v1_19_1:
55+
cubiomesVersion = Cubiomes.MCVersion.MC_1_19;
56+
break;
57+
case v1_19_2:
58+
case v1_19_3:
59+
case v1_19_4:
60+
cubiomesVersion = Cubiomes.MCVersion.MC_1_19_2;
61+
break;
62+
default:
63+
throw new IllegalStateException("Unexpected value: " + version);
64+
}
65+
} else if (version.isNewerOrEqualTo(MCVersion.v1_18)) {
66+
cubiomesVersion = Cubiomes.MCVersion.MC_1_18;
67+
}
68+
Pos pos = null;
69+
if (cubiomesVersion != null) {
70+
pos = Cubiomes.GetNearestStructure(feature, playerPos.getX(), playerPos.getZ(), seed,
71+
Cubiomes.MCVersion.MC_1_20, 8);
72+
} else {
73+
BlockPos bpos = WorldGenUtils.locateFeature(feature, playerPos);
74+
pos = new Pos();
75+
pos.x = bpos.getX();
76+
pos.z = bpos.getZ();
77+
78+
}
79+
if (pos != null) {
80+
MutableText text = Text.literal(String.format(
81+
"%s located at ",
82+
Utils.nameToTitle(feature.toString().replaceAll("_", "-"))));
83+
Vec3d coords = new Vec3d(pos.x, 0, pos.z);
84+
text.append(ChatUtils.formatCoords(coords));
85+
text.append(".");
86+
info(text);
87+
return SINGLE_SUCCESS;
88+
}
89+
throw NOT_FOUND.create(feature);
90+
})));
91+
}
5492
}

src/main/java/anticope/rejects/utils/WorldGenUtils.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import anticope.rejects.utils.seeds.Seed;
44
import anticope.rejects.utils.seeds.Seeds;
55
import baritone.api.BaritoneAPI;
6+
import cubitect.Cubiomes;
7+
68
import com.seedfinding.mcbiome.source.BiomeSource;
79
import com.seedfinding.mcfeature.misc.SlimeChunk;
810
import com.seedfinding.mcfeature.structure.*;
@@ -126,7 +128,20 @@ public enum Feature {
126128
desert_pyramid
127129
}
128130

129-
public static BlockPos locateFeature(Feature feature, BlockPos center) {
131+
public static BlockPos locateFeature(Cubiomes.StructureType cfeature, BlockPos center) {
132+
Feature feature = switch (cfeature) {
133+
case Treasure -> Feature.buried_treasure;
134+
case Mansion -> Feature.mansion;
135+
case Stronghold -> Feature.stronghold;
136+
case Fortress -> Feature.nether_fortress;
137+
case Monument -> Feature.ocean_monument;
138+
case Bastion -> Feature.bastion_remnant;
139+
case End_City -> Feature.end_city;
140+
case Village -> Feature.village;
141+
case Mineshaft -> Feature.mineshaft;
142+
case Desert_Pyramid -> Feature.desert_pyramid;
143+
default -> null;
144+
};
130145
Seed seed = Seeds.get().getSeed();
131146
BlockPos pos = null;
132147
if (!checkIfInDimension(getDimension(feature))) {

0 commit comments

Comments
 (0)