Combine all versions into a single tree
This commit is contained in:
@@ -151,7 +151,11 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
// TODO: Translate magic values to Keyboard.KEY_ constants
|
||||
|
||||
if (key == 32 && Keyboard.isKeyDown(61) && mc.ingameGUI != null) {
|
||||
//#if MC>=11100
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||
//#else
|
||||
//$$ mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
//#endif
|
||||
}
|
||||
|
||||
if (key == 31 && Keyboard.isKeyDown(61)) {
|
||||
|
||||
@@ -43,7 +43,11 @@ public class NoGuiScreenshot {
|
||||
mc.getFramebuffer().bindFramebuffer(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
|
||||
//#if MC>=10809
|
||||
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks, System.nanoTime());
|
||||
//#else
|
||||
//$$ mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks);
|
||||
//#endif
|
||||
|
||||
mc.getFramebuffer().unbindFramebuffer();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.lwjgl.opengl.Display;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
@@ -77,7 +78,7 @@ public class ReplayHandler {
|
||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||
this.replayFile = replayFile;
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Pre(this));
|
||||
FML_BUS.post(new ReplayOpenEvent.Pre(this));
|
||||
|
||||
markers = new ArrayList<>(replayFile.getMarkers().or(Collections.emptySet()));
|
||||
|
||||
@@ -88,7 +89,7 @@ public class ReplayHandler {
|
||||
overlay = new GuiReplayOverlay(this);
|
||||
overlay.setVisible(true);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayOpenEvent.Post(this));
|
||||
FML_BUS.post(new ReplayOpenEvent.Post(this));
|
||||
}
|
||||
|
||||
void restartedReplay() {
|
||||
@@ -102,7 +103,7 @@ public class ReplayHandler {
|
||||
public void endReplay() throws IOException {
|
||||
Preconditions.checkState(mc.isCallingFromMinecraftThread(), "Must be called from Minecraft thread.");
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Pre(this));
|
||||
FML_BUS.post(new ReplayCloseEvent.Pre(this));
|
||||
|
||||
replaySender.terminateReplay();
|
||||
|
||||
@@ -111,27 +112,35 @@ public class ReplayHandler {
|
||||
|
||||
channel.close().awaitUninterruptibly();
|
||||
|
||||
if (mc.player instanceof CameraEntity) {
|
||||
mc.player.setDead();
|
||||
if (player(mc) instanceof CameraEntity) {
|
||||
player(mc).setDead();
|
||||
}
|
||||
|
||||
if (mc.world != null) {
|
||||
mc.world.sendQuittingDisconnectingPacket();
|
||||
if (world(mc) != null) {
|
||||
world(mc).sendQuittingDisconnectingPacket();
|
||||
mc.loadWorld(null);
|
||||
}
|
||||
|
||||
//#if MC>=11200
|
||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK;
|
||||
//#else
|
||||
//$$ mc.timer.timerSpeed = 1;
|
||||
//#endif
|
||||
overlay.setVisible(false);
|
||||
|
||||
ReplayModReplay.instance.replayHandler = null;
|
||||
|
||||
mc.displayGuiScreen(null);
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ReplayCloseEvent.Post(this));
|
||||
FML_BUS.post(new ReplayCloseEvent.Post(this));
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages(true);
|
||||
//#if MC>=11100
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||
//#else
|
||||
//$$ mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
//#endif
|
||||
|
||||
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
||||
@Override
|
||||
@@ -144,6 +153,7 @@ public class ReplayHandler {
|
||||
networkManager.setNetHandler(netHandlerPlayClient);
|
||||
FMLClientHandler.instance().setPlayClient(netHandlerPlayClient);
|
||||
|
||||
//#if MC>=11200
|
||||
channel = new EmbeddedChannel();
|
||||
NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
||||
channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||
@@ -152,6 +162,15 @@ public class ReplayHandler {
|
||||
channel.pipeline().addLast("packet_handler", networkManager);
|
||||
channel.pipeline().fireChannelActive();
|
||||
networkDispatcher.clientToServerHandshake();
|
||||
//#else
|
||||
//$$ channel = new EmbeddedChannel(networkManager);
|
||||
//$$ NetworkDispatcher networkDispatcher = new NetworkDispatcher(networkManager);
|
||||
//$$ channel.attr(NetworkDispatcher.FML_DISPATCHER).set(networkDispatcher);
|
||||
//$$
|
||||
//$$ channel.pipeline().addFirst("ReplayModReplay_replaySender", replaySender);
|
||||
//$$ channel.pipeline().addAfter("ReplayModReplay_replaySender", "fml:packet_handler", networkDispatcher);
|
||||
//$$ channel.pipeline().fireChannelActive();
|
||||
//#endif
|
||||
}
|
||||
|
||||
public ReplayFile getReplayFile() {
|
||||
@@ -248,7 +267,7 @@ public class ReplayHandler {
|
||||
* @return {@code true} if the camera is the view entity, {@code false} otherwise
|
||||
*/
|
||||
public boolean isCameraView() {
|
||||
return mc.player instanceof CameraEntity && mc.player == mc.getRenderViewEntity();
|
||||
return player(mc) instanceof CameraEntity && player(mc) == mc.getRenderViewEntity();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,7 +275,7 @@ public class ReplayHandler {
|
||||
* @return The camera entity or {@code null} if it does not yet exist
|
||||
*/
|
||||
public CameraEntity getCameraEntity() {
|
||||
return mc.player instanceof CameraEntity ? (CameraEntity) mc.player : null;
|
||||
return player(mc) instanceof CameraEntity ? (CameraEntity) player(mc) : null;
|
||||
}
|
||||
|
||||
public UUID getSpectatedUUID() {
|
||||
@@ -303,7 +322,7 @@ public class ReplayHandler {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
drawBackground(0);
|
||||
drawCenteredString(fontRenderer, I18n.format("replaymod.gui.pleasewait"),
|
||||
drawCenteredString(getFontRenderer(mc), I18n.format("replaymod.gui.pleasewait"),
|
||||
width / 2, height / 2, 0xffffffff);
|
||||
}
|
||||
};
|
||||
@@ -318,7 +337,7 @@ public class ReplayHandler {
|
||||
mc.getFramebuffer().bindFramebuffer(true);
|
||||
mc.entityRenderer.setupOverlayRendering();
|
||||
|
||||
ScaledResolution resolution = new ScaledResolution(mc);
|
||||
ScaledResolution resolution = newScaledResolution(mc);
|
||||
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
||||
guiScreen.drawScreen(0, 0, 0);
|
||||
|
||||
@@ -335,8 +354,8 @@ public class ReplayHandler {
|
||||
replaySender.setAsyncMode(true);
|
||||
replaySender.setReplaySpeed(0);
|
||||
|
||||
mc.getConnection().getNetworkManager().processReceivedPackets();
|
||||
for (Entity entity : mc.world.loadedEntityList) {
|
||||
getConnection(mc).getNetworkManager().processReceivedPackets();
|
||||
for (Entity entity : loadedEntityList(world(mc))) {
|
||||
if (entity instanceof EntityOtherPlayerMP) {
|
||||
EntityOtherPlayerMP e = (EntityOtherPlayerMP) entity;
|
||||
e.setPosition(e.otherPlayerMPX, e.otherPlayerMPY, e.otherPlayerMPZ);
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
|
||||
import com.google.common.io.Files;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.utils.Restrictions;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import com.replaymod.replaystudio.io.ReplayInputStream;
|
||||
import com.replaymod.replaystudio.io.ReplayOutputStream;
|
||||
@@ -26,11 +25,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.*;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.util.ClassInheritanceMultiMap;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -41,12 +36,29 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
//#if MC>=11200
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
//#endif
|
||||
//#if MC>=11002
|
||||
import net.minecraft.world.GameType;
|
||||
//#else
|
||||
//$$ import net.minecraft.world.WorldSettings.GameType;
|
||||
//#endif
|
||||
//#if MC>=10904
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
//#else
|
||||
//$$ import net.minecraft.util.IChatComponent;
|
||||
//#endif
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
/**
|
||||
* Sends replay packets to netty channels.
|
||||
* Even though {@link Sharable}, this should never be added to multiple pipes at once, it may however be re-added when
|
||||
@@ -58,10 +70,13 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
* These packets are ignored completely during replay.
|
||||
*/
|
||||
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
||||
// TODO Update possibly more?
|
||||
//#if MC>=11200
|
||||
SPacketRecipeBook.class,
|
||||
SPacketAdvancementInfo.class,
|
||||
SPacketSelectAdvancementsTab.class,
|
||||
//#endif
|
||||
//#if MC>=10904
|
||||
// TODO Update possibly more?
|
||||
SPacketUpdateHealth.class,
|
||||
SPacketOpenWindow.class,
|
||||
SPacketCloseWindow.class,
|
||||
@@ -72,7 +87,21 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
SPacketSetExperience.class,
|
||||
SPacketCamera.class,
|
||||
SPacketPlayerAbilities.class,
|
||||
SPacketTitle.class);
|
||||
SPacketTitle.class
|
||||
//#else
|
||||
//$$ S06PacketUpdateHealth.class,
|
||||
//$$ S2DPacketOpenWindow.class,
|
||||
//$$ S2EPacketCloseWindow.class,
|
||||
//$$ S2FPacketSetSlot.class,
|
||||
//$$ S30PacketWindowItems.class,
|
||||
//$$ S36PacketSignEditorOpen.class,
|
||||
//$$ S37PacketStatistics.class,
|
||||
//$$ S1FPacketSetExperience.class,
|
||||
//$$ S43PacketCamera.class,
|
||||
//$$ S39PacketPlayerAbilities.class,
|
||||
//$$ S45PacketTitle.class
|
||||
//#endif
|
||||
);
|
||||
|
||||
private static int TP_DISTANCE_LIMIT = 128;
|
||||
|
||||
@@ -271,8 +300,8 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
// Entity#addedToChunk is not set and it is therefore not updated every tick.
|
||||
// To counteract this, we need to manually update it's position if it hasn't been added
|
||||
// to any chunk yet.
|
||||
if (mc.world != null) {
|
||||
for (EntityPlayer playerEntity : mc.world.playerEntities) {
|
||||
if (world(mc) != null) {
|
||||
for (EntityPlayer playerEntity : playerEntities(world(mc))) {
|
||||
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
||||
playerEntity.onLivingUpdate();
|
||||
}
|
||||
@@ -306,7 +335,8 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
// If we do not give minecraft time to tick, there will be dead entity artifacts left in the world
|
||||
// Therefore we have to remove all loaded, dead entities manually if we are in sync mode.
|
||||
// We do this after every SpawnX packet and after the destroy entities packet.
|
||||
if (!asyncMode && mc.world != null) {
|
||||
if (!asyncMode && world(mc) != null) {
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketSpawnPlayer
|
||||
|| p instanceof SPacketSpawnObject
|
||||
|| p instanceof SPacketSpawnMob
|
||||
@@ -314,14 +344,27 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
|| p instanceof SPacketSpawnPainting
|
||||
|| p instanceof SPacketSpawnExperienceOrb
|
||||
|| p instanceof SPacketDestroyEntities) {
|
||||
World world = mc.world;
|
||||
//#else
|
||||
//$$ if (p instanceof S0CPacketSpawnPlayer
|
||||
//$$ || p instanceof S0EPacketSpawnObject
|
||||
//$$ || p instanceof S0FPacketSpawnMob
|
||||
//$$ || p instanceof S2CPacketSpawnGlobalEntity
|
||||
//$$ || p instanceof S10PacketSpawnPainting
|
||||
//$$ || p instanceof S11PacketSpawnExperienceOrb
|
||||
//$$ || p instanceof S13PacketDestroyEntities) {
|
||||
//#endif
|
||||
World world = world(mc);
|
||||
for (int i = 0; i < world.loadedEntityList.size(); ++i) {
|
||||
Entity entity = world.loadedEntityList.get(i);
|
||||
Entity entity = loadedEntityList(world).get(i);
|
||||
if (entity.isDead) {
|
||||
int chunkX = entity.chunkCoordX;
|
||||
int chunkY = entity.chunkCoordZ;
|
||||
|
||||
//#if MC>=10904
|
||||
if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
||||
//#else
|
||||
//$$ if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
||||
//#endif
|
||||
world.getChunkFromChunkCoords(chunkX, chunkY).removeEntity(entity);
|
||||
}
|
||||
|
||||
@@ -345,7 +388,7 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
|
||||
int i = pb.readVarInt();
|
||||
int i = readVarInt(pb);
|
||||
|
||||
Packet p = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
p.readPacketData(pb);
|
||||
@@ -359,8 +402,13 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
* @return The processed packet or {@code null} if no packet shall be sent
|
||||
*/
|
||||
protected Packet processPacket(Packet p) throws Exception {
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
//#else
|
||||
//$$ if (p instanceof S3FPacketCustomPayload) {
|
||||
//$$ S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||
//#endif
|
||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
||||
final String unknown = replayHandler.getRestrictions().handle(packet);
|
||||
if (unknown == null) {
|
||||
@@ -386,8 +434,17 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketDisconnect) {
|
||||
ITextComponent reason = ((SPacketDisconnect) p).getReason();
|
||||
//#else
|
||||
//$$ if (p instanceof S40PacketDisconnect) {
|
||||
//#if MC>=10809
|
||||
//$$ IChatComponent reason = ((S40PacketDisconnect) p).getReason();
|
||||
//#else
|
||||
//$$ IChatComponent reason = ((S40PacketDisconnect) p).func_149165_c();
|
||||
//#endif
|
||||
//#endif
|
||||
if ("Please update to view this replay.".equals(reason.getUnformattedText())) {
|
||||
// This version of the mod supports replay restrictions so we are allowed
|
||||
// to remove this packet.
|
||||
@@ -397,16 +454,31 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
|
||||
if(BAD_PACKETS.contains(p.getClass())) return null;
|
||||
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
//#else
|
||||
//$$ if (p instanceof S3FPacketCustomPayload) {
|
||||
//$$ S3FPacketCustomPayload packet = (S3FPacketCustomPayload) p;
|
||||
//#endif
|
||||
if ("MC|BOpen".equals(packet.getChannelName())) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
if(p instanceof SPacketResourcePackSend) {
|
||||
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
||||
String url = packet.getURL();
|
||||
//#else
|
||||
//$$ if(p instanceof S48PacketResourcePackSend) {
|
||||
//$$ S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
||||
//#if MC>=10809
|
||||
//$$ String url = packet.getURL();
|
||||
//#else
|
||||
//$$ String url = packet.func_179783_a();
|
||||
//#endif
|
||||
//#endif
|
||||
if (url.startsWith("replay://")) {
|
||||
int id = Integer.parseInt(url.substring("replay://".length()));
|
||||
Map<Integer, String> index = replayFile.getResourcePackIndex();
|
||||
@@ -417,17 +489,23 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
if (!file.exists()) {
|
||||
IOUtils.copy(replayFile.getResourcePack(hash).get(), new FileOutputStream(file));
|
||||
}
|
||||
mc.getResourcePackRepository().setServerResourcePack(file);
|
||||
setServerResourcePack(mc.getResourcePackRepository(), file);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
if(p instanceof SPacketJoinGame) {
|
||||
SPacketJoinGame packet = (SPacketJoinGame) p;
|
||||
allowMovement = true;
|
||||
int entId = packet.getPlayerId();
|
||||
//#else
|
||||
//$$ if(p instanceof S01PacketJoinGame) {
|
||||
//$$ S01PacketJoinGame packet = (S01PacketJoinGame) p;
|
||||
//$$ int entId = packet.getEntityId();
|
||||
//#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
|
||||
int dimension = packet.getDimension();
|
||||
@@ -435,21 +513,43 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
int maxPlayers = packet.getMaxPlayers();
|
||||
WorldType worldType = packet.getWorldType();
|
||||
|
||||
//#if MC>=10904
|
||||
p = new SPacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||
difficulty, maxPlayers, worldType, false);
|
||||
//#else
|
||||
//$$ p = new S01PacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||
//$$ difficulty, maxPlayers, worldType, false);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
if(p instanceof SPacketRespawn) {
|
||||
SPacketRespawn respawn = (SPacketRespawn) p;
|
||||
p = new SPacketRespawn(respawn.getDimensionID(),
|
||||
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||
//#else
|
||||
//$$ if(p instanceof S07PacketRespawn) {
|
||||
//$$ S07PacketRespawn respawn = (S07PacketRespawn) p;
|
||||
//#if MC>=10809
|
||||
//$$ p = new S07PacketRespawn(respawn.getDimensionID(),
|
||||
//$$ respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||
//#else
|
||||
//$$ p = new S07PacketRespawn(respawn.func_149082_c(),
|
||||
//$$ respawn.func_149081_d(), respawn.func_149080_f(), GameType.SPECTATOR);
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
allowMovement = true;
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
if(p instanceof SPacketPlayerPosLook) {
|
||||
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||
final SPacketPlayerPosLook ppl = (SPacketPlayerPosLook) p;
|
||||
//#else
|
||||
//$$ if(p instanceof S08PacketPlayerPosLook) {
|
||||
//$$ final S08PacketPlayerPosLook ppl = (S08PacketPlayerPosLook) p;
|
||||
//#endif
|
||||
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||
|
||||
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
||||
// Close the world loading screen manually in case we swallow the packet
|
||||
@@ -460,17 +560,29 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
|
||||
CameraEntity cent = replayHandler.getCameraEntity();
|
||||
|
||||
//#if MC>=10904
|
||||
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
||||
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
||||
|| relative == SPacketPlayerPosLook.EnumFlags.Y
|
||||
|| relative == SPacketPlayerPosLook.EnumFlags.Z) {
|
||||
//#else
|
||||
//$$ for (Object relative : ppl.func_179834_f()) {
|
||||
//$$ if (relative == S08PacketPlayerPosLook.EnumFlags.X
|
||||
//$$ || relative == S08PacketPlayerPosLook.EnumFlags.Y
|
||||
//$$ || relative == S08PacketPlayerPosLook.EnumFlags.Z) {
|
||||
//#endif
|
||||
return null; // At least one of the coordinates is relative, so we don't care
|
||||
}
|
||||
}
|
||||
|
||||
if(cent != null) {
|
||||
//#if MC>=10809
|
||||
if(!allowMovement && !((Math.abs(cent.posX - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
||||
(Math.abs(cent.posZ - ppl.getZ()) > TP_DISTANCE_LIMIT))) {
|
||||
//#else
|
||||
//$$ if(!allowMovement && !((Math.abs(cent.posX - ppl.func_148932_c()) > TP_DISTANCE_LIMIT) ||
|
||||
//$$ (Math.abs(cent.posZ - ppl.func_148933_e()) > TP_DISTANCE_LIMIT))) {
|
||||
//#endif
|
||||
return null;
|
||||
} else {
|
||||
allowMovement = false;
|
||||
@@ -481,20 +593,34 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void run() {
|
||||
if (mc.world == null || !mc.isCallingFromMinecraftThread()) {
|
||||
if (world(mc) == null || !mc.isCallingFromMinecraftThread()) {
|
||||
ReplayMod.instance.runLater(this);
|
||||
return;
|
||||
}
|
||||
|
||||
CameraEntity cent = replayHandler.getCameraEntity();
|
||||
//#if MC>=10809
|
||||
cent.setCameraPosition(ppl.getX(), ppl.getY(), ppl.getZ());
|
||||
//#else
|
||||
//$$ cent.setCameraPosition(ppl.func_148932_c(), ppl.func_148928_d(), ppl.func_148933_e());
|
||||
//#endif
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
if(p instanceof SPacketChangeGameState) {
|
||||
SPacketChangeGameState pg = (SPacketChangeGameState)p;
|
||||
int reason = pg.getGameState();
|
||||
//#else
|
||||
//$$ if(p instanceof S2BPacketChangeGameState) {
|
||||
//$$ S2BPacketChangeGameState pg = (S2BPacketChangeGameState)p;
|
||||
//#if MC>=10809
|
||||
//$$ int reason = pg.getGameState();
|
||||
//#else
|
||||
//$$ int reason = pg.func_149138_c();
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
// only allow the following packets:
|
||||
// 1 - End raining
|
||||
@@ -508,7 +634,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketChat) {
|
||||
//#else
|
||||
//$$ if (p instanceof S02PacketChat) {
|
||||
//#endif
|
||||
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||
return null;
|
||||
}
|
||||
@@ -521,7 +651,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||
this.ctx = ctx;
|
||||
//#if MC>=10904
|
||||
ctx.channel().attr(NetworkManager.PROTOCOL_ATTRIBUTE_KEY).set(EnumConnectionState.PLAY);
|
||||
//#else
|
||||
//$$ ctx.attr(NetworkManager.attrKeyConnectionState).set(EnumConnectionState.PLAY);
|
||||
//#endif
|
||||
super.channelActive(ctx);
|
||||
}
|
||||
|
||||
@@ -549,7 +683,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
* @return {@code true} if it is paused, {@code false} otherwise
|
||||
*/
|
||||
public boolean paused() {
|
||||
//#if MC>=11200
|
||||
return mc.timer.tickLength == Float.POSITIVE_INFINITY;
|
||||
//#else
|
||||
//$$ return mc.timer.timerSpeed == 0;
|
||||
//#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,7 +707,11 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
*/
|
||||
public void setReplaySpeed(final double d) {
|
||||
if(d != 0) this.replaySpeed = d;
|
||||
//#if MC>=11200
|
||||
mc.timer.tickLength = WrappedTimer.DEFAULT_MS_PER_TICK / (float) d;
|
||||
//#else
|
||||
//$$ mc.timer.timerSpeed = (float) d;
|
||||
//#endif
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
@@ -739,11 +881,23 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
protected Packet processPacketAsync(Packet p) {
|
||||
//If hurrying, ignore some packets, except for short durations
|
||||
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
||||
//#if MC>=10904
|
||||
if(p instanceof SPacketParticles) return null;
|
||||
|
||||
if(p instanceof SPacketSpawnObject) {
|
||||
SPacketSpawnObject pso = (SPacketSpawnObject)p;
|
||||
int type = pso.getType();
|
||||
//#else
|
||||
//$$ if(p instanceof S2APacketParticles) return null;
|
||||
//$$
|
||||
//$$ if(p instanceof S0EPacketSpawnObject) {
|
||||
//$$ S0EPacketSpawnObject pso = (S0EPacketSpawnObject)p;
|
||||
//#if MC>=10809
|
||||
//$$ int type = pso.getType();
|
||||
//#else
|
||||
//$$ int type = pso.func_148993_l();
|
||||
//#endif
|
||||
//#endif
|
||||
if(type == 76) { // Firework rocket
|
||||
return null;
|
||||
}
|
||||
@@ -829,22 +983,38 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
}
|
||||
|
||||
protected Packet processPacketSync(Packet p) {
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketUnloadChunk) {
|
||||
SPacketUnloadChunk packet = (SPacketUnloadChunk) p;
|
||||
int x = packet.getX();
|
||||
int z = packet.getZ();
|
||||
//#else
|
||||
//#if MC>=10809
|
||||
//$$ if (p instanceof S21PacketChunkData && ((S21PacketChunkData) p).getExtractedSize() == 0) {
|
||||
//$$ S21PacketChunkData packet = (S21PacketChunkData) p;
|
||||
//$$ int x = packet.getChunkX();
|
||||
//$$ int z = packet.getChunkZ();
|
||||
//#else
|
||||
//$$ if (p instanceof S21PacketChunkData && ((S21PacketChunkData) p).func_149276_g() == 0) {
|
||||
//$$ S21PacketChunkData packet = (S21PacketChunkData) p;
|
||||
//$$ int x = packet.func_149273_e();
|
||||
//$$ int z = packet.func_149271_f();
|
||||
//#endif
|
||||
//#endif
|
||||
// If the chunk is getting unloaded, we will have to forcefully update the position of all entities
|
||||
// within. Otherwise, if there wasn't a game tick recently, there may be entities that have moved
|
||||
// out of the chunk by now but are still registered in it. If we do not update those, they will get
|
||||
// unloaded even though they shouldn't.
|
||||
// To make things worse, it seems like players were never supposed to be unloaded this way because
|
||||
// they will remain glitched in the World#playerEntities list.
|
||||
World world = mc.world;
|
||||
World world = world(mc);
|
||||
IChunkProvider chunkProvider = world.getChunkProvider();
|
||||
// Get the chunk that will be unloaded
|
||||
Chunk chunk = chunkProvider.provideChunk(packet.getX(), packet.getZ());
|
||||
Chunk chunk = chunkProvider.provideChunk(x, z);
|
||||
if (!chunk.isEmpty()) {
|
||||
List<Entity> entitiesInChunk = new ArrayList<>();
|
||||
// Gather all entities in that chunk
|
||||
for (ClassInheritanceMultiMap<Entity> entityList : chunk.getEntityLists()) {
|
||||
for (Collection<Entity> entityList : getEntityLists(chunk)) {
|
||||
entitiesInChunk.addAll(entityList);
|
||||
}
|
||||
for (Entity entity : entitiesInChunk) {
|
||||
@@ -857,12 +1027,17 @@ public class ReplaySender extends ChannelDuplexHandler {
|
||||
}
|
||||
|
||||
// Check whether the entity has left the chunk
|
||||
int chunkX = MathHelper.floor(entity.posX / 16);
|
||||
int chunkZ = MathHelper.floor(entity.posZ / 16);
|
||||
int chunkX = floor(entity.posX / 16);
|
||||
int chunkZ = floor(entity.posZ / 16);
|
||||
if (entity.chunkCoordX != chunkX || entity.chunkCoordZ != chunkZ) {
|
||||
// Entity has left the chunk
|
||||
chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
||||
//#if MC>=10904
|
||||
Chunk newChunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
||||
//#else
|
||||
//$$ Chunk newChunk = chunkProvider.chunkExists(chunkX, chunkZ)
|
||||
//$$ ? chunkProvider.provideChunk(chunkX, chunkZ) : null;
|
||||
//#endif
|
||||
if (newChunk != null) {
|
||||
newChunk.addEntity(entity);
|
||||
} else {
|
||||
|
||||
@@ -19,14 +19,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.stats.RecipeBook;
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
@@ -36,13 +29,32 @@ 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;
|
||||
//#if MC>=11200
|
||||
import net.minecraft.stats.RecipeBook;
|
||||
//#endif
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
//#else
|
||||
//$$ import net.minecraft.stats.StatFileWriter;
|
||||
//$$ import net.minecraft.util.AxisAlignedBB;
|
||||
//$$ import net.minecraft.util.IChatComponent;
|
||||
//$$ import net.minecraft.util.MovingObjectPosition;
|
||||
//#endif
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
/**
|
||||
* The camera entity used as the main player entity during replay viewing.
|
||||
* During a replay {@link Minecraft#player} should be an instance of this class.
|
||||
* 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 {
|
||||
@@ -69,9 +81,20 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
*/
|
||||
private final EventHandler eventHandler = new EventHandler();
|
||||
|
||||
//#if MC>=11200
|
||||
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager, RecipeBook recipeBook) {
|
||||
super(mcIn, worldIn, netHandlerPlayClient, statisticsManager, recipeBook);
|
||||
MinecraftForge.EVENT_BUS.register(eventHandler);
|
||||
//#else
|
||||
//#if MC>=10904
|
||||
//$$ public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager) {
|
||||
//$$ super(mcIn, worldIn, netHandlerPlayClient, statisticsManager);
|
||||
//#else
|
||||
//$$ public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatFileWriter statFileWriter) {
|
||||
//$$ super(mcIn, worldIn, netHandlerPlayClient, statFileWriter);
|
||||
//#endif
|
||||
//#endif
|
||||
FORGE_BUS.register(eventHandler);
|
||||
FML_BUS.register(eventHandler);
|
||||
if (ReplayModReplay.instance.getReplayHandler().getSpectatedUUID() == null) {
|
||||
cameraController = ReplayModReplay.instance.createCameraController(this);
|
||||
} else {
|
||||
@@ -159,14 +182,14 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
// entity is recreated and we have to spectate a new entity
|
||||
UUID spectating = ReplayModReplay.instance.getReplayHandler().getSpectatedUUID();
|
||||
if (spectating != null && (view.getUniqueID() != spectating
|
||||
|| view.world != world)
|
||||
|| world.getEntityByID(view.getEntityId()) != view) {
|
||||
|| world(view) != world(this))
|
||||
|| world(this).getEntityByID(view.getEntityId()) != view) {
|
||||
if (spectating == null) {
|
||||
// Entity (non-player) died, stop spectating
|
||||
ReplayModReplay.instance.getReplayHandler().spectateEntity(this);
|
||||
return;
|
||||
}
|
||||
view = world.getPlayerEntityByUUID(spectating);
|
||||
view = world(this).getPlayerEntityByUUID(spectating);
|
||||
if (view != null) {
|
||||
mc.setRenderViewEntity(view);
|
||||
} else {
|
||||
@@ -185,8 +208,8 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@Override
|
||||
public void preparePlayerToSpawn() {
|
||||
// Make sure our world is up-to-date in case of world changes
|
||||
if (mc.world != null) {
|
||||
world = mc.world;
|
||||
if (world(mc) != null) {
|
||||
world(this, world(mc));
|
||||
}
|
||||
super.preparePlayerToSpawn();
|
||||
}
|
||||
@@ -296,6 +319,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
return 0;
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
@Override
|
||||
public float getCooldownPeriod() {
|
||||
Entity view = mc.getRenderViewEntity();
|
||||
@@ -344,6 +368,19 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
return pos;
|
||||
}
|
||||
//#else
|
||||
//$$ @Override
|
||||
//$$ public MovingObjectPosition rayTrace(double p_174822_1_, float p_174822_3_) {
|
||||
//$$ MovingObjectPosition pos = super.rayTrace(p_174822_1_, 1f);
|
||||
//$$
|
||||
//$$ // Make sure we can never look at blocks (-> no outline)
|
||||
//$$ if(pos != null && pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
//$$ pos.typeOfHit = MovingObjectPosition.MovingObjectType.MISS;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ return pos;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public void openGui(Object mod, int modGuiId, World world, int x, int y, int z) {
|
||||
@@ -354,7 +391,8 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@Override
|
||||
public void setDead() {
|
||||
super.setDead();
|
||||
MinecraftForge.EVENT_BUS.unregister(eventHandler);
|
||||
FORGE_BUS.unregister(eventHandler);
|
||||
FML_BUS.unregister(eventHandler);
|
||||
}
|
||||
|
||||
private void update() {
|
||||
@@ -392,11 +430,23 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
||||
}
|
||||
|
||||
//#if MC>=11102
|
||||
@Override
|
||||
public void sendMessage(ITextComponent message) {
|
||||
if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
||||
super.sendMessage(message);
|
||||
}
|
||||
//#else
|
||||
//$$ @Override
|
||||
//#if MC>=10904
|
||||
//$$ public void addChatMessage(ITextComponent message) {
|
||||
//#else
|
||||
//$$ public void addChatMessage(IChatComponent message) {
|
||||
//#endif
|
||||
//$$ if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
||||
//$$ super.addChatMessage(message);
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
private class EventHandler {
|
||||
@SubscribeEvent
|
||||
@@ -417,11 +467,11 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@SubscribeEvent
|
||||
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||
// The crosshair should only render if targeted entity can actually be spectated
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
if (getType(event) == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
event.setCanceled(!canSpectate(mc.pointedEntity));
|
||||
}
|
||||
// Hotbar should never be rendered
|
||||
if (event.getType() == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
||||
if (getType(event) == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
@@ -454,16 +504,23 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
if (lastHandRendered != player) {
|
||||
lastHandRendered = player;
|
||||
|
||||
//#if MC>=10904
|
||||
mc.entityRenderer.itemRenderer.prevEquippedProgressMainHand = 1;
|
||||
mc.entityRenderer.itemRenderer.prevEquippedProgressOffHand = 1;
|
||||
mc.entityRenderer.itemRenderer.equippedProgressMainHand = 1;
|
||||
mc.entityRenderer.itemRenderer.equippedProgressOffHand = 1;
|
||||
mc.entityRenderer.itemRenderer.itemStackMainHand = player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND);
|
||||
mc.entityRenderer.itemRenderer.itemStackOffHand = player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND);
|
||||
//#else
|
||||
//$$ mc.entityRenderer.itemRenderer.prevEquippedProgress = 1;
|
||||
//$$ mc.entityRenderer.itemRenderer.equippedProgress = 1;
|
||||
//$$ mc.entityRenderer.itemRenderer.itemToRender = player.inventory.getCurrentItem();
|
||||
//$$ mc.entityRenderer.itemRenderer.equippedItemSlot = player.inventory.currentItem;
|
||||
//#endif
|
||||
|
||||
|
||||
mc.player.renderArmYaw = mc.player.prevRenderArmYaw = player.rotationYaw;
|
||||
mc.player.renderArmPitch = mc.player.prevRenderArmPitch = player.rotationPitch;
|
||||
player(mc).renderArmYaw = player(mc).prevRenderArmYaw = player.rotationYaw;
|
||||
player(mc).renderArmPitch = player(mc).prevRenderArmPitch = player.rotationPitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -471,7 +528,11 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
@SubscribeEvent
|
||||
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||
//#if MC>=10904
|
||||
event.setRoll(roll);
|
||||
//#else
|
||||
//$$ event.roll = roll;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,7 +540,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
@SubscribeEvent
|
||||
public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
|
||||
switch (event.getType()) {
|
||||
switch (getType(event)) {
|
||||
case ALL:
|
||||
heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips;
|
||||
mc.gameSettings.heldItemTooltips = false;
|
||||
@@ -492,15 +553,19 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
case EXPERIENCE:
|
||||
case HEALTHMOUNT:
|
||||
case JUMPBAR:
|
||||
//#if MC>=10904
|
||||
case POTION_ICONS:
|
||||
//#endif
|
||||
event.setCanceled(true);
|
||||
break;
|
||||
case HELMET:
|
||||
case PORTAL:
|
||||
case CROSSHAIRS:
|
||||
case BOSSHEALTH:
|
||||
//#if MC>=10904
|
||||
case BOSSINFO:
|
||||
case SUBTITLES:
|
||||
//#endif
|
||||
case TEXT:
|
||||
case CHAT:
|
||||
case PLAYER_LIST:
|
||||
@@ -511,7 +576,7 @@ public class CameraEntity extends EntityPlayerSP {
|
||||
|
||||
@SubscribeEvent
|
||||
public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
||||
if (event.getType() != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
if (getType(event) != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@ package com.replaymod.replay.camera;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
// TODO: Marius is responsible for this. Please, someone clean it up.
|
||||
public class ClassicCameraController implements CameraController {
|
||||
@@ -18,8 +19,8 @@ public class ClassicCameraController implements CameraController {
|
||||
private double THRESHOLD = MAX_SPEED / 20;
|
||||
private double DECAY = MAX_SPEED/3;
|
||||
|
||||
private Vec3d direction;
|
||||
private Vec3d dirBefore;
|
||||
private Vector3f direction;
|
||||
private Vector3f dirBefore;
|
||||
private double motion;
|
||||
private long lastCall = Sys.getTime();
|
||||
|
||||
@@ -129,7 +130,7 @@ public class ClassicCameraController implements CameraController {
|
||||
return;
|
||||
}
|
||||
|
||||
Vec3d movement = direction.normalize();
|
||||
Vector3f movement = direction.normalise(null);
|
||||
double factor = motion * (frac / 1000D);
|
||||
|
||||
camera.moveCamera(movement.x * factor, movement.y * factor, movement.z * factor);
|
||||
@@ -158,10 +159,10 @@ public class ClassicCameraController implements CameraController {
|
||||
break;
|
||||
}
|
||||
|
||||
Vec3d dbf = direction;
|
||||
Vector3f dbf = direction;
|
||||
|
||||
if(dirBefore != null) {
|
||||
direction = dirBefore.normalize().add(direction);
|
||||
direction = Vector3f.add(direction, dirBefore.normalise(null), null);
|
||||
}
|
||||
|
||||
dirBefore = dbf;
|
||||
@@ -169,12 +170,12 @@ public class ClassicCameraController implements CameraController {
|
||||
updateMovement();
|
||||
}
|
||||
|
||||
private Vec3d getVectorForRotation(float pitch, float yaw) {
|
||||
float f2 = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float f3 = MathHelper.sin(-yaw * 0.017453292F - (float)Math.PI);
|
||||
float f4 = -MathHelper.cos(-pitch * 0.017453292F);
|
||||
float f5 = MathHelper.sin(-pitch * 0.017453292F);
|
||||
return new Vec3d((double)(f3 * f4), (double)f5, (double)(f2 * f4));
|
||||
private Vector3f getVectorForRotation(float pitch, float yaw) {
|
||||
float f2 = cos(-yaw * 0.017453292F - (float) Math.PI);
|
||||
float f3 = sin(-yaw * 0.017453292F - (float)Math.PI);
|
||||
float f4 = -cos(-pitch * 0.017453292F);
|
||||
float f5 = sin(-pitch * 0.017453292F);
|
||||
return new Vector3f(f3 * f4, f5, f2 * f4);
|
||||
}
|
||||
|
||||
public enum MoveDirection {
|
||||
|
||||
@@ -41,9 +41,14 @@ public class SpectatorCameraController implements CameraController {
|
||||
if (view instanceof EntityPlayer) {
|
||||
EntityPlayer viewPlayer = (EntityPlayer) view;
|
||||
camera.inventory = viewPlayer.inventory;
|
||||
//#if MC>=10904
|
||||
camera.itemStackMainHand = viewPlayer.itemStackMainHand;
|
||||
camera.swingingHand = viewPlayer.swingingHand;
|
||||
camera.activeItemStackUseCount = viewPlayer.activeItemStackUseCount;
|
||||
//#else
|
||||
//$$ camera.itemInUse = viewPlayer.itemInUse;
|
||||
//$$ camera.itemInUseCount = viewPlayer.itemInUseCount;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,12 @@ import de.johni0702.minecraft.gui.RenderInfo;
|
||||
import de.johni0702.minecraft.gui.element.advanced.AbstractGuiTimeline;
|
||||
import de.johni0702.minecraft.gui.function.Draggable;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.lwjgl.util.Point;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
import org.lwjgl.util.ReadablePoint;
|
||||
|
||||
import static de.johni0702.minecraft.gui.utils.Utils.clamp;
|
||||
|
||||
public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> implements Draggable {
|
||||
protected static final int TEXTURE_MARKER_X = 109;
|
||||
protected static final int TEXTURE_MARKER_Y = 20;
|
||||
@@ -58,7 +59,7 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
||||
|
||||
protected void drawMarker(GuiRenderer renderer, ReadableDimension size, Marker marker) {
|
||||
int visibleLength = (int) (getLength() * getZoom());
|
||||
int markerPos = MathHelper.clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
int markerPos = clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
double positionInVisible = markerPos - getOffset();
|
||||
double fractionOfVisible = positionInVisible / visibleLength;
|
||||
int markerX = (int) (BORDER_LEFT + fractionOfVisible * (size.getWidth() - BORDER_LEFT - BORDER_RIGHT));
|
||||
@@ -99,7 +100,7 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
||||
int visibleLength = (int) (getLength() * getZoom());
|
||||
int contentWidth = lastSize.getWidth() - BORDER_LEFT - BORDER_RIGHT;
|
||||
for (Marker marker : replayHandler.getMarkers()) {
|
||||
int markerPos = MathHelper.clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
int markerPos = clamp(marker.getTime(), getOffset(), getOffset() + visibleLength);
|
||||
double positionInVisible = markerPos - getOffset();
|
||||
double fractionOfVisible = positionInVisible / visibleLength;
|
||||
int markerX = (int) (BORDER_LEFT + fractionOfVisible * contentWidth);
|
||||
|
||||
@@ -16,7 +16,6 @@ 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.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.InputEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
@@ -25,6 +24,7 @@ import org.lwjgl.util.ReadablePoint;
|
||||
import org.lwjgl.util.WritablePoint;
|
||||
|
||||
import static com.replaymod.core.ReplayMod.TEXTURE_SIZE;
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||
|
||||
@@ -138,9 +138,9 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||
public void setVisible(boolean visible) {
|
||||
if (isVisible() != visible) {
|
||||
if (visible) {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FML_BUS.register(this);
|
||||
} else {
|
||||
MinecraftForge.EVENT_BUS.unregister(this);
|
||||
FML_BUS.unregister(this);
|
||||
}
|
||||
}
|
||||
super.setVisible(visible);
|
||||
|
||||
@@ -35,8 +35,8 @@ import net.minecraft.util.Util;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOCase;
|
||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.Dimension;
|
||||
@@ -321,7 +321,7 @@ public class GuiReplayViewer extends GuiScreen implements Typeable {
|
||||
this.file = file;
|
||||
|
||||
name.setText(ChatFormatting.UNDERLINE + Utils.fileNameToReplayName(file.getName()));
|
||||
if (Strings.isEmpty(metaData.getServerName())
|
||||
if (StringUtils.isEmpty(metaData.getServerName())
|
||||
|| !ReplayMod.instance.getSettingsRegistry().get(Setting.SHOW_SERVER_IPS)) {
|
||||
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
||||
} else {
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||
|
||||
public class GuiHandler {
|
||||
@@ -35,12 +36,13 @@ public class GuiHandler {
|
||||
}
|
||||
|
||||
public void register() {
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
FML_BUS.register(this);
|
||||
FORGE_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
if (!(event.getGui() instanceof GuiIngameMenu)) {
|
||||
if (!(getGui(event) instanceof GuiIngameMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +51,7 @@ public class GuiHandler {
|
||||
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
||||
|
||||
GuiButton achievements = null, stats = null, openToLan = null;
|
||||
List<GuiButton> buttonList = event.getButtonList();
|
||||
List<GuiButton> buttonList = getButtonList(event);
|
||||
for(GuiButton b : new ArrayList<>(buttonList)) {
|
||||
switch (b.id) {
|
||||
// Replace "Exit Server" button with "Exit Replay" button
|
||||
@@ -70,12 +72,12 @@ public class GuiHandler {
|
||||
}
|
||||
}
|
||||
if (achievements != null && stats != null) {
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, achievements.y,
|
||||
achievements.x, stats.x + stats.width);
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, y(achievements),
|
||||
x(achievements), x(stats) + stats.width);
|
||||
}
|
||||
if (openToLan != null) {
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, openToLan.y,
|
||||
openToLan.x, openToLan.x + openToLan.width);
|
||||
moveAllButtonsDirectlyBelowUpwards(buttonList, y(openToLan),
|
||||
x(openToLan), x(openToLan) + openToLan.width);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,15 +91,15 @@ public class GuiHandler {
|
||||
*/
|
||||
private void moveAllButtonsDirectlyBelowUpwards(List<GuiButton> buttons, int belowY, int xStart, int xEnd) {
|
||||
for (GuiButton button : buttons) {
|
||||
if (button.y >= belowY && button.x <= xEnd && button.x + button.width >= xStart) {
|
||||
button.y -= 24;
|
||||
if (y(button) >= belowY && x(button) <= xEnd && x(button) + button.width >= xStart) {
|
||||
y(button, y(button) - 24);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||
if (!(event.getGui() instanceof GuiMainMenu)) {
|
||||
if (!(getGui(event) instanceof GuiMainMenu)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -115,25 +117,25 @@ public class GuiHandler {
|
||||
}
|
||||
}
|
||||
|
||||
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, event.getGui().width / 2 - 100,
|
||||
event.getGui().height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||
GuiButton button = new GuiButton(BUTTON_REPLAY_VIEWER, getGui(event).width / 2 - 100,
|
||||
getGui(event).height / 4 + 10 + 3 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||
button.width = button.width / 2 - 2;
|
||||
event.getButtonList().add(button);
|
||||
getButtonList(event).add(button);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||
if(!event.getButton().enabled) return;
|
||||
if(!getButton(event).enabled) return;
|
||||
|
||||
if (event.getGui() instanceof GuiMainMenu) {
|
||||
if (event.getButton().id == BUTTON_REPLAY_VIEWER) {
|
||||
if (getGui(event) instanceof GuiMainMenu) {
|
||||
if (getButton(event).id == BUTTON_REPLAY_VIEWER) {
|
||||
new GuiReplayViewer(mod).display();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getGui() instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||
if (event.getButton().id == BUTTON_EXIT_REPLAY) {
|
||||
event.getButton().enabled = false;
|
||||
if (getGui(event) instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||
if (getButton(event).id == BUTTON_EXIT_REPLAY) {
|
||||
getButton(event).enabled = false;
|
||||
mc.displayGuiScreen(new GuiMainMenu());
|
||||
try {
|
||||
mod.getReplayHandler().endReplay();
|
||||
|
||||
@@ -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