-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
46 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/java/com/sollace/fabwork/impl/ClientConnectionAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.sollace.fabwork.impl; | ||
|
||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
|
||
public interface ClientConnectionAccessor { | ||
ClientConnection getConnection(); | ||
|
||
static ClientConnection get(ServerPlayNetworkHandler handler) { | ||
return ((ClientConnectionAccessor)handler).getConnection(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
src/main/java/com/sollace/fabwork/impl/mixin/ServerPlayNetworkHandlerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
package com.sollace.fabwork.impl.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import com.sollace.fabwork.impl.ClientConnectionAccessor; | ||
import com.sollace.fabwork.impl.PlayPingSynchroniser; | ||
|
||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.network.NetworkThreadUtils; | ||
import net.minecraft.network.listener.ServerPlayPacketListener; | ||
import net.minecraft.network.packet.c2s.play.PlayPongC2SPacket; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
|
||
@Mixin(ServerPlayNetworkHandler.class) | ||
abstract class ServerPlayNetworkHandlerMixin implements ServerPlayPacketListener { | ||
abstract class ServerPlayNetworkHandlerMixin implements ServerPlayPacketListener, ClientConnectionAccessor { | ||
@Inject(method = "onPong(Lnet/minecraft/network/packet/c2s/play/PlayPongC2SPacket;)V", at = @At("HEAD")) | ||
private void onOnPong(PlayPongC2SPacket packet, CallbackInfo info) { | ||
NetworkThreadUtils.forceMainThread(packet, this, ((ServerPlayNetworkHandler)(Object)this).player.getWorld()); | ||
NetworkThreadUtils.forceMainThread(packet, this, ((ServerPlayNetworkHandler)(Object)this).player.getServerWorld()); | ||
PlayPingSynchroniser.onClientResponse(packet, ((ServerPlayNetworkHandler)(Object)this).player.getWorld().getServer()); | ||
} | ||
|
||
@Override | ||
@Accessor("connection") | ||
public abstract ClientConnection getConnection(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters