Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.

Commit

Permalink
Update to 1.12.2
Browse files Browse the repository at this point in the history
And remove keepalive packet modification for now
  • Loading branch information
mikroskeem committed Sep 19, 2017
1 parent 54f04c6 commit 79880cb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 53 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repositories {
dependencies {
compileOnly group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jre8', version: kotlin_version
compileOnly group: 'com.destroystokyo.paper', name: 'paper-api', version: '1.12.1-R0.1-SNAPSHOT'
compileOnly group: 'com.destroystokyo.paper', name: 'paper', version: '1.12.1-R0.1-SNAPSHOT'
compileOnly group: 'com.destroystokyo.paper', name: 'paper', version: '1.12.2-R0.1-SNAPSHOT'
compileOnly group: 'eu.mikroskeem', name: 'orion.api', version: '0.0.1'
compileOnly group: 'io.sentry', name: 'sentry', version: '1.3.0'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ public abstract class MixinPlayerConnection {

@Shadow public abstract void sendPacket(Packet<?> packet);
@Shadow public abstract CraftPlayer getPlayer();
@Shadow protected abstract long d();
@Shadow public EntityPlayer player;
@Shadow private int f;
@Shadow private int e;
@Shadow private long h;
@Shadow private long g;

private int helios$awayTicks = 0;

Expand Down Expand Up @@ -95,51 +90,4 @@ private void onUpdate(CallbackInfo cb) {
}
}
}

/* Replacement keepalive packet sender: TODO */
@Inject(method = "e", at = @At(
value = "JUMP",
opcode = Opcodes.IFLE,
ordinal = 0
))
private void onSendKeepAlive(CallbackInfo cb) {
long threshold = HeliosMod.INSTANCE.getConfigurationWrapper()
.getConfiguration()
.getPlayer()
.getKeepalivePacketThreshold();

long networkTickCount = (long) this.e;
long lastSentPingPacket = this.h;
if(networkTickCount - lastSentPingPacket > threshold) {
/* lastSentPingPacket */ this.h = networkTickCount;
/* lastPingTime = currentTimeMillis() */ this.g = this.d();
/* keepAliveId = lastPingTime */ this.f = (int) this.g;
sendPacket(new PacketPlayOutKeepAlive(this.f));
}
}

/*
* Fuck following if statement:
*
* if(this.e - this.h > 40L)
*
* Since (0 - 0) > 40 == false
*/
@Redirect(method = "e", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = helios$NETWORK_TICK_COUNT, ordinal = 1))
private int getNetworkTickCount(PlayerConnection playerConnection) { return 0; }
@Redirect(method = "e", at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = helios$LAST_SENT_PING_PACKET, ordinal = 0))
private long getLastSentPingPacket(PlayerConnection playerConnection) { return 0; }
/* End fucking the if statement :) */

@Inject(method = helios$PROCESS_KEEP_ALIVE, cancellable = true, at = @At("HEAD"))
private void onProcessKeepAlive(PacketPlayInKeepAlive keepAlive, CallbackInfo cb) {
int keepAliveKey = this.f;
int packetKey = keepAlive.a();
if(keepAliveKey == packetKey) {
int i = (int) (this.d() - this.g);
this.player.ping = (this.player.ping * 3 + i) / 4;
}

cb.cancel();
}
}

0 comments on commit 79880cb

Please sign in to comment.