-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from BlackLotus-SMP/1.20.2
1.20.2 update
- Loading branch information
Showing
12 changed files
with
71 additions
and
43 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
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
26 changes: 20 additions & 6 deletions
26
src/main/java/com/kahzerx/kahzerxmod/mixin/kloneExtension/NetworkHandlerMixin.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,32 +1,46 @@ | ||
package com.kahzerx.kahzerxmod.mixin.kloneExtension; | ||
|
||
import com.kahzerx.kahzerxmod.klone.KlonePlayerEntity; | ||
import com.mojang.authlib.GameProfile; | ||
import net.minecraft.network.ClientConnection; | ||
import net.minecraft.network.packet.Packet; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraft.server.network.ConnectedClientData; | ||
import net.minecraft.server.network.ServerCommonNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayNetworkHandler; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(value = ServerPlayNetworkHandler.class, priority = 69420) | ||
public class NetworkHandlerMixin { | ||
@Shadow public ServerPlayerEntity player; | ||
@Mixin(value = ServerCommonNetworkHandler.class, priority = 69420) | ||
public abstract class NetworkHandlerMixin { | ||
@Shadow protected abstract GameProfile getProfile(); | ||
|
||
@Shadow @Final protected MinecraftServer server; | ||
|
||
@Inject(method = "sendPacket(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true) | ||
private void onSendPacket(Packet<?> packet, CallbackInfo ci) { | ||
if (player instanceof KlonePlayerEntity) { | ||
if (this.getPlayer() instanceof KlonePlayerEntity) { | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Inject(method = "disconnect", at = @At("HEAD"), cancellable = true) | ||
private void onDisconnect(Text reason, CallbackInfo ci) { | ||
if (player instanceof KlonePlayerEntity) { | ||
((KlonePlayerEntity) player).kill(reason); | ||
if (this.getPlayer() instanceof KlonePlayerEntity) { | ||
((KlonePlayerEntity) this.getPlayer()).kill(reason); | ||
ci.cancel(); | ||
} | ||
} | ||
|
||
@Unique | ||
private ServerPlayerEntity getPlayer() { | ||
return this.server.getPlayerManager().getPlayer(this.getProfile().getId()); | ||
} | ||
} |
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
18 changes: 12 additions & 6 deletions
18
...eports/ServerPlayNetworkHandlerMixin.java → ...orts/ServerCommonNetworkHandlerMixin.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
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
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