Get online module compiling on 1.13
This commit is contained in:
@@ -7,6 +7,7 @@ import com.replaymod.core.gui.RestoreReplayGui;
|
||||
import com.replaymod.core.handler.MainMenuHandler;
|
||||
import com.replaymod.core.utils.OpenGLUtils;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.online.ReplayModOnline;
|
||||
import com.replaymod.recording.ReplayModRecording;
|
||||
import com.replaymod.render.ReplayModRender;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
@@ -164,7 +165,9 @@ public class ReplayMod implements Module {
|
||||
// Register all RM modules
|
||||
modules.add(this);
|
||||
modules.add(new ReplayModRecording(this));
|
||||
modules.add(new ReplayModReplay(this));
|
||||
ReplayModReplay replayModule = new ReplayModReplay(this);
|
||||
modules.add(replayModule);
|
||||
modules.add(new ReplayModOnline(this, replayModule));
|
||||
modules.add(new ReplayModRender(this));
|
||||
modules.add(new ReplayModSimplePathing(this));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.replaymod.online;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -9,7 +9,7 @@ public class AuthenticationHash {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public AuthenticationHash() {
|
||||
username = Minecraft.getMinecraft().getSession().getUsername();
|
||||
username = MCVer.getMinecraft().getSession().getUsername();
|
||||
currentTime = System.currentTimeMillis();
|
||||
randomLong = random.nextLong();
|
||||
hash = getAuthenticationHash();
|
||||
|
||||
@@ -1,63 +1,65 @@
|
||||
package com.replaymod.online;
|
||||
|
||||
import com.replaymod.online.api.ApiClient;
|
||||
import com.replaymod.online.api.AuthData;
|
||||
import com.replaymod.online.api.replay.holders.AuthConfirmation;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.common.config.Property;
|
||||
|
||||
/**
|
||||
* Auth data stored in a {@link Configuration}.
|
||||
*/
|
||||
public class ConfigurationAuthData implements AuthData {
|
||||
|
||||
private final Configuration config;
|
||||
private String userName;
|
||||
private String authKey;
|
||||
|
||||
public ConfigurationAuthData(Configuration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the data from the configuration and checks for its validity.
|
||||
* If the data is invalid, it is removed from the config.
|
||||
* @param apiClient Api client used for validating the auth data
|
||||
*/
|
||||
public void load(ApiClient apiClient) {
|
||||
Property property = config.get("authkey", "authkey", (String) null);
|
||||
if (property != null) {
|
||||
String authKey = property.getString();
|
||||
AuthConfirmation result = apiClient.checkAuthkey(authKey);
|
||||
if (result != null) {
|
||||
this.authKey = authKey;
|
||||
this.userName = result.getUsername();
|
||||
} else {
|
||||
setData(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthKey() {
|
||||
return authKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String userName, String authKey) {
|
||||
this.userName = userName;
|
||||
this.authKey = authKey;
|
||||
|
||||
config.removeCategory(config.getCategory("authkey"));
|
||||
if (authKey != null) {
|
||||
// Note: .get() actually creates the entry with the default value if it doesn't exist
|
||||
config.get("authkey", "authkey", authKey);
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
//#if MC<11300
|
||||
//$$ package com.replaymod.online;
|
||||
//$$
|
||||
//$$ import com.replaymod.online.api.ApiClient;
|
||||
//$$ import com.replaymod.online.api.AuthData;
|
||||
//$$ import com.replaymod.online.api.replay.holders.AuthConfirmation;
|
||||
//$$ import net.minecraftforge.common.config.Configuration;
|
||||
//$$ import net.minecraftforge.common.config.Property;
|
||||
//$$
|
||||
//$$ /**
|
||||
//$$ * Auth data stored in a {@link Configuration}.
|
||||
//$$ */
|
||||
//$$ public class ConfigurationAuthData implements AuthData {
|
||||
//$$
|
||||
//$$ private final Configuration config;
|
||||
//$$ private String userName;
|
||||
//$$ private String authKey;
|
||||
//$$
|
||||
//$$ public ConfigurationAuthData(Configuration config) {
|
||||
//$$ this.config = config;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ /**
|
||||
//$$ * Loads the data from the configuration and checks for its validity.
|
||||
//$$ * If the data is invalid, it is removed from the config.
|
||||
//$$ * @param apiClient Api client used for validating the auth data
|
||||
//$$ */
|
||||
//$$ public void load(ApiClient apiClient) {
|
||||
//$$ Property property = config.get("authkey", "authkey", (String) null);
|
||||
//$$ if (property != null) {
|
||||
//$$ String authKey = property.getString();
|
||||
//$$ AuthConfirmation result = apiClient.checkAuthkey(authKey);
|
||||
//$$ if (result != null) {
|
||||
//$$ this.authKey = authKey;
|
||||
//$$ this.userName = result.getUsername();
|
||||
//$$ } else {
|
||||
//$$ setData(null, null);
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public String getUserName() {
|
||||
//$$ return userName;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public String getAuthKey() {
|
||||
//$$ return authKey;
|
||||
//$$ }
|
||||
//$$
|
||||
//$$ @Override
|
||||
//$$ public void setData(String userName, String authKey) {
|
||||
//$$ this.userName = userName;
|
||||
//$$ this.authKey = authKey;
|
||||
//$$
|
||||
//$$ config.removeCategory(config.getCategory("authkey"));
|
||||
//$$ if (authKey != null) {
|
||||
//$$ // Note: .get() actually creates the entry with the default value if it doesn't exist
|
||||
//$$ config.get("authkey", "authkey", authKey);
|
||||
//$$ }
|
||||
//$$ config.save();
|
||||
//$$ }
|
||||
//$$ }
|
||||
//#endif
|
||||
|
||||
68
src/main/java/com/replaymod/online/PlainFileAuthData.java
Normal file
68
src/main/java/com/replaymod/online/PlainFileAuthData.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package com.replaymod.online;
|
||||
|
||||
import com.replaymod.online.api.ApiClient;
|
||||
import com.replaymod.online.api.AuthData;
|
||||
import com.replaymod.online.api.replay.holders.AuthConfirmation;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
/**
|
||||
* Auth data stored in a plain text file.
|
||||
*/
|
||||
public class PlainFileAuthData implements AuthData {
|
||||
private final Path path;
|
||||
private String userName;
|
||||
private String authKey;
|
||||
|
||||
public PlainFileAuthData(Path path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the data from the JSON file and checks for its validity.
|
||||
* If the data is invalid, the JSON file is removed.
|
||||
* @param apiClient Api client used for validating the auth data
|
||||
*/
|
||||
public void load(ApiClient apiClient) throws IOException {
|
||||
String authKey;
|
||||
try {
|
||||
authKey = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||
} catch (FileNotFoundException ignored) {
|
||||
return;
|
||||
}
|
||||
AuthConfirmation result = apiClient.checkAuthkey(authKey);
|
||||
if (result != null) {
|
||||
this.authKey = authKey;
|
||||
this.userName = result.getUsername();
|
||||
} else {
|
||||
Files.deleteIfExists(path);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthKey() {
|
||||
return authKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String userName, String authKey) {
|
||||
this.userName = userName;
|
||||
this.authKey = authKey;
|
||||
|
||||
try {
|
||||
Files.write(path, authKey.getBytes(StandardCharsets.UTF_8), StandardOpenOption.CREATE_NEW);
|
||||
} catch (IOException e) {
|
||||
ReplayModOnline.LOGGER.error("Saving auth data:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package com.replaymod.online;
|
||||
|
||||
import com.replaymod.core.Module;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.online.api.ApiClient;
|
||||
import com.replaymod.online.api.AuthData;
|
||||
import com.replaymod.online.gui.GuiLoginPrompt;
|
||||
import com.replaymod.online.gui.GuiReplayDownloading;
|
||||
import com.replaymod.online.gui.GuiSaveModifiedReplay;
|
||||
@@ -12,48 +15,36 @@ import com.replaymod.replaystudio.replay.ReplayFile;
|
||||
import com.replaymod.replaystudio.replay.ZipReplayFile;
|
||||
import com.replaymod.replaystudio.studio.ReplayStudio;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
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.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.common.config.Configuration;
|
||||
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.Mod;
|
||||
//$$ import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
//$$ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
//$$ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
import static net.minecraft.client.Minecraft.getMinecraft;
|
||||
|
||||
@Mod(modid = ReplayModOnline.MOD_ID,
|
||||
version = "@MOD_VERSION@",
|
||||
acceptedMinecraftVersions = "@MC_VERSION@",
|
||||
acceptableRemoteVersions = "*",
|
||||
//#if MC>=10800
|
||||
clientSideOnly = true,
|
||||
//#endif
|
||||
useMetadata = true)
|
||||
public class ReplayModOnline {
|
||||
public static final String MOD_ID = "replaymod-online";
|
||||
|
||||
@Mod.Instance(MOD_ID)
|
||||
public class ReplayModOnline implements Module {
|
||||
{ instance = this; }
|
||||
public static ReplayModOnline instance;
|
||||
|
||||
private ReplayMod core;
|
||||
|
||||
private ReplayModReplay replayModule;
|
||||
|
||||
public static Logger LOGGER;
|
||||
public static Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private ApiClient apiClient;
|
||||
|
||||
@@ -64,22 +55,31 @@ public class ReplayModOnline {
|
||||
*/
|
||||
private File currentReplayOutputFile;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
LOGGER = event.getModLog();
|
||||
core = ReplayMod.instance;
|
||||
replayModule = ReplayModReplay.instance;
|
||||
public ReplayModOnline(ReplayMod core, ReplayModReplay replayModule) {
|
||||
this.core = core;
|
||||
this.replayModule = replayModule;
|
||||
|
||||
core.getSettingsRegistry().register(Setting.class);
|
||||
|
||||
Configuration config = new Configuration(event.getSuggestedConfigurationFile());
|
||||
ConfigurationAuthData authData = new ConfigurationAuthData(config);
|
||||
apiClient = new ApiClient(authData);
|
||||
authData.load(apiClient);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
@Override
|
||||
public void initClient() {
|
||||
Path path = MCVer.mcDataDir(MCVer.getMinecraft()).toPath().resolve("config/replaymod-online.token");
|
||||
PlainFileAuthData authData = new PlainFileAuthData(path);
|
||||
apiClient = new ApiClient(authData);
|
||||
if (Files.notExists(path)) {
|
||||
AuthData oldAuthData = loadOldAuthData();
|
||||
if (oldAuthData != null) {
|
||||
authData.setData(oldAuthData.getUserName(), oldAuthData.getAuthKey());
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
authData.load(apiClient);
|
||||
} catch (IOException e) {
|
||||
ReplayModOnline.LOGGER.error("Loading auth data:", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (!getDownloadsFolder().exists()){
|
||||
if (!getDownloadsFolder().mkdirs()) {
|
||||
LOGGER.warn("Failed to create downloads folder: " + getDownloadsFolder());
|
||||
@@ -88,10 +88,7 @@ public class ReplayModOnline {
|
||||
|
||||
new GuiHandler(this).register();
|
||||
FML_BUS.register(this);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
// Initial login prompt
|
||||
if (!core.getSettingsRegistry().get(Setting.SKIP_LOGIN_PROMPT)) {
|
||||
if (!isLoggedIn()) {
|
||||
@@ -103,6 +100,23 @@ public class ReplayModOnline {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads old auth data from the legacy Configuration system and stores it in the new json file.
|
||||
* Always returns null on 1.13+ where the Configuration system has been removed.
|
||||
*/
|
||||
private AuthData loadOldAuthData() {
|
||||
//#if MC<11300
|
||||
//$$ Path path = MCVer.mcDataDir(MCVer.getMinecraft()).toPath().resolve("config/replaymod-online.cfg");
|
||||
//$$ Configuration config = new Configuration(path.toFile());
|
||||
//$$ ConfigurationAuthData authData = new ConfigurationAuthData(config);
|
||||
//$$ authData.load(new ApiClient(authData));
|
||||
//$$ if (authData.getAuthKey() != null) {
|
||||
//$$ return authData;
|
||||
//$$ }
|
||||
//#endif
|
||||
return null;
|
||||
}
|
||||
|
||||
public ReplayMod getCore() {
|
||||
return core;
|
||||
}
|
||||
@@ -125,7 +139,7 @@ public class ReplayModOnline {
|
||||
|
||||
public File getDownloadsFolder() {
|
||||
String path = core.getSettingsRegistry().get(Setting.DOWNLOAD_PATH);
|
||||
return new File(path.startsWith("./") ? getMinecraft().mcDataDir : null, path);
|
||||
return new File(path.startsWith("./") ? mcDataDir(getMinecraft()) : null, path);
|
||||
}
|
||||
|
||||
public File getDownloadedFile(int id) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.replaymod.core.ReplayMod;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.online.AuthenticationHash;
|
||||
import com.replaymod.online.api.replay.ReplayModApiMethods;
|
||||
import com.replaymod.online.api.replay.SearchQuery;
|
||||
@@ -30,7 +31,7 @@ import static com.replaymod.core.utils.Utils.SSL_SOCKET_FACTORY;
|
||||
|
||||
public class ApiClient {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
private static final Minecraft mc = MCVer.getMinecraft();
|
||||
private static final Gson gson = new Gson();
|
||||
private static final JsonParser jsonParser = new JsonParser();
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ public enum MinecraftVersion {
|
||||
MC_1_11_2("Minecraft 1.11.2", "1.11.2"),
|
||||
MC_1_12("Minecraft 1.12", "1.12"),
|
||||
MC_1_12_1("Minecraft 1.12.1", "1.12.1"),
|
||||
MC_1_12_2("Minecraft 1.12.2", "1.12.2");
|
||||
MC_1_12_2("Minecraft 1.12.2", "1.12.2"),
|
||||
MC_1_13_2("Minecraft 1.13.2", "1.13.2");
|
||||
|
||||
private String niceName, apiName;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.replaymod.online.gui;
|
||||
|
||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.online.api.ApiClient;
|
||||
import com.replaymod.online.api.ApiException;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiScreen;
|
||||
@@ -13,9 +12,9 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import de.johni0702.minecraft.gui.utils.Consumers;
|
||||
import de.johni0702.minecraft.gui.utils.Utils;
|
||||
import com.replaymod.core.utils.Patterns;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableColor;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import org.lwjgl.util.Dimension;
|
||||
import org.lwjgl.util.ReadableColor;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.*;
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ import de.johni0702.minecraft.gui.layout.VerticalLayout;
|
||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import de.johni0702.minecraft.gui.utils.Consumer;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.lwjgl.util.Dimension;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
@@ -462,7 +462,7 @@ public class GuiReplayCenter extends GuiScreen {
|
||||
|
||||
@Override
|
||||
public ReadableDimension calcMinSize(GuiContainer<?> container) {
|
||||
return new org.lwjgl.util.Dimension(300, thumbnail.getMinSize().getHeight());
|
||||
return new Dimension(300, thumbnail.getMinSize().getHeight());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,9 +15,14 @@ import de.johni0702.minecraft.gui.function.Typeable;
|
||||
import de.johni0702.minecraft.gui.layout.GridLayout;
|
||||
import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.ReadablePoint;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.ReadablePoint;
|
||||
|
||||
//#if MC>=11300
|
||||
import com.replaymod.core.versions.MCVer.Keyboard;
|
||||
//#else
|
||||
//$$ import org.lwjgl.input.Keyboard;
|
||||
//#endif
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,13 +33,16 @@ import de.johni0702.minecraft.gui.popup.AbstractGuiPopup;
|
||||
import de.johni0702.minecraft.gui.popup.GuiYesNoPopup;
|
||||
import de.johni0702.minecraft.gui.utils.Colors;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
//#if MC>=11300
|
||||
//#else
|
||||
//$$ import net.minecraft.client.settings.GameSettings;
|
||||
//#endif
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
@@ -47,6 +50,7 @@ import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.replaymod.core.versions.MCVer.newReportedException;
|
||||
import static java.util.Arrays.stream;
|
||||
|
||||
public class GuiUploadReplay extends GuiScreen {
|
||||
@@ -130,7 +134,7 @@ public class GuiUploadReplay extends GuiScreen {
|
||||
metaData = replayFile.getMetaData();
|
||||
optThumbnail = replayFile.getThumb();
|
||||
} catch (IOException e) {
|
||||
throw new ReportedException(CrashReport.makeCrashReport(e, "Read replay file " + file.getName()));
|
||||
throw newReportedException(CrashReport.makeCrashReport(e, "Read replay file " + file.getName()));
|
||||
}
|
||||
|
||||
// Apply to gui
|
||||
@@ -147,7 +151,11 @@ public class GuiUploadReplay extends GuiScreen {
|
||||
// Get name of key used for thumbnail creation
|
||||
KeyBindingRegistry registry = mod.getCore().getKeyBindingRegistry();
|
||||
KeyBinding keyBinding = registry.getKeyBindings().get("replaymod.input.thumbnail");
|
||||
String keyName = keyBinding == null ? "???" : GameSettings.getKeyDisplayString(keyBinding.getKeyCode());
|
||||
//#if MC>=11300
|
||||
String keyName = keyBinding == null ? "???" : keyBinding.func_197978_k();
|
||||
//#else
|
||||
//$$ String keyName = keyBinding == null ? "???" : GameSettings.getKeyDisplayString(keyBinding.getKeyCode());
|
||||
//#endif
|
||||
|
||||
// No thumbnail, show default thumbnail and hint on how to create one
|
||||
thumbnail.setTexture(Utils.DEFAULT_THUMBNAIL);
|
||||
|
||||
@@ -15,7 +15,12 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#if MC>=11300
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import java.util.ArrayList;
|
||||
//#else
|
||||
//$$ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
//#else
|
||||
//$$ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
//#endif
|
||||
@@ -45,8 +50,15 @@ public class GuiHandler {
|
||||
}
|
||||
|
||||
GuiButton button = new GuiButton(BUTTON_REPLAY_CENTER, getGui(event).width / 2 - 100,
|
||||
getGui(event).height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter"));
|
||||
getButtonList(event).add(button);
|
||||
getGui(event).height / 4 + 10 + 4 * 24, I18n.format("replaymod.gui.replaycenter")) {
|
||||
//#if MC>=11300
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
onButton(new GuiScreenEvent.ActionPerformedEvent.Pre(getGui(event), this, new ArrayList<>()));
|
||||
}
|
||||
//#endif
|
||||
};
|
||||
addButton(event, button);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
||||
Reference in New Issue
Block a user