Skip to content
This repository has been archived by the owner on Jun 30, 2024. It is now read-only.

Commit

Permalink
using x, y, and z replaces for player coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
RealRTTV committed Jul 1, 2022
1 parent 30f7ed3 commit fc80d82
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/main/java/ca/rttv/chatcalc/MathEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,31 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.LiteralTextContent;
import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import org.slf4j.Logger;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class MathEngine {
public static final Logger LOGGER = LogUtils.getLogger();

public static double eval(String input) {
input = input.toLowerCase().replaceAll("pi", "3.141592653589793").replaceAll("\\*\\*", "^").replaceAll("(?!c)e(?!il)", "2.718281828459045").replaceAll(",(?! )", "");
MinecraftClient client = MinecraftClient.getInstance();
input = input.toLowerCase()
.replaceAll("pi", "3.141592653589793")
.replaceAll("\\*\\*", "^").replaceAll("(?!c)e(?!il)", "2.718281828459045")
.replaceAll(",(?! )", "");
if (client.player != null) {
input = input.replaceAll("x", String.valueOf(client.player.getX()))
.replaceAll("y", String.valueOf(client.player.getY()))
.replaceAll("z", String.valueOf(client.player.getZ()));
}
List<Token> tokens = new ArrayList<>(input.length()); // array of custom objects which do different things each
Optional<Class<? extends Token>> currentType = Optional.empty();
StringBuilder sb = new StringBuilder();
MinecraftClient client = MinecraftClient.getInstance();

for (int i = 0; i < input.length(); i++) {
char c = input.charAt(i);
Expand Down

0 comments on commit fc80d82

Please sign in to comment.