Combine all versions into a single tree
This commit is contained in:
@@ -4,20 +4,22 @@ import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiSpectator;
|
||||
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 static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
@Mixin(GuiSpectator.class)
|
||||
public abstract class MixinGuiSpectator {
|
||||
@Shadow
|
||||
private Minecraft mc;
|
||||
|
||||
//#if MC>=10904
|
||||
@Inject(method = "onHotbarSelected", at = @At("HEAD"), cancellable = true)
|
||||
//#else
|
||||
//$$ @Inject(method = "func_175260_a", at = @At("HEAD"), cancellable = true)
|
||||
//#endif
|
||||
public void isInReplay(int i, CallbackInfo ci) {
|
||||
// Prevent spectator gui from opening while in a replay
|
||||
if (mc.player instanceof CameraEntity) {
|
||||
if (player(Minecraft.getMinecraft()) instanceof CameraEntity) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.client.particle.Particle;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.world.World;
|
||||
@@ -29,3 +30,4 @@ public abstract class MixinParticleManager {
|
||||
queueEntityFX.clear();
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -6,8 +6,6 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.stats.RecipeBook;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -15,6 +13,17 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
//#if MC>=11200
|
||||
import net.minecraft.stats.RecipeBook;
|
||||
//#endif
|
||||
//#if MC>=10904
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
//#else
|
||||
//$$ import net.minecraft.stats.StatFileWriter;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class MixinPlayerControllerMP {
|
||||
|
||||
@@ -22,20 +31,38 @@ public abstract class MixinPlayerControllerMP {
|
||||
private Minecraft mc;
|
||||
|
||||
@Shadow
|
||||
//#if MC>=10904
|
||||
private NetHandlerPlayClient connection;
|
||||
//#else
|
||||
//$$ private NetHandlerPlayClient netClientHandler;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11200
|
||||
@Inject(method = "func_192830_a", at=@At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, RecipeBook recipeBook, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager, recipeBook));
|
||||
//#else
|
||||
//#if MC>=10904
|
||||
//$$ @Inject(method = "createClientPlayer", at=@At("HEAD"), cancellable = true)
|
||||
//$$ private void replayModReplay_createReplayCamera(World worldIn, StatisticsManager statisticsManager, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||
//$$ if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
//$$ ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager));
|
||||
//#else
|
||||
//$$ @Inject(method = "func_178892_a", at=@At("HEAD"), cancellable = true)
|
||||
//$$ private void replayModReplay_createReplayCamera(World worldIn, StatFileWriter statFileWriter, CallbackInfoReturnable<EntityPlayerSP> ci) {
|
||||
//$$ if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
//$$ ci.setReturnValue(new CameraEntity(mc, worldIn, netClientHandler, statFileWriter));
|
||||
//#endif
|
||||
//#endif
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "isSpectator", at=@At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_isSpectator(CallbackInfoReturnable<Boolean> ci) {
|
||||
if (mc.player instanceof CameraEntity) { // this check should in theory not be required
|
||||
ci.setReturnValue(mc.player.isSpectator());
|
||||
if (player(mc) instanceof CameraEntity) { // this check should in theory not be required
|
||||
ci.setReturnValue(player(mc).isSpectator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,16 @@ package com.replaymod.replay.mixin;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.renderer.entity.RenderItem;
|
||||
//#endif
|
||||
|
||||
@Mixin(RenderItem.class)
|
||||
public class MixinRenderItem {
|
||||
@Redirect(method = "renderEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -11,11 +10,23 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
//#if MC>=10904
|
||||
@Mixin(RenderLivingBase.class)
|
||||
//#else
|
||||
//$$ @Mixin(RendererLivingEntity.class)
|
||||
//#endif
|
||||
public abstract class MixinRenderLivingBase {
|
||||
@Inject(method = "canRenderName", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_canRenderInvisibleName(EntityLivingBase entity, CallbackInfoReturnable<Boolean> ci) {
|
||||
EntityPlayer thePlayer = Minecraft.getMinecraft().player;
|
||||
EntityPlayer thePlayer = player(Minecraft.getMinecraft());
|
||||
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
||||
ci.setReturnValue(false);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,11 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(TileEntityEndPortalRenderer.class)
|
||||
public class MixinTileEntityEndPortalRenderer {
|
||||
//#if MC>=10809
|
||||
@Redirect(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||
//#else
|
||||
//$$ @Redirect(method = "func_180544_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||
//#endif
|
||||
private long replayModReplay_getEnchantmentTime() {
|
||||
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||
if (replayHandler != null) {
|
||||
|
||||
@@ -5,8 +5,6 @@ import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.ViewFrustum;
|
||||
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
@@ -14,6 +12,14 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
//#else
|
||||
//$$ import net.minecraft.util.BlockPos;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
@Mixin(ViewFrustum.class)
|
||||
public abstract class MixinViewFrustum {
|
||||
private IRenderChunkFactory renderChunkFactory;
|
||||
@@ -31,7 +37,7 @@ public abstract class MixinViewFrustum {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instead of calling {@link RenderChunk#setPosition(int, int, int)} we recreate the render chunk
|
||||
* Instead of updating its position, we recreate the render chunk
|
||||
* which seems to solve the problem that chunks are invisible when you leave an area and return
|
||||
* to it.
|
||||
* Any better fixes are welcome.
|
||||
@@ -43,8 +49,8 @@ public abstract class MixinViewFrustum {
|
||||
return;
|
||||
}
|
||||
|
||||
int i = MathHelper.floor(viewEntityX) - 8;
|
||||
int j = MathHelper.floor(viewEntityZ) - 8;
|
||||
int i = floor(viewEntityX) - 8;
|
||||
int j = floor(viewEntityZ) - 8;
|
||||
int k = this.countChunksX * 16;
|
||||
|
||||
for (int l = 0; l < this.countChunksX; ++l) {
|
||||
@@ -57,9 +63,18 @@ public abstract class MixinViewFrustum {
|
||||
BlockPos blockpos = new BlockPos(i1, i2, k1);
|
||||
if (!blockpos.equals(renderchunk.getPosition())) {
|
||||
// Recreate render chunk instead of setting its position
|
||||
//#if MC>=10904
|
||||
(renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
||||
renderChunkFactory.create(world, renderGlobal, 0)
|
||||
//#if MC>= 11100
|
||||
).setPosition(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
||||
//#else
|
||||
//$$ ).setOrigin(blockpos.getX(), blockpos.getY(), blockpos.getZ());
|
||||
//#endif
|
||||
//#else
|
||||
//$$ renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l] =
|
||||
//$$ renderChunkFactory.makeRenderChunk(world, renderGlobal, blockpos, 0);
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -67,5 +82,12 @@ public abstract class MixinViewFrustum {
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
@Shadow abstract int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
||||
//#else
|
||||
//$$ private int getBaseCoordinate(int p_178157_1_, int p_178157_2_, int p_178157_3_) {
|
||||
//$$ return func_178157_a(p_178157_1_, p_178157_2_, p_178157_3_);
|
||||
//$$ }
|
||||
//$$ @Shadow abstract int func_178157_a(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
||||
//#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user