Skip to content

Commit 5c140d3

Browse files
committed
Meteor integration
1 parent d711c0a commit 5c140d3

5 files changed

Lines changed: 193 additions & 7 deletions

File tree

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ repositories {
1414
name "TerraformersMC"
1515
url "https://maven.terraformersmc.com/releases"
1616
}
17+
maven {
18+
name "Meteor - Releases"
19+
url "https://maven.meteordev.org/releases"
20+
}
21+
maven {
22+
name "Meteor - Snapshots"
23+
url "https://maven.meteordev.org/snapshots"
24+
}
1725
}
1826

1927
dependencies {
@@ -25,6 +33,8 @@ dependencies {
2533
include "me.shedaniel.cloth:cloth-config-fabric:12.0.109"
2634

2735
modApi "com.terraformersmc:modmenu:8.0.0-beta.2"
36+
37+
modCompileOnly "meteordevelopment:meteor-client:0.5.5-SNAPSHOT"
2838
}
2939

3040
loom {
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
package meteordevelopment.voyager;
2+
3+
import meteordevelopment.meteorclient.pathing.IPathManager;
4+
import meteordevelopment.meteorclient.settings.*;
5+
import meteordevelopment.meteorclient.utils.render.color.Color;
6+
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
7+
import meteordevelopment.voyager.goals.DirectionGoal;
8+
import meteordevelopment.voyager.goals.XYZGoal;
9+
import meteordevelopment.voyager.goals.XZGoal;
10+
import net.minecraft.block.Block;
11+
import net.minecraft.entity.Entity;
12+
import net.minecraft.util.math.BlockPos;
13+
import org.apache.commons.lang3.NotImplementedException;
14+
15+
import java.util.HashMap;
16+
import java.util.Map;
17+
import java.util.function.Predicate;
18+
19+
@SuppressWarnings("unused")
20+
public class PathManager implements IPathManager {
21+
private final VoyagerSettings settings = new VoyagerSettings();
22+
23+
@Override
24+
public String getName() {
25+
return "Voyager";
26+
}
27+
28+
@Override
29+
public boolean isPathing() {
30+
return Voyager.INSTANCE.isMoving();
31+
}
32+
33+
@Override
34+
public void pause() {
35+
}
36+
37+
@Override
38+
public void resume() {
39+
}
40+
41+
@Override
42+
public void stop() {
43+
Voyager.INSTANCE.stop();
44+
}
45+
46+
@Override
47+
public void moveTo(BlockPos pos, boolean ignoreY) {
48+
if (ignoreY) {
49+
Voyager.INSTANCE.moveTo(new XZGoal(pos.getX(), pos.getY()));
50+
return;
51+
}
52+
53+
Voyager.INSTANCE.moveTo(new XYZGoal(pos));
54+
}
55+
56+
@Override
57+
public void moveInDirection(float yaw) {
58+
Voyager.INSTANCE.moveTo(new DirectionGoal(yaw));
59+
}
60+
61+
@Override
62+
public void mine(Block... blocks) {
63+
}
64+
65+
@Override
66+
public void follow(Predicate<Entity> predicate) {
67+
for (Entity entity : Voyager.mc.world.getEntities()) {
68+
if (predicate.test(entity)) {
69+
Voyager.INSTANCE.moveTo(new XYZGoal(entity.getBlockPos()));
70+
return;
71+
}
72+
}
73+
}
74+
75+
@Override
76+
public float getTargetYaw() {
77+
if (Voyager.mc.player.input instanceof VInput input)
78+
return input.getYaw(1);
79+
80+
return 0;
81+
}
82+
83+
@Override
84+
public float getTargetPitch() {
85+
return isPathing() ? Voyager.mc.player.getPitch() : 0;
86+
}
87+
88+
@Override
89+
public ISettings getSettings() {
90+
return settings;
91+
}
92+
93+
private static class VoyagerSettings implements ISettings {
94+
private final Settings settings = new Settings();
95+
private final Setting<Boolean> setting = new BoolSetting.Builder().build();
96+
97+
@SuppressWarnings({"rawtypes", "unchecked"})
98+
public VoyagerSettings() {
99+
Map<String, SettingGroup> groups = new HashMap<>();
100+
101+
for (var setting : Voyager.INSTANCE.getSettings().settings) {
102+
SettingGroup group = groups.computeIfAbsent(setting.category, settings::createGroup);
103+
104+
if (setting instanceof meteordevelopment.voyager.settings.BoolSetting s) {
105+
group.add(new BoolSetting.Builder()
106+
.name(s.name)
107+
.description(s.description)
108+
.defaultValue(s.getDefaultValue())
109+
.onChanged(s::set)
110+
.onModuleActivated(booleanSetting -> booleanSetting.set(s.get()))
111+
.build());
112+
}
113+
else if (setting instanceof meteordevelopment.voyager.settings.EnumSetting s) {
114+
group.add(new EnumSetting.Builder<>()
115+
.name(s.name)
116+
.description(s.description)
117+
.defaultValue((Enum<?>) s.getDefaultValue())
118+
.onChanged(anEnum -> s.set(anEnum))
119+
.onModuleActivated(booleanSetting -> booleanSetting.set((Enum<?>) s.get()))
120+
.build());
121+
}
122+
else if (setting instanceof meteordevelopment.voyager.settings.StringSetting s) {
123+
group.add(new StringSetting.Builder()
124+
.name(s.name)
125+
.description(s.description)
126+
.defaultValue(s.getDefaultValue())
127+
.onChanged(s::set)
128+
.onModuleActivated(stringSetting -> stringSetting.set(s.get()))
129+
.build());
130+
}
131+
else if (setting instanceof meteordevelopment.voyager.settings.ColorSetting s) {
132+
group.add(new ColorSetting.Builder()
133+
.name(s.name)
134+
.description(s.description)
135+
.defaultValue(new Color(s.getDefaultValue().pack()))
136+
.onChanged(settingColor -> s.set(new meteordevelopment.voyager.utils.Color(settingColor.getPacked())))
137+
.onModuleActivated(settingColorSetting -> settingColorSetting.set(new SettingColor(s.get().pack())))
138+
.build());
139+
}
140+
else {
141+
throw new NotImplementedException();
142+
}
143+
}
144+
}
145+
146+
@Override
147+
public Settings get() {
148+
return settings;
149+
}
150+
151+
@Override
152+
public Setting<Boolean> getWalkOnWater() {
153+
return setting;
154+
}
155+
156+
@Override
157+
public Setting<Boolean> getWalkOnLava() {
158+
return setting;
159+
}
160+
161+
@Override
162+
public Setting<Boolean> getStep() {
163+
return setting;
164+
}
165+
166+
@Override
167+
public Setting<Boolean> getNoFall() {
168+
return setting;
169+
}
170+
171+
@Override
172+
public void save() {
173+
Voyager.INSTANCE.getSettings().save();
174+
}
175+
}
176+
}

src/main/java/meteordevelopment/voyager/commands/ThiswayCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected void build(LiteralArgumentBuilder<CommandSource> builder) {
2424
}));
2525

