Skip to content

Commit

Permalink
Skip loading and saving dummy data
Browse files Browse the repository at this point in the history
  • Loading branch information
misode committed Dec 27, 2023
1 parent a3fe4c2 commit 59ca357
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/io/github/misode/packtest/mixin/PlayerListMixin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.misode.packtest.mixin;

import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.llamalad7.mixinextras.sugar.Local;
Expand All @@ -15,6 +16,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

/**
Expand All @@ -31,6 +33,21 @@ private void fixStartingPos(ServerPlayer player, CallbackInfoReturnable<Compound
}
}

@ModifyReturnValue(method = "load", at = @At(value = "RETURN"))
private CompoundTag skipLoadDummy(CompoundTag original, @Local(ordinal = 0) ServerPlayer player) {
if (player instanceof Dummy) {
return null;
}
return original;
}

@Inject(method = "save", at = @At(value = "HEAD"), cancellable = true)
private void skipSaveDummy(ServerPlayer player, CallbackInfo ci) {
if (player instanceof Dummy) {
ci.cancel();
}
}

@WrapOperation(method = "respawn", at = @At(value = "NEW", target = "(Lnet/minecraft/server/MinecraftServer;Lnet/minecraft/server/level/ServerLevel;Lcom/mojang/authlib/GameProfile;Lnet/minecraft/server/level/ClientInformation;)Lnet/minecraft/server/level/ServerPlayer;"))
private ServerPlayer createDummy(MinecraftServer server, ServerLevel level, GameProfile profile, ClientInformation cli, Operation<ServerPlayer> original, @Local(ordinal = 0) ServerPlayer player) {
if (player instanceof Dummy dummy) {
Expand Down

0 comments on commit 59ca357

Please sign in to comment.