Get core, recording and replay modules compiling on 1.13.2
This commit is contained in:
2
jGui
2
jGui
Submodule jGui updated: 73a6d9f774...e89934d686
10
src/main/java/com/replaymod/core/Module.java
Normal file
10
src/main/java/com/replaymod/core/Module.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.replaymod.core;
|
||||||
|
|
||||||
|
public interface Module {
|
||||||
|
// FMLCommonSetupEvent for 1.13+, FMLInitializationEvent below
|
||||||
|
default void initCommon() {}
|
||||||
|
// FMLClientSetupEvent for 1.13+, FMLInitializationEvent (if client) below
|
||||||
|
default void initClient() {}
|
||||||
|
// FMLClientSetupEvent for 1.13+, FMLInitializationEvent below
|
||||||
|
default void registerKeyBindings(KeyBindingRegistry registry) {}
|
||||||
|
}
|
||||||
@@ -14,7 +14,6 @@ import de.johni0702.minecraft.gui.container.GuiScreen;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import org.apache.commons.io.Charsets;
|
import org.apache.commons.io.Charsets;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
@@ -22,10 +21,15 @@ import org.apache.commons.io.FileUtils;
|
|||||||
import com.replaymod.core.versions.LangResourcePack;
|
import com.replaymod.core.versions.LangResourcePack;
|
||||||
import net.minecraft.resources.FolderPack;
|
import net.minecraft.resources.FolderPack;
|
||||||
import net.minecraft.resources.IResourcePack;
|
import net.minecraft.resources.IResourcePack;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLModLoadingContext;
|
import net.minecraftforge.fml.DeferredWorkQueue;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
import net.minecraftforge.versions.mcp.MCPVersion;
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraft.client.resources.FolderResourcePack;
|
//$$ import net.minecraft.client.resources.FolderResourcePack;
|
||||||
//$$ import net.minecraft.client.resources.IResourcePack;
|
//$$ import net.minecraft.client.resources.IResourcePack;
|
||||||
|
//$$ import net.minecraftforge.common.config.Configuration;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10904
|
//#if MC>=10904
|
||||||
@@ -51,12 +55,12 @@ import net.minecraftforge.fml.ModList;
|
|||||||
//$$ import net.minecraftforge.fml.common.Mod.EventHandler;
|
//$$ import net.minecraftforge.fml.common.Mod.EventHandler;
|
||||||
//$$ import net.minecraftforge.fml.common.Mod.Instance;
|
//$$ import net.minecraftforge.fml.common.Mod.Instance;
|
||||||
//$$ import net.minecraftforge.fml.common.ModContainer;
|
//$$ 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.SubscribeEvent;
|
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
//#endif
|
//#endif
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
//#else
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.Loader;
|
//$$ import cpw.mods.fml.common.Loader;
|
||||||
@@ -99,7 +103,7 @@ import static com.replaymod.core.versions.MCVer.*;
|
|||||||
//#endif
|
//#endif
|
||||||
//$$ guiFactory = "com.replaymod.core.gui.GuiFactory")
|
//$$ guiFactory = "com.replaymod.core.gui.GuiFactory")
|
||||||
//#endif
|
//#endif
|
||||||
public class ReplayMod {
|
public class ReplayMod implements Module {
|
||||||
|
|
||||||
public static ModContainer getContainer() {
|
public static ModContainer getContainer() {
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
@@ -111,7 +115,7 @@ public class ReplayMod {
|
|||||||
|
|
||||||
@Getter(lazy = true)
|
@Getter(lazy = true)
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
private static final String minecraftVersion = "1.13"; // FIXME
|
private static final String minecraftVersion = MCPVersion.getMCVersion();
|
||||||
//#else
|
//#else
|
||||||
//$$ private static final String minecraftVersion = Loader.MC_VERSION;
|
//$$ private static final String minecraftVersion = Loader.MC_VERSION;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -123,11 +127,16 @@ public class ReplayMod {
|
|||||||
|
|
||||||
private static final Minecraft mc = MCVer.getMinecraft();
|
private static final Minecraft mc = MCVer.getMinecraft();
|
||||||
|
|
||||||
@Deprecated
|
//#if MC<11300
|
||||||
public static Configuration config;
|
//$$ @Deprecated
|
||||||
|
//$$ public static Configuration config;
|
||||||
|
//#endif
|
||||||
|
|
||||||
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
||||||
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
private final SettingsRegistry settingsRegistry = new SettingsRegistry();
|
||||||
|
{
|
||||||
|
settingsRegistry.register(Setting.class);
|
||||||
|
}
|
||||||
|
|
||||||
// The instance of your mod that Forge uses.
|
// The instance of your mod that Forge uses.
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
@@ -138,9 +147,31 @@ public class ReplayMod {
|
|||||||
public static ReplayMod instance;
|
public static ReplayMod instance;
|
||||||
|
|
||||||
private final List<Module> modules = new ArrayList<>();
|
private final List<Module> modules = new ArrayList<>();
|
||||||
{
|
|
||||||
|
public ReplayMod() {
|
||||||
|
I18n.setI18n(net.minecraft.client.resources.I18n::format);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
DeferredWorkQueue.runLater(OpenGLUtils::init);
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
DeferredWorkQueue.runLater(() -> MCVer.getMinecraft().resourcePackRepository.addPackFinder(new LangResourcePack.Finder()));
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
// Register all RM modules
|
||||||
|
modules.add(this);
|
||||||
modules.add(new ReplayModRecording(this));
|
modules.add(new ReplayModRecording(this));
|
||||||
modules.add(new ReplayModReplay(this));
|
modules.add(new ReplayModReplay(this));
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
settingsRegistry.register();
|
||||||
|
//#else
|
||||||
|
//$$ config = new Configuration(event.getSuggestedConfigurationFile());
|
||||||
|
//$$ config.load();
|
||||||
|
//$$ settingsRegistry.setConfiguration(config);
|
||||||
|
//$$ settingsRegistry.save(); // Save default values to disk
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyBindingRegistry getKeyBindingRegistry() {
|
public KeyBindingRegistry getKeyBindingRegistry() {
|
||||||
@@ -158,32 +189,6 @@ public class ReplayMod {
|
|||||||
return folder;
|
return folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#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
|
|
||||||
OpenGLUtils.init();
|
|
||||||
|
|
||||||
I18n.setI18n(net.minecraft.client.resources.I18n::format);
|
|
||||||
//#if MC>=11300
|
|
||||||
MCVer.getMinecraft().resourcePackRepository.addPackFinder(new LangResourcePack.Finder());
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
//#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
|
//#ifdef DEV_ENV
|
||||||
static { // Note: even preInit is too late and we'd have to issue another resource reload
|
static { // Note: even preInit is too late and we'd have to issue another resource reload
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -231,39 +236,41 @@ public class ReplayMod {
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
{ FMLModLoadingContext.get().getModEventBus().addListener(this::init); }
|
{
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLCommonSetupEvent event) -> modules.forEach(Module::initCommon));
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLClientSetupEvent event) -> modules.forEach(Module::initClient));
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener((FMLClientSetupEvent event) -> modules.forEach(m -> m.registerKeyBindings(keyBindingRegistry)));
|
||||||
|
}
|
||||||
//#else
|
//#else
|
||||||
//$$ @EventHandler
|
//$$ @EventHandler
|
||||||
|
//$$ public void init(FMLInitializationEvent event) {
|
||||||
|
//$$ modules.forEach(Module::initCommon);
|
||||||
|
//$$ modules.forEach(Module::initClient);
|
||||||
|
//$$ modules.forEach(m -> m.registerKeyBindings(keyBindingRegistry));
|
||||||
|
//$$ }
|
||||||
//#endif
|
//#endif
|
||||||
public void init(FMLInitializationEvent event) {
|
|
||||||
getSettingsRegistry().register(Setting.class);
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerKeyBindings(KeyBindingRegistry registry) {
|
||||||
|
registry.registerKeyBinding("replaymod.input.settings", 0, () -> {
|
||||||
|
new GuiReplaySettings(null, settingsRegistry).display();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initClient() {
|
||||||
new MainMenuHandler().register();
|
new MainMenuHandler().register();
|
||||||
|
|
||||||
//#if MC<=10710
|
//#if MC<=10710
|
||||||
//$$ FML_BUS.register(this); // For runLater(Runnable)
|
//$$ FML_BUS.register(this); // For runLater(Runnable)
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
FML_BUS.register(keyBindingRegistry);
|
FML_BUS.register(keyBindingRegistry);
|
||||||
|
|
||||||
getKeyBindingRegistry().registerKeyBinding("replaymod.input.settings", 0, () -> {
|
|
||||||
new GuiReplaySettings(null, settingsRegistry).display();
|
|
||||||
});
|
|
||||||
|
|
||||||
modules.forEach(m -> m.init(event));
|
|
||||||
}
|
|
||||||
|
|
||||||
//#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
|
// 1.7.10 crashes when render distance > 16
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
//if(!FMLClientHandler.instance().hasOptifine()) FIXME 1.13 update
|
//if(!FMLClientHandler.instance().hasOptifine()) FIXME 1.13 update
|
||||||
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
testIfMoeshAndExitMinecraft();
|
testIfMoeshAndExitMinecraft();
|
||||||
@@ -300,8 +307,6 @@ public class ReplayMod {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
modules.forEach(m -> m.postInit(event));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,10 +438,4 @@ public class ReplayMod {
|
|||||||
mc.ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation(message, args));
|
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) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,67 @@
|
|||||||
package com.replaymod.core;
|
package com.replaymod.core;
|
||||||
|
|
||||||
import com.replaymod.core.events.SettingsChangedEvent;
|
import com.replaymod.core.events.SettingsChangedEvent;
|
||||||
import net.minecraft.client.resources.I18n;
|
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraftforge.common.config.Configuration;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import static com.replaymod.core.versions.MCVer.*;
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class SettingsRegistry {
|
public class SettingsRegistry {
|
||||||
private static final Object NULL_OBJECT = new Object();
|
private static final Object NULL_OBJECT = new Object();
|
||||||
private Map<SettingKey<?>, Object> settings = new ConcurrentHashMap<>();
|
private Map<SettingKey<?>, Object> settings = new ConcurrentHashMap<>();
|
||||||
private Configuration configuration;
|
//#if MC>=11300
|
||||||
|
private ForgeConfigSpec spec;
|
||||||
|
private ModConfig config;
|
||||||
|
//#else
|
||||||
|
//$$ private Configuration configuration;
|
||||||
|
//#endif
|
||||||
|
|
||||||
public void setConfiguration(Configuration configuration) {
|
//#if MC>=11300
|
||||||
this.configuration = configuration;
|
public void register() {
|
||||||
|
if (spec == null) {
|
||||||
|
ForgeConfigSpec.Builder builder = new ForgeConfigSpec.Builder();
|
||||||
|
for (SettingKey<?> key : settings.keySet()) {
|
||||||
|
builder
|
||||||
|
.translation(key.getDisplayString())
|
||||||
|
.define(key.getCategory() + "." + key.getKey(), key.getDefault());
|
||||||
|
}
|
||||||
|
spec = builder.build();
|
||||||
|
}
|
||||||
|
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::load);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, spec);
|
||||||
|
}
|
||||||
|
|
||||||
List<SettingKey<?>> keys = new ArrayList<>(settings.keySet());
|
private void load(ModConfig.Loading event) {
|
||||||
settings.clear();
|
config = event.getConfig();
|
||||||
for (SettingKey key : keys) {
|
for (Map.Entry<SettingKey<?>, Object> entry : settings.entrySet()) {
|
||||||
register(key);
|
SettingKey<?> key = entry.getKey();
|
||||||
|
Object value = config.getConfigData().get(key.getCategory() + "." + key.getKey());
|
||||||
|
entry.setValue(value == null ? key.getDefault() : value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ public void setConfiguration(Configuration configuration) {
|
||||||
|
//$$ this.configuration = configuration;
|
||||||
|
//$$
|
||||||
|
//$$ List<SettingKey<?>> keys = new ArrayList<>(settings.keySet());
|
||||||
|
//$$ settings.clear();
|
||||||
|
//$$ for (SettingKey key : keys) {
|
||||||
|
//$$ register(key);
|
||||||
|
//$$ }
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
|
|
||||||
public void register(Class<?> settingsClass) {
|
public void register(Class<?> settingsClass) {
|
||||||
for (Field field : settingsClass.getDeclaredFields()) {
|
for (Field field : settingsClass.getDeclaredFields()) {
|
||||||
@@ -40,23 +77,30 @@ public class SettingsRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void register(SettingKey<?> key) {
|
public void register(SettingKey<?> key) {
|
||||||
Object value;
|
//#if MC>=11300
|
||||||
if (configuration != null) {
|
if (spec != null) {
|
||||||
if (key.getDefault() instanceof Boolean) {
|
throw new IllegalStateException("Cannot register more settings are spec has been built.");
|
||||||
value = configuration.get(key.getCategory(), key.getKey(), (Boolean) key.getDefault()).getBoolean();
|
|
||||||
} else if (key.getDefault() instanceof Integer) {
|
|
||||||
value = configuration.get(key.getCategory(), key.getKey(), (Integer) key.getDefault()).getInt();
|
|
||||||
} else if (key.getDefault() instanceof Double) {
|
|
||||||
value = configuration.get(key.getCategory(), key.getKey(), (Double) key.getDefault()).getDouble();
|
|
||||||
} else if (key.getDefault() instanceof String) {
|
|
||||||
value = configuration.get(key.getCategory(), key.getKey(), (String) key.getDefault()).getString();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
value = NULL_OBJECT;
|
|
||||||
}
|
}
|
||||||
settings.put(key, value);
|
settings.put(key, NULL_OBJECT);
|
||||||
|
//#else
|
||||||
|
//$$ Object value;
|
||||||
|
//$$ if (configuration != null) {
|
||||||
|
//$$ if (key.getDefault() instanceof Boolean) {
|
||||||
|
//$$ value = configuration.get(key.getCategory(), key.getKey(), (Boolean) key.getDefault()).getBoolean();
|
||||||
|
//$$ } else if (key.getDefault() instanceof Integer) {
|
||||||
|
//$$ value = configuration.get(key.getCategory(), key.getKey(), (Integer) key.getDefault()).getInt();
|
||||||
|
//$$ } else if (key.getDefault() instanceof Double) {
|
||||||
|
//$$ value = configuration.get(key.getCategory(), key.getKey(), (Double) key.getDefault()).getDouble();
|
||||||
|
//$$ } else if (key.getDefault() instanceof String) {
|
||||||
|
//$$ value = configuration.get(key.getCategory(), key.getKey(), (String) key.getDefault()).getString();
|
||||||
|
//$$ } else {
|
||||||
|
//$$ throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
||||||
|
//$$ }
|
||||||
|
//$$ } else {
|
||||||
|
//$$ value = NULL_OBJECT;
|
||||||
|
//$$ }
|
||||||
|
//$$ settings.put(key, value);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<SettingKey<?>> getSettings() {
|
public Set<SettingKey<?>> getSettings() {
|
||||||
@@ -72,23 +116,35 @@ public class SettingsRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> void set(SettingKey<T> key, T value) {
|
public <T> void set(SettingKey<T> key, T value) {
|
||||||
if (key.getDefault() instanceof Boolean) {
|
//#if MC>=11300
|
||||||
configuration.get(key.getCategory(), key.getKey(), (Boolean) key.getDefault()).set((Boolean) value);
|
if (config != null) {
|
||||||
} else if (key.getDefault() instanceof Integer) {
|
config.getConfigData().set(key.getCategory() + "." + key.getKey(), value);
|
||||||
configuration.get(key.getCategory(), key.getKey(), (Integer) key.getDefault()).set((Integer) value);
|
|
||||||
} else if (key.getDefault() instanceof Double) {
|
|
||||||
configuration.get(key.getCategory(), key.getKey(), (Double) key.getDefault()).set((Double) value);
|
|
||||||
} else if (key.getDefault() instanceof String) {
|
|
||||||
configuration.get(key.getCategory(), key.getKey(), (String) key.getDefault()).set((String) value);
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
|
||||||
}
|
}
|
||||||
|
//#else
|
||||||
|
//$$ if (key.getDefault() instanceof Boolean) {
|
||||||
|
//$$ configuration.get(key.getCategory(), key.getKey(), (Boolean) key.getDefault()).set((Boolean) value);
|
||||||
|
//$$ } else if (key.getDefault() instanceof Integer) {
|
||||||
|
//$$ configuration.get(key.getCategory(), key.getKey(), (Integer) key.getDefault()).set((Integer) value);
|
||||||
|
//$$ } else if (key.getDefault() instanceof Double) {
|
||||||
|
//$$ configuration.get(key.getCategory(), key.getKey(), (Double) key.getDefault()).set((Double) value);
|
||||||
|
//$$ } else if (key.getDefault() instanceof String) {
|
||||||
|
//$$ configuration.get(key.getCategory(), key.getKey(), (String) key.getDefault()).set((String) value);
|
||||||
|
//$$ } else {
|
||||||
|
//$$ throw new IllegalArgumentException("Default type " + key.getDefault().getClass() + " not supported.");
|
||||||
|
//$$ }
|
||||||
|
//#endif
|
||||||
settings.put(key, value);
|
settings.put(key, value);
|
||||||
FML_BUS.post(new SettingsChangedEvent(this, key));
|
FML_BUS.post(new SettingsChangedEvent(this, key));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
// FIXME forge config api is currently broken configuration.save();
|
//#if MC>=11300
|
||||||
|
if (config != null) {
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
//#else
|
||||||
|
//$$ configuration.save();
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface SettingKey<T> {
|
public interface SettingKey<T> {
|
||||||
@@ -127,7 +183,7 @@ public class SettingsRegistry {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDisplayString() {
|
public String getDisplayString() {
|
||||||
return displayString == null ? null : I18n.format(displayString);
|
return displayString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class GuiReplaySettings extends AbstractGuiScreen<GuiReplaySettings> {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final SettingsRegistry.SettingKey<Boolean> booleanKey = (SettingsRegistry.SettingKey<Boolean>) key;
|
final SettingsRegistry.SettingKey<Boolean> booleanKey = (SettingsRegistry.SettingKey<Boolean>) key;
|
||||||
final GuiToggleButton button = new GuiToggleButton<>().setSize(150, 20)
|
final GuiToggleButton button = new GuiToggleButton<>().setSize(150, 20)
|
||||||
.setLabel(key.getDisplayString()).setSelected(settingsRegistry.get(booleanKey) ? 0 : 1)
|
.setI18nLabel(key.getDisplayString()).setSelected(settingsRegistry.get(booleanKey) ? 0 : 1)
|
||||||
.setValues(I18n.format("options.on"), I18n.format("options.off"));
|
.setValues(I18n.format("options.on"), I18n.format("options.off"));
|
||||||
element = button.onClick(new Runnable() {
|
element = button.onClick(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -60,7 +60,7 @@ public class GuiReplaySettings extends AbstractGuiScreen<GuiReplaySettings> {
|
|||||||
for (int j = 0; j < entries.length; j++) {
|
for (int j = 0; j < entries.length; j++) {
|
||||||
Object value = values.get(j);
|
Object value = values.get(j);
|
||||||
entries[j] = new MultipleChoiceDropdownEntry(value,
|
entries[j] = new MultipleChoiceDropdownEntry(value,
|
||||||
multipleChoiceKey.getDisplayString() + ": " + I18n.format(value.toString()));
|
I18n.format(multipleChoiceKey.getDisplayString()) + ": " + I18n.format(value.toString()));
|
||||||
if (currentValue.equals(value)) {
|
if (currentValue.equals(value)) {
|
||||||
selected = j;
|
selected = j;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,12 +73,25 @@ import static com.replaymod.core.versions.MCVer.getMinecraft;
|
|||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
|
private static InputStream getResourceAsStream(String path) {
|
||||||
|
// FIXME this seems broken in 1.13, hence the workaround. probably want to open an issue with modlauncher (or forge?)
|
||||||
|
//#ifdef DEV_ENV
|
||||||
|
try {
|
||||||
|
return new java.io.FileInputStream(new File("../src/main/resources" + path));
|
||||||
|
} catch (java.io.FileNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
//#else
|
||||||
|
//$$ return Utils.class.getResourceAsStream(path);
|
||||||
|
//#endif
|
||||||
|
}
|
||||||
|
|
||||||
public static final BufferedImage DEFAULT_THUMBNAIL;
|
public static final BufferedImage DEFAULT_THUMBNAIL;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BufferedImage thumbnail;
|
BufferedImage thumbnail;
|
||||||
try {
|
try {
|
||||||
thumbnail = ImageIO.read(Utils.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
|
thumbnail = ImageIO.read(getResourceAsStream("/default_thumb.jpg"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
thumbnail = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
thumbnail = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -103,7 +116,7 @@ public class Utils {
|
|||||||
|
|
||||||
static {
|
static {
|
||||||
// Largely from https://community.letsencrypt.org/t/134/37
|
// Largely from https://community.letsencrypt.org/t/134/37
|
||||||
try (InputStream in = Utils.class.getResourceAsStream("/dst_root_ca_x3.pem")){
|
try (InputStream in = getResourceAsStream("/dst_root_ca_x3.pem")){
|
||||||
Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate(in);
|
Certificate certificate = CertificateFactory.getInstance("X.509").generateCertificate(in);
|
||||||
|
|
||||||
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class LangResourcePack extends AbstractResourcePack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ModFileResourcePack getParent() {
|
private ModFileResourcePack getParent() {
|
||||||
return (ModFileResourcePack) ResourcePackLoader.getResourcePackFor(ReplayMod.MOD_ID);
|
return ResourcePackLoader.getResourcePackFor(ReplayMod.MOD_ID).orElseThrow(() -> new RuntimeException("Failed to get ReplayMod resource pack!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String langName(String path) {
|
private String langName(String path) {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.replaymod.recording;
|
package com.replaymod.recording;
|
||||||
|
|
||||||
|
import com.replaymod.core.KeyBindingRegistry;
|
||||||
|
import com.replaymod.core.Module;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.utils.Restrictions;
|
import com.replaymod.core.utils.Restrictions;
|
||||||
import com.replaymod.recording.handler.ConnectionEventHandler;
|
import com.replaymod.recording.handler.ConnectionEventHandler;
|
||||||
@@ -20,22 +22,18 @@ import com.replaymod.core.versions.MCVer.Keyboard;
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
import net.minecraftforge.fml.network.NetworkRegistry;
|
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraftforge.fml.common.network.NetworkRegistry;
|
//$$ import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||||
//#endif
|
//#endif
|
||||||
//#else
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.network.NetworkRegistry;
|
//$$ import cpw.mods.fml.common.network.NetworkRegistry;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
import static com.replaymod.core.versions.MCVer.*;
|
import static com.replaymod.core.versions.MCVer.*;
|
||||||
|
|
||||||
public class ReplayModRecording extends ReplayMod.Module {
|
public class ReplayModRecording implements Module {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private static final AttributeKey<Void> ATTR_CHECKED = AttributeKey.newInstance("ReplayModRecording_checked");
|
private static final AttributeKey<Void> ATTR_CHECKED = AttributeKey.newInstance("ReplayModRecording_checked");
|
||||||
@@ -49,13 +47,13 @@ public class ReplayModRecording extends ReplayMod.Module {
|
|||||||
|
|
||||||
public ReplayModRecording(ReplayMod mod) {
|
public ReplayModRecording(ReplayMod mod) {
|
||||||
core = mod;
|
core = mod;
|
||||||
|
|
||||||
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void registerKeyBindings(KeyBindingRegistry registry) {
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
registry.registerKeyBinding("replaymod.input.marker", Keyboard.KEY_M, new Runnable() {
|
||||||
|
|
||||||
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.marker", Keyboard.KEY_M, new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PacketListener packetListener = connectionEventHandler.getPacketListener();
|
PacketListener packetListener = connectionEventHandler.getPacketListener();
|
||||||
@@ -68,7 +66,7 @@ public class ReplayModRecording extends ReplayMod.Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(FMLInitializationEvent event) {
|
public void initClient() {
|
||||||
FML_BUS.register(connectionEventHandler = new ConnectionEventHandler(LOGGER, core));
|
FML_BUS.register(connectionEventHandler = new ConnectionEventHandler(LOGGER, core));
|
||||||
|
|
||||||
new GuiHandler(core).register();
|
new GuiHandler(core).register();
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.apache.logging.log4j.Logger;
|
|||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -62,7 +63,7 @@ public class ConnectionEventHandler {
|
|||||||
if (local) {
|
if (local) {
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
if (mc.getIntegratedServer().getWorld(0).getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
|
if (mc.getIntegratedServer().getWorld(DimensionType.OVERWORLD).getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
|
||||||
//#else
|
//#else
|
||||||
//$$ if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
|
//$$ if (mc.getIntegratedServer().getEntityWorld().getWorldType() == WorldType_DEBUG_ALL_BLOCK_STATES) {
|
||||||
//#endif
|
//#endif
|
||||||
|
|||||||
@@ -370,8 +370,17 @@ public class RecordingEventHandler {
|
|||||||
try {
|
try {
|
||||||
//#if MC>=11100
|
//#if MC>=11100
|
||||||
//#if MC>=11200
|
//#if MC>=11200
|
||||||
packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
//#if MC>=11300
|
||||||
event.pickedUp.getItem().getMaxStackSize()));
|
ItemStack stack = event.getStack();
|
||||||
|
packetListener.save(new SPacketCollectItem(
|
||||||
|
event.getOriginalEntity().getEntityId(),
|
||||||
|
event.getPlayer().getEntityId(),
|
||||||
|
event.getStack().getCount()
|
||||||
|
));
|
||||||
|
//#else
|
||||||
|
//$$ packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
||||||
|
//$$ event.pickedUp.getItem().getMaxStackSize()));
|
||||||
|
//#endif
|
||||||
//#else
|
//#else
|
||||||
//$$ packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
//$$ packetListener.save(new SPacketCollectItem(event.pickedUp.getEntityId(), event.player.getEntityId(),
|
||||||
//$$ event.pickedUp.getEntityItem().getMaxStackSize()));
|
//$$ event.pickedUp.getEntityItem().getMaxStackSize()));
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
package com.replaymod.recording.mixin;
|
package com.replaymod.recording.mixin;
|
||||||
|
|
||||||
import com.replaymod.recording.handler.RecordingEventHandler;
|
import com.replaymod.recording.handler.RecordingEventHandler;
|
||||||
import net.minecraft.client.renderer.RenderGlobal;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.renderer.RenderGlobal;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10904
|
//#if MC>=10904
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
//#else
|
//#else
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
|
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
import net.minecraft.world.dimension.Dimension;
|
import net.minecraft.world.dimension.Dimension;
|
||||||
|
import net.minecraft.world.storage.WorldSavedDataStorage;
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraft.world.WorldProvider;
|
//$$ import net.minecraft.world.WorldProvider;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -31,14 +32,22 @@ public abstract class MixinWorldClient extends World implements RecordingEventHa
|
|||||||
@Shadow
|
@Shadow
|
||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
|
|
||||||
protected MixinWorldClient(ISaveHandler saveHandlerIn, WorldInfo info,
|
protected MixinWorldClient(ISaveHandler saveHandlerIn,
|
||||||
|
//#if MC>=11300
|
||||||
|
WorldSavedDataStorage mapStorage,
|
||||||
|
//#endif
|
||||||
|
WorldInfo info,
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
Dimension providerIn,
|
Dimension providerIn,
|
||||||
//#else
|
//#else
|
||||||
//$$ WorldProvider providerIn,
|
//$$ WorldProvider providerIn,
|
||||||
//#endif
|
//#endif
|
||||||
Profiler profilerIn, boolean client) {
|
Profiler profilerIn, boolean client) {
|
||||||
super(saveHandlerIn, info, providerIn, profilerIn, client);
|
super(saveHandlerIn,
|
||||||
|
//#if MC>=11300
|
||||||
|
mapStorage,
|
||||||
|
//#endif
|
||||||
|
info, providerIn, profilerIn, client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RecordingEventHandler replayModRecording_getRecordingEventHandler() {
|
private RecordingEventHandler replayModRecording_getRecordingEventHandler() {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.apache.commons.io.IOUtils;
|
|||||||
|
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.world.dimension.DimensionType;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if MC>=11200
|
//#if MC>=11200
|
||||||
@@ -377,10 +378,14 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
int chunkX = entity.chunkCoordX;
|
int chunkX = entity.chunkCoordX;
|
||||||
int chunkY = entity.chunkCoordZ;
|
int chunkY = entity.chunkCoordZ;
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
if (entity.addedToChunk && world.getChunkProvider().provideChunk(chunkX, chunkY, false, false) != null) {
|
||||||
|
//#else
|
||||||
//#if MC>=10904
|
//#if MC>=10904
|
||||||
if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
//$$ if (entity.addedToChunk && world.getChunkProvider().getLoadedChunk(chunkX, chunkY) != null) {
|
||||||
//#else
|
//#else
|
||||||
//$$ if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
//$$ if (entity.addedToChunk && world.getChunkProvider().chunkExists(chunkX, chunkY)) {
|
||||||
|
//#endif
|
||||||
//#endif
|
//#endif
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
world.getChunk(chunkX, chunkY).removeEntity(entity);
|
world.getChunk(chunkX, chunkY).removeEntity(entity);
|
||||||
@@ -566,7 +571,11 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
actualID = entId;
|
actualID = entId;
|
||||||
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
entId = -1789435; // Camera entity id should be negative which is an invalid id and can't be used by servers
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
int dimension = packet.getDimension();
|
//#if MC>=11300
|
||||||
|
DimensionType dimension = packet.func_212642_e();
|
||||||
|
//#else
|
||||||
|
//$$ int dimension = packet.getDimension();
|
||||||
|
//#endif
|
||||||
EnumDifficulty difficulty = packet.getDifficulty();
|
EnumDifficulty difficulty = packet.getDifficulty();
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
int maxPlayers = 0;// FIXME needs AT packet.maxPlayers;
|
int maxPlayers = 0;// FIXME needs AT packet.maxPlayers;
|
||||||
@@ -596,7 +605,12 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
//#if MC>=10904
|
//#if MC>=10904
|
||||||
if(p instanceof SPacketRespawn) {
|
if(p instanceof SPacketRespawn) {
|
||||||
SPacketRespawn respawn = (SPacketRespawn) p;
|
SPacketRespawn respawn = (SPacketRespawn) p;
|
||||||
p = new SPacketRespawn(respawn.getDimensionID(),
|
p = new SPacketRespawn(
|
||||||
|
//#if MC>=11300
|
||||||
|
respawn.func_212643_b(),
|
||||||
|
//#else
|
||||||
|
//$$ respawn.getDimensionID(),
|
||||||
|
//#endif
|
||||||
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
respawn.getDifficulty(), respawn.getWorldType(), GameType.SPECTATOR);
|
||||||
//#else
|
//#else
|
||||||
//$$ if(p instanceof S07PacketRespawn) {
|
//$$ if(p instanceof S07PacketRespawn) {
|
||||||
@@ -1083,7 +1097,11 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
World world = world(mc);
|
World world = world(mc);
|
||||||
IChunkProvider chunkProvider = world.getChunkProvider();
|
IChunkProvider chunkProvider = world.getChunkProvider();
|
||||||
// Get the chunk that will be unloaded
|
// Get the chunk that will be unloaded
|
||||||
Chunk chunk = chunkProvider.provideChunk(x, z);
|
//#if MC>=11300
|
||||||
|
Chunk chunk = chunkProvider.provideChunk(x, z, false, false);
|
||||||
|
//#else
|
||||||
|
//$$ Chunk chunk = chunkProvider.provideChunk(x, z);
|
||||||
|
//#endif
|
||||||
if (!chunk.isEmpty()) {
|
if (!chunk.isEmpty()) {
|
||||||
List<Entity> entitiesInChunk = new ArrayList<>();
|
List<Entity> entitiesInChunk = new ArrayList<>();
|
||||||
// Gather all entities in that chunk
|
// Gather all entities in that chunk
|
||||||
@@ -1109,12 +1127,16 @@ public class FullReplaySender extends ChannelDuplexHandler implements ReplaySend
|
|||||||
if (entity.chunkCoordX != chunkX || entity.chunkCoordZ != chunkZ) {
|
if (entity.chunkCoordX != chunkX || entity.chunkCoordZ != chunkZ) {
|
||||||
// Entity has left the chunk
|
// Entity has left the chunk
|
||||||
chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
chunk.removeEntityAtIndex(entity, entity.chunkCoordY);
|
||||||
|
//#if MC>=11300
|
||||||
|
Chunk newChunk = chunkProvider.provideChunk(chunkX, chunkZ, false, false);
|
||||||
|
//#else
|
||||||
//#if MC>=10904
|
//#if MC>=10904
|
||||||
Chunk newChunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
//$$ Chunk newChunk = chunkProvider.getLoadedChunk(chunkX, chunkZ);
|
||||||
//#else
|
//#else
|
||||||
//$$ Chunk newChunk = chunkProvider.chunkExists(chunkX, chunkZ)
|
//$$ Chunk newChunk = chunkProvider.chunkExists(chunkX, chunkZ)
|
||||||
//$$ ? chunkProvider.provideChunk(chunkX, chunkZ) : null;
|
//$$ ? chunkProvider.provideChunk(chunkX, chunkZ) : null;
|
||||||
//#endif
|
//#endif
|
||||||
|
//#endif
|
||||||
if (newChunk != null) {
|
if (newChunk != null) {
|
||||||
newChunk.addEntity(entity);
|
newChunk.addEntity(entity);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -54,11 +54,15 @@ public class NoGuiScreenshot {
|
|||||||
mc.getFramebuffer().bindFramebuffer(true);
|
mc.getFramebuffer().bindFramebuffer(true);
|
||||||
GlStateManager.enableTexture2D();
|
GlStateManager.enableTexture2D();
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
mc.entityRenderer.renderWorld(mc.timer.renderPartialTicks, System.nanoTime());
|
||||||
|
//#else
|
||||||
//#if MC>=10809
|
//#if MC>=10809
|
||||||
mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks, System.nanoTime());
|
//$$ mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks, System.nanoTime());
|
||||||
//#else
|
//#else
|
||||||
//$$ mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks);
|
//$$ mc.entityRenderer.updateCameraAndRender(mc.timer.renderPartialTicks);
|
||||||
//#endif
|
//#endif
|
||||||
|
//#endif
|
||||||
|
|
||||||
mc.getFramebuffer().unbindFramebuffer();
|
mc.getFramebuffer().unbindFramebuffer();
|
||||||
GlStateManager.popMatrix();
|
GlStateManager.popMatrix();
|
||||||
@@ -79,7 +83,12 @@ public class NoGuiScreenshot {
|
|||||||
// disk for better maintainability
|
// disk for better maintainability
|
||||||
File tmpFolder = Files.createTempDir();
|
File tmpFolder = Files.createTempDir();
|
||||||
try {
|
try {
|
||||||
ScreenShotHelper.saveScreenshot(tmpFolder, "tmp", frameWidth, frameHeight, mc.getFramebuffer());
|
//#if MC>=11300
|
||||||
|
ScreenShotHelper.saveScreenshot(tmpFolder, "tmp", frameWidth, frameHeight, mc.getFramebuffer(), (msg) ->
|
||||||
|
mc.addScheduledTask(() -> mc.ingameGUI.getChatGUI().printChatMessage(msg)));
|
||||||
|
//#else
|
||||||
|
//$$ ScreenShotHelper.saveScreenshot(tmpFolder, "tmp", frameWidth, frameHeight, mc.getFramebuffer());
|
||||||
|
//#endif
|
||||||
File screenshotFile = new File(tmpFolder, "screenshots/tmp");
|
File screenshotFile = new File(tmpFolder, "screenshots/tmp");
|
||||||
BufferedImage image = ImageIO.read(screenshotFile);
|
BufferedImage image = ImageIO.read(screenshotFile);
|
||||||
int imageWidth = image.getWidth();
|
int imageWidth = image.getWidth();
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.google.common.base.Function;
|
|||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
import com.replaymod.core.KeyBindingRegistry;
|
||||||
|
import com.replaymod.core.Module;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.utils.ModCompat;
|
import com.replaymod.core.utils.ModCompat;
|
||||||
import com.replaymod.core.versions.MCVer;
|
import com.replaymod.core.versions.MCVer;
|
||||||
@@ -29,23 +31,12 @@ import com.replaymod.core.versions.MCVer.Keyboard;
|
|||||||
//$$ import org.lwjgl.input.Keyboard;
|
//$$ import org.lwjgl.input.Keyboard;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10800
|
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
//#else
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ReplayModReplay extends ReplayMod.Module {
|
public class ReplayModReplay implements Module {
|
||||||
|
|
||||||
{ instance = this; }
|
{ instance = this; }
|
||||||
public static ReplayModReplay instance;
|
public static ReplayModReplay instance;
|
||||||
@@ -64,13 +55,13 @@ public class ReplayModReplay extends ReplayMod.Module {
|
|||||||
|
|
||||||
public ReplayModReplay(ReplayMod core) {
|
public ReplayModReplay(ReplayMod core) {
|
||||||
this.core = core;
|
this.core = core;
|
||||||
|
|
||||||
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
public void registerKeyBindings(KeyBindingRegistry registry) {
|
||||||
core.getSettingsRegistry().register(Setting.class);
|
registry.registerKeyBinding("replaymod.input.marker", MCVer.Keyboard.KEY_M, new Runnable() {
|
||||||
|
|
||||||
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.marker", MCVer.Keyboard.KEY_M, new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (replayHandler != null ) {
|
if (replayHandler != null ) {
|
||||||
@@ -91,7 +82,7 @@ public class ReplayModReplay extends ReplayMod.Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
core.getKeyBindingRegistry().registerRaw(Keyboard.KEY_DELETE, () -> {
|
registry.registerRaw(Keyboard.KEY_DELETE, () -> {
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
GuiMarkerTimeline timeline = replayHandler.getOverlay().timeline;
|
GuiMarkerTimeline timeline = replayHandler.getOverlay().timeline;
|
||||||
if (timeline.getSelectedMarker() != null) {
|
if (timeline.getSelectedMarker() != null) {
|
||||||
@@ -102,7 +93,7 @@ public class ReplayModReplay extends ReplayMod.Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.thumbnail", Keyboard.KEY_N, new Runnable() {
|
registry.registerKeyBinding("replaymod.input.thumbnail", Keyboard.KEY_N, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
@@ -130,7 +121,7 @@ public class ReplayModReplay extends ReplayMod.Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.playpause", Keyboard.KEY_P, new Runnable() {
|
registry.registerKeyBinding("replaymod.input.playpause", Keyboard.KEY_P, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
@@ -139,7 +130,7 @@ public class ReplayModReplay extends ReplayMod.Module {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.quickmode", Keyboard.KEY_Q, () -> {
|
registry.registerKeyBinding("replaymod.input.quickmode", Keyboard.KEY_Q, () -> {
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
replayHandler.getReplaySender().setSyncModeAndWait();
|
replayHandler.getReplaySender().setSyncModeAndWait();
|
||||||
core.runLater(() ->
|
core.runLater(() ->
|
||||||
@@ -161,7 +152,10 @@ public class ReplayModReplay extends ReplayMod.Module {
|
|||||||
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.resettilt", Keyboard.KEY_K, () -> {
|
core.getKeyBindingRegistry().registerKeyBinding("replaymod.input.resettilt", Keyboard.KEY_K, () -> {
|
||||||
Optional.ofNullable(replayHandler).map(ReplayHandler::getCameraEntity).ifPresent(c -> c.roll = 0);
|
Optional.ofNullable(replayHandler).map(ReplayHandler::getCameraEntity).ifPresent(c -> c.roll = 0);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initClient() {
|
||||||
cameraControllerRegistry.register("replaymod.camera.classic", new Function<CameraEntity, CameraController>() {
|
cameraControllerRegistry.register("replaymod.camera.classic", new Function<CameraEntity, CameraController>() {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@@ -176,21 +170,13 @@ public class ReplayModReplay extends ReplayMod.Module {
|
|||||||
return new VanillaCameraController(core.getMinecraft(), cameraEntity);
|
return new VanillaCameraController(core.getMinecraft(), cameraEntity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(FMLInitializationEvent event) {
|
|
||||||
Minecraft mc = core.getMinecraft();
|
Minecraft mc = core.getMinecraft();
|
||||||
// FIXME mc.timer = new InputReplayTimer(mc.timer, this);
|
// FIXME mc.timer = new InputReplayTimer(mc.timer, this);
|
||||||
|
|
||||||
new GuiHandler(this).register();
|
new GuiHandler(this).register();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postInit(FMLPostInitializationEvent event) {
|
|
||||||
Setting.CAMERA.setChoices(new ArrayList<>(cameraControllerRegistry.getControllers()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startReplay(File file) throws IOException {
|
public void startReplay(File file) throws IOException {
|
||||||
startReplay(new ZipReplayFile(new ReplayStudio(), file));
|
startReplay(new ZipReplayFile(new ReplayStudio(), file));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package com.replaymod.replay.camera;
|
|||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.replaymod.replay.Setting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -14,6 +16,7 @@ public class CameraControllerRegistry {
|
|||||||
public void register(String name, Function<CameraEntity, CameraController> constructor) {
|
public void register(String name, Function<CameraEntity, CameraController> constructor) {
|
||||||
Preconditions.checkState(!constructors.containsKey(name), "Controller " + name + " is already registered.");
|
Preconditions.checkState(!constructors.containsKey(name), "Controller " + name + " is already registered.");
|
||||||
constructors.put(name, constructor);
|
constructors.put(name, constructor);
|
||||||
|
Setting.CAMERA.setChoices(new ArrayList<>(getControllers()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getControllers() {
|
public Set<String> getControllers() {
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ A Mod which allows you to record, replay and share your Minecraft experience.
|
|||||||
[[dependencies.replaymod]]
|
[[dependencies.replaymod]]
|
||||||
modId="forge"
|
modId="forge"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[14.23.2.0,)"
|
versionRange="[15.0,)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
[[dependencies.replaymod]]
|
[[dependencies.replaymod]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[ 1.13 ]"
|
versionRange="[ 1.13.2 ]"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
@@ -79,9 +79,8 @@ minecraft {
|
|||||||
if (FG3) {
|
if (FG3) {
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
workingDirectory project.file('eclipse')
|
workingDirectory rootProject.file('eclipse')
|
||||||
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
|
property 'forge.logging.console.level', 'info'
|
||||||
property 'forge.logging.console.level', 'debug'
|
|
||||||
mods {
|
mods {
|
||||||
replaymod {
|
replaymod {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
|
|||||||
Reference in New Issue
Block a user