add timer autoadjust
This commit is contained in:
parent
5e80dfa18e
commit
602d17bd8c
9 changed files with 57 additions and 12 deletions
|
@ -21,8 +21,8 @@ public abstract class PacketEvent extends CancellableEvent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Read extends PacketEvent {
|
public static class Receive extends PacketEvent {
|
||||||
public Read(Packet<?> packet) {
|
public Receive(Packet<?> packet) {
|
||||||
super(packet);
|
super(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class ChatCrypt extends Feature {
|
||||||
String sentOriginal = null;
|
String sentOriginal = null;
|
||||||
String sentEncrypted = null;
|
String sentEncrypted = null;
|
||||||
|
|
||||||
public void onPacketRead(PacketEvent.Read e) {
|
public void onPacketRead(PacketEvent.Receive e) {
|
||||||
if (e.getPacket() instanceof SPacketChat) {
|
if (e.getPacket() instanceof SPacketChat) {
|
||||||
String message = ((SPacketChat) e.getPacket()).getChatComponent().getUnformattedText();
|
String message = ((SPacketChat) e.getPacket()).getChatComponent().getUnformattedText();
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class ChatExtras extends Feature {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void onChat(PacketEvent.Read event) {
|
public void onChat(PacketEvent.Receive event) {
|
||||||
if (event.getPacket() instanceof SPacketChat && antiPopLag) {
|
if (event.getPacket() instanceof SPacketChat && antiPopLag) {
|
||||||
String message = ((SPacketChat) event.getPacket()).getChatComponent().getUnformattedText();
|
String message = ((SPacketChat) event.getPacket()).getChatComponent().getUnformattedText();
|
||||||
Pattern pattern = Pattern.compile("[^\t\r\n\\x20-\\x7E]+", Pattern.CASE_INSENSITIVE);
|
Pattern pattern = Pattern.compile("[^\t\r\n\\x20-\\x7E]+", Pattern.CASE_INSENSITIVE);
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class ChatFilter extends Feature {
|
||||||
return "ChatFilter";
|
return "ChatFilter";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPacketRead(PacketEvent.Read event) {
|
public void onPacketRead(PacketEvent.Receive event) {
|
||||||
if(event.getPacket() instanceof SPacketChat) {
|
if(event.getPacket() instanceof SPacketChat) {
|
||||||
SPacketChat packet = ((SPacketChat) event.getPacket());
|
SPacketChat packet = ((SPacketChat) event.getPacket());
|
||||||
String message = packet.getChatComponent().getFormattedText();
|
String message = packet.getChatComponent().getFormattedText();
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class Client extends Feature {
|
||||||
ServerDataManager.onPlayerDestroy();
|
ServerDataManager.onPlayerDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPacket(PacketEvent.Read packetEvent) {
|
public void onPacket(PacketEvent.Receive packetEvent) {
|
||||||
Packet<?> packet = packetEvent.getPacket();
|
Packet<?> packet = packetEvent.getPacket();
|
||||||
if (packet instanceof SPacketTimeUpdate) {
|
if (packet instanceof SPacketTimeUpdate) {
|
||||||
ServerDataManager.onTimePacket();
|
ServerDataManager.onTimePacket();
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.baseband.client.feature.client;
|
package com.baseband.client.feature.client;
|
||||||
|
|
||||||
|
import com.baseband.client.event.events.PacketEvent;
|
||||||
import com.baseband.client.event.events.PlayerDestroyEvent;
|
import com.baseband.client.event.events.PlayerDestroyEvent;
|
||||||
import com.baseband.client.feature.Feature;
|
import com.baseband.client.feature.Feature;
|
||||||
import com.baseband.client.feature.category.ClientCategory;
|
import com.baseband.client.feature.category.ClientCategory;
|
||||||
|
@ -11,6 +12,7 @@ import com.baseband.client.util.adapt.FieldFinder;
|
||||||
import com.baseband.client.util.adapt.Marker;
|
import com.baseband.client.util.adapt.Marker;
|
||||||
import com.baseband.client.util.interact.ServerDataManager;
|
import com.baseband.client.util.interact.ServerDataManager;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.network.play.server.SPacketPlayerPosLook;
|
||||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
|
@ -27,7 +29,14 @@ public class Timer extends Feature {
|
||||||
public boolean destroy;
|
public boolean destroy;
|
||||||
@Config("Multiplier")
|
@Config("Multiplier")
|
||||||
@Range("0.05..7.5")
|
@Range("0.05..7.5")
|
||||||
public float m = 0.5f;
|
public float multiplier = 0.5f;
|
||||||
|
float m = multiplier;
|
||||||
|
@Config("Adjust slower")
|
||||||
|
@Description("Adjusts the timer to be slower when being lagged back.")
|
||||||
|
public boolean adjSlower = false;
|
||||||
|
@Config("Adjust faster")
|
||||||
|
@Description("Adjusts the timer to be faster when not being lagged back.")
|
||||||
|
public boolean adjFaster = false;
|
||||||
@Config("Adjust to server")
|
@Config("Adjust to server")
|
||||||
@Description("Adjusts the client's TPS to the server's. Enable either Fasten or Slowdown for this to do anything.\n" +
|
@Description("Adjusts the client's TPS to the server's. Enable either Fasten or Slowdown for this to do anything.\n" +
|
||||||
"The client TPS is §lALSO§r still going to be adjusted by the Multiplier.")
|
"The client TPS is §lALSO§r still going to be adjusted by the Multiplier.")
|
||||||
|
@ -41,7 +50,12 @@ public class Timer extends Feature {
|
||||||
@Description("Allows client to run slower than 20TPS if the server runs at that speed. This usually doesn't cause any lag-backs, and even prevents them in very low TPS.")
|
@Description("Allows client to run slower than 20TPS if the server runs at that speed. This usually doesn't cause any lag-backs, and even prevents them in very low TPS.")
|
||||||
@Gate(1)
|
@Gate(1)
|
||||||
public boolean slowdown = true;
|
public boolean slowdown = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
m = multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
setGameTimer(20);
|
setGameTimer(20);
|
||||||
|
@ -57,11 +71,36 @@ public class Timer extends Feature {
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onRender(RenderWorldLastEvent event) {
|
public void onRender(RenderWorldLastEvent event) {
|
||||||
onTick();
|
tickTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lbCounter = 0;
|
||||||
|
int noLbCounter = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick() {
|
public void onTick() {
|
||||||
|
if(!adjFaster && !adjSlower) {
|
||||||
|
m = multiplier;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (lbCounter > 0)
|
||||||
|
lbCounter--;
|
||||||
|
if (lbCounter > 40 && adjSlower) {
|
||||||
|
m = Math.max(m - 0.05f, 0.5f);
|
||||||
|
lbCounter -= 40;
|
||||||
|
}
|
||||||
|
if (lbCounter == 0) {
|
||||||
|
noLbCounter++;
|
||||||
|
} else noLbCounter = 0;
|
||||||
|
if (noLbCounter > 80 && adjFaster) {
|
||||||
|
m = Math.min(m + 0.05f, multiplier);
|
||||||
|
noLbCounter = 40;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tickTimer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tickTimer() {
|
||||||
if (timerLock) {
|
if (timerLock) {
|
||||||
text = "Timer" + (enabled ? " §7[LOCKED]" : "");
|
text = "Timer" + (enabled ? " §7[LOCKED]" : "");
|
||||||
if(multiplierLock != null) {
|
if(multiplierLock != null) {
|
||||||
|
@ -94,4 +133,10 @@ public class Timer extends Feature {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onPacket(PacketEvent.Receive event) {
|
||||||
|
if(event.getPacket() instanceof SPacketPlayerPosLook) {
|
||||||
|
lbCounter += 40;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class Speed extends Feature {
|
||||||
//Time will tell.
|
//Time will tell.
|
||||||
//higher priority than default, so we can get explosion packets before velocity fucks with them
|
//higher priority than default, so we can get explosion packets before velocity fucks with them
|
||||||
@Priority(value = 2)
|
@Priority(value = 2)
|
||||||
public void onPacketReceive(PacketEvent.Read event) {
|
public void onPacketReceive(PacketEvent.Receive event) {
|
||||||
if(notIngame()) {
|
if(notIngame()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class Velocity extends Feature {
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void packetRead(PacketEvent.Read event) {
|
public void packetRead(PacketEvent.Receive event) {
|
||||||
if (event.getPacket() instanceof SPacketEntityVelocity) {
|
if (event.getPacket() instanceof SPacketEntityVelocity) {
|
||||||
SPacketEntityVelocity velocity = (SPacketEntityVelocity) event.getPacket();
|
SPacketEntityVelocity velocity = (SPacketEntityVelocity) event.getPacket();
|
||||||
if (velocity.getEntityID() == mc.player.getEntityId()) {
|
if (velocity.getEntityID() == mc.player.getEntityId()) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class MixinNetworkManager {
|
||||||
|
|
||||||
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
|
@Inject(method = "channelRead0(Lio/netty/channel/ChannelHandlerContext;Lnet/minecraft/network/Packet;)V", at = @At("HEAD"), cancellable = true)
|
||||||
public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) {
|
public void channelRead0(ChannelHandlerContext p_channelRead0_1_, Packet<?> p_channelRead0_2_, CallbackInfo ci) {
|
||||||
if (BaseBand.publish(new PacketEvent.Read(p_channelRead0_2_)).isCancelled())
|
if (BaseBand.publish(new PacketEvent.Receive(p_channelRead0_2_)).isCancelled())
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue