GLOW
This commit is contained in:
parent
682aeedc7e
commit
c03c04eca1
@ -9,6 +9,7 @@ import cmods.haxxor.client.AutoFarmer;
|
||||
import cmods.haxxor.client.options.HaxxorOptions;
|
||||
import cmods.haxxor.client.ui.ElevatorOptionsScreen;
|
||||
import cmods.haxxor.client.ui.FarmerOptionsScreen;
|
||||
import cmods.haxxor.client.ui.GlowOptionsScreen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.text.Text;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -39,6 +40,9 @@ public class HaxxorModule extends Module {
|
||||
optionButtons.add(((screen, client) -> ButtonWidget.builder(Text.translatable("haxxor.options.elevator"),
|
||||
button -> client.setScreen(new ElevatorOptionsScreen(screen))).build()));
|
||||
|
||||
optionButtons.add(((screen, client) -> ButtonWidget.builder(Text.translatable("haxxor.options.glow"),
|
||||
button -> client.setScreen(new GlowOptionsScreen(screen))).build()));
|
||||
|
||||
optionButtons.add((screen, client) -> new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("haxxor.options.fall_damage"), options.cancelFallDamage));
|
||||
|
||||
|
@ -22,6 +22,7 @@ public class HaxxorClient implements ClientModInitializer {
|
||||
|
||||
private static StickyKeyBinding auto_farm_key;
|
||||
private static StickyKeyBinding fly_hack_key;
|
||||
private static StickyKeyBinding glow_key;
|
||||
private static final HaxxorOptions options = HaxxorOptions.getInstance();
|
||||
|
||||
@Override
|
||||
@ -46,6 +47,13 @@ public class HaxxorClient implements ClientModInitializer {
|
||||
() -> true
|
||||
));
|
||||
|
||||
glow_key = (StickyKeyBinding) KeyBindingHelper.registerKeyBinding(new StickyKeyBinding(
|
||||
"key.haxxor.glow",
|
||||
-1,
|
||||
"category.haxxor.options",
|
||||
() -> true
|
||||
));
|
||||
|
||||
AutoFarmer.init();
|
||||
Elevator.init();
|
||||
|
||||
@ -59,9 +67,17 @@ public class HaxxorClient implements ClientModInitializer {
|
||||
return options.autoFarmer.enabled.get();
|
||||
}
|
||||
|
||||
public static boolean toggleGlow() {
|
||||
glow_key.setPressed(true);
|
||||
options.glow.enabled.set(glow_key.isPressed());
|
||||
|
||||
return options.glow.enabled.get();
|
||||
}
|
||||
|
||||
private void tick(MinecraftClient client) {
|
||||
options.autoFarmer.enabled.set(auto_farm_key.isPressed());
|
||||
options.flyHackEnabled.set(fly_hack_key.isPressed());
|
||||
options.glow.enabled.set(glow_key.isPressed());
|
||||
|
||||
AutoFarmer.tick(client);
|
||||
Elevator.tick(client);
|
||||
|
@ -19,6 +19,7 @@ public final class HaxxorOptions extends ModuleOptions {
|
||||
public final AutoFarmerOptions autoFarmer;
|
||||
public final UIOptions uiOptions;
|
||||
public final ElevatorOptions elevatorOptions;
|
||||
public final GlowOptions glow;
|
||||
|
||||
public final BooleanOption flyHackEnabled = new BooleanOption(false);
|
||||
public final BooleanOption cancelFallDamage = new BooleanOption(true);
|
||||
@ -36,6 +37,7 @@ public final class HaxxorOptions extends ModuleOptions {
|
||||
autoFarmer = new AutoFarmerOptions();
|
||||
uiOptions = new UIOptions();
|
||||
elevatorOptions = new ElevatorOptions();
|
||||
glow = new GlowOptions();
|
||||
}
|
||||
|
||||
public void load(@Nullable Properties properties) {
|
||||
@ -43,6 +45,7 @@ public final class HaxxorOptions extends ModuleOptions {
|
||||
autoFarmer.load(properties);
|
||||
uiOptions.load(properties);
|
||||
elevatorOptions.load(properties);
|
||||
glow.load(properties);
|
||||
|
||||
// Top level properties
|
||||
cancelFallDamage.value = getBooleanProperty(properties, "cancel_fall_damage", cancelFallDamage.value);
|
||||
@ -53,6 +56,7 @@ public final class HaxxorOptions extends ModuleOptions {
|
||||
autoFarmer.save(properties);
|
||||
uiOptions.save(properties);
|
||||
elevatorOptions.save(properties);
|
||||
glow.save(properties);
|
||||
|
||||
// Top level properties
|
||||
properties.setProperty("cancel_fall_damage", cancelFallDamage.value.toString());
|
||||
@ -172,4 +176,21 @@ public final class HaxxorOptions extends ModuleOptions {
|
||||
properties.setProperty(PREFIX + "max_tp_down", max_tp_down.value.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static class GlowOptions {
|
||||
private final String PREFIX = MODULE_PREFIX + "glow.";
|
||||
|
||||
public final BooleanOption enabled = new BooleanOption(false);
|
||||
public final BooleanOption include_non_living = new BooleanOption(false);
|
||||
|
||||
GlowOptions() { }
|
||||
|
||||
private void load(@Nullable Properties properties) {
|
||||
include_non_living.value = getBooleanProperty(properties, PREFIX + "include_non_living", include_non_living.value);
|
||||
}
|
||||
|
||||
private void save(Properties properties) {
|
||||
properties.setProperty(PREFIX + "include_non_living", include_non_living.value.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
67
src/main/java/cmods/haxxor/client/ui/GlowOptionsScreen.java
Normal file
67
src/main/java/cmods/haxxor/client/ui/GlowOptionsScreen.java
Normal file
@ -0,0 +1,67 @@
|
||||
package cmods.haxxor.client.ui;
|
||||
|
||||
import cmods.cmods.client.options.CmodsOptions;
|
||||
import cmods.cmods.client.ui.ToggleButton;
|
||||
import cmods.haxxor.client.HaxxorClient;
|
||||
import cmods.haxxor.client.options.HaxxorOptions;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.GridWidget;
|
||||
import net.minecraft.client.gui.widget.SimplePositioningWidget;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import static cmods.cmods.client.ui.Constants.*;
|
||||
|
||||
public class GlowOptionsScreen extends Screen {
|
||||
private final Screen parent;
|
||||
private final CmodsOptions global_options = CmodsOptions.getInstance();
|
||||
private final HaxxorOptions.GlowOptions options = HaxxorOptions.getInstance().glow;
|
||||
|
||||
public GlowOptionsScreen(Screen parent) {
|
||||
super(Text.translatable("haxxor.options.glow.title"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
if (client == null)
|
||||
return;
|
||||
|
||||
final int startHeight = (int) Math.floor(this.height * startHeight_multiplier);
|
||||
|
||||
GridWidget grid = new GridWidget();
|
||||
grid.getMainPositioner().marginX(5).marginBottom(4).alignHorizontalCenter();
|
||||
GridWidget.Adder adder = grid.createAdder(2);
|
||||
|
||||
adder.add(ButtonWidget.builder(
|
||||
Text.translatable("haxxor.options.glow.enabled", options.enabled.get() ?
|
||||
Text.translatable("haxxor.state.enabled") :
|
||||
Text.translatable("haxxor.state.disabled")),
|
||||
button -> button.setMessage(
|
||||
Text.translatable("haxxor.options.glow.enabled", HaxxorClient.toggleGlow() ?
|
||||
Text.translatable("haxxor.state.enabled") :
|
||||
Text.translatable("haxxor.state.disabled"))
|
||||
)).build());
|
||||
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("haxxor.options.glow.include_non_living"), options.include_non_living));
|
||||
|
||||
adder.add(ButtonWidget.builder(ScreenTexts.DONE, button -> client.setScreen(parent))
|
||||
.width(doneButtonWidth).build(), 2, adder.copyPositioner().marginTop(doneButtonRowIncrement));
|
||||
|
||||
grid.recalculateDimensions();
|
||||
SimplePositioningWidget.setPos(grid, 0, startHeight, this.width, this.height, 0.5f, 0.0f);
|
||||
addDrawableChild(grid);
|
||||
}
|
||||
|
||||
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.renderBackground(matrices);
|
||||
drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xffffff);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
public void removed() {
|
||||
global_options.save();
|
||||
}
|
||||
}
|
@ -43,6 +43,9 @@ public class HaxxorOptionsScreen extends Screen {
|
||||
adder.add(ButtonWidget.builder(Text.translatable("haxxor.options.elevator"),
|
||||
button -> this.client.setScreen(new ElevatorOptionsScreen(this))).build());
|
||||
|
||||
adder.add((ButtonWidget.builder(Text.translatable("haxxor.options.glow"),
|
||||
button -> client.setScreen(new GlowOptionsScreen(this))).build()));
|
||||
|
||||
adder.add(new ToggleButton(0, 0, buttonWidth, buttonHeight,
|
||||
Text.translatable("haxxor.options.fall_damage"), options.cancelFallDamage));
|
||||
|
||||
|
20
src/main/java/cmods/haxxor/mixin/GlobalGlow.java
Normal file
20
src/main/java/cmods/haxxor/mixin/GlobalGlow.java
Normal file
@ -0,0 +1,20 @@
|
||||
package cmods.haxxor.mixin;
|
||||
|
||||
import cmods.haxxor.client.options.HaxxorOptions;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public class GlobalGlow {
|
||||
private static final HaxxorOptions options = HaxxorOptions.getInstance();
|
||||
|
||||
@Inject(method = "isGlowing()Z", at = @At("RETURN"), cancellable = true)
|
||||
private void isGlowingOverride(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (options.glow.enabled.get()) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
20
src/main/java/cmods/haxxor/mixin/GlobalGlowAll.java
Normal file
20
src/main/java/cmods/haxxor/mixin/GlobalGlowAll.java
Normal file
@ -0,0 +1,20 @@
|
||||
package cmods.haxxor.mixin;
|
||||
|
||||
import cmods.haxxor.client.options.HaxxorOptions;
|
||||
import net.minecraft.entity.Entity;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Entity.class)
|
||||
public class GlobalGlowAll {
|
||||
private static final HaxxorOptions options = HaxxorOptions.getInstance();
|
||||
|
||||
@Inject(method = "isGlowing()Z", at = @At("RETURN"), cancellable = true)
|
||||
private void isGlowingOverride(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (options.glow.enabled.get() && options.glow.include_non_living.get()) {
|
||||
cir.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -19,6 +19,11 @@
|
||||
"haxxor.options.fall_damage": "Fall Damage Cancel",
|
||||
"haxxor.options.fall_damage.title": "Fall Damage Cancel Options",
|
||||
|
||||
"haxxor.options.glow": "Glow",
|
||||
"haxxor.options.glow.title": "Glow Options",
|
||||
"haxxor.options.glow.enabled": "Glow: %s",
|
||||
"haxxor.options.glow.include_non_living": "Include Non-Living",
|
||||
|
||||
"haxxor.options.ui": "UI",
|
||||
"haxxor.options.ui.title": "UI Options",
|
||||
"haxxor.options.ui.hud_enabled": "Show HUD",
|
||||
@ -45,8 +50,9 @@
|
||||
"haxxor.options.elevator.max_tp_down": "Max Tp Down",
|
||||
|
||||
"category.haxxor.options": "Haxxor",
|
||||
"key.haxxor.auto_farm": "Auto Farm Toggle",
|
||||
"key.haxxor.fly": "Fly Hack Toggle",
|
||||
"key.haxxor.auto_farm": "Auto Farm",
|
||||
"key.haxxor.fly": "Fly Hack",
|
||||
"key.haxxor.glow": "Global Glow",
|
||||
"key.haxxor.elevator.up": "Teleport Up",
|
||||
"key.haxxor.elevator.down": "Teleport Down"
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
"package": "cmods.haxxor.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"GlobalGlow",
|
||||
"GlobalGlowAll"
|
||||
],
|
||||
"client": [],
|
||||
"injectors": {
|
||||
|
Loading…
Reference in New Issue
Block a user