Compare commits
3 Commits
9325e24c5c
...
281297bdca
Author | SHA1 | Date | |
---|---|---|---|
281297bdca | |||
55e9b0fafd | |||
4b5b697883 |
@ -4,13 +4,20 @@ import net.fabricmc.api.ClientModInitializer;
|
||||
import wtf.hak.survivalfabric.config.client.ClientConfigManager;
|
||||
import wtf.hak.survivalfabric.features.AngleViewer;
|
||||
import wtf.hak.survivalfabric.features.RemoveDarknessEffect;
|
||||
import wtf.hak.survivalfabric.features.SFKeyBindings;
|
||||
|
||||
public class SurvivalFabricClient implements ClientModInitializer {
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
|
||||
// Config
|
||||
ClientConfigManager.getConfig();
|
||||
|
||||
// Features
|
||||
AngleViewer.register();
|
||||
RemoveDarknessEffect.register();
|
||||
SFKeyBindings.register();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package wtf.hak.survivalfabric.features;
|
||||
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||
import net.minecraft.client.option.KeyBinding;
|
||||
import net.minecraft.client.util.InputUtil;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class SFKeyBindings {
|
||||
|
||||
private static final KeyBinding CAMERA_BIND = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.survivalfabric.camera", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_PERIOD, "category.survivalfabric.survivalfabric"));
|
||||
|
||||
public static void register() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if(client.player != null) {
|
||||
if (CAMERA_BIND.wasPressed()) {
|
||||
client.player.networkHandler.sendChatCommand("camera");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -51,10 +51,14 @@ public abstract class PlayerManagerMixin {
|
||||
private void onBroadcast(SignedMessage message, ServerPlayerEntity sender, MessageType.Parameters parameters, CallbackInfo ci) {
|
||||
if (sender != null && ConfigManager.getConfig().chatMessageEnabled) {
|
||||
String rawMessage = message.getContent().getString().trim();
|
||||
if (sender != null && ConfigManager.getConfig().chatCalcEnabled && rawMessage.endsWith("=")) {
|
||||
String expression = rawMessage.substring(0, rawMessage.length() - 1).trim();
|
||||
if (sender != null && ConfigManager.getConfig().chatCalcEnabled) {
|
||||
String expression = rawMessage.endsWith("=") ? rawMessage.substring(0, rawMessage.length() - 1).trim() : rawMessage;
|
||||
try {
|
||||
String result = String.valueOf(evaluateExpression(expression));
|
||||
String old = rawMessage;
|
||||
rawMessage += "§6";
|
||||
if (rawMessage.contains(" ")) rawMessage += " ";
|
||||
if (!old.trim().endsWith("=")) rawMessage += "=";
|
||||
if (rawMessage.contains(" ")) rawMessage += " ";
|
||||
rawMessage += (result.endsWith(".0")) ? result.substring(0, result.length() - 2) : result;
|
||||
} catch (Exception e) {
|
||||
@ -65,10 +69,13 @@ public abstract class PlayerManagerMixin {
|
||||
ci.cancel();
|
||||
} else if (sender != null && ConfigManager.getConfig().chatCalcEnabled) {
|
||||
String rawMessage = message.getContent().getString().trim();
|
||||
if (rawMessage.endsWith("=")) {
|
||||
String expression = rawMessage.substring(0, rawMessage.length() - 1).trim();
|
||||
String expression = rawMessage.endsWith("=") ? rawMessage.substring(0, rawMessage.length() - 1).trim() : rawMessage;
|
||||
try {
|
||||
String result = String.valueOf(evaluateExpression(expression));
|
||||
String old = rawMessage;
|
||||
rawMessage += "§6";
|
||||
if (rawMessage.contains(" ")) rawMessage += " ";
|
||||
if (!old.trim().endsWith("=")) rawMessage += "=";
|
||||
if (rawMessage.contains(" ")) rawMessage += " ";
|
||||
rawMessage += (result.endsWith(".0")) ? result.substring(0, result.length() - 2) : result;
|
||||
Text formattedMessage = Text.literal("<" + sender.getName().getString() + "> " + rawMessage);
|
||||
@ -76,7 +83,6 @@ public abstract class PlayerManagerMixin {
|
||||
ci.cancel();
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,5 +15,7 @@
|
||||
"key.survivalfabric.angle12": "204.81 / -54.23",
|
||||
"key.survivalfabric.angle13": "245.14 / -54.23",
|
||||
"key.survivalfabric.angle14": "204.98 / -41.68",
|
||||
"key.survivalfabric.angle15": "244.97 / -41.71"
|
||||
"key.survivalfabric.angle15": "244.97 / -41.71",
|
||||
"category.survivalfabric.survivalfabric": "Survival Fabric",
|
||||
"key.survivalfabric.camera": "/camera"
|
||||
}
|
Reference in New Issue
Block a user