Add 1.7.10 version
This commit is contained in:
@@ -13,11 +13,20 @@ import net.minecraft.util.ReportedException;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Event;
|
||||
//$$ import net.minecraft.client.renderer.entity.RenderManager;
|
||||
//$$
|
||||
//$$ import static com.replaymod.core.versions.MCVer.FML_BUS;
|
||||
//#endif
|
||||
|
||||
public class InputReplayTimer extends WrappedTimer {
|
||||
private final ReplayModReplay mod;
|
||||
@@ -33,6 +42,11 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
public void updateTimer() {
|
||||
super.updateTimer();
|
||||
|
||||
// 1.7.10: We have to run the scheduled executables (ours only) because MC would only run them every tick
|
||||
//#if MC<=10710
|
||||
//$$ FML_BUS.post(new RunScheduledTasks());
|
||||
//#endif
|
||||
|
||||
// If we are in a replay, we have to manually process key and mouse events as the
|
||||
// tick speed may vary or there may not be any ticks at all (when the replay is paused)
|
||||
if (mod.getReplayHandler() != null) {
|
||||
@@ -45,11 +59,15 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
handleKeyEvent();
|
||||
}
|
||||
} else {
|
||||
//#if MC>=10800
|
||||
try {
|
||||
mc.currentScreen.handleInput();
|
||||
} catch (IOException e) { // *SIGH*
|
||||
e.printStackTrace();
|
||||
}
|
||||
//#else
|
||||
//$$ mc.currentScreen.handleInput();
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,17 +109,22 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
mc.setIngameFocus();
|
||||
}
|
||||
} else {
|
||||
//#if MC>=10800
|
||||
try {
|
||||
mc.currentScreen.handleMouseInput();
|
||||
} catch (IOException e) { // WHO IS RESPONSIBLE FOR THIS MESS?!?
|
||||
e.printStackTrace();
|
||||
}
|
||||
//#else
|
||||
//$$ mc.currentScreen.handleMouseInput();
|
||||
//#endif
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().fireMouseInput();
|
||||
}
|
||||
|
||||
protected void handleKeyEvent() {
|
||||
// TODO 1.7.10: This might be missing some 1.7.10-only key bindings or implement some of them incorrectly
|
||||
int key = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
|
||||
boolean pressed = Keyboard.getEventKeyState();
|
||||
|
||||
@@ -131,15 +154,23 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
if (pressed) {
|
||||
// This might be subject to change as vanilla shaders are still kinda unused in 1.8
|
||||
if (key == Keyboard.KEY_F4 && mc.entityRenderer != null) {
|
||||
//#if MC>=10800
|
||||
mc.entityRenderer.switchUseShader();
|
||||
//#else
|
||||
//$$ mc.entityRenderer.activateNextShader();
|
||||
//#endif
|
||||
}
|
||||
|
||||
if (mc.currentScreen != null) {
|
||||
//#if MC>=10800
|
||||
try {
|
||||
mc.currentScreen.handleKeyboardInput();
|
||||
} catch (IOException e) { // AND WHO THOUGHT THIS WAS A GREAT IDEA?
|
||||
e.printStackTrace();
|
||||
}
|
||||
//#else
|
||||
//$$ mc.currentScreen.handleKeyboardInput();
|
||||
//#endif
|
||||
} else {
|
||||
if (key == Keyboard.KEY_ESCAPE) {
|
||||
mc.displayInGameMenu();
|
||||
@@ -176,7 +207,11 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
}
|
||||
|
||||
if (key == 48 && Keyboard.isKeyDown(61)) {
|
||||
//#if MC>=10800
|
||||
mc.getRenderManager().setDebugBoundingBox(!mc.getRenderManager().isDebugBoundingBox());
|
||||
//#else
|
||||
//$$ RenderManager.debugBoundingBox = !RenderManager.debugBoundingBox;
|
||||
//#endif
|
||||
}
|
||||
|
||||
if (key == 25 && Keyboard.isKeyDown(61)) {
|
||||
@@ -196,6 +231,7 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
if (mc.gameSettings.keyBindTogglePerspective.isPressed()) {
|
||||
mc.gameSettings.thirdPersonView = (mc.gameSettings.thirdPersonView + 1) % 3;
|
||||
|
||||
//#if MC>=10800
|
||||
if (mc.entityRenderer != null) { // Extra check, not in vanilla code
|
||||
if (mc.gameSettings.thirdPersonView == 0) {
|
||||
mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity());
|
||||
@@ -203,6 +239,7 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
mc.entityRenderer.loadEntityShader(null);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,4 +259,8 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
|
||||
FMLCommonHandler.instance().fireKeyInput();
|
||||
}
|
||||
|
||||
//#if MC<=10710
|
||||
//$$ public static class RunScheduledTasks extends Event {}
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -8,10 +8,15 @@ import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.util.ScreenShotHelper;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
//#else
|
||||
//$$ import com.replaymod.core.versions.MCVer.GlStateManager;
|
||||
//#endif
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.replaymod.replay;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
@@ -18,22 +17,36 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityOtherPlayerMP;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
//#if MC>=10800
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher;
|
||||
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
|
||||
//$$ import com.replaymod.replay.gui.screen.GuiOpeningReplay;
|
||||
//$$ import io.netty.channel.ChannelOutboundHandlerAdapter;
|
||||
//$$ import net.minecraft.client.network.NetHandlerLoginClient;
|
||||
//$$ import net.minecraft.entity.EntityLivingBase;
|
||||
//$$ import net.minecraft.network.EnumConnectionState;
|
||||
//$$
|
||||
//$$ import static com.replaymod.core.versions.MCVer.GlStateManager.*;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
|
||||
@@ -148,6 +161,7 @@ public class ReplayHandler {
|
||||
//$$ mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) {
|
||||
@@ -177,6 +191,31 @@ public class ReplayHandler {
|
||||
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "fml:packet_handler", networkDispatcher);
|
||||
//$$ channel.pipeline().fireChannelActive();
|
||||
//#endif
|
||||
//#else
|
||||
//$$ NetworkManager networkManager = new NetworkManager(true) {
|
||||
//$$ @Override
|
||||
//$$ public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) {
|
||||
//$$ t.printStackTrace();
|
||||
//$$ }
|
||||
//$$ };
|
||||
//$$ networkManager.setNetHandler(new NetHandlerLoginClient(networkManager, mc, null));
|
||||
//$$
|
||||
//$$ mc.displayGuiScreen(new GuiOpeningReplay(networkManager));
|
||||
//$$
|
||||
//$$ ChannelOutboundHandlerAdapter dummyHandler = new ChannelOutboundHandlerAdapter();
|
||||
//$$ channel = new EmbeddedChannel(dummyHandler);
|
||||
//$$ channel.pipeline().remove(dummyHandler);
|
||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", replaySender);
|
||||
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "packet_handler", networkManager);
|
||||
//$$ channel.pipeline().fireChannelActive();
|
||||
//$$
|
||||
//$$ // Call twice to force-overwrite the NetworkManager's internal state
|
||||
//$$ networkManager.setConnectionState(EnumConnectionState.PLAY);
|
||||
//$$ networkManager.getNetHandler().onConnectionStateTransition(EnumConnectionState.LOGIN, EnumConnectionState.PLAY);
|
||||
//$$ networkManager.setConnectionState(EnumConnectionState.PLAY);
|
||||
//$$
|
||||
//$$ FMLNetworkHandler.fmlClientHandshake(networkManager);
|
||||
//#endif
|
||||
}
|
||||
|
||||
public ReplayFile getReplayFile() {
|
||||
@@ -236,7 +275,11 @@ public class ReplayHandler {
|
||||
* When the entity is {@code null} or the camera entity, the camera becomes the view entity.
|
||||
* @param e The entity to spectate
|
||||
*/
|
||||
//#if MC>=10800
|
||||
public void spectateEntity(Entity e) {
|
||||
//#else
|
||||
//$$ public void spectateEntity(EntityLivingBase e) {
|
||||
//#endif
|
||||
CameraEntity cameraEntity = getCameraEntity();
|
||||
if (cameraEntity == null) {
|
||||
return; // Cannot spectate if we have no camera
|
||||
@@ -254,15 +297,15 @@ public class ReplayHandler {
|
||||
cameraEntity.setCameraController(new SpectatorCameraController(cameraEntity));
|
||||
}
|
||||
|
||||
if (mc.getRenderViewEntity() != e) {
|
||||
mc.setRenderViewEntity(e);
|
||||
if (getRenderViewEntity(mc) != e) {
|
||||
setRenderViewEntity(mc, e);
|
||||
cameraEntity.setCameraPosRot(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the camera as the view entity.
|
||||
* This is equivalent to {@link #spectateEntity(Entity) spectateEntity(null)}.
|
||||
* This is equivalent to {@code spectateEntity(null)}.
|
||||
*/
|
||||
public void spectateCamera() {
|
||||
spectateEntity(null);
|
||||
@@ -273,7 +316,7 @@ public class ReplayHandler {
|
||||
* @return {@code true} if the camera is the view entity, {@code false} otherwise
|
||||
*/
|
||||
public boolean isCameraView() {
|
||||
return player(mc) instanceof CameraEntity && player(mc) == mc.getRenderViewEntity();
|
||||
return player(mc) instanceof CameraEntity && player(mc) == getRenderViewEntity(mc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,11 +417,15 @@ public class ReplayHandler {
|
||||
entity.prevRotationYaw = entity.rotationYaw;
|
||||
entity.prevRotationPitch = entity.rotationPitch;
|
||||
}
|
||||
//#if MC>=10800
|
||||
try {
|
||||
mc.runTick();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(); // This should never be thrown but whatever
|
||||
}
|
||||
//#else
|
||||
//$$ mc.runTick();
|
||||
//#endif
|
||||
|
||||
//finally, updating the camera's position (which is not done by the sync jumping)
|
||||
moveCameraToTargetPosition();
|
||||
|
||||
@@ -19,12 +19,20 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.Mod;
|
||||
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
//$$ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
//#endif
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
@@ -36,7 +44,9 @@ import java.util.Optional;
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
//#if MC>=10800
|
||||
clientSideOnly = true,
|
||||
//#endif
|
||||
useMetadata = true)
|
||||
public class ReplayModReplay {
|
||||
public static final String MOD_ID = "replaymod-replay";
|
||||
|
||||
@@ -31,8 +31,6 @@ import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
@@ -50,6 +48,15 @@ import net.minecraft.util.text.ITextComponent;
|
||||
//$$ import net.minecraft.util.IChatComponent;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//$$ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
//$$ import org.apache.commons.io.Charsets;
|
||||
//#endif
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -89,6 +96,10 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
SPacketPlayerAbilities.class,
|
||||
SPacketTitle.class
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ S43PacketCamera.class,
|
||||
//$$ S45PacketTitle.class,
|
||||
//#endif
|
||||
//$$ S06PacketUpdateHealth.class,
|
||||
//$$ S2DPacketOpenWindow.class,
|
||||
//$$ S2EPacketCloseWindow.class,
|
||||
@@ -97,9 +108,7 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//$$ S36PacketSignEditorOpen.class,
|
||||
//$$ S37PacketStatistics.class,
|
||||
//$$ S1FPacketSetExperience.class,
|
||||
//$$ S43PacketCamera.class,
|
||||
//$$ S39PacketPlayerAbilities.class,
|
||||
//$$ S45PacketTitle.class
|
||||
//$$ S39PacketPlayerAbilities.class
|
||||
//#endif
|
||||
);
|
||||
|
||||
@@ -390,7 +399,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
|
||||
int i = readVarInt(pb);
|
||||
|
||||
//#if MC>=10800
|
||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
//#else
|
||||
//$$ Packet p = Packet.generatePacket(EnumConnectionState.PLAY.func_150755_b(), i);
|
||||
//#endif
|
||||
p.readPacketData(pb);
|
||||
|
||||
return p;
|
||||
@@ -409,7 +422,12 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//$$ if (p instanceof S3FPacketCustomPayload) {
|
||||
//$$ S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||
//#endif
|
||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
||||
//#if MC>=10800
|
||||
String channelName = packet.getChannelName();
|
||||
//#else
|
||||
//$$ String channelName = packet.func_149169_c();
|
||||
//#endif
|
||||
if (Restrictions.PLUGIN_CHANNEL.equals(channelName)) {
|
||||
final String unknown = replayHandler.getRestrictions().handle(packet);
|
||||
if (unknown == null) {
|
||||
return null;
|
||||
@@ -461,9 +479,15 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//$$ if (p instanceof S3FPacketCustomPayload) {
|
||||
//$$ S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||
//#endif
|
||||
if ("MC|BOpen".equals(packet.getChannelName())) {
|
||||
//#if MC>=10800
|
||||
String channelName = packet.getChannelName();
|
||||
//#else
|
||||
//$$ String channelName = packet.func_149169_c();
|
||||
//#endif
|
||||
if ("MC|BOpen".equals(channelName)) {
|
||||
return null;
|
||||
}
|
||||
//#if MC>=10800
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
@@ -476,10 +500,15 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//#if MC>=10809
|
||||
//$$ String url = packet.getURL();
|
||||
//#else
|
||||
//$$ String url = packet.func_179783_a();
|
||||
//$$ String url = packet.func_179783_a();
|
||||
//#endif
|
||||
//#endif
|
||||
if (url.startsWith("replay://")) {
|
||||
//#else
|
||||
//$$ String url;
|
||||
//$$ if ("MC|RPack".equals(channelName) &&
|
||||
//$$ (url = new String(packet.func_149168_d(), Charsets.UTF_8)).startsWith("replay://")) {
|
||||
//#endif
|
||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
||||
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
||||
if (index != null) {
|
||||
@@ -503,11 +532,16 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//#else
|
||||
//$$ if(p instanceof S01PacketJoinGame) {
|
||||
//$$ S01PacketJoinGame packet = (S01PacketJoinGame) p;
|
||||
//$$ int entId = packet.getEntityId();
|
||||
//#if MC>=10800
|
||||
//$$ int entId = packet.getEntityId();
|
||||
//#else
|
||||
//$$ int entId = packet.func_149197_c();
|
||||
//#endif
|
||||
//#endif
|
||||
allowMovement = true;
|
||||
actualID = entId;
|
||||
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
||||
//#if MC>=10800
|
||||
int dimension = packet.getDimension();
|
||||
EnumDifficulty difficulty = packet.getDifficulty();
|
||||
int maxPlayers = packet.getMaxPlayers();
|
||||
@@ -520,6 +554,15 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//$$ p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||
//$$ difficulty, maxPlayers, worldType, false);
|
||||
//#endif
|
||||
//#else
|
||||
//$$ int dimension = packet.func_149194_f();
|
||||
//$$ EnumDifficulty difficulty = packet.func_149192_g();
|
||||
//$$ int maxPlayers = packet.func_149193_h();
|
||||
//$$ WorldType worldType = packet.func_149196_i();
|
||||
//$$
|
||||
//$$ p = new S01PacketJoinGame(entId, GameType.ADVENTURE, false, dimension,
|
||||
//$$ difficulty, maxPlayers, worldType);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
@@ -535,7 +578,12 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//$$ respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||
//#else
|
||||
//$$ p = new S07PacketRespawn(respawn.func_149082_c(),
|
||||
//$$ respawn.func_149081_d(), respawn.func_149080_f(), GameType.SPECTATOR);
|
||||
//$$ respawn.func_149081_d(), respawn.func_149080_f(),
|
||||
//#if MC>=10800
|
||||
//$$ GameType.SPECTATOR);
|
||||
//#else
|
||||
//$$ GameType.ADVENTURE);
|
||||
//#endif
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
@@ -560,6 +608,7 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
|
||||
CameraEntity cent = replayHandler.getCameraEntity();
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=10904
|
||||
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
||||
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
||||
@@ -574,6 +623,7 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
return null; // At least one of the coordinates is relative, so we don't care
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
if(cent != null) {
|
||||
//#if MC>=10809
|
||||
@@ -654,8 +704,10 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
//#if MC>=10904
|
||||
ctx.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ ctx.attr(NetworkManager.attrKeyConnectionState).set(EnumConnectionState.PLAY);
|
||||
//#endif
|
||||
//#endif
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ import lombok.Setter;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -25,9 +25,6 @@ import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
@@ -46,6 +43,19 @@ import net.minecraft.util.text.ITextComponent;
|
||||
//$$ import net.minecraft.util.MovingObjectPosition;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraftforge.fml.common.eventhandler.EventPriority;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//$$ import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
//$$ import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
//$$ import net.minecraft.util.Session;
|
||||
//#endif
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
@@ -57,7 +67,13 @@ import static com.replaymod.core.versions.MCVer.*;
|
||||
* During a replay the player should be an instance of this class.
|
||||
* Camera movement is controlled by a separate {@link CameraController}.
|
||||
*/
|
||||
public class CameraEntity extends EntityPlayerSP {
|
||||
public class CameraEntity
|
||||
//#if MC>=10800
|
||||
extends EntityPlayerSP
|
||||
//#else
|
||||
//$$ extends EntityClientPlayerMP
|
||||
//#endif
|
||||
{
|
||||
/**
|
||||
* Roll of this camera in degrees.
|
||||
*/
|
||||
@@ -89,8 +105,13 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
//$$ public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager) {
|
||||
//$$ super(mcIn, worldIn, netHandlerPlayClient, statisticsManager);
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatFileWriter statFileWriter) {
|
||||
//$$ super(mcIn, worldIn, netHandlerPlayClient, statFileWriter);
|
||||
//#else
|
||||
//$$ public CameraEntity(Minecraft mcIn, World worldIn, Session session, NetHandlerPlayClient netHandlerPlayClient, StatFileWriter statFileWriter) {
|
||||
//$$ super(mcIn, worldIn, session, netHandlerPlayClient, statFileWriter);
|
||||
//#endif
|
||||
//#endif
|
||||
//#endif
|
||||
FORGE_BUS.register(eventHandler);
|
||||
@@ -151,31 +172,45 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
* @param to The entity whose position to copy
|
||||
*/
|
||||
public void setCameraPosRot(Entity to) {
|
||||
if (to == this) return;
|
||||
//#if MC>=10800
|
||||
float yOffset = 0;
|
||||
//#else
|
||||
//$$ float yOffset = 1.62f; // Magic value (eye height) from EntityRenderer#orientCamera
|
||||
//#endif
|
||||
prevPosX = to.prevPosX;
|
||||
prevPosY = to.prevPosY;
|
||||
prevPosY = to.prevPosY + yOffset;
|
||||
prevPosZ = to.prevPosZ;
|
||||
prevRotationYaw = to.prevRotationYaw;
|
||||
prevRotationPitch = to.prevRotationPitch;
|
||||
posX = to.posX;
|
||||
posY = to.posY;
|
||||
posY = to.posY + yOffset;
|
||||
posZ = to.posZ;
|
||||
rotationYaw = to.rotationYaw;
|
||||
rotationPitch = to.rotationPitch;
|
||||
lastTickPosX = to.lastTickPosX;
|
||||
lastTickPosY = to.lastTickPosY;
|
||||
lastTickPosY = to.lastTickPosY + yOffset;
|
||||
lastTickPosZ = to.lastTickPosZ;
|
||||
updateBoundingBox();
|
||||
}
|
||||
|
||||
private void updateBoundingBox() {
|
||||
//#if MC>=10800
|
||||
setEntityBoundingBox(new AxisAlignedBB(
|
||||
//#else
|
||||
//$$ this.boundingBox.setBB(AxisAlignedBB.getBoundingBox(
|
||||
//#endif
|
||||
posX - width / 2, posY, posZ - width / 2,
|
||||
posX + width / 2, posY + height, posZ + width / 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
//#if MC>=10800
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
//#else
|
||||
//$$ EntityLivingBase view = getRenderViewEntity(mc);
|
||||
//#endif
|
||||
if (view != null) {
|
||||
// Make sure we're always spectating the right entity
|
||||
// This is important if the spectated player respawns as their
|
||||
@@ -191,9 +226,9 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
}
|
||||
view = world(this).getPlayerEntityByUUID(spectating);
|
||||
if (view != null) {
|
||||
mc.setRenderViewEntity(view);
|
||||
setRenderViewEntity(mc, view);
|
||||
} else {
|
||||
mc.setRenderViewEntity(this);
|
||||
setRenderViewEntity(mc, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -216,7 +251,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
@Override
|
||||
public void setRotation(float yaw, float pitch) {
|
||||
if (mc.getRenderViewEntity() == this) {
|
||||
if (getRenderViewEntity(mc) == this) {
|
||||
// Only update camera rotation when the camera is the view
|
||||
super.setRotation(yaw, pitch);
|
||||
}
|
||||
@@ -232,10 +267,17 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
return falseUnlessSpectating(e -> e.isInsideOfMaterial(materialIn)); // Make sure no overlays are rendered
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@Override
|
||||
public boolean isInLava() {
|
||||
return falseUnlessSpectating(Entity::isInLava); // Make sure no lava overlay is rendered
|
||||
}
|
||||
//#else
|
||||
//$$ @Override
|
||||
//$$ public boolean handleLavaMovement() {
|
||||
//$$ return falseUnlessSpectating(Entity::handleLavaMovement); // Make sure no lava overlay is rendered
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public boolean isInWater() {
|
||||
@@ -248,7 +290,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
}
|
||||
|
||||
private boolean falseUnlessSpectating(Function<Entity, Boolean> property) {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
if (view != null && view != this) {
|
||||
return property.apply(view);
|
||||
}
|
||||
@@ -260,20 +302,24 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
return false; // We are in full control of ourselves
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@Override
|
||||
protected void createRunningParticles() {
|
||||
// We do not produce any particles, we are a camera
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
return false; // We are a camera, we cannot collide
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@Override
|
||||
public boolean isSpectator() {
|
||||
return ReplayModReplay.instance.getReplayHandler().isCameraView(); // Make sure we're treated as spectator
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass) {
|
||||
@@ -285,7 +331,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
@Override
|
||||
public boolean isInvisible() {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
if (view != this) {
|
||||
return view.isInvisible();
|
||||
}
|
||||
@@ -294,13 +340,14 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getLocationSkin() {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return Utils.getResourceLocationForPlayerUUID(view.getUniqueID());
|
||||
}
|
||||
return super.getLocationSkin();
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@Override
|
||||
public String getSkinType() {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
@@ -309,10 +356,11 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
}
|
||||
return super.getSkinType();
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public float getSwingProgress(float renderPartialTicks) {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return ((EntityPlayer) view).getSwingProgress(renderPartialTicks);
|
||||
}
|
||||
@@ -403,17 +451,21 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
if (mc.gameSettings.keyBindAttack.isPressed() || mc.gameSettings.keyBindUseItem.isPressed()) {
|
||||
if (canSpectate(mc.pointedEntity)) {
|
||||
ReplayModReplay.instance.getReplayHandler().spectateEntity(mc.pointedEntity);
|
||||
ReplayModReplay.instance.getReplayHandler().spectateEntity(
|
||||
//#if MC<=10710
|
||||
//$$ (EntityLivingBase)
|
||||
//#endif
|
||||
mc.pointedEntity);
|
||||
// Make sure we don't exit right away
|
||||
mc.gameSettings.keyBindSneak.pressTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, KeyBinding> keyBindings = ReplayMod.instance.getKeyBindingRegistry().getKeyBindings();
|
||||
if (keyBindings.get("replaymod.input.rollclockwise").isKeyDown()) {
|
||||
if (isKeyDown(keyBindings.get("replaymod.input.rollclockwise"))) {
|
||||
roll += Utils.isCtrlDown() ? 0.2 : 1;
|
||||
}
|
||||
if (keyBindings.get("replaymod.input.rollcounterclockwise").isKeyDown()) {
|
||||
if (isKeyDown(keyBindings.get("replaymod.input.rollcounterclockwise"))) {
|
||||
roll -= Utils.isCtrlDown() ? 0.2 : 1;
|
||||
}
|
||||
}
|
||||
@@ -427,7 +479,11 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
public boolean canSpectate(Entity e) {
|
||||
return e != null && !e.isInvisible()
|
||||
//#if MC>=10800
|
||||
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
||||
//#else
|
||||
//$$ && e instanceof EntityPlayer; // cannot be more generic since 1.7.10 has no concept of eye height
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=11102
|
||||
@@ -448,7 +504,14 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
private class EventHandler {
|
||||
//#if MC>=10800
|
||||
private
|
||||
//#else
|
||||
//$$ public // All event handlers need to be public in 1.7.10
|
||||
//#endif
|
||||
class EventHandler {
|
||||
private EventHandler() {}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPreClientTick(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase == TickEvent.Phase.START) {
|
||||
@@ -490,14 +553,14 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@SubscribeEvent
|
||||
public void onRenderHand(RenderHandEvent event) {
|
||||
// Unless we are spectating another player, don't render our hand
|
||||
if (mc.getRenderViewEntity() == CameraEntity.this || !(mc.getRenderViewEntity() instanceof EntityPlayer)) {
|
||||
if (getRenderViewEntity(mc) == CameraEntity.this || !(getRenderViewEntity(mc) instanceof EntityPlayer)) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onRenderHandMonitor(RenderHandEvent event) {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
if (view instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) view;
|
||||
// When the spectated player has changed, force equip their items to prevent the equip animation
|
||||
@@ -525,6 +588,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@SubscribeEvent
|
||||
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||
@@ -535,6 +599,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
private boolean heldItemTooltipsWasTrue;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ClassicCameraController implements CameraController {
|
||||
boolean forward = false, backward = false, left = false, right = false, up = false, down = false;
|
||||
speedup = false;
|
||||
for(KeyBinding kb : Minecraft.getMinecraft().gameSettings.keyBindings) {
|
||||
if(!kb.isKeyDown()) continue;
|
||||
if(!isKeyDown(kb)) continue;
|
||||
if(kb.getKeyDescription().equals("key.forward")) {
|
||||
forward = true;
|
||||
speedup = true;
|
||||
|
||||
@@ -10,6 +10,8 @@ import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class SpectatorCameraController implements CameraController {
|
||||
private final CameraEntity camera;
|
||||
@@ -34,9 +36,9 @@ public class SpectatorCameraController implements CameraController {
|
||||
// Always make sure the camera is in the exact same spot as the spectated entity
|
||||
// This is necessary as some rendering code for the hand doesn't respect the view entity
|
||||
// and always uses mc.thePlayer
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
if (view != null && view != camera) {
|
||||
camera.setCameraPosRot(mc.getRenderViewEntity());
|
||||
camera.setCameraPosRot(getRenderViewEntity(mc));
|
||||
// If it's a player, also 'steal' its inventory so the rendering code knows what item to render
|
||||
if (view instanceof EntityPlayer) {
|
||||
EntityPlayer viewPlayer = (EntityPlayer) view;
|
||||
|
||||
@@ -5,6 +5,8 @@ import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
/**
|
||||
* Camera controller performing vanilla creative-like camera movements.
|
||||
*/
|
||||
@@ -39,7 +41,7 @@ public class VanillaCameraController implements CameraController {
|
||||
if (partialTicksPassed == 0) return;
|
||||
Vector3f direction = new Vector3f(0, 0, 0);
|
||||
for (int i = 0; i < 6; i++) { // First, get movement direction depending on keys pressed
|
||||
if (bindings[i].isKeyDown()) {
|
||||
if (isKeyDown(bindings[i])) {
|
||||
Vector3f.add(direction, DIRECTIONS[i], direction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,14 @@ package com.replaymod.replay.events;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Event;
|
||||
//#endif
|
||||
|
||||
@Cancelable
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -3,7 +3,12 @@ package com.replaymod.replay.events;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Event;
|
||||
//#endif
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class ReplayCloseEvent extends Event {
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
package com.replaymod.replay.events;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Event;
|
||||
//#endif
|
||||
|
||||
public abstract class ReplayDispatchKeypressesEvent extends Event {
|
||||
|
||||
|
||||
@@ -3,7 +3,12 @@ package com.replaymod.replay.events;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.Event;
|
||||
//#endif
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class ReplayOpenEvent extends Event {
|
||||
|
||||
@@ -16,13 +16,19 @@ import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
import org.lwjgl.util.ReadablePoint;
|
||||
import org.lwjgl.util.WritablePoint;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//$$ import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
//#endif
|
||||
|
||||
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//#if MC<=10710
|
||||
//$$ package com.replaymod.replay.gui.screen;
|
||||
//$$
|
||||
//$$ import net.minecraft.client.gui.GuiScreen;
|
||||
//$$ import net.minecraft.network.NetworkManager;
|
||||
//$$
|
||||
//$$ public class GuiOpeningReplay extends GuiScreen {
|
||||
//$$ private final NetworkManager networkManager;
|
||||
//$$
|
||||
//$$ public GuiOpeningReplay(NetworkManager networkManager) {
|
||||
//$$ this.networkManager = networkManager;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public void handleInput() {
|
||||
//$$ networkManager.processReceivedPackets();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
@@ -8,8 +8,12 @@ import net.minecraft.client.gui.GuiIngameMenu;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//#if MC>=10800
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
@@ -24,3 +25,4 @@ public abstract class MixinGuiSpectator {
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.replaymod.replay.mixin;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
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.world.World;
|
||||
@@ -22,7 +21,14 @@ import net.minecraft.stats.StatisticsManager;
|
||||
//$$ import net.minecraft.stats.StatFileWriter;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//#endif
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class MixinPlayerControllerMP {
|
||||
@@ -49,20 +55,43 @@ public abstract class MixinPlayerControllerMP {
|
||||
//$$ if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
//$$ ci.setReturnValue(new CameraEntity(mc, worldIn, connection, statisticsManager));
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ @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));
|
||||
//#else
|
||||
//$$ @Inject(method = "createPlayer", at=@At("HEAD"), cancellable = true)
|
||||
//$$ private void replayModReplay_createReplayCamera(World worldIn, StatFileWriter statFileWriter, CallbackInfoReturnable<EntityClientPlayerMP> ci) {
|
||||
//$$ if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
//$$ ci.setReturnValue(new CameraEntity(mc, worldIn, mc.getSession(), netClientHandler, statFileWriter));
|
||||
//#endif
|
||||
//#endif
|
||||
//#endif
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@Inject(method = "isSpectator", at=@At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_isSpectator(CallbackInfoReturnable<Boolean> ci) {
|
||||
if (player(mc) instanceof CameraEntity) { // this check should in theory not be required
|
||||
ci.setReturnValue(player(mc).isSpectator());
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
//#if MC<=10710
|
||||
//$$ // Prevent the disconnect GUI from being opened during the short time when the replay is restarted
|
||||
//$$ // at which the old network manager is closed but still getting ticked (hence the disconnect GUI opening).
|
||||
//$$ @Inject(method = "updateController", at = @At("HEAD"), cancellable = true)
|
||||
//$$ private void replayModReplay_onlyTickNeverDisconnect(CallbackInfo ci) {
|
||||
//$$ if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
//$$ if (netClientHandler.getNetworkManager().isChannelOpen()) {
|
||||
//$$ netClientHandler.getNetworkManager().processReceivedPackets();
|
||||
//$$ }
|
||||
//$$ ci.cancel();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//#if MC>=10800
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
@@ -21,3 +22,4 @@ public abstract class MixinRenderArrow extends Render {
|
||||
return ReplayModReplay.instance.getReplayHandler() != null || super.shouldRender(entity, camera, camX, camY, camZ);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//#if MC>=10800
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -25,3 +26,4 @@ public class MixinRenderManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -3,17 +3,30 @@ 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.tileentity.TileEntityEndPortalRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityEndPortalRenderer;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.renderer.tileentity.RenderEndPortal;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
@Mixin(TileEntityEndPortalRenderer.class)
|
||||
//#else
|
||||
//$$ @Mixin(RenderEndPortal.class)
|
||||
//#endif
|
||||
public class MixinTileEntityEndPortalRenderer {
|
||||
//#if MC>=10809
|
||||
@Redirect(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ @Redirect(method = "func_180544_a", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||
//#else
|
||||
//$$ @Redirect(method = "renderTileEntityAt(Lnet/minecraft/tileentity/TileEntityEndPortal;DDDF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||
//#endif
|
||||
//#endif
|
||||
private long replayModReplay_getEnchantmentTime() {
|
||||
ReplayHandler replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//#if MC>=10800
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
@@ -91,3 +92,4 @@ public abstract class MixinViewFrustum {
|
||||
//$$ @Shadow abstract int func_178157_a(int p_178157_1_, int p_178157_2_, int p_178157_3_);
|
||||
//#endif
|
||||
}
|
||||
//#endif
|
||||
|
||||
Reference in New Issue
Block a user