2626
builder.executes(context -> {
27-
Voyager.INSTANCE.moveTo(new DirectionGoal(mc.player));
27+
Voyager.INSTANCE.moveTo(new DirectionGoal(mc.player.getYaw()));
2828
return SUCCESS;
2929
});
3030
}

src/main/java/meteordevelopment/voyager/goals/DirectionGoal.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package meteordevelopment.voyager.goals;
22

3-
import net.minecraft.entity.Entity;
3+
import meteordevelopment.voyager.Voyager;
44

55
public class DirectionGoal implements IGoal {
66
private final double yaw;
77
private int x, z;
88

9-
public DirectionGoal(Entity entity) {
10-
this.x = (int) Math.floor(entity.getX());
11-
this.z = (int) Math.floor(entity.getZ());
12-
this.yaw = Math.toRadians(entity.getYaw());
9+
public DirectionGoal(float yaw) {
10+
this.x = (int) Math.floor(Voyager.mc.player.getX());
11+
this.z = (int) Math.floor(Voyager.mc.player.getZ());
12+
this.yaw = Math.toRadians(yaw);
1313

1414
recalculate();
1515
}

src/main/java/meteordevelopment/voyager/settings/Settings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class Settings {
2323
private final File file;
24-
private final List<Setting<?>> settings = new ArrayList<>();
24+
public final List<Setting<?>> settings = new ArrayList<>();
2525

2626
public Settings(File file) {
2727
this.file = file;

0 commit comments

Comments
 (0)