Skip to content

Commit

Permalink
feat✨(fake player): Fix fake player spawning crashing the server of c…
Browse files Browse the repository at this point in the history
…arpet between 1.20.2~1.20.4
  • Loading branch information
wendavid552 committed Sep 4, 2024
1 parent cac5650 commit f5aa974
Showing 1 changed file with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,50 @@
package club.mcams.carpetpatcher.mixins.fakePlayerCrashing;

import carpet.patches.EntityPlayerMPFake;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.authlib.GameProfile;
import net.minecraft.server.MinecraftServer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

@Mixin(value = EntityPlayerMPFake.class, remap = false)
public class EntityPlayerMPFakeMixin {

// @WrapMethod(
// method = "createFake"
// )
// private static EntityPlayerMPFake createFake(String username, MinecraftServer server, double d0, double d1, double d2, double yaw, double pitch, DimensionType dimension, GameMode gamemode, Operation<EntityPlayerMPFake> original) {
// try {
// CompletableFuture<EntityPlayerMPFake> future = CompletableFuture.supplyAsync(() -> original.call(username, server, d0, d1, d2, yaw, pitch, dimension, gamemode), server);
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// // 异常处理
// e.printStackTrace();
// // 根据需求返回默认值或其他处理
// return null;
// }
// }
//
// @WrapOperation(
// method = "createFake",
//
// )
//上面的先不管,优先处理会崩服的
//#if MC>=12002 && MC<=12004
//$$ @WrapOperation(
//$$ method = "createFake",
//$$ at = @At(
//$$ value = "INVOKE",
//$$ target = "Ljava/util/concurrent/CompletableFuture;thenAccept(Ljava/util/function/Consumer;)Ljava/util/concurrent/CompletableFuture;"
//$$ )
//$$ )
//$$ private static CompletableFuture<Void> createFake(CompletableFuture<Optional<GameProfile>> instance, Consumer<Optional<GameProfile>> action, Operation<CompletableFuture<Void>> original, @Local(argsOnly = true) MinecraftServer server) {
//$$ return instance.thenAcceptAsync(action, server);
//$$ }
//#endif
}

0 comments on commit f5aa974

Please sign in to comment.