|
2 | 2 |
|
3 | 3 | import anticope.rejects.arguments.EnumArgumentType;
|
4 | 4 | import anticope.rejects.utils.WorldGenUtils;
|
| 5 | +import anticope.rejects.utils.seeds.Seeds; |
| 6 | + |
5 | 7 | import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
6 | 8 | import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
| 9 | +import com.seedfinding.mccore.version.MCVersion; |
| 10 | + |
7 | 11 | import meteordevelopment.meteorclient.commands.Command;
|
8 | 12 | import meteordevelopment.meteorclient.utils.Utils;
|
9 | 13 | import meteordevelopment.meteorclient.utils.player.ChatUtils;
|
|
12 | 16 | import net.minecraft.text.Text;
|
13 | 17 | import net.minecraft.util.math.BlockPos;
|
14 | 18 | import net.minecraft.util.math.Vec3d;
|
| 19 | +import cubitect.Cubiomes; |
| 20 | +import cubitect.Cubiomes.Pos; |
15 | 21 |
|
16 | 22 | import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
|
17 | 23 | import static meteordevelopment.meteorclient.MeteorClient.mc;
|
18 | 24 |
|
19 | 25 | public class LocateCommand extends Command {
|
20 | 26 |
|
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 | + } |
54 | 92 | }
|
0 commit comments