mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Merge branch '1.19.3-multiloader' into 1.19.1-multiloader
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -30,3 +30,4 @@ bin/
|
||||
|
||||
.architectury-transformer/
|
||||
run/
|
||||
scripts/
|
||||
|
||||
@@ -3,12 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
publishMods {
|
||||
if (project.name == 'fabric')
|
||||
file = remapJar.archiveFile
|
||||
else if (project.name == 'neoforge')
|
||||
file = jar.archiveFile
|
||||
else
|
||||
file = tasks.named('jarJar').get().archiveFile
|
||||
file = project.layout.buildDirectory.file("libs/${project.archivesBaseName}-${project.version}.jar").map { it.asFile }.getOrNull()
|
||||
|
||||
modLoaders.add(project.name)
|
||||
type = STABLE
|
||||
|
||||
@@ -5,17 +5,26 @@ import net.minecraft.network.Connection;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(PlayerList.class)
|
||||
public abstract class PlayerListMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract List<ServerPlayer> getPlayers();
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftServer server;
|
||||
|
||||
@Inject(method = "remove", at = @At("TAIL"))
|
||||
private void remove(ServerPlayer player, CallbackInfo ci) {
|
||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
||||
@@ -23,14 +32,13 @@ public abstract class PlayerListMixin {
|
||||
|
||||
@Inject(method = "removeAll", at = @At("HEAD"))
|
||||
private void removeAll(CallbackInfo ci) {
|
||||
for (var player : ((PlayerList) (Object) this).getPlayers()) {
|
||||
for (var player : getPlayers()) {
|
||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "placeNewPlayer", at = @At("HEAD"))
|
||||
private void placeNewPlayer(Connection connection, ServerPlayer player, CallbackInfo ci) {
|
||||
var server = ((PlayerList) (Object) this).getServer();
|
||||
var delay = SkinRestorer.getConfig().skinApplyDelayOnJoin();
|
||||
|
||||
if (delay <= 0) {
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(ServerLoginPacketListenerImpl.class)
|
||||
public interface ServerLoginPacketListenerImplAccessorInvoker {
|
||||
|
||||
@Accessor
|
||||
GameProfile getGameProfile();
|
||||
|
||||
@Invoker
|
||||
GameProfile invokeCreateFakeProfile(GameProfile original);
|
||||
}
|
||||
@@ -20,6 +20,12 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Mixin(ServerLoginPacketListenerImpl.class)
|
||||
public abstract class ServerLoginPacketListenerImplMixin {
|
||||
|
||||
@Shadow @Nullable
|
||||
private GameProfile gameProfile;
|
||||
|
||||
@Shadow
|
||||
protected abstract GameProfile createFakeProfile(GameProfile original);
|
||||
|
||||
@Unique
|
||||
private CompletableFuture<Void> skinrestorer$pendingSkin;
|
||||
|
||||
@@ -27,11 +33,11 @@ public abstract class ServerLoginPacketListenerImplMixin {
|
||||
public void waitForSkin(CallbackInfo ci) {
|
||||
if (skinrestorer$pendingSkin == null) {
|
||||
skinrestorer$pendingSkin = CompletableFuture.supplyAsync(() -> {
|
||||
var profile = ((ServerLoginPacketListenerImplAccessorInvoker) this).getGameProfile();
|
||||
var profile = gameProfile;
|
||||
assert profile != null;
|
||||
|
||||
if (!profile.isComplete())
|
||||
profile = ((ServerLoginPacketListenerImplAccessorInvoker) this).invokeCreateFakeProfile(profile);
|
||||
profile = createFakeProfile(profile);
|
||||
|
||||
var originalSkin = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
"mixins": [
|
||||
"ChunkMapAccessor",
|
||||
"PlayerListMixin",
|
||||
"ServerLoginPacketListenerImplAccessorInvoker",
|
||||
"ServerLoginPacketListenerImplMixin",
|
||||
"TrackedEntityAccessorInvoker"
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user