Start update to 1.13

This commit is contained in:
Jonas Herzig
2018-12-19 09:44:21 +01:00
parent 65295b311e
commit 9655677972
37 changed files with 793 additions and 245 deletions

View File

@@ -1,3 +1,6 @@
apply plugin: 'eclipse'
apply plugin: 'idea'
import groovy.json.JsonOutput
def latestVersion = file('version.txt').readLines().first()

View File

@@ -1,3 +1,5 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.parallel=

View File

@@ -2,5 +2,5 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
distributionSha256Sum=69d99ade952de3727b65a88f3188ee72231ff4e28c2d00aacfc96a42c6d6f303
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
distributionSha256Sum=39e2d5803bbd5eaf6c8efe07067b0e5a00235e8c71318642b2ed262920b27721

2
jGui

Submodule jGui updated: 43a5816075...48b3d75950

View File

@@ -1,11 +1,12 @@
include ':jGui'
[
'core',
'1.7.10',
'1.8',
'1.8.9',
'1.9.4',
'1.12'
//'1.7.10', FIXME
//'1.8', FIXME
//'1.8.9', FIXME
//'1.9.4',
//'1.12',
'1.13'
].each { version ->
include ":jGui:$version"
project(":jGui:$version").with {
@@ -16,16 +17,17 @@ include ':jGui'
def versions = [
'core',
'1.7.10',
'1.8',
'1.8.9',
'1.9.4',
'1.10.2',
'1.11',
'1.11.2',
'1.12',
'1.12.1',
'1.12.2'
//'1.7.10', FIXME
//'1.8', FIXME
//'1.8.9', FIXME
//'1.9.4',
//'1.10.2',
//'1.11',
//'1.11.2',
//'1.12',
//'1.12.1',
//'1.12.2',
'1.13'
]
versions.each { version ->
include ":$version"

View File

@@ -6,12 +6,19 @@ import com.replaymod.core.versions.MCVer;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.util.ReportedException;
import org.lwjgl.input.Keyboard;
//#if MC>=11300
//#else
//$$ import org.lwjgl.input.Keyboard;
//#endif
//#if MC>=10800
//#if MC>=11300
import net.minecraftforge.eventbus.api.SubscribeEvent;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#endif
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
//#else
@@ -95,24 +102,25 @@ public class KeyBindingRegistry {
} catch (Throwable cause) {
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Key Binding");
CrashReportCategory category = crashReport.makeCategory("Key Binding");
category.addCrashSection("Key Binding", keyBinding);
MCVer.addDetail(category, "Key Binding", keyBinding::toString);
MCVer.addDetail(category, "Handler", runnable::toString);
throw new ReportedException(crashReport);
throw newReportedException(crashReport);
}
}
}
public void handleRaw() {
int keyCode = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
//int keyCode = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() + 256 : Keyboard.getEventKey();
int keyCode = -1; // FIXME
for (final Runnable runnable : rawHandlers.get(keyCode)) {
try {
runnable.run();
} catch (Throwable cause) {
CrashReport crashReport = CrashReport.makeCrashReport(cause, "Handling Raw Key Binding");
CrashReportCategory category = crashReport.makeCategory("Key Binding");
category.addCrashSection("Key Code", keyCode);
MCVer.addDetail(category, "Key Code", () -> "" + keyCode);
MCVer.addDetail(category, "Handler", runnable::toString);
throw new ReportedException(crashReport);
throw newReportedException(crashReport);
}
}
}

View File

@@ -1,3 +1,4 @@
/* FIXME
package com.replaymod.core;
import org.apache.logging.log4j.LogManager;
@@ -96,3 +97,4 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
}
}
*/

View File

@@ -6,17 +6,26 @@ import com.replaymod.core.gui.GuiReplaySettings;
import com.replaymod.core.gui.RestoreReplayGui;
import com.replaymod.core.handler.MainMenuHandler;
import com.replaymod.core.utils.OpenGLUtils;
import com.replaymod.core.versions.MCVer;
import com.replaymod.recording.ReplayModRecording;
import com.replaymod.replaystudio.util.I18n;
import de.johni0702.minecraft.gui.container.GuiScreen;
import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.FolderResourcePack;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.FileUtils;
//#if MC>=11300
import net.minecraft.resources.FolderPack;
import net.minecraft.resources.IResourcePack;
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
//#else
//$$ import net.minecraft.client.resources.FolderResourcePack;
//$$ import net.minecraft.client.resources.IResourcePack;
//#endif
//#if MC>=10904
import net.minecraft.util.text.*;
//#else
@@ -28,18 +37,24 @@ import net.minecraft.util.text.*;
//#endif
//#if MC>=10800
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.common.Loader;
//#if MC>=11300
import net.minecraft.client.GameSettings;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
//#else
//$$ import net.minecraft.client.settings.GameSettings;
//$$ import net.minecraftforge.fml.client.FMLClientHandler;
//$$ import net.minecraftforge.fml.common.Loader;
//$$ import net.minecraftforge.fml.common.Mod.EventHandler;
//$$ import net.minecraftforge.fml.common.Mod.Instance;
//$$ import net.minecraftforge.fml.common.ModContainer;
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#endif
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.ModContainer;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventBus;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
//#else
//$$ import cpw.mods.fml.common.Loader;
@@ -50,7 +65,6 @@ import net.minecraftforge.fml.common.gameevent.TickEvent;
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
//$$ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
//$$ import cpw.mods.fml.common.eventhandler.EventBus;
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
//$$ import cpw.mods.fml.common.gameevent.TickEvent;
//$$ import com.replaymod.replay.InputReplayTimer;
@@ -62,37 +76,50 @@ import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.FutureTask;
import static com.replaymod.core.versions.MCVer.*;
@Mod(modid = ReplayMod.MOD_ID,
useMetadata = true,
version = "@MOD_VERSION@",
acceptedMinecraftVersions = "@MC_VERSION@",
acceptableRemoteVersions = "*",
//#if MC>=11300
@Mod(ReplayMod.MOD_ID)
//#else
//$$ @Mod(modid = ReplayMod.MOD_ID,
//$$ useMetadata = true,
//$$ version = "@MOD_VERSION@",
//$$ acceptedMinecraftVersions = "@MC_VERSION@",
//$$ acceptableRemoteVersions = "*",
//#if MC>=10800
clientSideOnly = true,
updateJSON = "https://raw.githubusercontent.com/ReplayMod/ReplayMod/master/versions.json",
//$$ clientSideOnly = true,
//$$ updateJSON = "https://raw.githubusercontent.com/ReplayMod/ReplayMod/master/versions.json",
//#endif
guiFactory = "com.replaymod.core.gui.GuiFactory")
//$$ guiFactory = "com.replaymod.core.gui.GuiFactory")
//#endif
public class ReplayMod {
public static ModContainer getContainer() {
return Loader.instance().getIndexedModList().get(MOD_ID);
//#if MC>=11300
return ModList.get().getModContainerById(MOD_ID).get();
//#else
//$$ return Loader.instance().getIndexedModList().get(MOD_ID);
//#endif
}
@Getter(lazy = true)
private static final String minecraftVersion = Loader.MC_VERSION;
//#if MC>=11300
private static final String minecraftVersion = "1.13"; // FIXME
//#else
//$$ private static final String minecraftVersion = Loader.MC_VERSION;
//#endif
public static final String MOD_ID = "replaymod";
public static final ResourceLocation TEXTURE = new ResourceLocation("replaymod", "replay_gui.png");
public static final int TEXTURE_SIZE = 256;
private static final Minecraft mc = Minecraft.getMinecraft();
private static final Minecraft mc = MCVer.getMinecraft();
@Deprecated
public static Configuration config;
@@ -101,9 +128,18 @@ public class ReplayMod {
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
// The instance of your mod that Forge uses.
@Instance(MOD_ID)
//#if MC>=11300
{ instance = this; }
//#else
//$$ @Instance(MOD_ID)
//#endif
public static ReplayMod instance;
private final List<Module> modules = new ArrayList<>();
{
modules.add(new ReplayModRecording(this));
}
public KeyBindingRegistry getKeyBindingRegistry() {
return keyBindingRegistry;
}
@@ -114,12 +150,16 @@ public class ReplayMod {
public File getReplayFolder() throws IOException {
String path = getSettingsRegistry().get(Setting.RECORDING_PATH);
File folder = new File(path.startsWith("./") ? getMinecraft().mcDataDir : null, path);
File folder = new File(path.startsWith("./") ? mcDataDir(getMinecraft()) : null, path);
FileUtils.forceMkdir(folder);
return folder;
}
@EventHandler
//#if MC>=11300
{ FMLModLoadingContext.get().getModEventBus().addListener(this::preInit); }
//#else
//$$ @EventHandler
//#endif
public void preInit(FMLPreInitializationEvent event) {
// Initialize the static OpenGL info field from the minecraft main thread
// Unfortunately lwjgl uses static methods so we have to make use of magic init calls as well
@@ -127,20 +167,35 @@ public class ReplayMod {
I18n.setI18n(net.minecraft.client.resources.I18n::format);
config = new Configuration(event.getSuggestedConfigurationFile());
config.load();
//#if MC>=11300
config = new Configuration(new File(mcDataDir(mc), "configs/replaymod.cfg")); // FIXME where'd the suggestion go?
//#else
//$$ config = new Configuration(event.getSuggestedConfigurationFile());
//#endif
// FIXME forge config api is currently broken config.load();
settingsRegistry.setConfiguration(config);
modules.forEach(m -> m.preInit(event));
}
//#ifdef DEV_ENV
static { // Note: even preInit is too late and we'd have to issue another resource reload
@SuppressWarnings("unchecked")
List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
FolderResourcePack jGuiResourcePack = new FolderResourcePack(new File("../jGui/src/main/resources")) {
//#if MC>=11300
List<IResourcePack> defaultResourcePacks = new ArrayList<>(); // FIXME: probably replaced with DownloadingPackFinder
FolderPack jGuiResourcePack = new FolderPack(new File("../jGui/src/main/resources")) {
@Override
protected InputStream getInputStreamByName(String resourceName) throws IOException {
protected InputStream getInputStream(String resourceName) throws IOException {
try {
return super.getInputStreamByName(resourceName);
return super.getInputStream(resourceName);
//#else
//$$ List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
//$$ FolderResourcePack jGuiResourcePack = new FolderResourcePack(new File("../jGui/src/main/resources")) {
//$$ @Override
//$$ protected InputStream getInputStreamByName(String resourceName) throws IOException {
//$$ try {
//$$ return super.getInputStreamByName(resourceName);
//#endif
} catch (IOException e) {
if ("pack.mcmeta".equals(resourceName)) {
return new ByteArrayInputStream(("{\"pack\": {\"description\": \"dummy pack for jGui resources in dev-env\", \"pack_format\": 1}}").getBytes(Charsets.UTF_8));
@@ -169,7 +224,11 @@ public class ReplayMod {
}
//#endif
@EventHandler
//#if MC>=11300
{ FMLModLoadingContext.get().getModEventBus().addListener(this::init); }
//#else
//$$ @EventHandler
//#endif
public void init(FMLInitializationEvent event) {
getSettingsRegistry().register(Setting.class);
@@ -183,15 +242,21 @@ public class ReplayMod {
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
new GuiReplaySettings(null, settingsRegistry).display();
});
modules.forEach(m -> m.init(event));
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) throws IOException {
//#if MC>=11300
{ FMLModLoadingContext.get().getModEventBus().addListener(this::postInit); }
//#else
//$$ @EventHandler
//#endif
public void postInit(FMLPostInitializationEvent event) {
settingsRegistry.save(); // Save default values to disk
// 1.7.10 crashes when render distance > 16
//#if MC>=10800
if(!FMLClientHandler.instance().hasOptifine())
//if(!FMLClientHandler.instance().hasOptifine()) FIXME 1.13 update
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
//#endif
@@ -229,6 +294,8 @@ public class ReplayMod {
e.printStackTrace();
}
});
modules.forEach(m -> m.postInit(event));
}
/**
@@ -240,19 +307,18 @@ public class ReplayMod {
public void runLater(Runnable runnable) {
if (mc.isCallingFromMinecraftThread() && inRunLater) {
EventBus bus = FORGE_BUS;
//#if MC>=10800
bus.register(new Object() {
FORGE_BUS.register(new Object() {
@SubscribeEvent
public void onRenderTick(TickEvent.RenderTickEvent event) {
if (event.phase == TickEvent.Phase.START) {
runLater(runnable);
bus.unregister(this);
FORGE_BUS.unregister(this);
}
}
});
//#else
//$$ bus.register(new RunLaterHelper(runnable));
//$$ FORGE_BUS.register(new RunLaterHelper(runnable));
//#endif
return;
}
@@ -309,7 +375,11 @@ public class ReplayMod {
//#endif
public String getVersion() {
return getContainer().getVersion();
//#if MC>=11300
return getContainer().getModInfo().getVersion().toString();
//#else
//$$ return getContainer().getVersion();
//#endif
}
private void testIfMoeshAndExitMinecraft() {
@@ -332,6 +402,7 @@ public class ReplayMod {
private void printToChat(boolean warning, String message, Object... args) {
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
/* FIXME: needs RuntimeInvisibleParameterAnnotations workaround
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
//#if MC>=10904
Style coloredDarkGray = new Style().setColor(TextFormatting.DARK_GRAY);
@@ -352,7 +423,14 @@ public class ReplayMod {
//#endif
// Send message to chat GUI
// The ingame GUI is initialized at startup, therefore this is possible before the client is connected
mc.ingameGUI.getChatGUI().printChatMessage(text);
*/
mc.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation(message, args));
}
}
public static abstract class Module {
public void preInit(FMLPreInitializationEvent event) {}
public void init(FMLInitializationEvent event) {}
public void postInit(FMLPostInitializationEvent event) {}
}
}

View File

@@ -88,7 +88,7 @@ public class SettingsRegistry {
}
public void save() {
configuration.save();
// FIXME forge config api is currently broken configuration.save();
}
public interface SettingKey<T> {

View File

@@ -5,7 +5,11 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
//#if MC>=10800
import net.minecraftforge.fml.common.eventhandler.Event;
//#if MC>=11300
import net.minecraftforge.eventbus.api.Event;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.Event;
//#endif
//#else
//$$ import cpw.mods.fml.common.eventhandler.Event;
//#endif

View File

@@ -9,7 +9,11 @@ import net.minecraftforge.common.MinecraftForge;
import org.lwjgl.opengl.GL11;
//#if MC>=10800
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#if MC>=11300
import net.minecraftforge.eventbus.api.SubscribeEvent;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#endif
//#else
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
//#endif
@@ -41,21 +45,25 @@ public class MainMenuHandler {
// and then move back down by 10 to compensate for the space to the exit button that was already there
int offset = -2 * 24 + 10;
y(button, y(button) + offset);
//#if MC>=11202
}
/* FIXME
//#if MC>=11300
if (button == gui.realmsButton) {
realmsOffset = offset;
}
//#endif
}
//#if MC>=11202
//#if MC>=11300
if (realmsOffset != 0 && gui.realmsNotification instanceof GuiScreenRealmsProxy) {
gui.realmsNotification = new RealmsNotificationProxy((GuiScreenRealmsProxy) gui.realmsNotification, realmsOffset);
}
//#endif
*/
}
}
//#if MC>=11202
/* FIXME
//#if MC>=11300
private static class RealmsNotificationProxy extends GuiScreen {
private final GuiScreenRealmsProxy proxy;
private final int offset;
@@ -98,4 +106,5 @@ public class MainMenuHandler {
}
}
//#endif
*/
}

View File

@@ -14,8 +14,12 @@ import net.minecraftforge.registries.RegistryManager;
//#endif
//#if MC>=10800
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
//#if MC>=11300
// FIXME
//#else
//$$ import net.minecraftforge.fml.common.Loader;
//$$ import net.minecraftforge.fml.common.ModContainer;
//#endif
//#else
//$$ import cpw.mods.fml.common.Loader;
//$$ import cpw.mods.fml.common.ModContainer;
@@ -29,16 +33,19 @@ import java.util.stream.Stream;
public class ModCompat {
@SuppressWarnings("unchecked")
public static Collection<ModInfo> getInstalledNetworkMods() {
Map<String, ModContainer> ignoreCaseMap = Loader.instance().getModList().stream()
.collect(Collectors.toMap(m -> m.getModId().toLowerCase(), Function.identity()));
//#if MC>=11300
return Stream.<ModInfo>empty().collect(Collectors.toList());
//#else
//$$ Map<String, ModContainer> ignoreCaseMap = Loader.instance().getModList().stream()
//$$ .collect(Collectors.toMap(m -> m.getModId().toLowerCase(), Function.identity()));
//#if MC>=11200
return RegistryManager.ACTIVE.takeSnapshot(false).keySet().stream()
.map(RegistryManager.ACTIVE::getRegistry)
.map(ForgeRegistry::getKeys).flatMap(Set::stream)
.map(ResourceLocation::getResourceDomain).filter(s -> !s.equals("minecraft")).distinct()
.map(String::toLowerCase).map(ignoreCaseMap::get).filter(mod -> mod != null)
.map(mod -> new ModInfo(mod.getModId(), mod.getName(), mod.getVersion()))
.collect(Collectors.toList());
//$$ return RegistryManager.ACTIVE.takeSnapshot(false).keySet().stream()
//$$ .map(RegistryManager.ACTIVE::getRegistry)
//$$ .map(ForgeRegistry::getKeys).flatMap(Set::stream)
//$$ .map(ResourceLocation::getResourceDomain).filter(s -> !s.equals("minecraft")).distinct()
//$$ .map(String::toLowerCase).map(ignoreCaseMap::get).filter(mod -> mod != null)
//$$ .map(mod -> new ModInfo(mod.getModId(), mod.getName(), mod.getVersion()))
//$$ .collect(Collectors.toList());
//#else
//#if MC>=10800
//$$ return Stream.concat(
@@ -61,6 +68,7 @@ public class ModCompat {
//$$ .collect(Collectors.toList());
//#endif
//#endif
//#endif
}
public static final class ModInfoDifference {

View File

@@ -11,7 +11,13 @@ public class OpenGLUtils {
static {
IntBuffer buffer = BufferUtils.createIntBuffer(16);
GL11.glGetInteger(GL11.GL_MAX_VIEWPORT_DIMS, buffer);
//#if MC>=11300
// FIXME GL11.glGetIntegerv(GL11.GL_MAX_VIEWPORT_DIMS, buffer);
buffer.put(0xffff);
buffer.put(0xffff);
//#else
//$$ GL11.glGetInteger(GL11.GL_MAX_VIEWPORT_DIMS, buffer);
//#endif
VIEWPORT_MAX_WIDTH = buffer.get();
VIEWPORT_MAX_HEIGHT = buffer.get();
}

View File

@@ -18,6 +18,7 @@ import static com.replaymod.core.versions.MCVer.readString;
* @see <a href="https://gist.github.com/Johni0702/2547c463e51f65f312cb">Replay Restrictions Gist</a>
*/
public class Restrictions {
// FIXME these should be ResourceLocations now
public static final String PLUGIN_CHANNEL = "Replay|Restrict";
private boolean noXray;
private boolean noNoclip;

View File

@@ -18,15 +18,19 @@ import de.johni0702.minecraft.gui.layout.HorizontalLayout;
import de.johni0702.minecraft.gui.layout.VerticalLayout;
import de.johni0702.minecraft.gui.popup.GuiInfoPopup;
import de.johni0702.minecraft.gui.utils.Colors;
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.crash.CrashReport;
import net.minecraft.util.ResourceLocation;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.FilenameUtils;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import org.lwjgl.util.Dimension;
import org.lwjgl.util.ReadableDimension;
//#if MC>=11300
//#else
//$$ import org.lwjgl.input.Keyboard;
//#endif
//#if MC>=10800
import net.minecraft.client.network.NetworkPlayerInfo;
@@ -64,7 +68,8 @@ import java.util.Date;
import java.util.UUID;
import java.util.function.Consumer;
import static net.minecraft.client.Minecraft.getMinecraft;
import static com.replaymod.core.versions.MCVer.Minecraft_mcDataDir;
import static com.replaymod.core.versions.MCVer.getMinecraft;
public class Utils {
@@ -189,7 +194,11 @@ public class Utils {
}
public static boolean isCtrlDown() {
return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
//#if MC>=11300
return GuiScreen.isCtrlKeyDown();
//#else
//$$ return Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL);
//#endif
}
public static <T> void addCallback(ListenableFuture<T> future, Consumer<T> onSuccess, Consumer<Throwable> onFailure) {
@@ -216,7 +225,7 @@ public class Utils {
// Try to save the crash report
if (crashReport.getFile() == null) {
try {
File folder = new File(getMinecraft().mcDataDir, "crash-reports");
File folder = new File(Minecraft_mcDataDir(getMinecraft()), "crash-reports");
File file = new File(folder, "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-client.txt");
logger.debug("Saving crash report to file: {}", file);
crashReport.saveToFile(file);
@@ -262,8 +271,8 @@ public class Utils {
l -> new GuiLabel().setText(l).setColor(Colors.BLACK)).toArray(GuiElement[]::new)));
// Replace close button with panel containing close and copy buttons
GuiButton copyToClipboardButton = new GuiButton().setI18nLabel("chat.copy").onClick(() ->
GuiScreen.setClipboardString(crashReport)).setSize(150, 20);
GuiButton copyToClipboardButton = new GuiButton().setI18nLabel("chat.copy")/* FIXME .onClick(() ->
//GuiScreen.setClipboardString(crashReport))*/.setSize(150, 20);
GuiButton closeButton = getCloseButton();
popup.removeElement(closeButton);
popup.addElements(new VerticalLayout.Data(1),

View File

@@ -8,15 +8,27 @@ public class WrappedTimer extends Timer {
protected final Timer wrapped;
public WrappedTimer(Timer wrapped) {
super(0);
//#if MC>=11300
super(0, 0);
//#else
//$$ super(0);
//#endif
this.wrapped = wrapped;
copy(wrapped, this);
}
@Override
public void updateTimer() {
public void updateTimer(
//#if MC>=11300
long sysClock
//#endif
) {
copy(this, wrapped);
wrapped.updateTimer();
wrapped.updateTimer(
//#if MC>=11300
sysClock
//#endif
);
copy(wrapped, this);
}
@@ -26,7 +38,7 @@ public class WrappedTimer extends Timer {
to.lastSyncSysClock = from.lastSyncSysClock;
to.elapsedPartialTicks = from.elapsedPartialTicks;
//#if MC>=11200
to.tickLength = from.tickLength;
// FIXME (should be good to go once AT are applied) to.tickLength = from.tickLength;
//#else
//$$ to.ticksPerSecond = from.ticksPerSecond;
//$$ to.lastHRTime = from.lastHRTime;

View File

@@ -6,21 +6,22 @@ import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.multiplayer.ServerList;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.resources.ResourcePackRepository;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.Packet;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Util;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.client.event.GuiScreenEvent;
@@ -28,6 +29,20 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.common.MinecraftForge;
//#if MC>=11300
import net.minecraft.client.MainWindow;
import net.minecraft.crash.ReportedException;
import org.lwjgl.glfw.GLFW;
//#else
//$$ import net.minecraft.client.gui.ScaledResolution;
//$$ import net.minecraft.client.resources.ResourcePackRepository;
//$$ import net.minecraft.util.ReportedException;
//$$ import org.apache.logging.log4j.LogManager;
//$$ import org.lwjgl.Sys;
//$$ import java.awt.Desktop;
//#endif
//#if MC>=10904
//#if MC>=11200
import net.minecraft.client.renderer.BufferBuilder;
@@ -53,9 +68,13 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
//#if MC>=10800
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.BooleanState;
// FIXME import net.minecraft.client.renderer.GlStateManager.BooleanState;
import net.minecraft.world.WorldType;
import net.minecraftforge.fml.common.eventhandler.EventBus;
//#if MC>=11300
import net.minecraftforge.eventbus.api.IEventBus;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.EventBus;
//#endif
//#else
//$$ import com.google.common.util.concurrent.Futures;
//$$ import com.replaymod.render.hooks.GLStateTracker;
@@ -77,12 +96,17 @@ import java.util.concurrent.Callable;
* Abstraction over things that have changed between different MC versions.
*/
public class MCVer {
public static EventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
//#if MC>=11300
public static IEventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
public static IEventBus FML_BUS = FORGE_BUS;
//#else
//$$ public static EventBus FORGE_BUS = MinecraftForge.EVENT_BUS;
//#if MC>=10809
public static EventBus FML_BUS = FORGE_BUS;
//$$ public static EventBus FML_BUS = FORGE_BUS;
//#else
//$$ public static EventBus FML_BUS = FMLCommonHandler.instance().bus();
//#endif
//#endif
public static void addDetail(CrashReportCategory category, String name, Callable<String> callable) {
//#if MC>=10904
@@ -218,6 +242,14 @@ public class MCVer {
//#endif
//#endif
public static File mcDataDir(Minecraft mc) {
//#if MC>=11300
return mc.gameDir;
//#else
//$$ return mc.mcDataDir;
//#endif
}
//#if MC>=10800
public static Entity getRenderViewEntity(Minecraft mc) {
return mc.getRenderViewEntity();
@@ -297,9 +329,13 @@ public class MCVer {
return world.playerEntities;
}
/* FIXME
public static BooleanState fog() {
//#if MC>=11300
return GlStateManager.FOG.fog;
//#else
//#if MC>=10809
return GlStateManager.fogState.fog;
//$$ return GlStateManager.fogState.fog;
//#else
//#if MC>=10800
//$$ return GlStateManager.fogState.field_179049_a;
@@ -307,11 +343,15 @@ public class MCVer {
//$$ return GLStateTracker.getInstance().fog;
//#endif
//#endif
//#endif
}
public static void fog(BooleanState fog) {
//#if MC>=11300
GlStateManager.FOG.fog = fog;
//#else
//#if MC>=10809
GlStateManager.fogState.fog = fog;
//$$ GlStateManager.fogState.fog = fog;
//#else
//#if MC>=10800
//$$ GlStateManager.fogState.field_179049_a = fog;
@@ -319,23 +359,33 @@ public class MCVer {
//$$ GLStateTracker.getInstance().fog = fog;
//#endif
//#endif
//#endif
}
public static BooleanState texture2DState(int index) {
//#if MC>=11300
return GlStateManager.TEXTURES[index].texture2DState;
//#else
//#if MC>=10800
return GlStateManager.textureState[index].texture2DState;
//$$ return GlStateManager.textureState[index].texture2DState;
//#else
//$$ return GLStateTracker.getInstance().texture[index];
//#endif
//#endif
}
public static void texture2DState(int index, BooleanState texture2DState) {
//#if MC>=11300
GlStateManager.TEXTURES[index].texture2DState = texture2DState;
//#else
//#if MC>=10800
GlStateManager.textureState[index].texture2DState = texture2DState;
//$$ GlStateManager.textureState[index].texture2DState = texture2DState;
//#else
//$$ GLStateTracker.getInstance().texture[index] = texture2DState;
//#endif
//#endif
}
*/
public static void ServerList_saveSingleServer(ServerData serverData) {
//#if MC>=10904
@@ -353,14 +403,22 @@ public class MCVer {
//#endif
}
public static ScaledResolution newScaledResolution(Minecraft mc) {
//#if MC>=10809
return new ScaledResolution(mc);
//#else
//$$ return new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
//#endif
}
//#if MC>=11300
public static MainWindow newScaledResolution(Minecraft mc) {
return mc.mainWindow;
}
//#else
//$$ public static ScaledResolution newScaledResolution(Minecraft mc) {
//#if MC>=10809
//$$ return new ScaledResolution(mc);
//#else
//$$ return new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
//#endif
//$$ }
//#endif
/* FIXME
public static ListenableFuture setServerResourcePack(ResourcePackRepository repo, File file) {
//#if MC>=10809
//#if MC>=11200
@@ -379,6 +437,7 @@ public class MCVer {
//#endif
//#endif
}
*/
public static boolean isKeyDown(KeyBinding keyBinding) {
//#if MC>=10800
@@ -523,12 +582,28 @@ public class MCVer {
public static RenderManager getRenderManager() {
//#if MC>=10800
return Minecraft.getMinecraft().getRenderManager();
return getMinecraft().getRenderManager();
//#else
//$$ return RenderManager.instance;
//#endif
}
public static Minecraft getMinecraft() {
//#if MC>=11300
return Minecraft.getInstance();
//#else
//$$ return Minecraft.getMinecraft();
//#endif
}
public static File Minecraft_mcDataDir(Minecraft mc) {
//#if MC>=11300
return mc.gameDir;
//#else
//$$ return mc.mcDataDir;
//#endif
}
public static int floor(double val) {
//#if MC>=11102
return MathHelper.floor(val);
@@ -537,6 +612,14 @@ public class MCVer {
//#endif
}
public static void bindTexture(ResourceLocation texture) {
//#if MC>=11300
getMinecraft().getTextureManager().bindTexture(texture);
//#else
//$$ getMinecraft().renderEngine.bindTexture(texture);
//#endif
}
public static float cos(float val) {
return MathHelper.cos(val);
}
@@ -545,6 +628,40 @@ public class MCVer {
return MathHelper.sin(val);
}
public static ReportedException newReportedException(CrashReport crashReport) {
return new ReportedException(crashReport);
}
public static void openFile(File file) {
//#if MC>=11300
Util.getOSType().openFile(file);
//#else
//$$ String path = file.getAbsolutePath();
//$$
//$$ // First try OS specific methods
//$$ try {
//$$ switch (Util.getOSType()) {
//$$ case WINDOWS:
//$$ Runtime.getRuntime().exec(String.format("cmd.exe /C start \"Open file\" \"%s\"", path));
//$$ return;
//$$ case OSX:
//$$ Runtime.getRuntime().exec(new String[]{"/usr/bin/open", path});
//$$ return;
//$$ }
//$$ } catch (IOException e) {
//$$ LogManager.getLogger().error("Cannot open file", e);
//$$ }
//$$
//$$ // Otherwise try to java way
//$$ try {
//$$ Desktop.getDesktop().browse(file.toURI());
//$$ } catch (Throwable throwable) {
//$$ // And if all fails, lwjgl
//$$ Sys.openURL("file://" + path);
//$$ }
//#endif
}
//#if MC<=10710
//$$ public static class GlStateManager {
//$$ public static void resetColor() { /* nop */ }
@@ -561,4 +678,53 @@ public class MCVer {
//$$ public static void rotate(float angle, float x, float y, float z) { glRotatef(angle, x, y, z); }
//$$ }
//#endif
//#if MC>=11300
public static void color(float r, float g, float b, float a) { GlStateManager.color4f(r, g, b, a); }
public static void enableAlpha() { GlStateManager.enableAlphaTest(); }
public static void disableAlpha() { GlStateManager.disableAlphaTest(); }
public static void tryBlendFuncSeparate(int l, int r, int vl, int vr) { GlStateManager.blendFuncSeparate(l, r, vl, vr); }
public static void colorLogicOp(int op) { GlStateManager.logicOp(op); }
public static abstract class Keyboard {
public static final int KEY_ESCAPE = GLFW.GLFW_KEY_ESCAPE;
public static final int KEY_HOME = GLFW.GLFW_KEY_HOME;
public static final int KEY_END = GLFW.GLFW_KEY_END;
public static final int KEY_UP = GLFW.GLFW_KEY_UP;
public static final int KEY_DOWN = GLFW.GLFW_KEY_DOWN;
public static final int KEY_LEFT = GLFW.GLFW_KEY_LEFT;
public static final int KEY_RIGHT = GLFW.GLFW_KEY_RIGHT;
public static final int KEY_BACK = GLFW.GLFW_KEY_BACKSPACE;
public static final int KEY_DELETE = GLFW.GLFW_KEY_DELETE;
public static final int KEY_RETURN = GLFW.GLFW_KEY_ENTER;
public static final int KEY_TAB = GLFW.GLFW_KEY_TAB;
public static final int KEY_F1 = GLFW.GLFW_KEY_F1;
public static final int KEY_A = GLFW.GLFW_KEY_A;
public static final int KEY_B = GLFW.GLFW_KEY_B;
public static final int KEY_C = GLFW.GLFW_KEY_C;
public static final int KEY_D = GLFW.GLFW_KEY_D;
public static final int KEY_E = GLFW.GLFW_KEY_E;
public static final int KEY_F = GLFW.GLFW_KEY_F;
public static final int KEY_G = GLFW.GLFW_KEY_G;
public static final int KEY_H = GLFW.GLFW_KEY_H;
public static final int KEY_I = GLFW.GLFW_KEY_I;
public static final int KEY_J = GLFW.GLFW_KEY_J;
public static final int KEY_K = GLFW.GLFW_KEY_K;
public static final int KEY_L = GLFW.GLFW_KEY_L;
public static final int KEY_M = GLFW.GLFW_KEY_M;
public static final int KEY_N = GLFW.GLFW_KEY_N;
public static final int KEY_O = GLFW.GLFW_KEY_O;
public static final int KEY_P = GLFW.GLFW_KEY_P;
public static final int KEY_Q = GLFW.GLFW_KEY_Q;
public static final int KEY_R = GLFW.GLFW_KEY_R;
public static final int KEY_S = GLFW.GLFW_KEY_S;
public static final int KEY_T = GLFW.GLFW_KEY_T;
public static final int KEY_U = GLFW.GLFW_KEY_U;
public static final int KEY_V = GLFW.GLFW_KEY_V;
public static final int KEY_W = GLFW.GLFW_KEY_W;
public static final int KEY_X = GLFW.GLFW_KEY_X;
public static final int KEY_Y = GLFW.GLFW_KEY_Y;
public static final int KEY_Z = GLFW.GLFW_KEY_Z;
}
//#endif
}

View File

@@ -5,53 +5,54 @@ import com.replaymod.core.utils.Restrictions;
import com.replaymod.recording.handler.ConnectionEventHandler;
import com.replaymod.recording.handler.GuiHandler;
import com.replaymod.recording.packet.PacketListener;
import io.netty.channel.Channel;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandler;
import io.netty.util.AttributeKey;
import net.minecraft.network.NetworkManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
//#if MC>=11300
import com.replaymod.core.versions.MCVer.Keyboard;
//#else
//$$ import org.lwjgl.input.Keyboard;
//#endif
//#if MC>=10800
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.EventBus;
import net.minecraftforge.fml.common.network.NetworkRegistry;
//#if MC>=11300
import net.minecraftforge.fml.network.NetworkRegistry;
//#else
//$$ import net.minecraftforge.fml.common.network.NetworkRegistry;
//#endif
//#else
//$$ import cpw.mods.fml.common.Mod;
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
//$$ import cpw.mods.fml.common.eventhandler.EventBus;
//$$ import cpw.mods.fml.common.network.NetworkRegistry;
//#endif
import static com.replaymod.core.versions.MCVer.*;
@Mod(modid = ReplayModRecording.MOD_ID,
version = "@MOD_VERSION@",
acceptedMinecraftVersions = "@MC_VERSION@",
acceptableRemoteVersions = "*",
//#if MC>=10800
clientSideOnly = true,
//#endif
useMetadata = true)
public class ReplayModRecording {
public static final String MOD_ID = "replaymod-recording";
public class ReplayModRecording extends ReplayMod.Module {
@Mod.Instance(MOD_ID)
private static final Logger LOGGER = LogManager.getLogger();
private static final AttributeKey<Void> ATTR_CHECKED = AttributeKey.newInstance("ReplayModRecording_checked");
{ instance = this; }
public static ReplayModRecording instance;
private ReplayMod core;
private Logger logger;
private ConnectionEventHandler connectionEventHandler;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
logger = event.getModLog();
core = ReplayMod.instance;
public ReplayModRecording(ReplayMod mod) {
core = mod;
}
@Override
public void preInit(FMLPreInitializationEvent event) {
core.getSettingsRegistry().register(Setting.class);
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.marker", Keyboard.KEY_M, new Runnable() {
@@ -66,20 +67,27 @@ public class ReplayModRecording {
});
}
@Mod.EventHandler
@Override
public void init(FMLInitializationEvent event) {
EventBus bus = FML_BUS;
bus.register(connectionEventHandler = new ConnectionEventHandler(logger, core));
FML_BUS.register(connectionEventHandler = new ConnectionEventHandler(LOGGER, core));
new GuiHandler(core).register();
NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler());
//#if MC>=11300
// FIXME
//#else
//$$ NetworkRegistry.INSTANCE.newChannel(Restrictions.PLUGIN_CHANNEL, new RestrictionsChannelHandler());
//#endif
}
@ChannelHandler.Sharable
private static class RestrictionsChannelHandler extends ChannelDuplexHandler {}
public void initiateRecording(NetworkManager networkManager) {
Channel channel = networkManager.channel();
if (channel.pipeline().get("ReplayModReplay_replaySender") != null) return;
if (channel.hasAttr(ATTR_CHECKED)) return;
channel.attr(ATTR_CHECKED).set(null);
connectionEventHandler.onConnectedToServerEvent(networkManager);
}
}

View File

@@ -10,8 +10,12 @@ import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.common.MinecraftForge;
//#if MC>=10800
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#if MC>=11300
import net.minecraftforge.eventbus.api.SubscribeEvent;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#endif
import static net.minecraft.client.renderer.GlStateManager.*;
//#else
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
//#endif
@@ -50,9 +54,9 @@ public class GuiRecordingOverlay {
if (settingsRegistry.get(Setting.INDICATOR)) {
FontRenderer fontRenderer = getFontRenderer(mc);
fontRenderer.drawString(I18n.format("replaymod.gui.recording").toUpperCase(), 30, 18 - (fontRenderer.FONT_HEIGHT / 2), 0xffffffff);
mc.renderEngine.bindTexture(TEXTURE);
GlStateManager.resetColor();
GlStateManager.enableAlpha();
bindTexture(TEXTURE);
resetColor();
enableAlpha();
Gui.drawModalRectWithCustomSizedTexture(10, 10, 58, 20, 16, 16, TEXTURE_SIZE, TEXTURE_SIZE);
}
}

View File

@@ -15,8 +15,12 @@ import net.minecraft.network.NetworkManager;
import org.apache.logging.log4j.Logger;
//#if MC>=10800
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent;
//#if MC>=11300
import net.minecraftforge.eventbus.api.SubscribeEvent;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//$$ import net.minecraftforge.fml.common.network.FMLNetworkEvent.ClientDisconnectionFromServerEvent;
//#endif
import static com.replaymod.core.versions.MCVer.WorldType_DEBUG_ALL_BLOCK_STATES;
//#else
@@ -28,6 +32,8 @@ import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import static com.replaymod.core.versions.MCVer.getMinecraft;
/**
* Handles connection events and initiates recording if enabled.
*/
@@ -36,7 +42,7 @@ public class ConnectionEventHandler {
private static final String packetHandlerKey = "packet_handler";
private static final String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss";
private static final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
private static final Minecraft mc = Minecraft.getMinecraft();
private static final Minecraft mc = getMinecraft();
private final Logger logger;
private final ReplayMod core;
@@ -55,7 +61,11 @@ public class ConnectionEventHandler {
boolean local = networkManager.isLocalChannel();
if (local) {
//#if MC>=10800
if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
//#if MC>=11300
if (mc.getIntegratedServer().getWorld(0).getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
//#else
//$$ if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
//#endif
logger.info("Debug World recording is not supported.");
return;
}
@@ -74,10 +84,10 @@ public class ConnectionEventHandler {
String worldName;
if (local) {
worldName = mc.getIntegratedServer().getWorldName();
} else if (Minecraft.getMinecraft().getCurrentServerData() != null) {
worldName = Minecraft.getMinecraft().getCurrentServerData().serverIP;
} else if (mc.getCurrentServerData() != null) {
worldName = mc.getCurrentServerData().serverIP;
//#if MC>=11100
} else if (Minecraft.getMinecraft().isConnectedToRealms()) {
} else if (mc.isConnectedToRealms()) {
// we can't access the server name without tapping too deep in the Realms Library
worldName = "A Realms Server";
//#endif
@@ -97,7 +107,7 @@ public class ConnectionEventHandler {
ReplayMetaData metaData = new ReplayMetaData();
metaData.setSingleplayer(local);
metaData.setServerName(worldName);
metaData.setGenerator("ReplayMod v" + ReplayMod.getContainer().getVersion());
metaData.setGenerator("ReplayMod v" + ReplayMod.instance.getVersion());
metaData.setDate(System.currentTimeMillis());
metaData.setMcVersion(ReplayMod.getMinecraftVersion());
packetListener = new PacketListener(replayFile, metaData);
@@ -116,6 +126,7 @@ public class ConnectionEventHandler {
}
}
/* FIXME event not (yet?) in 1.13
@SubscribeEvent
public void onDisconnectedFromServerEvent(ClientDisconnectionFromServerEvent event) {
if (packetListener != null) {
@@ -126,6 +137,7 @@ public class ConnectionEventHandler {
packetListener = null;
}
}
*/
public PacketListener getPacketListener() {
return packetListener;

View File

@@ -1,34 +1,36 @@
package com.replaymod.recording.handler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
//#if MC<11300
//$$ package com.replaymod.recording.handler;
//$$
//$$ import io.netty.channel.ChannelHandlerContext;
//$$ import io.netty.channel.SimpleChannelInboundHandler;
//$$
//#if MC>=10800
import net.minecraftforge.fml.common.network.handshake.FMLHandshakeMessage;
//$$ import net.minecraftforge.fml.common.network.handshake.FMLHandshakeMessage;
//#else
//$$ import cpw.mods.fml.common.network.handshake.FMLHandshakeMessage;
//#endif
/**
* Filters out all handshake packets that were sent for recording but must
* not actually be handled.
* This handler is only present when connected to the integrated server as
* otherwise all packets must be handled.
*
* When in single player, the game state packets must never be handled
* otherwise wired bugs related to semi-singletons can occur.
* See https://bugs.replaymod.com/show_bug.cgi?id=44
*/
public class FMLHandshakeFilter extends SimpleChannelInboundHandler<FMLHandshakeMessage> {
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLHandshakeMessage msg) throws Exception {
//$$
//$$ /**
//$$ * Filters out all handshake packets that were sent for recording but must
//$$ * not actually be handled.
//$$ * This handler is only present when connected to the integrated server as
//$$ * otherwise all packets must be handled.
//$$ *
//$$ * When in single player, the game state packets must never be handled
//$$ * otherwise wired bugs related to semi-singletons can occur.
//$$ * See https://bugs.replaymod.com/show_bug.cgi?id=44
//$$ */
//$$ public class FMLHandshakeFilter extends SimpleChannelInboundHandler<FMLHandshakeMessage> {
//$$ @Override
//$$ protected void channelRead0(ChannelHandlerContext ctx, FMLHandshakeMessage msg) throws Exception {
//#if MC>=10800
if (!(msg instanceof FMLHandshakeMessage.RegistryData)) {
//$$ if (!(msg instanceof FMLHandshakeMessage.RegistryData)) {
//#else
//$$ if (!(msg instanceof FMLHandshakeMessage.ModIdData)) {
//#endif
// Pass on everything but RegistryData messages
ctx.fireChannelRead(msg);
}
}
}
//$$ // Pass on everything but RegistryData messages
//$$ ctx.fireChannelRead(msg);
//$$ }
//$$ }
//$$ }
//#endif

View File

@@ -17,7 +17,11 @@ import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.MinecraftForge;
//#if MC>=10800
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#if MC>=11300
import net.minecraftforge.eventbus.api.SubscribeEvent;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#endif
//#else
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
//#endif

View File

@@ -7,11 +7,15 @@ import net.minecraft.item.ItemStack;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.*;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
// FIXME not (yet?) 1.13 import net.minecraftforge.event.entity.minecart.MinecartInteractEvent;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
//#if MC>=10904
import net.minecraft.entity.EntityLiving;
//#if MC>=11300
import net.minecraft.entity.EntityLivingBase;
//#else
//$$ import net.minecraft.entity.EntityLiving;
//#endif
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.util.EnumHand;
@@ -25,7 +29,11 @@ import net.minecraft.util.math.BlockPos;
//#endif
//#if MC>=10800
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#if MC>=11300
import net.minecraftforge.eventbus.api.SubscribeEvent;
//#else
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
//#endif
import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
@@ -42,7 +50,7 @@ import static com.replaymod.core.versions.MCVer.*;
public class RecordingEventHandler {
private final Minecraft mc = Minecraft.getMinecraft();
private final Minecraft mc = getMinecraft();
private final PacketListener packetListener;
private Double lastX, lastY, lastZ;
@@ -171,9 +179,15 @@ public class RecordingEventHandler {
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
//#if MC>=10904
packet = new SPacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
//#if MC>=11300
packet = new SPacketEntity.Move(
//#else
//$$ packet = new SPacketEntity.S17PacketEntityLookMove(
//#endif
e.player.getEntityId(),
(short) Math.round(dx * 4096), (short) Math.round(dy * 4096), (short) Math.round(dz * 4096),
newYaw, newPitch, e.player.onGround);
newYaw, newPitch, e.player.onGround
);
//#else
//$$ packet = new S14PacketEntity.S17PacketEntityLookMove(e.player.getEntityId(),
//$$ (byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
@@ -300,9 +314,15 @@ public class RecordingEventHandler {
//Leaving Ride
if((!player(mc).isRiding() && lastRiding != -1) ||
(player(mc).isRiding() && lastRiding != getRidingEntity(player(mc)).getEntityId())) {
if(!player(mc).isRiding()) {
//#if MC>=11300
if((!player(mc).isPassenger() && lastRiding != -1) ||
(player(mc).isPassenger() && lastRiding != getRidingEntity(player(mc)).getEntityId())) {
if(!player(mc).isPassenger()) {
//#else
//$$ if((!player(mc).isRiding() && lastRiding != -1) ||
//$$ (player(mc).isRiding() && lastRiding != getRidingEntity(player(mc)).getEntityId())) {
//$$ if(!player(mc).isRiding()) {
//#endif
lastRiding = -1;
} else {
lastRiding = getRidingEntity(player(mc)).getEntityId();
@@ -331,7 +351,11 @@ public class RecordingEventHandler {
lastActiveHand = player(mc).getActiveHand();
EntityDataManager dataManager = new EntityDataManager(null);
int state = (wasHandActive ? 1 : 0) | (lastActiveHand == EnumHand.OFF_HAND ? 2 : 0);
dataManager.register(EntityLiving.HAND_STATES, (byte) state);
//#if MC>=11300
dataManager.register(EntityLivingBase.LIVING_FLAGS, (byte) state);
//#else
//$$ dataManager.register(EntityLiving.HAND_STATES, (byte) state);
//#endif
packetListener.save(new SPacketEntityMetadata(player(mc).getEntityId(), dataManager, true));
}
//#endif
@@ -394,6 +418,7 @@ public class RecordingEventHandler {
}
}
/* FIXME event not (yet?) on 1.13
@SubscribeEvent
public void enterMinecart(MinecartInteractEvent event) {
try {
@@ -418,6 +443,7 @@ public class RecordingEventHandler {
e.printStackTrace();
}
}
*/
//#if MC>=10800
public void onBlockBreakAnim(int breakerId, BlockPos pos, int progress) {

View File

@@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#if MC>=10800
import net.minecraftforge.fml.common.network.FMLNetworkEvent;
// FIXME event not (yet?) in 1.13 import net.minecraftforge.fml.common.network.FMLNetworkEvent;
//#else
//$$ import cpw.mods.fml.common.network.FMLNetworkEvent;
//#endif
@@ -25,12 +25,16 @@ public abstract class MixinNetHandlerLoginClient {
//$$ private NetworkManager field_147393_d;
//#endif
/**
* Starts the recording right before switching into PLAY state.
* We cannot use the {@link FMLNetworkEvent.ClientConnectedToServerEvent}
* as it only fires after the forge handshake.
*/
@Inject(method = "handleLoginSuccess", at=@At("HEAD"))
//#if MC>=11300
@Inject(method = "func_209521_a", at=@At("HEAD"))
//#else
//$$ /**
//$$ * Starts the recording right before switching into PLAY state.
//$$ * We cannot use the {@link FMLNetworkEvent.ClientConnectedToServerEvent}
//$$ * as it only fires after the forge handshake.
//$$ */
//$$ @Inject(method = "handleLoginSuccess", at=@At("HEAD"))
//#endif
public void replayModRecording_initiateRecording(CallbackInfo cb) {
//#if MC>=10800
ReplayModRecording.instance.initiateRecording(networkManager);

View File

@@ -13,7 +13,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#if MC>=10800
//#if MC>=10904
import net.minecraft.network.play.server.SPacketPlayerListItem.Action;
import net.minecraft.network.play.server.SPacketPlayerListItem.AddPlayerData;
// FIXME requires RuntimeInvisParam workaround import net.minecraft.network.play.server.SPacketPlayerListItem.AddPlayerData;
//#else
//$$ import net.minecraft.network.play.server.S38PacketPlayerListItem.Action;
//$$ import net.minecraft.network.play.server.S38PacketPlayerListItem.AddPlayerData;
@@ -61,6 +61,7 @@ public abstract class MixinNetHandlerPlayClient {
RecordingEventHandler handler = getRecordingEventHandler();
if (handler != null && packet.getAction() == Action.ADD_PLAYER) {
/* FIXME see import
for (AddPlayerData data : packet.getEntries()) {
if (data.getProfile() == null || data.getProfile().getId() == null) continue;
// Only add spawn packet for our own player and only if he isn't known yet
@@ -69,6 +70,7 @@ public abstract class MixinNetHandlerPlayClient {
handler.onPlayerJoin();
}
}
*/
}
}
//#else

View File

@@ -1,3 +1,4 @@
/* FIXME
package com.replaymod.recording.mixin;
import com.replaymod.recording.handler.FMLHandshakeFilter;
@@ -42,6 +43,7 @@ public abstract class MixinNetworkDispatcher {
* Injects a {@link FMLHandshakeFilter} on the client side to filter out
* those extra, unexpected packets.
*/
/*
@Inject(method = "insertIntoChannel", at=@At("HEAD"))
public void replayModRecording_setupForLocalRecording(CallbackInfo cb) {
// If we're in multiplayer, everything is fine as is
@@ -73,3 +75,4 @@ public abstract class MixinNetworkDispatcher {
}
//#endif
}
*/

View File

@@ -23,10 +23,12 @@ public abstract class MixinPlayerControllerMP implements RecordingEventHandler.R
// 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);
}
*/
}
//#endif

View File

@@ -15,6 +15,7 @@ import net.minecraft.util.math.BlockPos;
//#endif
//#endif
/* FIXME runtimeinvisparameter
@Mixin(RenderGlobal.class)
public abstract class MixinRenderGlobal implements RecordingEventHandler.RecordingEventSender {
@@ -53,3 +54,4 @@ public abstract class MixinRenderGlobal implements RecordingEventHandler.Recordi
}
}
}
*/

View File

@@ -10,7 +10,6 @@ import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraft.world.storage.WorldInfo;
import org.spongepowered.asm.mixin.Mixin;
@@ -19,6 +18,12 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
//#if MC>=11300
import net.minecraft.world.dimension.Dimension;
//#else
//$$ import net.minecraft.world.WorldProvider;
//#endif
import static com.replaymod.core.versions.MCVer.*;
@Mixin(WorldClient.class)
@@ -26,7 +31,13 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
@Shadow
private Minecraft mc;
protected MixinWorldClient(ISaveHandler saveHandlerIn, WorldInfo info, WorldProvider providerIn, Profiler profilerIn, boolean client) {
protected MixinWorldClient(ISaveHandler saveHandlerIn, WorldInfo info,
//#if MC>=11300
Dimension providerIn,
//#else
//$$ WorldProvider providerIn,
//#endif
Profiler profilerIn, boolean client) {
super(saveHandlerIn, info, providerIn, profilerIn, client);
}

View File

@@ -29,7 +29,7 @@ import net.minecraft.util.text.TextComponentString;
//#if MC>=10800
import net.minecraft.network.EnumPacketDirection;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
// FIXME import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
//#else
//$$ import cpw.mods.fml.common.network.internal.FMLProxyPacket;
//#endif
@@ -49,7 +49,7 @@ import static com.replaymod.core.versions.MCVer.*;
public class PacketListener extends ChannelInboundHandlerAdapter {
private static final Minecraft mc = Minecraft.getMinecraft();
private static final Minecraft mc = getMinecraft();
private static final Logger logger = LogManager.getLogger();
private final ReplayFile replayFile;
@@ -229,6 +229,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
//#endif
//#endif
/* FIXME
if (packet instanceof FMLProxyPacket) {
// This packet requires special handling
//#if MC>=10800
@@ -239,6 +240,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
super.channelRead(ctx, msg);
return;
}
*/
save(packet);
@@ -358,7 +360,7 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
}
public void addMarker() {
Entity view = getRenderViewEntity(Minecraft.getMinecraft());
Entity view = getRenderViewEntity(mc);
int timestamp = (int) (System.currentTimeMillis() - startTime);
Marker marker = new Marker();

View File

@@ -9,7 +9,7 @@ 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.client.resources.ResourcePackRepository;
// FIXME import net.minecraft.client.resources.ResourcePackRepository;
import net.minecraft.util.HttpUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -36,8 +36,6 @@ import net.minecraft.network.NetworkManager;
import org.apache.commons.io.FileUtils;
import javax.annotation.Nonnull;
import static com.replaymod.core.versions.MCVer.*;
//#else
//$$ import net.minecraft.client.multiplayer.ServerData.ServerResourceMode;
//$$ import net.minecraft.client.multiplayer.ServerList;
@@ -52,12 +50,14 @@ import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import static com.replaymod.core.versions.MCVer.*;
/**
* Records resource packs and handles incoming resource pack packets during recording.
*/
public class ResourcePackRecorder {
private static final Logger logger = LogManager.getLogger();
private static final Minecraft mc = Minecraft.getMinecraft();
private static final Minecraft mc = getMinecraft();
private final ReplayFile replayFile;
@@ -131,11 +131,12 @@ public class ResourcePackRecorder {
if (url.startsWith("level://")) {
String levelName = url.substring("level://".length());
File savesDir = new File(mc.mcDataDir, "saves");
File savesDir = new File(mcDataDir(mc), "saves");
final File levelDir = new File(savesDir, levelName);
if (levelDir.isFile()) {
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
/* FIXME
Futures.addCallback(setServerResourcePack(mc.getResourcePackRepository(), levelDir), new FutureCallback<Object>() {
@Override
public void onSuccess(Object result) {
@@ -148,6 +149,7 @@ public class ResourcePackRecorder {
netManager.sendPacket(makeStatusPacket(hash, Action.FAILED_DOWNLOAD));
}
});
*/
} else {
netManager.sendPacket(makeStatusPacket(hash, Action.FAILED_DOWNLOAD));
}
@@ -155,7 +157,7 @@ public class ResourcePackRecorder {
final ServerData serverData = mc.getCurrentServerData();
if (serverData != null && serverData.getResourceMode() == ServerData.ServerResourceMode.ENABLED) {
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
downloadResourcePackFuture(requestId, url, hash);
// FIXME downloadResourcePackFuture(requestId, url, hash);
} else if (serverData != null && serverData.getResourceMode() != ServerData.ServerResourceMode.PROMPT) {
netManager.sendPacket(makeStatusPacket(hash, Action.DECLINED));
} else {
@@ -163,13 +165,17 @@ public class ResourcePackRecorder {
//noinspection Convert2Lambda
mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiYesNo(new GuiYesNoCallback() {
@Override
public void confirmClicked(boolean result, int id) {
//#if MC>=11300
public void confirmResult(boolean result, int id) {
//#else
//$$ public void confirmClicked(boolean result, int id) {
//#endif
if (serverData != null) {
serverData.setResourceMode(result ? ServerData.ServerResourceMode.ENABLED : ServerData.ServerResourceMode.DISABLED);
}
if (result) {
netManager.sendPacket(makeStatusPacket(hash, Action.ACCEPTED));
downloadResourcePackFuture(requestId, url, hash);
// FIXME downloadResourcePackFuture(requestId, url, hash);
} else {
netManager.sendPacket(makeStatusPacket(hash, Action.DECLINED));
}
@@ -188,6 +194,7 @@ public class ResourcePackRecorder {
//#endif
}
/* FIXME
private void downloadResourcePackFuture(int requestId, String url, final String hash) {
Futures.addCallback(downloadResourcePack(requestId, url, hash), new FutureCallback() {
@Override
@@ -370,4 +377,5 @@ public class ResourcePackRecorder {
//$$ }
//#endif
*/
}

View File

@@ -0,0 +1,28 @@
modLoader="javafml"
loaderVersion="[13,)"
updateJSONURL="https://raw.githubusercontent.com/ReplayMod/ReplayMod/master/versions.json"
issueTrackerURL="https://replaymod.com/forum"
displayURL="https://replaymod.com"
logoFile="replaymod_logo.png"
authors="CrushedPixel, johni0702"
[[mods]]
modId="replaymod"
version="${version}"
displayName="Replay Mod"
description='''
A Mod which allows you to record, replay and share your Minecraft experience.
'''
[[dependencies.replaymod]]
modId="forge"
mandatory=true
versionRange="[14.23.2.0,)"
ordering="NONE"
side="BOTH"
[[dependencies.replaymod]]
modId="minecraft"
mandatory=true
versionRange="[ 1.13 ]"
ordering="NONE"
side="BOTH"

View File

@@ -143,7 +143,7 @@ public net.minecraft.crash.CrashReportCategory$Entry
public net.minecraft.client.settings.KeyBinding field_151474_i # pressTime
# Timer
public net.minecraft.util.Timer *
public-f net.minecraft.util.Timer *
# GlStateManager
public net.minecraft.client.renderer.GlStateManager *

View File

@@ -0,0 +1,6 @@
{
"pack": {
"description": "ReplayMod resources",
"pack_format": 4
}
}

0
versions/1.13/.gitkeep Normal file
View File

View File

@@ -5,11 +5,12 @@ buildscript {
mcVersion = "${major}${minor.padLeft(2, '0')}${(patch ?: '').padLeft(2, '0')}" as int
} else {
def f = file('mcVersion')
mcVersion = f.exists() ? f.readLines().first() as int : 11202
mcVersion = f.exists() ? f.readLines().first() as int : 11300
}
project.ext.mcVersion = mcVersion
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven {
@@ -30,6 +31,7 @@ buildscript {
exclude group: 'org.ow2.asm', module: 'asm-debug-all'
}
classpath 'net.minecraftforge.gradle:ForgeGradle:' + (
mcVersion >= 11300 ? '3.+' :
mcVersion >= 11200 ? '2.3-SNAPSHOT' :
mcVersion >= 10904 ? '2.2-SNAPSHOT' :
mcVersion >= 10809 ? '2.1-SNAPSHOT' :
@@ -40,9 +42,21 @@ buildscript {
}
}
def mcVersionStr = "${(int)(mcVersion/10000)}.${(int)(mcVersion/100)%100}" + (mcVersion%100==0 ? '' : ".${mcVersion%100}")
def FG3 = mcVersion >= 11300
if (mcVersion >= 10800) {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
if (FG3) {
apply plugin: 'net.minecraftforge.gradle'
// FIXME use mixin plugin once updated
compileJava {
options.compilerArgs += ['-AreobfSrgFile=' + new File(project.buildDir, 'mcp-srg.srg').getCanonicalPath()]
}
} else {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
}
} else {
apply plugin: 'forge'
@@ -56,16 +70,27 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
afterEvaluate {
version = project.minecraft.version + '-' + rootProject.version
version = mcVersionStr + '-' + rootProject.version
}
group= "com.replaymod"
archivesBaseName = "replaymod"
minecraft {
if (mcVersion >= 10800) {
coreMod = 'com.replaymod.core.LoadingPlugin'
if (FG3) {
runConfig {
name = 'Minecraft Client'
main = 'net.minecraftforge.userdev.UserdevLauncher'
ideaModuleName = '${project.name}_main'
workingDirectory = project.file('eclipse').canonicalPath
environment 'target', 'fmldevclient'
environment 'assetDirectory', downloadAssets.output.absolutePath
}
} else {
if (mcVersion >= 10800) {
coreMod = 'com.replaymod.core.LoadingPlugin'
}
runDir = "../../eclipse"
}
runDir = "../../eclipse"
version = [
11202: '1.12.2-14.23.0.2486',
@@ -80,6 +105,7 @@ minecraft {
10710: '1.7.10-10.13.4.1558-1.7.10',
][mcVersion]
mappings = [
11300: "snapshot_20180921-1.13",
11202: "snapshot_20170615",
11201: "snapshot_20170615",
11200: "snapshot_20170615",
@@ -92,15 +118,20 @@ minecraft {
10710: "stable_12",
][mcVersion]
}
afterEvaluate {
// Note cannot use minecraft.replace because that has already been forwarded to the task by FG by now
tasks.sourceMainJava.replace '@MOD_VERSION@', project.version
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
// a newer srg-compatible MC version (that may be using a different protocol version)
tasks.sourceMainJava.replace '@MC_VERSION@', "[ ${project.minecraft.version} ]"
if (mcVersion >= 11300) {
} else {
// Note cannot use minecraft.replace because that has already been forwarded to the task by FG by now
tasks.sourceMainJava.replace '@MOD_VERSION@', project.version
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
// a newer srg-compatible MC version (that may be using a different protocol version)
tasks.sourceMainJava.replace '@MC_VERSION@', "[ $mcVersionStr ]"
}
}
repositories {
mavenLocal()
maven {
name = "SpongePowered Repo"
url = "http://repo.spongepowered.org/maven/"
@@ -116,9 +147,20 @@ configurations {
}
dependencies {
if (FG3) {
minecraft 'net.minecraftforge.test:forge:' + [
11300: '1.13-24.0.33-1.13-pre',
][mcVersion]
}
annotationProcessor group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
compileOnly group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
// compile 'com.github.SpongePowered:Mixin:404f5da' // 0.7.5-SNAPSHOT
// ^ mixin doesn't compile on jitpack, so we'll have to depend on the SNAPSHOT and build it manually for reprod
compile 'org.spongepowered:mixin:0.7.5-SNAPSHOT'
annotationProcessor 'org.spongepowered:mixin:0.7.8-SNAPSHOT'
compileOnly 'org.spongepowered:mixin:0.7.8-SNAPSHOT'
compile 'org.spongepowered:mixin:0.7.8-SNAPSHOT'
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
shade 'org.apache.commons:commons-exec:1.3'
def withoutGuava = { exclude group: 'com.google.guava', module: 'guava-jdk5' }
@@ -129,9 +171,9 @@ dependencies {
shade 'org.aspectj:aspectjrt:1.8.2'
def studioVersion = "${(int)(mcVersion/10000)}.${(int)(mcVersion/100)%100}" + (mcVersion%100==0 ? '' : ".${mcVersion%100}")
def studioVersion = mcVersionStr
if (studioVersion == '1.8.9') studioVersion = '1.8'
shade("com.github.ReplayMod.ReplayStudio:$studioVersion:2d8d41d"){
shade("com.replaymod.replaystudio:$studioVersion:2d8d41d"){ // FIXME
exclude group: 'com.google.guava', module: 'guava' // provided by MC
exclude group: 'org.projectlombok', module: 'lombok' // runtime only for @SneakyThrows which isn't used
}
@@ -144,6 +186,7 @@ dependencies {
exclude group: 'org.projectlombok', module: 'lombok' // runtime only for @SneakyThrows which isn't used
}
annotationProcessor 'org.projectlombok:lombok:1.16.6'
compile 'org.projectlombok:lombok:1.16.6' // runtime only for @SneakyThrows which isn't used
testCompile 'junit:junit:4.11'
@@ -173,8 +216,10 @@ if (project.name != 'core') {
def preprocessedSrc = 'build/preprocessed/src'
def preprocessedRes = 'build/preprocessed/res'
def preprocessedAT = 'build/preprocessed/at.cfg'
def originalSrc = '../../src/main/java'
def originalRes = '../../src/main/resources'
def originalAT = originalRes + '/META-INF/replaymod_at.cfg'
def vars = [MC: mcVersion as int]
sourceSets {
@@ -200,19 +245,42 @@ if (project.name != 'core') {
compileJava.dependsOn preprocessJava
processResources.dependsOn preprocessResources
(mcVersion >= 10800 ? [deobfMcMCP, deobfMcSRG] : [deobfuscateJar, deobfBinJar]).each { task ->
task.dependsOn preprocessResources
if (FG3) {
// FG3 reads the AT file right after project evaluation, so we need to convert it right now
project.convertTree(vars, originalAT, preprocessedAT)
minecraft.accessTransformers << file(preprocessedAT)
} else {
(mcVersion >= 10800 ? [deobfMcMCP, deobfMcSRG] : [deobfuscateJar, deobfBinJar]).each { task ->
task.dependsOn preprocessResources
}
minecraft.accessTransformer preprocessedRes + '/META-INF/replaymod_at.cfg'
}
minecraft.accessTransformer preprocessedRes + '/META-INF/replaymod_at.cfg'
} else {
if (FG3) {
minecraft.accessTransformers << file('../../src/main/resources/META-INF/replaymod_at.cfg')
}
sourceSets {
main.java.srcDirs = ['../../src/main/java']
main.resources.srcDirs = ['../../src/main/resources']
}
}
sourceSets {
main {
java {
exclude 'com/replaymod/compat'
exclude 'com/replaymod/editor'
exclude 'com/replaymod/extras'
exclude 'com/replaymod/online'
exclude 'com/replaymod/pathing'
exclude 'com/replaymod/render'
exclude 'com/replaymod/replay'
exclude 'com/replaymod/restrictions'
exclude 'com/replaymod/simplepathing'
}
}
}
if (!FG3) { // FIXME
def reobfTask = mcVersion >= 10800 ? tasks.reobfJar : tasks.reobf
task configureRelocation() {
dependsOn tasks.jar
@@ -237,6 +305,7 @@ task configureRelocation() {
}
}
reobfTask.dependsOn configureRelocation
}
if (mcVersion <= 10710) {
// Dummy task so "./gradlew reobfJar" also builds 1.7.10
@@ -294,21 +363,23 @@ processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property 'version', { project.version }
inputs.property 'mcversion', { project.minecraft.version }
inputs.property 'mcversion', { mcVersionStr }
// replace stuff in mcmod.info, nothing else
// replace stuff in mcmod.info (pre 1.13) and mods.toml (1.13+), nothing else
from(sourceSets.main.resources.srcDirs) { spec ->
include 'mcmod.info'
include 'mods.toml'
// replace version and mcversion
afterEvaluate {
spec.expand 'version': project.version, 'mcversion': project.minecraft.version
spec.expand 'version': project.version, 'mcversion': mcVersionStr
}
}
// copy everything else, thats not the mcmod.info
// copy everything else, thats not the mcmod.info (or mods.toml)
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude 'mods.toml'
}
}
@@ -325,14 +396,42 @@ sourceSets {
}
}
task copySrg(type: Copy, dependsOn: 'genSrgs') {
from {project.tasks.genSrgs.mcpToSrg}
into 'build'
if (FG3) {
task copySrg(dependsOn: 'createMcpToSrg') {
doLast {
def tsrg = file(project.tasks.createMcpToSrg.output).readLines()
def srg = []
def cls = ''
for (def line : tsrg) {
if (line[0] != '\t') {
srg.add('CL: ' + line)
cls = line.split(' ')[0]
} else {
def parts = line.substring(1).split(' ')
if (line.contains('(')) {
srg.add('MD: ' + cls + '/' + parts[0] + ' ' + parts[1] + ' ' + cls + '/' + parts[2] + ' ' + parts[1])
} else {
srg.add('FD: ' + cls + '/' + parts[0] + ' ' + cls + '/' + parts[1])
}
}
}
new File(project.buildDir, 'mcp-srg.srg').write(srg.join('\n'))
}
}
} else {
task copySrg(type: Copy, dependsOn: 'genSrgs') {
from {project.tasks.genSrgs.mcpToSrg}
into 'build'
}
}
setupDecompWorkspace.dependsOn copySrg
setupDevWorkspace.dependsOn copySrg
project.tasks.idea.dependsOn copySrg
if (FG3) {
// FIXME project.tasks.idea.dependsOn copySrg
compileJava.dependsOn copySrg // FIXME can probably remove this one once mixingradle is updated
} else {
setupDecompWorkspace.dependsOn copySrg
setupDevWorkspace.dependsOn copySrg
}
if (mcVersion <= 10710) {
reobf.doFirst {
@@ -351,6 +450,7 @@ if (mcVersion <= 10710) {
}
}
/* FIXME
// Mixin uses multiple HashMaps to generate the refmap.
// HashMaps are unordered collections and as such do not produce deterministic output.
// To fix that, we simply sort the refmap json file.
@@ -375,6 +475,7 @@ compileJava.doLast {
refmapFile.withWriter { it.write json }
}
}
*/
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
@@ -425,10 +526,11 @@ def annotationWorkaround = {
jar.delete()
tmp.renameTo(jar)
}
if (mcVersion >= 10809) {
if (mcVersion >= 10809 && !FG3) {
tasks.deobfMcMCP.doLast annotationWorkaround
}
if (!FG3) { // FIXME
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
main = 'GradleStart'
standardOutput = System.out
@@ -452,5 +554,6 @@ task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
runIntegrationTest.classpath runClient.classpath + sourceSets.integrationTest.output
}
}
}
defaultTasks 'build'

View File

@@ -9,6 +9,17 @@ static def evalVar(vars, String var) {
import java.util.regex.Pattern
static def evalExpr(vars, String expr) {
expr = expr.trim()
def parts = expr.split(/\|\|/)
if (parts.length > 1) {
return parts.any { evalExpr(vars, it) }
}
parts = expr.split(/&&/)
if (parts.length > 1) {
return !parts.any { !evalExpr(vars, it) }
}
def matcher = Pattern.compile(/(.+)(<=|>=|<|>)(.+)/).matcher(expr)
if (matcher.matches()) {
def lhs = evalVar(vars, matcher.group(1))