Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import static de.rettichlp.ucutils.UCUtils.renderService;
import static de.rettichlp.ucutils.UCUtils.storage;
import static de.rettichlp.ucutils.UCUtils.utilService;
import static java.lang.Integer.parseInt;
import static java.util.Objects.nonNull;
import static java.util.Optional.ofNullable;
import static java.util.regex.Pattern.compile;
Expand All @@ -39,6 +40,7 @@ public class CarListener
private static final Pattern CAR_UNLOCK_PATTERN = compile("^\\[Car] Du hast deinen .+ aufgeschlossen\\.$");
private static final Pattern CAR_LOCK_PATTERN = compile("^\\[Car] Du hast deinen .+ abgeschlossen\\.$");
private static final Pattern CAR_LOCKED_OWN_PATTERN = compile("^\\[Car] Dein Fahrzeug ist abgeschlossen\\.$");
private static final Pattern CAR_FIND_PATTERN = compile("^\\[Car] Das Fahrzeug befindet sich bei » X: (?<x>\\d+) \\| Y: (?<y>\\d+) \\| Z: (?<z>\\d+)$");

@Override
public void onEnterVehicle(Entity vehicle) {
Expand Down Expand Up @@ -66,7 +68,7 @@ public void onEntityRender(WorldRenderContext context) {
VertexConsumerProvider vertexConsumers = context.consumers();
ClientWorld world = MinecraftClient.getInstance().world;

if (nonNull(matrices) && nonNull(vertexConsumers) && nonNull(world) && configuration.getOptions().car().highlight()) {
if (world != null && configuration.getOptions().car().highlight()) {
ofNullable(storage.getMinecartEntityToHighlight())
.map(minecartEntity -> world.getEntityById(minecartEntity.getId()))
.ifPresent(minecartEntity -> renderService.renderTextAboveEntity(matrices, vertexConsumers, minecartEntity, Text.of("🚗").copy().formatted(AQUA), 0.05F));
Expand All @@ -93,6 +95,15 @@ public boolean onMessageReceive(Text text, String message) {
return true;
}

Matcher carFindMatcher = CAR_FIND_PATTERN.matcher(message);
if (carFindMatcher.find()) {
int x = parseInt(carFindMatcher.group("x"));
int y = parseInt(carFindMatcher.group("y"));
int z = parseInt(carFindMatcher.group("z"));
commandService.sendCommand("navi " + x + "/" + y + "/" + z);
return true;
}

return true;
}

Expand Down