mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-02 06:28:48 +00:00
Stuff
This commit is contained in:
1 parent
9c4a30d224
commit
666398e480
174 files changed
+8694
-2942
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.client.renderer.entity.ArmorStandRenderer;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
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;
|
||||
|
||||
@Mixin(ArmorStandRenderer.class)
|
||||
public class MixinArmorStandRenderer {
|
||||
|
||||
/*
|
||||
* Disable armor stand hit animation
|
||||
* If the game time isn't updated, it'll just keep on playing it (even if it wasn't hit)
|
||||
*/
|
||||
|
||||
@Inject(method = "setupRotations(Lnet/minecraft/world/entity/decoration/ArmorStand;Lcom/mojang/blaze3d/vertex/PoseStack;FFFF)V", at = @At("HEAD"), cancellable = true)
|
||||
public void setupRotations(ArmorStand armorStand, PoseStack poseStack, float f, float g, float h, float i, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
poseStack.mulPose(Axis.YP.rotationDegrees(180.0F - g));
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.packet.FinishedServerTick;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.ClientCommonPacketListenerImpl;
|
||||
import net.minecraft.network.protocol.PacketUtils;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.CallbackInfo;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
@Mixin(ClientCommonPacketListenerImpl.class)
|
||||
public abstract class MixinClientCommonPacketListenerImpl {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
protected Minecraft minecraft;
|
||||
|
||||
@Shadow
|
||||
@Nullable
|
||||
private static URL parseResourcePackUrl(String string) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the resource pack prompt screen in replays
|
||||
*/
|
||||
@Inject(method = "handleResourcePackPush", at = @At("HEAD"), cancellable = true)
|
||||
public void handleResourcePackPush(ClientboundResourcePackPushPacket clientboundResourcePackPushPacket, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
PacketUtils.ensureRunningOnSameThread(clientboundResourcePackPushPacket, (ClientCommonPacketListenerImpl)(Object)this, this.minecraft);
|
||||
|
||||
UUID uuid = clientboundResourcePackPushPacket.id();
|
||||
URL uRL = parseResourcePackUrl(clientboundResourcePackPushPacket.url());
|
||||
if (uRL != null) {
|
||||
String string = clientboundResourcePackPushPacket.hash();
|
||||
this.minecraft.getDownloadedPackSource().allowServerPacks();
|
||||
this.minecraft.getDownloadedPackSource().pushPack(uuid, uRL, string);
|
||||
}
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "handleCustomPayload(Lnet/minecraft/network/protocol/common/ClientboundCustomPayloadPacket;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void handleCustomPayload(ClientboundCustomPayloadPacket clientboundCustomPayloadPacket, CallbackInfo ci) {
|
||||
if (clientboundCustomPayloadPacket.payload() == FinishedServerTick.INSTANCE) {
|
||||
if (Flashback.EXPORT_JOB != null) {
|
||||
Flashback.EXPORT_JOB.onFinishedServerTick();
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.ReplayVisuals;
|
||||
import com.moulberry.flashback.editor.ui.ReplayUI;
|
||||
import com.moulberry.flashback.ext.ItemInHandRendererExt;
|
||||
import com.moulberry.flashback.ext.MinecraftExt;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.client.multiplayer.MultiPlayerGameMode;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.player.LocalPlayer;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public class MixinGameRenderer {
|
||||
|
||||
|
||||
@WrapOperation(method = "render", at=@At(value = "FIELD", target = "Lnet/minecraft/client/Options;pauseOnLostFocus:Z"))
|
||||
public boolean getPauseOnLostFocus(Options instance, Operation<Boolean> original) {
|
||||
if (ReplayUI.isActive() || Flashback.EXPORT_JOB != null) {
|
||||
return false;
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
/*
|
||||
* Render item in hand for spectators in a replay
|
||||
*/
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private Minecraft minecraft;
|
||||
|
||||
@WrapOperation(method = "renderItemInHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;getPlayerMode()Lnet/minecraft/world/level/GameType;"))
|
||||
public GameType getPlayerMode(MultiPlayerGameMode instance, Operation<GameType> original) {
|
||||
if (Flashback.getSpectatingPlayer() != null) {
|
||||
return GameType.SURVIVAL;
|
||||
}
|
||||
return original.call(instance);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderItemInHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemInHandRenderer;renderHandsWithItems(FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource$BufferSource;Lnet/minecraft/client/player/LocalPlayer;I)V"))
|
||||
public void renderItemInHand_renderHandsWithItems(ItemInHandRenderer instance, float f, PoseStack poseStack, MultiBufferSource.BufferSource bufferSource, LocalPlayer localPlayer, int i, Operation<Void> original) {
|
||||
AbstractClientPlayer spectatingPlayer = Flashback.getSpectatingPlayer();
|
||||
if (spectatingPlayer != null) {
|
||||
f = ((MinecraftExt)this.minecraft).flashback$getLocalPlayerPartialTick();
|
||||
((ItemInHandRendererExt)instance).flashback$renderHandsWithItems(f, poseStack, bufferSource, spectatingPlayer, i);
|
||||
} else {
|
||||
original.call(instance, f, poseStack, bufferSource, localPlayer, i);
|
||||
}
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;setup(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/world/entity/Entity;ZZF)V"))
|
||||
public void renderLevel_setupCamera(Camera instance, BlockGetter blockGetter, Entity entity, boolean bl, boolean bl2, float f, Operation<Void> original) {
|
||||
if (Flashback.isInReplay()) {
|
||||
f = ((MinecraftExt)this.minecraft).flashback$getLocalPlayerPartialTick();
|
||||
}
|
||||
original.call(instance, blockGetter, entity, bl, bl2, f);
|
||||
}
|
||||
|
||||
@Inject(method = "tryTakeScreenshotIfNeeded", at = @At("HEAD"), cancellable = true)
|
||||
public void tryTakeScreenshotIfNeeded(CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getFov", at = @At("HEAD"), cancellable = true)
|
||||
public void getFov(Camera camera, float f, boolean bl, CallbackInfoReturnable<Double> cir) {
|
||||
if (Flashback.isInReplay()) {
|
||||
if (!bl) {
|
||||
cir.setReturnValue(70.0);
|
||||
return;
|
||||
}
|
||||
|
||||
int fov = this.minecraft.options.fov().get().intValue();
|
||||
if (ReplayVisuals.overrideFov) {
|
||||
cir.setReturnValue((double) ReplayVisuals.overrideFovAmount);
|
||||
return;
|
||||
}
|
||||
cir.setReturnValue((double) fov);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import com.moulberry.flashback.ext.ItemInHandRendererExt;
|
||||
import net.minecraft.client.player.AbstractClientPlayer;
|
||||
import net.minecraft.client.renderer.ItemInHandRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
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.UUID;
|
||||
|
||||
@Mixin(ItemInHandRenderer.class)
|
||||
public abstract class MixinItemInHandRenderer implements ItemInHandRendererExt {
|
||||
|
||||
@Shadow
|
||||
private float oMainHandHeight;
|
||||
|
||||
@Shadow
|
||||
private float mainHandHeight;
|
||||
|
||||
@Shadow
|
||||
private float oOffHandHeight;
|
||||
|
||||
@Shadow
|
||||
private float offHandHeight;
|
||||
|
||||
@Shadow
|
||||
protected abstract void renderArmWithItem(AbstractClientPlayer abstractClientPlayer, float f, float g, InteractionHand interactionHand, float h, ItemStack itemStack, float i, PoseStack poseStack, MultiBufferSource multiBufferSource, int j);
|
||||
|
||||
@Shadow
|
||||
private ItemStack mainHandItem;
|
||||
|
||||
@Shadow
|
||||
private ItemStack offHandItem;
|
||||
|
||||
@Override
|
||||
public void flashback$renderHandsWithItems(float partialTick, PoseStack poseStack, MultiBufferSource.BufferSource bufferSource, AbstractClientPlayer clientPlayer, int i) {
|
||||
float m;
|
||||
float l;
|
||||
float g = clientPlayer.getAttackAnim(partialTick);
|
||||
InteractionHand interactionHand = MoreObjects.firstNonNull(clientPlayer.swingingArm, InteractionHand.MAIN_HAND);
|
||||
float h = Mth.lerp(partialTick, clientPlayer.xRotO, clientPlayer.getXRot());
|
||||
// todo: hand selection
|
||||
// ItemInHandRenderer.HandRenderSelection handRenderSelection = evaluateWhichHandsToRender(clientPlayer);
|
||||
// todo: bob
|
||||
// float j = Mth.lerp((float)f, (float)clientPlayer.xBobO, (float)clientPlayer.xBob);
|
||||
// float k = Mth.lerp((float)f, (float)clientPlayer.yBobO, (float)clientPlayer.yBob);
|
||||
// poseStack.mulPose(Axis.XP.rotationDegrees((clientPlayer.getViewXRot(f) - j) * 0.1f));
|
||||
// poseStack.mulPose(Axis.YP.rotationDegrees((clientPlayer.getViewYRot(f) - k) * 0.1f));
|
||||
if (true) {
|
||||
l = interactionHand == InteractionHand.MAIN_HAND ? g : 0.0f;
|
||||
m = 1.0f - Mth.lerp(partialTick, this.oMainHandHeight, this.mainHandHeight);
|
||||
renderArmWithItem(clientPlayer, partialTick, h, InteractionHand.MAIN_HAND, l, this.mainHandItem, m, poseStack, bufferSource, i);
|
||||
}
|
||||
if (true) {
|
||||
l = interactionHand == InteractionHand.OFF_HAND ? g : 0.0f;
|
||||
m = 1.0f - Mth.lerp(partialTick, this.oOffHandHeight, this.offHandHeight);
|
||||
renderArmWithItem(clientPlayer, partialTick, h, InteractionHand.OFF_HAND, l, this.offHandItem, m, poseStack, bufferSource, i);
|
||||
}
|
||||
bufferSource.endBatch();
|
||||
}
|
||||
|
||||
// todo: change first person FOV when pulling bows, etc.
|
||||
|
||||
// todo: show arm (need to replace usage of LocalPlayer in renderPlayerArm
|
||||
|
||||
@Unique
|
||||
private UUID lastSpectatingPlayer = null;
|
||||
|
||||
@Inject(method = "tick", at = @At("HEAD"), cancellable = true)
|
||||
public void tick(CallbackInfo ci) {
|
||||
AbstractClientPlayer spectatingPlayer = Flashback.getSpectatingPlayer();
|
||||
if (spectatingPlayer == null) {
|
||||
this.lastSpectatingPlayer = null;
|
||||
} else {
|
||||
ItemStack newMainHandItem = spectatingPlayer.getMainHandItem();
|
||||
ItemStack newOffHandItem = spectatingPlayer.getOffhandItem();
|
||||
|
||||
if (!spectatingPlayer.getUUID().equals(lastSpectatingPlayer)) {
|
||||
this.lastSpectatingPlayer = spectatingPlayer.getUUID();
|
||||
this.mainHandItem = newMainHandItem;
|
||||
this.offHandItem = newOffHandItem;
|
||||
this.oMainHandHeight = this.mainHandHeight = 1.0f;
|
||||
this.oOffHandHeight = this.offHandHeight = 1.0f;
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
this.oMainHandHeight = this.mainHandHeight;
|
||||
this.oOffHandHeight = this.offHandHeight;
|
||||
if (ItemStack.matches(this.mainHandItem, newMainHandItem)) {
|
||||
this.mainHandItem = newMainHandItem;
|
||||
}
|
||||
if (ItemStack.matches(this.offHandItem, newOffHandItem)) {
|
||||
this.offHandItem = newOffHandItem;
|
||||
}
|
||||
if (false /*clientPlayer.isHandsBusy()*/) {
|
||||
this.mainHandHeight = Mth.clamp((float)(this.mainHandHeight - 0.4f), (float)0.0f, (float)1.0f);
|
||||
this.offHandHeight = Mth.clamp((float)(this.offHandHeight - 0.4f), (float)0.0f, (float)1.0f);
|
||||
} else {
|
||||
// todo: attack strength
|
||||
float f = 1.0f;//spectatingPlayer.getAttackStrengthScale(1.0f);
|
||||
this.mainHandHeight += Mth.clamp((this.mainHandItem == newMainHandItem ? f * f * f : 0.0f) - this.mainHandHeight, -0.4f, 0.4f);
|
||||
this.offHandHeight += Mth.clamp((float)(this.offHandItem == newOffHandItem ? 1 : 0) - this.offHandHeight, -0.4f, 0.4f);
|
||||
}
|
||||
if (this.mainHandHeight < 0.1f) {
|
||||
this.mainHandItem = newMainHandItem;
|
||||
}
|
||||
if (this.offHandHeight < 0.1f) {
|
||||
this.offHandItem = newOffHandItem;
|
||||
}
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.ext.LevelChunkSectionExt;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.chunk.LevelChunkSection;
|
||||
import net.minecraft.world.level.chunk.PalettedContainer;
|
||||
import net.minecraft.world.level.chunk.PalettedContainerRO;
|
||||
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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(LevelChunkSection.class)
|
||||
public class MixinLevelChunkSection implements LevelChunkSectionExt {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private PalettedContainer<BlockState> states;
|
||||
|
||||
@Shadow
|
||||
private short nonEmptyBlockCount;
|
||||
|
||||
@Shadow
|
||||
private PalettedContainerRO<Holder<Biome>> biomes;
|
||||
|
||||
@Unique
|
||||
private int cachedChunkId = -1;
|
||||
|
||||
@Override
|
||||
public int flashback$getCachedChunkId() {
|
||||
return this.cachedChunkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flashback$setCachedChunkId(int cachedChunkId) {
|
||||
this.cachedChunkId = cachedChunkId;
|
||||
}
|
||||
|
||||
@Inject(method = "read", at = @At("RETURN"))
|
||||
public void read(FriendlyByteBuf friendlyByteBuf, CallbackInfo ci) {
|
||||
this.cachedChunkId = -1;
|
||||
}
|
||||
|
||||
@Inject(method = "setBlockState(IIILnet/minecraft/world/level/block/state/BlockState;Z)Lnet/minecraft/world/level/block/state/BlockState;", at = @At("RETURN"))
|
||||
public void setBlockState(int i, int j, int k, BlockState blockState, boolean bl, CallbackInfoReturnable<BlockState> cir) {
|
||||
this.cachedChunkId = -1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(LivingEntity.class)
|
||||
public abstract class MixinLivingEntity extends Entity {
|
||||
|
||||
@Shadow
|
||||
public abstract void lerpTo(double d, double e, double f, float g, float h, int i);
|
||||
|
||||
@Shadow
|
||||
public abstract void lerpHeadTo(float f, int i);
|
||||
|
||||
public MixinLivingEntity(EntityType<?> entityType, Level level) {
|
||||
super(entityType, level);
|
||||
}
|
||||
|
||||
// todo: maybe reintroduce this lerpTo code?
|
||||
// @Inject(method = "lerpTo", at = @At("HEAD"), cancellable = true)
|
||||
// public void lerpTo(double d, double e, double f, float g, float h, int i, CallbackInfo ci) {
|
||||
// if (FlashbackClient.isInReplay() && i > 1 && FlashbackClient.getReplayServer().getLocalPlayerId() == this.getId() && Minecraft.getInstance().getCameraEntity() == this) {
|
||||
// this.lerpTo(d, e, f, g, h, 1);
|
||||
// ci.cancel();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Inject(method = "lerpHeadTo", at = @At("HEAD"), cancellable = true)
|
||||
// public void lerpHeadTo(float f, int i, CallbackInfo ci) {
|
||||
// if (FlashbackClient.isInReplay() && i > 1 && FlashbackClient.getReplayServer().getLocalPlayerId() == this.getId() && Minecraft.getInstance().getCameraEntity() == this) {
|
||||
// this.lerpHeadTo(f, 1);
|
||||
// ci.cancel();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.PlayerChunkSender;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(PlayerChunkSender.class)
|
||||
public class MixinPlayerChunkSender {
|
||||
|
||||
// Make chunks send faster on replay servers
|
||||
|
||||
@Shadow
|
||||
private float desiredChunksPerTick;
|
||||
|
||||
@Shadow
|
||||
private int unacknowledgedBatches;
|
||||
|
||||
@Shadow
|
||||
private float batchQuota;
|
||||
|
||||
@Inject(method = "sendNextChunks", at = @At("HEAD"))
|
||||
public void sendNextChunks(ServerPlayer serverPlayer, CallbackInfo ci) {
|
||||
if (Flashback.isInReplay()) {
|
||||
this.unacknowledgedBatches = 0;
|
||||
this.batchQuota = 0.0f;
|
||||
this.desiredChunksPerTick = Math.max(this.desiredChunksPerTick, 256.0f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.numbers.NumberFormat;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.Scoreboard;
|
||||
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
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(Scoreboard.class)
|
||||
public abstract class MixinScoreboard {
|
||||
|
||||
@Shadow @Final private Object2ObjectMap<String, Objective> objectivesByName;
|
||||
|
||||
@Shadow public abstract void removeObjective(Objective objective);
|
||||
|
||||
@Inject(method = "addObjective", at = @At("HEAD"))
|
||||
public void addObjective(String string, ObjectiveCriteria objectiveCriteria, Component component, ObjectiveCriteria.RenderType renderType, boolean bl, NumberFormat numberFormat, CallbackInfoReturnable<Objective> cir) {
|
||||
if (Flashback.isInReplay() && this.objectivesByName.containsKey(string)) {
|
||||
this.removeObjective(this.objectivesByName.get(string));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.moulberry.flashback.mixin.playback;
|
||||
|
||||
import com.moulberry.flashback.Flashback;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.server.ServerTickRateManager;
|
||||
import net.minecraft.world.TickRateManager;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(TickRateManager.class)
|
||||
public abstract class MixinTickRateManager {
|
||||
|
||||
@Shadow
|
||||
public abstract boolean runsNormally();
|
||||
|
||||
@Unique
|
||||
private final boolean isClientTickRateManager = !((Object)this instanceof ServerTickRateManager);
|
||||
|
||||
@Inject(method = "isEntityFrozen", at = @At("HEAD"), cancellable = true)
|
||||
public void isEntityFrozen(Entity entity, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (this.isClientTickRateManager && Flashback.isInReplay()) {
|
||||
if (Flashback.EXPORT_JOB != null && Flashback.EXPORT_JOB.isRunning()) {
|
||||
cir.setReturnValue(false);
|
||||
} else {
|
||||
cir.setReturnValue(!this.runsNormally() || entity == Minecraft.getInstance().player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user