Switch core to 1.14 (generated via ./gradlew :1.14:setCoreVersion)
This commit is contained in:
@@ -19,46 +19,46 @@ import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityOtherPlayerMP;
|
||||
import net.minecraft.client.gui.GuiDownloadTerrain;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.OtherClientPlayerEntity;
|
||||
import net.minecraft.client.gui.menu.DownloadingTerrainScreen;
|
||||
import net.minecraft.client.gui.menu.NoticeScreen;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.NetworkState;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.network.login.server.SPacketLoginSuccess;
|
||||
import net.minecraft.network.play.server.*;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import net.minecraft.client.network.packet.LoginSuccessS2CPacket;
|
||||
import net.minecraft.client.network.packet.*;
|
||||
import net.minecraft.text.TextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.chunk.ChunkProvider;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
//$$ import net.minecraft.entity.EntityType;
|
||||
//$$ import net.minecraft.text.TranslatableTextComponent;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
//#else
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.EnumDifficulty;
|
||||
import net.minecraft.world.WorldType;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
//$$ import net.minecraft.client.resources.I18n;
|
||||
//$$ import net.minecraft.entity.Entity;
|
||||
//$$ import net.minecraft.util.math.MathHelper;
|
||||
//$$ import net.minecraft.world.EnumDifficulty;
|
||||
//$$ import net.minecraft.world.WorldType;
|
||||
//$$ import net.minecraft.world.chunk.Chunk;
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//$$ import java.util.ArrayList;
|
||||
//$$ import java.util.Collection;
|
||||
//$$ import java.util.Iterator;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Identifier;
|
||||
//#if MC<11400
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
//$$ import net.minecraft.world.dimension.DimensionType;
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
@@ -66,13 +66,13 @@ import net.minecraft.world.dimension.DimensionType;
|
||||
import com.replaymod.core.utils.WrappedTimer;
|
||||
//#endif
|
||||
//#if MC>=11002
|
||||
import net.minecraft.world.GameType;
|
||||
import net.minecraft.world.GameMode;
|
||||
//#else
|
||||
//$$ import net.minecraft.world.WorldSettings.GameType;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
//#else
|
||||
//$$ import org.apache.commons.io.Charsets;
|
||||
//#endif
|
||||
@@ -96,26 +96,26 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
*/
|
||||
private static final List<Class> BAD_PACKETS = Arrays.<Class>asList(
|
||||
//#if MC>=11400
|
||||
//$$ OpenWrittenBookS2CPacket.class,
|
||||
OpenWrittenBookS2CPacket.class,
|
||||
//#endif
|
||||
//#if MC>=11200
|
||||
SPacketRecipeBook.class,
|
||||
SPacketAdvancementInfo.class,
|
||||
SPacketSelectAdvancementsTab.class,
|
||||
SynchronizeRecipesS2CPacket.class,
|
||||
AdvancementUpdateS2CPacket.class,
|
||||
SelectAdvancementTabS2CPacket.class,
|
||||
//#endif
|
||||
//#if MC>=10904
|
||||
// TODO Update possibly more?
|
||||
SPacketUpdateHealth.class,
|
||||
SPacketOpenWindow.class,
|
||||
SPacketCloseWindow.class,
|
||||
SPacketSetSlot.class,
|
||||
SPacketWindowItems.class,
|
||||
SPacketSignEditorOpen.class,
|
||||
SPacketStatistics.class,
|
||||
SPacketSetExperience.class,
|
||||
SPacketCamera.class,
|
||||
SPacketPlayerAbilities.class,
|
||||
SPacketTitle.class
|
||||
HealthUpdateS2CPacket.class,
|
||||
GuiOpenS2CPacket.class,
|
||||
GuiCloseS2CPacket.class,
|
||||
GuiSlotUpdateS2CPacket.class,
|
||||
GuiUpdateS2CPacket.class,
|
||||
SignEditorOpenS2CPacket.class,
|
||||
StatisticsS2CPacket.class,
|
||||
ExperienceBarUpdateS2CPacket.class,
|
||||
SetCameraEntityS2CPacket.class,
|
||||
PlayerAbilitiesS2CPacket.class,
|
||||
TitleS2CPacket.class
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//$$ S43PacketCamera.class,
|
||||
@@ -211,7 +211,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
/**
|
||||
* The minecraft instance.
|
||||
*/
|
||||
protected Minecraft mc = getMinecraft();
|
||||
protected MinecraftClient mc = getMinecraft();
|
||||
|
||||
/**
|
||||
* The total length of this replay in milliseconds.
|
||||
@@ -325,13 +325,13 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
class EventHandler extends EventRegistrations {
|
||||
//#if MC>=11400
|
||||
//$$ { on(PreTickCallback.EVENT, this::onWorldTick); }
|
||||
//$$ private void onWorldTick() {
|
||||
{ on(PreTickCallback.EVENT, this::onWorldTick); }
|
||||
private void onWorldTick() {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.ClientTickEvent event) {
|
||||
// Unfortunately the WorldTickEvent doesn't seem to be emitted on the CLIENT side
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onWorldTick(TickEvent.ClientTickEvent event) {
|
||||
//$$ // Unfortunately the WorldTickEvent doesn't seem to be emitted on the CLIENT side
|
||||
//$$ if (event.phase != TickEvent.Phase.START) return;
|
||||
//#endif
|
||||
|
||||
// Spawning a player into an empty chunk (which we might do with the recording player)
|
||||
@@ -340,10 +340,10 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
// 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 : playerEntities(mc.world)) {
|
||||
if (!playerEntity.addedToChunk && playerEntity instanceof EntityOtherPlayerMP) {
|
||||
for (PlayerEntity playerEntity : playerEntities(mc.world)) {
|
||||
if (!playerEntity.field_6016 && playerEntity instanceof OtherClientPlayerEntity) {
|
||||
//#if MC>=11300
|
||||
playerEntity.livingTick();
|
||||
playerEntity.updateState();
|
||||
//#else
|
||||
//$$ playerEntity.onLivingUpdate();
|
||||
//#endif
|
||||
@@ -380,27 +380,27 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
// 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 (p instanceof SPacketSpawnPlayer
|
||||
|| p instanceof SPacketSpawnObject
|
||||
|| p instanceof SPacketSpawnMob
|
||||
|| p instanceof SPacketSpawnGlobalEntity
|
||||
|| p instanceof SPacketSpawnPainting
|
||||
|| p instanceof SPacketSpawnExperienceOrb
|
||||
|| p instanceof SPacketDestroyEntities) {
|
||||
WorldClient world = mc.world;
|
||||
if (p instanceof PlayerSpawnS2CPacket
|
||||
|| p instanceof EntitySpawnS2CPacket
|
||||
|| p instanceof MobSpawnS2CPacket
|
||||
|| p instanceof EntitySpawnGlobalS2CPacket
|
||||
|| p instanceof PaintingSpawnS2CPacket
|
||||
|| p instanceof ExperienceOrbSpawnS2CPacket
|
||||
|| p instanceof EntitiesDestroyS2CPacket) {
|
||||
ClientWorld world = mc.world;
|
||||
//#if MC>=11400
|
||||
//$$ // Note: Not sure if it's still required but there's this really handy method anyway
|
||||
//$$ world.finishRemovingEntities();
|
||||
// Note: Not sure if it's still required but there's this really handy method anyway
|
||||
world.finishRemovingEntities();
|
||||
//#else
|
||||
Iterator<Entity> iter = loadedEntityList(world).iterator();
|
||||
while (iter.hasNext()) {
|
||||
Entity entity = iter.next();
|
||||
if (entity.removed) {
|
||||
int chunkX = entity.chunkCoordX;
|
||||
int chunkY = entity.chunkCoordZ;
|
||||
|
||||
//$$ Iterator<Entity> iter = loadedEntityList(world).iterator();
|
||||
//$$ while (iter.hasNext()) {
|
||||
//$$ Entity entity = iter.next();
|
||||
//$$ if (entity.removed) {
|
||||
//$$ int chunkX = entity.chunkCoordX;
|
||||
//$$ int chunkY = entity.chunkCoordZ;
|
||||
//$$
|
||||
//#if MC>=11300
|
||||
if (entity.addedToChunk && world.getChunkProvider().provideChunk(chunkX, chunkY, false, false) != null) {
|
||||
//$$ if (entity.addedToChunk && world.getChunkProvider().provideChunk(chunkX, chunkY, false, false) != null) {
|
||||
//#else
|
||||
//#if MC>=10904
|
||||
//$$ if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
||||
@@ -408,14 +408,14 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
//$$ if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
||||
//#endif
|
||||
//#endif
|
||||
world.getChunk(chunkX, chunkY).removeEntity(entity);
|
||||
}
|
||||
|
||||
iter.remove();
|
||||
world.onEntityRemoved(entity);
|
||||
}
|
||||
|
||||
}
|
||||
//$$ world.getChunk(chunkX, chunkY).removeEntity(entity);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ iter.remove();
|
||||
//$$ world.onEntityRemoved(entity);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
@@ -430,17 +430,17 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
private Packet deserializePacket(byte[] bytes) throws IOException, IllegalAccessException, InstantiationException {
|
||||
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
|
||||
PacketBuffer pb = new PacketBuffer(bb);
|
||||
PacketByteBuf pb = new PacketByteBuf(bb);
|
||||
|
||||
int i = pb.readVarInt();
|
||||
|
||||
EnumConnectionState state = loginPhase ? EnumConnectionState.LOGIN : EnumConnectionState.PLAY;
|
||||
NetworkState state = loginPhase ? NetworkState.LOGIN : NetworkState.PLAY;
|
||||
//#if MC>=10800
|
||||
Packet p = state.getPacket(EnumPacketDirection.CLIENTBOUND, i);
|
||||
Packet p = state.getPacketHandler(NetworkSide.CLIENT, i);
|
||||
//#else
|
||||
//$$ Packet p = Packet.generatePacket(state.func_150755_b(), i);
|
||||
//#endif
|
||||
p.readPacketData(pb);
|
||||
p.read(pb);
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -451,14 +451,14 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
* @return The processed packet or {@code null} if no packet shall be sent
|
||||
*/
|
||||
protected Packet processPacket(Packet p) throws Exception {
|
||||
if (p instanceof SPacketLoginSuccess) {
|
||||
if (p instanceof LoginSuccessS2CPacket) {
|
||||
loginPhase = false;
|
||||
return p;
|
||||
}
|
||||
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannelName())) {
|
||||
if (p instanceof CustomPayloadS2CPacket) {
|
||||
CustomPayloadS2CPacket packet = (CustomPayloadS2CPacket) p;
|
||||
if (Restrictions.PLUGIN_CHANNEL.equals(packet.getChannel())) {
|
||||
final String unknown = replayHandler.getRestrictions().handle(packet);
|
||||
if (unknown == null) {
|
||||
return null;
|
||||
@@ -472,22 +472,22 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
mc.displayGuiScreen(new GuiErrorScreen(
|
||||
mc.openScreen(new NoticeScreen(
|
||||
//#if MC>=11400
|
||||
//$$ () -> {},
|
||||
//$$ new TranslatableTextComponent("replaymod.error.unknownrestriction1"),
|
||||
//$$ new TranslatableTextComponent("replaymod.error.unknownrestriction2", unknown)
|
||||
() -> {},
|
||||
new TranslatableTextComponent("replaymod.error.unknownrestriction1"),
|
||||
new TranslatableTextComponent("replaymod.error.unknownrestriction2", unknown)
|
||||
//#else
|
||||
I18n.format("replaymod.error.unknownrestriction1"),
|
||||
I18n.format("replaymod.error.unknownrestriction2", unknown)
|
||||
//$$ I18n.format("replaymod.error.unknownrestriction1"),
|
||||
//$$ I18n.format("replaymod.error.unknownrestriction2", unknown)
|
||||
//#endif
|
||||
));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p instanceof SPacketDisconnect) {
|
||||
ITextComponent reason = ((SPacketDisconnect) p).getReason();
|
||||
if (p instanceof DisconnectS2CPacket) {
|
||||
TextComponent reason = ((DisconnectS2CPacket) p).getReason();
|
||||
String message = reason.getString();
|
||||
if ("Please update to view this replay.".equals(message)) {
|
||||
// This version of the mod supports replay restrictions so we are allowed
|
||||
@@ -498,28 +498,28 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
if(BAD_PACKETS.contains(p.getClass())) return null;
|
||||
|
||||
if (p instanceof SPacketCustomPayload) {
|
||||
SPacketCustomPayload packet = (SPacketCustomPayload) p;
|
||||
if (p instanceof CustomPayloadS2CPacket) {
|
||||
CustomPayloadS2CPacket packet = (CustomPayloadS2CPacket) p;
|
||||
//#if MC>=11300
|
||||
ResourceLocation channelName = packet.getChannelName();
|
||||
Identifier channelName = packet.getChannel();
|
||||
//#else
|
||||
//$$ String channelName = packet.getChannelName();
|
||||
//#endif
|
||||
// On 1.14+ there's a dedicated OpenWrittenBookS2CPacket now
|
||||
//#if MC<11400
|
||||
//#if MC>=11300
|
||||
if (SPacketCustomPayload.BOOK_OPEN.equals(channelName)) {
|
||||
//$$ if (SPacketCustomPayload.BOOK_OPEN.equals(channelName)) {
|
||||
//#else
|
||||
//$$ if ("MC|BOpen".equals(channelName)) {
|
||||
//#endif
|
||||
return null;
|
||||
}
|
||||
//$$ return null;
|
||||
//$$ }
|
||||
//#endif
|
||||
//#if MC>=10800
|
||||
}
|
||||
|
||||
if(p instanceof SPacketResourcePackSend) {
|
||||
SPacketResourcePackSend packet = (SPacketResourcePackSend) p;
|
||||
if(p instanceof ResourcePackSendS2CPacket) {
|
||||
ResourcePackSendS2CPacket packet = (ResourcePackSendS2CPacket) p;
|
||||
String url = packet.getURL();
|
||||
if (url.startsWith("replay://")) {
|
||||
//#else
|
||||
@@ -543,41 +543,41 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
}
|
||||
}
|
||||
|
||||
if(p instanceof SPacketJoinGame) {
|
||||
SPacketJoinGame packet = (SPacketJoinGame) p;
|
||||
int entId = packet.getPlayerId();
|
||||
if(p instanceof GameJoinS2CPacket) {
|
||||
GameJoinS2CPacket packet = (GameJoinS2CPacket) p;
|
||||
int entId = packet.getEntityId();
|
||||
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>=11400
|
||||
//$$ p = new GameJoinS2CPacket(
|
||||
//$$ entId,
|
||||
//$$ GameMode.SPECTATOR,
|
||||
//$$ false,
|
||||
//$$ packet.getDimension(),
|
||||
//$$ 0, // max players (has no getter -> never actually used)
|
||||
//$$ packet.getGeneratorType(),
|
||||
//$$ packet.getChunkLoadDistance(),
|
||||
//$$ packet.hasReducedDebugInfo()
|
||||
//$$ );
|
||||
p = new GameJoinS2CPacket(
|
||||
entId,
|
||||
GameMode.SPECTATOR,
|
||||
false,
|
||||
packet.getDimension(),
|
||||
0, // max players (has no getter -> never actually used)
|
||||
packet.getGeneratorType(),
|
||||
packet.getChunkLoadDistance(),
|
||||
packet.hasReducedDebugInfo()
|
||||
);
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
DimensionType dimension = packet.func_212642_e();
|
||||
//$$ DimensionType dimension = packet.func_212642_e();
|
||||
//#else
|
||||
//$$ int dimension = packet.getDimension();
|
||||
//#endif
|
||||
EnumDifficulty difficulty = packet.getDifficulty();
|
||||
//$$ EnumDifficulty difficulty = packet.getDifficulty();
|
||||
//#if MC>=11300
|
||||
int maxPlayers = 0; // literally never used by vanilla (i.e. no accessor)
|
||||
//$$ int maxPlayers = 0; // literally never used by vanilla (i.e. no accessor)
|
||||
//#else
|
||||
//$$ int maxPlayers = packet.getMaxPlayers();
|
||||
//#endif
|
||||
WorldType worldType = packet.getWorldType();
|
||||
|
||||
//$$ WorldType worldType = packet.getWorldType();
|
||||
//$$
|
||||
//#if MC>=10904
|
||||
p = new SPacketJoinGame(entId, GameType.SPECTATOR, false, dimension,
|
||||
difficulty, maxPlayers, worldType, false);
|
||||
//$$ 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);
|
||||
@@ -594,14 +594,14 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
//#endif
|
||||
}
|
||||
|
||||
if(p instanceof SPacketRespawn) {
|
||||
SPacketRespawn respawn = (SPacketRespawn) p;
|
||||
if(p instanceof PlayerRespawnS2CPacket) {
|
||||
PlayerRespawnS2CPacket respawn = (PlayerRespawnS2CPacket) p;
|
||||
//#if MC>=11400
|
||||
//$$ p = new PlayerRespawnS2CPacket(respawn.getDimension(), respawn.getGeneratorType(), GameMode.SPECTATOR);
|
||||
p = new PlayerRespawnS2CPacket(respawn.getDimension(), respawn.getGeneratorType(), GameMode.SPECTATOR);
|
||||
//#else
|
||||
//#if MC>=10809
|
||||
p = new SPacketRespawn(respawn.func_212643_b(),
|
||||
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||
//$$ p = new SPacketRespawn(respawn.func_212643_b(),
|
||||
//$$ respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||
//#else
|
||||
//$$ p = new S07PacketRespawn(respawn.func_149082_c(),
|
||||
//$$ respawn.func_149081_d(), respawn.func_149080_f(),
|
||||
@@ -616,13 +616,13 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
allowMovement = true;
|
||||
}
|
||||
|
||||
if(p instanceof SPacketPlayerPosLook) {
|
||||
final SPacketPlayerPosLook ppl = (SPacketPlayerPosLook) p;
|
||||
if(p instanceof PlayerPositionLookS2CPacket) {
|
||||
final PlayerPositionLookS2CPacket ppl = (PlayerPositionLookS2CPacket) p;
|
||||
if(!hasWorldLoaded) hasWorldLoaded = true;
|
||||
|
||||
if (mc.currentScreen instanceof GuiDownloadTerrain) {
|
||||
if (mc.currentScreen instanceof DownloadingTerrainScreen) {
|
||||
// Close the world loading screen manually in case we swallow the packet
|
||||
mc.displayGuiScreen(null);
|
||||
mc.openScreen(null);
|
||||
}
|
||||
|
||||
if(replayHandler.shouldSuppressCameraMovements()) return null;
|
||||
@@ -631,13 +631,13 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=10904
|
||||
for (SPacketPlayerPosLook.EnumFlags relative : ppl.getFlags()) {
|
||||
for (PlayerPositionLookS2CPacket.Flag relative : ppl.getFlags()) {
|
||||
//#else
|
||||
//$$ for (Object relative : ppl.func_179834_f()) {
|
||||
//#endif
|
||||
if (relative == SPacketPlayerPosLook.EnumFlags.X
|
||||
|| relative == SPacketPlayerPosLook.EnumFlags.Y
|
||||
|| relative == SPacketPlayerPosLook.EnumFlags.Z) {
|
||||
if (relative == PlayerPositionLookS2CPacket.Flag.X
|
||||
|| relative == PlayerPositionLookS2CPacket.Flag.Y
|
||||
|| relative == PlayerPositionLookS2CPacket.Flag.Z) {
|
||||
return null; // At least one of the coordinates is relative, so we don't care
|
||||
}
|
||||
}
|
||||
@@ -645,8 +645,8 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
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))) {
|
||||
if(!allowMovement && !((Math.abs(cent.x - ppl.getX()) > TP_DISTANCE_LIMIT) ||
|
||||
(Math.abs(cent.z - 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))) {
|
||||
@@ -676,9 +676,9 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
}.run();
|
||||
}
|
||||
|
||||
if(p instanceof SPacketChangeGameState) {
|
||||
SPacketChangeGameState pg = (SPacketChangeGameState)p;
|
||||
int reason = pg.getGameState();
|
||||
if(p instanceof GameStateChangeS2CPacket) {
|
||||
GameStateChangeS2CPacket pg = (GameStateChangeS2CPacket)p;
|
||||
int reason = pg.getReason();
|
||||
|
||||
// only allow the following packets:
|
||||
// 1 - End raining
|
||||
@@ -692,7 +692,7 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
}
|
||||
}
|
||||
|
||||
if (p instanceof SPacketChat) {
|
||||
if (p instanceof ChatMessageS2CPacket) {
|
||||
if (!ReplayModReplay.instance.getCore().getSettingsRegistry().get(Setting.SHOW_CHAT)) {
|
||||
return null;
|
||||
}
|
||||
@@ -923,17 +923,17 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
protected Packet processPacketAsync(Packet p) {
|
||||
//If hurrying, ignore some packets, except for short durations
|
||||
if(desiredTimeStamp - lastTimeStamp > 1000) {
|
||||
if(p instanceof SPacketParticles) return null;
|
||||
if(p instanceof ParticleS2CPacket) return null;
|
||||
|
||||
if(p instanceof SPacketSpawnObject) {
|
||||
SPacketSpawnObject pso = (SPacketSpawnObject)p;
|
||||
if(p instanceof EntitySpawnS2CPacket) {
|
||||
EntitySpawnS2CPacket pso = (EntitySpawnS2CPacket)p;
|
||||
//#if MC>=11400
|
||||
//$$ if (pso.getEntityTypeId() == EntityType.FIREWORK_ROCKET) return null;
|
||||
if (pso.getEntityTypeId() == EntityType.FIREWORK_ROCKET) return null;
|
||||
//#else
|
||||
int type = pso.getType();
|
||||
if(type == 76) { // Firework rocket
|
||||
return null;
|
||||
}
|
||||
//$$ int type = pso.getType();
|
||||
//$$ if(type == 76) { // Firework rocket
|
||||
//$$ return null;
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
@@ -1020,8 +1020,8 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
|
||||
protected Packet processPacketSync(Packet p) {
|
||||
//#if MC>=10904
|
||||
if (p instanceof SPacketUnloadChunk) {
|
||||
SPacketUnloadChunk packet = (SPacketUnloadChunk) p;
|
||||
if (p instanceof UnloadChunkS2CPacket) {
|
||||
UnloadChunkS2CPacket packet = (UnloadChunkS2CPacket) p;
|
||||
int x = packet.getX();
|
||||
int z = packet.getZ();
|
||||
//#else
|
||||
@@ -1045,43 +1045,43 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
// 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;
|
||||
IChunkProvider chunkProvider = world.getChunkProvider();
|
||||
ChunkProvider chunkProvider = world.getChunkManager();
|
||||
// Get the chunk that will be unloaded
|
||||
//#if MC>=11400
|
||||
//$$ // FIXME fabric
|
||||
// FIXME fabric
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
Chunk chunk = chunkProvider.provideChunk(x, z, false, false);
|
||||
//$$ Chunk chunk = chunkProvider.provideChunk(x, z, false, false);
|
||||
//#else
|
||||
//$$ Chunk chunk = chunkProvider.provideChunk(x, z);
|
||||
//#endif
|
||||
if (!chunk.isEmpty()) {
|
||||
List<Entity> entitiesInChunk = new ArrayList<>();
|
||||
// Gather all entities in that chunk
|
||||
for (Collection<Entity> entityList : getEntityLists(chunk)) {
|
||||
entitiesInChunk.addAll(entityList);
|
||||
}
|
||||
for (Entity entity : entitiesInChunk) {
|
||||
// Skip interpolation of position updates coming from server
|
||||
// (See: newX in EntityLivingBase or otherPlayerMPX in EntityOtherPlayerMP)
|
||||
// Needs to be called at least 4 times thanks to
|
||||
// EntityOtherPlayerMP#otherPlayerMPPosRotationIncrements (max vanilla value is 3)
|
||||
for (int i = 0; i < 4; i++) {
|
||||
//$$ if (!chunk.isEmpty()) {
|
||||
//$$ List<Entity> entitiesInChunk = new ArrayList<>();
|
||||
//$$ // Gather all entities in that chunk
|
||||
//$$ for (Collection<Entity> entityList : getEntityLists(chunk)) {
|
||||
//$$ entitiesInChunk.addAll(entityList);
|
||||
//$$ }
|
||||
//$$ for (Entity entity : entitiesInChunk) {
|
||||
//$$ // Skip interpolation of position updates coming from server
|
||||
//$$ // (See: newX in EntityLivingBase or otherPlayerMPX in EntityOtherPlayerMP)
|
||||
//$$ // Needs to be called at least 4 times thanks to
|
||||
//$$ // EntityOtherPlayerMP#otherPlayerMPPosRotationIncrements (max vanilla value is 3)
|
||||
//$$ for (int i = 0; i < 4; i++) {
|
||||
//#if MC>=11300
|
||||
entity.tick();
|
||||
//$$ entity.tick();
|
||||
//#else
|
||||
//$$ entity.onUpdate();
|
||||
//#endif
|
||||
}
|
||||
|
||||
// Check whether the entity has left the chunk
|
||||
int chunkX = MathHelper.floor(entity.posX / 16);
|
||||
int chunkZ = MathHelper.floor(entity.posZ / 16);
|
||||
if (entity.chunkCoordX != chunkX || entity.chunkCoordZ != chunkZ) {
|
||||
// Entity has left the chunk
|
||||
chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ // Check whether the entity has left the chunk
|
||||
//$$ int chunkX = MathHelper.floor(entity.posX / 16);
|
||||
//$$ int chunkZ = MathHelper.floor(entity.posZ / 16);
|
||||
//$$ if (entity.chunkCoordX != chunkX || entity.chunkCoordZ != chunkZ) {
|
||||
//$$ // Entity has left the chunk
|
||||
//$$ chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
||||
//#if MC>=11300
|
||||
Chunk newChunk = chunkProvider.provideChunk(chunkX, chunkZ, false, false);
|
||||
//$$ Chunk newChunk = chunkProvider.provideChunk(chunkX, chunkZ, false, false);
|
||||
//#else
|
||||
//#if MC>=10904
|
||||
//$$ Chunk newChunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
||||
@@ -1090,34 +1090,34 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
||||
//$$ ? chunkProvider.provideChunk(chunkX, chunkZ) : null;
|
||||
//#endif
|
||||
//#endif
|
||||
if (newChunk != null) {
|
||||
newChunk.addEntity(entity);
|
||||
} else {
|
||||
// Entity has left all loaded chunks
|
||||
entity.addedToChunk = false;
|
||||
}
|
||||
} else {
|
||||
// When entities remain in a chunk that's to be unloaded, they'll only be added to a unload
|
||||
// queue and remain loaded as before until the next tick (which during jumping is way off).
|
||||
// So, if they are re-spawned with the same entity id, MC actually cleans up the old entity and
|
||||
// then adds the new one but leaves the unload queue as is.
|
||||
// Finally, on the next tick the legitimate entity will be unloaded because it's part of the
|
||||
// unload queue (entities .equals based purely on their id). However, the old entity object
|
||||
// is used to determine the chunk the entity is removed from and in this case that'll allow the
|
||||
// legitimate entity to remain registered in a loaded chunk, causing them to still be rendered.
|
||||
//
|
||||
// The usual removal-due-to-chunk-unload process will, without touching the entityList, call
|
||||
// onEntityRemoved. In that method WorldClient checks to see whether the entity is still in the
|
||||
// entityList (which it is) and then adds it to the entitySpawnQueue.
|
||||
// As the final result the entity will remain loaded.
|
||||
// To get the same result without ticking, we just remove the entity from the to-be-unloaded
|
||||
// chunk but keep it loaded otherwise. They won't be rendered because they're not part of any
|
||||
// chunk and will be removed properly if the server decides to re-spawn the entity.
|
||||
chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
||||
entity.addedToChunk = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
//$$ if (newChunk != null) {
|
||||
//$$ newChunk.addEntity(entity);
|
||||
//$$ } else {
|
||||
//$$ // Entity has left all loaded chunks
|
||||
//$$ entity.addedToChunk = false;
|
||||
//$$ }
|
||||
//$$ } else {
|
||||
//$$ // When entities remain in a chunk that's to be unloaded, they'll only be added to a unload
|
||||
//$$ // queue and remain loaded as before until the next tick (which during jumping is way off).
|
||||
//$$ // So, if they are re-spawned with the same entity id, MC actually cleans up the old entity and
|
||||
//$$ // then adds the new one but leaves the unload queue as is.
|
||||
//$$ // Finally, on the next tick the legitimate entity will be unloaded because it's part of the
|
||||
//$$ // unload queue (entities .equals based purely on their id). However, the old entity object
|
||||
//$$ // is used to determine the chunk the entity is removed from and in this case that'll allow the
|
||||
//$$ // legitimate entity to remain registered in a loaded chunk, causing them to still be rendered.
|
||||
//$$ //
|
||||
//$$ // The usual removal-due-to-chunk-unload process will, without touching the entityList, call
|
||||
//$$ // onEntityRemoved. In that method WorldClient checks to see whether the entity is still in the
|
||||
//$$ // entityList (which it is) and then adds it to the entitySpawnQueue.
|
||||
//$$ // As the final result the entity will remain loaded.
|
||||
//$$ // To get the same result without ticking, we just remove the entity from the to-be-unloaded
|
||||
//$$ // chunk but keep it loaded otherwise. They won't be rendered because they're not part of any
|
||||
//$$ // chunk and will be removed properly if the server decides to re-spawn the entity.
|
||||
//$$ chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
||||
//$$ entity.addedToChunk = false;
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
return p; // During synchronous playback everything is sent normally
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.replaymod.core.utils.WrappedTimer;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.replay.camera.CameraController;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.Timer;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
|
||||
//#if MC>=11300
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
@@ -32,9 +32,9 @@ import org.lwjgl.glfw.GLFW;
|
||||
|
||||
public class InputReplayTimer extends WrappedTimer {
|
||||
private final ReplayModReplay mod;
|
||||
private final Minecraft mc;
|
||||
private final MinecraftClient mc;
|
||||
|
||||
public InputReplayTimer(Timer wrapped, ReplayModReplay mod) {
|
||||
public InputReplayTimer(RenderTickCounter wrapped, ReplayModReplay mod) {
|
||||
super(wrapped);
|
||||
this.mod = mod;
|
||||
this.mc = mod.getCore().getMinecraft();
|
||||
@@ -43,12 +43,12 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
@Override
|
||||
//#if MC>=11300
|
||||
//#if MC>=11400
|
||||
//$$ // FIXME this should be handled by the preprocessor but there seems to be a bug
|
||||
//$$ public void beginRenderTick(long sysClock) {
|
||||
// FIXME this should be handled by the preprocessor but there seems to be a bug
|
||||
public void beginRenderTick(long sysClock) {
|
||||
//#else
|
||||
public void updateTimer(long sysClock) {
|
||||
//$$ public void updateTimer(long sysClock) {
|
||||
//#endif
|
||||
super.updateTimer(sysClock);
|
||||
super.beginRenderTick(sysClock);
|
||||
//#else
|
||||
//$$ public void updateTimer() {
|
||||
//$$ super.updateTimer();
|
||||
@@ -63,11 +63,11 @@ public class InputReplayTimer extends WrappedTimer {
|
||||
// tick speed may vary or there may not be any ticks at all (when the replay is paused)
|
||||
if (mod.getReplayHandler() != null) {
|
||||
//#if MC>=11300
|
||||
if (mc.currentScreen == null || mc.currentScreen.allowUserInput) {
|
||||
if (mc.currentScreen == null || mc.currentScreen.passEvents) {
|
||||
GLFW.glfwPollEvents();
|
||||
MCVer.processKeyBinds();
|
||||
}
|
||||
mc.keyboardListener.tick();
|
||||
mc.keyboard.pollDebugCrash();
|
||||
//#else
|
||||
//#if MC>=10904
|
||||
//$$ if (mc.currentScreen == null || mc.currentScreen.allowUserInput) {
|
||||
|
||||
@@ -8,9 +8,9 @@ import com.replaymod.core.versions.MCVer;
|
||||
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 net.minecraft.client.MinecraftClient;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import net.minecraft.client.util.ScreenshotUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@@ -25,7 +25,7 @@ public class NoGuiScreenshot {
|
||||
private final int width;
|
||||
private final int height;
|
||||
|
||||
public static ListenableFuture<NoGuiScreenshot> take(final Minecraft mc, final int width, final int height) {
|
||||
public static ListenableFuture<NoGuiScreenshot> take(final MinecraftClient mc, final int width, final int height) {
|
||||
final SettableFuture<NoGuiScreenshot> future = SettableFuture.create();
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
@@ -35,28 +35,28 @@ public class NoGuiScreenshot {
|
||||
}
|
||||
|
||||
//#if MC>=11300
|
||||
int frameWidth = mc.mainWindow.getFramebufferWidth(), frameHeight = mc.mainWindow.getFramebufferHeight();
|
||||
int frameWidth = mc.window.getFramebufferWidth(), frameHeight = mc.window.getFramebufferHeight();
|
||||
//#else
|
||||
//$$ int frameWidth = mc.displayWidth, frameHeight = mc.displayHeight;
|
||||
//#endif
|
||||
|
||||
final boolean guiHidden = mc.gameSettings.hideGUI;
|
||||
final boolean guiHidden = mc.options.hudHidden;
|
||||
try {
|
||||
mc.gameSettings.hideGUI = true;
|
||||
mc.options.hudHidden = true;
|
||||
|
||||
// Render frame without GUI
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.clear(
|
||||
16640
|
||||
//#if MC>=11400
|
||||
//$$ , true
|
||||
, true
|
||||
//#endif
|
||||
);
|
||||
mc.getFramebuffer().bindFramebuffer(true);
|
||||
GlStateManager.enableTexture2D();
|
||||
mc.getFramebuffer().beginWrite(true);
|
||||
GlStateManager.enableTexture();
|
||||
|
||||
//#if MC>=11300
|
||||
mc.entityRenderer.renderWorld(MCVer.getRenderPartialTicks(), System.nanoTime());
|
||||
mc.gameRenderer.renderWorld(MCVer.getRenderPartialTicks(), System.nanoTime());
|
||||
//#else
|
||||
//#if MC>=10809
|
||||
//$$ mc.entityRenderer.updateCameraAndRender(MCVer.getRenderPartialTicks(), System.nanoTime());
|
||||
@@ -65,17 +65,17 @@ public class NoGuiScreenshot {
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
mc.getFramebuffer().unbindFramebuffer();
|
||||
mc.getFramebuffer().endWrite();
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.pushMatrix();
|
||||
mc.getFramebuffer().framebufferRender(frameWidth, frameHeight);
|
||||
mc.getFramebuffer().draw(frameWidth, frameHeight);
|
||||
GlStateManager.popMatrix();
|
||||
} catch (Throwable t) {
|
||||
future.setException(t);
|
||||
return;
|
||||
} finally {
|
||||
// Reset GUI settings
|
||||
mc.gameSettings.hideGUI = guiHidden;
|
||||
mc.options.hudHidden = guiHidden;
|
||||
}
|
||||
|
||||
// The frame without GUI has been rendered
|
||||
@@ -85,8 +85,8 @@ public class NoGuiScreenshot {
|
||||
File tmpFolder = Files.createTempDir();
|
||||
try {
|
||||
//#if MC>=11300
|
||||
ScreenShotHelper.saveScreenshot(tmpFolder, "tmp", frameWidth, frameHeight, mc.getFramebuffer(), (msg) ->
|
||||
ReplayMod.instance.runLater(() -> mc.ingameGUI.getChatGUI().printChatMessage(msg)));
|
||||
ScreenshotUtils.method_1662(tmpFolder, "tmp", frameWidth, frameHeight, mc.getFramebuffer(), (msg) ->
|
||||
ReplayMod.instance.runLater(() -> mc.inGameHud.getChatHud().addMessage(msg)));
|
||||
//#else
|
||||
//$$ ScreenShotHelper.saveScreenshot(tmpFolder, "tmp", frameWidth, frameHeight, mc.getFramebuffer());
|
||||
//#endif
|
||||
|
||||
@@ -58,20 +58,20 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerAdapter;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.EnumConnectionState;
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.network.NetworkState;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
import net.minecraft.network.Packet;
|
||||
import net.minecraft.network.PacketBuffer;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
//#else
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.FML_BUS;
|
||||
//$$ import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//$$
|
||||
//$$ import static com.replaymod.core.versions.MCVer.FML_BUS;
|
||||
//#endif
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -113,7 +113,7 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
private static final String CACHE_INDEX_ENTRY = "quickModeCacheIndex.bin";
|
||||
private static final int CACHE_VERSION = 0;
|
||||
|
||||
private final Minecraft mc = getMinecraft();
|
||||
private final MinecraftClient mc = getMinecraft();
|
||||
|
||||
private final ReplayModReplay mod;
|
||||
private final ReplayFile replayFile;
|
||||
@@ -216,7 +216,7 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
ctx.fireChannelRead(toMC(new ServerRespawnPacket(
|
||||
0,
|
||||
//#if MC<11400
|
||||
Difficulty.NORMAL,
|
||||
//$$ Difficulty.NORMAL,
|
||||
//#endif
|
||||
GameMode.SPECTATOR,
|
||||
WorldType.DEFAULT
|
||||
@@ -279,12 +279,12 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
|
||||
private class EventHandler extends EventRegistrations {
|
||||
//#if MC>=11400
|
||||
//$$ { on(PreTickCallback.EVENT, this::onTick); }
|
||||
//$$ private void onTick() {
|
||||
{ on(PreTickCallback.EVENT, this::onTick); }
|
||||
private void onTick() {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onTick(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onTick(TickEvent.ClientTickEvent event) {
|
||||
//$$ if (event.phase != TickEvent.Phase.START) return;
|
||||
//#endif
|
||||
if (!asyncMode) return;
|
||||
|
||||
@@ -653,16 +653,16 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
|
||||
private static final ByteBuf byteBuf = Unpooled.buffer();
|
||||
private static final ByteBufOutputStream byteBufOut = new ByteBufOutputStream(byteBuf);
|
||||
private static final PacketBuffer packetBuf = new PacketBuffer(byteBuf);
|
||||
private static final PacketByteBuf packetBuf = new PacketByteBuf(byteBuf);
|
||||
private static final ReplayOutputStream encoder = new ReplayOutputStream(new ReplayStudio(), byteBufOut);
|
||||
private static final Inflater inflater = new Inflater();
|
||||
private static final Deflater deflater = new Deflater();
|
||||
|
||||
private static Packet<?> toMC(com.github.steveice10.packetlib.packet.Packet packet) {
|
||||
return toMC(packet, EnumConnectionState.PLAY);
|
||||
return toMC(packet, NetworkState.PLAY);
|
||||
}
|
||||
|
||||
private static Packet<?> toMC(com.github.steveice10.packetlib.packet.Packet packet, EnumConnectionState state) {
|
||||
private static Packet<?> toMC(com.github.steveice10.packetlib.packet.Packet packet, NetworkState state) {
|
||||
// We need to re-encode MCProtocolLib packets, so we can then decode them as NMS packets
|
||||
// The main reason we aren't reading them as NMS packets is that we want ReplayStudio to be able
|
||||
// to apply ViaVersion (and potentially other magic) to it.
|
||||
@@ -676,8 +676,8 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
byteBuf.skipBytes(8); // Skip packet length & timestamp
|
||||
|
||||
int packetId = packetBuf.readVarInt();
|
||||
Packet<?> mcPacket = state.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
||||
mcPacket.readPacketData(packetBuf);
|
||||
Packet<?> mcPacket = state.getPacketHandler(NetworkSide.CLIENT, packetId);
|
||||
mcPacket.read(packetBuf);
|
||||
return mcPacket;
|
||||
} catch (Exception e) {
|
||||
Utils.throwIfUnchecked(e);
|
||||
@@ -710,8 +710,8 @@ public class QuickReplaySender extends ChannelHandlerAdapter implements ReplaySe
|
||||
}
|
||||
|
||||
int packetId = packetBuf.readVarInt();
|
||||
Packet<?> mcPacket = EnumConnectionState.PLAY.getPacket(EnumPacketDirection.CLIENTBOUND, packetId);
|
||||
mcPacket.readPacketData(packetBuf);
|
||||
Packet<?> mcPacket = NetworkState.PLAY.getPacketHandler(NetworkSide.CLIENT, packetId);
|
||||
mcPacket.read(packetBuf);
|
||||
return mcPacket;
|
||||
} catch (Exception e) {
|
||||
Utils.throwIfInstanceOf(e, IOException.class);
|
||||
|
||||
@@ -24,22 +24,22 @@ import de.johni0702.minecraft.gui.element.advanced.GuiProgressBar;
|
||||
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.embedded.EmbeddedChannel;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.network.NetHandlerLoginClient;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import net.minecraft.client.network.ClientLoginNetworkHandler;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.network.ClientConnection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
//#if MC>=11300
|
||||
import com.replaymod.replay.mixin.EntityLivingBaseAccessor;
|
||||
import net.minecraft.client.MainWindow;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.client.util.Window;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
//#else
|
||||
//$$ import com.replaymod.replay.mixin.EntityOtherPlayerMPAccessor;
|
||||
//$$ import net.minecraft.client.entity.EntityOtherPlayerMP;
|
||||
@@ -59,11 +59,11 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
import net.minecraft.network.NetworkSide;
|
||||
//#if MC>=11400
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.fml.network.NetworkHooks;
|
||||
//$$ import net.minecraftforge.fml.network.NetworkHooks;
|
||||
//#else
|
||||
//$$ import com.mojang.authlib.GameProfile;
|
||||
//$$ import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
@@ -86,13 +86,13 @@ import javax.annotation.Nullable;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||
import static com.mojang.blaze3d.platform.GlStateManager.*;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT;
|
||||
|
||||
public class ReplayHandler {
|
||||
|
||||
private static Minecraft mc = getMinecraft();
|
||||
private static MinecraftClient mc = getMinecraft();
|
||||
|
||||
/**
|
||||
* The file currently being played.
|
||||
@@ -164,11 +164,11 @@ public class ReplayHandler {
|
||||
// Force re-creation of camera entity by unloading the previous world
|
||||
ReplayMod.instance.runLater(() -> {
|
||||
//#if MC>=11300
|
||||
mc.mouseHelper.ungrabMouse();
|
||||
mc.mouse.unlockCursor();
|
||||
//#else
|
||||
//$$ mc.setIngameNotInFocus();
|
||||
//#endif
|
||||
mc.loadWorld(null);
|
||||
mc.joinWorld(null);
|
||||
});
|
||||
|
||||
restrictions = new Restrictions();
|
||||
@@ -202,8 +202,8 @@ public class ReplayHandler {
|
||||
}
|
||||
|
||||
if (mc.world != null) {
|
||||
mc.world.sendQuittingDisconnectingPacket();
|
||||
mc.loadWorld(null);
|
||||
mc.world.disconnect();
|
||||
mc.joinWorld(null);
|
||||
}
|
||||
|
||||
TimerAccessor timer = (TimerAccessor) ((MinecraftAccessor) mc).getTimer();
|
||||
@@ -216,20 +216,20 @@ public class ReplayHandler {
|
||||
|
||||
ReplayModReplay.instance.replayHandler = null;
|
||||
|
||||
mc.displayGuiScreen(null);
|
||||
mc.openScreen(null);
|
||||
|
||||
ReplayClosedCallback.EVENT.invoker().replayClosed(this);
|
||||
}
|
||||
|
||||
private void setup() {
|
||||
//#if MC>=11100
|
||||
mc.ingameGUI.getChatGUI().clearChatMessages(false);
|
||||
mc.inGameHud.getChatHud().clear(false);
|
||||
//#else
|
||||
//$$ mc.ingameGUI.getChatGUI().clearChatMessages();
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
NetworkManager networkManager = new NetworkManager(EnumPacketDirection.CLIENTBOUND) {
|
||||
ClientConnection networkManager = new ClientConnection(NetworkSide.CLIENT) {
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable t) {
|
||||
t.printStackTrace();
|
||||
@@ -258,7 +258,7 @@ public class ReplayHandler {
|
||||
//$$ mc.displayGuiScreen(new GuiOpeningReplay(networkManager));
|
||||
//#endif
|
||||
|
||||
networkManager.setNetHandler(new NetHandlerLoginClient(
|
||||
networkManager.setPacketListener(new ClientLoginNetworkHandler(
|
||||
networkManager,
|
||||
mc,
|
||||
null
|
||||
@@ -283,7 +283,7 @@ public class ReplayHandler {
|
||||
channel.pipeline().fireChannelActive();
|
||||
|
||||
//#if MC>=11300 && MC<11400
|
||||
NetworkHooks.registerClientLoginChannel(networkManager);
|
||||
//$$ NetworkHooks.registerClientLoginChannel(networkManager);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ public class ReplayHandler {
|
||||
@Override
|
||||
public void onFailure(@Nonnull Throwable t) {
|
||||
String message = "Failed to initialize quick mode. It will not be available.";
|
||||
Utils.error(LOGGER, overlay, CrashReport.makeCrashReport(t, message), popup::close);
|
||||
Utils.error(LOGGER, overlay, CrashReport.create(t, message), popup::close);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public class ReplayHandler {
|
||||
|
||||
CameraEntity cam = getCameraEntity();
|
||||
if (cam != null) {
|
||||
targetCameraPosition = new Location(cam.posX, cam.posY, cam.posZ, cam.rotationYaw, cam.rotationPitch);
|
||||
targetCameraPosition = new Location(cam.x, cam.y, cam.z, cam.yaw, cam.pitch);
|
||||
} else {
|
||||
targetCameraPosition = null;
|
||||
}
|
||||
@@ -445,8 +445,8 @@ public class ReplayHandler {
|
||||
if (e == null || e == cameraEntity) {
|
||||
spectating = null;
|
||||
e = cameraEntity;
|
||||
} else if (e instanceof EntityPlayer) {
|
||||
spectating = e.getUniqueID();
|
||||
} else if (e instanceof PlayerEntity) {
|
||||
spectating = e.getUuid();
|
||||
}
|
||||
|
||||
if (e == cameraEntity) {
|
||||
@@ -514,16 +514,16 @@ public class ReplayHandler {
|
||||
// Update all entity positions (especially prev/lastTick values)
|
||||
for (Entity entity : loadedEntityList(mc.world)) {
|
||||
skipTeleportInterpolation(entity);
|
||||
entity.lastTickPosX = entity.prevPosX = entity.posX;
|
||||
entity.lastTickPosY = entity.prevPosY = entity.posY;
|
||||
entity.lastTickPosZ = entity.prevPosZ = entity.posZ;
|
||||
entity.prevRotationYaw = entity.rotationYaw;
|
||||
entity.prevRotationPitch = entity.rotationPitch;
|
||||
entity.prevRenderX = entity.prevX = entity.x;
|
||||
entity.prevRenderY = entity.prevY = entity.y;
|
||||
entity.prevRenderZ = entity.prevZ = entity.z;
|
||||
entity.prevYaw = entity.yaw;
|
||||
entity.prevPitch = entity.pitch;
|
||||
}
|
||||
|
||||
// Run previous tick
|
||||
//#if MC>=11300
|
||||
mc.runTick();
|
||||
mc.tick();
|
||||
//#else
|
||||
//$$ try {
|
||||
//$$ mc.runTick();
|
||||
@@ -549,14 +549,14 @@ public class ReplayHandler {
|
||||
}
|
||||
|
||||
if (targetTime < replaySender.currentTimeStamp()) {
|
||||
mc.displayGuiScreen(null);
|
||||
mc.openScreen(null);
|
||||
}
|
||||
|
||||
if (retainCameraPosition) {
|
||||
CameraEntity cam = getCameraEntity();
|
||||
if (cam != null) {
|
||||
targetCameraPosition = new Location(cam.posX, cam.posY, cam.posZ,
|
||||
cam.rotationYaw, cam.rotationPitch);
|
||||
targetCameraPosition = new Location(cam.x, cam.y, cam.z,
|
||||
cam.yaw, cam.pitch);
|
||||
} else {
|
||||
targetCameraPosition = null;
|
||||
}
|
||||
@@ -568,9 +568,9 @@ public class ReplayHandler {
|
||||
replaySender.jumpToTime(targetTime);
|
||||
} else { // We either have to restart the replay or send a significant amount of packets
|
||||
// Render our please-wait-screen
|
||||
GuiScreen guiScreen = new GuiScreen(
|
||||
Screen guiScreen = new Screen(
|
||||
//#if MC>=11400
|
||||
//$$ null
|
||||
null
|
||||
//#endif
|
||||
) {
|
||||
@Override
|
||||
@@ -579,8 +579,8 @@ public class ReplayHandler {
|
||||
//#else
|
||||
//$$ public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
//#endif
|
||||
drawBackground(0);
|
||||
drawCenteredString(mc.fontRenderer, I18n.format("replaymod.gui.pleasewait"),
|
||||
renderDirtBackground(0);
|
||||
drawCenteredString(minecraft.textRenderer, I18n.translate("replaymod.gui.pleasewait"),
|
||||
width / 2, height / 2, 0xffffffff);
|
||||
}
|
||||
};
|
||||
@@ -592,46 +592,46 @@ public class ReplayHandler {
|
||||
pushMatrix();
|
||||
clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
|
||||
//#if MC>=11400
|
||||
//$$ , true
|
||||
, true
|
||||
//#endif
|
||||
);
|
||||
enableTexture2D();
|
||||
mc.getFramebuffer().bindFramebuffer(true);
|
||||
enableTexture();
|
||||
mc.getFramebuffer().beginWrite(true);
|
||||
//#if MC>=11400
|
||||
//$$ mc.window.method_4493(true);
|
||||
mc.window.method_4493(true);
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
mc.mainWindow.setupOverlayRendering();
|
||||
//$$ mc.mainWindow.setupOverlayRendering();
|
||||
//#else
|
||||
//$$ mc.entityRenderer.setupOverlayRendering();
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
MainWindow
|
||||
Window
|
||||
//#else
|
||||
//$$ ScaledResolution
|
||||
//#endif
|
||||
resolution = newScaledResolution(mc);
|
||||
guiScreen.setWorldAndResolution(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
||||
guiScreen.init(mc, resolution.getScaledWidth(), resolution.getScaledHeight());
|
||||
//#if MC>=11300
|
||||
guiScreen.render(0, 0, 0);
|
||||
//#else
|
||||
//$$ guiScreen.drawScreen(0, 0, 0);
|
||||
//#endif
|
||||
|
||||
mc.getFramebuffer().unbindFramebuffer();
|
||||
mc.getFramebuffer().endWrite();
|
||||
popMatrix();
|
||||
pushMatrix();
|
||||
//#if MC>=11300
|
||||
mc.getFramebuffer().framebufferRender(mc.mainWindow.getFramebufferWidth(), mc.mainWindow.getFramebufferHeight());
|
||||
mc.getFramebuffer().draw(mc.window.getFramebufferWidth(), mc.window.getFramebufferHeight());
|
||||
//#else
|
||||
//$$ mc.getFramebuffer().framebufferRender(mc.displayWidth, mc.displayHeight);
|
||||
//#endif
|
||||
popMatrix();
|
||||
|
||||
//#if MC>=11300
|
||||
mc.mainWindow.update(true);
|
||||
mc.window.setFullscreen(true);
|
||||
//#else
|
||||
//$$ Display.update();
|
||||
//#endif
|
||||
@@ -641,7 +641,7 @@ public class ReplayHandler {
|
||||
replaySender.setAsyncMode(true);
|
||||
replaySender.setReplaySpeed(0);
|
||||
|
||||
mc.getConnection().getNetworkManager()
|
||||
mc.getNetworkHandler().getClientConnection()
|
||||
//#if MC>=11300
|
||||
.tick();
|
||||
//#else
|
||||
@@ -649,11 +649,11 @@ public class ReplayHandler {
|
||||
//#endif
|
||||
for (Entity entity : loadedEntityList(mc.world)) {
|
||||
skipTeleportInterpolation(entity);
|
||||
entity.lastTickPosX = entity.prevPosX = entity.posX;
|
||||
entity.lastTickPosY = entity.prevPosY = entity.posY;
|
||||
entity.lastTickPosZ = entity.prevPosZ = entity.posZ;
|
||||
entity.prevRotationYaw = entity.rotationYaw;
|
||||
entity.prevRotationPitch = entity.rotationPitch;
|
||||
entity.prevRenderX = entity.prevX = entity.x;
|
||||
entity.prevRenderY = entity.prevY = entity.y;
|
||||
entity.prevRenderZ = entity.prevZ = entity.z;
|
||||
entity.prevYaw = entity.yaw;
|
||||
entity.prevPitch = entity.pitch;
|
||||
}
|
||||
//#if MC>=10800 && MC<11300
|
||||
//$$ try {
|
||||
@@ -662,7 +662,7 @@ public class ReplayHandler {
|
||||
//$$ e.printStackTrace(); // This should never be thrown but whatever
|
||||
//$$ }
|
||||
//#else
|
||||
mc.runTick();
|
||||
mc.tick();
|
||||
//#endif
|
||||
|
||||
//finally, updating the camera's position (which is not done by the sync jumping)
|
||||
@@ -676,12 +676,12 @@ public class ReplayHandler {
|
||||
|
||||
private void skipTeleportInterpolation(Entity entity) {
|
||||
//#if MC>=11300
|
||||
if (entity instanceof EntityLivingBase && !(entity instanceof CameraEntity)) {
|
||||
EntityLivingBase e = (EntityLivingBase) entity;
|
||||
if (entity instanceof LivingEntity && !(entity instanceof CameraEntity)) {
|
||||
LivingEntity e = (LivingEntity) entity;
|
||||
EntityLivingBaseAccessor ea = (EntityLivingBaseAccessor) e;
|
||||
e.setPosition(ea.getInterpTargetX(), ea.getInterpTargetY(), ea.getInterpTargetZ());
|
||||
e.rotationYaw = (float) ea.getInterpTargetYaw();
|
||||
e.rotationPitch = (float) ea.getInterpTargetPitch();
|
||||
e.yaw = (float) ea.getInterpTargetYaw();
|
||||
e.pitch = (float) ea.getInterpTargetPitch();
|
||||
}
|
||||
//#else
|
||||
//$$ if (entity instanceof EntityOtherPlayerMP) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.replaymod.replaystudio.data.Marker;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -64,11 +64,11 @@ public class ReplayModReplay implements Module {
|
||||
if (camera != null) {
|
||||
Marker marker = new Marker();
|
||||
marker.setTime(replayHandler.getReplaySender().currentTimeStamp());
|
||||
marker.setX(camera.posX);
|
||||
marker.setY(camera.posY);
|
||||
marker.setZ(camera.posZ);
|
||||
marker.setYaw(camera.rotationYaw);
|
||||
marker.setPitch(camera.rotationPitch);
|
||||
marker.setX(camera.x);
|
||||
marker.setY(camera.y);
|
||||
marker.setZ(camera.z);
|
||||
marker.setYaw(camera.yaw);
|
||||
marker.setPitch(camera.pitch);
|
||||
marker.setRoll(camera.roll);
|
||||
replayHandler.getOverlay().timeline.addMarker(marker);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class ReplayModReplay implements Module {
|
||||
@Override
|
||||
public void run() {
|
||||
if (replayHandler != null) {
|
||||
Minecraft mc = MCVer.getMinecraft();
|
||||
MinecraftClient mc = MCVer.getMinecraft();
|
||||
ListenableFuture<NoGuiScreenshot> future = NoGuiScreenshot.take(mc, 1280, 720);
|
||||
Futures.addCallback(future, new FutureCallback<NoGuiScreenshot>() {
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.replaymod.replay;
|
||||
|
||||
import com.replaymod.core.mixin.MinecraftAccessor;
|
||||
import com.replaymod.core.mixin.TimerAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.getMinecraft;
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface ReplaySender {
|
||||
* @return {@code true} if it is paused, {@code false} otherwise
|
||||
*/
|
||||
public default boolean paused() {
|
||||
Minecraft mc = getMinecraft();
|
||||
MinecraftClient mc = getMinecraft();
|
||||
TimerAccessor timer = (TimerAccessor) ((MinecraftAccessor) mc).getTimer();
|
||||
//#if MC>=11200
|
||||
return timer.getTickLength() == Float.POSITIVE_INFINITY;
|
||||
|
||||
@@ -11,45 +11,45 @@ import com.replaymod.replay.mixin.FirstPersonRendererAccessor;
|
||||
import com.replaymod.replaystudio.util.Location;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.AbstractClientPlayerEntity;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
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.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.entity.decoration.ItemFrameEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BoundingBox;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import com.replaymod.core.events.KeyBindingEventCallback;
|
||||
//$$ import com.replaymod.core.events.PreRenderCallback;
|
||||
//$$ import com.replaymod.core.events.PreRenderHandCallback;
|
||||
//$$ import com.replaymod.replay.events.RenderSpectatorCrosshairCallback;
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
//$$ import net.fabricmc.fabric.api.util.TriState;
|
||||
//$$ import net.minecraft.client.world.ClientWorld;
|
||||
//$$ import net.minecraft.fluid.Fluid;
|
||||
//$$ import net.minecraft.tag.Tag;
|
||||
//$$ import net.minecraft.util.hit.BlockHitResult;
|
||||
//$$ import net.minecraft.util.hit.HitResult;
|
||||
import com.replaymod.core.events.KeyBindingEventCallback;
|
||||
import com.replaymod.core.events.PreRenderCallback;
|
||||
import com.replaymod.core.events.PreRenderHandCallback;
|
||||
import com.replaymod.replay.events.RenderSpectatorCrosshairCallback;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.PreTickCallback;
|
||||
import net.fabricmc.fabric.api.util.TriState;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.hit.HitResult;
|
||||
//#else
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.replay.events.ReplayChatMessageEvent;
|
||||
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;
|
||||
import net.minecraftforge.client.event.RenderHandEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
|
||||
//$$ import com.replaymod.core.versions.MCVer;
|
||||
//$$ import com.replaymod.replay.events.ReplayChatMessageEvent;
|
||||
//$$ 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;
|
||||
//$$ import net.minecraftforge.client.event.RenderHandEvent;
|
||||
//$$ import net.minecraftforge.common.MinecraftForge;
|
||||
//$$ import net.minecraftforge.eventbus.api.EventPriority;
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$ import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
//$$
|
||||
//#if MC>=11300
|
||||
import net.minecraft.util.math.RayTraceFluidMode;
|
||||
//$$ import net.minecraft.util.math.RayTraceFluidMode;
|
||||
//#else
|
||||
//$$ import net.minecraft.block.material.Material;
|
||||
//$$ import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -57,22 +57,22 @@ import net.minecraft.util.math.RayTraceFluidMode;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10904
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
//#if MC>=11200
|
||||
//#if MC>=11300
|
||||
import net.minecraft.client.util.RecipeBookClient;
|
||||
import net.minecraft.client.recipe.book.ClientRecipeBook;
|
||||
//#else
|
||||
//$$ import net.minecraft.stats.RecipeBook;
|
||||
//#endif
|
||||
//#endif
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.stat.StatHandler;
|
||||
import net.minecraft.util.Hand;
|
||||
//#else
|
||||
//$$ import net.minecraft.stats.StatFileWriter;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
//$$ import net.minecraft.util.Session;
|
||||
@@ -92,7 +92,7 @@ import static com.replaymod.core.versions.MCVer.*;
|
||||
@SuppressWarnings("EntityConstructor")
|
||||
public class CameraEntity
|
||||
//#if MC>=10800
|
||||
extends EntityPlayerSP
|
||||
extends ClientPlayerEntity
|
||||
//#else
|
||||
//$$ extends EntityClientPlayerMP
|
||||
//#endif
|
||||
@@ -122,9 +122,9 @@ public class CameraEntity
|
||||
|
||||
//#if MC>=11300
|
||||
//#if MC>=11400
|
||||
//$$ public CameraEntity(MinecraftClient mcIn, ClientWorld worldIn, ClientPlayNetworkHandler netHandlerPlayClient, StatHandler statisticsManager, ClientRecipeBook recipeBookClient) {
|
||||
public CameraEntity(MinecraftClient mcIn, ClientWorld worldIn, ClientPlayNetworkHandler netHandlerPlayClient, StatHandler statisticsManager, ClientRecipeBook recipeBookClient) {
|
||||
//#else
|
||||
public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager, RecipeBookClient recipeBookClient) {
|
||||
//$$ public CameraEntity(Minecraft mcIn, World worldIn, NetHandlerPlayClient netHandlerPlayClient, StatisticsManager statisticsManager, RecipeBookClient recipeBookClient) {
|
||||
//#endif
|
||||
super(mcIn, worldIn, netHandlerPlayClient, statisticsManager, recipeBookClient);
|
||||
//#else
|
||||
@@ -161,7 +161,7 @@ public class CameraEntity
|
||||
* @param z Delta in Z direction
|
||||
*/
|
||||
public void moveCamera(double x, double y, double z) {
|
||||
setCameraPosition(this.posX + x, this.posY + y, this.posZ + z);
|
||||
setCameraPosition(this.x + x, this.y + y, this.z + z);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,9 +171,9 @@ public class CameraEntity
|
||||
* @param z Z coordinate
|
||||
*/
|
||||
public void setCameraPosition(double x, double y, double z) {
|
||||
this.lastTickPosX = this.prevPosX = this.posX = x;
|
||||
this.lastTickPosY = this.prevPosY = this.posY = y;
|
||||
this.lastTickPosZ = this.prevPosZ = this.posZ = z;
|
||||
this.prevRenderX = this.prevX = this.x = x;
|
||||
this.prevRenderY = this.prevY = this.y = y;
|
||||
this.prevRenderZ = this.prevZ = this.z = z;
|
||||
updateBoundingBox();
|
||||
}
|
||||
|
||||
@@ -184,8 +184,8 @@ public class CameraEntity
|
||||
* @param roll Roll in degrees
|
||||
*/
|
||||
public void setCameraRotation(float yaw, float pitch, float roll) {
|
||||
this.prevRotationYaw = this.rotationYaw = yaw;
|
||||
this.prevRotationPitch = this.rotationPitch = pitch;
|
||||
this.prevYaw = this.yaw = yaw;
|
||||
this.prevPitch = this.pitch = pitch;
|
||||
this.roll = roll;
|
||||
}
|
||||
|
||||
@@ -209,38 +209,38 @@ public class CameraEntity
|
||||
//#else
|
||||
//$$ float yOffset = 1.62f; // Magic value (eye height) from EntityRenderer#orientCamera
|
||||
//#endif
|
||||
this.prevPosX = to.prevPosX;
|
||||
this.prevPosY = to.prevPosY + yOffset;
|
||||
this.prevPosZ = to.prevPosZ;
|
||||
this.prevRotationYaw = to.prevRotationYaw;
|
||||
this.prevRotationPitch = to.prevRotationPitch;
|
||||
this.posX = to.posX;
|
||||
this.posY = to.posY + yOffset;
|
||||
this.posZ = to.posZ;
|
||||
this.rotationYaw = to.rotationYaw;
|
||||
this.rotationPitch = to.rotationPitch;
|
||||
this.lastTickPosX = to.lastTickPosX;
|
||||
this.lastTickPosY = to.lastTickPosY + yOffset;
|
||||
this.lastTickPosZ = to.lastTickPosZ;
|
||||
this.prevX = to.prevX;
|
||||
this.prevY = to.prevY + yOffset;
|
||||
this.prevZ = to.prevZ;
|
||||
this.prevYaw = to.prevYaw;
|
||||
this.prevPitch = to.prevPitch;
|
||||
this.x = to.x;
|
||||
this.y = to.y + yOffset;
|
||||
this.z = to.z;
|
||||
this.yaw = to.yaw;
|
||||
this.pitch = to.pitch;
|
||||
this.prevRenderX = to.prevRenderX;
|
||||
this.prevRenderY = to.prevRenderY + yOffset;
|
||||
this.prevRenderZ = to.prevRenderZ;
|
||||
updateBoundingBox();
|
||||
}
|
||||
|
||||
private void updateBoundingBox() {
|
||||
//#if MC>=11400
|
||||
//$$ float width = getWidth();
|
||||
//$$ float height = getHeight();
|
||||
float width = getWidth();
|
||||
float height = getHeight();
|
||||
//#endif
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
setBoundingBox(new AxisAlignedBB(
|
||||
setBoundingBox(new BoundingBox(
|
||||
//#else
|
||||
//$$ setEntityBoundingBox(new AxisAlignedBB(
|
||||
//#endif
|
||||
//#else
|
||||
//$$ this.boundingBox.setBB(AxisAlignedBB.getBoundingBox(
|
||||
//#endif
|
||||
this.posX - width / 2, this.posY, this.posZ - width / 2,
|
||||
this.posX + width / 2, this.posY + height, this.posZ + width / 2));
|
||||
this.x - width / 2, this.y, this.z - width / 2,
|
||||
this.x + width / 2, this.y + height, this.z + width / 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,7 +250,7 @@ public class CameraEntity
|
||||
//$$ public void onUpdate() {
|
||||
//#endif
|
||||
//#if MC>=10800
|
||||
Entity view = getRenderViewEntity(this.mc);
|
||||
Entity view = getRenderViewEntity(this.client);
|
||||
//#else
|
||||
//$$ EntityLivingBase view = getRenderViewEntity(this.mc);
|
||||
//#endif
|
||||
@@ -259,19 +259,19 @@ public class CameraEntity
|
||||
// This is important if the spectated player respawns as their
|
||||
// entity is recreated and we have to spectate a new entity
|
||||
UUID spectating = ReplayModReplay.instance.getReplayHandler().getSpectatedUUID();
|
||||
if (spectating != null && (view.getUniqueID() != spectating
|
||||
if (spectating != null && (view.getUuid() != spectating
|
||||
|| view.world != this.world)
|
||||
|| this.world.getEntityByID(view.getEntityId()) != view) {
|
||||
|| this.world.getEntityById(view.getEntityId()) != view) {
|
||||
if (spectating == null) {
|
||||
// Entity (non-player) died, stop spectating
|
||||
ReplayModReplay.instance.getReplayHandler().spectateEntity(this);
|
||||
return;
|
||||
}
|
||||
view = this.world.getPlayerEntityByUUID(spectating);
|
||||
view = this.world.getPlayerByUuid(spectating);
|
||||
if (view != null) {
|
||||
setRenderViewEntity(this.mc, view);
|
||||
setRenderViewEntity(this.client, view);
|
||||
} else {
|
||||
setRenderViewEntity(this.mc, this);
|
||||
setRenderViewEntity(this.client, this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -284,25 +284,25 @@ public class CameraEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayerToSpawn() {
|
||||
public void method_5823() {
|
||||
// Make sure our world is up-to-date in case of world changes
|
||||
if (this.mc.world != null) {
|
||||
this.world = this.mc.world;
|
||||
if (this.client.world != null) {
|
||||
this.world = this.client.world;
|
||||
}
|
||||
super.preparePlayerToSpawn();
|
||||
super.method_5823();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotation(float yaw, float pitch) {
|
||||
if (getRenderViewEntity(this.mc) == this) {
|
||||
if (getRenderViewEntity(this.client) == this) {
|
||||
// Only update camera rotation when the camera is the view
|
||||
super.setRotation(yaw, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEntityInsideOpaqueBlock() {
|
||||
return falseUnlessSpectating(Entity::isEntityInsideOpaqueBlock); // Make sure no suffocation overlay is rendered
|
||||
public boolean isInsideWall() {
|
||||
return falseUnlessSpectating(Entity::isInsideWall); // Make sure no suffocation overlay is rendered
|
||||
}
|
||||
|
||||
//#if MC<11300
|
||||
@@ -313,36 +313,36 @@ public class CameraEntity
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ @Override
|
||||
//$$ public boolean isInFluid(Tag<Fluid> fluid, boolean loadedChunksOnly) {
|
||||
//$$ return falseUnlessSpectating(entity -> entity.isInFluid(fluid, loadedChunksOnly));
|
||||
//$$ }
|
||||
@Override
|
||||
public boolean isInFluid(Tag<Fluid> fluid, boolean loadedChunksOnly) {
|
||||
return falseUnlessSpectating(entity -> entity.isInFluid(fluid, loadedChunksOnly));
|
||||
}
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
@Override
|
||||
public boolean isInLava() {
|
||||
return falseUnlessSpectating(Entity::isInLava); // Make sure no lava overlay is rendered
|
||||
}
|
||||
//$$ @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() {
|
||||
return falseUnlessSpectating(Entity::isInWater); // Make sure no water overlay is rendered
|
||||
}
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public boolean isInWater() {
|
||||
//$$ return falseUnlessSpectating(Entity::isInWater); // Make sure no water overlay is rendered
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public boolean isBurning() {
|
||||
return falseUnlessSpectating(Entity::isBurning); // Make sure no fire overlay is rendered
|
||||
public boolean isOnFire() {
|
||||
return falseUnlessSpectating(Entity::isOnFire); // Make sure no fire overlay is rendered
|
||||
}
|
||||
|
||||
private boolean falseUnlessSpectating(Function<Entity, Boolean> property) {
|
||||
Entity view = getRenderViewEntity(this.mc);
|
||||
Entity view = getRenderViewEntity(this.client);
|
||||
if (view != null && view != this) {
|
||||
return property.apply(view);
|
||||
}
|
||||
@@ -350,19 +350,19 @@ public class CameraEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBePushed() {
|
||||
public boolean isPushable() {
|
||||
return false; // We are in full control of ourselves
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@Override
|
||||
protected void createRunningParticles() {
|
||||
protected void spawnSprintingParticles() {
|
||||
// We do not produce any particles, we are a camera
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public boolean canBeCollidedWith() {
|
||||
public boolean collides() {
|
||||
return false; // We are a camera, we cannot collide
|
||||
}
|
||||
|
||||
@@ -374,23 +374,23 @@ public class CameraEntity
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ @Override
|
||||
//$$ public boolean shouldRenderFrom(double double_1, double double_2, double double_3) {
|
||||
//$$ return false; // never render the camera otherwise it'd be visible e.g. in 3rd-person or with shaders
|
||||
//$$ }
|
||||
//#else
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass) {
|
||||
// Never render the camera
|
||||
// This is necessary to hide the player head in third person mode and to not
|
||||
// cause any unwanted shadows when rendering with shaders.
|
||||
return false;
|
||||
public boolean shouldRenderFrom(double double_1, double double_2, double double_3) {
|
||||
return false; // never render the camera otherwise it'd be visible e.g. in 3rd-person or with shaders
|
||||
}
|
||||
//#else
|
||||
//$$ @Override
|
||||
//$$ public boolean shouldRenderInPass(int pass) {
|
||||
//$$ // Never render the camera
|
||||
//$$ // This is necessary to hide the player head in third person mode and to not
|
||||
//$$ // cause any unwanted shadows when rendering with shaders.
|
||||
//$$ return false;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public boolean isInvisible() {
|
||||
Entity view = getRenderViewEntity(this.mc);
|
||||
Entity view = getRenderViewEntity(this.client);
|
||||
if (view != this) {
|
||||
return view.isInvisible();
|
||||
}
|
||||
@@ -398,99 +398,99 @@ public class CameraEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getLocationSkin() {
|
||||
Entity view = getRenderViewEntity(this.mc);
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return Utils.getResourceLocationForPlayerUUID(view.getUniqueID());
|
||||
public Identifier getSkinTexture() {
|
||||
Entity view = getRenderViewEntity(this.client);
|
||||
if (view != this && view instanceof PlayerEntity) {
|
||||
return Utils.getResourceLocationForPlayerUUID(view.getUuid());
|
||||
}
|
||||
return super.getLocationSkin();
|
||||
return super.getSkinTexture();
|
||||
}
|
||||
|
||||
//#if MC>=10800
|
||||
@Override
|
||||
public String getSkinType() {
|
||||
Entity view = this.mc.getRenderViewEntity();
|
||||
if (view != this && view instanceof AbstractClientPlayer) {
|
||||
return ((AbstractClientPlayer) view).getSkinType();
|
||||
public String getModel() {
|
||||
Entity view = this.client.getCameraEntity();
|
||||
if (view != this && view instanceof AbstractClientPlayerEntity) {
|
||||
return ((AbstractClientPlayerEntity) view).getModel();
|
||||
}
|
||||
return super.getSkinType();
|
||||
return super.getModel();
|
||||
}
|
||||
//#endif
|
||||
|
||||
@Override
|
||||
public float getSwingProgress(float renderPartialTicks) {
|
||||
Entity view = getRenderViewEntity(this.mc);
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return ((EntityPlayer) view).getSwingProgress(renderPartialTicks);
|
||||
public float getHandSwingProgress(float renderPartialTicks) {
|
||||
Entity view = getRenderViewEntity(this.client);
|
||||
if (view != this && view instanceof PlayerEntity) {
|
||||
return ((PlayerEntity) view).getHandSwingProgress(renderPartialTicks);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//#if MC>=10904
|
||||
@Override
|
||||
public float getCooldownPeriod() {
|
||||
Entity view = this.mc.getRenderViewEntity();
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return ((EntityPlayer) view).getCooldownPeriod();
|
||||
public float method_7279() {
|
||||
Entity view = this.client.getCameraEntity();
|
||||
if (view != this && view instanceof PlayerEntity) {
|
||||
return ((PlayerEntity) view).method_7279();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCooledAttackStrength(float adjustTicks) {
|
||||
Entity view = this.mc.getRenderViewEntity();
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return ((EntityPlayer) view).getCooledAttackStrength(adjustTicks);
|
||||
public float method_7261(float adjustTicks) {
|
||||
Entity view = this.client.getCameraEntity();
|
||||
if (view != this && view instanceof PlayerEntity) {
|
||||
return ((PlayerEntity) view).method_7261(adjustTicks);
|
||||
}
|
||||
// Default to 1 as to not render the cooldown indicator (renders for < 1)
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumHand getActiveHand() {
|
||||
Entity view = this.mc.getRenderViewEntity();
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return ((EntityPlayer) view).getActiveHand();
|
||||
public Hand getActiveHand() {
|
||||
Entity view = this.client.getCameraEntity();
|
||||
if (view != this && view instanceof PlayerEntity) {
|
||||
return ((PlayerEntity) view).getActiveHand();
|
||||
}
|
||||
return super.getActiveHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHandActive() {
|
||||
Entity view = this.mc.getRenderViewEntity();
|
||||
if (view != this && view instanceof EntityPlayer) {
|
||||
return ((EntityPlayer) view).isHandActive();
|
||||
public boolean isUsingItem() {
|
||||
Entity view = this.client.getCameraEntity();
|
||||
if (view != this && view instanceof PlayerEntity) {
|
||||
return ((PlayerEntity) view).isUsingItem();
|
||||
}
|
||||
return super.isHandActive();
|
||||
return super.isUsingItem();
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ @Override
|
||||
//$$ public HitResult rayTrace(double maxDistance, float tickDelta, boolean fluids) {
|
||||
//$$ HitResult result = super.rayTrace(maxDistance, tickDelta, fluids);
|
||||
//$$
|
||||
//$$ // Make sure we can never look at blocks (-> no outline)
|
||||
//$$ if (result instanceof BlockHitResult) {
|
||||
//$$ BlockHitResult blockResult = (BlockHitResult) result;
|
||||
//$$ result = BlockHitResult.createMissed(result.getPos(), blockResult.getSide(), blockResult.getBlockPos());
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ return result;
|
||||
//$$ }
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
@Override
|
||||
public RayTraceResult rayTrace(double blockReachDistance, float partialTicks, RayTraceFluidMode p_174822_4_) {
|
||||
RayTraceResult pos = super.rayTrace(blockReachDistance, partialTicks, p_174822_4_);
|
||||
public HitResult rayTrace(double maxDistance, float tickDelta, boolean fluids) {
|
||||
HitResult result = super.rayTrace(maxDistance, tickDelta, fluids);
|
||||
|
||||
// Make sure we can never look at blocks (-> no outline)
|
||||
if(pos != null && pos.type == RayTraceResult.Type.BLOCK) {
|
||||
pos.type = RayTraceResult.Type.MISS;
|
||||
if (result instanceof BlockHitResult) {
|
||||
BlockHitResult blockResult = (BlockHitResult) result;
|
||||
result = BlockHitResult.createMissed(result.getPos(), blockResult.getSide(), blockResult.getBlockPos());
|
||||
}
|
||||
|
||||
return pos;
|
||||
return result;
|
||||
}
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
//$$ @Override
|
||||
//$$ public RayTraceResult rayTrace(double blockReachDistance, float partialTicks, RayTraceFluidMode p_174822_4_) {
|
||||
//$$ RayTraceResult pos = super.rayTrace(blockReachDistance, partialTicks, p_174822_4_);
|
||||
//$$
|
||||
//$$ // Make sure we can never look at blocks (-> no outline)
|
||||
//$$ if(pos != null && pos.type == RayTraceResult.Type.BLOCK) {
|
||||
//$$ pos.type = RayTraceResult.Type.MISS;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ return pos;
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ @Override
|
||||
//$$ public RayTraceResult rayTrace(double p_174822_1_, float p_174822_3_) {
|
||||
//$$ RayTraceResult pos = super.rayTrace(p_174822_1_, 1f);
|
||||
@@ -546,40 +546,40 @@ public class CameraEntity
|
||||
handleInputEvents();
|
||||
|
||||
Map<String, KeyBinding> keyBindings = ReplayMod.instance.getKeyBindingRegistry().getKeyBindings();
|
||||
if (keyBindings.get("replaymod.input.rollclockwise").isKeyDown()) {
|
||||
if (keyBindings.get("replaymod.input.rollclockwise").isPressed()) {
|
||||
roll += Utils.isCtrlDown() ? 0.2 : 1;
|
||||
}
|
||||
if (keyBindings.get("replaymod.input.rollcounterclockwise").isKeyDown()) {
|
||||
if (keyBindings.get("replaymod.input.rollcounterclockwise").isPressed()) {
|
||||
roll -= Utils.isCtrlDown() ? 0.2 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleInputEvents() {
|
||||
if (this.mc.gameSettings.keyBindAttack.isPressed() || this.mc.gameSettings.keyBindUseItem.isPressed()) {
|
||||
if (canSpectate(this.mc.pointedEntity)) {
|
||||
if (this.client.options.keyAttack.wasPressed() || this.client.options.keyUse.wasPressed()) {
|
||||
if (canSpectate(this.client.targetedEntity)) {
|
||||
ReplayModReplay.instance.getReplayHandler().spectateEntity(
|
||||
//#if MC<=10710
|
||||
//$$ (EntityLivingBase)
|
||||
//#endif
|
||||
this.mc.pointedEntity);
|
||||
this.client.targetedEntity);
|
||||
// Make sure we don't exit right away
|
||||
//noinspection StatementWithEmptyBody
|
||||
while (this.mc.gameSettings.keyBindSneak.isPressed());
|
||||
while (this.client.options.keySneak.wasPressed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateArmYawAndPitch() {
|
||||
this.prevRenderArmYaw = this.renderArmYaw;
|
||||
this.prevRenderArmPitch = this.renderArmPitch;
|
||||
this.renderArmPitch = this.renderArmPitch + (this.rotationPitch - this.renderArmPitch) * 0.5f;
|
||||
this.renderArmYaw = this.renderArmYaw + (this.rotationYaw - this.renderArmYaw) * 0.5f;
|
||||
this.lastRenderYaw = this.renderYaw;
|
||||
this.lastRenderPitch = this.renderPitch;
|
||||
this.renderPitch = this.renderPitch + (this.pitch - this.renderPitch) * 0.5f;
|
||||
this.renderYaw = this.renderYaw + (this.yaw - this.renderYaw) * 0.5f;
|
||||
}
|
||||
|
||||
public boolean canSpectate(Entity e) {
|
||||
return e != null && !e.isInvisible()
|
||||
//#if MC>=10800
|
||||
&& (e instanceof EntityPlayer || e instanceof EntityLiving || e instanceof EntityItemFrame);
|
||||
&& (e instanceof PlayerEntity || e instanceof MobEntity || e instanceof ItemFrameEntity);
|
||||
//#else
|
||||
//$$ && e instanceof EntityPlayer; // cannot be more generic since 1.7.10 has no concept of eye height
|
||||
//#endif
|
||||
@@ -587,11 +587,11 @@ public class CameraEntity
|
||||
|
||||
//#if MC<11400
|
||||
//#if MC>=11102
|
||||
@Override
|
||||
public void sendMessage(ITextComponent message) {
|
||||
if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
||||
super.sendMessage(message);
|
||||
}
|
||||
//$$ @Override
|
||||
//$$ public void sendMessage(ITextComponent message) {
|
||||
//$$ if (MinecraftForge.EVENT_BUS.post(new ReplayChatMessageEvent(this))) return;
|
||||
//$$ super.sendMessage(message);
|
||||
//$$ }
|
||||
//#else
|
||||
//$$ @Override
|
||||
//$$ public void addChatMessage(ITextComponent message) {
|
||||
@@ -607,53 +607,53 @@ public class CameraEntity
|
||||
//$$ public // All event handlers need to be public in 1.7.10
|
||||
//#endif
|
||||
class EventHandler extends EventRegistrations {
|
||||
private final Minecraft mc = getMinecraft();
|
||||
private final MinecraftClient mc = getMinecraft();
|
||||
|
||||
private EventHandler() {}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(PreTickCallback.EVENT, this::onPreClientTick); }
|
||||
//$$ private void onPreClientTick() {
|
||||
{ on(PreTickCallback.EVENT, this::onPreClientTick); }
|
||||
private void onPreClientTick() {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onPreClientTick(TickEvent.ClientTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onPreClientTick(TickEvent.ClientTickEvent event) {
|
||||
//$$ if (event.phase != TickEvent.Phase.START) return;
|
||||
//#endif
|
||||
updateArmYawAndPitch();
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(PreRenderCallback.EVENT, this::onRenderUpdate); }
|
||||
//$$ private void onRenderUpdate() {
|
||||
{ on(PreRenderCallback.EVENT, this::onRenderUpdate); }
|
||||
private void onRenderUpdate() {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onRenderUpdate(TickEvent.RenderTickEvent event) {
|
||||
if (event.phase != TickEvent.Phase.START) return;
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onRenderUpdate(TickEvent.RenderTickEvent event) {
|
||||
//$$ if (event.phase != TickEvent.Phase.START) return;
|
||||
//#endif
|
||||
update();
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(KeyBindingEventCallback.EVENT, CameraEntity.this::handleInputEvents); }
|
||||
{ on(KeyBindingEventCallback.EVENT, CameraEntity.this::handleInputEvents); }
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(RenderSpectatorCrosshairCallback.EVENT, this::shouldRenderSpectatorCrosshair); }
|
||||
//$$ private TriState shouldRenderSpectatorCrosshair() {
|
||||
//$$ return TriState.of(canSpectate(mc.targetedEntity));
|
||||
//$$ }
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||
// The crosshair should only render if targeted entity can actually be spectated
|
||||
if (MCVer.getType(event) == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
event.setCanceled(!canSpectate(mc.pointedEntity));
|
||||
}
|
||||
// Hotbar should never be rendered
|
||||
if (MCVer.getType(event) == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
{ on(RenderSpectatorCrosshairCallback.EVENT, this::shouldRenderSpectatorCrosshair); }
|
||||
private TriState shouldRenderSpectatorCrosshair() {
|
||||
return TriState.of(canSpectate(mc.targetedEntity));
|
||||
}
|
||||
//#else
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void preCrosshairRender(RenderGameOverlayEvent.Pre event) {
|
||||
//$$ // The crosshair should only render if targeted entity can actually be spectated
|
||||
//$$ if (MCVer.getType(event) == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
//$$ event.setCanceled(!canSpectate(mc.pointedEntity));
|
||||
//$$ }
|
||||
//$$ // Hotbar should never be rendered
|
||||
//$$ if (MCVer.getType(event) == RenderGameOverlayEvent.ElementType.HOTBAR) {
|
||||
//$$ event.setCanceled(true);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
{ on(SettingsChangedCallback.EVENT, this::onSettingsChanged); }
|
||||
@@ -668,47 +668,47 @@ public class CameraEntity
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(PreRenderHandCallback.EVENT, this::onRenderHand); }
|
||||
//$$ private boolean onRenderHand() {
|
||||
//$$ // Unless we are spectating another player, don't render our hand
|
||||
//$$ if (getRenderViewEntity(mc) == CameraEntity.this || !(getRenderViewEntity(mc) instanceof PlayerEntity)) {
|
||||
//$$ return true; // cancel hand rendering
|
||||
//$$ } else {
|
||||
//$$ onRenderHandMonitor();
|
||||
//$$ return false;
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void onRenderHand(RenderHandEvent event) {
|
||||
{ on(PreRenderHandCallback.EVENT, this::onRenderHand); }
|
||||
private boolean onRenderHand() {
|
||||
// Unless we are spectating another player, don't render our hand
|
||||
if (getRenderViewEntity(mc) == CameraEntity.this || !(getRenderViewEntity(mc) instanceof EntityPlayer)) {
|
||||
event.setCanceled(true);
|
||||
if (getRenderViewEntity(mc) == CameraEntity.this || !(getRenderViewEntity(mc) instanceof PlayerEntity)) {
|
||||
return true; // cancel hand rendering
|
||||
} else {
|
||||
onRenderHandMonitor();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//#else
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onRenderHand(RenderHandEvent event) {
|
||||
//$$ // Unless we are spectating another player, don't render our hand
|
||||
//$$ if (getRenderViewEntity(mc) == CameraEntity.this || !(getRenderViewEntity(mc) instanceof EntityPlayer)) {
|
||||
//$$ event.setCanceled(true);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ private void onRenderHandMonitor() {
|
||||
private void onRenderHandMonitor() {
|
||||
//#else
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onRenderHandMonitor(RenderHandEvent event) {
|
||||
//$$ @SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
//$$ public void onRenderHandMonitor(RenderHandEvent event) {
|
||||
//#endif
|
||||
Entity view = getRenderViewEntity(mc);
|
||||
if (view instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) view;
|
||||
if (view instanceof PlayerEntity) {
|
||||
PlayerEntity player = (PlayerEntity) view;
|
||||
// When the spectated player has changed, force equip their items to prevent the equip animation
|
||||
if (lastHandRendered != player) {
|
||||
lastHandRendered = player;
|
||||
|
||||
FirstPersonRendererAccessor acc = (FirstPersonRendererAccessor) mc.entityRenderer.itemRenderer;
|
||||
FirstPersonRendererAccessor acc = (FirstPersonRendererAccessor) mc.gameRenderer.firstPersonRenderer;
|
||||
//#if MC>=10904
|
||||
acc.setPrevEquippedProgressMainHand(1);
|
||||
acc.setPrevEquippedProgressOffHand(1);
|
||||
acc.setEquippedProgressMainHand(1);
|
||||
acc.setEquippedProgressOffHand(1);
|
||||
acc.setItemStackMainHand(player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND));
|
||||
acc.setItemStackOffHand(player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND));
|
||||
acc.setItemStackMainHand(player.getEquippedStack(EquipmentSlot.HAND_MAIN));
|
||||
acc.setItemStackOffHand(player.getEquippedStack(EquipmentSlot.HAND_OFF));
|
||||
//#else
|
||||
//$$ acc.setPrevEquippedProgress(1);
|
||||
//$$ acc.setEquippedProgress(1);
|
||||
@@ -717,75 +717,75 @@ public class CameraEntity
|
||||
//#endif
|
||||
|
||||
|
||||
mc.player.renderArmYaw = mc.player.prevRenderArmYaw = player.rotationYaw;
|
||||
mc.player.renderArmPitch = mc.player.prevRenderArmPitch = player.rotationPitch;
|
||||
mc.player.renderYaw = mc.player.lastRenderYaw = player.yaw;
|
||||
mc.player.renderPitch = mc.player.lastRenderPitch = player.pitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ // Moved to MixinCamera
|
||||
// Moved to MixinCamera
|
||||
//#else
|
||||
//#if MC>=10800
|
||||
@SubscribeEvent
|
||||
public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||
if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onEntityViewRenderEvent(EntityViewRenderEvent.CameraSetup event) {
|
||||
//$$ if (mc.getRenderViewEntity() == CameraEntity.this) {
|
||||
//#if MC>=10904
|
||||
event.setRoll(roll);
|
||||
//$$ event.setRoll(roll);
|
||||
//#else
|
||||
//$$ event.roll = roll;
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
private boolean heldItemTooltipsWasTrue;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ // FIXME fabric
|
||||
// FIXME fabric
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
|
||||
switch (MCVer.getType(event)) {
|
||||
case ALL:
|
||||
heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips;
|
||||
mc.gameSettings.heldItemTooltips = false;
|
||||
break;
|
||||
case ARMOR:
|
||||
case HEALTH:
|
||||
case FOOD:
|
||||
case AIR:
|
||||
case HOTBAR:
|
||||
case EXPERIENCE:
|
||||
case HEALTHMOUNT:
|
||||
case JUMPBAR:
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void preRenderGameOverlay(RenderGameOverlayEvent.Pre event) {
|
||||
//$$ switch (MCVer.getType(event)) {
|
||||
//$$ case ALL:
|
||||
//$$ heldItemTooltipsWasTrue = mc.gameSettings.heldItemTooltips;
|
||||
//$$ mc.gameSettings.heldItemTooltips = false;
|
||||
//$$ break;
|
||||
//$$ case ARMOR:
|
||||
//$$ case HEALTH:
|
||||
//$$ case FOOD:
|
||||
//$$ case AIR:
|
||||
//$$ case HOTBAR:
|
||||
//$$ case EXPERIENCE:
|
||||
//$$ case HEALTHMOUNT:
|
||||
//$$ case JUMPBAR:
|
||||
//#if MC>=10904
|
||||
case POTION_ICONS:
|
||||
//$$ case POTION_ICONS:
|
||||
//#endif
|
||||
event.setCanceled(true);
|
||||
break;
|
||||
case HELMET:
|
||||
case PORTAL:
|
||||
case CROSSHAIRS:
|
||||
case BOSSHEALTH:
|
||||
//$$ event.setCanceled(true);
|
||||
//$$ break;
|
||||
//$$ case HELMET:
|
||||
//$$ case PORTAL:
|
||||
//$$ case CROSSHAIRS:
|
||||
//$$ case BOSSHEALTH:
|
||||
//#if MC>=10904
|
||||
case BOSSINFO:
|
||||
case SUBTITLES:
|
||||
//$$ case BOSSINFO:
|
||||
//$$ case SUBTITLES:
|
||||
//#endif
|
||||
case TEXT:
|
||||
case CHAT:
|
||||
case PLAYER_LIST:
|
||||
case DEBUG:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
||||
if (MCVer.getType(event) != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue;
|
||||
}
|
||||
//$$ case TEXT:
|
||||
//$$ case CHAT:
|
||||
//$$ case PLAYER_LIST:
|
||||
//$$ case DEBUG:
|
||||
//$$ break;
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void postRenderGameOverlay(RenderGameOverlayEvent.Post event) {
|
||||
//$$ if (MCVer.getType(event) != RenderGameOverlayEvent.ElementType.ALL) return;
|
||||
//$$ mc.gameSettings.heldItemTooltips = heldItemTooltipsWasTrue;
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.replaymod.replay.camera;
|
||||
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector3f;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
@@ -32,34 +32,34 @@ public class ClassicCameraController implements CameraController {
|
||||
public void update(float partialTicksPassed) {
|
||||
boolean forward = false, backward = false, left = false, right = false, up = false, down = false;
|
||||
speedup = false;
|
||||
for(KeyBinding kb : getMinecraft().gameSettings.keyBindings) {
|
||||
if(!kb.isKeyDown()) continue;
|
||||
if(kb.getKeyDescription().equals("key.forward")) {
|
||||
for(KeyBinding kb : getMinecraft().options.keysAll) {
|
||||
if(!kb.isPressed()) continue;
|
||||
if(kb.getId().equals("key.forward")) {
|
||||
forward = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.back")) {
|
||||
if(kb.getId().equals("key.back")) {
|
||||
backward = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.jump")) {
|
||||
if(kb.getId().equals("key.jump")) {
|
||||
up = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.left")) {
|
||||
if(kb.getId().equals("key.left")) {
|
||||
left = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.right")) {
|
||||
if(kb.getId().equals("key.right")) {
|
||||
right = true;
|
||||
speedup = true;
|
||||
}
|
||||
|
||||
if(kb.getKeyDescription().equals("key.sneak")) {
|
||||
if(kb.getId().equals("key.sneak")) {
|
||||
down = true;
|
||||
speedup = true;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class ClassicCameraController implements CameraController {
|
||||
}
|
||||
|
||||
private void setMovement(MoveDirection dir) {
|
||||
float rotationPitch = camera.rotationPitch, rotationYaw = camera.rotationYaw;
|
||||
float rotationPitch = camera.pitch, rotationYaw = camera.yaw;
|
||||
switch(dir) {
|
||||
case BACKWARD:
|
||||
direction = this.getVectorForRotation(-rotationPitch, rotationYaw - 180);
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.replaymod.replay.camera;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.mixin.EntityPlayerAccessor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
@@ -27,17 +27,17 @@ public class SpectatorCameraController implements CameraController {
|
||||
|
||||
@Override
|
||||
public void update(float partialTicksPassed) {
|
||||
Minecraft mc = getMinecraft();
|
||||
if (mc.gameSettings.keyBindSneak.isPressed()) {
|
||||
MinecraftClient mc = getMinecraft();
|
||||
if (mc.options.keySneak.wasPressed()) {
|
||||
ReplayModReplay.instance.getReplayHandler().spectateCamera();
|
||||
}
|
||||
|
||||
// Soak up all remaining key presses
|
||||
for (KeyBinding binding : Arrays.asList(mc.gameSettings.keyBindAttack, mc.gameSettings.keyBindUseItem,
|
||||
mc.gameSettings.keyBindJump, mc.gameSettings.keyBindSneak, mc.gameSettings.keyBindForward,
|
||||
mc.gameSettings.keyBindBack, mc.gameSettings.keyBindLeft, mc.gameSettings.keyBindRight)) {
|
||||
for (KeyBinding binding : Arrays.asList(mc.options.keyAttack, mc.options.keyUse,
|
||||
mc.options.keyJump, mc.options.keySneak, mc.options.keyForward,
|
||||
mc.options.keyBack, mc.options.keyLeft, mc.options.keyRight)) {
|
||||
//noinspection StatementWithEmptyBody
|
||||
while (binding.isPressed());
|
||||
while (binding.wasPressed());
|
||||
}
|
||||
|
||||
// Prevent mouse movement
|
||||
@@ -54,18 +54,18 @@ public class SpectatorCameraController implements CameraController {
|
||||
if (view != null && view != camera) {
|
||||
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;
|
||||
if (view instanceof PlayerEntity) {
|
||||
PlayerEntity viewPlayer = (PlayerEntity) view;
|
||||
//#if MC>=11400
|
||||
//$$ camera.setEquippedStack(EquipmentSlot.HEAD, viewPlayer.getEquippedStack(EquipmentSlot.HEAD));
|
||||
camera.setEquippedStack(EquipmentSlot.HEAD, viewPlayer.getEquippedStack(EquipmentSlot.HEAD));
|
||||
//#else
|
||||
camera.inventory = viewPlayer.inventory;
|
||||
//$$ camera.inventory = viewPlayer.inventory;
|
||||
//#endif
|
||||
EntityPlayerAccessor cameraA = (EntityPlayerAccessor) camera;
|
||||
EntityPlayerAccessor viewPlayerA = (EntityPlayerAccessor) viewPlayer;
|
||||
//#if MC>=10904
|
||||
cameraA.setItemStackMainHand(viewPlayerA.getItemStackMainHand());
|
||||
camera.swingingHand = viewPlayer.swingingHand;
|
||||
camera.preferredHand = viewPlayer.preferredHand;
|
||||
cameraA.setActiveItemStackUseCount(viewPlayerA.getActiveItemStackUseCount());
|
||||
//#else
|
||||
//$$ cameraA.setItemInUse(viewPlayerA.getItemInUse());
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.replaymod.replay.camera;
|
||||
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.vector.Vector3f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.options.KeyBinding;
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.options.GameOptions;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.settings.GameSettings;
|
||||
//#endif
|
||||
@@ -28,15 +28,15 @@ public class VanillaCameraController implements CameraController {
|
||||
|
||||
private int speed;
|
||||
|
||||
public VanillaCameraController(Minecraft mc, CameraEntity camera) {
|
||||
public VanillaCameraController(MinecraftClient mc, CameraEntity camera) {
|
||||
this.camera = camera;
|
||||
GameSettings gameSettings = mc.gameSettings;
|
||||
this.bindings[0] = gameSettings.keyBindForward;
|
||||
this.bindings[1] = gameSettings.keyBindBack;
|
||||
this.bindings[2] = gameSettings.keyBindLeft;
|
||||
this.bindings[3] = gameSettings.keyBindRight;
|
||||
this.bindings[4] = gameSettings.keyBindJump;
|
||||
this.bindings[5] = gameSettings.keyBindSneak;
|
||||
GameOptions gameSettings = mc.options;
|
||||
this.bindings[0] = gameSettings.keyForward;
|
||||
this.bindings[1] = gameSettings.keyBack;
|
||||
this.bindings[2] = gameSettings.keyLeft;
|
||||
this.bindings[3] = gameSettings.keyRight;
|
||||
this.bindings[4] = gameSettings.keyJump;
|
||||
this.bindings[5] = gameSettings.keySneak;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,13 +44,13 @@ 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 (bindings[i].isPressed()) {
|
||||
Vector3f.add(direction, DIRECTIONS[i], direction);
|
||||
}
|
||||
}
|
||||
if (direction.length() == 0) return;
|
||||
direction.normalise(direction); // Normalize, so we don't move quicker if we hold down multiple keys
|
||||
double yawRadians = Math.toRadians(camera.rotationYaw);
|
||||
double yawRadians = Math.toRadians(camera.yaw);
|
||||
float yawSin = (float) Math.sin(yawRadians), yawCos = (float) Math.cos(yawRadians);
|
||||
// Rotate by yaw
|
||||
direction.set(
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
//#if MC<11400
|
||||
package com.replaymod.replay.events;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.minecraftforge.eventbus.api.Cancelable;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
@Cancelable
|
||||
@RequiredArgsConstructor
|
||||
public class ReplayChatMessageEvent extends Event {
|
||||
@Getter
|
||||
private final CameraEntity cameraEntity;
|
||||
}
|
||||
//$$ package com.replaymod.replay.events;
|
||||
//$$
|
||||
//$$ import com.replaymod.replay.camera.CameraEntity;
|
||||
//$$ import lombok.Getter;
|
||||
//$$ import lombok.RequiredArgsConstructor;
|
||||
//$$ import net.minecraftforge.eventbus.api.Cancelable;
|
||||
//$$ import net.minecraftforge.eventbus.api.Event;
|
||||
//$$
|
||||
//$$ @Cancelable
|
||||
//$$ @RequiredArgsConstructor
|
||||
//$$ public class ReplayChatMessageEvent extends Event {
|
||||
//$$ @Getter
|
||||
//$$ private final CameraEntity cameraEntity;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@@ -14,7 +14,7 @@ import de.johni0702.minecraft.gui.function.Typeable;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Point;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -219,7 +219,7 @@ public class GuiMarkerTimeline extends AbstractGuiTimeline<GuiMarkerTimeline> im
|
||||
protected String getTooltipText(RenderInfo renderInfo) {
|
||||
Marker marker = getMarkerAt(renderInfo.mouseX, renderInfo.mouseY);
|
||||
if (marker != null) {
|
||||
return marker.getName() != null ? marker.getName() : I18n.format("replaymod.gui.ingame.unnamedmarker");
|
||||
return marker.getName() != null ? marker.getName() : I18n.translate("replaymod.gui.ingame.unnamedmarker");
|
||||
}
|
||||
return super.getTooltipText(renderInfo);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.WritablePoint;
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.options.GameOptions;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
|
||||
//#if MC>=11300
|
||||
import com.replaymod.core.events.KeyBindingEventCallback;
|
||||
@@ -117,7 +117,7 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||
@Override
|
||||
public void run() {
|
||||
double speed = getSpeedSliderValue();
|
||||
speedSlider.setText(I18n.format("replaymod.gui.speed") + ": " + speed + "x");
|
||||
speedSlider.setText(I18n.translate("replaymod.gui.speed") + ": " + speed + "x");
|
||||
ReplaySender replaySender = replayHandler.getReplaySender();
|
||||
if (!replaySender.paused()) {
|
||||
replaySender.setReplaySpeed(speed);
|
||||
@@ -157,7 +157,7 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||
@Override
|
||||
public void draw(GuiRenderer renderer, ReadableDimension size, RenderInfo renderInfo) {
|
||||
// Do not render overlay when user pressed F1 and we are not currently in some popup
|
||||
if (getMinecraft().gameSettings.hideGUI && isAllowUserInput()) {
|
||||
if (getMinecraft().options.hudHidden && isAllowUserInput()) {
|
||||
// Note that this only applies to when the mouse is visible, otherwise
|
||||
// the draw method isn't called in the first place
|
||||
return;
|
||||
@@ -178,8 +178,8 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onKeyBindingEvent(InputEvent.KeyInputEvent event) {
|
||||
//#endif
|
||||
GameSettings gameSettings = getMinecraft().gameSettings;
|
||||
while (gameSettings.keyBindChat.isPressed() || gameSettings.keyBindCommand.isPressed()) {
|
||||
GameOptions gameSettings = getMinecraft().options;
|
||||
while (gameSettings.keyChat.wasPressed() || gameSettings.keyCommand.wasPressed()) {
|
||||
if (!isMouseVisible()) {
|
||||
setMouseVisible(true);
|
||||
}
|
||||
@@ -196,10 +196,10 @@ public class GuiReplayOverlay extends AbstractGuiOverlay<GuiReplayOverlay> {
|
||||
//$$ if (!Keyboard.getEventKeyState()) return;
|
||||
//$$ int key = Keyboard.getEventKey();
|
||||
//#endif
|
||||
GameSettings gameSettings = getMinecraft().gameSettings;
|
||||
GameOptions gameSettings = getMinecraft().options;
|
||||
// Handle the F1 key binding while the overlay is opened as a gui screen
|
||||
if (isMouseVisible() && key == Keyboard.KEY_F1) {
|
||||
gameSettings.hideGUI = !gameSettings.hideGUI;
|
||||
gameSettings.hudHidden = !gameSettings.hudHidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class GuiModCompatWarning extends AbstractGuiScreen<GuiModCompatWarning>
|
||||
}
|
||||
}
|
||||
|
||||
cancelButton.onClick(() -> getMinecraft().displayGuiScreen(null));
|
||||
cancelButton.onClick(() -> getMinecraft().openScreen(null));
|
||||
loadButton.onClick(() -> {
|
||||
try {
|
||||
mod.startReplay(replayFile, false);
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.google.common.base.Supplier;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.SettableFuture;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.text.TextFormat;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.SettingsRegistry;
|
||||
import com.replaymod.core.gui.GuiReplaySettings;
|
||||
@@ -36,9 +36,9 @@ import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.ReportedException;
|
||||
import net.minecraft.client.gui.menu.NoticeScreen;
|
||||
import net.minecraft.util.crash.CrashReport;
|
||||
import net.minecraft.util.crash.CrashException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOCase;
|
||||
import org.apache.commons.io.filefilter.SuffixFileFilter;
|
||||
@@ -57,9 +57,9 @@ import java.util.List;
|
||||
import static com.replaymod.replay.ReplayModReplay.LOGGER;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.minecraft.text.TranslatableTextComponent;
|
||||
import net.minecraft.text.TranslatableTextComponent;
|
||||
//#else
|
||||
import net.minecraft.client.resources.I18n;
|
||||
//$$ import net.minecraft.client.resources.I18n;
|
||||
//#endif
|
||||
|
||||
public class GuiReplayViewer extends GuiScreen {
|
||||
@@ -141,14 +141,14 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
} catch (IOException e) {
|
||||
// We failed (might also be their OS)
|
||||
e.printStackTrace();
|
||||
getMinecraft().displayGuiScreen(new GuiErrorScreen(
|
||||
getMinecraft().openScreen(new NoticeScreen(
|
||||
//#if MC>=11400
|
||||
//$$ () -> {},
|
||||
//$$ new TranslatableTextComponent("replaymod.gui.viewer.delete.failed1"),
|
||||
//$$ new TranslatableTextComponent("replaymod.gui.viewer.delete.failed2")
|
||||
() -> {},
|
||||
new TranslatableTextComponent("replaymod.gui.viewer.delete.failed1"),
|
||||
new TranslatableTextComponent("replaymod.gui.viewer.delete.failed2")
|
||||
//#else
|
||||
I18n.format("replaymod.gui.viewer.delete.failed1"),
|
||||
I18n.format("replaymod.gui.viewer.delete.failed2")
|
||||
//$$ I18n.format("replaymod.gui.viewer.delete.failed1"),
|
||||
//$$ I18n.format("replaymod.gui.viewer.delete.failed2")
|
||||
//#endif
|
||||
));
|
||||
return;
|
||||
@@ -170,7 +170,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
String name = list.getSelected().name.getText();
|
||||
GuiYesNoPopup popup = GuiYesNoPopup.open(GuiReplayViewer.this,
|
||||
new GuiLabel().setI18nText("replaymod.gui.viewer.delete.linea").setColor(Colors.BLACK),
|
||||
new GuiLabel().setI18nText("replaymod.gui.viewer.delete.lineb", name + TextFormatting.RESET).setColor(Colors.BLACK)
|
||||
new GuiLabel().setI18nText("replaymod.gui.viewer.delete.lineb", name + TextFormat.RESET).setColor(Colors.BLACK)
|
||||
).setYesI18nLabel("replaymod.gui.delete").setNoI18nLabel("replaymod.gui.cancel");
|
||||
Futures.addCallback(popup.getFuture(), new FutureCallback<Boolean>() {
|
||||
@Override
|
||||
@@ -203,7 +203,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
public final GuiButton cancelButton = new GuiButton().onClick(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getMinecraft().displayGuiScreen(null);
|
||||
getMinecraft().openScreen(null);
|
||||
}
|
||||
}).setSize(73, 20).setI18nLabel("replaymod.gui.cancel");
|
||||
|
||||
@@ -225,7 +225,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
try {
|
||||
list.setFolder(mod.getCore().getReplayFolder());
|
||||
} catch (IOException e) {
|
||||
throw new ReportedException(CrashReport.makeCrashReport(e, "Getting replay folder"));
|
||||
throw new CrashException(CrashReport.create(e, "Getting replay folder"));
|
||||
}
|
||||
|
||||
setTitle(new GuiLabel().setI18nText("replaymod.gui.replayviewer"));
|
||||
@@ -404,7 +404,7 @@ public class GuiReplayViewer extends GuiScreen {
|
||||
public GuiReplayEntry(File file, ReplayMetaData metaData, BufferedImage thumbImage) {
|
||||
this.file = file;
|
||||
|
||||
name.setText(TextFormatting.UNDERLINE + Utils.fileNameToReplayName(file.getName()));
|
||||
name.setText(TextFormat.UNDERLINE + Utils.fileNameToReplayName(file.getName()));
|
||||
if (StringUtils.isEmpty(metaData.getServerName())
|
||||
|| !ReplayMod.instance.getSettingsRegistry().get(Setting.SHOW_SERVER_IPS)) {
|
||||
server.setI18nText("replaymod.gui.iphidden").setColor(Colors.DARK_RED);
|
||||
|
||||
@@ -3,19 +3,19 @@ package com.replaymod.replay.handler;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replay.gui.screen.GuiReplayViewer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiIngameMenu;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiMultiplayer;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.menu.PauseMenuScreen;
|
||||
import net.minecraft.client.gui.MainMenuScreen;
|
||||
import net.minecraft.client.gui.menu.MultiplayerScreen;
|
||||
import net.minecraft.client.gui.Screen;
|
||||
import net.minecraft.client.resource.language.I18n;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
//$$ import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
import de.johni0702.minecraft.gui.versions.callbacks.InitScreenCallback;
|
||||
import net.minecraft.client.gui.widget.AbstractButtonWidget;
|
||||
//#else
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//$$ import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
//$$ import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -37,15 +37,15 @@ public class GuiHandler extends EventRegistrations {
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(InitScreenCallback.EVENT, this::injectIntoIngameMenu); }
|
||||
//$$ private void injectIntoIngameMenu(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
{ on(InitScreenCallback.EVENT, this::injectIntoIngameMenu); }
|
||||
private void injectIntoIngameMenu(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
GuiScreen guiScreen = getGui(event);
|
||||
List<GuiButton> buttonList = getButtonList(event);
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void injectIntoIngameMenu(GuiScreenEvent.InitGuiEvent.Post event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//$$ List<GuiButton> buttonList = getButtonList(event);
|
||||
//#endif
|
||||
if (!(guiScreen instanceof GuiIngameMenu)) {
|
||||
if (!(guiScreen instanceof PauseMenuScreen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,19 +54,19 @@ public class GuiHandler extends EventRegistrations {
|
||||
mod.getReplayHandler().getReplaySender().setReplaySpeed(0);
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ final String BUTTON_OPTIONS = I18n.translate("menu.options");
|
||||
//$$ final String BUTTON_EXIT_SERVER = I18n.translate("menu.disconnect");
|
||||
//$$ final String BUTTON_ADVANCEMENTS = I18n.translate("gui.advancements");
|
||||
//$$ final String BUTTON_STATS = I18n.translate("gui.stats");
|
||||
//$$ final String BUTTON_OPEN_TO_LAN = I18n.translate("menu.shareToLan");
|
||||
final String BUTTON_OPTIONS = I18n.translate("menu.options");
|
||||
final String BUTTON_EXIT_SERVER = I18n.translate("menu.disconnect");
|
||||
final String BUTTON_ADVANCEMENTS = I18n.translate("gui.advancements");
|
||||
final String BUTTON_STATS = I18n.translate("gui.stats");
|
||||
final String BUTTON_OPEN_TO_LAN = I18n.translate("menu.shareToLan");
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
final int BUTTON_OPTIONS = 0;
|
||||
//$$ final int BUTTON_OPTIONS = 0;
|
||||
//#endif
|
||||
final int BUTTON_EXIT_SERVER = 1;
|
||||
final int BUTTON_ADVANCEMENTS = 5;
|
||||
final int BUTTON_STATS = 6;
|
||||
final int BUTTON_OPEN_TO_LAN = 7;
|
||||
//$$ final int BUTTON_EXIT_SERVER = 1;
|
||||
//$$ final int BUTTON_ADVANCEMENTS = 5;
|
||||
//$$ final int BUTTON_STATS = 6;
|
||||
//$$ final int BUTTON_OPEN_TO_LAN = 7;
|
||||
//#endif
|
||||
|
||||
|
||||
@@ -74,17 +74,17 @@ public class GuiHandler extends EventRegistrations {
|
||||
//$$ GuiButton openToLan = null;
|
||||
//#endif
|
||||
//#if MC>=11400
|
||||
//$$ AbstractButtonWidget achievements = null, stats = null;
|
||||
//$$ for(AbstractButtonWidget b : new ArrayList<>(buttonList)) {
|
||||
AbstractButtonWidget achievements = null, stats = null;
|
||||
for(AbstractButtonWidget b : new ArrayList<>(buttonList)) {
|
||||
//#else
|
||||
GuiButton achievements = null, stats = null;
|
||||
for(GuiButton b : new ArrayList<>(buttonList)) {
|
||||
//$$ GuiButton achievements = null, stats = null;
|
||||
//$$ for(GuiButton b : new ArrayList<>(buttonList)) {
|
||||
//#endif
|
||||
boolean remove = false;
|
||||
//#if MC>=11400
|
||||
//$$ String id = b.getMessage();
|
||||
String id = b.getMessage();
|
||||
//#else
|
||||
Integer id = b.id;
|
||||
//$$ Integer id = b.id;
|
||||
//#endif
|
||||
if (id.equals(BUTTON_EXIT_SERVER)) {
|
||||
// Replace "Exit Server" button with "Exit Replay" button
|
||||
@@ -96,7 +96,7 @@ public class GuiHandler extends EventRegistrations {
|
||||
b.y,
|
||||
width(b),
|
||||
height(b),
|
||||
I18n.format("replaymod.gui.exit"),
|
||||
I18n.translate("replaymod.gui.exit"),
|
||||
this::onButton
|
||||
));
|
||||
} else if (id.equals(BUTTON_ADVANCEMENTS)) {
|
||||
@@ -114,9 +114,9 @@ public class GuiHandler extends EventRegistrations {
|
||||
//#if MC>=11300
|
||||
} else if (id.equals(BUTTON_OPTIONS)) {
|
||||
//#if MC>=11400
|
||||
//$$ width(b, 204);
|
||||
width(b, 204);
|
||||
//#else
|
||||
width(b, 200);
|
||||
//$$ width(b, 200);
|
||||
//#endif
|
||||
//#endif
|
||||
}
|
||||
@@ -149,9 +149,9 @@ public class GuiHandler extends EventRegistrations {
|
||||
*/
|
||||
private void moveAllButtonsDirectlyBelowUpwards(
|
||||
//#if MC>=11400
|
||||
//$$ List<AbstractButtonWidget> buttons,
|
||||
List<AbstractButtonWidget> buttons,
|
||||
//#else
|
||||
List<GuiButton> buttons,
|
||||
//$$ List<GuiButton> buttons,
|
||||
//#endif
|
||||
int belowY,
|
||||
int xStart,
|
||||
@@ -164,14 +164,14 @@ public class GuiHandler extends EventRegistrations {
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(InitScreenCallback.EVENT, this::ensureReplayStopped); }
|
||||
//$$ private void ensureReplayStopped(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
{ on(InitScreenCallback.EVENT, this::ensureReplayStopped); }
|
||||
private void ensureReplayStopped(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void ensureReplayStopped(GuiScreenEvent.InitGuiEvent event) {
|
||||
GuiScreen guiScreen = getGui(event);
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void ensureReplayStopped(GuiScreenEvent.InitGuiEvent event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//#endif
|
||||
if (!(guiScreen instanceof GuiMainMenu || guiScreen instanceof GuiMultiplayer)) {
|
||||
if (!(guiScreen instanceof MainMenuScreen || guiScreen instanceof MultiplayerScreen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -191,24 +191,24 @@ public class GuiHandler extends EventRegistrations {
|
||||
}
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ { on(InitScreenCallback.EVENT, this::injectIntoMainMenu); }
|
||||
//$$ private void injectIntoMainMenu(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
{ on(InitScreenCallback.EVENT, this::injectIntoMainMenu); }
|
||||
private void injectIntoMainMenu(Screen guiScreen, List<AbstractButtonWidget> buttonList) {
|
||||
//#else
|
||||
@SubscribeEvent
|
||||
public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||
GuiScreen guiScreen = getGui(event);
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void injectIntoMainMenu(GuiScreenEvent.InitGuiEvent event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//#endif
|
||||
if (!(guiScreen instanceof GuiMainMenu)) {
|
||||
if (!(guiScreen instanceof MainMenuScreen)) {
|
||||
return;
|
||||
}
|
||||
GuiButton button = new InjectedButton(
|
||||
ButtonWidget button = new InjectedButton(
|
||||
guiScreen,
|
||||
BUTTON_REPLAY_VIEWER,
|
||||
guiScreen.width / 2 - 100,
|
||||
guiScreen.height / 4 + 10 + 4 * 24,
|
||||
98,
|
||||
20,
|
||||
I18n.format("replaymod.gui.replayviewer"),
|
||||
I18n.translate("replaymod.gui.replayviewer"),
|
||||
this::onButton
|
||||
);
|
||||
addButton(guiScreen, button);
|
||||
@@ -216,24 +216,24 @@ public class GuiHandler extends EventRegistrations {
|
||||
|
||||
//#if MC>=11300
|
||||
private void onButton(InjectedButton button) {
|
||||
GuiScreen guiScreen = button.guiScreen;
|
||||
Screen guiScreen = button.guiScreen;
|
||||
//#else
|
||||
//$$ @SubscribeEvent
|
||||
//$$ public void onButton(GuiScreenEvent.ActionPerformedEvent.Pre event) {
|
||||
//$$ GuiScreen guiScreen = getGui(event);
|
||||
//$$ GuiButton button = getButton(event);
|
||||
//#endif
|
||||
if(!button.enabled) return;
|
||||
if(!button.active) return;
|
||||
|
||||
if (guiScreen instanceof GuiMainMenu) {
|
||||
if (guiScreen instanceof MainMenuScreen) {
|
||||
if (button.id == BUTTON_REPLAY_VIEWER) {
|
||||
new GuiReplayViewer(mod).display();
|
||||
}
|
||||
}
|
||||
|
||||
if (guiScreen instanceof GuiIngameMenu && mod.getReplayHandler() != null) {
|
||||
if (guiScreen instanceof PauseMenuScreen && mod.getReplayHandler() != null) {
|
||||
if (button.id == BUTTON_EXIT_REPLAY) {
|
||||
button.enabled = false;
|
||||
button.active = false;
|
||||
try {
|
||||
mod.getReplayHandler().endReplay();
|
||||
} catch (IOException e) {
|
||||
@@ -243,11 +243,11 @@ public class GuiHandler extends EventRegistrations {
|
||||
}
|
||||
}
|
||||
|
||||
public static class InjectedButton extends GuiButton {
|
||||
public final GuiScreen guiScreen;
|
||||
public static class InjectedButton extends ButtonWidget {
|
||||
public final Screen guiScreen;
|
||||
public final int id;
|
||||
private Consumer<InjectedButton> onClick;
|
||||
public InjectedButton(GuiScreen guiScreen, int buttonId, int x, int y, int width, int height, String buttonText,
|
||||
public InjectedButton(Screen guiScreen, int buttonId, int x, int y, int width, int height, String buttonText,
|
||||
//#if MC>=11300
|
||||
Consumer<InjectedButton> onClick
|
||||
//#else
|
||||
@@ -256,7 +256,7 @@ public class GuiHandler extends EventRegistrations {
|
||||
) {
|
||||
super(
|
||||
//#if MC<11400
|
||||
buttonId,
|
||||
//$$ buttonId,
|
||||
//#endif
|
||||
x,
|
||||
y,
|
||||
@@ -264,7 +264,7 @@ public class GuiHandler extends EventRegistrations {
|
||||
height,
|
||||
buttonText
|
||||
//#if MC>=11400
|
||||
//$$ , self -> onClick.accept((InjectedButton) self)
|
||||
, self -> onClick.accept((InjectedButton) self)
|
||||
//#endif
|
||||
);
|
||||
this.guiScreen = guiScreen;
|
||||
@@ -277,10 +277,10 @@ public class GuiHandler extends EventRegistrations {
|
||||
}
|
||||
|
||||
//#if MC>=11300 && MC<11400
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
onClick.accept(this);
|
||||
}
|
||||
//$$ @Override
|
||||
//$$ public void onClick(double mouseX, double mouseY) {
|
||||
//$$ onClick.accept(this);
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(EntityLivingBase.class)
|
||||
@Mixin(LivingEntity.class)
|
||||
public interface EntityLivingBaseAccessor {
|
||||
//#if MC>=11300
|
||||
@Accessor
|
||||
@Accessor("field_6224")
|
||||
double getInterpTargetX();
|
||||
@Accessor
|
||||
@Accessor("field_6245")
|
||||
double getInterpTargetY();
|
||||
@Accessor
|
||||
@Accessor("field_6263")
|
||||
double getInterpTargetZ();
|
||||
@Accessor
|
||||
@Accessor("field_6284")
|
||||
double getInterpTargetYaw();
|
||||
@Accessor
|
||||
@Accessor("field_6221")
|
||||
double getInterpTargetPitch();
|
||||
//#endif
|
||||
|
||||
//#if MC>=10904
|
||||
@Accessor
|
||||
@Accessor("itemUseTimeLeft")
|
||||
int getActiveItemStackUseCount();
|
||||
@Accessor
|
||||
@Accessor("itemUseTimeLeft")
|
||||
void setActiveItemStackUseCount(int value);
|
||||
//#endif
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(EntityPlayer.class)
|
||||
@Mixin(PlayerEntity.class)
|
||||
public interface EntityPlayerAccessor extends EntityLivingBaseAccessor {
|
||||
//#if MC>=10904
|
||||
@Accessor
|
||||
@Accessor("field_7525")
|
||||
ItemStack getItemStackMainHand();
|
||||
@Accessor
|
||||
@Accessor("field_7525")
|
||||
void setItemStackMainHand(ItemStack value);
|
||||
//#else
|
||||
//$$ @Accessor
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import net.minecraft.client.renderer.FirstPersonRenderer;
|
||||
import net.minecraft.client.render.FirstPersonRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
@@ -8,17 +8,17 @@ import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
@Mixin(FirstPersonRenderer.class)
|
||||
public interface FirstPersonRendererAccessor {
|
||||
//#if MC>=10904
|
||||
@Accessor
|
||||
@Accessor("mainHand")
|
||||
void setItemStackMainHand(ItemStack value);
|
||||
@Accessor
|
||||
@Accessor("offHand")
|
||||
void setItemStackOffHand(ItemStack value);
|
||||
@Accessor
|
||||
@Accessor("equipProgressMainHand")
|
||||
void setEquippedProgressMainHand(float value);
|
||||
@Accessor
|
||||
@Accessor("prevEquipProgressMainHand")
|
||||
void setPrevEquippedProgressMainHand(float value);
|
||||
@Accessor
|
||||
@Accessor("equipProgressOffHand")
|
||||
void setEquippedProgressOffHand(float value);
|
||||
@Accessor
|
||||
@Accessor("prevEquipProgressOffHand")
|
||||
void setPrevEquippedProgressOffHand(float value);
|
||||
//#else
|
||||
//$$ @Accessor
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.replay.mixin;
|
||||
//$$
|
||||
//$$ import com.mojang.blaze3d.platform.GlStateManager;
|
||||
//$$ import com.replaymod.replay.camera.CameraEntity;
|
||||
//$$ import net.minecraft.client.render.Camera;
|
||||
//$$ import net.minecraft.entity.Entity;
|
||||
//$$ import net.minecraft.world.BlockView;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//$$
|
||||
//$$ @Mixin(Camera.class)
|
||||
//$$ public class MixinCamera {
|
||||
//$$ @Inject(
|
||||
//$$ method = "update",
|
||||
//$$ at = @At(
|
||||
//$$ value = "INVOKE",
|
||||
//$$ target = "Lcom/mojang/blaze3d/platform/GlStateManager;rotatef(FFFF)V",
|
||||
//$$ ordinal = 0
|
||||
//$$ )
|
||||
//$$ )
|
||||
//$$ private void applyRoll(BlockView blockView, Entity view, boolean boolean_1, boolean boolean_2, float float_1, CallbackInfo ci) {
|
||||
//$$ if (view instanceof CameraEntity) {
|
||||
//$$ GlStateManager.rotatef(((CameraEntity) view).roll, 0.0F, 0.0F, 1.0F);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.world.BlockView;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Camera.class)
|
||||
public class MixinCamera {
|
||||
@Inject(
|
||||
method = "update",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lcom/mojang/blaze3d/platform/GlStateManager;rotatef(FFFF)V",
|
||||
ordinal = 0
|
||||
)
|
||||
)
|
||||
private void applyRoll(BlockView blockView, Entity view, boolean boolean_1, boolean boolean_2, float float_1, CallbackInfo ci) {
|
||||
if (view instanceof CameraEntity) {
|
||||
GlStateManager.rotatef(((CameraEntity) view).roll, 0.0F, 0.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.client.gui.GuiSpectator;
|
||||
import net.minecraft.client.gui.hud.SpectatorHud;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -10,18 +10,18 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
@Mixin(GuiSpectator.class)
|
||||
@Mixin(SpectatorHud.class)
|
||||
public abstract class MixinGuiSpectator {
|
||||
//#if MC>=10904
|
||||
@Inject(method = "onHotbarSelected", at = @At("HEAD"), cancellable = true)
|
||||
@Inject(method = "method_1976", at = @At("HEAD"), cancellable = true)
|
||||
//#else
|
||||
//$$ @Inject(method = "func_175260_a", at = @At("HEAD"), cancellable = true)
|
||||
//#endif
|
||||
public void isInReplay(
|
||||
//#if MC>=11400
|
||||
//$$ double i,
|
||||
double i,
|
||||
//#else
|
||||
int i,
|
||||
//$$ int i,
|
||||
//#endif
|
||||
CallbackInfo ci
|
||||
) {
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
//#if MC>=11400
|
||||
//$$ package com.replaymod.replay.mixin;
|
||||
//$$
|
||||
//$$ import com.replaymod.replay.events.RenderSpectatorCrosshairCallback;
|
||||
//$$ import net.fabricmc.fabric.api.util.TriState;
|
||||
//$$ import net.minecraft.client.gui.hud.InGameHud;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
//$$
|
||||
//$$ @Mixin(InGameHud.class)
|
||||
//$$ public class MixinInGameHud {
|
||||
//$$ @Inject(method = "shouldRenderSpectatorCrosshair", at = @At("HEAD"), cancellable = true)
|
||||
//$$ private void shouldRenderSpectatorCrosshair(CallbackInfoReturnable<Boolean> ci) {
|
||||
//$$ TriState state = RenderSpectatorCrosshairCallback.EVENT.invoker().shouldRenderSpectatorCrosshair();
|
||||
//$$ if (state != TriState.DEFAULT) {
|
||||
//$$ ci.setReturnValue(state.get());
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.events.RenderSpectatorCrosshairCallback;
|
||||
import net.fabricmc.fabric.api.util.TriState;
|
||||
import net.minecraft.client.gui.hud.InGameHud;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(InGameHud.class)
|
||||
public class MixinInGameHud {
|
||||
@Inject(method = "shouldRenderSpectatorCrosshair", at = @At("HEAD"), cancellable = true)
|
||||
private void shouldRenderSpectatorCrosshair(CallbackInfoReturnable<Boolean> ci) {
|
||||
TriState state = RenderSpectatorCrosshairCallback.EVENT.invoker().shouldRenderSpectatorCrosshair();
|
||||
if (state != TriState.DEFAULT) {
|
||||
ci.setReturnValue(state.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -8,30 +8,30 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraft.client.KeyboardListener;
|
||||
import net.minecraft.client.Keyboard;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11300
|
||||
@Mixin(KeyboardListener.class)
|
||||
@Mixin(Keyboard.class)
|
||||
//#else
|
||||
//$$ @Mixin(Minecraft.class)
|
||||
//#endif
|
||||
public abstract class MixinKeyboardListener {
|
||||
@Inject(
|
||||
//#if MC>=11300
|
||||
method = "onKeyEvent",
|
||||
method = "onKey",
|
||||
//#else
|
||||
//$$ method = "dispatchKeypresses",
|
||||
//#endif
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
//#if MC>=11400
|
||||
//$$ target = "Lnet/minecraft/client/util/ScreenshotUtils;method_1659(Ljava/io/File;IILnet/minecraft/client/gl/GlFramebuffer;Ljava/util/function/Consumer;)V"
|
||||
target = "Lnet/minecraft/client/util/ScreenshotUtils;method_1659(Ljava/io/File;IILnet/minecraft/client/gl/GlFramebuffer;Ljava/util/function/Consumer;)V"
|
||||
//#else
|
||||
//#if MC>=11300
|
||||
target = "Lnet/minecraft/util/ScreenShotHelper;saveScreenshot(Ljava/io/File;IILnet/minecraft/client/shader/Framebuffer;Ljava/util/function/Consumer;)V"
|
||||
//$$ target = "Lnet/minecraft/util/ScreenShotHelper;saveScreenshot(Ljava/io/File;IILnet/minecraft/client/shader/Framebuffer;Ljava/util/function/Consumer;)V"
|
||||
//#else
|
||||
//$$ target = "Lnet/minecraft/util/ScreenShotHelper;saveScreenshot(Ljava/io/File;IILnet/minecraft/client/shader/Framebuffer;)Lnet/minecraft/util/text/ITextComponent;"
|
||||
//#endif
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Queue;
|
||||
public abstract class MixinParticleManager {
|
||||
@Shadow
|
||||
//#if MC>=11300
|
||||
private Queue<Particle> queue;
|
||||
private Queue<Particle> newParticles;
|
||||
//#else
|
||||
//$$ private Queue<Particle> queueEntityFX;
|
||||
//#endif
|
||||
@@ -29,10 +29,10 @@ public abstract class MixinParticleManager {
|
||||
* @param world The new world
|
||||
* @param ci Callback info
|
||||
*/
|
||||
@Inject(method = "clearEffects", at = @At("HEAD"))
|
||||
@Inject(method = "setWorld", at = @At("HEAD"))
|
||||
public void replayModReplay_clearParticleQueue(World world, CallbackInfo ci) {
|
||||
//#if MC>=11300
|
||||
this.queue.clear();
|
||||
this.newParticles.clear();
|
||||
//#else
|
||||
//$$ this.queueEntityFX.clear();
|
||||
//#endif
|
||||
|
||||
@@ -2,9 +2,9 @@ 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.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayerInteractionManager;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -12,40 +12,40 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
//#if MC>=11400
|
||||
//$$ import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
//#else
|
||||
import net.minecraft.world.World;
|
||||
//$$ import net.minecraft.world.World;
|
||||
//#endif
|
||||
|
||||
//#if MC>=11200
|
||||
//#if MC>=11300
|
||||
import net.minecraft.client.util.RecipeBookClient;
|
||||
import net.minecraft.client.recipe.book.ClientRecipeBook;
|
||||
//#else
|
||||
//$$ import net.minecraft.stats.RecipeBook;
|
||||
//#endif
|
||||
//#endif
|
||||
//#if MC>=10904
|
||||
import net.minecraft.stats.StatisticsManager;
|
||||
import net.minecraft.stat.StatHandler;
|
||||
//#else
|
||||
//$$ import net.minecraft.stats.StatFileWriter;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.entity.EntityPlayerSP;
|
||||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//#endif
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
@Mixin(ClientPlayerInteractionManager.class)
|
||||
public abstract class MixinPlayerControllerMP {
|
||||
|
||||
@Shadow
|
||||
private Minecraft mc;
|
||||
private MinecraftClient client;
|
||||
|
||||
@Shadow
|
||||
//#if MC>=10904
|
||||
private NetHandlerPlayClient connection;
|
||||
private ClientPlayNetworkHandler networkHandler;
|
||||
//#else
|
||||
//$$ private NetHandlerPlayClient netClientHandler;
|
||||
//#endif
|
||||
@@ -54,16 +54,16 @@ public abstract class MixinPlayerControllerMP {
|
||||
@Inject(method = "createPlayer", at=@At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_createReplayCamera(
|
||||
//#if MC>=11400
|
||||
//$$ ClientWorld worldIn,
|
||||
ClientWorld worldIn,
|
||||
//#else
|
||||
World worldIn,
|
||||
//$$ World worldIn,
|
||||
//#endif
|
||||
StatisticsManager statisticsManager,
|
||||
RecipeBookClient recipeBookClient,
|
||||
CallbackInfoReturnable<EntityPlayerSP> ci
|
||||
StatHandler statisticsManager,
|
||||
ClientRecipeBook recipeBookClient,
|
||||
CallbackInfoReturnable<ClientPlayerEntity> ci
|
||||
) {
|
||||
if (ReplayModReplay.instance.getReplayHandler() != null) {
|
||||
ci.setReturnValue(new CameraEntity(this.mc, worldIn, this.connection, statisticsManager, recipeBookClient));
|
||||
ci.setReturnValue(new CameraEntity(this.client, worldIn, this.networkHandler, statisticsManager, recipeBookClient));
|
||||
//#else
|
||||
//#if MC>=11200
|
||||
//$$ @Inject(method = "func_192830_a", at=@At("HEAD"), cancellable = true)
|
||||
@@ -97,13 +97,13 @@ public abstract class MixinPlayerControllerMP {
|
||||
|
||||
//#if MC>=10800
|
||||
//#if MC>=11300
|
||||
@Inject(method = "isSpectatorMode", at=@At("HEAD"), cancellable = true)
|
||||
@Inject(method = "isFlyingLocked", at=@At("HEAD"), cancellable = true)
|
||||
//#else
|
||||
//$$ @Inject(method = "isSpectator", at=@At("HEAD"), cancellable = true)
|
||||
//#endif
|
||||
private void replayModReplay_isSpectator(CallbackInfoReturnable<Boolean> ci) {
|
||||
if (this.mc.player instanceof CameraEntity) { // this check should in theory not be required
|
||||
ci.setReturnValue(this.mc.player.isSpectator());
|
||||
if (this.client.player instanceof CameraEntity) { // this check should in theory not be required
|
||||
ci.setReturnValue(this.client.player.isSpectator());
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -2,24 +2,24 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderArrow;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.render.VisibleRegion;
|
||||
import net.minecraft.client.render.entity.EntityRenderer;
|
||||
import net.minecraft.client.render.entity.ArrowEntityRenderer;
|
||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(RenderArrow.class)
|
||||
public abstract class MixinRenderArrow extends Render {
|
||||
protected MixinRenderArrow(RenderManager renderManager) {
|
||||
@Mixin(ArrowEntityRenderer.class)
|
||||
public abstract class MixinRenderArrow extends EntityRenderer {
|
||||
protected MixinRenderArrow(EntityRenderDispatcher renderManager) {
|
||||
super(renderManager);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
||||
public boolean isVisible(Entity entity, VisibleRegion camera, double camX, double camY, double camZ) {
|
||||
// Force arrows to always render, otherwise they stop rendering when you get close to them
|
||||
return ReplayModReplay.instance.getReplayHandler() != null || super.shouldRender(entity, camera, camX, camY, camZ);
|
||||
return ReplayModReplay.instance.getReplayHandler() != null || super.isVisible(entity, camera, camX, camY, camZ);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
//#endif
|
||||
@@ -17,9 +17,9 @@ import net.minecraft.util.Util;
|
||||
public class MixinRenderItem {
|
||||
//#if MC>=11300
|
||||
//#if MC>=11400
|
||||
//$$ @Redirect(method = "renderGlint", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/SystemUtil;getMeasuringTimeMs()J"))
|
||||
@Redirect(method = "renderGlint", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/SystemUtil;getMeasuringTimeMs()J"))
|
||||
//#else
|
||||
@Redirect(method = "renderEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;milliTime()J"))
|
||||
//$$ @Redirect(method = "renderEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;milliTime()J"))
|
||||
//#endif
|
||||
private static long getEnchantmentTime() {
|
||||
//#else
|
||||
@@ -31,7 +31,7 @@ public class MixinRenderItem {
|
||||
return replayHandler.getReplaySender().currentTimeStamp();
|
||||
}
|
||||
//#if MC>=11300
|
||||
return Util.milliTime();
|
||||
return SystemUtil.getMeasuringTimeMs();
|
||||
//#else
|
||||
//$$ return Minecraft.getSystemTime();
|
||||
//#endif
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.camera.CameraEntity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@@ -10,7 +10,7 @@ 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;
|
||||
import net.minecraft.client.render.entity.LivingEntityRenderer;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
//#endif
|
||||
@@ -18,31 +18,31 @@ import net.minecraft.client.renderer.entity.RenderLivingBase;
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
//#if MC>=10904
|
||||
@Mixin(RenderLivingBase.class)
|
||||
@Mixin(LivingEntityRenderer.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 = getMinecraft().player;
|
||||
@Inject(method = "method_4055", at = @At("HEAD"), cancellable = true)
|
||||
private void replayModReplay_canRenderInvisibleName(LivingEntity entity, CallbackInfoReturnable<Boolean> ci) {
|
||||
PlayerEntity thePlayer = getMinecraft().player;
|
||||
if (thePlayer instanceof CameraEntity && entity.isInvisible()) {
|
||||
ci.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = "renderModel",
|
||||
method = "render",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
//#if MC>=11400
|
||||
//$$ target = "Lnet/minecraft/entity/LivingEntity;canSeePlayer(Lnet/minecraft/entity/player/PlayerEntity;)Z"
|
||||
target = "Lnet/minecraft/entity/LivingEntity;canSeePlayer(Lnet/minecraft/entity/player/PlayerEntity;)Z"
|
||||
//#else
|
||||
target = "Lnet/minecraft/entity/EntityLivingBase;isInvisibleToPlayer(Lnet/minecraft/entity/player/EntityPlayer;)Z"
|
||||
//$$ target = "Lnet/minecraft/entity/EntityLivingBase;isInvisibleToPlayer(Lnet/minecraft/entity/player/EntityPlayer;)Z"
|
||||
//#endif
|
||||
)
|
||||
)
|
||||
private boolean replayModReplay_shouldInvisibleNotBeRendered(EntityLivingBase entity, EntityPlayer thePlayer) {
|
||||
return thePlayer instanceof CameraEntity || entity.isInvisibleToPlayer(thePlayer);
|
||||
private boolean replayModReplay_shouldInvisibleNotBeRendered(LivingEntity entity, PlayerEntity thePlayer) {
|
||||
return thePlayer instanceof CameraEntity || entity.canSeePlayer(thePlayer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
// Appears to no longer be needed in 1.14+ (maybe not even 1.13?)
|
||||
//#if MC>=10800 && MC<11400
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import net.minecraft.client.GameSettings;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.world.World;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RenderManager.class)
|
||||
public class MixinRenderManager {
|
||||
@Shadow
|
||||
private float playerViewY;
|
||||
|
||||
@Inject(method = "cacheActiveRenderInfo", at = @At("RETURN"))
|
||||
public void fixHeadRotationForAnimals(World world, FontRenderer font, Entity view, Entity target, GameSettings settings, float partialRenderTick, CallbackInfo ci) {
|
||||
if (view instanceof EntityAnimal && !((EntityAnimal) view).isPlayerSleeping()) {
|
||||
EntityAnimal e = (EntityAnimal) view;
|
||||
this.playerViewY = e.prevRotationYawHead + (e.rotationYawHead - e.prevRotationYawHead) * partialRenderTick;
|
||||
}
|
||||
}
|
||||
}
|
||||
//$$ package com.replaymod.replay.mixin;
|
||||
//$$
|
||||
//$$ import net.minecraft.client.GameSettings;
|
||||
//$$ import net.minecraft.client.gui.FontRenderer;
|
||||
//$$ import net.minecraft.client.renderer.entity.RenderManager;
|
||||
//$$ import net.minecraft.entity.Entity;
|
||||
//$$ import net.minecraft.entity.passive.EntityAnimal;
|
||||
//$$ import net.minecraft.world.World;
|
||||
//$$ import org.spongepowered.asm.mixin.Mixin;
|
||||
//$$ import org.spongepowered.asm.mixin.Shadow;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.At;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
//$$ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
//$$
|
||||
//$$ @Mixin(RenderManager.class)
|
||||
//$$ public class MixinRenderManager {
|
||||
//$$ @Shadow
|
||||
//$$ private float playerViewY;
|
||||
//$$
|
||||
//$$ @Inject(method = "cacheActiveRenderInfo", at = @At("RETURN"))
|
||||
//$$ public void fixHeadRotationForAnimals(World world, FontRenderer font, Entity view, Entity target, GameSettings settings, float partialRenderTick, CallbackInfo ci) {
|
||||
//$$ if (view instanceof EntityAnimal && !((EntityAnimal) view).isPlayerSleeping()) {
|
||||
//$$ EntityAnimal e = (EntityAnimal) view;
|
||||
//$$ this.playerViewY = e.prevRotationYawHead + (e.rotationYawHead - e.prevRotationYawHead) * partialRenderTick;
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@@ -2,21 +2,21 @@ package com.replaymod.replay.mixin;
|
||||
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityEndPortalRenderer;
|
||||
import net.minecraft.client.render.block.entity.EndPortalBlockEntityRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
//#if MC>=11300
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
//#endif
|
||||
|
||||
@Mixin(TileEntityEndPortalRenderer.class)
|
||||
@Mixin(EndPortalBlockEntityRenderer.class)
|
||||
public class MixinTileEntityEndPortalRenderer {
|
||||
//#if MC>=11300
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Util;milliTime()J"))
|
||||
@Redirect(method = "method_3591", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/SystemUtil;getMeasuringTimeMs()J"))
|
||||
//#else
|
||||
//#if MC>=10809
|
||||
//$$ @Redirect(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getSystemTime()J"))
|
||||
@@ -34,7 +34,7 @@ public class MixinTileEntityEndPortalRenderer {
|
||||
return replayHandler.getReplaySender().currentTimeStamp();
|
||||
}
|
||||
//#if MC>=11300
|
||||
return Util.milliTime();
|
||||
return SystemUtil.getMeasuringTimeMs();
|
||||
//#else
|
||||
//$$ return Minecraft.getSystemTime();
|
||||
//#endif
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
//#if MC>=10800
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import net.minecraft.client.renderer.ViewFrustum;
|
||||
import net.minecraft.client.renderer.chunk.RenderChunk;
|
||||
import net.minecraft.client.render.ChunkRenderDispatcher;
|
||||
import net.minecraft.client.render.chunk.ChunkRenderer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ViewFrustum.class)
|
||||
@Mixin(ChunkRenderDispatcher.class)
|
||||
public abstract class MixinViewFrustum {
|
||||
@Redirect(
|
||||
method = "updateChunkPositions",
|
||||
method = "updateCameraPosition",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
//#if MC>=10904
|
||||
target = "Lnet/minecraft/client/renderer/chunk/RenderChunk;setPosition(III)V"
|
||||
target = "Lnet/minecraft/client/render/chunk/ChunkRenderer;method_3653(III)V"
|
||||
//#else
|
||||
//$$ target = "Lnet/minecraft/client/renderer/chunk/RenderChunk;setPosition(Lnet/minecraft/util/BlockPos;)V"
|
||||
//#endif
|
||||
)
|
||||
)
|
||||
private void replayModReplay_updatePositionAndMarkForUpdate(
|
||||
RenderChunk renderChunk,
|
||||
ChunkRenderer renderChunk,
|
||||
//#if MC>=10904
|
||||
int x, int y, int z
|
||||
//#else
|
||||
@@ -32,10 +32,10 @@ public abstract class MixinViewFrustum {
|
||||
//#if MC>=10904
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
//#endif
|
||||
if (!pos.equals(renderChunk.getPosition())) {
|
||||
if (!pos.equals(renderChunk.getOrigin())) {
|
||||
//#if MC>=10904
|
||||
renderChunk.setPosition(x, y, z);
|
||||
renderChunk.setNeedsUpdate(false);
|
||||
renderChunk.method_3653(x, y, z);
|
||||
renderChunk.scheduleRender(false);
|
||||
//#else
|
||||
//$$ renderChunk.setPosition(pos);
|
||||
//$$ renderChunk.setNeedsUpdate(true);
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
package com.replaymod.replay.mixin;
|
||||
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.entity.Entity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(WorldClient.class)
|
||||
@Mixin(ClientWorld.class)
|
||||
public abstract class MixinWorldClient {
|
||||
|
||||
// Looks like this has finally been fixed in 1.14 (or been moved somewhere else entirely, guess we'll find out)
|
||||
//#if MC<11400
|
||||
/**
|
||||
* Fixes a bug in vanilla Minecraft that leaves entities remaining in the entityList even after respawn.
|
||||
* The entityList in WorldClient is a Set that assumes that the entity ID of its entities does not change.
|
||||
* However in {@link WorldClient#addEntityToWorld(int, Entity)}, the entity passed in is first added to the
|
||||
* set and subsequently its id is changed, leaving it stuck in he Set. That is the buggy method.
|
||||
* This wouldn't be too much of a problem if the entity had the correct id to begin with, however the handler for
|
||||
* the spawn player packet creates an EntityOtherPlayerMP which takes its id from a counter and then passes it to
|
||||
* this method with the wrong id.
|
||||
* This mixin fixes the id of the entity before it is added to the set instead of right after.
|
||||
* The original id change right after is not changed, however it should not have any effect.
|
||||
* @param entityId The id to be set for the entity
|
||||
* @param entity The entity to be added
|
||||
* @param ci Callback info
|
||||
*/
|
||||
@Inject(method = "addEntityToWorld", at=@At("HEAD"))
|
||||
public void replayModReplay_fix_addEntityToWorld(int entityId, Entity entity, CallbackInfo ci) {
|
||||
entity.setEntityId(entityId);
|
||||
}
|
||||
//$$ /**
|
||||
//$$ * Fixes a bug in vanilla Minecraft that leaves entities remaining in the entityList even after respawn.
|
||||
//$$ * The entityList in WorldClient is a Set that assumes that the entity ID of its entities does not change.
|
||||
//$$ * However in {@link WorldClient#addEntityToWorld(int, Entity)}, the entity passed in is first added to the
|
||||
//$$ * set and subsequently its id is changed, leaving it stuck in he Set. That is the buggy method.
|
||||
//$$ * This wouldn't be too much of a problem if the entity had the correct id to begin with, however the handler for
|
||||
//$$ * the spawn player packet creates an EntityOtherPlayerMP which takes its id from a counter and then passes it to
|
||||
//$$ * this method with the wrong id.
|
||||
//$$ * This mixin fixes the id of the entity before it is added to the set instead of right after.
|
||||
//$$ * The original id change right after is not changed, however it should not have any effect.
|
||||
//$$ * @param entityId The id to be set for the entity
|
||||
//$$ * @param entity The entity to be added
|
||||
//$$ * @param ci Callback info
|
||||
//$$ */
|
||||
//$$ @Inject(method = "addEntityToWorld", at=@At("HEAD"))
|
||||
//$$ public void replayModReplay_fix_addEntityToWorld(int entityId, Entity entity, CallbackInfo ci) {
|
||||
//$$ entity.setEntityId(entityId);
|
||||
//$$ }
|
||||
//#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user