Get extras module compiling on 1.13
Remove LocalizationExtra (too much update work for too little gain)
This commit is contained in:
@@ -8,6 +8,7 @@ import com.replaymod.core.handler.MainMenuHandler;
|
|||||||
import com.replaymod.core.utils.OpenGLUtils;
|
import com.replaymod.core.utils.OpenGLUtils;
|
||||||
import com.replaymod.core.versions.MCVer;
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.editor.ReplayModEditor;
|
import com.replaymod.editor.ReplayModEditor;
|
||||||
|
import com.replaymod.extras.ReplayModExtras;
|
||||||
import com.replaymod.online.ReplayModOnline;
|
import com.replaymod.online.ReplayModOnline;
|
||||||
import com.replaymod.recording.ReplayModRecording;
|
import com.replaymod.recording.ReplayModRecording;
|
||||||
import com.replaymod.render.ReplayModRender;
|
import com.replaymod.render.ReplayModRender;
|
||||||
@@ -172,6 +173,7 @@ public class ReplayMod implements Module {
|
|||||||
modules.add(new ReplayModRender(this));
|
modules.add(new ReplayModRender(this));
|
||||||
modules.add(new ReplayModSimplePathing(this));
|
modules.add(new ReplayModSimplePathing(this));
|
||||||
modules.add(new ReplayModEditor(this));
|
modules.add(new ReplayModEditor(this));
|
||||||
|
modules.add(new ReplayModExtras(this));
|
||||||
|
|
||||||
//#if MC>=11300
|
//#if MC>=11300
|
||||||
settingsRegistry.register();
|
settingsRegistry.register();
|
||||||
|
|||||||
@@ -8,11 +8,21 @@ import com.replaymod.replay.gui.overlay.GuiReplayOverlay;
|
|||||||
import de.johni0702.minecraft.gui.element.GuiImage;
|
import de.johni0702.minecraft.gui.element.GuiImage;
|
||||||
import de.johni0702.minecraft.gui.element.IGuiImage;
|
import de.johni0702.minecraft.gui.element.IGuiImage;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
|
||||||
import org.lwjgl.input.Keyboard;
|
//#if MC>=11300
|
||||||
|
import com.replaymod.core.versions.MCVer.Keyboard;
|
||||||
|
import net.minecraft.client.GameSettings;
|
||||||
|
//#else
|
||||||
|
//$$ import net.minecraft.client.settings.GameSettings;
|
||||||
|
//$$ import org.lwjgl.input.Keyboard;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10800
|
//#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.TickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||||
//#else
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
@@ -28,7 +38,11 @@ public class FullBrightness implements Extra {
|
|||||||
|
|
||||||
private GameSettings gameSettings;
|
private GameSettings gameSettings;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
private float originalGamma;
|
//#if MC>=11300
|
||||||
|
private double originalGamma;
|
||||||
|
//#else
|
||||||
|
//$$ private float originalGamma;
|
||||||
|
//#endif
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(final ReplayMod mod) throws Exception {
|
public void register(final ReplayMod mod) throws Exception {
|
||||||
@@ -39,7 +53,11 @@ public class FullBrightness implements Extra {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
active = !active;
|
active = !active;
|
||||||
mod.getMinecraft().entityRenderer.lightmapUpdateNeeded = true;
|
//#if MC>=11300
|
||||||
|
// FIXME check if this is no longer required (especially when replay is paused)
|
||||||
|
//#else
|
||||||
|
//$$ mod.getMinecraft().entityRenderer.lightmapUpdateNeeded = true;
|
||||||
|
//#endif
|
||||||
ReplayHandler replayHandler = module.getReplayHandler();
|
ReplayHandler replayHandler = module.getReplayHandler();
|
||||||
if (replayHandler != null) {
|
if (replayHandler != null) {
|
||||||
updateIndicator(replayHandler.getOverlay());
|
updateIndicator(replayHandler.getOverlay());
|
||||||
|
|||||||
@@ -16,13 +16,21 @@ import de.johni0702.minecraft.gui.layout.CustomLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.GridLayout;
|
import de.johni0702.minecraft.gui.layout.GridLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.LayoutData;
|
import de.johni0702.minecraft.gui.layout.LayoutData;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
import org.lwjgl.util.Dimension;
|
//#if MC>=11300
|
||||||
import org.lwjgl.util.ReadableDimension;
|
//#else
|
||||||
|
//$$ import org.lwjgl.input.Keyboard;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10800
|
//#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
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -89,7 +97,11 @@ public class HotkeyButtons implements Extra {
|
|||||||
// There doesn't seem to be an KeyBindingUpdate event, so we'll just update it every time
|
// There doesn't seem to be an KeyBindingUpdate event, so we'll just update it every time
|
||||||
String keyName = "???";
|
String keyName = "???";
|
||||||
try {
|
try {
|
||||||
keyName = Keyboard.getKeyName(keyBinding.getKeyCode());
|
//#if MC>=11300
|
||||||
|
keyName = keyBinding.func_197978_k();
|
||||||
|
//#else
|
||||||
|
//$$ keyName = Keyboard.getKeyName(keyBinding.getKeyCode());
|
||||||
|
//#endif
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
// Apparently windows likes to press strange keys, see https://www.replaymod.com/forum/thread/55
|
// Apparently windows likes to press strange keys, see https://www.replaymod.com/forum/thread/55
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
package com.replaymod.extras;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.replaymod.compat.optifine.OptifineReflection;
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.resources.IResourcePack;
|
|
||||||
import net.minecraft.client.resources.data.IMetadataSection;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
//#if MC>=10904
|
|
||||||
import net.minecraft.client.resources.data.MetadataSerializer;
|
|
||||||
//#else
|
|
||||||
//$$ import net.minecraft.client.resources.data.IMetadataSerializer;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipInputStream;
|
|
||||||
|
|
||||||
import static com.replaymod.extras.ReplayModExtras.LOGGER;
|
|
||||||
|
|
||||||
public class LocalizationExtra implements Extra {
|
|
||||||
private static final String ZIP_FILE_URL = "https://github.com/ReplayMod/Translations/archive/master.zip";
|
|
||||||
private static final String LANG_PREFIX = "Translations-master/";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void register(ReplayMod mod) throws Exception {
|
|
||||||
final Minecraft mc = mod.getMinecraft();
|
|
||||||
if (Boolean.parseBoolean(System.getProperty("replaymod.offline", "false"))) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Thread localizedResourcePackLoader = new Thread(() -> {
|
|
||||||
try {
|
|
||||||
// Download zip of lang files
|
|
||||||
LOGGER.debug("Downloading languages from {}", ZIP_FILE_URL);
|
|
||||||
Map<String, byte[]> languages = new HashMap<>();
|
|
||||||
try (InputStream urlIn = new URL(ZIP_FILE_URL).openStream();
|
|
||||||
ZipInputStream in = new ZipInputStream(urlIn)) {
|
|
||||||
ZipEntry entry;
|
|
||||||
while ((entry = in.getNextEntry()) != null) {
|
|
||||||
String name = entry.getName();
|
|
||||||
if (!name.startsWith(LANG_PREFIX) || !name.endsWith(".lang")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
name = name.substring(LANG_PREFIX.length());
|
|
||||||
languages.put(name, IOUtils.toByteArray(in));
|
|
||||||
LOGGER.debug("Added language file {}", name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LOGGER.debug("Downloaded {} languages", languages.size());
|
|
||||||
|
|
||||||
// Add lang files as resource pack
|
|
||||||
mc.addScheduledTask(() -> {
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
|
|
||||||
defaultResourcePacks.add(new LocalizedResourcePack(languages));
|
|
||||||
mc.getLanguageManager().onResourceManagerReload(mc.getResourceManager());
|
|
||||||
// Optifine does its own, additional language data loading
|
|
||||||
OptifineReflection.reloadLang();
|
|
||||||
LOGGER.debug("Added language files to resource packs and reloaded LanguageManager");
|
|
||||||
});
|
|
||||||
} catch (Throwable t) {
|
|
||||||
LOGGER.error("Loading localized resource pack:", t);
|
|
||||||
}
|
|
||||||
}, "localizedResourcePackLoader");
|
|
||||||
localizedResourcePackLoader.setDaemon(true);
|
|
||||||
localizedResourcePackLoader.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class LocalizedResourcePack implements IResourcePack {
|
|
||||||
private final Pattern LANG_PATTERN = Pattern.compile("^lang/([.+].lang)$");
|
|
||||||
private final Map<String, byte[]> languages;
|
|
||||||
|
|
||||||
public LocalizedResourcePack(Map<String, byte[]> languages) {
|
|
||||||
this.languages = languages;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public InputStream getInputStream(ResourceLocation loc) {
|
|
||||||
if (!"replaymod".equals(loc.getResourceDomain())) return null;
|
|
||||||
Matcher matcher = LANG_PATTERN.matcher(loc.getResourcePath());
|
|
||||||
if (matcher.matches()) {
|
|
||||||
byte[] bytes = languages.get(matcher.group());
|
|
||||||
if (bytes != null) {
|
|
||||||
return new ByteArrayInputStream(bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean resourceExists(ResourceLocation loc) {
|
|
||||||
// Assumes that getInputStream returns a ByteArrayInputStream that doesn't need to be closed
|
|
||||||
return getInputStream(loc) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getResourceDomains() {
|
|
||||||
return ImmutableSet.of("replaymod");
|
|
||||||
}
|
|
||||||
|
|
||||||
//#if MC>=10904
|
|
||||||
@Override
|
|
||||||
public <T extends IMetadataSection> T getPackMetadata(MetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
|
|
||||||
//#else
|
|
||||||
//$$ @Override
|
|
||||||
//$$ public IMetadataSection getPackMetadata(IMetadataSerializer metadataSerializer, String metadataSectionName) throws IOException {
|
|
||||||
//#endif
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BufferedImage getPackImage() throws IOException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPackName() {
|
|
||||||
return "ReplayModLocalizationResourcePack";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package com.replaymod.extras;
|
|||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.Setting;
|
import com.replaymod.core.Setting;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||||
import de.johni0702.minecraft.gui.container.GuiContainer;
|
import de.johni0702.minecraft.gui.container.GuiContainer;
|
||||||
import de.johni0702.minecraft.gui.container.GuiPanel;
|
import de.johni0702.minecraft.gui.container.GuiPanel;
|
||||||
@@ -16,11 +17,15 @@ import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
|||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
//#if MC>=11300
|
||||||
|
import net.minecraftforge.fml.ModList;
|
||||||
|
//#else
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import net.minecraftforge.fml.common.Loader;
|
//$$ import net.minecraftforge.fml.common.Loader;
|
||||||
//#else
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.Loader;
|
//$$ import cpw.mods.fml.common.Loader;
|
||||||
//#endif
|
//#endif
|
||||||
|
//#endif
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -34,7 +39,7 @@ import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
|||||||
import static com.replaymod.extras.ReplayModExtras.LOGGER;
|
import static com.replaymod.extras.ReplayModExtras.LOGGER;
|
||||||
|
|
||||||
public class OpenEyeExtra implements Extra {
|
public class OpenEyeExtra implements Extra {
|
||||||
private static final String DOWNLOAD_URL = "https://www.replaymod.com/dl/openeye/" + Loader.MC_VERSION;
|
private static final String DOWNLOAD_URL = "https://www.replaymod.com/dl/openeye/" + ReplayMod.getMinecraftVersion();
|
||||||
private static final Setting<Boolean> ASK_FOR_OPEN_EYE = new Setting<>("advanced", "askForOpenEye", null, true);
|
private static final Setting<Boolean> ASK_FOR_OPEN_EYE = new Setting<>("advanced", "askForOpenEye", null, true);
|
||||||
|
|
||||||
private ReplayMod mod;
|
private ReplayMod mod;
|
||||||
@@ -42,9 +47,13 @@ public class OpenEyeExtra implements Extra {
|
|||||||
@Override
|
@Override
|
||||||
public void register(ReplayMod mod) throws Exception {
|
public void register(ReplayMod mod) throws Exception {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
mod.getSettingsRegistry().register(ASK_FOR_OPEN_EYE);
|
|
||||||
|
|
||||||
if (!Loader.isModLoaded("OpenEye") && mod.getSettingsRegistry().get(ASK_FOR_OPEN_EYE)) {
|
//#if MC>=11300
|
||||||
|
boolean isOpenEyeLoaded = ModList.get().isLoaded("openeye");
|
||||||
|
//#else
|
||||||
|
//$$ boolean isOpenEyeLoaded = Loader.isModLoaded("OpenEye");
|
||||||
|
//#endif
|
||||||
|
if (!isOpenEyeLoaded && mod.getSettingsRegistry().get(ASK_FOR_OPEN_EYE)) {
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
LOGGER.trace("Checking for OpenEye availability");
|
LOGGER.trace("Checking for OpenEye availability");
|
||||||
@@ -93,7 +102,7 @@ public class OpenEyeExtra implements Extra {
|
|||||||
GuiPopup popup = new GuiPopup(OfferGui.this);
|
GuiPopup popup = new GuiPopup(OfferGui.this);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
File targetFile = new File(mod.getMinecraft().mcDataDir, "mods/" + Loader.MC_VERSION + "/OpenEye.jar");
|
File targetFile = new File(MCVer.mcDataDir(mod.getMinecraft()), "mods/" + ReplayMod.getMinecraftVersion() + "/OpenEye.jar");
|
||||||
FileUtils.forceMkdir(targetFile.getParentFile());
|
FileUtils.forceMkdir(targetFile.getParentFile());
|
||||||
|
|
||||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(DOWNLOAD_URL).openConnection();
|
HttpsURLConnection connection = (HttpsURLConnection) new URL(DOWNLOAD_URL).openConnection();
|
||||||
|
|||||||
@@ -1,40 +1,22 @@
|
|||||||
package com.replaymod.extras;
|
package com.replaymod.extras;
|
||||||
|
|
||||||
|
import com.replaymod.core.Module;
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.extras.advancedscreenshots.AdvancedScreenshots;
|
import com.replaymod.extras.advancedscreenshots.AdvancedScreenshots;
|
||||||
import com.replaymod.extras.playeroverview.PlayerOverview;
|
import com.replaymod.extras.playeroverview.PlayerOverview;
|
||||||
import com.replaymod.extras.urischeme.UriSchemeExtra;
|
import com.replaymod.extras.urischeme.UriSchemeExtra;
|
||||||
import com.replaymod.extras.youtube.YoutubeUpload;
|
import com.replaymod.extras.youtube.YoutubeUpload;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
//#if MC>=10800
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
//#else
|
|
||||||
//$$ import cpw.mods.fml.common.Mod;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
|
||||||
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Mod(modid = ReplayModExtras.MOD_ID,
|
public class ReplayModExtras implements Module {
|
||||||
version = "@MOD_VERSION@",
|
{ instance = this; }
|
||||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
|
||||||
acceptableRemoteVersions = "*",
|
|
||||||
//#if MC>=10800
|
|
||||||
clientSideOnly = true,
|
|
||||||
//#endif
|
|
||||||
useMetadata = true)
|
|
||||||
public class ReplayModExtras {
|
|
||||||
public static final String MOD_ID = "replaymod-extras";
|
|
||||||
|
|
||||||
@Mod.Instance(MOD_ID)
|
|
||||||
public static ReplayModExtras instance;
|
public static ReplayModExtras instance;
|
||||||
|
|
||||||
private static final List<Class<? extends Extra>> builtin = Arrays.asList(
|
private static final List<Class<? extends Extra>> builtin = Arrays.asList(
|
||||||
@@ -44,22 +26,19 @@ public class ReplayModExtras {
|
|||||||
YoutubeUpload.class,
|
YoutubeUpload.class,
|
||||||
FullBrightness.class,
|
FullBrightness.class,
|
||||||
HotkeyButtons.class,
|
HotkeyButtons.class,
|
||||||
LocalizationExtra.class,
|
|
||||||
OpenEyeExtra.class
|
OpenEyeExtra.class
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Map<Class<? extends Extra>, Extra> instances = new HashMap<>();
|
private final Map<Class<? extends Extra>, Extra> instances = new HashMap<>();
|
||||||
|
|
||||||
public static Logger LOGGER;
|
public static Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
@Mod.EventHandler
|
public ReplayModExtras(ReplayMod core) {
|
||||||
public void preInit(FMLPreInitializationEvent event) {
|
core.getSettingsRegistry().register(Setting.class);
|
||||||
LOGGER = event.getModLog();
|
|
||||||
ReplayMod.instance.getSettingsRegistry().register(Setting.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mod.EventHandler
|
@Override
|
||||||
public void init(FMLInitializationEvent event) {
|
public void initClient() {
|
||||||
for (Class<? extends Extra> cls : builtin) {
|
for (Class<? extends Extra> cls : builtin) {
|
||||||
try {
|
try {
|
||||||
Extra extra = cls.newInstance();
|
Extra extra = cls.newInstance();
|
||||||
|
|||||||
@@ -1,15 +1,26 @@
|
|||||||
package com.replaymod.extras.advancedscreenshots;
|
package com.replaymod.extras.advancedscreenshots;
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.extras.Extra;
|
import com.replaymod.extras.Extra;
|
||||||
import com.replaymod.replay.events.ReplayDispatchKeypressesEvent;
|
import com.replaymod.replay.events.ReplayDispatchKeypressesEvent;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiControls;
|
import net.minecraft.client.gui.GuiControls;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
//#if MC>=11300
|
||||||
|
import com.replaymod.core.versions.MCVer.Keyboard;
|
||||||
|
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||||
|
//#else
|
||||||
|
//$$ import org.lwjgl.input.Keyboard;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10800
|
//#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
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -18,7 +29,7 @@ public class AdvancedScreenshots implements Extra {
|
|||||||
|
|
||||||
private ReplayMod mod;
|
private ReplayMod mod;
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = MCVer.getMinecraft();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(ReplayMod mod) throws Exception {
|
public void register(ReplayMod mod) throws Exception {
|
||||||
@@ -28,19 +39,20 @@ public class AdvancedScreenshots implements Extra {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onDispatchKeypresses(ReplayDispatchKeypressesEvent.Pre event) {
|
public void onDispatchKeypresses(ReplayDispatchKeypressesEvent.Pre event) {
|
||||||
int keyCode = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey();
|
if (mc.currentScreen instanceof GuiControls) return;
|
||||||
|
//#if MC>=11300
|
||||||
|
// FIXME
|
||||||
|
//#else
|
||||||
|
//$$ if (!Keyboard.getEventKeyState()) return;
|
||||||
|
//$$ if (Keyboard.isRepeatEvent()) return;
|
||||||
|
//$$ int keyCode = Keyboard.getEventKey() == 0 ? Keyboard.getEventCharacter() : Keyboard.getEventKey();
|
||||||
|
//$$ if (keyCode == 0 || keyCode != mc.gameSettings.keyBindScreenshot.getKeyCode()) return;
|
||||||
|
//#endif
|
||||||
|
|
||||||
// all the conditions required to trigger a screenshot condensed in a single if statement
|
ReplayMod.instance.runLater(() -> {
|
||||||
if (keyCode != 0 && !Keyboard.isRepeatEvent()
|
new GuiCreateScreenshot(mod).display();
|
||||||
&& (!(mc.currentScreen instanceof GuiControls) || ((GuiControls) mc.currentScreen).time <= mc.getSystemTime() - 20L)
|
});
|
||||||
&& Keyboard.getEventKeyState()
|
|
||||||
&& keyCode == mc.gameSettings.keyBindScreenshot.getKeyCode()) {
|
|
||||||
|
|
||||||
ReplayMod.instance.runLater(() -> {
|
event.setCanceled(true);
|
||||||
new GuiCreateScreenshot(mod).display();
|
|
||||||
});
|
|
||||||
|
|
||||||
event.setCanceled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.replaymod.extras.advancedscreenshots;
|
package com.replaymod.extras.advancedscreenshots;
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.render.RenderSettings;
|
import com.replaymod.render.RenderSettings;
|
||||||
import com.replaymod.render.gui.GuiRenderSettings;
|
import com.replaymod.render.gui.GuiRenderSettings;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
@@ -12,10 +13,9 @@ import de.johni0702.minecraft.gui.layout.GridLayout;
|
|||||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.util.ScreenShotHelper;
|
import net.minecraft.util.ScreenShotHelper;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
|
||||||
import net.minecraftforge.common.config.Property;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static com.replaymod.core.utils.Utils.error;
|
import static com.replaymod.core.utils.Utils.error;
|
||||||
@@ -82,13 +82,12 @@ public class GuiCreateScreenshot extends GuiRenderSettings implements Loadable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected File generateOutputFile(RenderSettings.EncodingPreset encodingPreset) {
|
protected File generateOutputFile(RenderSettings.EncodingPreset encodingPreset) {
|
||||||
File screenshotFolder = new File(getMinecraft().mcDataDir, "screenshots");
|
File screenshotFolder = new File(MCVer.mcDataDir(getMinecraft()), "screenshots");
|
||||||
return ScreenShotHelper.getTimestampedPNGFileForDirectory(screenshotFolder);
|
return ScreenShotHelper.getTimestampedPNGFileForDirectory(screenshotFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Property getConfigProperty(Configuration configuration) {
|
protected Path getSettingsPath() {
|
||||||
return configuration.get("screenshotsettings", "settings", "{}",
|
return MCVer.mcDataDir(getMinecraft()).toPath().resolve("config/replaymod-screenshotsettings.json");
|
||||||
"Last state of the screenshot settings GUI. Internal use only.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,7 +12,7 @@ import de.johni0702.minecraft.gui.element.GuiLabel;
|
|||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||||
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||||
import org.lwjgl.util.ReadableColor;
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.replaymod.extras.advancedscreenshots;
|
package com.replaymod.extras.advancedscreenshots;
|
||||||
|
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.render.RenderSettings;
|
import com.replaymod.render.RenderSettings;
|
||||||
import com.replaymod.render.capturer.RenderInfo;
|
import com.replaymod.render.capturer.RenderInfo;
|
||||||
import com.replaymod.render.rendering.Pipelines;
|
import com.replaymod.render.rendering.Pipelines;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import org.lwjgl.util.Dimension;
|
|
||||||
import org.lwjgl.util.ReadableDimension;
|
|
||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
||||||
@@ -16,7 +17,7 @@ import com.replaymod.render.hooks.ChunkLoadingRenderGlobal;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ScreenshotRenderer implements RenderInfo {
|
public class ScreenshotRenderer implements RenderInfo {
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = MCVer.getMinecraft();
|
||||||
|
|
||||||
private final RenderSettings settings;
|
private final RenderSettings settings;
|
||||||
|
|
||||||
@@ -24,8 +25,12 @@ public class ScreenshotRenderer implements RenderInfo {
|
|||||||
|
|
||||||
public boolean renderScreenshot() throws Throwable {
|
public boolean renderScreenshot() throws Throwable {
|
||||||
try {
|
try {
|
||||||
int displayWidthBefore = mc.displayWidth;
|
//#if MC>=11300
|
||||||
int displayHeightBefore = mc.displayHeight;
|
// FIXME
|
||||||
|
//#else
|
||||||
|
//$$ int displayWidthBefore = mc.displayWidth;
|
||||||
|
//$$ int displayHeightBefore = mc.displayHeight;
|
||||||
|
//#endif
|
||||||
|
|
||||||
boolean hideGUIBefore = mc.gameSettings.hideGUI;
|
boolean hideGUIBefore = mc.gameSettings.hideGUI;
|
||||||
mc.gameSettings.hideGUI = true;
|
mc.gameSettings.hideGUI = true;
|
||||||
@@ -42,12 +47,16 @@ public class ScreenshotRenderer implements RenderInfo {
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
mc.gameSettings.hideGUI = hideGUIBefore;
|
mc.gameSettings.hideGUI = hideGUIBefore;
|
||||||
mc.resize(displayWidthBefore, displayHeightBefore);
|
//#if MC>=11300
|
||||||
|
// FIXME
|
||||||
|
//#else
|
||||||
|
//$$ mc.resize(displayWidthBefore, displayHeightBefore);
|
||||||
|
//#endif
|
||||||
return true;
|
return true;
|
||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
CrashReport report = CrashReport.makeCrashReport(e, "Creating Equirectangular Screenshot");
|
CrashReport report = CrashReport.makeCrashReport(e, "Creating Equirectangular Screenshot");
|
||||||
Minecraft.getMinecraft().crashed(report);
|
MCVer.getMinecraft().crashed(report);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ package com.replaymod.extras.advancedscreenshots;
|
|||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
import com.replaymod.core.ReplayMod;
|
||||||
import com.replaymod.core.utils.Utils;
|
import com.replaymod.core.utils.Utils;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.extras.ReplayModExtras;
|
import com.replaymod.extras.ReplayModExtras;
|
||||||
import com.replaymod.render.frame.RGBFrame;
|
import com.replaymod.render.frame.RGBFrame;
|
||||||
import com.replaymod.render.rendering.FrameConsumer;
|
import com.replaymod.render.rendering.FrameConsumer;
|
||||||
import com.replaymod.replay.ReplayModReplay;
|
import com.replaymod.replay.ReplayModReplay;
|
||||||
import net.minecraft.client.Minecraft;
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import org.lwjgl.util.ReadableDimension;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@@ -48,7 +48,7 @@ public class ScreenshotWriter implements FrameConsumer<RGBFrame> {
|
|||||||
} catch (OutOfMemoryError e) {
|
} catch (OutOfMemoryError e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
CrashReport report = CrashReport.makeCrashReport(e, "Exporting frame");
|
CrashReport report = CrashReport.makeCrashReport(e, "Exporting frame");
|
||||||
Minecraft.getMinecraft().crashed(report);
|
MCVer.getMinecraft().crashed(report);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
CrashReport report = CrashReport.makeCrashReport(t, "Exporting frame");
|
CrashReport report = CrashReport.makeCrashReport(t, "Exporting frame");
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,19 @@ import com.replaymod.replay.events.ReplayOpenEvent;
|
|||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraftforge.client.event.RenderHandEvent;
|
import net.minecraftforge.client.event.RenderHandEvent;
|
||||||
import org.lwjgl.input.Keyboard;
|
|
||||||
|
//#if MC>=11300
|
||||||
|
//#else
|
||||||
|
//$$ import org.lwjgl.input.Keyboard;
|
||||||
|
//#endif
|
||||||
|
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
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
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.EventPriority;
|
//$$ import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|||||||
@@ -18,15 +18,13 @@ import de.johni0702.minecraft.gui.function.Closeable;
|
|||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
import de.johni0702.minecraft.gui.layout.HorizontalLayout;
|
||||||
import de.johni0702.minecraft.gui.utils.Colors;
|
import de.johni0702.minecraft.gui.utils.Colors;
|
||||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.lwjgl.util.Dimension;
|
|
||||||
import org.lwjgl.util.ReadableDimension;
|
|
||||||
|
|
||||||
//#if MC>=10904
|
//#if MC>=10904
|
||||||
import net.minecraft.init.MobEffects;
|
import net.minecraft.init.MobEffects;
|
||||||
import net.minecraft.init.SoundEvents;
|
|
||||||
//#else
|
//#else
|
||||||
//$$ import net.minecraft.potion.Potion;
|
//$$ import net.minecraft.potion.Potion;
|
||||||
//#endif
|
//#endif
|
||||||
@@ -55,30 +53,12 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox checkAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
//#if MC>=10904
|
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
|
||||||
//#else
|
|
||||||
//#if MC>=10800
|
|
||||||
//$$ getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
|
||||||
//#else
|
|
||||||
//$$ getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.createPositionedSoundRecord(BUTTON_SOUND, 1.0F));
|
|
||||||
//#endif
|
|
||||||
//#endif
|
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(true);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
}.setLabel("").setChecked(true).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.showall"));
|
||||||
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
public final GuiCheckbox uncheckAll = new GuiCheckbox(contentPanel){
|
||||||
@Override
|
@Override
|
||||||
public void onClick() {
|
public void onClick() {
|
||||||
//#if MC>=10904
|
|
||||||
getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(SoundEvents.UI_BUTTON_CLICK, 1.0F));
|
|
||||||
//#else
|
|
||||||
//#if MC>=10800
|
|
||||||
//$$ getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(BUTTON_SOUND, 1.0F));
|
|
||||||
//#else
|
|
||||||
//$$ getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.createPositionedSoundRecord(BUTTON_SOUND, 1.0F));
|
|
||||||
//#endif
|
|
||||||
//#endif
|
|
||||||
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
playersScrollable.forEach(IGuiCheckbox.class).setChecked(false);
|
||||||
}
|
}
|
||||||
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
}.setLabel("").setChecked(false).setTooltip(new GuiTooltip().setI18nText("replaymod.gui.playeroverview.hideall"));
|
||||||
@@ -135,11 +115,15 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
}
|
}
|
||||||
}.setSize(16, 16),
|
}.setSize(16, 16),
|
||||||
new GuiLabel().setText(
|
new GuiLabel().setText(
|
||||||
|
//#if MC>=11300
|
||||||
|
p.getName().getFormattedText()
|
||||||
|
//#else
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
p.getName()
|
//$$ p.getName()
|
||||||
//#else
|
//#else
|
||||||
//$$ p.getDisplayName()
|
//$$ p.getDisplayName()
|
||||||
//#endif
|
//#endif
|
||||||
|
//#endif
|
||||||
).setColor(isSpectator(p) ? Colors.DKGREY : Colors.WHITE)
|
).setColor(isSpectator(p) ? Colors.DKGREY : Colors.WHITE)
|
||||||
).onClick(new Runnable() {
|
).onClick(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -196,11 +180,15 @@ public class PlayerOverviewGui extends GuiScreen implements Closeable {
|
|||||||
public int compare(EntityPlayer o1, EntityPlayer o2) {
|
public int compare(EntityPlayer o1, EntityPlayer o2) {
|
||||||
if (isSpectator(o1) && !isSpectator(o2)) return 1;
|
if (isSpectator(o1) && !isSpectator(o2)) return 1;
|
||||||
if (isSpectator(o2) && !isSpectator(o1)) return -1;
|
if (isSpectator(o2) && !isSpectator(o1)) return -1;
|
||||||
|
//#if MC>=11300
|
||||||
|
return o1.getName().getFormattedText().compareToIgnoreCase(o2.getName().getFormattedText());
|
||||||
|
//#else
|
||||||
//#if MC>=10800
|
//#if MC>=10800
|
||||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
//$$ return o1.getName().compareToIgnoreCase(o2.getName());
|
||||||
//#else
|
//#else
|
||||||
//$$ return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
|
//$$ return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
|
||||||
//#endif
|
//#endif
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.replaymod.extras.urischeme;
|
package com.replaymod.extras.urischeme;
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.io.output.StringBuilderWriter;
|
import org.apache.commons.io.output.StringBuilderWriter;
|
||||||
@@ -17,7 +16,7 @@ public class LinuxUriScheme extends UriScheme {
|
|||||||
public void install() throws URISyntaxException, IOException {
|
public void install() throws URISyntaxException, IOException {
|
||||||
File file = new File("replaymod.desktop");
|
File file = new File("replaymod.desktop");
|
||||||
File iconFile = new File("replaymod-icon.jpg");
|
File iconFile = new File("replaymod-icon.jpg");
|
||||||
String path = ReplayMod.getContainer().getSource().getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"");
|
String path = findJarFile().getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"");
|
||||||
String content =
|
String content =
|
||||||
"[Desktop Entry]\n" +
|
"[Desktop Entry]\n" +
|
||||||
"Name=ReplayMod\n" +
|
"Name=ReplayMod\n" +
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import javax.swing.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.security.CodeSource;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public abstract class UriScheme {
|
public abstract class UriScheme {
|
||||||
@@ -82,4 +85,19 @@ public abstract class UriScheme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract void install() throws Exception;
|
public abstract void install() throws Exception;
|
||||||
|
|
||||||
|
File findJarFile() throws IOException {
|
||||||
|
CodeSource codeSource = UriScheme.class.getProtectionDomain().getCodeSource();
|
||||||
|
if (codeSource != null) {
|
||||||
|
URL location = codeSource.getLocation();
|
||||||
|
if (location != null) {
|
||||||
|
try {
|
||||||
|
return new File(location.toURI());
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new IOException("No jar file found. Is this a development environment?");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.replaymod.extras.urischeme;
|
package com.replaymod.extras.urischeme;
|
||||||
|
|
||||||
import com.replaymod.core.ReplayMod;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.io.output.StringBuilderWriter;
|
import org.apache.commons.io.output.StringBuilderWriter;
|
||||||
|
|
||||||
@@ -9,7 +8,7 @@ import java.io.IOException;
|
|||||||
public class WindowsUriScheme extends UriScheme {
|
public class WindowsUriScheme extends UriScheme {
|
||||||
@Override
|
@Override
|
||||||
public void install() throws IOException, InterruptedException {
|
public void install() throws IOException, InterruptedException {
|
||||||
String path = ReplayMod.getContainer().getSource().getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"");
|
String path = findJarFile().getAbsolutePath().replace("\\", "\\\\").replace("\"", "\\\"");
|
||||||
regAdd("\\replaymod /f /ve /d \"URL:replaymod Protocol\"");
|
regAdd("\\replaymod /f /ve /d \"URL:replaymod Protocol\"");
|
||||||
regAdd("\\replaymod /f /v \"URL Protocol\" /d \"\"");
|
regAdd("\\replaymod /f /v \"URL Protocol\" /d \"\"");
|
||||||
regAdd("\\replaymod\\shell\\open\\command /f /ve /d \"java -cp \\\"" + path + "\\\" " + UriScheme.class.getName() + " \\\"%1\\\"\"");
|
regAdd("\\replaymod\\shell\\open\\command /f /ve /d \"java -cp \\\"" + path + "\\\" " + UriScheme.class.getName() + " \\\"%1\\\"\"");
|
||||||
|
|||||||
@@ -18,12 +18,17 @@ import de.johni0702.minecraft.gui.element.advanced.GuiTextArea;
|
|||||||
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
import de.johni0702.minecraft.gui.layout.CustomLayout;
|
||||||
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||||
import de.johni0702.minecraft.gui.popup.GuiFileChooserPopup;
|
import de.johni0702.minecraft.gui.popup.GuiFileChooserPopup;
|
||||||
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||||
import joptsimple.internal.Strings;
|
import joptsimple.internal.Strings;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.lwjgl.Sys;
|
|
||||||
import org.lwjgl.util.ReadableDimension;
|
//#if MC>=11300
|
||||||
|
import net.minecraft.util.Util;
|
||||||
|
//#else
|
||||||
|
//$$ import org.lwjgl.Sys;
|
||||||
|
//#endif
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -213,7 +218,11 @@ public class GuiYoutubeUpload extends GuiScreen {
|
|||||||
try {
|
try {
|
||||||
Desktop.getDesktop().browse(new URL(url).toURI());
|
Desktop.getDesktop().browse(new URL(url).toURI());
|
||||||
} catch(Throwable throwable) {
|
} catch(Throwable throwable) {
|
||||||
Sys.openURL(url);
|
//#if MC>=11300
|
||||||
|
Util.getOSType().openURI(url);
|
||||||
|
//#else
|
||||||
|
//$$ Sys.openURL(url);
|
||||||
|
//#endif
|
||||||
}
|
}
|
||||||
upload = null;
|
upload = null;
|
||||||
progressBar.setLabel(I18n.format("replaymod.gui.ytuploadprogress.done", url));
|
progressBar.setLabel(I18n.format("replaymod.gui.ytuploadprogress.done", url));
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ import net.minecraftforge.client.event.GuiScreenEvent;
|
|||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
|
||||||
//#if MC>=10800
|
//#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
|
//#else
|
||||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
//#endif
|
//#endif
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.google.common.base.Suppliers;
|
|||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.SettableFuture;
|
import com.google.common.util.concurrent.SettableFuture;
|
||||||
|
import com.replaymod.core.versions.MCVer;
|
||||||
import com.replaymod.render.RenderSettings;
|
import com.replaymod.render.RenderSettings;
|
||||||
import com.replaymod.render.metadata.MetadataInjector;
|
import com.replaymod.render.metadata.MetadataInjector;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -78,7 +79,7 @@ public class YoutubeUploader {
|
|||||||
this.videoVisibility = videoVisibility;
|
this.videoVisibility = videoVisibility;
|
||||||
this.videoSnippet = videoSnippet;
|
this.videoSnippet = videoSnippet;
|
||||||
this.httpTransport = GoogleNetHttpTransport.newTrustedTransport();
|
this.httpTransport = GoogleNetHttpTransport.newTrustedTransport();
|
||||||
this.dataStoreFactory = new FileDataStoreFactory(minecraft.mcDataDir);
|
this.dataStoreFactory = new FileDataStoreFactory(MCVer.mcDataDir(minecraft));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,10 +297,9 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
this.replayHandler = replayHandler;
|
this.replayHandler = replayHandler;
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
|
|
||||||
Path path = ReplayModRender.instance.getRenderSettingsPath();
|
|
||||||
String json = "{}";
|
String json = "{}";
|
||||||
try {
|
try {
|
||||||
json = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
json = new String(Files.readAllBytes(getSettingsPath()), StandardCharsets.UTF_8);
|
||||||
} catch (FileNotFoundException ignored) {
|
} catch (FileNotFoundException ignored) {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Reading render settings:", e);
|
LOGGER.error("Reading render settings:", e);
|
||||||
@@ -507,6 +506,10 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
return new File(folder, fileName + "." + encodingPreset.getFileExtension());
|
return new File(folder, fileName + "." + encodingPreset.getFileExtension());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Path getSettingsPath() {
|
||||||
|
return ReplayModRender.instance.getRenderSettingsPath();
|
||||||
|
}
|
||||||
|
|
||||||
private RenderSettings getDefaultRenderSettings() {
|
private RenderSettings getDefaultRenderSettings() {
|
||||||
return new RenderSettings(RenderSettings.RenderMethod.DEFAULT, RenderSettings.EncodingPreset.MP4_DEFAULT, 1920, 1080, 60, 10 << 20, null,
|
return new RenderSettings(RenderSettings.RenderMethod.DEFAULT, RenderSettings.EncodingPreset.MP4_DEFAULT, 1920, 1080, 60, 10 << 20, null,
|
||||||
true, false, false, false, null, 360, 180, false, RenderSettings.AntiAliasing.NONE, "", RenderSettings.EncodingPreset.MP4_DEFAULT.getValue(), false);
|
true, false, false, false, null, 360, 180, false, RenderSettings.AntiAliasing.NONE, "", RenderSettings.EncodingPreset.MP4_DEFAULT.getValue(), false);
|
||||||
@@ -516,9 +519,8 @@ public class GuiRenderSettings extends GuiScreen implements Closeable {
|
|||||||
public void close() {
|
public void close() {
|
||||||
RenderSettings settings = save(true);
|
RenderSettings settings = save(true);
|
||||||
String json = new Gson().toJson(settings);
|
String json = new Gson().toJson(settings);
|
||||||
Path path = ReplayModRender.instance.getRenderSettingsPath();
|
|
||||||
try {
|
try {
|
||||||
Files.write(path, json.getBytes(StandardCharsets.UTF_8));
|
Files.write(getSettingsPath(), json.getBytes(StandardCharsets.UTF_8));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.error("Saving render settings:", e);
|
LOGGER.error("Saving render settings:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,7 +274,6 @@ sourceSets {
|
|||||||
main {
|
main {
|
||||||
java {
|
java {
|
||||||
exclude 'com/replaymod/compat'
|
exclude 'com/replaymod/compat'
|
||||||
exclude 'com/replaymod/extras'
|
|
||||||
exclude 'com/replaymod/restrictions'
|
exclude 'com/replaymod/restrictions'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user