From 45f8d95e94d6a315877558b904a7d3643c4b4a50 Mon Sep 17 00:00:00 2001 From: wuritz Date: Sat, 19 Jul 2025 23:28:17 +0200 Subject: [PATCH] genyo blink --- src/main/java/com/genyo/addon/GenyoAddon.java | 6 +- .../addon/mixin/AccessorGameOptions.java | 21 ++++ .../genyo/addon/modules/GenyoSkinBlink.java | 67 ++++++++++++ .../genyo/addon/systems/enemies/Enemies.java | 2 +- .../genyo/addon/systems/timer/CacheTimer.java | 102 ++++++++++++++++++ .../addon/systems/timer/ShorelineTimer.java | 34 ++++++ src/main/resources/genyo.mixins.json | 3 +- 7 files changed, 229 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/genyo/addon/mixin/AccessorGameOptions.java create mode 100644 src/main/java/com/genyo/addon/modules/GenyoSkinBlink.java create mode 100644 src/main/java/com/genyo/addon/systems/timer/CacheTimer.java create mode 100644 src/main/java/com/genyo/addon/systems/timer/ShorelineTimer.java diff --git a/src/main/java/com/genyo/addon/GenyoAddon.java b/src/main/java/com/genyo/addon/GenyoAddon.java index 3a9fdb5..64e7754 100644 --- a/src/main/java/com/genyo/addon/GenyoAddon.java +++ b/src/main/java/com/genyo/addon/GenyoAddon.java @@ -1,9 +1,6 @@ package com.genyo.addon; -import com.genyo.addon.modules.AngelSexHulkenberg; -import com.genyo.addon.modules.GenyoAutoEZ; -import com.genyo.addon.modules.GenyoSurround; -import com.genyo.addon.modules.GenyoWelcome; +import com.genyo.addon.modules.*; import com.genyo.addon.systems.enemies.EnemiesTab; import com.genyo.addon.hud.InCombatHud; import com.genyo.addon.hud.PvPNeccessaryHud; @@ -63,6 +60,7 @@ private void initModules(Modules modules) { modules.add(new AngelSexHulkenberg()); modules.add(new GenyoSurround()); modules.add(new GenyoWelcome()); + modules.add(new GenyoSkinBlink()); } private void initHUD(Hud hud) { diff --git a/src/main/java/com/genyo/addon/mixin/AccessorGameOptions.java b/src/main/java/com/genyo/addon/mixin/AccessorGameOptions.java new file mode 100644 index 0000000..ce299d9 --- /dev/null +++ b/src/main/java/com/genyo/addon/mixin/AccessorGameOptions.java @@ -0,0 +1,21 @@ +package com.genyo.addon.mixin; + +import net.minecraft.client.option.GameOptions; +import net.minecraft.entity.player.PlayerModelPart; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.Set; + +@Mixin(GameOptions.class) +public interface AccessorGameOptions { + + /** + * @return + */ + @Accessor("enabledPlayerModelParts") + @Mutable + Set getPlayerModelParts(); + +} diff --git a/src/main/java/com/genyo/addon/modules/GenyoSkinBlink.java b/src/main/java/com/genyo/addon/modules/GenyoSkinBlink.java new file mode 100644 index 0000000..814a66d --- /dev/null +++ b/src/main/java/com/genyo/addon/modules/GenyoSkinBlink.java @@ -0,0 +1,67 @@ +package com.genyo.addon.modules; + +import com.genyo.addon.GenyoAddon; +import com.genyo.addon.mixin.AccessorGameOptions; +import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.settings.IntSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.entity.player.PlayerModelPart; + +import java.util.HashSet; +import java.util.Set; + +public class GenyoSkinBlink extends GenyoModule{ + + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting delay = sgGeneral.add(new IntSetting.Builder() + .name("Delay (mp)") + .description("hulkenberg????") + .defaultValue(2) + .sliderRange(1, 15) + .build() + ); + + public GenyoSkinBlink() { + super(GenyoAddon.GENYO, "genyo-skin-blink", "i love kiwi. i love kiwi. i love kiwi. i love kiwi. "); + } + + private int timer = 0; + private Set enabledParts = new HashSet<>(); + + @Override + public void onActivate() { + if (mc.options == null) return; + + timer = 0; + enabledParts = ((AccessorGameOptions) mc.options).getPlayerModelParts(); + } + + @Override + public void onDeactivate() { + if (enabledParts == null || mc.options == null) return; + + timer = 0; + for (PlayerModelPart part : PlayerModelPart.values()) mc.options.setPlayerModelPart(part, enabledParts.contains(part)); + } + + @EventHandler + public void onTick(TickEvent.Post event) { + timer++; + if (mc.player == null && mc.world == null) return; + + if (!(timer >= (delay.get() * 20))) return; + GenyoAddon.LOG.info("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + + Set currentParts = ((AccessorGameOptions) mc.options).getPlayerModelParts(); + for (PlayerModelPart part : PlayerModelPart.values()) { + mc.options.setPlayerModelPart(part, !currentParts.contains(part)); + } + mc.options.sendClientSettings(); + + timer = 0; + } + +} diff --git a/src/main/java/com/genyo/addon/systems/enemies/Enemies.java b/src/main/java/com/genyo/addon/systems/enemies/Enemies.java index 363f939..be83199 100644 --- a/src/main/java/com/genyo/addon/systems/enemies/Enemies.java +++ b/src/main/java/com/genyo/addon/systems/enemies/Enemies.java @@ -191,7 +191,7 @@ public Enemies fromTag(NbtCompound tag) { enemies.clear(); - for (NbtElement itemTag : tag.getList("enemies", 0)) { + for (NbtElement itemTag : tag.getList("enemies", 8)) { NbtCompound enemyTag = (NbtCompound) itemTag; if (!enemyTag.contains("name")) continue; diff --git a/src/main/java/com/genyo/addon/systems/timer/CacheTimer.java b/src/main/java/com/genyo/addon/systems/timer/CacheTimer.java new file mode 100644 index 0000000..35bd1e8 --- /dev/null +++ b/src/main/java/com/genyo/addon/systems/timer/CacheTimer.java @@ -0,0 +1,102 @@ +package com.genyo.addon.systems.timer; + +import java.util.concurrent.TimeUnit; + +public class CacheTimer implements ShorelineTimer { + + // The cached time since last reset which indicates the time passed since + // the last timer reset + private long time; + + private long lastResetTime; + + /** + * Default constructor which will initialize the time to the current time + * which means {@link #passed(Number)} and {@link #passed(Number, TimeUnit)} + * will always return true initially + */ + public CacheTimer() { + this.time = System.nanoTime(); + } + + /** + * Returns true if the time since the last reset has exceeded + * the param time. + * + * @param time The param time in ms + * @return true if the time since the last reset has exceeded + * the param time + */ + @Override + public boolean passed(Number time) { + if (time.longValue() <= 0) { + return true; + } + return getElapsedTime() > time.longValue(); + } + + /** + * Returns true if the time since the last reset has exceeded + * the param time which is in the param units. + * + * @param time The param time + * @param unit The unit of the time + * @return true if the time since the last reset has exceeded + * the param time + * @see #passed(Number) + */ + public boolean passed(Number time, TimeUnit unit) { + return passed(unit.toMillis(time.longValue())); + } + + /** + * @return + */ + @Override + public long getElapsedTime() { + return toMillis(System.nanoTime() - time); + } + + /** + * @param time + */ + @Override + public void setElapsedTime(Number time) { + this.time = time.longValue() == MAX_TIME ? 0 : + System.nanoTime() - time.longValue(); + } + + public void setDelay(Number delay) { + this.time += delay.longValue(); + } + + /** + * @return + */ + public long getElapsedTime(TimeUnit unit) { + return unit.convert(getElapsedTime(), TimeUnit.MILLISECONDS); + } + + public long getLastResetTime() { + return lastResetTime; + } + + /** + * Sets the cached time since the last reset to the current time + */ + @Override + public void reset() { + long time = System.nanoTime(); + lastResetTime = time - this.time; + + this.time = time; + } + + /** + * @return + */ + private long toMillis(long nanos) { + return nanos / 1000000; + } + +} diff --git a/src/main/java/com/genyo/addon/systems/timer/ShorelineTimer.java b/src/main/java/com/genyo/addon/systems/timer/ShorelineTimer.java new file mode 100644 index 0000000..4a0f61c --- /dev/null +++ b/src/main/java/com/genyo/addon/systems/timer/ShorelineTimer.java @@ -0,0 +1,34 @@ +package com.genyo.addon.systems.timer; + +public interface ShorelineTimer { + // + long MAX_TIME = -0xff; + + /** + * Returns true if the time since the last reset has exceeded + * the param time. + * + * @param time The param time + * @return true if the time since the last reset has exceeded + * the param time + */ + boolean passed(Number time); + + /** + * Resets the current elapsed time state of the timer and restarts the + * timer from 0. + */ + void reset(); + + /** + * Returns the elapsed time since the last reset of the timer. + * + * @return The elapsed time since the last reset + */ + long getElapsedTime(); + + /** + * @param time + */ + void setElapsedTime(Number time); +} diff --git a/src/main/resources/genyo.mixins.json b/src/main/resources/genyo.mixins.json index 072fd05..00e1e9a 100644 --- a/src/main/resources/genyo.mixins.json +++ b/src/main/resources/genyo.mixins.json @@ -6,7 +6,8 @@ "PlayerUtilsMixin", "FriendsInjector", "IEntity", - "DefaultSettingsWidgetFactoryMixin" + "DefaultSettingsWidgetFactoryMixin", + "AccessorGameOptions" ], "injectors": { "defaultRequire": 1