mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 22:17:10 +00:00
0.4.0
This commit is contained in:
1 parent
fcf1b4168f
commit
2fbe1f5480
46 files changed
+1846
-132
No files matched your search
@@ -1,23 +1,58 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.editor.ui.CustomImGuiImplGlfw;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.phys.HitResult;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Gui.class)
|
||||
public class MixinGui {
|
||||
public abstract class MixinGui {
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
protected abstract Player getCameraPlayer();
|
||||
|
||||
@Unique
|
||||
private GameType cameraGameType = GameType.DEFAULT_MODE;
|
||||
|
||||
@Inject(method = "render", at = @At("HEAD"))
|
||||
public void render_updateCameraGameType(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
var connection = Minecraft.getInstance().getConnection();
|
||||
if (connection != null) {
|
||||
var playerInfo = connection.getPlayerInfo(player.getUUID());
|
||||
if (playerInfo != null) {
|
||||
this.cameraGameType = playerInfo.getGameMode();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.cameraGameType = Minecraft.getInstance().gameMode.getPlayerMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderChat", at = @At("HEAD"), cancellable = true)
|
||||
public void renderChat(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo ci) {
|
||||
@@ -51,6 +86,84 @@ public class MixinGui {
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderHotbarAndDecorations", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;getPlayerMode()Lnet/minecraft/world/level/GameType;"))
|
||||
public GameType renderHotbarAndDecorations_getPlayerMode(MultiPlayerGameMode instance, Operation<GameType> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
return this.cameraGameType;
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderHotbarAndDecorations", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;canHurtPlayer()Z"))
|
||||
public boolean renderHotbarAndDecorations_canHurtPlayer(MultiPlayerGameMode instance, Operation<Boolean> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
return this.cameraGameType.isSurvival();
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@Inject(method = "isExperienceBarVisible", at = @At("HEAD"), cancellable = true)
|
||||
public void isExperienceBarVisible(CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Flashback.isInReplay()) {
|
||||
cir.setReturnValue(this.cameraGameType.isSurvival());
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderExperienceBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getXpNeededForNextLevel()I"))
|
||||
public int renderExperienceBar_getXpNeededForNextLevel(LocalPlayer instance, Operation<Integer> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.getXpNeededForNextLevel();
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderExperienceBar", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;experienceProgress:F"))
|
||||
public float renderExperienceBar_experienceProgress(LocalPlayer instance, Operation<Float> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.experienceProgress;
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getAttackStrengthScale(F)F"))
|
||||
public float renderCrosshair_getAttackStrengthScale(LocalPlayer instance, float partialTick, Operation<Float> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.getAttackStrengthScale(partialTick);
|
||||
}
|
||||
}
|
||||
return original.call(instance, partialTick);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/player/LocalPlayer;getCurrentItemAttackStrengthDelay()F"))
|
||||
public float renderCrosshair_getCurrentItemAttackStrengthDelay(LocalPlayer instance, Operation<Float> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.getCurrentItemAttackStrengthDelay();
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderExperienceLevel", at = @At(value = "FIELD", target = "Lnet/minecraft/client/player/LocalPlayer;experienceLevel:I"))
|
||||
public int renderExperienceLevel_experienceLevel(LocalPlayer instance, Operation<Integer> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
Player player = this.getCameraPlayer();
|
||||
if (player != null) {
|
||||
return player.experienceLevel;
|
||||
}
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@Inject(method = "renderVignette", at = @At("HEAD"), cancellable = true)
|
||||
public void renderVignette(GuiGraphics guiGraphics, Entity entity, CallbackInfo ci) {
|
||||
// The vignette ruins the transparency when trying to export with alpha
|
||||
@@ -62,16 +175,12 @@ public class MixinGui {
|
||||
|
||||
@Inject(method = "canRenderCrosshairForSpectator", at = @At("HEAD"), cancellable = true)
|
||||
public void canRenderCrosshairForSpectator(HitResult hitResult, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (Flashback.isExporting()) {
|
||||
cir.setReturnValue(false);
|
||||
return;
|
||||
}
|
||||
if (ReplayUI.isActive() && ReplayUI.imguiGlfw.getMouseHandledBy() == CustomImGuiImplGlfw.MouseHandledBy.GAME) {
|
||||
cir.setReturnValue(true);
|
||||
return;
|
||||
}
|
||||
if (Flashback.getSpectatingPlayer() != null) {
|
||||
cir.setReturnValue(true);
|
||||
if (Flashback.isInReplay()) {
|
||||
if (!Flashback.isExporting() && ReplayUI.isActive() && ReplayUI.imguiGlfw.getMouseHandledBy() == CustomImGuiImplGlfw.MouseHandledBy.GAME) {
|
||||
cir.setReturnValue(true);
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue(Flashback.getSpectatingPlayer() != null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user