improving modulation, bug: Config not working
This commit is contained in:
@@ -5,22 +5,23 @@ import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
|
|||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
|
||||||
import org.saturnclient.modules.mods.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
import org.saturnclient.saturnclient.SaturnClient;
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
import org.saturnclient.saturnclient.SaturnClientConfig;
|
||||||
import org.saturnclient.saturnclient.menus.HudEditor;
|
import org.saturnclient.saturnclient.menus.HudEditor;
|
||||||
|
|
||||||
public class ModManager {
|
public class ModManager {
|
||||||
|
public static List<Module> MODS = new ArrayList<>();
|
||||||
|
|
||||||
public static Module[] MODS = {
|
public static <T extends Module> void impl(Class<T> mod) {
|
||||||
new Coordinates(),
|
try {
|
||||||
new ArmorDisplay(),
|
MODS.add((Module) mod.getDeclaredConstructor().newInstance());
|
||||||
new FpsDisplay(),
|
} catch (Exception e) {
|
||||||
new Particles(),
|
e.printStackTrace();
|
||||||
new Crosshair(),
|
}
|
||||||
new FreeLook(),
|
}
|
||||||
new AutoSprint()
|
|
||||||
};
|
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
ClientTickEvents.START_CLIENT_TICK.register(client -> {
|
ClientTickEvents.START_CLIENT_TICK.register(client -> {
|
||||||
|
|||||||
@@ -1,35 +1,37 @@
|
|||||||
package org.saturnclient.modules;
|
package org.saturnclient.modules;
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
import org.saturnclient.saturnclient.config.ConfigManager;
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
import org.saturnclient.saturnclient.config.NamedProperty;
|
||||||
import org.saturnclient.ui.Textures;
|
import org.saturnclient.ui.Textures;
|
||||||
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
public abstract class Module {
|
public abstract class Module {
|
||||||
public static Property<Boolean> enabled;
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String namespace;
|
private final String namespace;
|
||||||
private final ConfigManager configManager;
|
private final ConfigManager configManager;
|
||||||
|
|
||||||
|
public Module(String name, String namespace, NamedProperty<?>... props) {
|
||||||
|
this.name = name;
|
||||||
|
this.namespace = namespace;
|
||||||
|
|
||||||
|
configManager = new ConfigManager(name);
|
||||||
|
|
||||||
|
for (NamedProperty<?> prop : props) {
|
||||||
|
configManager.property(prop.name, prop.prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Module(ConfigManager config, String name, String namespace) {
|
public Module(ConfigManager config, String name, String namespace) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.namespace = namespace;
|
this.namespace = namespace;
|
||||||
|
|
||||||
enabled = config.property(
|
|
||||||
"Enabled",
|
|
||||||
new Property<>(false));
|
|
||||||
|
|
||||||
configManager = config;
|
configManager = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled() {
|
public abstract boolean isEnabled();
|
||||||
return enabled.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEnabled(boolean e) {
|
public abstract void setEnabled(boolean e);
|
||||||
enabled.value = e;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String getName() {
|
public final String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
package org.saturnclient.modules.mods;
|
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.HudMod;
|
|
||||||
import org.saturnclient.modules.ModDimensions;
|
|
||||||
import org.saturnclient.modules.Module;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
|
||||||
|
|
||||||
public class ArmorDisplay extends Module implements HudMod {
|
|
||||||
|
|
||||||
private static ConfigManager config = new ConfigManager("Armor Display");
|
|
||||||
private static ModDimensions dimensions = new ModDimensions(
|
|
||||||
config,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
34,
|
|
||||||
75);
|
|
||||||
|
|
||||||
public static Property<Integer> fgColor = config.property(
|
|
||||||
"Foreground color",
|
|
||||||
new Property<>(SaturnClientConfig.WHITE, Property.PropertyType.HEX));
|
|
||||||
|
|
||||||
|
|
||||||
public ArmorDisplay() {
|
|
||||||
super(config, "Armor Display", "armor");
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean renderItem(DrawContext context, ItemStack item, int y) {
|
|
||||||
if (item.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.drawItem(item, 0, y);
|
|
||||||
|
|
||||||
if (item.getMaxDamage() > 0) {
|
|
||||||
MatrixStack matrices = context.getMatrices();
|
|
||||||
|
|
||||||
matrices.push();
|
|
||||||
|
|
||||||
matrices.translate(17, y + 5, 0);
|
|
||||||
|
|
||||||
matrices.scale(0.8f, 0.8f, 0f);
|
|
||||||
|
|
||||||
context.drawText(
|
|
||||||
SaturnClientConfig.textRenderer,
|
|
||||||
"" + (item.getMaxDamage() - item.getDamage()),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
fgColor.value,
|
|
||||||
false);
|
|
||||||
|
|
||||||
matrices.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(DrawContext context) {
|
|
||||||
PlayerEntity player = SaturnClient.client.player;
|
|
||||||
ItemStack[] items = {
|
|
||||||
player.getEquippedStack(EquipmentSlot.MAINHAND),
|
|
||||||
player.getEquippedStack(EquipmentSlot.FEET),
|
|
||||||
player.getEquippedStack(EquipmentSlot.LEGS),
|
|
||||||
player.getEquippedStack(EquipmentSlot.CHEST),
|
|
||||||
player.getEquippedStack(EquipmentSlot.HEAD),
|
|
||||||
};
|
|
||||||
|
|
||||||
int y = 60;
|
|
||||||
|
|
||||||
for (ItemStack item : items) {
|
|
||||||
if (renderItem(context, item, y)) {
|
|
||||||
y -= 15;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderDummy(DrawContext context) {
|
|
||||||
ItemStack[] items = {
|
|
||||||
new ItemStack(Items.DIAMOND_SWORD),
|
|
||||||
new ItemStack(Items.DIAMOND_BOOTS),
|
|
||||||
new ItemStack(Items.DIAMOND_LEGGINGS),
|
|
||||||
new ItemStack(Items.DIAMOND_CHESTPLATE),
|
|
||||||
new ItemStack(Items.DIAMOND_HELMET),
|
|
||||||
};
|
|
||||||
|
|
||||||
int y = 60;
|
|
||||||
|
|
||||||
for (ItemStack item : items) {
|
|
||||||
if (renderItem(context, item, y)) {
|
|
||||||
y -= 15;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModDimensions getDimensions() {
|
|
||||||
return dimensions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package org.saturnclient.modules.mods;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.Module;
|
|
||||||
import org.saturnclient.modules.TickModule;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
|
||||||
|
|
||||||
public class AutoSprint extends Module implements TickModule {
|
|
||||||
|
|
||||||
private static ConfigManager config = new ConfigManager("Armor Display");
|
|
||||||
|
|
||||||
public AutoSprint() {
|
|
||||||
super(config, "Auto Sprint", "auto_sprint");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void tick() {
|
|
||||||
if (SaturnClient.client.options.forwardKey.isPressed() && !SaturnClient.client.options.backKey.isPressed() && !SaturnClient.client.player.horizontalCollision) {
|
|
||||||
Objects.requireNonNull(SaturnClient.client.player).setSprinting(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package org.saturnclient.modules.mods;
|
|
||||||
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.HudMod;
|
|
||||||
import org.saturnclient.modules.ModDimensions;
|
|
||||||
import org.saturnclient.modules.Module;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
|
||||||
|
|
||||||
public class Coordinates extends Module implements HudMod {
|
|
||||||
|
|
||||||
private static ConfigManager config = new ConfigManager("Coordinates");
|
|
||||||
private static ModDimensions dimensions = new ModDimensions(config);
|
|
||||||
|
|
||||||
public static Property<Integer> fgColor = config.property(
|
|
||||||
"Foreground color",
|
|
||||||
new Property<>(SaturnClientConfig.WHITE, Property.PropertyType.HEX));
|
|
||||||
|
|
||||||
public Coordinates() {
|
|
||||||
super(config, "Coordinates", "coords");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void renderDummy(DrawContext context) {
|
|
||||||
int playerX = 124;
|
|
||||||
int playerY = 69;
|
|
||||||
int playerZ = 83;
|
|
||||||
|
|
||||||
context.drawText(
|
|
||||||
SaturnClientConfig.textRenderer,
|
|
||||||
playerX + " " + playerY + " " + playerZ,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
fgColor.value,
|
|
||||||
false);
|
|
||||||
|
|
||||||
dimensions.width = SaturnClientConfig.textRenderer.getWidth(
|
|
||||||
playerX + " " + playerY + " " + playerZ);
|
|
||||||
dimensions.height = SaturnClientConfig.textRenderer.fontHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void render(DrawContext context) {
|
|
||||||
PlayerEntity player = SaturnClient.client.player;
|
|
||||||
int playerX = (int) player.getX();
|
|
||||||
int playerY = (int) player.getY();
|
|
||||||
int playerZ = (int) player.getZ();
|
|
||||||
|
|
||||||
context.drawText(
|
|
||||||
SaturnClientConfig.textRenderer,
|
|
||||||
playerX + " " + playerY + " " + playerZ,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
fgColor.value,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ModDimensions getDimensions() {
|
|
||||||
return dimensions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +1,29 @@
|
|||||||
package org.saturnclient.modules.mods;
|
package org.saturnclient.modules.mods;
|
||||||
|
|
||||||
|
import org.saturnclient.modules.ModManager;
|
||||||
import org.saturnclient.modules.Module;
|
import org.saturnclient.modules.Module;
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
import org.saturnclient.saturnclient.config.NamedProperty;
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
import org.saturnclient.saturnclient.config.Property;
|
||||||
|
|
||||||
public class Crosshair extends Module {
|
public class Crosshair extends Module {
|
||||||
public static ConfigManager config = new ConfigManager("Crosshair");
|
public static NamedProperty<Boolean> enabled = new Property<>(false).named("Enabled");
|
||||||
|
public static NamedProperty<Boolean> range_indicator = new Property<>(false).named("Range Indicator");
|
||||||
public static Property<Boolean> range_indicator = config.property(
|
|
||||||
"Hit range indicator",
|
|
||||||
new Property<>(false));
|
|
||||||
|
|
||||||
public Crosshair() {
|
public Crosshair() {
|
||||||
super(config, "Crosshair", "crosshair");
|
super("Crosshair", "crosshair", enabled, range_indicator);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
ModManager.impl(Crosshair.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled.prop.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setEnabled(boolean e) {
|
||||||
|
enabled.prop.value = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
package org.saturnclient.modules.mods;
|
|
||||||
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
import net.minecraft.client.gui.DrawContext;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.HudMod;
|
|
||||||
import org.saturnclient.modules.ModDimensions;
|
|
||||||
import org.saturnclient.modules.Module;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
|
||||||
|
|
||||||
public class FpsDisplay extends Module implements HudMod {
|
|
||||||
|
|
||||||
public static ConfigManager config = new ConfigManager("Fps Display");
|
|
||||||
|
|
||||||
public static ModDimensions dimensions = new ModDimensions(
|
|
||||||
config,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
40,
|
|
||||||
8);
|
|
||||||
|
|
||||||
public static Property<Integer> fgColor = config.property(
|
|
||||||
"Foreground color",
|
|
||||||
new Property<>(SaturnClientConfig.WHITE, Property.PropertyType.HEX));
|
|
||||||
|
|
||||||
|
|
||||||
public FpsDisplay() {
|
|
||||||
super(config, "Fps Display", "fps");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ModDimensions getDimensions() {
|
|
||||||
return dimensions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void renderDummy(DrawContext context) {
|
|
||||||
int fps = 128;
|
|
||||||
|
|
||||||
context.drawText(
|
|
||||||
SaturnClientConfig.textRenderer,
|
|
||||||
String.valueOf(fps) + " FPS",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
fgColor.value,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(DrawContext context) {
|
|
||||||
int fps = SaturnClient.client.getCurrentFps();
|
|
||||||
|
|
||||||
context.drawText(
|
|
||||||
SaturnClientConfig.textRenderer,
|
|
||||||
String.valueOf(fps) + " FPS",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
fgColor.value,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package org.saturnclient.modules.mods;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.Module;
|
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
|
||||||
import net.minecraft.client.option.Perspective;
|
|
||||||
|
|
||||||
public class FreeLook extends Module {
|
|
||||||
public static boolean isFreeLooking = false;
|
|
||||||
public static Perspective lastPerspective = null;
|
|
||||||
|
|
||||||
private static ConfigManager config = new ConfigManager("Free Look");
|
|
||||||
|
|
||||||
public static Property<Boolean> toggle = config.property(
|
|
||||||
"Toggle Free Look",
|
|
||||||
new Property<>(false));
|
|
||||||
|
|
||||||
public FreeLook() {
|
|
||||||
super(config, "Free Look", "freelook");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package org.saturnclient.modules.mods;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.Module;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClientConfig;
|
|
||||||
import org.saturnclient.saturnclient.config.ConfigManager;
|
|
||||||
import org.saturnclient.saturnclient.config.Property;
|
|
||||||
|
|
||||||
public class Particles extends Module {
|
|
||||||
public static ConfigManager config = new ConfigManager("Particles");
|
|
||||||
|
|
||||||
public static ConfigManager totem = new ConfigManager(config, "Totem particles");
|
|
||||||
|
|
||||||
public static Property<Boolean> totem_enabled = totem.property(
|
|
||||||
"Change totem color",
|
|
||||||
new Property<>(false));
|
|
||||||
|
|
||||||
public static Property<Integer> totem_1 = totem.property(
|
|
||||||
"Totem particle color 1",
|
|
||||||
new Property<>(SaturnClientConfig.color.value, Property.PropertyType.HEX));
|
|
||||||
|
|
||||||
public static Property<Integer> totem_2 = totem.property(
|
|
||||||
"Totem particle color 2",
|
|
||||||
new Property<>(SaturnClientConfig.color.value, Property.PropertyType.HEX));
|
|
||||||
|
|
||||||
public Particles() {
|
|
||||||
super(config, "Particles", "particles");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,8 +34,8 @@ public class SaturnClient implements ModInitializer {
|
|||||||
LOGGER.info("Initializing " + MOD_ID);
|
LOGGER.info("Initializing " + MOD_ID);
|
||||||
client = MinecraftClient.getInstance();
|
client = MinecraftClient.getInstance();
|
||||||
ModManager.init();
|
ModManager.init();
|
||||||
ConfigManager.load();
|
|
||||||
ThemeManager.load();
|
ThemeManager.load();
|
||||||
|
ConfigManager.load();
|
||||||
|
|
||||||
ClientLifecycleEvents.CLIENT_STOPPING.register(_o -> {ConfigManager.save(); ThemeManager.save();});
|
ClientLifecycleEvents.CLIENT_STOPPING.register(_o -> {ConfigManager.save(); ThemeManager.save();});
|
||||||
ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
|
ScreenEvents.BEFORE_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package org.saturnclient.saturnclient.config;
|
||||||
|
|
||||||
|
public class NamedProperty<T> {
|
||||||
|
public String name;
|
||||||
|
public Property<T> prop;
|
||||||
|
|
||||||
|
public NamedProperty(String name, Property<T> value) {
|
||||||
|
this.name = name;
|
||||||
|
this.prop = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -150,4 +150,8 @@ public class Property<T> {
|
|||||||
this.value = (T) value;
|
this.value = (T) value;
|
||||||
this.defaultValue = (T) defaultValue;
|
this.defaultValue = (T) defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NamedProperty<T> named(String name) {
|
||||||
|
return new NamedProperty<>(name, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package org.saturnclient.saturnclient.event;
|
|||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
|
||||||
import net.minecraft.client.option.KeyBinding;
|
import net.minecraft.client.option.KeyBinding;
|
||||||
import net.minecraft.client.option.Perspective;
|
// import net.minecraft.client.option.Perspective;
|
||||||
import net.minecraft.client.util.InputUtil;
|
import net.minecraft.client.util.InputUtil;
|
||||||
|
|
||||||
import org.saturnclient.modules.mods.FreeLook;
|
// import org.saturnclient.modules.mods.FreeLook;
|
||||||
import org.saturnclient.saturnclient.menus.ModMenu;
|
import org.saturnclient.saturnclient.menus.ModMenu;
|
||||||
import org.saturnclient.saturnclient.menus.SaturnMenu;
|
// import org.saturnclient.saturnclient.menus.SaturnMenu;
|
||||||
import org.lwjgl.glfw.GLFW;
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,9 +21,9 @@ public class KeyInputHandler {
|
|||||||
private static final int DEFAULT_MENU_KEY = GLFW.GLFW_KEY_RIGHT_SHIFT;
|
private static final int DEFAULT_MENU_KEY = GLFW.GLFW_KEY_RIGHT_SHIFT;
|
||||||
private static KeyBinding mainMenuKeyBinding;
|
private static KeyBinding mainMenuKeyBinding;
|
||||||
|
|
||||||
private static final String FREELOOK_KEY_ID = "key.saturnclient.freelook";
|
// private static final String FREELOOK_KEY_ID = "key.saturnclient.freelook";
|
||||||
private static final int FREELOOK_KEY = GLFW.GLFW_KEY_M;
|
// private static final int FREELOOK_KEY = GLFW.GLFW_KEY_M;
|
||||||
private static KeyBinding freelookKeyBinding;
|
// private static KeyBinding freelookKeyBinding;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers all keybindings and their associated event handlers.
|
* Registers all keybindings and their associated event handlers.
|
||||||
@@ -37,38 +37,39 @@ public class KeyInputHandler {
|
|||||||
DEFAULT_MENU_KEY,
|
DEFAULT_MENU_KEY,
|
||||||
KEY_CATEGORY));
|
KEY_CATEGORY));
|
||||||
|
|
||||||
freelookKeyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
// freelookKeyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
|
||||||
FREELOOK_KEY_ID,
|
// FREELOOK_KEY_ID,
|
||||||
InputUtil.Type.KEYSYM,
|
// InputUtil.Type.KEYSYM,
|
||||||
FREELOOK_KEY,
|
// FREELOOK_KEY,
|
||||||
KEY_CATEGORY));
|
// KEY_CATEGORY));
|
||||||
|
|
||||||
// Register the event handler for the main menu key
|
// Register the event handler for the main menu key
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||||
if (mainMenuKeyBinding.wasPressed()) {
|
if (mainMenuKeyBinding.wasPressed()) {
|
||||||
client.setScreen(new ModMenu());
|
client.setScreen(new ModMenu());
|
||||||
} else if (freelookKeyBinding.wasPressed() && FreeLook.enabled.value && FreeLook.toggle.value) {
|
|
||||||
FreeLook.isFreeLooking = !FreeLook.isFreeLooking;
|
|
||||||
if (FreeLook.isFreeLooking) {
|
|
||||||
FreeLook.lastPerspective = client.options.getPerspective();
|
|
||||||
client.options.setPerspective(Perspective.THIRD_PERSON_BACK);
|
|
||||||
} else if (FreeLook.lastPerspective != null) {
|
|
||||||
client.options.setPerspective(FreeLook.lastPerspective);
|
|
||||||
FreeLook.lastPerspective = null;
|
|
||||||
}
|
|
||||||
} else if (FreeLook.enabled.value && !FreeLook.toggle.value) {
|
|
||||||
if (freelookKeyBinding.isPressed()) {
|
|
||||||
if (!FreeLook.isFreeLooking) {
|
|
||||||
FreeLook.lastPerspective = client.options.getPerspective();
|
|
||||||
client.options.setPerspective(Perspective.THIRD_PERSON_BACK);
|
|
||||||
FreeLook.isFreeLooking = true;
|
|
||||||
}
|
|
||||||
} else if (FreeLook.isFreeLooking && FreeLook.lastPerspective != null) {
|
|
||||||
client.options.setPerspective(FreeLook.lastPerspective);
|
|
||||||
FreeLook.isFreeLooking = false;
|
|
||||||
FreeLook.lastPerspective = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// else if (freelookKeyBinding.wasPressed() && FreeLook.enabled.value && FreeLook.toggle.value) {
|
||||||
|
// FreeLook.isFreeLooking = !FreeLook.isFreeLooking;
|
||||||
|
// if (FreeLook.isFreeLooking) {
|
||||||
|
// FreeLook.lastPerspective = client.options.getPerspective();
|
||||||
|
// client.options.setPerspective(Perspective.THIRD_PERSON_BACK);
|
||||||
|
// } else if (FreeLook.lastPerspective != null) {
|
||||||
|
// client.options.setPerspective(FreeLook.lastPerspective);
|
||||||
|
// FreeLook.lastPerspective = null;
|
||||||
|
// }
|
||||||
|
// } else if (FreeLook.enabled.value && !FreeLook.toggle.value) {
|
||||||
|
// if (freelookKeyBinding.isPressed()) {
|
||||||
|
// if (!FreeLook.isFreeLooking) {
|
||||||
|
// FreeLook.lastPerspective = client.options.getPerspective();
|
||||||
|
// client.options.setPerspective(Perspective.THIRD_PERSON_BACK);
|
||||||
|
// FreeLook.isFreeLooking = true;
|
||||||
|
// }
|
||||||
|
// } else if (FreeLook.isFreeLooking && FreeLook.lastPerspective != null) {
|
||||||
|
// client.options.setPerspective(FreeLook.lastPerspective);
|
||||||
|
// FreeLook.isFreeLooking = false;
|
||||||
|
// FreeLook.lastPerspective = null;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package org.saturnclient.saturnclient.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.client.render.Camera;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.mods.FreeLook;
|
|
||||||
import org.saturnclient.saturnclient.SaturnClient;
|
|
||||||
import org.saturnclient.saturnclient.mod_utils.CameraOverriddenEntity;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.world.BlockView;
|
|
||||||
|
|
||||||
@Mixin(Camera.class)
|
|
||||||
public abstract class CameraMixin {
|
|
||||||
@Unique
|
|
||||||
boolean firstTime = true;
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
protected abstract void setRotation(float yaw, float pitch);
|
|
||||||
|
|
||||||
@Inject(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;setRotation(FF)V", ordinal = 1, shift = At.Shift.AFTER))
|
|
||||||
public void lockRotation(BlockView focusedBlock, Entity cameraEntity, boolean isThirdPerson, boolean isFrontFacing,
|
|
||||||
float tickDelta, CallbackInfo ci) {
|
|
||||||
if (FreeLook.isFreeLooking && cameraEntity instanceof ClientPlayerEntity) {
|
|
||||||
CameraOverriddenEntity cameraOverriddenEntity = (CameraOverriddenEntity) cameraEntity;
|
|
||||||
|
|
||||||
if (firstTime && SaturnClient.client.player != null) {
|
|
||||||
cameraOverriddenEntity.freelook$setCameraPitch(SaturnClient.client.player.getPitch());
|
|
||||||
cameraOverriddenEntity.freelook$setCameraYaw(SaturnClient.client.player.getYaw());
|
|
||||||
firstTime = false;
|
|
||||||
}
|
|
||||||
this.setRotation(cameraOverriddenEntity.freelook$getCameraYaw(),
|
|
||||||
cameraOverriddenEntity.freelook$getCameraPitch());
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!FreeLook.isFreeLooking && cameraEntity instanceof ClientPlayerEntity) {
|
|
||||||
firstTime = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,6 @@ import net.minecraft.client.render.RenderLayer;
|
|||||||
import net.minecraft.client.render.RenderTickCounter;
|
import net.minecraft.client.render.RenderTickCounter;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
import org.spongepowered.asm.mixin.Unique;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
@@ -27,8 +25,8 @@ public class Crosshair {
|
|||||||
|
|
||||||
@Inject(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0))
|
@Inject(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Ljava/util/function/Function;Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0))
|
||||||
private void drawCrosshair(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
private void drawCrosshair(DrawContext context, RenderTickCounter tickCounter, CallbackInfo ci) {
|
||||||
if (org.saturnclient.modules.mods.Crosshair.enabled.value
|
if (org.saturnclient.modules.mods.Crosshair.enabled.prop.value
|
||||||
&& org.saturnclient.modules.mods.Crosshair.range_indicator.value
|
&& org.saturnclient.modules.mods.Crosshair.range_indicator.prop.value
|
||||||
&& SaturnClient.client.targetedEntity != null
|
&& SaturnClient.client.targetedEntity != null
|
||||||
&& SaturnClient.client.targetedEntity.isAlive()) {
|
&& SaturnClient.client.targetedEntity.isAlive()) {
|
||||||
RenderSystem.setShaderTexture(0, textureLocation);
|
RenderSystem.setShaderTexture(0, textureLocation);
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
package org.saturnclient.saturnclient.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.client.network.ClientPlayerEntity;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.mods.FreeLook;
|
|
||||||
import org.saturnclient.saturnclient.mod_utils.CameraOverriddenEntity;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(Entity.class)
|
|
||||||
public class EntityMixin implements CameraOverriddenEntity {
|
|
||||||
@Unique
|
|
||||||
private float cameraPitch;
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
private float cameraYaw;
|
|
||||||
|
|
||||||
@Inject(method = "changeLookDirection", at = @At("HEAD"), cancellable = true)
|
|
||||||
public void changeCameraLookDirection(double xDelta, double yDelta, CallbackInfo ci) {
|
|
||||||
// noinspection ConstantValue// IntelliJ is incorrect here, this code block is
|
|
||||||
// reachable
|
|
||||||
if (FreeLook.isFreeLooking && (Object) this instanceof ClientPlayerEntity) {
|
|
||||||
double pitchDelta = (yDelta * 0.15);
|
|
||||||
double yawDelta = (xDelta * 0.15);
|
|
||||||
|
|
||||||
this.cameraPitch = MathHelper.clamp(this.cameraPitch + (float) pitchDelta, -90.0f, 90.0f);
|
|
||||||
this.cameraYaw += (float) yawDelta;
|
|
||||||
|
|
||||||
ci.cancel();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Unique
|
|
||||||
public float freelook$getCameraPitch() {
|
|
||||||
return this.cameraPitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Unique
|
|
||||||
public float freelook$getCameraYaw() {
|
|
||||||
return this.cameraYaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Unique
|
|
||||||
public void freelook$setCameraPitch(float pitch) {
|
|
||||||
this.cameraPitch = pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Unique
|
|
||||||
public void freelook$setCameraYaw(float yaw) {
|
|
||||||
this.cameraYaw = yaw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package org.saturnclient.saturnclient.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.client.particle.AnimatedParticle;
|
|
||||||
import net.minecraft.client.particle.SpriteProvider;
|
|
||||||
import net.minecraft.client.particle.TotemParticle;
|
|
||||||
import net.minecraft.client.world.ClientWorld;
|
|
||||||
import net.minecraft.util.math.ColorHelper;
|
|
||||||
|
|
||||||
import org.saturnclient.modules.mods.Particles;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(TotemParticle.class)
|
|
||||||
public class TotemParticleMixin extends AnimatedParticle {
|
|
||||||
protected TotemParticleMixin(ClientWorld world, double x, double y, double z, SpriteProvider spriteProvider,
|
|
||||||
float upwardsAcceleration) {
|
|
||||||
super(world, x, y, z, spriteProvider, upwardsAcceleration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("TAIL"), method = "<init>")
|
|
||||||
private void colorChanger(ClientWorld world, double x, double y, double z, double velocityX, double velocityY,
|
|
||||||
double velocityZ, SpriteProvider spriteProvider, CallbackInfo ci) {
|
|
||||||
if (Particles.enabled.value && Particles.totem_enabled.value) {
|
|
||||||
if (this.random.nextInt(2) == 0) {
|
|
||||||
this.setColor(ColorHelper.getRedFloat(Particles.totem_1.value),
|
|
||||||
ColorHelper.getGreenFloat(Particles.totem_1.value),
|
|
||||||
ColorHelper.getBlueFloat(Particles.totem_1.value));
|
|
||||||
} else {
|
|
||||||
this.setColor(ColorHelper.getRedFloat(Particles.totem_2.value),
|
|
||||||
ColorHelper.getGreenFloat(Particles.totem_2.value),
|
|
||||||
ColorHelper.getBlueFloat(Particles.totem_2.value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,10 +9,7 @@
|
|||||||
"PlayerEntityRendererMixin",
|
"PlayerEntityRendererMixin",
|
||||||
"WhoAmI",
|
"WhoAmI",
|
||||||
"SaturnReload",
|
"SaturnReload",
|
||||||
"TotemParticleMixin",
|
|
||||||
"Crosshair",
|
"Crosshair",
|
||||||
"EntityMixin",
|
|
||||||
"CameraMixin",
|
|
||||||
"DrawContextAccessor"
|
"DrawContextAccessor"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
|||||||
Reference in New Issue
Block a user