add timer
This commit is contained in:
parent
e7e95e17fd
commit
e249ecb663
3 changed files with 116 additions and 0 deletions
|
@ -6,6 +6,7 @@ import com.baseband.client.module.chat.ChatCrypt;
|
|||
import com.baseband.client.module.chat.ExtraChat;
|
||||
import com.baseband.client.module.client.Client;
|
||||
import com.baseband.client.module.client.MidClick;
|
||||
import com.baseband.client.module.client.Timer;
|
||||
import com.baseband.client.module.combat.AutoKill;
|
||||
import com.baseband.client.module.combat.AutoTotem;
|
||||
import com.baseband.client.module.command.Bind;
|
||||
|
@ -53,6 +54,7 @@ public class Setup {
|
|||
new Bright(),
|
||||
new MidClick(),
|
||||
new Selection(),
|
||||
new Timer(),
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package com.baseband.client.module.client;
|
||||
|
||||
import com.baseband.client.configuration.annotation.Config;
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import com.baseband.client.event.events.PlayerDestroyEvent;
|
||||
import com.baseband.client.gui.GuiTheme;
|
||||
import com.baseband.client.init.BaseBand;
|
||||
import com.baseband.client.module.Feature;
|
||||
import com.baseband.client.util.ingame.ChatUtil;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketTimeUpdate;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@com.baseband.client.module.category.Client
|
||||
|
@ -52,4 +56,47 @@ public class Client extends Feature {
|
|||
BaseBand.disabled = true;
|
||||
ChatUtil.print("Waiting for config...");
|
||||
}
|
||||
|
||||
|
||||
public float tps = 20;
|
||||
long lastDiff = 0;
|
||||
long lastTick = -1;
|
||||
|
||||
public void onPlayerDestroy(PlayerDestroyEvent event) {
|
||||
tps = 20;
|
||||
}
|
||||
|
||||
public void onPacket(PacketEvent.Read packetEvent) {
|
||||
Packet<?> packet = packetEvent.getPacket();
|
||||
if (packet instanceof SPacketTimeUpdate) {
|
||||
long time = System.currentTimeMillis();
|
||||
if (lastTick != -1) {
|
||||
long diff = time - lastTick;
|
||||
time(diff);
|
||||
lastDiff = diff;
|
||||
}
|
||||
lastTick = time;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
if (notIngame()) return;
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
if (lastTick != -1) {
|
||||
long diff = time - lastTick;
|
||||
if (diff > 3000 && diff > lastDiff) {
|
||||
time(diff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void time(long diff) {
|
||||
if (lastTick != -1) {
|
||||
if (diff > 50) {
|
||||
tps = (1000f / diff) * 20f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package com.baseband.client.module.client;
|
||||
|
||||
import com.baseband.client.configuration.annotation.Config;
|
||||
import com.baseband.client.configuration.annotation.Gate;
|
||||
import com.baseband.client.configuration.annotation.Range;
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import com.baseband.client.event.events.PlayerDestroyEvent;
|
||||
import com.baseband.client.init.BaseBand;
|
||||
import com.baseband.client.module.Feature;
|
||||
import com.baseband.client.module.category.Client;
|
||||
import com.baseband.client.util.misc.FieldFinder;
|
||||
import com.baseband.client.util.misc.Marker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.play.server.SPacketTimeUpdate;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
@Client
|
||||
public class Timer extends Feature {
|
||||
|
||||
@Config("Multiplier")
|
||||
@Range("0.05..7.5")
|
||||
float m = 0.5f;
|
||||
@Config("Adjust to server")
|
||||
@Marker(1)
|
||||
public boolean adjust = false;
|
||||
@Config("Fasten")
|
||||
@Gate(1)
|
||||
boolean fasten = false;
|
||||
@Config("Slowdown")
|
||||
@Gate(1)
|
||||
boolean slowdown = true;
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
setGameTimer(20);
|
||||
}
|
||||
|
||||
public void onPlayerDestroy(PlayerDestroyEvent event) {
|
||||
toggle();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onRender(RenderWorldLastEvent event) {
|
||||
onTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick() {
|
||||
setGameTimer(BaseBand.getFeature(com.baseband.client.module.client.Client.class).tps * m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Timer [TPS: " + BaseBand.getFeature(com.baseband.client.module.client.Client.class).tps * m + "]";
|
||||
}
|
||||
|
||||
public void setGameTimer(float tps) {
|
||||
try {
|
||||
Object timer = FieldFinder.findUnmarked(Minecraft.class, net.minecraft.util.Timer.class, 0).get(mc);
|
||||
FieldFinder.findUnmarked(net.minecraft.util.Timer.class, float.class, 2).setFloat(timer, 1000f / tps);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue