fix ping causing bad packet events
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m40s
All checks were successful
/ Build BaseBand DSM & Broadway (push) Successful in 2m40s
This commit is contained in:
parent
25f358f361
commit
920ea1229d
3 changed files with 36 additions and 10 deletions
|
@ -0,0 +1,30 @@
|
||||||
|
package de.com.baseband.client.event.events;
|
||||||
|
|
||||||
|
import de.com.baseband.client.event.CancellableEvent;
|
||||||
|
import net.minecraft.network.Packet;
|
||||||
|
|
||||||
|
public abstract class PrePacketEvent extends CancellableEvent {
|
||||||
|
|
||||||
|
private final Packet<?> packet;
|
||||||
|
|
||||||
|
public PrePacketEvent(Packet<?> packet) {
|
||||||
|
this.packet = packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Packet<?> getPacket() {
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Send extends PrePacketEvent {
|
||||||
|
public Send(Packet<?> packet) {
|
||||||
|
super(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Receive extends PrePacketEvent {
|
||||||
|
public Receive(Packet<?> packet) {
|
||||||
|
super(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
package de.com.baseband.client.feature.modules.ingame;
|
package de.com.baseband.client.feature.modules.ingame;
|
||||||
|
|
||||||
import de.com.baseband.client.BaseBand;
|
import de.com.baseband.client.BaseBand;
|
||||||
import de.com.baseband.client.event.events.PacketEvent;
|
import de.com.baseband.client.event.events.PrePacketEvent;
|
||||||
import de.com.baseband.client.event.events.PlayerDestroyEvent;
|
|
||||||
import de.com.baseband.client.feature.Feature;
|
import de.com.baseband.client.feature.Feature;
|
||||||
import de.com.baseband.client.feature.category.Ingame;
|
import de.com.baseband.client.feature.category.Ingame;
|
||||||
import de.com.baseband.client.registry.annotation.Config;
|
import de.com.baseband.client.registry.annotation.Config;
|
||||||
|
@ -97,7 +96,7 @@ public class Ping extends Feature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPacket(PacketEvent.Send e) {
|
public void onPacket(PrePacketEvent.Send e) {
|
||||||
if(allowSend == e.getPacket() || notIngame())
|
if(allowSend == e.getPacket() || notIngame())
|
||||||
return;
|
return;
|
||||||
if (e.getPacket() instanceof CPacketKeepAlive || holdAll) {
|
if (e.getPacket() instanceof CPacketKeepAlive || holdAll) {
|
||||||
|
@ -107,7 +106,7 @@ public class Ping extends Feature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPacket(PacketEvent.Receive e) {
|
public void onPacket(PrePacketEvent.Receive e) {
|
||||||
if(allowRecv == e.getPacket() || notIngame())
|
if(allowRecv == e.getPacket() || notIngame())
|
||||||
return;
|
return;
|
||||||
if (e.getPacket() instanceof SPacketKeepAlive || holdAll) {
|
if (e.getPacket() instanceof SPacketKeepAlive || holdAll) {
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package de.com.baseband.client.mixin;
|
package de.com.baseband.client.mixin;
|
||||||
|
|
||||||
import de.com.baseband.client.BaseBand;
|
import de.com.baseband.client.BaseBand;
|
||||||
import de.com.baseband.client.event.events.DamageBlockEvent;
|
import de.com.baseband.client.event.events.*;
|
||||||
import de.com.baseband.client.event.events.MotionUpdateEvent;
|
|
||||||
import de.com.baseband.client.event.events.MoveEvent;
|
|
||||||
import de.com.baseband.client.event.events.PacketEvent;
|
|
||||||
import de.com.baseband.client.feature.Features;
|
import de.com.baseband.client.feature.Features;
|
||||||
import de.com.baseband.client.feature.modules.chat.ChatExtras;
|
import de.com.baseband.client.feature.modules.chat.ChatExtras;
|
||||||
import de.com.baseband.client.feature.modules.client.Client;
|
import de.com.baseband.client.feature.modules.client.Client;
|
||||||
|
@ -66,12 +63,12 @@ public class MixinProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPacketReceive(Packet<?> p_channelRead0_2_, CallbackInfo ci) {
|
public static void onPacketReceive(Packet<?> p_channelRead0_2_, CallbackInfo ci) {
|
||||||
if (BaseBand.publish(new PacketEvent.Receive(p_channelRead0_2_)).isCancelled())
|
if (BaseBand.publish(new PrePacketEvent.Receive(p_channelRead0_2_)).isCancelled() || BaseBand.publish(new PacketEvent.Receive(p_channelRead0_2_)).isCancelled())
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onPacketSend(Packet<?> packetIn, CallbackInfo ci) {
|
public static void onPacketSend(Packet<?> packetIn, CallbackInfo ci) {
|
||||||
if (BaseBand.publish(new PacketEvent.Send(packetIn)).isCancelled())
|
if (BaseBand.publish(new PrePacketEvent.Send(packetIn)).isCancelled() || BaseBand.publish(new PacketEvent.Send(packetIn)).isCancelled())
|
||||||
ci.cancel();
|
ci.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue