This commit is contained in:
Moulberry committed 2024-07-25 16:40:29 +08:00
1 parent 9c4a30d224
commit 666398e480
174 files changed
+8694 -2942

No files matched your search

@@ -0,0 +1,44 @@
package com.moulberry.flashback.mixin.playback;
import com.moulberry.flashback.Flashback;
import com.moulberry.flashback.playback.ReplayServer;
import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Entity.class)
public abstract class MixinEntity {
@Shadow
public abstract boolean isInvisible();
@Shadow
private Level level;
@Shadow
public abstract boolean isInvisibleTo(Player player);
@Inject(method = "isInvisibleTo", at = @At("HEAD"), cancellable = true)
public void isInvisibleTo(Player player, CallbackInfoReturnable<Boolean> cir) {
ReplayServer replayServer = Flashback.getReplayServer();
if (replayServer != null && player == Minecraft.getInstance().player) {
int localId = replayServer.getLocalPlayerId();
if (this.level.getEntity(localId) instanceof Player localPlayer) {
if ((Object)this == localPlayer) {
cir.setReturnValue(false);
} else {
cir.setReturnValue(this.isInvisibleTo(localPlayer));
}
} else {
cir.setReturnValue(this.isInvisible());
}
}
}
}