Complete all currently actionable 1.13.2 FIXMEs
This commit is contained in:
@@ -74,7 +74,7 @@ public class ReplayModRecording implements Module {
|
||||
new GuiHandler(core).register();
|
||||
|
||||
//#if MC>=11300
|
||||
// FIXME
|
||||
NetworkRegistry.newEventChannel(Restrictions.PLUGIN_CHANNEL, () -> "0", any -> true, any -> true);
|
||||
//#else
|
||||
//$$ NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler());
|
||||
//#endif
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//#if MC>=11300
|
||||
package com.replaymod.recording.mixin;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import com.replaymod.recording.packet.ResourcePackRecorder;
|
||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||
import net.minecraft.client.resources.DownloadingPackFinder;
|
||||
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.Redirect;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Mixin(DownloadingPackFinder.class)
|
||||
public abstract class MixinDownloadingPackFinder implements ResourcePackRecorder.IDownloadingPackFinder {
|
||||
private Consumer<File> requestCallback;
|
||||
|
||||
@Override
|
||||
public void setRequestCallback(Consumer<File> callback) {
|
||||
requestCallback = callback;
|
||||
}
|
||||
|
||||
@Shadow
|
||||
public abstract ListenableFuture<Object> func_195741_a(File file);
|
||||
|
||||
@Redirect(method = "downloadResourcePack", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/DownloadingPackFinder;func_195741_a(Ljava/io/File;)Lcom/google/common/util/concurrent/ListenableFuture;"))
|
||||
private ListenableFuture<Object> recordDownloadedPack(DownloadingPackFinder downloadingPackFinder, File file) {
|
||||
if (requestCallback != null) {
|
||||
requestCallback.consume(file);
|
||||
requestCallback = null;
|
||||
}
|
||||
return func_195741_a(file);
|
||||
}
|
||||
}
|
||||
//#endif
|
||||
@@ -1,34 +1,32 @@
|
||||
package com.replaymod.recording.mixin;
|
||||
|
||||
//#if MC>=10904
|
||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
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.Redirect;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
@Mixin(PlayerControllerMP.class)
|
||||
public abstract class MixinPlayerControllerMP implements RecordingEventHandler.RecordingEventSender {
|
||||
|
||||
@Shadow
|
||||
private Minecraft mc;
|
||||
|
||||
// Redirects the call to playEvent without the initial player argument to the method with that argument
|
||||
// The new method will then play it and (if applicable) record it. (See MixinWorldClient)
|
||||
// This is necessary for the block break event (particles and sound) to be recorded. Otherwise it looks like the
|
||||
// event was emitted because of a packet (player will be null) and not as it actually was (by the player).
|
||||
/* FIXME test if this is still an issue (the call seems to be gone)
|
||||
@Redirect(method = "onPlayerDestroyBlock", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/World;playEvent(ILnet/minecraft/util/math/BlockPos;I)V"))
|
||||
public void replayModRecording_playEvent_fixed(World world, int type, BlockPos pos, int data) {
|
||||
world.playEvent(player(mc), type, pos, data);
|
||||
}
|
||||
*/
|
||||
}
|
||||
//#if MC>=10904 && MC<11300
|
||||
//$$ import com.replaymod.recording.handler.RecordingEventHandler;
|
||||
//$$ import net.minecraft.client.Minecraft;
|
||||
//$$ import net.minecraft.client.multiplayer.PlayerControllerMP;
|
||||
//$$ import net.minecraft.util.math.BlockPos;
|
||||
//$$ 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.Redirect;
|
||||
//$$
|
||||
//$$ import static com.replaymod.core.versions.MCVer.*;
|
||||
//$$
|
||||
//$$ @Mixin(PlayerControllerMP.class)
|
||||
//$$ public abstract class MixinPlayerControllerMP implements RecordingEventHandler.RecordingEventSender {
|
||||
//$$
|
||||
//$$ @Shadow
|
||||
//$$ private Minecraft mc;
|
||||
//$$
|
||||
//$$ // Redirects the call to playEvent without the initial player argument to the method with that argument
|
||||
//$$ // The new method will then play it and (if applicable) record it. (See MixinWorldClient)
|
||||
//$$ // This is necessary for the block break event (particles and sound) to be recorded. Otherwise it looks like the
|
||||
//$$ // event was emitted because of a packet (player will be null) and not as it actually was (by the player).
|
||||
//$$ @Redirect(method = "onPlayerDestroyBlock", at = @At(value = "INVOKE",
|
||||
//$$ target = "Lnet/minecraft/world/World;playEvent(ILnet/minecraft/util/math/BlockPos;I)V"))
|
||||
//$$ public void replayModRecording_playEvent_fixed(World world, int type, BlockPos pos, int data) {
|
||||
//$$ world.playEvent(player(mc), type, pos, data);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
@@ -33,7 +33,9 @@ import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.network.EnumPacketDirection;
|
||||
// FIXME import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
//#if MC<11300
|
||||
//$$ import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.network.internal.FMLProxyPacket;
|
||||
//#endif
|
||||
@@ -244,18 +246,18 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
/* FIXME
|
||||
if (packet instanceof FMLProxyPacket) {
|
||||
// This packet requires special handling
|
||||
//#if MC<11300
|
||||
//$$ if (packet instanceof FMLProxyPacket) {
|
||||
//$$ // This packet requires special handling
|
||||
//#if MC>=10800
|
||||
((FMLProxyPacket) packet).toS3FPackets().forEach(this::save);
|
||||
//$$ ((FMLProxyPacket) packet).toS3FPackets().forEach(this::save);
|
||||
//#else
|
||||
//$$ save(((FMLProxyPacket) packet).toS3FPacket());
|
||||
//#endif
|
||||
super.channelRead(ctx, msg);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
//$$ super.channelRead(ctx, msg);
|
||||
//$$ return;
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
save(packet);
|
||||
|
||||
|
||||
@@ -4,19 +4,20 @@ import com.google.common.hash.Hashing;
|
||||
import com.google.common.io.Files;
|
||||
import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreenWorking;
|
||||
import net.minecraft.client.gui.GuiYesNo;
|
||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.HttpUtil;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
//#if MC>=11300
|
||||
// FIXME
|
||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||
import net.minecraft.client.resources.DownloadingPackFinder;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.gui.GuiScreenWorking;
|
||||
//$$ import net.minecraft.client.resources.ResourcePackRepository;
|
||||
//$$ import net.minecraft.util.HttpUtil;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10904
|
||||
@@ -38,7 +39,9 @@ import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
//#if MC<11300
|
||||
//$$ import org.apache.commons.io.FileUtils;
|
||||
//#endif
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
//#else
|
||||
@@ -141,8 +144,7 @@ public class ResourcePackRecorder {
|
||||
|
||||
if (levelDir.isFile()) {
|
||||
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
|
||||
/* FIXME
|
||||
Futures.addCallback(setServerResourcePack(mc.getResourcePackRepository(), levelDir), new FutureCallback<Object>() {
|
||||
Futures.addCallback(setServerResourcePack(levelDir), new FutureCallback<Object>() {
|
||||
@Override
|
||||
public void onSuccess(Object result) {
|
||||
recordResourcePack(levelDir, requestId);
|
||||
@@ -154,7 +156,6 @@ public class ResourcePackRecorder {
|
||||
netManager.sendPacket(makeStatusPacket(hash, Action.FAILED_DOWNLOAD));
|
||||
}
|
||||
});
|
||||
*/
|
||||
} else {
|
||||
netManager.sendPacket(makeStatusPacket(hash, Action.FAILED_DOWNLOAD));
|
||||
}
|
||||
@@ -162,7 +163,7 @@ public class ResourcePackRecorder {
|
||||
final ServerData serverData = mc.getCurrentServerData();
|
||||
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
|
||||
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
|
||||
// FIXME downloadResourcePackFuture(requestId, url, hash);
|
||||
downloadResourcePackFuture(requestId, url, hash);
|
||||
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
|
||||
netManager.sendPacket(makeStatusPacket(hash, Action.DECLINED));
|
||||
} else {
|
||||
@@ -180,7 +181,7 @@ public class ResourcePackRecorder {
|
||||
}
|
||||
if (result) {
|
||||
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
|
||||
// FIXME downloadResourcePackFuture(requestId, url, hash);
|
||||
downloadResourcePackFuture(requestId, url, hash);
|
||||
} else {
|
||||
netManager.sendPacket(makeStatusPacket(hash, Action.DECLINED));
|
||||
}
|
||||
@@ -199,7 +200,6 @@ public class ResourcePackRecorder {
|
||||
//#endif
|
||||
}
|
||||
|
||||
/* FIXME
|
||||
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
|
||||
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
|
||||
@Override
|
||||
@@ -214,101 +214,112 @@ public class ResourcePackRecorder {
|
||||
});
|
||||
}
|
||||
|
||||
//#if MC>=11300
|
||||
private ListenableFuture downloadResourcePack(final int requestId, String url, String hash) {
|
||||
final ResourcePackRepository repo = mc.mcResourcePackRepository;
|
||||
String fileName;
|
||||
if (hash.matches("^[a-f0-9]{40}$")) {
|
||||
fileName = hash;
|
||||
} else {
|
||||
fileName = url.substring(url.lastIndexOf("/") + 1);
|
||||
DownloadingPackFinder packFinder = mc.getPackFinder();
|
||||
((IDownloadingPackFinder) packFinder).setRequestCallback(file -> recordResourcePack(file, requestId));
|
||||
return packFinder.downloadResourcePack(url, hash);
|
||||
}
|
||||
|
||||
if (fileName.contains("?")) {
|
||||
fileName = fileName.substring(0, fileName.indexOf("?"));
|
||||
}
|
||||
|
||||
if (!fileName.endsWith(".zip")) {
|
||||
return Futures.immediateFailedFuture(new IllegalArgumentException("Invalid filename; must end in .zip"));
|
||||
}
|
||||
|
||||
fileName = "legacy_" + fileName.replaceAll("\\W", "");
|
||||
}
|
||||
|
||||
final File file = new File(repo.dirServerResourcepacks, fileName);
|
||||
public interface IDownloadingPackFinder {
|
||||
void setRequestCallback(Consumer<File> callback);
|
||||
}
|
||||
//#else
|
||||
//$$ private ListenableFuture downloadResourcePack(final int requestId, String url, String hash) {
|
||||
//$$ final ResourcePackRepository repo = mc.mcResourcePackRepository;
|
||||
//$$ String fileName;
|
||||
//$$ if (hash.matches("^[a-f0-9]{40}$")) {
|
||||
//$$ fileName = hash;
|
||||
//$$ } else {
|
||||
//$$ fileName = url.substring(url.lastIndexOf("/") + 1);
|
||||
//$$
|
||||
//$$ if (fileName.contains("?")) {
|
||||
//$$ fileName = fileName.substring(0, fileName.indexOf("?"));
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ if (!fileName.endsWith(".zip")) {
|
||||
//$$ return Futures.immediateFailedFuture(new IllegalArgumentException("Invalid filename; must end in .zip"));
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ fileName = "legacy_" + fileName.replaceAll("\\W", "");
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ final File file = new File(repo.dirServerResourcepacks, fileName);
|
||||
//#if MC>=10809
|
||||
repo.lock.lock();
|
||||
//$$ repo.lock.lock();
|
||||
//#else
|
||||
//$$ repo.field_177321_h.lock();
|
||||
//#endif
|
||||
try {
|
||||
//$$ try {
|
||||
//#if MC>=10809
|
||||
repo.clearResourcePack();
|
||||
//$$ repo.clearResourcePack();
|
||||
//#else
|
||||
//$$ repo.func_148529_f();
|
||||
//#endif
|
||||
|
||||
if (file.exists() && hash.length() == 40) {
|
||||
try {
|
||||
String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
||||
if (fileHash.equals(hash)) {
|
||||
recordResourcePack(file, requestId);
|
||||
return setServerResourcePack(repo, file);
|
||||
}
|
||||
|
||||
logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
||||
FileUtils.deleteQuietly(file);
|
||||
} catch (IOException ioexception) {
|
||||
logger.warn("File " + file + " couldn\'t be hashed. Deleting it.", ioexception);
|
||||
FileUtils.deleteQuietly(file);
|
||||
}
|
||||
}
|
||||
|
||||
final GuiScreenWorking guiScreen = new GuiScreenWorking();
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
||||
|
||||
//$$
|
||||
//$$ if (file.exists() && hash.length() == 40) {
|
||||
//$$ try {
|
||||
//$$ String fileHash = Hashing.sha1().hashBytes(Files.toByteArray(file)).toString();
|
||||
//$$ if (fileHash.equals(hash)) {
|
||||
//$$ recordResourcePack(file, requestId);
|
||||
//$$ return setServerResourcePack(file);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ logger.warn("File " + file + " had wrong hash (expected " + hash + ", found " + fileHash + "). Deleting it.");
|
||||
//$$ FileUtils.deleteQuietly(file);
|
||||
//$$ } catch (IOException ioexception) {
|
||||
//$$ logger.warn("File " + file + " couldn\'t be hashed. Deleting it.", ioexception);
|
||||
//$$ FileUtils.deleteQuietly(file);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ final GuiScreenWorking guiScreen = new GuiScreenWorking();
|
||||
//$$ final Minecraft mc = Minecraft.getMinecraft();
|
||||
//$$
|
||||
//$$ Futures.getUnchecked(mc.addScheduledTask(() -> mc.displayGuiScreen(guiScreen)));
|
||||
//$$
|
||||
//#if MC>=10809
|
||||
//#if MC>=11002
|
||||
//#if MC>=11100
|
||||
Map<String, String> sessionInfo = ResourcePackRepository.getDownloadHeaders();
|
||||
//$$ Map<String, String> sessionInfo = ResourcePackRepository.getDownloadHeaders();
|
||||
//#else
|
||||
//$$ Map<String, String> sessionInfo = ResourcePackRepository.func_190115_a();
|
||||
//#endif
|
||||
//#else
|
||||
//$$ Map<String, String> sessionInfo = Minecraft.getSessionInfo();
|
||||
//#endif
|
||||
repo.downloadingPacks = HttpUtil.downloadResourcePack(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||
Futures.addCallback(repo.downloadingPacks, new FutureCallback<Object>() {
|
||||
//$$ repo.downloadingPacks = HttpUtil.downloadResourcePack(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||
//$$ Futures.addCallback(repo.downloadingPacks, new FutureCallback<Object>() {
|
||||
//#else
|
||||
//$$ Map sessionInfo = Minecraft.getSessionInfo();
|
||||
//$$ repo.field_177322_i = HttpUtil.func_180192_a(file, url, sessionInfo, 50 * 1024 * 1024, guiScreen, mc.getProxy());
|
||||
//$$ Futures.addCallback(repo.field_177322_i, new FutureCallback() {
|
||||
//#endif
|
||||
@Override
|
||||
public void onSuccess(Object value) {
|
||||
recordResourcePack(file, requestId);
|
||||
setServerResourcePack(repo, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@Nonnull Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
});
|
||||
//$$ @Override
|
||||
//$$ public void onSuccess(Object value) {
|
||||
//$$ recordResourcePack(file, requestId);
|
||||
//$$ setServerResourcePack(file);
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public void onFailure(@Nonnull Throwable throwable) {
|
||||
//$$ throwable.printStackTrace();
|
||||
//$$ }
|
||||
//$$ });
|
||||
//#if MC>=10809
|
||||
return repo.downloadingPacks;
|
||||
//$$ return repo.downloadingPacks;
|
||||
//#else
|
||||
//$$ return repo.field_177322_i;
|
||||
//#endif
|
||||
} finally {
|
||||
//$$ } finally {
|
||||
//#if MC>=10809
|
||||
repo.lock.unlock();
|
||||
//$$ repo.lock.unlock();
|
||||
//#else
|
||||
//$$ repo.field_177321_h.unlock();
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
*/
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
//#else
|
||||
//$$ public synchronized S3FPacketCustomPayload handleResourcePack(S3FPacketCustomPayload packet) {
|
||||
//$$ final int requestId = nextRequestId++;
|
||||
|
||||
Reference in New Issue
Block a user