Fix all warnings
Add and make use of Lombok Remove Mojang API Remove ZipFileUtils Remove StreamTools in favor of Apache IOUtils Keyframe should be abstract all derivatives final Replace clone in Keyframe with copy Move some constants from GuiReplaySetttings to GuiConstants
This commit is contained in:
@@ -41,6 +41,8 @@ configurations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compile 'org.projectlombok:lombok:1.16.4'
|
||||||
|
|
||||||
shade fileTree(dir: 'libs', includes: ['*.jar'])
|
shade fileTree(dir: 'libs', includes: ['*.jar'])
|
||||||
// you may put jars on which you depend on in ./libs
|
// you may put jars on which you depend on in ./libs
|
||||||
// or you may define them like so..
|
// or you may define them like so..
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
|||||||
import eu.crushedpixel.replaymod.utils.TooltipRenderer;
|
import eu.crushedpixel.replaymod.utils.TooltipRenderer;
|
||||||
import eu.crushedpixel.replaymod.video.frame.*;
|
import eu.crushedpixel.replaymod.video.frame.*;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
|
import net.minecraft.client.resources.IResourcePack;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.common.config.Configuration;
|
import net.minecraftforge.common.config.Configuration;
|
||||||
@@ -39,12 +41,16 @@ import net.minecraftforge.fml.common.ModContainer;
|
|||||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
|
import static org.apache.commons.io.FileUtils.forceDelete;
|
||||||
|
import static org.apache.commons.io.FileUtils.listFiles;
|
||||||
|
|
||||||
@Mod(modid = ReplayMod.MODID, useMetadata = true)
|
@Mod(modid = ReplayMod.MODID, useMetadata = true)
|
||||||
public class ReplayMod {
|
public class ReplayMod {
|
||||||
|
|
||||||
@@ -148,8 +154,10 @@ public class ReplayMod {
|
|||||||
|
|
||||||
tooltipRenderer = new TooltipRenderer();
|
tooltipRenderer = new TooltipRenderer();
|
||||||
|
|
||||||
mc.getRenderManager().skinMap.put("default", new InvisibilityRender(mc.getRenderManager()));
|
@SuppressWarnings("unchecked")
|
||||||
mc.getRenderManager().skinMap.put("slim", new InvisibilityRender(mc.getRenderManager(), true));
|
Map<String, RenderPlayer> skinMap = mc.getRenderManager().skinMap;
|
||||||
|
skinMap.put("default", new InvisibilityRender(mc.getRenderManager()));
|
||||||
|
skinMap.put("slim", new InvisibilityRender(mc.getRenderManager(), true));
|
||||||
|
|
||||||
//clean up replay_recordings folder
|
//clean up replay_recordings folder
|
||||||
removeTmcprFiles();
|
removeTmcprFiles();
|
||||||
@@ -158,7 +166,9 @@ public class ReplayMod {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
mc.defaultResourcePacks.add(new LocalizedResourcePack());
|
@SuppressWarnings("unchecked")
|
||||||
|
List<IResourcePack> defaultResourcePacks = mc.defaultResourcePacks;
|
||||||
|
defaultResourcePacks.add(new LocalizedResourcePack());
|
||||||
mc.addScheduledTask(new Runnable() {
|
mc.addScheduledTask(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -319,12 +329,14 @@ public class ReplayMod {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeTmcprFiles() {
|
private void removeTmcprFiles() {
|
||||||
|
try {
|
||||||
File folder = ReplayFileIO.getReplayFolder();
|
File folder = ReplayFileIO.getReplayFolder();
|
||||||
|
|
||||||
for(File f : folder.listFiles()) {
|
for (File file : listFiles(folder, new String[]{ReplayFile.TEMP_FILE_EXTENSION.substring(1)}, false)) {
|
||||||
if(("." + FilenameUtils.getExtension(f.getAbsolutePath())).equals(ReplayFile.TEMP_FILE_EXTENSION)) {
|
forceDelete(file);
|
||||||
f.delete();
|
}
|
||||||
}
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,10 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.mojang.authlib.exceptions.AuthenticationException;
|
import com.mojang.authlib.exceptions.AuthenticationException;
|
||||||
import eu.crushedpixel.replaymod.api.mojang.MojangApiMethods;
|
|
||||||
import eu.crushedpixel.replaymod.api.mojang.holders.Profile;
|
|
||||||
import eu.crushedpixel.replaymod.api.replay.ReplayModApiMethods;
|
import eu.crushedpixel.replaymod.api.replay.ReplayModApiMethods;
|
||||||
import eu.crushedpixel.replaymod.api.replay.SearchQuery;
|
import eu.crushedpixel.replaymod.api.replay.SearchQuery;
|
||||||
import eu.crushedpixel.replaymod.api.replay.holders.*;
|
import eu.crushedpixel.replaymod.api.replay.holders.*;
|
||||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHash;
|
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHash;
|
||||||
import eu.crushedpixel.replaymod.utils.StreamTools;
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
@@ -20,7 +17,6 @@ import java.io.*;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
|
|
||||||
@@ -33,8 +29,7 @@ public class ApiClient {
|
|||||||
builder.put("user", username);
|
builder.put("user", username);
|
||||||
builder.put("pw", password);
|
builder.put("pw", password);
|
||||||
builder.put("mod", true);
|
builder.put("mod", true);
|
||||||
AuthKey auth = invokeAndReturn(builder, AuthKey.class);
|
return invokeAndReturn(builder, AuthKey.class);
|
||||||
return auth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthKey register(String username, String mail, String password, String uuid)
|
public AuthKey register(String username, String mail, String password, String uuid)
|
||||||
@@ -50,8 +45,7 @@ public class ApiClient {
|
|||||||
builder.put("mcusername", authenticationHash.username);
|
builder.put("mcusername", authenticationHash.username);
|
||||||
builder.put("timelong", authenticationHash.currentTime);
|
builder.put("timelong", authenticationHash.currentTime);
|
||||||
builder.put("randomlong", authenticationHash.randomLong);
|
builder.put("randomlong", authenticationHash.randomLong);
|
||||||
AuthKey auth = invokeAndReturn(builder, AuthKey.class);
|
return invokeAndReturn(builder, AuthKey.class);
|
||||||
return auth;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AuthenticationHash sessionserverJoin() throws AuthenticationException {
|
private AuthenticationHash sessionserverJoin() throws AuthenticationException {
|
||||||
@@ -67,8 +61,7 @@ public class ApiClient {
|
|||||||
try {
|
try {
|
||||||
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.check_authkey);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.check_authkey);
|
||||||
builder.put("auth", auth);
|
builder.put("auth", auth);
|
||||||
AuthConfirmation conf = invokeAndReturn(builder, AuthConfirmation.class);
|
return invokeAndReturn(builder, AuthConfirmation.class);
|
||||||
return conf;
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -89,33 +82,21 @@ public class ApiClient {
|
|||||||
return succ.hasDonated();
|
return succ.hasDonated();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public UserFiles getUserFiles(String auth, String user) throws IOException, ApiException {
|
|
||||||
//TODO if required
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileInfo[] getFileInfo(List<Integer> ids) throws IOException, ApiException {
|
public FileInfo[] getFileInfo(List<Integer> ids) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.file_details);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.file_details);
|
||||||
builder.put("id", buildListString(ids));
|
builder.put("id", buildListString(ids));
|
||||||
FileInfo[] info = invokeAndReturn(builder, FileInfo[].class);
|
return invokeAndReturn(builder, FileInfo[].class);
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileInfo[] searchFiles(SearchQuery query) throws IOException, ApiException {
|
public FileInfo[] searchFiles(SearchQuery query) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.search);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.search);
|
||||||
StringBuilder sb = new StringBuilder(builder.toString());
|
return invokeAndReturn(builder.toString() + query.buildQuery(), SearchResult.class).getResults();
|
||||||
sb.append(query.buildQuery());
|
|
||||||
|
|
||||||
FileInfo[] info = invokeAndReturn(sb.toString(), SearchResult.class).getResults();
|
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTranslation(String languageCode) throws IOException, ApiException {
|
public String getTranslation(String languageCode) throws IOException, ApiException {
|
||||||
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_language);
|
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.get_language);
|
||||||
builder.put("language", languageCode);
|
builder.put("language", languageCode);
|
||||||
String properties = SimpleApiClient.invokeUrl(builder.toString());
|
return SimpleApiClient.invokeUrl(builder.toString());
|
||||||
return properties;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void downloadThumbnail(int file, File target) throws IOException {
|
public void downloadThumbnail(int file, File target) throws IOException {
|
||||||
@@ -142,14 +123,14 @@ public class ApiClient {
|
|||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
JsonElement element = jsonParser.parse(StreamTools.readStreamtoString(is));
|
JsonElement element = jsonParser.parse(IOUtils.toString(is));
|
||||||
try {
|
try {
|
||||||
ApiError err = gson.fromJson(element, ApiError.class);
|
ApiError err = gson.fromJson(element, ApiError.class);
|
||||||
if(err.getDesc() != null) {
|
if(err.getDesc() != null) {
|
||||||
throw new ApiException(err);
|
throw new ApiException(err);
|
||||||
}
|
}
|
||||||
} catch(JsonParseException e) {
|
} catch(JsonParseException e) {
|
||||||
throw new ApiException(StreamTools.readStreamtoString(is));
|
throw new ApiException(IOUtils.toString(is));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,15 +172,6 @@ public class ApiClient {
|
|||||||
invokeAndReturn(builder, Success.class);
|
invokeAndReturn(builder, Success.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
MOJANG API CALLS
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Profile getProfileFromUUID(UUID uuid) throws IOException, ApiException {
|
|
||||||
String url = String.format(MojangApiMethods.userprofile+"%s", uuid.toString().replace("-", ""));
|
|
||||||
return invokeAndReturn(url, Profile.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T invokeAndReturn(QueryBuilder builder, Class<T> classOfT) throws IOException, ApiException {
|
private <T> T invokeAndReturn(QueryBuilder builder, Class<T> classOfT) throws IOException, ApiException {
|
||||||
return invokeAndReturn(builder.toString(), classOfT);
|
return invokeAndReturn(builder.toString(), classOfT);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,28 @@
|
|||||||
package eu.crushedpixel.replaymod.api;
|
package eu.crushedpixel.replaymod.api;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
|
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class ApiException extends Exception {
|
public class ApiException extends Exception {
|
||||||
|
|
||||||
private static final long serialVersionUID = 349073390504232810L;
|
private static final long serialVersionUID = 349073390504232810L;
|
||||||
|
|
||||||
private ApiError error;
|
private ApiError error;
|
||||||
private String errorMsg;
|
|
||||||
|
|
||||||
public ApiException(ApiError error) {
|
public ApiException(ApiError error) {
|
||||||
super(error.getTranslatedDesc());
|
super(error.getTranslatedDesc());
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.errorMsg = error.getTranslatedDesc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiException(String error) {
|
public ApiException(String error) {
|
||||||
super(error);
|
super(error);
|
||||||
this.errorMsg = error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiError getError() {
|
public ApiError getError() {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getErrorMsg() {
|
|
||||||
return errorMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.google.gson.JsonElement;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class GsonApiClient {
|
public class GsonApiClient {
|
||||||
|
|
||||||
@@ -20,18 +19,7 @@ public class GsonApiClient {
|
|||||||
return wrapWithJson(apiResult);
|
return wrapWithJson(apiResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonElement invokeJson(String apiKey, String method, Map<String, Object> paramMap) throws IOException, ApiException {
|
|
||||||
String apiResult = SimpleApiClient.invoke(method, paramMap);
|
|
||||||
return wrapWithJson(apiResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static JsonElement invokeJson(String apiKey, String method) throws IOException, ApiException {
|
|
||||||
String apiResult = SimpleApiClient.invoke(method, null);
|
|
||||||
return wrapWithJson(apiResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JsonElement wrapWithJson(String apiResult) {
|
private static JsonElement wrapWithJson(String apiResult) {
|
||||||
JsonElement element = parser.parse(apiResult);
|
return parser.parse(apiResult);
|
||||||
return element;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,32 +10,10 @@ public class QueryBuilder {
|
|||||||
public String apiMethod;
|
public String apiMethod;
|
||||||
public Map<String, String> paramMap;
|
public Map<String, String> paramMap;
|
||||||
|
|
||||||
public QueryBuilder() {
|
|
||||||
this(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryBuilder(String apiMethod) {
|
public QueryBuilder(String apiMethod) {
|
||||||
this.apiMethod = apiMethod;
|
this.apiMethod = apiMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryBuilder(String apiMethod, String key, String value) {
|
|
||||||
this(apiMethod);
|
|
||||||
put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryBuilder(String apiMethod, String key1, String value1, String key2, String value2) {
|
|
||||||
this(apiMethod);
|
|
||||||
put(key1, value1);
|
|
||||||
put(key2, value2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public QueryBuilder(String apiMethod, String key1, String value1, String key2, String value2, String key3, String value3) {
|
|
||||||
this(apiMethod);
|
|
||||||
put(key1, value1);
|
|
||||||
put(key2, value2);
|
|
||||||
put(key3, value3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(String key, Object value) {
|
public void put(String key, Object value) {
|
||||||
if(key != null && value != null) {
|
if(key != null && value != null) {
|
||||||
if(paramMap == null) {
|
if(paramMap == null) {
|
||||||
@@ -45,17 +23,6 @@ public class QueryBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void put(String key1, Object value1, String key2, Object value2) {
|
|
||||||
put(key1, value1);
|
|
||||||
put(key2, value2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(String key1, Object value1, String key2, Object value2, String key3, Object value3) {
|
|
||||||
put(key1, value1);
|
|
||||||
put(key2, value2);
|
|
||||||
put(key3, value3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void put(Map<String, Object> paraMap) {
|
public void put(Map<String, Object> paraMap) {
|
||||||
if(paraMap == null) return;
|
if(paraMap == null) return;
|
||||||
for(String key : paraMap.keySet()) {
|
for(String key : paraMap.keySet()) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
|
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
|
||||||
import eu.crushedpixel.replaymod.utils.StreamTools;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -88,7 +88,7 @@ public class SimpleApiClient {
|
|||||||
if(responseCode != 200) {
|
if(responseCode != 200) {
|
||||||
is = httpUrlConnection.getErrorStream();
|
is = httpUrlConnection.getErrorStream();
|
||||||
if(is != null) {
|
if(is != null) {
|
||||||
responseContent = StreamTools.readStreamtoString(is, "UTF-8");
|
responseContent = IOUtils.toString(is, "UTF-8");
|
||||||
} else {
|
} else {
|
||||||
responseContent = "";
|
responseContent = "";
|
||||||
}
|
}
|
||||||
@@ -102,10 +102,8 @@ public class SimpleApiClient {
|
|||||||
|
|
||||||
is = httpUrlConnection.getInputStream();
|
is = httpUrlConnection.getInputStream();
|
||||||
|
|
||||||
responseContent = StreamTools.readStreamtoString(is, "UTF-8");
|
responseContent = IOUtils.toString(is, "UTF-8");
|
||||||
|
|
||||||
} catch(IOException e) {
|
|
||||||
throw e;
|
|
||||||
} finally {
|
} finally {
|
||||||
if(is != null) {
|
if(is != null) {
|
||||||
is.close();
|
is.close();
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.mojang;
|
|
||||||
|
|
||||||
public class MojangApiMethods {
|
|
||||||
|
|
||||||
public static final String userprofile = "https://sessionserver.mojang.com/session/minecraft/profile/";
|
|
||||||
public static final String joinServer = "https://sessionserver.mojang.com/session/minecraft/join";
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.mojang;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
|
||||||
import eu.crushedpixel.replaymod.api.ApiException;
|
|
||||||
import eu.crushedpixel.replaymod.api.mojang.holders.Profile;
|
|
||||||
import eu.crushedpixel.replaymod.api.mojang.holders.Properties;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.renderer.ImageBufferDownload;
|
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
|
||||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class SkinDownloader {
|
|
||||||
|
|
||||||
public static ITextureObject getDownloadImageSkin(ResourceLocation resourceLocationIn, UUID uuid) throws IOException, ApiException {
|
|
||||||
TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager();
|
|
||||||
ITextureObject object = texturemanager.getTexture(resourceLocationIn);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(object == null) {
|
|
||||||
Profile profile = ReplayMod.apiClient.getProfileFromUUID(uuid);
|
|
||||||
|
|
||||||
if(profile.getProperties() != null && profile.getProperties().length > 0) {
|
|
||||||
List<Properties> plist = Arrays.asList(profile.getProperties());
|
|
||||||
Collections.reverse(plist);
|
|
||||||
|
|
||||||
for(Properties p : plist) {
|
|
||||||
if(p.getName().equals("textures")) {
|
|
||||||
object = new ThreadDownloadImageData((File) null,
|
|
||||||
p.getTextureValue().getTextures().getSKIN().getUrl(),
|
|
||||||
DefaultPlayerSkin.getDefaultSkin(uuid), new ImageBufferDownload());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
object = new ThreadDownloadImageData((File)null,
|
|
||||||
null,
|
|
||||||
DefaultPlayerSkin.getDefaultSkin(uuid), new ImageBufferDownload());
|
|
||||||
}
|
|
||||||
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.mojang.holders;
|
|
||||||
|
|
||||||
public class Profile {
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
private String name;
|
|
||||||
private Properties[] properties;
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Properties[] getProperties() {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProperties(Properties[] properties) {
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.mojang.holders;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.codec.binary.StringUtils;
|
|
||||||
|
|
||||||
public class Properties {
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private String value;
|
|
||||||
private String signature;
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TextureValue getTextureValue() {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
return gson.fromJson(StringUtils.newStringUtf8(Base64.decodeBase64(value)), TextureValue.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSignature() {
|
|
||||||
return signature;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSignature(String signature) {
|
|
||||||
this.signature = signature;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.mojang.holders;
|
|
||||||
|
|
||||||
public class TextureValue {
|
|
||||||
private long timestamp;
|
|
||||||
private String profileId;
|
|
||||||
private String profileName;
|
|
||||||
private boolean isPublic;
|
|
||||||
private Textures textures;
|
|
||||||
|
|
||||||
public long getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimestamp(long timestamp) {
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProfileId() {
|
|
||||||
return profileId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfileId(String profileId) {
|
|
||||||
this.profileId = profileId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProfileName() {
|
|
||||||
return profileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfileName(String profileName) {
|
|
||||||
this.profileName = profileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPublic() {
|
|
||||||
return isPublic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsPublic(boolean isPublic) {
|
|
||||||
this.isPublic = isPublic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Textures getTextures() {
|
|
||||||
return textures;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTextures(Textures textures) {
|
|
||||||
this.textures = textures;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.mojang.holders;
|
|
||||||
|
|
||||||
public class Textures {
|
|
||||||
private UrlHolder SKIN;
|
|
||||||
private UrlHolder CAPE;
|
|
||||||
|
|
||||||
public UrlHolder getSKIN() {
|
|
||||||
return SKIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSKIN(UrlHolder SKIN) {
|
|
||||||
this.SKIN = SKIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UrlHolder getCAPE() {
|
|
||||||
return CAPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCAPE(UrlHolder CAPE) {
|
|
||||||
this.CAPE = CAPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.api.mojang.holders;
|
|
||||||
|
|
||||||
public class UrlHolder {
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
public String getUrl() {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url) {
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,7 +11,6 @@ import java.io.*;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FileUploader {
|
public class FileUploader {
|
||||||
@@ -21,14 +20,8 @@ public class FileUploader {
|
|||||||
private long filesize;
|
private long filesize;
|
||||||
private long current;
|
private long current;
|
||||||
|
|
||||||
private String attachmentName = "file";
|
|
||||||
private String attachmentFileName = "file.mcpr";
|
|
||||||
private String crlf = "\r\n";
|
|
||||||
private String twoHyphens = "--";
|
|
||||||
|
|
||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
|
|
||||||
private String boundary = "*****";
|
|
||||||
private GuiUploadFile parent;
|
private GuiUploadFile parent;
|
||||||
|
|
||||||
public void uploadFile(GuiUploadFile gui, String auth, String filename, List<String> tags, File file, Category category, String description)
|
public void uploadFile(GuiUploadFile gui, String auth, String filename, List<String> tags, File file, Category category, String description)
|
||||||
@@ -62,7 +55,7 @@ public class FileUploader {
|
|||||||
|
|
||||||
postData += "&name=" + URLEncoder.encode(filename, "UTF-8");
|
postData += "&name=" + URLEncoder.encode(filename, "UTF-8");
|
||||||
|
|
||||||
String url = "http://ReplayMod.com/api/upload_file" + postData;
|
String url = ReplayModApiMethods.upload_file + postData;
|
||||||
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
|
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
|
||||||
con.setUseCaches(false);
|
con.setUseCaches(false);
|
||||||
con.setDoOutput(true);
|
con.setDoOutput(true);
|
||||||
@@ -70,18 +63,18 @@ public class FileUploader {
|
|||||||
con.setChunkedStreamingMode(1024);
|
con.setChunkedStreamingMode(1024);
|
||||||
con.setRequestProperty("Connection", "Keep-Alive");
|
con.setRequestProperty("Connection", "Keep-Alive");
|
||||||
con.setRequestProperty("Cache-Control", "no-cache");
|
con.setRequestProperty("Cache-Control", "no-cache");
|
||||||
con.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + this.boundary);
|
String boundary = "*****";
|
||||||
|
con.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
|
||||||
HashMap<String, String> params = new HashMap<String, String>();
|
|
||||||
params.put("auth", auth);
|
|
||||||
params.put("name", filename);
|
|
||||||
params.put("category", category.getId() + "");
|
|
||||||
|
|
||||||
DataOutputStream request = new DataOutputStream(con.getOutputStream());
|
DataOutputStream request = new DataOutputStream(con.getOutputStream());
|
||||||
|
|
||||||
request.writeBytes(this.twoHyphens + this.boundary + this.crlf);
|
String crlf = "\r\n";
|
||||||
request.writeBytes("Content-Disposition: form-data; name=\"" + this.attachmentName + "\";filename=\"" + this.attachmentFileName + "\"" + this.crlf);
|
String twoHyphens = "--";
|
||||||
request.writeBytes(this.crlf);
|
request.writeBytes(twoHyphens + boundary + crlf);
|
||||||
|
String attachmentName = "file";
|
||||||
|
String attachmentFileName = "file.mcpr";
|
||||||
|
request.writeBytes("Content-Disposition: form-data; name=\"" + attachmentName + "\";filename=\"" + attachmentFileName + "\"" + crlf);
|
||||||
|
request.writeBytes(crlf);
|
||||||
|
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
FileInputStream fis = new FileInputStream(file);
|
FileInputStream fis = new FileInputStream(file);
|
||||||
@@ -102,8 +95,8 @@ public class FileUploader {
|
|||||||
}
|
}
|
||||||
fis.close();
|
fis.close();
|
||||||
|
|
||||||
request.writeBytes(this.crlf);
|
request.writeBytes(crlf);
|
||||||
request.writeBytes(this.twoHyphens + this.boundary + this.twoHyphens + this.crlf);
|
request.writeBytes(twoHyphens + boundary + twoHyphens + crlf);
|
||||||
|
|
||||||
request.flush();
|
request.flush();
|
||||||
request.close();
|
request.close();
|
||||||
|
|||||||
@@ -1,32 +1,17 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay;
|
package eu.crushedpixel.replaymod.api.replay;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
public class SearchQuery {
|
public class SearchQuery {
|
||||||
|
|
||||||
public Boolean order, singleplayer;
|
public Boolean order, singleplayer;
|
||||||
public String player, tag, version, server, name, auth;
|
public String player, tag, version, server, name, auth;
|
||||||
public Integer category, offset;
|
public Integer category, offset;
|
||||||
|
|
||||||
public SearchQuery() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public SearchQuery(Boolean order, Boolean singleplayer, String player,
|
|
||||||
String tag, String version, String server, String name,
|
|
||||||
String auth, Integer category, Integer offset) {
|
|
||||||
this.order = order;
|
|
||||||
this.singleplayer = singleplayer;
|
|
||||||
this.player = player;
|
|
||||||
this.tag = tag;
|
|
||||||
this.version = version;
|
|
||||||
this.server = server;
|
|
||||||
this.name = name;
|
|
||||||
this.auth = auth;
|
|
||||||
this.category = category;
|
|
||||||
this.offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String buildQuery() {
|
public String buildQuery() {
|
||||||
String query = "";
|
String query = "";
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class ApiError {
|
public class ApiError {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
@@ -9,27 +11,6 @@ public class ApiError {
|
|||||||
private String key;
|
private String key;
|
||||||
private String[] objects;
|
private String[] objects;
|
||||||
|
|
||||||
public ApiError(int id, String desc) {
|
|
||||||
this.id = id;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDesc() {
|
|
||||||
return desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDesc(String desc) {
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTranslatedDesc() {
|
public String getTranslatedDesc() {
|
||||||
try {
|
try {
|
||||||
return I18n.format(key, (Object[]) objects);
|
return I18n.format(key, (Object[]) objects);
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class AuthConfirmation {
|
public class AuthConfirmation {
|
||||||
private String username;
|
private String username;
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class AuthKey {
|
public class AuthKey {
|
||||||
|
|
||||||
private String auth;
|
private String auth;
|
||||||
|
|
||||||
public AuthKey(String authkey) {
|
|
||||||
this.auth = authkey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAuthkey() {
|
|
||||||
return auth;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class Donated {
|
public class Donated {
|
||||||
|
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private boolean donated = false;
|
private boolean donated = false;
|
||||||
|
|
||||||
public boolean hasDonated() {
|
public boolean hasDonated() {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class Favorites {
|
public class Favorites {
|
||||||
private int[] favorited;
|
private int[] favorited;
|
||||||
|
|
||||||
public int[] getFavorited() { return favorited; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
import eu.crushedpixel.replaymod.recording.ReplayMetaData;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
public class FileInfo {
|
public class FileInfo {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private ReplayMetaData metadata;
|
private ReplayMetaData metadata;
|
||||||
private String owner;
|
private String owner;
|
||||||
@@ -11,67 +16,12 @@ public class FileInfo {
|
|||||||
private int size;
|
private int size;
|
||||||
private int category;
|
private int category;
|
||||||
private int downloads;
|
private int downloads;
|
||||||
private int favorites;
|
|
||||||
private String name;
|
private String name;
|
||||||
|
@Getter(AccessLevel.NONE)
|
||||||
private boolean thumbnail;
|
private boolean thumbnail;
|
||||||
|
private int favorites;
|
||||||
|
|
||||||
public FileInfo(int id, ReplayMetaData metadata, String owner,
|
|
||||||
Rating ratings, int size, int category, int downloads, String name,
|
|
||||||
boolean thumbnail, int favorites) {
|
|
||||||
this.id = id;
|
|
||||||
this.metadata = metadata;
|
|
||||||
this.owner = owner;
|
|
||||||
this.ratings = ratings;
|
|
||||||
this.size = size;
|
|
||||||
this.category = category;
|
|
||||||
this.downloads = downloads;
|
|
||||||
this.name = name;
|
|
||||||
this.thumbnail = thumbnail;
|
|
||||||
this.favorites = favorites;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ReplayMetaData getMetadata() {
|
|
||||||
return metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOwner() {
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rating getRatings() {
|
|
||||||
return ratings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSize() {
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCategory() {
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDownloads() {
|
|
||||||
return downloads;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFavorites() { return favorites; }
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasThumbnail() {
|
public boolean hasThumbnail() {
|
||||||
return thumbnail;
|
return thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class FileRating {
|
public class FileRating {
|
||||||
|
|
||||||
private int file;
|
private int file;
|
||||||
@@ -9,6 +12,7 @@ public class FileRating {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO Will be changed later
|
||||||
public boolean getRating() {
|
public boolean getRating() {
|
||||||
return rating;
|
return rating;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class RatedFiles {
|
public class RatedFiles {
|
||||||
|
|
||||||
private FileRating[] rated;
|
private FileRating[] rated;
|
||||||
|
|
||||||
public FileRating[] getRated() {
|
|
||||||
return rated;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,11 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class Rating {
|
public class Rating {
|
||||||
|
|
||||||
private int negative, positive;
|
private int negative, positive;
|
||||||
|
|
||||||
public int getNegative() {
|
|
||||||
return negative;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPositive() {
|
|
||||||
return positive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum RatingType {
|
public enum RatingType {
|
||||||
|
|
||||||
LIKE("like"), DISLIKE("dislike"), NEUTRAL("neutral");
|
LIKE("like"), DISLIKE("dislike"), NEUTRAL("neutral");
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class SearchResult {
|
public class SearchResult {
|
||||||
|
|
||||||
private FileInfo[] results;
|
private FileInfo[] results;
|
||||||
|
|
||||||
public FileInfo[] getResults() {
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class Success {
|
public class Success {
|
||||||
|
|
||||||
private boolean success = false;
|
private boolean success = false;
|
||||||
|
|
||||||
public boolean isSuccess() {
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,10 @@
|
|||||||
package eu.crushedpixel.replaymod.api.replay.holders;
|
package eu.crushedpixel.replaymod.api.replay.holders;
|
||||||
|
|
||||||
public class UserFiles {
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class UserFiles {
|
||||||
private String user;
|
private String user;
|
||||||
private FileInfo[] files;
|
private FileInfo[] files;
|
||||||
private int total_size;
|
private int total_size;
|
||||||
|
|
||||||
public String getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileInfo[] getFiles() {
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTotal_size() {
|
|
||||||
return total_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import eu.crushedpixel.replaymod.api.replay.holders.FileInfo;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface Pagination {
|
public interface Pagination {
|
||||||
public List<FileInfo> getFiles();
|
List<FileInfo> getFiles();
|
||||||
|
|
||||||
public int getLoadedPages();
|
int getLoadedPages();
|
||||||
|
|
||||||
public boolean fetchPage();
|
boolean fetchPage();
|
||||||
|
|
||||||
public static final int PAGE_SIZE = 30; //defined by the Website API
|
int PAGE_SIZE = 30; //defined by the Website API
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,20 +29,16 @@ public class ChatMessageHandler {
|
|||||||
|
|
||||||
|
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
private boolean alive = true;
|
|
||||||
private Queue<IChatComponent> requests = new ConcurrentLinkedQueue<IChatComponent>();
|
private Queue<IChatComponent> requests = new ConcurrentLinkedQueue<IChatComponent>();
|
||||||
private EntityPlayerSP player = null;
|
private EntityPlayerSP player = null;
|
||||||
public Thread t = new Thread(new Runnable() {
|
public Thread t = new Thread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while(alive) {
|
while(!Thread.currentThread().isInterrupted()) {
|
||||||
while(active) {
|
while(active) {
|
||||||
try {
|
try {
|
||||||
while(player == null) {
|
while(player == null) {
|
||||||
if(!alive) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
player = Minecraft.getMinecraft().thePlayer;
|
player = Minecraft.getMinecraft().thePlayer;
|
||||||
}
|
}
|
||||||
@@ -67,6 +63,7 @@ public class ChatMessageHandler {
|
|||||||
}, "replaymod-chat-message-handler");
|
}, "replaymod-chat-message-handler");
|
||||||
|
|
||||||
public ChatMessageHandler() {
|
public ChatMessageHandler() {
|
||||||
|
t.setDaemon(true);
|
||||||
t.start();
|
t.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,17 +20,17 @@ public class EnchantmentTimerCT implements IClassTransformer {
|
|||||||
public byte[] transform(String name, String transformedName,
|
public byte[] transform(String name, String transformedName,
|
||||||
byte[] basicClass) {
|
byte[] basicClass) {
|
||||||
if(name.equals("cqh")) {
|
if(name.equals("cqh")) {
|
||||||
return patchRenderEffectMethod(name, basicClass, true);
|
return patchRenderEffectMethod(basicClass, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(name.equals("net.minecraft.client.renderer.entity.RenderItem")) {
|
if(name.equals("net.minecraft.client.renderer.entity.RenderItem")) {
|
||||||
return patchRenderEffectMethod(name, basicClass, false);
|
return patchRenderEffectMethod(basicClass, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return basicClass;
|
return basicClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] patchRenderEffectMethod(String name, byte[] bytes, boolean obfuscated) {
|
public byte[] patchRenderEffectMethod(byte[] bytes, boolean obfuscated) {
|
||||||
System.out.println("REPLAY MOD CORE PATCHER: Inside RenderItem class");
|
System.out.println("REPLAY MOD CORE PATCHER: Inside RenderItem class");
|
||||||
|
|
||||||
String methodName = obfuscated ? "a" : "renderEffect";
|
String methodName = obfuscated ? "a" : "renderEffect";
|
||||||
@@ -46,18 +46,16 @@ public class EnchantmentTimerCT implements IClassTransformer {
|
|||||||
|
|
||||||
List<Pair<AbstractInsnNode, AbstractInsnNode>> toInsert = new ArrayList<Pair<AbstractInsnNode, AbstractInsnNode>>();
|
List<Pair<AbstractInsnNode, AbstractInsnNode>> toInsert = new ArrayList<Pair<AbstractInsnNode, AbstractInsnNode>>();
|
||||||
|
|
||||||
Iterator<MethodNode> iterator = classNode.methods.iterator();
|
for (MethodNode m : classNode.methods) {
|
||||||
while(iterator.hasNext()) {
|
if (m.name.equals(methodName) && m.desc.equals(classDescriptor)) {
|
||||||
MethodNode m = iterator.next();
|
|
||||||
if(m.name.equals(methodName) && m.desc.equals(classDescriptor)) {
|
|
||||||
System.out.println("REPLAY MOD CORE PATCHER: Inside renderEffect method");
|
System.out.println("REPLAY MOD CORE PATCHER: Inside renderEffect method");
|
||||||
|
|
||||||
Iterator<AbstractInsnNode> nodeIterator = m.instructions.iterator();
|
Iterator<AbstractInsnNode> nodeIterator = m.instructions.iterator();
|
||||||
while(nodeIterator.hasNext()) {
|
while (nodeIterator.hasNext()) {
|
||||||
AbstractInsnNode node = nodeIterator.next();
|
AbstractInsnNode node = nodeIterator.next();
|
||||||
if(node instanceof MethodInsnNode) {
|
if (node instanceof MethodInsnNode) {
|
||||||
MethodInsnNode min = (MethodInsnNode) node;
|
MethodInsnNode min = (MethodInsnNode) node;
|
||||||
if(min.getOpcode() == Opcodes.INVOKESTATIC && min.name.equals(getSystemTime) &&
|
if (min.getOpcode() == Opcodes.INVOKESTATIC && min.name.equals(getSystemTime) &&
|
||||||
min.owner.equals(minecraftClass) && min.desc.equals(sysTimeDesc)) {
|
min.owner.equals(minecraftClass) && min.desc.equals(sysTimeDesc)) {
|
||||||
MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC,
|
MethodInsnNode n = new MethodInsnNode(Opcodes.INVOKESTATIC,
|
||||||
"eu/crushedpixel/replaymod/timer/EnchantmentTimer", "getEnchantmentTime",
|
"eu/crushedpixel/replaymod/timer/EnchantmentTimer", "getEnchantmentTime",
|
||||||
@@ -67,7 +65,7 @@ public class EnchantmentTimerCT implements IClassTransformer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Pair<AbstractInsnNode, AbstractInsnNode> pair : toInsert) {
|
for (Pair<AbstractInsnNode, AbstractInsnNode> pair : toInsert) {
|
||||||
m.instructions.insertBefore(pair.first(), pair.second());
|
m.instructions.insertBefore(pair.first(), pair.second());
|
||||||
m.instructions.remove(pair.first());
|
m.instructions.remove(pair.first());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,15 +97,17 @@ public class GuiEventHandler {
|
|||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onInit(InitGuiEvent event) {
|
public void onInit(InitGuiEvent event) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = event.buttonList;
|
||||||
if(event.gui instanceof GuiIngameMenu && ReplayHandler.isInReplay()) {
|
if(event.gui instanceof GuiIngameMenu && ReplayHandler.isInReplay()) {
|
||||||
ReplayMod.replaySender.setReplaySpeed(0);
|
ReplayMod.replaySender.setReplaySpeed(0);
|
||||||
for(GuiButton b : new ArrayList<GuiButton>(event.buttonList)) {
|
for(GuiButton b : new ArrayList<GuiButton>(buttonList)) {
|
||||||
if(b.id == 1) {
|
if(b.id == 1) {
|
||||||
b.displayString = I18n.format("replaymod.gui.exit");
|
b.displayString = I18n.format("replaymod.gui.exit");
|
||||||
b.yPosition -= 24 * 2;
|
b.yPosition -= 24 * 2;
|
||||||
b.id = GuiConstants.EXIT_REPLAY_BUTTON;
|
b.id = GuiConstants.EXIT_REPLAY_BUTTON;
|
||||||
} else if(b.id >= 5 && b.id <= 7) {
|
} else if(b.id >= 5 && b.id <= 7) {
|
||||||
event.buttonList.remove(b);
|
buttonList.remove(b);
|
||||||
} else if(b.id != 4) {
|
} else if(b.id != 4) {
|
||||||
b.yPosition -= 24 * 2;
|
b.yPosition -= 24 * 2;
|
||||||
}
|
}
|
||||||
@@ -113,7 +115,7 @@ public class GuiEventHandler {
|
|||||||
} else if(event.gui instanceof GuiMainMenu) {
|
} else if(event.gui instanceof GuiMainMenu) {
|
||||||
int i1 = event.gui.height / 4 + 24 + 10;
|
int i1 = event.gui.height / 4 + 24 + 10;
|
||||||
|
|
||||||
for(GuiButton b : (List<GuiButton>) event.buttonList) {
|
for(GuiButton b : buttonList) {
|
||||||
if(b.id != 0 && b.id != 4 && b.id != 5) {
|
if(b.id != 0 && b.id != 4 && b.id != 5) {
|
||||||
b.yPosition = b.yPosition - 2 * 24 + 10;
|
b.yPosition = b.yPosition - 2 * 24 + 10;
|
||||||
}
|
}
|
||||||
@@ -122,23 +124,23 @@ public class GuiEventHandler {
|
|||||||
GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2 * 24, I18n.format("replaymod.gui.replayviewer"));
|
GuiButton rm = new GuiButton(GuiConstants.REPLAY_MANAGER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 2 * 24, I18n.format("replaymod.gui.replayviewer"));
|
||||||
rm.width = rm.width / 2 - 2;
|
rm.width = rm.width / 2 - 2;
|
||||||
//rm.enabled = AuthenticationHandler.isAuthenticated();
|
//rm.enabled = AuthenticationHandler.isAuthenticated();
|
||||||
event.buttonList.add(rm);
|
buttonList.add(rm);
|
||||||
|
|
||||||
replayCount = ReplayFileIO.getAllReplayFiles().size();
|
replayCount = ReplayFileIO.getAllReplayFiles().size();
|
||||||
|
|
||||||
GuiButton re = new GuiButton(GuiConstants.REPLAY_EDITOR_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2 * 24, I18n.format("replaymod.gui.replayeditor"));
|
GuiButton re = new GuiButton(GuiConstants.REPLAY_EDITOR_BUTTON_ID, event.gui.width / 2 + 2, i1 + 2 * 24, I18n.format("replaymod.gui.replayeditor"));
|
||||||
re.width = re.width / 2 - 2;
|
re.width = re.width / 2 - 2;
|
||||||
re.enabled = VersionValidator.isValid && replayCount > 0;
|
re.enabled = VersionValidator.isValid && replayCount > 0;
|
||||||
event.buttonList.add(re);
|
buttonList.add(re);
|
||||||
|
|
||||||
editorButton = re;
|
editorButton = re;
|
||||||
|
|
||||||
GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 3 * 24, I18n.format("replaymod.gui.replaycenter"));
|
GuiButton rc = new GuiButton(GuiConstants.REPLAY_CENTER_BUTTON_ID, event.gui.width / 2 - 100, i1 + 3 * 24, I18n.format("replaymod.gui.replaycenter"));
|
||||||
rc.enabled = true;
|
rc.enabled = true;
|
||||||
event.buttonList.add(rc);
|
buttonList.add(rc);
|
||||||
|
|
||||||
} else if(event.gui instanceof GuiOptions) {
|
} else if(event.gui instanceof GuiOptions) {
|
||||||
event.buttonList.add(new GuiButton(GuiConstants.REPLAY_OPTIONS_BUTTON_ID,
|
buttonList.add(new GuiButton(GuiConstants.REPLAY_OPTIONS_BUTTON_ID,
|
||||||
event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, I18n.format("replaymod.gui.settings.title")));
|
event.gui.width / 2 - 155, event.gui.height / 6 + 48 - 6 - 24, 310, 20, I18n.format("replaymod.gui.settings.title")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import net.minecraft.client.gui.GuiScreen;
|
|||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
import net.minecraft.client.settings.KeyBinding;
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.MathHelper;
|
import net.minecraft.util.MathHelper;
|
||||||
import net.minecraft.util.ReportedException;
|
import net.minecraft.util.ReportedException;
|
||||||
import net.minecraftforge.client.event.MouseEvent;
|
import net.minecraftforge.client.event.MouseEvent;
|
||||||
@@ -116,26 +115,6 @@ public class MinecraftTicker {
|
|||||||
mc.refreshResources();
|
mc.refreshResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(i == 17 && Keyboard.isKeyDown(61)) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 18 && Keyboard.isKeyDown(61)) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 47 && Keyboard.isKeyDown(61)) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 38 && Keyboard.isKeyDown(61)) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 22 && Keyboard.isKeyDown(61)) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i == 20 && Keyboard.isKeyDown(61)) {
|
if(i == 20 && Keyboard.isKeyDown(61)) {
|
||||||
mc.refreshResources();
|
mc.refreshResources();
|
||||||
}
|
}
|
||||||
@@ -179,10 +158,12 @@ public class MinecraftTicker {
|
|||||||
mc.gameSettings.thirdPersonView = 0;
|
mc.gameSettings.thirdPersonView = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mc.gameSettings.thirdPersonView == 0) {
|
if (mc.entityRenderer != null) {
|
||||||
mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity());
|
if (mc.gameSettings.thirdPersonView == 0) {
|
||||||
} else if(mc.gameSettings.thirdPersonView == 1) {
|
mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity());
|
||||||
mc.entityRenderer.loadEntityShader((Entity) null);
|
} else if (mc.gameSettings.thirdPersonView == 1) {
|
||||||
|
mc.entityRenderer.loadEntityShader(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,30 +203,23 @@ public class MinecraftTicker {
|
|||||||
mc.playerController.onStoppedUsingItem(mc.thePlayer);
|
mc.playerController.onStoppedUsingItem(mc.thePlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
label435:
|
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
if(!mc.gameSettings.keyBindAttack.isPressed()) {
|
if(!mc.gameSettings.keyBindAttack.isPressed()) {
|
||||||
while(mc.gameSettings.keyBindUseItem.isPressed()) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
if(mc.gameSettings.keyBindPickBlock.isPressed()) {
|
if (!mc.gameSettings.keyBindUseItem.isPressed()
|
||||||
continue;
|
&& !mc.gameSettings.keyBindPickBlock.isPressed()) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break label435;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mc != null && mc.thePlayer != null)
|
if(mc.thePlayer != null)
|
||||||
mc.sendClickBlockToController(mc.currentScreen == null && mc.gameSettings.keyBindAttack.isKeyDown() && mc.inGameHasFocus);
|
mc.sendClickBlockToController(mc.currentScreen == null && mc.gameSettings.keyBindAttack.isKeyDown() && mc.inGameHasFocus);
|
||||||
|
|
||||||
if(mc != null)
|
mc.systemTime = Minecraft.getSystemTime();
|
||||||
mc.systemTime = Minecraft.getSystemTime();
|
|
||||||
} catch (ReportedException e) {
|
} catch (ReportedException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -24,16 +24,12 @@ import net.minecraftforge.fml.common.gameevent.PlayerEvent.ItemPickupEvent;
|
|||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
|
import net.minecraftforge.fml.common.gameevent.PlayerEvent.PlayerRespawnEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class RecordingHandler {
|
public class RecordingHandler {
|
||||||
|
|
||||||
public static final int entityID = Integer.MIN_VALUE + 9001;
|
public static final int entityID = Integer.MIN_VALUE + 9001;
|
||||||
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
private Double lastX = null, lastY = null, lastZ = null;
|
private Double lastX = null, lastY = null, lastZ = null;
|
||||||
private List<Integer> lastEffects = new ArrayList<Integer>();
|
|
||||||
private ItemStack[] playerItems = new ItemStack[5];
|
private ItemStack[] playerItems = new ItemStack[5];
|
||||||
private int ticksSinceLastCorrection = 0;
|
private int ticksSinceLastCorrection = 0;
|
||||||
private boolean wasSleeping = false;
|
private boolean wasSleeping = false;
|
||||||
@@ -81,7 +77,7 @@ public class RecordingHandler {
|
|||||||
PacketBuffer pb = new PacketBuffer(bb);
|
PacketBuffer pb = new PacketBuffer(bb);
|
||||||
|
|
||||||
pb.writeVarIntToBuffer(entityID);
|
pb.writeVarIntToBuffer(entityID);
|
||||||
pb.writeUuid(player.getUUID(player.getGameProfile()));
|
pb.writeUuid(EntityPlayer.getUUID(player.getGameProfile()));
|
||||||
|
|
||||||
pb.writeInt(MathHelper.floor_double(player.posX * 32.0D));
|
pb.writeInt(MathHelper.floor_double(player.posX * 32.0D));
|
||||||
pb.writeInt(MathHelper.floor_double(player.posY * 32.0D));
|
pb.writeInt(MathHelper.floor_double(player.posY * 32.0D));
|
||||||
@@ -106,7 +102,6 @@ public class RecordingHandler {
|
|||||||
public void resetVars() {
|
public void resetVars() {
|
||||||
lastX = lastY = lastZ = null;
|
lastX = lastY = lastZ = null;
|
||||||
rotationYawHeadBefore = null;
|
rotationYawHeadBefore = null;
|
||||||
lastEffects = new ArrayList<Integer>();
|
|
||||||
playerItems = new ItemStack[5];
|
playerItems = new ItemStack[5];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +134,7 @@ public class RecordingHandler {
|
|||||||
lastY = e.player.posY;
|
lastY = e.player.posY;
|
||||||
lastZ = e.player.posZ;
|
lastZ = e.player.posZ;
|
||||||
|
|
||||||
Packet packet = null;
|
Packet packet;
|
||||||
if(force || Math.abs(dx) > 4.0 || Math.abs(dy) > 4.0 || Math.abs(dz) > 4.0) {
|
if(force || Math.abs(dx) > 4.0 || Math.abs(dy) > 4.0 || Math.abs(dz) > 4.0) {
|
||||||
int x = MathHelper.floor_double(e.player.posX * 32.0D);
|
int x = MathHelper.floor_double(e.player.posX * 32.0D);
|
||||||
int y = MathHelper.floor_double(e.player.posY * 32.0D);
|
int y = MathHelper.floor_double(e.player.posY * 32.0D);
|
||||||
@@ -148,14 +143,9 @@ public class RecordingHandler {
|
|||||||
byte pitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
byte pitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||||
packet = new S18PacketEntityTeleport(entityID, x, y, z, yaw, pitch, e.player.onGround);
|
packet = new S18PacketEntityTeleport(entityID, x, y, z, yaw, pitch, e.player.onGround);
|
||||||
} else {
|
} else {
|
||||||
byte oldYaw = (byte) ((int) (e.player.prevRotationYaw * 256.0F / 360.0F));
|
|
||||||
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
byte newYaw = (byte) ((int) (e.player.rotationYaw * 256.0F / 360.0F));
|
||||||
byte oldPitch = (byte) ((int) (e.player.prevRotationPitch * 256.0F / 360.0F));
|
|
||||||
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
byte newPitch = (byte) ((int) (e.player.rotationPitch * 256.0F / 360.0F));
|
||||||
|
|
||||||
byte dPitch = (byte) (newPitch - oldPitch);
|
|
||||||
byte dYaw = (byte) (newYaw - oldYaw);
|
|
||||||
|
|
||||||
packet = new S17PacketEntityLookMove(entityID,
|
packet = new S17PacketEntityLookMove(entityID,
|
||||||
(byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
|
(byte) Math.round(dx * 32), (byte) Math.round(dy * 32), (byte) Math.round(dz * 32),
|
||||||
newYaw, newPitch, e.player.onGround);
|
newYaw, newPitch, e.player.onGround);
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ public class TickAndRenderListener {
|
|||||||
|
|
||||||
private static int requestScreenshot = 0;
|
private static int requestScreenshot = 0;
|
||||||
|
|
||||||
//private boolean f1Down = false;
|
|
||||||
|
|
||||||
public static void requestScreenshot() {
|
public static void requestScreenshot() {
|
||||||
if(requestScreenshot == 0) requestScreenshot = 1;
|
if(requestScreenshot == 0) requestScreenshot = 1;
|
||||||
}
|
}
|
||||||
@@ -82,17 +80,16 @@ public class TickAndRenderListener {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void onMouseMove(MouseEvent event) {
|
public void onMouseMove(MouseEvent event) {
|
||||||
if(!ReplayHandler.isInReplay()) return;
|
if(!ReplayHandler.isInReplay()) return;
|
||||||
boolean flag = true;
|
|
||||||
|
|
||||||
mc.mcProfiler.startSection("mouse");
|
mc.mcProfiler.startSection("mouse");
|
||||||
|
|
||||||
if(flag && Minecraft.isRunningOnMac && mc.inGameHasFocus && !Mouse.isInsideWindow()) {
|
if(Minecraft.isRunningOnMac && mc.inGameHasFocus && !Mouse.isInsideWindow()) {
|
||||||
Mouse.setGrabbed(false);
|
Mouse.setGrabbed(false);
|
||||||
Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2);
|
Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2);
|
||||||
Mouse.setGrabbed(true);
|
Mouse.setGrabbed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mc.inGameHasFocus && flag && !(ReplayHandler.isInPath())) {
|
if(mc.inGameHasFocus && !(ReplayHandler.isInPath())) {
|
||||||
mc.mouseHelper.mouseXYChange();
|
mc.mouseHelper.mouseXYChange();
|
||||||
float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
float f1 = mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
||||||
float f2 = f1 * f1 * f1 * 8.0F;
|
float f2 = f1 * f1 * f1 * 8.0F;
|
||||||
|
|||||||
@@ -15,16 +15,10 @@ public class GuiConstants {
|
|||||||
public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011;
|
public static final int CENTER_DISLIKE_REPLAY_BUTTON = 2011;
|
||||||
public static final int CENTER_FAVORITED_REPLAYS_BUTTON = 2012;
|
public static final int CENTER_FAVORITED_REPLAYS_BUTTON = 2012;
|
||||||
|
|
||||||
public static final int UPLOAD_NAME_INPUT = 3001;
|
|
||||||
public static final int UPLOAD_CATEGORY_BUTTON = 3002;
|
|
||||||
public static final int UPLOAD_START_BUTTON = 3003;
|
public static final int UPLOAD_START_BUTTON = 3003;
|
||||||
public static final int UPLOAD_CANCEL_BUTTON = 3004;
|
public static final int UPLOAD_CANCEL_BUTTON = 3004;
|
||||||
public static final int UPLOAD_BACK_BUTTON = 3005;
|
public static final int UPLOAD_BACK_BUTTON = 3005;
|
||||||
public static final int UPLOAD_INFO_FIELD = 3006;
|
public static final int UPLOAD_INFO_FIELD = 3006;
|
||||||
public static final int UPLOAD_TAG_INPUT = 3007;
|
|
||||||
public static final int UPLOAD_TAG_PLACEHOLDER = 3008;
|
|
||||||
public static final int UPLOAD_HIDE_SERVER_IP = 3009;
|
|
||||||
public static final int UPLOAD_NAME_PLACEHOLDER = 3010;
|
|
||||||
|
|
||||||
public static final int EXIT_REPLAY_BUTTON = 4001;
|
public static final int EXIT_REPLAY_BUTTON = 4001;
|
||||||
|
|
||||||
@@ -33,8 +27,6 @@ public class GuiConstants {
|
|||||||
public static final int REPLAY_MANAGER_BUTTON_ID = 9001;
|
public static final int REPLAY_MANAGER_BUTTON_ID = 9001;
|
||||||
public static final int REPLAY_EDITOR_BUTTON_ID = 9002;
|
public static final int REPLAY_EDITOR_BUTTON_ID = 9002;
|
||||||
public static final int REPLAY_CENTER_BUTTON_ID = 9003;
|
public static final int REPLAY_CENTER_BUTTON_ID = 9003;
|
||||||
public static final int REPLAY_CENTER_LOGIN_TEXT_ID = 9004;
|
|
||||||
public static final int REPLAY_CENTER_PASSWORD_TEXT_ID = 9005;
|
|
||||||
|
|
||||||
public static final int LOGIN_OKAY_BUTTON = 1100;
|
public static final int LOGIN_OKAY_BUTTON = 1100;
|
||||||
public static final int LOGIN_CANCEL_BUTTON = 1101;
|
public static final int LOGIN_CANCEL_BUTTON = 1101;
|
||||||
@@ -79,16 +71,11 @@ public class GuiConstants {
|
|||||||
public static final int KEYFRAME_EDITOR_PITCH_INPUT = 6007;
|
public static final int KEYFRAME_EDITOR_PITCH_INPUT = 6007;
|
||||||
public static final int KEYFRAME_EDITOR_YAW_INPUT = 6008;
|
public static final int KEYFRAME_EDITOR_YAW_INPUT = 6008;
|
||||||
public static final int KEYFRAME_EDITOR_ROLL_INPUT = 6009;
|
public static final int KEYFRAME_EDITOR_ROLL_INPUT = 6009;
|
||||||
public static final int KEYFRAME_EDITOR_MIN_INPUT = 6010;
|
|
||||||
public static final int KEYFRAME_EDITOR_SEC_INPUT = 6011;
|
|
||||||
public static final int KEYFRAME_EDITOR_MS_INPUT = 6012;
|
|
||||||
public static final int KEYFRAME_EDITOR_REAL_MIN_INPUT = 6013;
|
public static final int KEYFRAME_EDITOR_REAL_MIN_INPUT = 6013;
|
||||||
public static final int KEYFRAME_EDITOR_REAL_SEC_INPUT = 6014;
|
public static final int KEYFRAME_EDITOR_REAL_SEC_INPUT = 6014;
|
||||||
public static final int KEYFRAME_EDITOR_REAL_MS_INPUT = 6015;
|
|
||||||
public static final int KEYFRAME_EDITOR_MARKER_NAME_INPUT = 6016;
|
|
||||||
|
|
||||||
public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010;
|
public static final int PLAYER_OVERVIEW_HIDE_ALL = 1010;
|
||||||
public static final int PLAYER_OVERVIEW_SHOW_ALL = 0101;
|
public static final int PLAYER_OVERVIEW_SHOW_ALL = 101;
|
||||||
public static final int PLAYER_OVERVIEW_REMEMBER = -10;
|
public static final int PLAYER_OVERVIEW_REMEMBER = -10;
|
||||||
|
|
||||||
public static final int RENDER_SETTINGS_RENDERER_DROPDOWN = 9001;
|
public static final int RENDER_SETTINGS_RENDERER_DROPDOWN = 9001;
|
||||||
@@ -106,4 +93,13 @@ public class GuiConstants {
|
|||||||
public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013;
|
public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013;
|
||||||
public static final int RENDER_SETTINGS_COLOR_PICKER = 9014;
|
public static final int RENDER_SETTINGS_COLOR_PICKER = 9014;
|
||||||
public static final int RENDER_SETTINGS_ENABLE_GREENSCREEN = 9015;
|
public static final int RENDER_SETTINGS_ENABLE_GREENSCREEN = 9015;
|
||||||
|
|
||||||
|
public static final int REPLAY_SETTINGS_RECORDSERVER_ID = 9004;
|
||||||
|
public static final int REPLAY_SETTINGS_RECORDSP_ID = 9005;
|
||||||
|
public static final int REPLAY_SETTINGS_SEND_CHAT = 9006;
|
||||||
|
public static final int REPLAY_SETTINGS_FORCE_LINEAR = 9007;
|
||||||
|
public static final int REPLAY_SETTINGS_ENABLE_LIGHTING = 9008;
|
||||||
|
public static final int REPLAY_SETTINGS_RESOURCEPACK_ID = 9010;
|
||||||
|
public static final int REPLAY_SETTINGS_INDICATOR_ID = 9012;
|
||||||
|
public static final int REPLAY_SETTINGS_PATHPREVIEW_ID = 9013;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
private Keyframe keyframeBackup;
|
private Keyframe keyframeBackup;
|
||||||
private boolean save;
|
private boolean save;
|
||||||
private boolean posKeyframe;
|
private boolean posKeyframe;
|
||||||
private boolean timeKeyframe;
|
|
||||||
private boolean markerKeyframe;
|
private boolean markerKeyframe;
|
||||||
|
|
||||||
private Keyframe previous, next;
|
private Keyframe previous, next;
|
||||||
|
|
||||||
private int w, w2, w3;
|
private int w2;
|
||||||
|
private int w3;
|
||||||
private int totalWidth;
|
private int totalWidth;
|
||||||
private int left;
|
private int left;
|
||||||
|
|
||||||
@@ -55,9 +55,9 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
|
|
||||||
public GuiEditKeyframe(Keyframe keyframe) {
|
public GuiEditKeyframe(Keyframe keyframe) {
|
||||||
this.keyframe = keyframe;
|
this.keyframe = keyframe;
|
||||||
this.keyframeBackup = keyframe.clone();
|
this.keyframeBackup = keyframe.copy();
|
||||||
this.posKeyframe = keyframe instanceof PositionKeyframe;
|
this.posKeyframe = keyframe instanceof PositionKeyframe;
|
||||||
this.timeKeyframe = keyframe instanceof TimeKeyframe;
|
boolean timeKeyframe = keyframe instanceof TimeKeyframe;
|
||||||
this.markerKeyframe = keyframe instanceof MarkerKeyframe;
|
this.markerKeyframe = keyframe instanceof MarkerKeyframe;
|
||||||
|
|
||||||
ReplayHandler.selectKeyframe(null);
|
ReplayHandler.selectKeyframe(null);
|
||||||
@@ -152,14 +152,14 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65;
|
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-65;
|
||||||
|
|
||||||
if(posKeyframe) {
|
if(posKeyframe) {
|
||||||
w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
int w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")),
|
||||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")),
|
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.ypos")),
|
||||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos"))));
|
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.zpos"))));
|
||||||
w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")),
|
w2 = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camyaw")),
|
||||||
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")),
|
Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.campitch")),
|
||||||
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll"))));
|
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.camroll"))));
|
||||||
|
|
||||||
totalWidth = w+100+w2+100+5+5+10;
|
totalWidth = w +100+w2+100+5+5+10;
|
||||||
left = (this.width - totalWidth)/2;
|
left = (this.width - totalWidth)/2;
|
||||||
|
|
||||||
int x = w + left + 5;
|
int x = w + left + 5;
|
||||||
@@ -178,6 +178,9 @@ public class GuiEditKeyframe extends GuiScreen {
|
|||||||
saveButton.xPosition = this.width - 100 - 5 - 10;
|
saveButton.xPosition = this.width - 100 - 5 - 10;
|
||||||
cancelButton.xPosition = saveButton.xPosition - 100 - 5;
|
cancelButton.xPosition = saveButton.xPosition - 100 - 5;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
|
|
||||||
buttonList.add(saveButton);
|
buttonList.add(saveButton);
|
||||||
buttonList.add(cancelButton);
|
buttonList.add(cancelButton);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.gui;
|
|
||||||
|
|
||||||
public class GuiHelpOverlay {
|
|
||||||
}
|
|
||||||
@@ -121,6 +121,9 @@ public class GuiKeyframeRepository extends GuiScreen implements GuiReplayOverlay
|
|||||||
saveButton.yPosition = keyframeSetList.yPosition+keyframeSetList.height-20;
|
saveButton.yPosition = keyframeSetList.yPosition+keyframeSetList.height-20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
|
|
||||||
buttonList.add(removeButton);
|
buttonList.add(removeButton);
|
||||||
buttonList.add(loadButton);
|
buttonList.add(loadButton);
|
||||||
buttonList.add(saveButton);
|
buttonList.add(saveButton);
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ import org.lwjgl.input.Mouse;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoOverlay {
|
||||||
@@ -150,6 +148,9 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
|||||||
upperPlayer = 0;
|
upperPlayer = 0;
|
||||||
lowerBound = this.height - 10;
|
lowerBound = this.height - 10;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(GuiCheckBox checkBox : checkBoxes) {
|
for(GuiCheckBox checkBox : checkBoxes) {
|
||||||
checkBox.xPosition = (int)(this.width*0.7)-5;
|
checkBox.xPosition = (int)(this.width*0.7)-5;
|
||||||
@@ -235,6 +236,8 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
|||||||
GlStateManager.resetColor();
|
GlStateManager.resetColor();
|
||||||
if(fitting >= checkBoxes.size()) {
|
if(fitting >= checkBoxes.size()) {
|
||||||
checkBoxes.add(new GuiCheckBox(checkBoxes.size(), (int)(this.width*0.7)-5, l2+3, "", true));
|
checkBoxes.add(new GuiCheckBox(checkBoxes.size(), (int)(this.width*0.7)-5, l2+3, "", true));
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
buttonList.add(checkBoxes.get(checkBoxes.size() - 1));
|
buttonList.add(checkBoxes.get(checkBoxes.size() - 1));
|
||||||
}
|
}
|
||||||
checkBoxes.get(fitting).setIsChecked(!PlayerHandler.isHidden(p.first().getUniqueID()));
|
checkBoxes.get(fitting).setIsChecked(!PlayerHandler.isHidden(p.first().getUniqueID()));
|
||||||
@@ -294,7 +297,8 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
|||||||
}
|
}
|
||||||
|
|
||||||
private PlayerVisibility getVisibilityInstance() {
|
private PlayerVisibility getVisibilityInstance() {
|
||||||
return new PlayerVisibility(PlayerHandler.getHiddenPlayers());
|
Set<UUID> hidden = PlayerHandler.getHiddenPlayers();
|
||||||
|
return new PlayerVisibility(hidden.toArray(new UUID[hidden.size()]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -302,7 +306,7 @@ public class GuiPlayerOverview extends GuiScreen implements GuiReplayOverlay.NoO
|
|||||||
if(rememberHidden.isChecked()) {
|
if(rememberHidden.isChecked()) {
|
||||||
try {
|
try {
|
||||||
File f = File.createTempFile(ReplayFile.ENTRY_VISIBILITY, "json");
|
File f = File.createTempFile(ReplayFile.ENTRY_VISIBILITY, "json");
|
||||||
ReplayFileIO.writePlayerVisibilityToFile(getVisibilityInstance(), f);
|
ReplayFileIO.write(getVisibilityInstance(), f);
|
||||||
ReplayMod.replayFileAppender.registerModifiedFile(f, ReplayFile.ENTRY_VISIBILITY, ReplayHandler.getReplayFile());
|
ReplayMod.replayFileAppender.registerModifiedFile(f, ReplayFile.ENTRY_VISIBILITY, ReplayHandler.getReplayFile());
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiRenderSettings extends GuiScreen {
|
public class GuiRenderSettings extends GuiScreen {
|
||||||
|
private static final int LEFT_BORDER = 10;
|
||||||
|
|
||||||
private GuiButton renderButton, cancelButton, advancedButton;
|
private GuiButton renderButton, cancelButton, advancedButton;
|
||||||
private GuiDropdown<RendererSettings> rendererDropdown;
|
private GuiDropdown<RendererSettings> rendererDropdown;
|
||||||
|
|
||||||
private int virtualY, virtualHeight;
|
private int virtualY, virtualHeight;
|
||||||
private int leftBorder = 10;
|
|
||||||
|
|
||||||
private GuiCheckBox customResolution, ignoreCamDir, youtubeExport, enableGreenscreen;
|
private GuiCheckBox customResolution, ignoreCamDir, youtubeExport, enableGreenscreen;
|
||||||
private GuiNumberInput xRes, yRes;
|
private GuiNumberInput xRes, yRes;
|
||||||
@@ -42,7 +42,7 @@ public class GuiRenderSettings extends GuiScreen {
|
|||||||
|
|
||||||
private boolean advancedTab = false;
|
private boolean advancedTab = false;
|
||||||
|
|
||||||
private int w1, w2, w3;
|
private int w1;
|
||||||
|
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
@@ -170,18 +170,18 @@ public class GuiRenderSettings extends GuiScreen {
|
|||||||
rendererDropdown.yPosition = virtualY + 15 + 15;
|
rendererDropdown.yPosition = virtualY + 15 + 15;
|
||||||
rendererDropdown.xPosition = (width-w1)/2 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10;
|
rendererDropdown.xPosition = (width-w1)/2 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.rendersettings.renderer") + ":")+10;
|
||||||
|
|
||||||
w2 = customResolution.width+5+xRes.width+5+fontRendererObj.getStringWidth("*")+5+yRes.width;
|
int w2 = customResolution.width + 5 + xRes.width + 5 + fontRendererObj.getStringWidth("*") + 5 + yRes.width;
|
||||||
|
|
||||||
customResolution.yPosition = virtualY + 15 + 5 + 20 + 10 +5+fontRendererObj.getStringWidth("*")+5;
|
customResolution.yPosition = virtualY + 15 + 5 + 20 + 10 +5+fontRendererObj.getStringWidth("*")+5;
|
||||||
customResolution.xPosition = (width-w2)/2;
|
customResolution.xPosition = (width- w2)/2;
|
||||||
|
|
||||||
xRes.xPosition = customResolution.xPosition + customResolution.width + 5;
|
xRes.xPosition = customResolution.xPosition + customResolution.width + 5;
|
||||||
yRes.xPosition = xRes.xPosition+xRes.width+5+fontRendererObj.getStringWidth("*")+5;
|
yRes.xPosition = xRes.xPosition+xRes.width+5+fontRendererObj.getStringWidth("*")+5;
|
||||||
xRes.yPosition = yRes.yPosition = customResolution.yPosition-3;
|
xRes.yPosition = yRes.yPosition = customResolution.yPosition-3;
|
||||||
|
|
||||||
w3 = interpolation.width + 10 + forceChunks.width;
|
int w3 = interpolation.width + 10 + forceChunks.width;
|
||||||
|
|
||||||
interpolation.xPosition = (width-w3)/2;
|
interpolation.xPosition = (width- w3)/2;
|
||||||
interpolation.yPosition = xRes.yPosition+20+10;
|
interpolation.yPosition = xRes.yPosition+20+10;
|
||||||
|
|
||||||
forceChunks.xPosition = interpolation.xPosition+interpolation.width+10;
|
forceChunks.xPosition = interpolation.xPosition+interpolation.width+10;
|
||||||
@@ -224,7 +224,7 @@ public class GuiRenderSettings extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
drawGradientRect(leftBorder, virtualY, width - leftBorder, virtualY + virtualHeight, -1072689136, -804253680);
|
drawGradientRect(LEFT_BORDER, virtualY, width - LEFT_BORDER, virtualY + virtualHeight, -1072689136, -804253680);
|
||||||
|
|
||||||
this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.title"),
|
this.drawCenteredString(fontRendererObj, I18n.format("replaymod.gui.rendersettings.title"),
|
||||||
this.width / 2, virtualY + 5, Color.WHITE.getRGB());
|
this.width / 2, virtualY + 5, Color.WHITE.getRGB());
|
||||||
@@ -252,7 +252,7 @@ public class GuiRenderSettings extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||||
if(!rendererDropdown.mouseClickedResult(mouseX, mouseY, mouseButton)) {
|
if(!rendererDropdown.mouseClickedResult(mouseX, mouseY)) {
|
||||||
xRes.mouseClicked(mouseX, mouseY, mouseButton);
|
xRes.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
yRes.mouseClicked(mouseX, mouseY, mouseButton);
|
yRes.mouseClicked(mouseX, mouseY, mouseButton);
|
||||||
|
|
||||||
|
|||||||
@@ -12,21 +12,11 @@ import net.minecraftforge.fml.client.FMLClientHandler;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class GuiReplaySettings extends GuiScreen {
|
import static eu.crushedpixel.replaymod.gui.GuiConstants.*;
|
||||||
|
|
||||||
//TODO: Move to GuiConstants
|
public class GuiReplaySettings extends GuiScreen {
|
||||||
private static final int RECORDSERVER_ID = 9004;
|
|
||||||
private static final int RECORDSP_ID = 9005;
|
|
||||||
private static final int SEND_CHAT = 9006;
|
|
||||||
private static final int FORCE_LINEAR = 9007;
|
|
||||||
private static final int ENABLE_LIGHTING = 9008;
|
|
||||||
private static final int RESOURCEPACK_ID = 9010;
|
|
||||||
private static final int INDICATOR_ID = 9012;
|
|
||||||
private static final int PATHPREVIEW_ID = 9013;
|
|
||||||
protected String screenTitle = I18n.format("replaymod.gui.settings.title");
|
protected String screenTitle = I18n.format("replaymod.gui.settings.title");
|
||||||
private GuiScreen parentGuiScreen;
|
private GuiScreen parentGuiScreen;
|
||||||
private GuiToggleButton recordServerButton, recordSPButton, sendChatButton, linearButton, lightingButton,
|
|
||||||
resourcePackButton, showIndicatorButton, pathPreviewButton;
|
|
||||||
|
|
||||||
public GuiReplaySettings(GuiScreen parentGuiScreen) {
|
public GuiReplaySettings(GuiScreen parentGuiScreen) {
|
||||||
this.parentGuiScreen = parentGuiScreen;
|
this.parentGuiScreen = parentGuiScreen;
|
||||||
@@ -34,8 +24,12 @@ public class GuiReplaySettings extends GuiScreen {
|
|||||||
|
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
this.screenTitle = I18n.format("replaymod.gui.settings.title");
|
this.screenTitle = I18n.format("replaymod.gui.settings.title");
|
||||||
this.buttonList.clear();
|
|
||||||
this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done")));
|
@SuppressWarnings("unchecked")
|
||||||
|
java.util.List<GuiButton> buttonList = this.buttonList;
|
||||||
|
|
||||||
|
buttonList.clear();
|
||||||
|
buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, I18n.format("gui.done")));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@@ -45,20 +39,20 @@ public class GuiReplaySettings extends GuiScreen {
|
|||||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
int yPos = this.height / 6 + 24 * (i >> 1);
|
||||||
|
|
||||||
if(o == RecordingOptions.notifications) {
|
if(o == RecordingOptions.notifications) {
|
||||||
sendChatButton = new GuiSettingsOnOffButton(SEND_CHAT, xPos, yPos, 150, 20, o);
|
GuiToggleButton sendChatButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_SEND_CHAT, xPos, yPos, 150, 20, o);
|
||||||
this.buttonList.add(sendChatButton);
|
buttonList.add(sendChatButton);
|
||||||
|
|
||||||
} else if(o == RecordingOptions.recordServer) {
|
} else if(o == RecordingOptions.recordServer) {
|
||||||
recordServerButton = new GuiSettingsOnOffButton(RECORDSERVER_ID, xPos, yPos, 150, 20, o);
|
GuiToggleButton recordServerButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSERVER_ID, xPos, yPos, 150, 20, o);
|
||||||
this.buttonList.add(recordServerButton);
|
buttonList.add(recordServerButton);
|
||||||
|
|
||||||
} else if(o == RecordingOptions.recordSingleplayer) {
|
} else if(o == RecordingOptions.recordSingleplayer) {
|
||||||
recordSPButton = new GuiSettingsOnOffButton(RECORDSP_ID, xPos, yPos, 150, 20, o);
|
GuiToggleButton recordSPButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RECORDSP_ID, xPos, yPos, 150, 20, o);
|
||||||
this.buttonList.add(recordSPButton);
|
buttonList.add(recordSPButton);
|
||||||
|
|
||||||
} else if(o == RecordingOptions.indicator) {
|
} else if(o == RecordingOptions.indicator) {
|
||||||
showIndicatorButton = new GuiSettingsOnOffButton(INDICATOR_ID, xPos, yPos, 150, 20, o);
|
GuiToggleButton showIndicatorButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_INDICATOR_ID, xPos, yPos, 150, 20, o);
|
||||||
this.buttonList.add(showIndicatorButton);
|
buttonList.add(showIndicatorButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
@@ -75,21 +69,21 @@ public class GuiReplaySettings extends GuiScreen {
|
|||||||
int yPos = this.height / 6 + 24 * (i >> 1);
|
int yPos = this.height / 6 + 24 * (i >> 1);
|
||||||
|
|
||||||
if(o == ReplayOptions.lighting) {
|
if(o == ReplayOptions.lighting) {
|
||||||
lightingButton = new GuiSettingsOnOffButton(ENABLE_LIGHTING, xPos, yPos, 150, 20, o);
|
GuiToggleButton lightingButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_ENABLE_LIGHTING, xPos, yPos, 150, 20, o);
|
||||||
this.buttonList.add(lightingButton);
|
buttonList.add(lightingButton);
|
||||||
|
|
||||||
} else if(o == ReplayOptions.linear) {
|
} else if(o == ReplayOptions.linear) {
|
||||||
linearButton = new GuiSettingsOnOffButton(FORCE_LINEAR, xPos, yPos, 150, 20, o,
|
GuiToggleButton linearButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_FORCE_LINEAR, xPos, yPos, 150, 20, o,
|
||||||
I18n.format("replaymod.gui.settings.interpolation.linear"), I18n.format("replaymod.gui.settings.interpolation.cubic"));
|
I18n.format("replaymod.gui.settings.interpolation.linear"), I18n.format("replaymod.gui.settings.interpolation.cubic"));
|
||||||
this.buttonList.add(linearButton);
|
buttonList.add(linearButton);
|
||||||
|
|
||||||
} else if(o == ReplayOptions.useResources) {
|
} else if(o == ReplayOptions.useResources) {
|
||||||
resourcePackButton = new GuiSettingsOnOffButton(RESOURCEPACK_ID, xPos, yPos, 150, 20, o);
|
GuiToggleButton resourcePackButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_RESOURCEPACK_ID, xPos, yPos, 150, 20, o);
|
||||||
this.buttonList.add(resourcePackButton);
|
buttonList.add(resourcePackButton);
|
||||||
|
|
||||||
} else if(o == ReplayOptions.previewPath) {
|
} else if(o == ReplayOptions.previewPath) {
|
||||||
pathPreviewButton = new GuiSettingsOnOffButton(PATHPREVIEW_ID, xPos, yPos, 150, 20, o);
|
GuiToggleButton pathPreviewButton = new GuiSettingsOnOffButton(REPLAY_SETTINGS_PATHPREVIEW_ID, xPos, yPos, 150, 20, o);
|
||||||
this.buttonList.add(pathPreviewButton);
|
buttonList.add(pathPreviewButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
|
|||||||
@@ -39,14 +39,6 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
|||||||
displayString = displayKey + ": 1x";
|
displayString = displayKey + ": 1x";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float convertScaleRet(float value) {
|
|
||||||
if(value <= 1) {
|
|
||||||
return Math.round(value * 10);
|
|
||||||
}
|
|
||||||
float steps = value - 1;
|
|
||||||
return Math.round(steps / 0.25f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float convertScale(float value) {
|
public static float convertScale(float value) {
|
||||||
if(value == 10) {
|
if(value == 10) {
|
||||||
return 1;
|
return 1;
|
||||||
@@ -89,6 +81,7 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
|||||||
|
|
||||||
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
|
this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - 8) / 2, l);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
// TODO: Fix exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,6 +114,7 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
|||||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20);
|
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20);
|
||||||
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
|
this.drawTexturedModalRect(this.xPosition + (int) (sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
// TODO: Fix exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,13 +123,6 @@ public class GuiReplaySpeedSlider extends GuiButton implements GuiElement {
|
|||||||
return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
|
return MathHelper.clamp_float((this.snapToStepClamp(p_148266_1_) - this.valueMin) / (this.valueMax - this.valueMin), 0.0F, 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float realToNormalized(float value) {
|
|
||||||
float min = 0 - valueMin;
|
|
||||||
float max = valueMax + min;
|
|
||||||
|
|
||||||
return value / (max) - min;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float denormalizeValue(float p_148262_1_) {
|
public float denormalizeValue(float p_148262_1_) {
|
||||||
return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(p_148262_1_, 0.0F, 1.0F));
|
return this.snapToStepClamp(this.valueMin + (this.valueMax - this.valueMin) * MathHelper.clamp_float(p_148262_1_, 0.0F, 1.0F));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,22 +5,10 @@ import net.minecraft.client.gui.GuiButton;
|
|||||||
|
|
||||||
public class GuiAdvancedButton extends GuiButton implements GuiElement {
|
public class GuiAdvancedButton extends GuiButton implements GuiElement {
|
||||||
|
|
||||||
public GuiAdvancedButton(int x, int y, String buttonText) {
|
|
||||||
this(0, x, y, buttonText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiAdvancedButton(int x, int y, int widthIn, int heightIn, String buttonText) {
|
|
||||||
this(0, x, y, widthIn, heightIn, buttonText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiAdvancedButton(int id, int x, int y, String buttonText) {
|
public GuiAdvancedButton(int id, int x, int y, String buttonText) {
|
||||||
super(id, x, y, buttonText);
|
super(id, x, y, buttonText);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiAdvancedButton(int id, int x, int y, int widthIn, int heightIn, String buttonText) {
|
|
||||||
super(id, x, y, widthIn, heightIn, buttonText);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
public void draw(Minecraft mc, int mouseX, int mouseY) {
|
||||||
drawButton(mc, mouseX, mouseY);
|
drawButton(mc, mouseX, mouseY);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import java.awt.*;
|
|||||||
public class GuiArrowButton extends GuiButton {
|
public class GuiArrowButton extends GuiButton {
|
||||||
|
|
||||||
public enum Direction {
|
public enum Direction {
|
||||||
UP, DOWN, RIGHT, LEFT;
|
UP, DOWN, RIGHT, LEFT
|
||||||
}
|
}
|
||||||
|
|
||||||
private Direction dir;
|
private Direction dir;
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ public class GuiDropdown<T> extends GuiTextField {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(int xPos, int yPos, int mouseButton) {
|
public void mouseClicked(int xPos, int yPos, int mouseButton) {
|
||||||
mouseClickedResult(xPos, yPos, mouseButton);
|
mouseClickedResult(xPos, yPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean mouseClickedResult(int xPos, int yPos, int mouseButton) {
|
public boolean mouseClickedResult(int xPos, int yPos) {
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
if(xPos > xPosition + width - height && xPos < xPosition + width && yPos > yPosition && yPos < yPosition + height) {
|
if(xPos > xPosition + width - height && xPos < xPosition + width && yPos > yPosition && yPos < yPosition + height) {
|
||||||
open = !open;
|
open = !open;
|
||||||
@@ -146,8 +146,7 @@ public class GuiDropdown<T> extends GuiTextField {
|
|||||||
if(xPos > xPosition && xPos < xPosition + width && open) {
|
if(xPos > xPosition && xPos < xPosition + width && open) {
|
||||||
int requiredHeight = Math.min(maxDropoutHeight, elements.size() * dropoutElementHeight);
|
int requiredHeight = Math.min(maxDropoutHeight, elements.size() * dropoutElementHeight);
|
||||||
if(yPos > yPosition + height && yPos < yPosition + height + requiredHeight) {
|
if(yPos > yPosition + height && yPos < yPosition + height + requiredHeight) {
|
||||||
int clickedIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex;
|
this.selectionIndex = (int) Math.floor((yPos - (yPosition + height)) / dropoutElementHeight) + upperIndex;
|
||||||
this.selectionIndex = clickedIndex;
|
|
||||||
success = true;
|
success = true;
|
||||||
fireSelectionChangeEvent();
|
fireSelectionChangeEvent();
|
||||||
}
|
}
|
||||||
@@ -217,10 +216,6 @@ public class GuiDropdown<T> extends GuiTextField {
|
|||||||
this.selectionListeners.add(listener);
|
this.selectionListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSelectionListener(SelectionListener listener) {
|
|
||||||
this.selectionListeners.remove(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExpanded() {
|
public boolean isExpanded() {
|
||||||
return open;
|
return open;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,11 +118,6 @@ public class GuiEntryList<T> extends GuiTextField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearElements() {
|
|
||||||
this.elements = new ArrayList<T>();
|
|
||||||
selectionIndex = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addElement(T element) {
|
public void addElement(T element) {
|
||||||
this.elements.add(element);
|
this.elements.add(element);
|
||||||
if(selectionIndex == -1) {
|
if(selectionIndex == -1) {
|
||||||
@@ -172,8 +167,4 @@ public class GuiEntryList<T> extends GuiTextField {
|
|||||||
this.selectionListeners.add(listener);
|
this.selectionListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSelectionListener(SelectionListener listener) {
|
|
||||||
this.selectionListeners.remove(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,11 +185,8 @@ public class GuiKeyframeTimeline extends GuiTimeline {
|
|||||||
|
|
||||||
|
|
||||||
//Draw Keyframe logos
|
//Draw Keyframe logos
|
||||||
ListIterator<Keyframe> iterator = ReplayHandler.getKeyframes().listIterator();
|
for (Keyframe kf : ReplayHandler.getKeyframes()) {
|
||||||
while(iterator.hasNext()) {
|
if (kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
||||||
Keyframe kf = iterator.next();
|
|
||||||
|
|
||||||
if(kf != null && !kf.equals(ReplayHandler.getSelectedKeyframe()))
|
|
||||||
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
drawKeyframe(kf, bodyWidth, leftTime, rightTime, segmentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import java.awt.*;
|
|||||||
|
|
||||||
public class GuiLoadingListEntry implements IGuiListEntry {
|
public class GuiLoadingListEntry implements IGuiListEntry {
|
||||||
|
|
||||||
boolean registered = false;
|
|
||||||
private final Minecraft mc = Minecraft.getMinecraft();
|
private final Minecraft mc = Minecraft.getMinecraft();
|
||||||
private final String message = I18n.format("replaymod.gui.loading")+"...";
|
private final String message = I18n.format("replaymod.gui.loading")+"...";
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public class GuiNumberInput extends GuiTextField {
|
|||||||
|
|
||||||
public GuiNumberInput(int id, FontRenderer fontRenderer,
|
public GuiNumberInput(int id, FontRenderer fontRenderer,
|
||||||
int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) {
|
int xPos, int yPos, int width, int minimum, int maximum, int defaultValue, boolean acceptFloats) {
|
||||||
this(id, fontRenderer, xPos, yPos, width, new Double(minimum), new Double(maximum), new Double(defaultValue), acceptFloats);
|
this(id, fontRenderer, xPos, yPos, width, (double) minimum, (double) maximum, (double) defaultValue, acceptFloats);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -42,15 +42,12 @@ public class GuiNumberInput extends GuiTextField {
|
|||||||
} else {
|
} else {
|
||||||
val = Integer.valueOf(getText());
|
val = Integer.valueOf(getText());
|
||||||
}
|
}
|
||||||
if(minimum != null && val < minimum) {
|
|
||||||
setText(acceptFloats ? minimum.toString() : new Integer((int)Math.round(minimum)).toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(maximum != null && val > maximum) {
|
|
||||||
setText(acceptFloats ? maximum.toString() : new Integer((int)Math.round(maximum)).toString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(minimum != null && val < minimum) {
|
||||||
|
setText(acceptFloats ? minimum.toString() : Integer.toString((int) Math.round(minimum)));
|
||||||
|
} else if(maximum != null && val > maximum) {
|
||||||
|
setText(acceptFloats ? maximum.toString() : Integer.toString((int) Math.round(maximum)));
|
||||||
|
}
|
||||||
} catch(NumberFormatException e) {
|
} catch(NumberFormatException e) {
|
||||||
setText(textBefore);
|
setText(textBefore);
|
||||||
setCursorPosition(cursorPositionBefore);
|
setCursorPosition(cursorPositionBefore);
|
||||||
@@ -81,12 +78,4 @@ public class GuiNumberInput extends GuiTextField {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getPreciseValueNullable() {
|
|
||||||
try {
|
|
||||||
return Double.valueOf(getText());
|
|
||||||
} catch(Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ public class GuiOnOffButton extends GuiToggleButton {
|
|||||||
|
|
||||||
private static final String[] values = new String[] {I18n.format("options.on"), I18n.format("options.off")};
|
private static final String[] values = new String[] {I18n.format("options.on"), I18n.format("options.off")};
|
||||||
|
|
||||||
public GuiOnOffButton(int buttonId, int x, int y, String buttonText) {
|
|
||||||
super(buttonId, x, y, buttonText, values);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiOnOffButton(int buttonId, int x, int y, int width, int height, String buttonText) {
|
public GuiOnOffButton(int buttonId, int x, int y, int width, int height, String buttonText) {
|
||||||
super(buttonId, x, y, width, height, buttonText, values);
|
super(buttonId, x, y, width, height, buttonText, values);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class GuiReplayListEntry implements IGuiListEntry {
|
|||||||
private ResourceLocation textureResource;
|
private ResourceLocation textureResource;
|
||||||
private DynamicTexture dynTex = null;
|
private DynamicTexture dynTex = null;
|
||||||
private File imageFile;
|
private File imageFile;
|
||||||
private BufferedImage image = null;
|
|
||||||
private GuiReplayListExtended parent;
|
private GuiReplayListExtended parent;
|
||||||
|
|
||||||
public GuiReplayListEntry(GuiReplayListExtended parent, FileInfo fileInfo, File imageFile) {
|
public GuiReplayListEntry(GuiReplayListExtended parent, FileInfo fileInfo, File imageFile) {
|
||||||
@@ -60,13 +59,13 @@ public class GuiReplayListEntry implements IGuiListEntry {
|
|||||||
registered = false;
|
registered = false;
|
||||||
ResourceHelper.freeResource(textureResource);
|
ResourceHelper.freeResource(textureResource);
|
||||||
textureResource = null;
|
textureResource = null;
|
||||||
image = null;
|
|
||||||
dynTex = null;
|
dynTex = null;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if(!registered) {
|
if(!registered) {
|
||||||
textureResource = new ResourceLocation("thumbs/" + fileInfo.getName() + fileInfo.getId());
|
textureResource = new ResourceLocation("thumbs/" + fileInfo.getName() + fileInfo.getId());
|
||||||
|
BufferedImage image;
|
||||||
if(imageFile == null) {
|
if(imageFile == null) {
|
||||||
image = ResourceHelper.getDefaultThumbnail();
|
image = ResourceHelper.getDefaultThumbnail();
|
||||||
} else {
|
} else {
|
||||||
@@ -122,7 +121,9 @@ public class GuiReplayListEntry implements IGuiListEntry {
|
|||||||
|
|
||||||
if(online) {
|
if(online) {
|
||||||
Category category = Category.fromId(fileInfo.getCategory());
|
Category category = Category.fromId(fileInfo.getCategory());
|
||||||
|
if (category == null) {
|
||||||
|
category = Category.MISCELLANEOUS;
|
||||||
|
}
|
||||||
mc.fontRendererObj.drawStringWithShadow(ChatFormatting.ITALIC.toString()+category.toNiceString(), x + 3, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.GRAY.getRGB());
|
mc.fontRendererObj.drawStringWithShadow(ChatFormatting.ITALIC.toString()+category.toNiceString(), x + 3, y + slotHeight - mc.fontRendererObj.FONT_HEIGHT, Color.GRAY.getRGB());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton {
|
|||||||
super(buttonId, x, y, width, height, toChange.getName()+": ");
|
super(buttonId, x, y, width, height, toChange.getName()+": ");
|
||||||
this.toChange = toChange;
|
this.toChange = toChange;
|
||||||
if(toChange.getValue() instanceof Boolean) {
|
if(toChange.getValue() instanceof Boolean) {
|
||||||
this.setValue((Boolean) toChange.getValue() == true ? 0 : 1);
|
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ public class GuiSettingsOnOffButton extends GuiOnOffButton {
|
|||||||
super(buttonId, x, y, width, height, toChange.getName()+": ", onValue, offValue);
|
super(buttonId, x, y, width, height, toChange.getName()+": ", onValue, offValue);
|
||||||
this.toChange = toChange;
|
this.toChange = toChange;
|
||||||
if(toChange.getValue() instanceof Boolean) {
|
if(toChange.getValue() instanceof Boolean) {
|
||||||
this.setValue((Boolean) toChange.getValue() == true ? 0 : 1);
|
this.setValue((Boolean) toChange.getValue() ? 0 : 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,6 @@ public class GuiTexturedButton extends GuiButton implements GuiElement {
|
|||||||
private final Runnable action;
|
private final Runnable action;
|
||||||
private final String hoverText;
|
private final String hoverText;
|
||||||
|
|
||||||
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
|
|
||||||
int u, int v, int textureWidth, int textureHeight, Runnable action) {
|
|
||||||
this(buttonId, x, y, width, height, texture, u, v, textureWidth, textureHeight, action, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
|
public GuiTexturedButton(int buttonId, int x, int y, int width, int height, ResourceLocation texture,
|
||||||
int u, int v, int textureWidth, int textureHeight, Runnable action, String hoverText) {
|
int u, int v, int textureWidth, int textureHeight, Runnable action, String hoverText) {
|
||||||
super(buttonId, x, y, width, height, "");
|
super(buttonId, x, y, width, height, "");
|
||||||
|
|||||||
@@ -212,7 +212,6 @@ public class GuiTimeline extends Gui implements GuiElement {
|
|||||||
|
|
||||||
int distance;
|
int distance;
|
||||||
int smallDistance;
|
int smallDistance;
|
||||||
int maximum = 10;
|
|
||||||
|
|
||||||
MarkerType(int minimum, int smallDistance) {
|
MarkerType(int minimum, int smallDistance) {
|
||||||
this.distance = minimum;
|
this.distance = minimum;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.lwjgl.input.Keyboard;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiLoginPrompt extends GuiScreen {
|
public class GuiLoginPrompt extends GuiScreen {
|
||||||
|
|
||||||
@@ -78,12 +79,12 @@ public class GuiLoginPrompt extends GuiScreen {
|
|||||||
int tw = 150+5+strwidth;
|
int tw = 150+5+strwidth;
|
||||||
registerButton.xPosition = (width/2) - (tw/2) + strwidth+5;
|
registerButton.xPosition = (width/2) - (tw/2) + strwidth+5;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
buttonList.add(loginButton);
|
buttonList.add(loginButton);
|
||||||
buttonList.add(cancelButton);
|
buttonList.add(cancelButton);
|
||||||
buttonList.add(registerButton);
|
buttonList.add(registerButton);
|
||||||
|
|
||||||
strwidth2 = Math.max(fontRendererObj.getStringWidth(usernameLabel), fontRendererObj.getStringWidth(passwordLabel));
|
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +127,6 @@ public class GuiLoginPrompt extends GuiScreen {
|
|||||||
|
|
||||||
private String usernameLabel = I18n.format("replaymod.gui.username");
|
private String usernameLabel = I18n.format("replaymod.gui.username");
|
||||||
private String passwordLabel = I18n.format("replaymod.gui.password");
|
private String passwordLabel = I18n.format("replaymod.gui.password");
|
||||||
private int strwidth2 = 100;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||||
|
|||||||
@@ -26,9 +26,6 @@ public class GuiRegister extends GuiScreen {
|
|||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
|
|
||||||
private int strwidth = 0;
|
|
||||||
private int totalwidth = 0;
|
|
||||||
|
|
||||||
private String[] labels = new String[]{I18n.format("replaymod.gui.username"), I18n.format("replaymod.gui.mail"), I18n.format("replaymod.gui.password"),
|
private String[] labels = new String[]{I18n.format("replaymod.gui.username"), I18n.format("replaymod.gui.mail"), I18n.format("replaymod.gui.password"),
|
||||||
I18n.format("replaymod.gui.register.confirmpw")};
|
I18n.format("replaymod.gui.register.confirmpw")};
|
||||||
|
|
||||||
@@ -71,14 +68,16 @@ public class GuiRegister extends GuiScreen {
|
|||||||
inputFields.add(passwordInput);
|
inputFields.add(passwordInput);
|
||||||
inputFields.add(passwordConfirmation);
|
inputFields.add(passwordConfirmation);
|
||||||
|
|
||||||
strwidth = Math.max(Math.max(fontRendererObj.getStringWidth(labels[0]), fontRendererObj.getStringWidth(labels[1])),
|
int strwidth = Math.max(Math.max(fontRendererObj.getStringWidth(labels[0]), fontRendererObj.getStringWidth(labels[1])),
|
||||||
Math.max(fontRendererObj.getStringWidth(labels[2]), fontRendererObj.getStringWidth(labels[3])));
|
Math.max(fontRendererObj.getStringWidth(labels[2]), fontRendererObj.getStringWidth(labels[3])));
|
||||||
|
|
||||||
totalwidth = 145+10+strwidth;
|
int totalwidth = 145 + 10 + strwidth;
|
||||||
|
|
||||||
for(GuiTextField f : inputFields)
|
for(GuiTextField f : inputFields)
|
||||||
f.xPosition = (width/2) - (totalwidth/2) + strwidth+5;
|
f.xPosition = (width/2) - (totalwidth /2) + strwidth +5;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
buttonList.add(registerButton);
|
buttonList.add(registerButton);
|
||||||
buttonList.add(cancelButton);
|
buttonList.add(cancelButton);
|
||||||
|
|
||||||
|
|||||||
@@ -32,16 +32,13 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
null, null, null, null);
|
null, null, null, null);
|
||||||
private static final int LOGOUT_CALLBACK_ID = 1;
|
private static final int LOGOUT_CALLBACK_ID = 1;
|
||||||
private ReplayFileList currentList;
|
private ReplayFileList currentList;
|
||||||
private Tab currentTab = Tab.RECENT_FILES;
|
|
||||||
private GuiButton loadButton, favButton, likeButton, dislikeButton;
|
private GuiButton loadButton, favButton, likeButton, dislikeButton;
|
||||||
private List<GuiButton> replayButtonBar, bottomBar, topBar;
|
private List<GuiButton> replayButtonBar, bottomBar, topBar;
|
||||||
private GuiLoadingListEntry loadingListEntry;
|
|
||||||
|
|
||||||
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, int p_152129_2_) {
|
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, int p_152129_2_) {
|
||||||
String s1 = I18n.format("replaymod.gui.center.logoutcallback");
|
String s1 = I18n.format("replaymod.gui.center.logoutcallback");
|
||||||
GuiYesNo guiyesno = new GuiYesNo(p_152129_0_, s1, "", I18n.format("replaymod.gui.logout"),
|
return new GuiYesNo(p_152129_0_, s1, "", I18n.format("replaymod.gui.logout"),
|
||||||
I18n.format("replaymod.gui.cancel"), p_152129_2_);
|
I18n.format("replaymod.gui.cancel"), p_152129_2_);
|
||||||
return guiyesno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
@@ -110,6 +107,9 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentList.height = height-60;
|
currentList.height = height-60;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(GuiButton b : topBar) {
|
for(GuiButton b : topBar) {
|
||||||
int w = this.width - 30;
|
int w = this.width - 30;
|
||||||
@@ -355,7 +355,7 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
private void updateCurrentList(Pagination pagination) {
|
private void updateCurrentList(Pagination pagination) {
|
||||||
elementSelected(-1);
|
elementSelected(-1);
|
||||||
currentList = new ReplayFileList(mc, width, height, 50, height - 60, this);
|
currentList = new ReplayFileList(mc, width, height, 50, height - 60, this);
|
||||||
loadingListEntry = new GuiLoadingListEntry();
|
GuiLoadingListEntry loadingListEntry = new GuiLoadingListEntry();
|
||||||
currentList.addEntry(loadingListEntry);
|
currentList.addEntry(loadingListEntry);
|
||||||
|
|
||||||
if(pagination.getLoadedPages() < 0) {
|
if(pagination.getLoadedPages() < 0) {
|
||||||
@@ -381,7 +381,14 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
private Thread currentListLoader;
|
private Thread currentListLoader;
|
||||||
|
|
||||||
private void cancelCurrentListLoader() {
|
private void cancelCurrentListLoader() {
|
||||||
if(currentListLoader != null && currentListLoader.isAlive()) currentListLoader.stop();
|
if(currentListLoader != null && currentListLoader.isAlive()) {
|
||||||
|
currentListLoader.interrupt();
|
||||||
|
try {
|
||||||
|
currentListLoader.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showOnlineRecent() {
|
public void showOnlineRecent() {
|
||||||
@@ -389,7 +396,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
currentTab = Tab.RECENT_FILES;
|
|
||||||
updateCurrentList(new SearchPagination(recentFileSearchQuery));
|
updateCurrentList(new SearchPagination(recentFileSearchQuery));
|
||||||
}
|
}
|
||||||
}, "replaymod-list-loader");
|
}, "replaymod-list-loader");
|
||||||
@@ -401,7 +407,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
currentTab = Tab.BEST_FILES;
|
|
||||||
updateCurrentList(new SearchPagination(bestFileSearchQuery));
|
updateCurrentList(new SearchPagination(bestFileSearchQuery));
|
||||||
}
|
}
|
||||||
}, "replaymod-list-loader");
|
}, "replaymod-list-loader");
|
||||||
@@ -413,7 +418,6 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
currentTab = Tab.DOWNLOADED_FILES;
|
|
||||||
updateCurrentList(new DownloadedFilePagination());
|
updateCurrentList(new DownloadedFilePagination());
|
||||||
}
|
}
|
||||||
}, "replaymod-list-loader");
|
}, "replaymod-list-loader");
|
||||||
@@ -425,27 +429,10 @@ public class GuiReplayCenter extends GuiScreen implements GuiYesNoCallback {
|
|||||||
currentListLoader = new Thread(new Runnable() {
|
currentListLoader = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
currentTab = Tab.FAVORITED_FILES;
|
|
||||||
ReplayMod.favoritedFileHandler.reloadFavorites();
|
ReplayMod.favoritedFileHandler.reloadFavorites();
|
||||||
updateCurrentList(new FavoritedFilePagination());
|
updateCurrentList(new FavoritedFilePagination());
|
||||||
}
|
}
|
||||||
}, "replaymod-list-loader");
|
}, "replaymod-list-loader");
|
||||||
currentListLoader.start();
|
currentListLoader.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum Tab {
|
|
||||||
RECENT_FILES("replaymod.gui.center.tab.recent"),
|
|
||||||
BEST_FILES("replaymod.gui.center.tab.best"),
|
|
||||||
DOWNLOADED_FILES("replaymod.gui.center.tab.downloaded"),
|
|
||||||
FAVORITED_FILES("replaymod.gui.center.tab.favorited"),
|
|
||||||
SEARCH("replaymod.gui.center.tab.search");
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
|
|
||||||
Tab(String title) {
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTitle() { return I18n.format(title); }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ import net.minecraft.client.gui.GuiTextField;
|
|||||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.client.settings.GameSettings;
|
import net.minecraft.client.settings.GameSettings;
|
||||||
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
@@ -54,7 +56,8 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
|
|
||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
|
|
||||||
private int columnWidth, columnLeft, columnMiddle, columnRight;
|
private int columnWidth;
|
||||||
|
private int columnRight;
|
||||||
|
|
||||||
private GuiAdvancedTextField name, tags;
|
private GuiAdvancedTextField name, tags;
|
||||||
private GuiToggleButton category;
|
private GuiToggleButton category;
|
||||||
@@ -80,8 +83,6 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
|
|
||||||
private boolean lockUploadButton = false;
|
private boolean lockUploadButton = false;
|
||||||
|
|
||||||
private final Logger logger = LogManager.getLogger();
|
|
||||||
|
|
||||||
public GuiUploadFile(File file, GuiReplayViewer parent) {
|
public GuiUploadFile(File file, GuiReplayViewer parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|
||||||
@@ -109,17 +110,15 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
if(archive != null) {
|
if(archive != null) {
|
||||||
try {
|
IOUtils.closeQuietly(archive);
|
||||||
archive.close();
|
|
||||||
} catch(IOException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!correctFile) {
|
if(!correctFile) {
|
||||||
|
Logger logger = LogManager.getLogger();
|
||||||
logger.error("Invalid file provided to upload");
|
logger.error("Invalid file provided to upload");
|
||||||
mc.displayGuiScreen(parent); //TODO: Error message
|
mc.displayGuiScreen(parent);
|
||||||
replayFile = null;
|
replayFile = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -190,8 +189,8 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
columnWidth = Math.min(200, (width - 60) / 3);
|
columnWidth = Math.min(200, (width - 60) / 3);
|
||||||
columnLeft = width / 2 - columnWidth / 2 * 3 - 10;
|
int columnLeft = width / 2 - columnWidth / 2 * 3 - 10;
|
||||||
columnMiddle = width / 2 - columnWidth / 2;
|
int columnMiddle = width / 2 - columnWidth / 2;
|
||||||
columnRight = width / 2 + columnWidth / 2 + 10;
|
columnRight = width / 2 + columnWidth / 2 + 10;
|
||||||
|
|
||||||
name.xPosition = columnLeft;
|
name.xPosition = columnLeft;
|
||||||
@@ -218,6 +217,8 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
}
|
}
|
||||||
content = new ComposedElement(elements.toArray(new GuiElement[elements.size()]));
|
content = new ComposedElement(elements.toArray(new GuiElement[elements.size()]));
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
if(startUploadButton == null) {
|
if(startUploadButton == null) {
|
||||||
List<GuiButton> bottomBar = new ArrayList<GuiButton>();
|
List<GuiButton> bottomBar = new ArrayList<GuiButton>();
|
||||||
startUploadButton = new GuiButton(GuiConstants.UPLOAD_START_BUTTON, 0, 0, I18n.format("replaymod.gui.upload.start"));
|
startUploadButton = new GuiButton(GuiConstants.UPLOAD_START_BUTTON, 0, 0, I18n.format("replaymod.gui.upload.start"));
|
||||||
@@ -316,7 +317,7 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
|
|
||||||
ReplayMetaData newMetaData = metaData.copy();
|
ReplayMetaData newMetaData = metaData.copy();
|
||||||
newMetaData.removeServer();
|
newMetaData.removeServer();
|
||||||
ReplayFileIO.writeReplayMetaDataToFile(newMetaData, tmpMeta);
|
ReplayFileIO.write(newMetaData, tmpMeta);
|
||||||
|
|
||||||
HashMap<String, File> toAdd = new HashMap<String, File>();
|
HashMap<String, File> toAdd = new HashMap<String, File>();
|
||||||
toAdd.put(ReplayFile.ENTRY_METADATA, tmpMeta);
|
toAdd.put(ReplayFile.ENTRY_METADATA, tmpMeta);
|
||||||
@@ -326,8 +327,8 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
|
|
||||||
uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, tmp, category, desc);
|
uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, tmp, category, desc);
|
||||||
|
|
||||||
tmpMeta.delete();
|
FileUtils.deleteQuietly(tmpMeta);
|
||||||
tmp.delete();
|
FileUtils.deleteQuietly(tmp);
|
||||||
} else {
|
} else {
|
||||||
uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, replayFile, category, desc);
|
uploader.uploadFile(GuiUploadFile.this, AuthenticationHandler.getKey(), name, tags, replayFile, category, desc);
|
||||||
}
|
}
|
||||||
@@ -365,8 +366,9 @@ public class GuiUploadFile extends GuiScreen {
|
|||||||
Gui.drawScaledCustomSizeModalRect(columnRight, 20, 0, 0, 1280, 720, columnWidth, height, 1280, 720);
|
Gui.drawScaledCustomSizeModalRect(columnRight, 20, 0, 0, 1280, 720, columnWidth, height, 1280, 720);
|
||||||
|
|
||||||
if (!hasThumbnail) {
|
if (!hasThumbnail) {
|
||||||
|
KeyBinding keyBinding = KeybindRegistry.getKeyBinding(KeybindRegistry.KEY_THUMBNAIL);
|
||||||
String str = I18n.format("replaymod.gui.upload.nothumbnail",
|
String str = I18n.format("replaymod.gui.upload.nothumbnail",
|
||||||
GameSettings.getKeyDisplayString(KeybindRegistry.getKeyBinding(KeybindRegistry.KEY_THUMBNAIL).getKeyCode()));
|
keyBinding == null ? "???" : GameSettings.getKeyDisplayString(keyBinding.getKeyCode()));
|
||||||
int y = 20 + height + 10;
|
int y = 20 + height + 10;
|
||||||
fontRendererObj.drawSplitString(str, columnRight, y, columnWidth, Color.RED.getRGB());
|
fontRendererObj.drawSplitString(str, columnRight, y, columnWidth, Color.RED.getRGB());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ public class GuiReplayOverlay extends Gui {
|
|||||||
/**
|
/**
|
||||||
* Dummy interface for GUI on which this replay overlay shall not be rendered.
|
* Dummy interface for GUI on which this replay overlay shall not be rendered.
|
||||||
*/
|
*/
|
||||||
public static interface NoOverlay {
|
public interface NoOverlay {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class GuiConnectPart extends GuiStudioPart {
|
|||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
concatList = new GuiEntryList(1, fontRendererObj, 30, yPos, 150, 0);
|
concatList = new GuiEntryList<String>(1, fontRendererObj, 30, yPos, 150, 0);
|
||||||
filesToConcat = new ArrayList<String>();
|
filesToConcat = new ArrayList<String>();
|
||||||
String selectedName = FilenameUtils.getBaseName(GuiReplayEditor.instance.getSelectedFile().getAbsolutePath());
|
String selectedName = FilenameUtils.getBaseName(GuiReplayEditor.instance.getSelectedFile().getAbsolutePath());
|
||||||
filesToConcat.add(selectedName);
|
filesToConcat.add(selectedName);
|
||||||
@@ -82,7 +82,7 @@ public class GuiConnectPart extends GuiStudioPart {
|
|||||||
|
|
||||||
concatList.setSelectionIndex(0);
|
concatList.setSelectionIndex(0);
|
||||||
|
|
||||||
replayDropdown = new GuiDropdown(1, fontRendererObj, 250, yPos + 5, 0, 4);
|
replayDropdown = new GuiDropdown<String>(1, fontRendererObj, 250, yPos + 5, 0, 4);
|
||||||
|
|
||||||
replayDropdown.clearElements();
|
replayDropdown.clearElements();
|
||||||
replayFiles = ReplayFileIO.getAllReplayFiles();
|
replayFiles = ReplayFileIO.getAllReplayFiles();
|
||||||
@@ -107,14 +107,15 @@ public class GuiConnectPart extends GuiStudioPart {
|
|||||||
filesToConcat.set(concatList.getSelectionIndex(), replayDropdown.getElement(selectionIndex));
|
filesToConcat.set(concatList.getSelectionIndex(), replayDropdown.getElement(selectionIndex));
|
||||||
concatList.setElements(filesToConcat);
|
concatList.setElements(filesToConcat);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
} //Sorry, too lazy to properly avoid this Exception here
|
// TODO Prevent exception
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
concatList.addSelectionListener(new SelectionListener() {
|
concatList.addSelectionListener(new SelectionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSelectionChanged(int selectionIndex) {
|
public void onSelectionChanged(int selectionIndex) {
|
||||||
String selName = (String) concatList.getElement(selectionIndex);
|
String selName = concatList.getElement(selectionIndex);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Object s : replayDropdown.getAllElements()) {
|
for(Object s : replayDropdown.getAllElements()) {
|
||||||
String str = (String) s;
|
String str = (String) s;
|
||||||
@@ -130,14 +131,15 @@ public class GuiConnectPart extends GuiStudioPart {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
|
|
||||||
upButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_UP_BUTTON, 195, yPos + 40, "", GuiArrowButton.Direction.UP);
|
upButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_UP_BUTTON, 195, yPos + 40, "", GuiArrowButton.Direction.UP);
|
||||||
buttonList.add(upButton);
|
buttonList.add(upButton);
|
||||||
|
|
||||||
downButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_DOWN_BUTTON, 219, yPos + 40, "", GuiArrowButton.Direction.DOWN);
|
downButton = new GuiArrowButton(GuiConstants.REPLAY_EDITOR_DOWN_BUTTON, 219, yPos + 40, "", GuiArrowButton.Direction.DOWN);
|
||||||
buttonList.add(downButton);
|
buttonList.add(downButton);
|
||||||
|
|
||||||
int w = GuiReplayEditor.instance.width - 243 - 20 - 4;
|
|
||||||
|
|
||||||
removeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_REMOVE_BUTTON, 249, yPos + 40, I18n.format("replaymod.gui.remove"));
|
removeButton = new GuiButton(GuiConstants.REPLAY_EDITOR_REMOVE_BUTTON, 249, yPos + 40, I18n.format("replaymod.gui.remove"));
|
||||||
buttonList.add(removeButton);
|
buttonList.add(removeButton);
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
private static final int tabYPos = 110;
|
private static final int tabYPos = 110;
|
||||||
public static GuiReplayEditor instance = null;
|
public static GuiReplayEditor instance = null;
|
||||||
private StudioTab currentTab = StudioTab.TRIM;
|
private StudioTab currentTab = StudioTab.TRIM;
|
||||||
private GuiDropdown replayDropdown;
|
private GuiDropdown<String> replayDropdown;
|
||||||
private GuiButton saveModeButton, saveButton;
|
private GuiButton saveModeButton;
|
||||||
private boolean overrideSave = false;
|
private boolean overrideSave = false;
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
private List<File> replayFiles = new ArrayList<File>();
|
private List<File> replayFiles = new ArrayList<File>();
|
||||||
@@ -56,6 +56,8 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
List<GuiButton> tabButtons = new ArrayList<GuiButton>();
|
List<GuiButton> tabButtons = new ArrayList<GuiButton>();
|
||||||
|
|
||||||
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_TRIM_TAB, 0, 0, I18n.format("replaymod.gui.editor.trim.title")));
|
tabButtons.add(new GuiButton(GuiConstants.REPLAY_EDITOR_TRIM_TAB, 0, 0, I18n.format("replaymod.gui.editor.trim.title")));
|
||||||
@@ -79,7 +81,7 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
int modeWidth = tabButtons.get(0).width;
|
int modeWidth = tabButtons.get(0).width;
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
replayDropdown = new GuiDropdown(1, fontRendererObj, 15 + 2 + 1 + 80, 60, this.width - 30 - 8 - 80 - modeWidth - 4, 5);
|
replayDropdown = new GuiDropdown<String>(1, fontRendererObj, 15 + 2 + 1 + 80, 60, this.width - 30 - 8 - 80 - modeWidth - 4, 5);
|
||||||
refreshReplayDropdown();
|
refreshReplayDropdown();
|
||||||
} else {
|
} else {
|
||||||
replayDropdown.width = this.width - 30 - 8 - 80 - modeWidth - 4;
|
replayDropdown.width = this.width - 30 - 8 - 80 - modeWidth - 4;
|
||||||
@@ -98,7 +100,7 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
backButton.width = 70;
|
backButton.width = 70;
|
||||||
buttonList.add(backButton);
|
buttonList.add(backButton);
|
||||||
|
|
||||||
saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save"));
|
GuiButton saveButton = new GuiButton(GuiConstants.REPLAY_EDITOR_SAVE_BUTTON, width - 70 - 18, height - (2 * 20) - 5 - 3, I18n.format("replaymod.gui.save"));
|
||||||
saveButton.width = 70;
|
saveButton.width = 70;
|
||||||
buttonList.add(saveButton);
|
buttonList.add(saveButton);
|
||||||
|
|
||||||
@@ -113,8 +115,6 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
return overrideSave ? I18n.format("replaymod.gui.editor.savemode.override") : I18n.format("replaymod.gui.editor.savemode.newfile");
|
return overrideSave ? I18n.format("replaymod.gui.editor.savemode.override") : I18n.format("replaymod.gui.editor.savemode.newfile");
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void actionPerformed(GuiButton button) throws IOException {
|
protected void actionPerformed(GuiButton button) throws IOException {
|
||||||
if(!button.enabled) return;
|
if(!button.enabled) return;
|
||||||
@@ -194,7 +194,7 @@ public class GuiReplayEditor extends GuiScreen {
|
|||||||
|
|
||||||
private GuiStudioPart studioPart;
|
private GuiStudioPart studioPart;
|
||||||
|
|
||||||
private StudioTab(GuiStudioPart part) {
|
StudioTab(GuiStudioPart part) {
|
||||||
this.studioPart = part;
|
this.studioPart = part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,13 @@ import net.minecraft.client.gui.GuiButton;
|
|||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
import net.minecraft.client.gui.GuiTextField;
|
import net.minecraft.client.gui.GuiTextField;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class GuiRenameReplay extends GuiScreen {
|
public class GuiRenameReplay extends GuiScreen {
|
||||||
private GuiScreen field_146585_a;
|
private GuiScreen field_146585_a;
|
||||||
@@ -28,9 +30,11 @@ public class GuiRenameReplay extends GuiScreen {
|
|||||||
|
|
||||||
public void initGui() {
|
public void initGui() {
|
||||||
Keyboard.enableRepeatEvents(true);
|
Keyboard.enableRepeatEvents(true);
|
||||||
this.buttonList.clear();
|
@SuppressWarnings("unchecked")
|
||||||
this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("replaymod.gui.rename")));
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("replaymod.gui.cancel")));
|
buttonList.clear();
|
||||||
|
buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("replaymod.gui.rename")));
|
||||||
|
buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("replaymod.gui.cancel")));
|
||||||
String s = FilenameUtils.getBaseName(file.getAbsolutePath());
|
String s = FilenameUtils.getBaseName(file.getAbsolutePath());
|
||||||
this.field_146583_f = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
|
this.field_146583_f = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 60, 200, 20);
|
||||||
this.field_146583_f.setFocused(true);
|
this.field_146583_f.setFocused(true);
|
||||||
@@ -55,7 +59,7 @@ public class GuiRenameReplay extends GuiScreen {
|
|||||||
renamed = new File(initRenamed.getAbsolutePath() + "_" + i);
|
renamed = new File(initRenamed.getAbsolutePath() + "_" + i);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
file.renameTo(renamed);
|
FileUtils.moveFile(file, renamed);
|
||||||
this.mc.displayGuiScreen(this.field_146585_a);
|
this.mc.displayGuiScreen(this.field_146585_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ import net.minecraft.client.gui.GuiYesNo;
|
|||||||
import net.minecraft.client.gui.GuiYesNoCallback;
|
import net.minecraft.client.gui.GuiYesNoCallback;
|
||||||
import net.minecraft.client.resources.I18n;
|
import net.minecraft.client.resources.I18n;
|
||||||
import net.minecraft.util.Util;
|
import net.minecraft.util.Util;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.lwjgl.Sys;
|
import org.lwjgl.Sys;
|
||||||
import org.lwjgl.input.Keyboard;
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
@@ -29,7 +31,6 @@ import java.awt.*;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -45,7 +46,10 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
|||||||
private boolean initialized;
|
private boolean initialized;
|
||||||
private GuiReplayListExtended replayGuiList;
|
private GuiReplayListExtended replayGuiList;
|
||||||
private List<Pair<Pair<File, ReplayMetaData>, File>> replayFileList = new ArrayList<Pair<Pair<File, ReplayMetaData>, File>>();
|
private List<Pair<Pair<File, ReplayMetaData>, File>> replayFileList = new ArrayList<Pair<Pair<File, ReplayMetaData>, File>>();
|
||||||
private GuiButton loadButton, uploadButton, folderButton, renameButton, deleteButton, cancelButton, settingsButton;
|
private GuiButton loadButton;
|
||||||
|
private GuiButton uploadButton;
|
||||||
|
private GuiButton renameButton;
|
||||||
|
private GuiButton deleteButton;
|
||||||
private boolean delete_file = false;
|
private boolean delete_file = false;
|
||||||
|
|
||||||
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, String file, int p_152129_2_) {
|
public static GuiYesNo getYesNoGui(GuiYesNoCallback p_152129_0_, String file, int p_152129_2_) {
|
||||||
@@ -53,8 +57,7 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
|||||||
String s2 = "\'" + file + "\' " + I18n.format("replaymod.gui.viewer.delete.lineb");
|
String s2 = "\'" + file + "\' " + I18n.format("replaymod.gui.viewer.delete.lineb");
|
||||||
String s3 = I18n.format("replaymod.gui.delete");
|
String s3 = I18n.format("replaymod.gui.delete");
|
||||||
String s4 = I18n.format("replaymod.gui.cancel");
|
String s4 = I18n.format("replaymod.gui.cancel");
|
||||||
GuiYesNo guiyesno = new GuiYesNo(p_152129_0_, s1, s2, s3, s4, p_152129_2_);
|
return new GuiYesNo(p_152129_0_, s1, s2, s3, s4, p_152129_2_);
|
||||||
return guiyesno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadFiles() {
|
private void reloadFiles() {
|
||||||
@@ -132,13 +135,15 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createButtons() {
|
private void createButtons() {
|
||||||
this.buttonList.add(loadButton = new GuiButton(LOAD_BUTTON_ID, this.width / 2 - 154, this.height - 52, 73, 20, I18n.format("replaymod.gui.load")));
|
@SuppressWarnings("unchecked")
|
||||||
this.buttonList.add(uploadButton = new GuiButton(UPLOAD_BUTTON_ID, this.width / 2 - 154 + 78, this.height - 52, 73, 20, I18n.format("replaymod.gui.upload")));
|
List<GuiButton> buttonList = this.buttonList;
|
||||||
this.buttonList.add(folderButton = new GuiButton(FOLDER_BUTTON_ID, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("replaymod.gui.viewer.replayfolder")));
|
buttonList.add(loadButton = new GuiButton(LOAD_BUTTON_ID, this.width / 2 - 154, this.height - 52, 73, 20, I18n.format("replaymod.gui.load")));
|
||||||
this.buttonList.add(renameButton = new GuiButton(RENAME_BUTTON_ID, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("replaymod.gui.rename")));
|
buttonList.add(uploadButton = new GuiButton(UPLOAD_BUTTON_ID, this.width / 2 - 154 + 78, this.height - 52, 73, 20, I18n.format("replaymod.gui.upload")));
|
||||||
this.buttonList.add(deleteButton = new GuiButton(DELETE_BUTTON_ID, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("replaymod.gui.delete")));
|
buttonList.add(new GuiButton(FOLDER_BUTTON_ID, this.width / 2 + 4, this.height - 52, 150, 20, I18n.format("replaymod.gui.viewer.replayfolder")));
|
||||||
this.buttonList.add(settingsButton = new GuiButton(SETTINGS_BUTTON_ID, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("replaymod.gui.settings")));
|
buttonList.add(renameButton = new GuiButton(RENAME_BUTTON_ID, this.width / 2 - 154, this.height - 28, 72, 20, I18n.format("replaymod.gui.rename")));
|
||||||
this.buttonList.add(cancelButton = new GuiButton(CANCEL_BUTTON_ID, this.width / 2 + 4 + 78, this.height - 28, 72, 20, I18n.format("replaymod.gui.cancel")));
|
buttonList.add(deleteButton = new GuiButton(DELETE_BUTTON_ID, this.width / 2 - 76, this.height - 28, 72, 20, I18n.format("replaymod.gui.delete")));
|
||||||
|
buttonList.add(new GuiButton(SETTINGS_BUTTON_ID, this.width / 2 + 4, this.height - 28, 72, 20, I18n.format("replaymod.gui.settings")));
|
||||||
|
buttonList.add(new GuiButton(CANCEL_BUTTON_ID, this.width / 2 + 4 + 78, this.height - 28, 72, 20, I18n.format("replaymod.gui.cancel")));
|
||||||
setButtonsEnabled(false);
|
setButtonsEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,24 +212,24 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
|||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(new String[]{"/usr/bin/open", s});
|
Runtime.getRuntime().exec(new String[]{"/usr/bin/open", s});
|
||||||
return;
|
return;
|
||||||
} catch(IOException ioexception1) {
|
} catch (IOException e) {
|
||||||
|
LogManager.getLogger().error("Cannot open file", e);
|
||||||
}
|
}
|
||||||
} else if(Util.getOSType() == Util.EnumOS.WINDOWS) {
|
} else if(Util.getOSType() == Util.EnumOS.WINDOWS) {
|
||||||
String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", new Object[]{s});
|
String s1 = String.format("cmd.exe /C start \"Open file\" \"%s\"", s);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(s1);
|
Runtime.getRuntime().exec(s1);
|
||||||
return;
|
return;
|
||||||
} catch(IOException ioexception) {
|
} catch(IOException e) {
|
||||||
|
LogManager.getLogger().error("Cannot open file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class oclass = Class.forName("java.awt.Desktop");
|
Desktop.getDesktop().browse(file1.toURI());
|
||||||
Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]);
|
|
||||||
oclass.getMethod("browse", new Class[]{URI.class}).invoke(object, new Object[]{file1.toURI()});
|
|
||||||
} catch(Throwable throwable) {
|
} catch(Throwable throwable) {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
@@ -241,7 +246,11 @@ public class GuiReplayViewer extends GuiScreen implements GuiYesNoCallback {
|
|||||||
this.delete_file = false;
|
this.delete_file = false;
|
||||||
|
|
||||||
if(result) {
|
if(result) {
|
||||||
replayFileList.get(replayGuiList.selected).first().first().delete();
|
try {
|
||||||
|
FileUtils.forceDelete(replayFileList.get(replayGuiList.selected).first().first());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
replayFileList.remove(replayGuiList.selected);
|
replayFileList.remove(replayGuiList.selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,33 +1,15 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
public class Keyframe {
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@AllArgsConstructor
|
||||||
|
public abstract class Keyframe {
|
||||||
|
|
||||||
private int realTimestamp;
|
private int realTimestamp;
|
||||||
|
|
||||||
public Keyframe clone() {
|
public abstract Keyframe copy();
|
||||||
return new Keyframe(realTimestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Keyframe(int realTimestamp) {
|
|
||||||
this.realTimestamp = realTimestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRealTimestamp() {
|
|
||||||
return realTimestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRealTimestamp(int realTimestamp) { this.realTimestamp = realTimestamp; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o2) {
|
|
||||||
if(o2 == null) return false;
|
|
||||||
if(!(o2 instanceof Keyframe)) return false;
|
|
||||||
Keyframe kf = (Keyframe)o2;
|
|
||||||
return hashCode() == kf.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return realTimestamp;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package eu.crushedpixel.replaymod.holders;
|
|||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class KeyframeSet {
|
public class KeyframeSet {
|
||||||
@@ -40,8 +41,8 @@ public class KeyframeSet {
|
|||||||
|
|
||||||
public Keyframe[] getKeyframes() {
|
public Keyframe[] getKeyframes() {
|
||||||
List<Keyframe> kfList = new ArrayList<Keyframe>();
|
List<Keyframe> kfList = new ArrayList<Keyframe>();
|
||||||
for(Keyframe kf : positionKeyframes) kfList.add(kf);
|
Collections.addAll(kfList, positionKeyframes);
|
||||||
for(Keyframe kf : timeKeyframes) kfList.add(kf);
|
Collections.addAll(kfList, timeKeyframes);
|
||||||
return kfList.toArray(new Keyframe[kfList.size()]);
|
return kfList.toArray(new Keyframe[kfList.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +1,23 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
public class MarkerKeyframe extends Keyframe {
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public final class MarkerKeyframe extends Keyframe {
|
||||||
|
|
||||||
private Position position;
|
private Position position;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Keyframe clone() {
|
|
||||||
return new MarkerKeyframe(this.getPosition(), this.getRealTimestamp(), this.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public MarkerKeyframe(Position position, int timestamp, String name) {
|
public MarkerKeyframe(Position position, int timestamp, String name) {
|
||||||
super(timestamp);
|
super(timestamp);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position getPosition() {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o2) {
|
public Keyframe copy() {
|
||||||
if(o2 == null) return false;
|
return new MarkerKeyframe(position, getRealTimestamp(), name);
|
||||||
if(!(o2 instanceof MarkerKeyframe)) return false;
|
|
||||||
MarkerKeyframe m2 = (MarkerKeyframe)o2;
|
|
||||||
return hashCode() == m2.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder(17, 37)
|
|
||||||
.append(position)
|
|
||||||
.append(getRealTimestamp())
|
|
||||||
.append(name)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,11 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
public class PacketData {
|
public class PacketData {
|
||||||
|
private byte[] byteArray;
|
||||||
private byte[] array;
|
|
||||||
private int timestamp;
|
private int timestamp;
|
||||||
|
|
||||||
public PacketData(byte[] array, int timestamp) {
|
|
||||||
this.array = array;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] getByteArray() {
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setByteArray(byte[] array) {
|
|
||||||
this.array = array;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTimestamp(int timestamp) {
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
import java.util.Collection;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
public class PlayerVisibility {
|
public class PlayerVisibility {
|
||||||
|
|
||||||
public PlayerVisibility(Collection<UUID> hidden) {
|
|
||||||
this.hidden = hidden.toArray(new UUID[hidden.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private UUID[] hidden;
|
private UUID[] hidden;
|
||||||
|
|
||||||
public UUID[] getHiddenPlayers() {
|
|
||||||
return hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
public class Position {
|
public class Position {
|
||||||
|
|
||||||
private double x, y, z;
|
private double x, y, z;
|
||||||
@@ -14,103 +17,17 @@ public class Position {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Position(Entity e) {
|
public Position(Entity e) {
|
||||||
this.x = e.posX;
|
this(e.posX, e.posY, e.posZ, e.rotationPitch, e.rotationYaw);
|
||||||
this.y = e.posY;
|
|
||||||
this.z = e.posZ;
|
|
||||||
this.pitch = e.rotationPitch;
|
|
||||||
this.yaw = e.rotationYaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Position(double x, double y, double z, float pitch, float yaw, float roll) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.pitch = pitch;
|
|
||||||
this.yaw = yaw;
|
|
||||||
this.roll = roll;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position(double x, double y, double z, float pitch, float yaw) {
|
public Position(double x, double y, double z, float pitch, float yaw) {
|
||||||
this.x = x;
|
this(x, y, z, pitch, yaw, 0);
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.pitch = pitch;
|
|
||||||
this.yaw = yaw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setX(double x) {
|
|
||||||
this.x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setY(double y) {
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getZ() {
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZ(double z) {
|
|
||||||
this.z = z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getPitch() {
|
|
||||||
return pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPitch(float pitch) {
|
|
||||||
this.pitch = pitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getYaw() {
|
|
||||||
return yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYaw(float yaw) {
|
|
||||||
this.yaw = yaw;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getRoll() { return roll; }
|
|
||||||
|
|
||||||
public void setRoll(float roll) { this.roll = roll; }
|
|
||||||
|
|
||||||
public double distanceSquared(double x, double y, double z) {
|
public double distanceSquared(double x, double y, double z) {
|
||||||
double dx = this.x - x;
|
double dx = this.x - x;
|
||||||
double dy = this.y - y;
|
double dy = this.y - y;
|
||||||
double dz = this.z - z;
|
double dz = this.z - z;
|
||||||
return dx * dx + dy * dy + dz * dz;
|
return dx * dx + dy * dy + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch + ", Roll="+roll;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o2) {
|
|
||||||
if(o2 == null) return false;
|
|
||||||
if(!(o2 instanceof Position)) return false;
|
|
||||||
Position pos2 = (Position)o2;
|
|
||||||
return hashCode() == pos2.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder(17, 37)
|
|
||||||
.append(x)
|
|
||||||
.append(y)
|
|
||||||
.append(z)
|
|
||||||
.append(pitch)
|
|
||||||
.append(yaw)
|
|
||||||
.append(roll)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
public class PositionKeyframe extends Keyframe {
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public final class PositionKeyframe extends Keyframe {
|
||||||
|
|
||||||
private Position position;
|
private Position position;
|
||||||
private Integer spectatedEntityID = null;
|
private Integer spectatedEntityID;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Keyframe clone() {
|
|
||||||
return new PositionKeyframe(getRealTimestamp(), position, spectatedEntityID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PositionKeyframe(int realTime, Position position) {
|
public PositionKeyframe(int realTime, Position position) {
|
||||||
super(realTime);
|
this(realTime, position, null);
|
||||||
this.position = position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PositionKeyframe(int realTime, Position position, Integer spectatedEntityID) {
|
public PositionKeyframe(int realTime, Position position, Integer spectatedEntityID) {
|
||||||
@@ -27,28 +24,8 @@ public class PositionKeyframe extends Keyframe {
|
|||||||
this(realTime, new Position(spectatedEntityID), spectatedEntityID);
|
this(realTime, new Position(spectatedEntityID), spectatedEntityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Position getPosition() {
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPosition(Position position) { this.position = position; }
|
|
||||||
|
|
||||||
public Integer getSpectatedEntityID() { return spectatedEntityID; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o2) {
|
public Keyframe copy() {
|
||||||
if(o2 == null) return false;
|
return new PositionKeyframe(getRealTimestamp(), position, spectatedEntityID);
|
||||||
if(!(o2 instanceof PositionKeyframe)) return false;
|
|
||||||
PositionKeyframe kf = (PositionKeyframe)o2;
|
|
||||||
return hashCode() == kf.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder(17, 37)
|
|
||||||
.append(getPosition())
|
|
||||||
.append(getRealTimestamp())
|
|
||||||
.append(getSpectatedEntityID())
|
|
||||||
.toHashCode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,38 +1,21 @@
|
|||||||
package eu.crushedpixel.replaymod.holders;
|
package eu.crushedpixel.replaymod.holders;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.HashCodeBuilder;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
public class TimeKeyframe extends Keyframe {
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public final class TimeKeyframe extends Keyframe {
|
||||||
|
|
||||||
private final int timestamp;
|
private final int timestamp;
|
||||||
|
|
||||||
@Override
|
|
||||||
public Keyframe clone() {
|
|
||||||
return new TimeKeyframe(this.getRealTimestamp(), this.getTimestamp());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TimeKeyframe(int realTime, int timestamp) {
|
public TimeKeyframe(int realTime, int timestamp) {
|
||||||
super(realTime);
|
super(realTime);
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTimestamp() {
|
|
||||||
return timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o2) {
|
public Keyframe copy() {
|
||||||
if(o2 == null) return false;
|
return new TimeKeyframe(getRealTimestamp(), getTimestamp());
|
||||||
if(!(o2 instanceof TimeKeyframe)) return false;
|
|
||||||
TimeKeyframe kf = (TimeKeyframe)o2;
|
|
||||||
return hashCode() == kf.hashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder(17, 37)
|
|
||||||
.append(getTimestamp())
|
|
||||||
.append(getRealTimestamp())
|
|
||||||
.toHashCode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ public abstract class LinearInterpolation<K> implements Interpolation<K> {
|
|||||||
points.add(point);
|
points.add(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearPoints() {
|
|
||||||
points = new ArrayList<K>();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Pair<Float, Pair<K, K>> getCurrentPoints(float position) {
|
protected Pair<Float, Pair<K, K>> getCurrentPoints(float position) {
|
||||||
if(points.size() == 0) return null;
|
if(points.size() == 0) return null;
|
||||||
position = position * (points.size() - 1);
|
position = position * (points.size() - 1);
|
||||||
|
|||||||
@@ -24,8 +24,6 @@ public class LinearPoint extends LinearInterpolation<Position> {
|
|||||||
|
|
||||||
float rot = (float)getInterpolatedValue(first.getRoll(), second.getRoll(), perc);
|
float rot = (float)getInterpolatedValue(first.getRoll(), second.getRoll(), perc);
|
||||||
|
|
||||||
Position inter = new Position(x, y, z, pitch, yaw, rot);
|
return new Position(x, y, z, pitch, yaw, rot);
|
||||||
|
|
||||||
return inter;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ public class LinearTimestamp extends LinearInterpolation<Integer> {
|
|||||||
int first = pair.second().first();
|
int first = pair.second().first();
|
||||||
int second = pair.second().second();
|
int second = pair.second().second();
|
||||||
|
|
||||||
int val = (int) getInterpolatedValue(first, second, perc);
|
return (int) getInterpolatedValue(first, second, perc);
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class SplinePoint extends BasicSpline implements Interpolation<Position> {
|
public class SplinePoint extends BasicSpline implements Interpolation<Position> {
|
||||||
private static final Object[] EMPTYOBJ = new Object[]{};
|
|
||||||
private Vector<Position> points;
|
private Vector<Position> points;
|
||||||
private Vector<Cubic> xCubics;
|
private Vector<Cubic> xCubics;
|
||||||
private Vector<Cubic> yCubics;
|
private Vector<Cubic> yCubics;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class AuthenticationHandler {
|
|||||||
}
|
}
|
||||||
public static String getUsername() { return username; }
|
public static String getUsername() { return username; }
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public static boolean hasDonated(String uuid) throws IOException, ApiException {
|
public static boolean hasDonated(String uuid) throws IOException, ApiException {
|
||||||
return apiClient.hasDonated(uuid);
|
return apiClient.hasDonated(uuid);
|
||||||
}
|
}
|
||||||
@@ -42,12 +43,12 @@ public class AuthenticationHandler {
|
|||||||
AuthKey auth = apiClient.register(usrname, mail, password,
|
AuthKey auth = apiClient.register(usrname, mail, password,
|
||||||
mc.getSession().getProfile().getId().toString());
|
mc.getSession().getProfile().getId().toString());
|
||||||
username = usrname;
|
username = usrname;
|
||||||
authkey = auth.getAuthkey();
|
authkey = auth.getAuth();
|
||||||
saveAuthkey(authkey);
|
saveAuthkey(authkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAuthkeyFromConfig() {
|
public static void loadAuthkeyFromConfig() {
|
||||||
Property p = ReplayMod.instance.config.get("authkey", "authkey", "null");
|
Property p = ReplayMod.config.get("authkey", "authkey", "null");
|
||||||
|
|
||||||
String key = null;
|
String key = null;
|
||||||
if(!(p.getString().equals("null"))) {
|
if(!(p.getString().equals("null"))) {
|
||||||
@@ -68,7 +69,7 @@ public class AuthenticationHandler {
|
|||||||
|
|
||||||
public static int authenticate(String usrname, String password) {
|
public static int authenticate(String usrname, String password) {
|
||||||
try {
|
try {
|
||||||
authkey = ReplayMod.apiClient.getLogin(usrname, password).getAuthkey();
|
authkey = ReplayMod.apiClient.getLogin(usrname, password).getAuth();
|
||||||
username = usrname;
|
username = usrname;
|
||||||
saveAuthkey(authkey);
|
saveAuthkey(authkey);
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
@@ -94,8 +95,8 @@ public class AuthenticationHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void saveAuthkey(String authkey) {
|
private static void saveAuthkey(String authkey) {
|
||||||
ReplayMod.instance.config.removeCategory(ReplayMod.config.getCategory("authkey"));
|
ReplayMod.config.removeCategory(ReplayMod.config.getCategory("authkey"));
|
||||||
ReplayMod.instance.config.get("authkey", "authkey", authkey);
|
ReplayMod.config.get("authkey", "authkey", authkey);
|
||||||
ReplayMod.instance.config.save();
|
ReplayMod.config.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,19 +21,14 @@ public class AuthenticationHash {
|
|||||||
public final String hash;
|
public final String hash;
|
||||||
|
|
||||||
private String getAuthenticationHash() {
|
private String getAuthenticationHash() {
|
||||||
StringBuilder builder = new StringBuilder();
|
String md5 = username + currentTime + randomLong;
|
||||||
builder.append(username);
|
|
||||||
builder.append(currentTime);
|
|
||||||
builder.append(randomLong);
|
|
||||||
|
|
||||||
String md5 = builder.toString();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
|
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
|
||||||
byte[] array = md.digest(md5.getBytes());
|
byte[] array = md.digest(md5.getBytes());
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < array.length; ++i) {
|
for (byte b : array) {
|
||||||
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
|
sb.append(Integer.toHexString((b & 0xFF) | 0x100).substring(1, 3));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} catch (java.security.NoSuchAlgorithmException e) {
|
} catch (java.security.NoSuchAlgorithmException e) {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import eu.crushedpixel.replaymod.gui.overlay.GuiRecordingOverlay;
|
|||||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelHandler;
|
|
||||||
import io.netty.channel.ChannelPipeline;
|
import io.netty.channel.ChannelPipeline;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.network.NetworkManager;
|
import net.minecraft.network.NetworkManager;
|
||||||
@@ -23,23 +22,16 @@ import org.apache.logging.log4j.Logger;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public class ConnectionEventHandler {
|
public class ConnectionEventHandler {
|
||||||
|
|
||||||
private static final String decoderKey = "decoder";
|
|
||||||
private static final String packetHandlerKey = "packet_handler";
|
private static final String packetHandlerKey = "packet_handler";
|
||||||
private static final String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss";
|
private static final String DATE_FORMAT = "yyyy_MM_dd_HH_mm_ss";
|
||||||
private static final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
private static final SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
|
||||||
private static PacketListener packetListener = null;
|
private static PacketListener packetListener = null;
|
||||||
private static boolean isRecording = false;
|
private static boolean isRecording = false;
|
||||||
private final GuiRecordingOverlay guiOverlay = new GuiRecordingOverlay(Minecraft.getMinecraft());
|
private final GuiRecordingOverlay guiOverlay = new GuiRecordingOverlay(Minecraft.getMinecraft());
|
||||||
private File currentFile;
|
|
||||||
private String fileName;
|
|
||||||
|
|
||||||
private static final Logger logger = LogManager.getLogger();
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
@@ -95,65 +87,26 @@ public class ConnectionEventHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
NetworkManager nm = event.manager;
|
NetworkManager nm = event.manager;
|
||||||
String worldName = "";
|
String worldName;
|
||||||
if(!event.isLocal) {
|
if(event.isLocal) {
|
||||||
|
worldName = MinecraftServer.getServer().getWorldName();
|
||||||
|
} else {
|
||||||
worldName = ((InetSocketAddress) nm.getRemoteAddress()).getHostName();
|
worldName = ((InetSocketAddress) nm.getRemoteAddress()).getHostName();
|
||||||
}
|
}
|
||||||
Channel channel = nm.channel();
|
Channel channel = nm.channel();
|
||||||
ChannelPipeline pipeline = channel.pipeline();
|
ChannelPipeline pipeline = channel.pipeline();
|
||||||
|
|
||||||
List<String> channelHandlerKeys = new ArrayList<String>();
|
|
||||||
Iterator<Entry<String, ChannelHandler>> it = pipeline.iterator();
|
|
||||||
while(it.hasNext()) {
|
|
||||||
Entry<String, ChannelHandler> entry = it.next();
|
|
||||||
channelHandlerKeys.add(entry.getKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
File folder = ReplayFileIO.getReplayFolder();
|
File folder = ReplayFileIO.getReplayFolder();
|
||||||
|
|
||||||
fileName = sdf.format(Calendar.getInstance().getTime());
|
String fileName = sdf.format(Calendar.getInstance().getTime());
|
||||||
currentFile = new File(folder, fileName + ReplayFile.TEMP_FILE_EXTENSION);
|
File currentFile = new File(folder, fileName + ReplayFile.TEMP_FILE_EXTENSION);
|
||||||
|
|
||||||
currentFile.createNewFile();
|
pipeline.addBefore(packetHandlerKey, "replay_recorder", packetListener = new PacketListener
|
||||||
|
|
||||||
PacketListener insert = null;
|
|
||||||
|
|
||||||
pipeline.addBefore(packetHandlerKey, "replay_recorder", insert = new PacketListener
|
|
||||||
(currentFile, fileName, worldName, System.currentTimeMillis(), event.isLocal));
|
(currentFile, fileName, worldName, System.currentTimeMillis(), event.isLocal));
|
||||||
ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.recordingstarted", ChatMessageType.INFORMATION);
|
ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.recordingstarted", ChatMessageType.INFORMATION);
|
||||||
isRecording = true;
|
isRecording = true;
|
||||||
|
|
||||||
MinecraftForge.EVENT_BUS.register(guiOverlay);
|
MinecraftForge.EVENT_BUS.register(guiOverlay);
|
||||||
|
|
||||||
final PacketListener listener = insert;
|
|
||||||
|
|
||||||
if(insert != null && event.isLocal) {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
String worldName = null;
|
|
||||||
while (true) {
|
|
||||||
if (MinecraftServer.getServer() != null) {
|
|
||||||
worldName = MinecraftServer.getServer().getWorldName();
|
|
||||||
}
|
|
||||||
if (worldName == null) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(100);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
listener.setWorldName(worldName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "replaymod-world-name-fetcher").start();
|
|
||||||
}
|
|
||||||
|
|
||||||
packetListener = listener;
|
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.recordingfailed", ChatMessageType.WARNING);
|
ReplayMod.chatMessageHandler.addLocalizedChatMessage("replaymod.chat.recordingfailed", ChatMessageType.WARNING);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package eu.crushedpixel.replaymod.recording;
|
|||||||
|
|
||||||
import com.google.common.hash.Hashing;
|
import com.google.common.hash.Hashing;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
import eu.crushedpixel.replaymod.holders.MarkerKeyframe;
|
||||||
import eu.crushedpixel.replaymod.holders.PacketData;
|
import eu.crushedpixel.replaymod.holders.PacketData;
|
||||||
@@ -37,7 +36,6 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter {
|
|||||||
protected Set<String> players = new HashSet<String>();
|
protected Set<String> players = new HashSet<String>();
|
||||||
protected Set<MarkerKeyframe> markers = new HashSet<MarkerKeyframe>();
|
protected Set<MarkerKeyframe> markers = new HashSet<MarkerKeyframe>();
|
||||||
private boolean singleplayer;
|
private boolean singleplayer;
|
||||||
private Gson gson = new Gson();
|
|
||||||
|
|
||||||
private int saveState = 0; //0: Idle, 1: Saving, 2: Saved
|
private int saveState = 0; //0: Idle, 1: Saving, 2: Saved
|
||||||
|
|
||||||
@@ -72,10 +70,6 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter {
|
|||||||
}, "shutdown-hook-data-listener"));
|
}, "shutdown-hook-data-listener"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorldName(String worldName) {
|
|
||||||
this.worldName = worldName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelInactive(ChannelHandlerContext ctx) {
|
public void channelInactive(ChannelHandlerContext ctx) {
|
||||||
dataWriter.requestFinish(players, markers);
|
dataWriter.requestFinish(players, markers);
|
||||||
@@ -181,11 +175,9 @@ public abstract class DataListener extends ChannelInboundHandlerAdapter {
|
|||||||
File folder = ReplayFileIO.getReplayFolder();
|
File folder = ReplayFileIO.getReplayFolder();
|
||||||
|
|
||||||
File archive = new File(folder, name + ReplayFile.ZIP_FILE_EXTENSION);
|
File archive = new File(folder, name + ReplayFile.ZIP_FILE_EXTENSION);
|
||||||
archive.createNewFile();
|
|
||||||
|
|
||||||
ReplayFileIO.writeReplayFile(archive, file, metaData, markers, resourcePacks, requestToHash);
|
ReplayFileIO.writeReplayFile(archive, file, metaData, markers, resourcePacks, requestToHash);
|
||||||
|
|
||||||
file.delete();
|
FileUtils.forceDelete(file);
|
||||||
FileUtils.deleteDirectory(tempResourcePacksFolder);
|
FileUtils.deleteDirectory(tempResourcePacksFolder);
|
||||||
|
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package eu.crushedpixel.replaymod.recording;
|
package eu.crushedpixel.replaymod.recording;
|
||||||
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import net.minecraft.network.*;
|
import net.minecraft.network.*;
|
||||||
import net.minecraft.util.MessageSerializer;
|
import net.minecraft.util.MessageSerializer;
|
||||||
@@ -14,14 +13,6 @@ public class PacketSerializer extends MessageSerializer {
|
|||||||
super(direction);
|
super(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ByteBuf toByteBuf(byte[] bytes) throws IOException, ClassNotFoundException {
|
|
||||||
ByteBuf bb;
|
|
||||||
bb = Unpooled.buffer(bytes.length);
|
|
||||||
bb.writeBytes(bytes);
|
|
||||||
|
|
||||||
return bb;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf byteBuf) throws IOException {
|
public void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf byteBuf) throws IOException {
|
||||||
EnumConnectionState state = ((EnumConnectionState) ctx.channel().attr(NetworkManager.attrKeyConnectionState).get());
|
EnumConnectionState state = ((EnumConnectionState) ctx.channel().attr(NetworkManager.attrKeyConnectionState).get());
|
||||||
@@ -31,11 +22,9 @@ public class PacketSerializer extends MessageSerializer {
|
|||||||
public void encode(EnumConnectionState state, Packet packet, ByteBuf byteBuf) {
|
public void encode(EnumConnectionState state, Packet packet, ByteBuf byteBuf) {
|
||||||
Integer integer = state.getPacketId(EnumPacketDirection.CLIENTBOUND, packet);
|
Integer integer = state.getPacketId(EnumPacketDirection.CLIENTBOUND, packet);
|
||||||
|
|
||||||
if(integer == null) {
|
if (integer != null) {
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
PacketBuffer packetbuffer = new PacketBuffer(byteBuf);
|
PacketBuffer packetbuffer = new PacketBuffer(byteBuf);
|
||||||
packetbuffer.writeVarIntToBuffer(integer.intValue());
|
packetbuffer.writeVarIntToBuffer(integer);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
packet.writePacketData(packetbuffer);
|
packet.writePacketData(packetbuffer);
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package eu.crushedpixel.replaymod.recording;
|
package eu.crushedpixel.replaymod.recording;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
public class ReplayMetaData {
|
public class ReplayMetaData {
|
||||||
|
|
||||||
private boolean singleplayer;
|
private boolean singleplayer;
|
||||||
@@ -15,48 +20,5 @@ public class ReplayMetaData {
|
|||||||
this.duration, this.date, this.players, this.mcversion);
|
this.duration, this.date, this.players, this.mcversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReplayMetaData(boolean singleplayer, String serverName, String generator,
|
|
||||||
int duration, long date, String[] players, String mcversion) {
|
|
||||||
this.singleplayer = singleplayer;
|
|
||||||
this.serverName = serverName;
|
|
||||||
this.generator = generator;
|
|
||||||
this.duration = duration;
|
|
||||||
this.date = date;
|
|
||||||
this.players = players;
|
|
||||||
this.mcversion = mcversion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeServer() { this.serverName = null; }
|
public void removeServer() { this.serverName = null; }
|
||||||
|
|
||||||
public boolean isSingleplayer() {
|
|
||||||
return singleplayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServerName() {
|
|
||||||
return serverName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGenerator() {
|
|
||||||
return generator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getDuration() {
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDuration(int duration) {
|
|
||||||
this.duration = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getDate() {
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getPlayers() {
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMCVersion() {
|
|
||||||
return mcversion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ package eu.crushedpixel.replaymod.registry;
|
|||||||
import eu.crushedpixel.replaymod.ReplayMod;
|
import eu.crushedpixel.replaymod.ReplayMod;
|
||||||
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHandler;
|
||||||
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
import eu.crushedpixel.replaymod.utils.ReplayFile;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class DownloadedFileHandler {
|
public class DownloadedFileHandler {
|
||||||
@@ -16,18 +18,19 @@ public class DownloadedFileHandler {
|
|||||||
|
|
||||||
public DownloadedFileHandler() {
|
public DownloadedFileHandler() {
|
||||||
downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath());
|
downloadFolder = new File(ReplayMod.replaySettings.getDownloadPath());
|
||||||
downloadFolder.mkdirs();
|
try {
|
||||||
|
FileUtils.forceMkdir(downloadFolder);
|
||||||
|
|
||||||
for(File f : downloadFolder.listFiles()) {
|
for(File f : FileUtils.listFiles(downloadFolder, new String[]{"mcpr"}, false)) {
|
||||||
if(!FilenameUtils.getExtension(f.getAbsolutePath()).equals("mcpr")) continue;
|
try {
|
||||||
try {
|
int id = Integer.parseInt(FilenameUtils.getBaseName(f.getAbsolutePath()));
|
||||||
Integer i = Integer.valueOf(FilenameUtils.getBaseName(f.getAbsolutePath()));
|
downloadedFiles.put(id, f);
|
||||||
if(i != null) {
|
} catch(NumberFormatException e) {
|
||||||
downloadedFiles.put(i, f);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ public class PlayerHandler {
|
|||||||
private static Predicate<EntityPlayer> playerPredicate = new Predicate<EntityPlayer>() {
|
private static Predicate<EntityPlayer> playerPredicate = new Predicate<EntityPlayer>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(EntityPlayer input) {
|
public boolean apply(EntityPlayer input) {
|
||||||
if(input instanceof CameraEntity || input == mc.thePlayer) return false;
|
return !(input instanceof CameraEntity || input == mc.thePlayer);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ public class PlayerHandler {
|
|||||||
resetHiddenPlayers();
|
resetHiddenPlayers();
|
||||||
if(visibility != null) {
|
if(visibility != null) {
|
||||||
GuiPlayerOverview.defaultSave = true;
|
GuiPlayerOverview.defaultSave = true;
|
||||||
Collections.addAll(hidden, visibility.getHiddenPlayers());
|
Collections.addAll(hidden, visibility.getHidden());
|
||||||
} else {
|
} else {
|
||||||
GuiPlayerOverview.defaultSave = false;
|
GuiPlayerOverview.defaultSave = false;
|
||||||
}
|
}
|
||||||
@@ -65,6 +64,7 @@ public class PlayerHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
List<EntityPlayer> players = mc.theWorld.getEntities(EntityPlayer.class, playerPredicate);
|
List<EntityPlayer> players = mc.theWorld.getEntities(EntityPlayer.class, playerPredicate);
|
||||||
mc.displayGuiScreen(new GuiPlayerOverview(players));
|
mc.displayGuiScreen(new GuiPlayerOverview(players));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,6 @@ public class RatedFileHandler {
|
|||||||
reloadRatings();
|
reloadRatings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, Boolean> getRated() {
|
|
||||||
return rated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rating.RatingType getRating(int id) {
|
public Rating.RatingType getRating(int id) {
|
||||||
return Rating.RatingType.fromBoolean(rated.get(id));
|
return Rating.RatingType.fromBoolean(rated.get(id));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import eu.crushedpixel.replaymod.gui.GuiReplaySaving;
|
|||||||
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
import eu.crushedpixel.replaymod.utils.ReplayFileIO;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
@@ -17,7 +19,6 @@ public class ReplayFileAppender extends Thread {
|
|||||||
private Multimap<File, Pair<File, String>> filesToMove = ArrayListMultimap.create();
|
private Multimap<File, Pair<File, String>> filesToMove = ArrayListMultimap.create();
|
||||||
private Queue<File> filesToRewrite = new ConcurrentLinkedQueue<File>();
|
private Queue<File> filesToRewrite = new ConcurrentLinkedQueue<File>();
|
||||||
|
|
||||||
private boolean shutdown = false;
|
|
||||||
private List<GuiReplaySaving> listeners = new ArrayList<GuiReplaySaving>();
|
private List<GuiReplaySaving> listeners = new ArrayList<GuiReplaySaving>();
|
||||||
|
|
||||||
//this is true if the DataListener is currently busy saving a newly recorded Replay File
|
//this is true if the DataListener is currently busy saving a newly recorded Replay File
|
||||||
@@ -53,11 +54,9 @@ public class ReplayFileAppender extends Thread {
|
|||||||
|
|
||||||
public void registerModifiedFile(File toAdd, String name, File replayFile) {
|
public void registerModifiedFile(File toAdd, String name, File replayFile) {
|
||||||
//first, remove any files with the same name assigned to this Replay File
|
//first, remove any files with the same name assigned to this Replay File
|
||||||
if(filesToMove.get(replayFile) != null) {
|
for (Iterator<Pair<File, String>> iter = filesToMove.get(replayFile).iterator(); iter.hasNext(); ) {
|
||||||
for(Pair<File, String> p : new ArrayList<Pair<File, String>>((Collection<Pair<File, String>>)filesToMove.get(replayFile))) {
|
if (iter.next().getRight().equals(name)) {
|
||||||
if(p.getRight().equals(name)) {
|
iter.remove();
|
||||||
filesToMove.remove(replayFile, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +70,7 @@ public class ReplayFileAppender extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
shutdown = true;
|
interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFinishListener(GuiReplaySaving gui) {
|
public void addFinishListener(GuiReplaySaving gui) {
|
||||||
@@ -80,7 +79,7 @@ public class ReplayFileAppender extends Thread {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while(!shutdown || !filesToRewrite.isEmpty()) {
|
while(!Thread.interrupted() || !filesToRewrite.isEmpty()) {
|
||||||
File replayFile = filesToRewrite.poll();
|
File replayFile = filesToRewrite.poll();
|
||||||
if(replayFile != null) {
|
if(replayFile != null) {
|
||||||
if(replayFile.canWrite()) {
|
if(replayFile.canWrite()) {
|
||||||
@@ -96,7 +95,11 @@ public class ReplayFileAppender extends Thread {
|
|||||||
//delete all written files
|
//delete all written files
|
||||||
for(Pair<File, String> p : filesToMove.get(replayFile)) {
|
for(Pair<File, String> p : filesToMove.get(replayFile)) {
|
||||||
if(p.getLeft() != null) {
|
if(p.getLeft() != null) {
|
||||||
p.getLeft().delete();
|
try {
|
||||||
|
FileUtils.forceDelete(p.getLeft());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +117,9 @@ public class ReplayFileAppender extends Thread {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Thread.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch(Exception e) {}
|
} catch (InterruptedException e) {
|
||||||
|
interrupt();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class UploadedFileHandler {
|
|||||||
public UploadedFileHandler(File confDir) {
|
public UploadedFileHandler(File confDir) {
|
||||||
try {
|
try {
|
||||||
File confFile = new File(confDir, "uploaded");
|
File confFile = new File(confDir, "uploaded");
|
||||||
confFile.createNewFile();
|
FileUtils.touch(confFile);
|
||||||
configuration = new Configuration(confFile);
|
configuration = new Configuration(confFile);
|
||||||
configuration.load();
|
configuration.load();
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ public class InvisibilityRender extends RenderPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
public boolean shouldRender(Entity entity, ICamera camera, double camX, double camY, double camZ) {
|
||||||
if(PlayerHandler.isHidden(entity.getUniqueID()) || entity.isInvisible() ||
|
return !(PlayerHandler.isHidden(entity.getUniqueID()) || entity.isInvisible() || (ReplayHandler.isInReplay()
|
||||||
(ReplayHandler.isInReplay() && entity == Minecraft.getMinecraft().thePlayer)) return false;
|
&& entity == Minecraft.getMinecraft().thePlayer))
|
||||||
return super.shouldRender(entity, camera, camX, camY, camZ);
|
&& super.shouldRender(entity, camera, camX, camY, camZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,7 @@ public class SafeEntityRenderer extends EntityRenderer {
|
|||||||
super.updateCameraAndRender(partialTicks);
|
super.updateCameraAndRender(partialTicks);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} //This is plain easier than doing proper error prevention.
|
}
|
||||||
//If Johni reads this, don't think I'm a bad programmer... Just a lazy one :P
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -24,6 +23,7 @@ public class SafeEntityRenderer extends EntityRenderer {
|
|||||||
try {
|
try {
|
||||||
super.updateRenderer();
|
super.updateRenderer();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.minecraft.block.state.IBlockState;
|
|||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.model.ModelPlayer;
|
import net.minecraft.client.model.ModelPlayer;
|
||||||
import net.minecraft.client.renderer.*;
|
import net.minecraft.client.renderer.*;
|
||||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
@@ -117,8 +116,10 @@ public class SpectatorRenderer {
|
|||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void renderItemInFirstPerson(float partialTicks) {
|
public void renderItemInFirstPerson(float partialTicks) {
|
||||||
EntityPlayer entityPlayer = getSpectatedPlayer();
|
EntityPlayer entityPlayer = getSpectatedPlayer();
|
||||||
|
if (entityPlayer == null) return;
|
||||||
|
|
||||||
float equippedProgressState = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks);
|
float equippedProgressState = 1.0F - (prevEquippedProgress + (equippedProgress - prevEquippedProgress) * partialTicks);
|
||||||
float swingProgress = entityPlayer.getSwingProgress(partialTicks);
|
float swingProgress = entityPlayer.getSwingProgress(partialTicks);
|
||||||
@@ -171,7 +172,8 @@ public class SpectatorRenderer {
|
|||||||
mc.entityRenderer.itemRenderer.func_178096_b(equippedProgressState, swingProgress);
|
mc.entityRenderer.itemRenderer.func_178096_b(equippedProgressState, swingProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
mc.entityRenderer.itemRenderer.renderItem(entityPlayer, itemToRender, ItemCameraTransforms.TransformType.FIRST_PERSON);
|
mc.entityRenderer.itemRenderer.renderItem(entityPlayer, itemToRender,
|
||||||
|
net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType.FIRST_PERSON);
|
||||||
}
|
}
|
||||||
else if (!entityPlayer.isInvisible()) {
|
else if (!entityPlayer.isInvisible()) {
|
||||||
renderPlayerHand(entityPlayer, equippedProgressState, swingProgress);
|
renderPlayerHand(entityPlayer, equippedProgressState, swingProgress);
|
||||||
@@ -210,7 +212,7 @@ public class SpectatorRenderer {
|
|||||||
GlStateManager.rotate(0.0F, 1.0F, 0.0F, 0.0F);
|
GlStateManager.rotate(0.0F, 1.0F, 0.0F, 0.0F);
|
||||||
GlStateManager.translate(-1.0F, -1.0F, 0.0F);
|
GlStateManager.translate(-1.0F, -1.0F, 0.0F);
|
||||||
GlStateManager.scale(0.015625F, 0.015625F, 0.015625F);
|
GlStateManager.scale(0.015625F, 0.015625F, 0.015625F);
|
||||||
this.mc.getTextureManager().bindTexture(mc.entityRenderer.itemRenderer.RES_MAP_BACKGROUND);
|
this.mc.getTextureManager().bindTexture(ItemRenderer.RES_MAP_BACKGROUND);
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||||
GL11.glNormal3f(0.0F, 0.0F, -1.0F);
|
GL11.glNormal3f(0.0F, 0.0F, -1.0F);
|
||||||
@@ -229,7 +231,7 @@ public class SpectatorRenderer {
|
|||||||
|
|
||||||
public void renderMapArms(EntityPlayer entityPlayer) {
|
public void renderMapArms(EntityPlayer entityPlayer) {
|
||||||
bindPlayerTexture(entityPlayer);
|
bindPlayerTexture(entityPlayer);
|
||||||
Render render = mc.entityRenderer.itemRenderer.renderManager.getEntityRenderObject((EntityPlayer)ReplayHandler.getCurrentEntity());
|
Render render = mc.entityRenderer.itemRenderer.renderManager.getEntityRenderObject(ReplayHandler.getCurrentEntity());
|
||||||
RenderPlayer renderplayer = (RenderPlayer)render;
|
RenderPlayer renderplayer = (RenderPlayer)render;
|
||||||
|
|
||||||
if(!entityPlayer.isInvisible()) {
|
if(!entityPlayer.isInvisible()) {
|
||||||
@@ -444,11 +446,7 @@ public class SpectatorRenderer {
|
|||||||
if(!itemToRender.getIsItemStackEqual(itemstack)) {
|
if(!itemToRender.getIsItemStackEqual(itemstack)) {
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
} else if(itemToRender == null && itemstack == null) {
|
} else flag = !(itemToRender == null && itemstack == null);
|
||||||
flag = false;
|
|
||||||
} else {
|
|
||||||
flag = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
float f = 0.4F;
|
float f = 0.4F;
|
||||||
float f1 = flag ? 0.0F : 1.0F;
|
float f1 = flag ? 0.0F : 1.0F;
|
||||||
@@ -484,7 +482,7 @@ public class SpectatorRenderer {
|
|||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
double d0 = player.posX + (double)(((float)((i >> 0) % 2) - 0.5F) * player.width * 0.8F);
|
double d0 = player.posX + (double)(((float)((i) % 2) - 0.5F) * player.width * 0.8F);
|
||||||
double d1 = player.posY + (double)(((float)((i >> 1) % 2) - 0.5F) * 0.1F);
|
double d1 = player.posY + (double)(((float)((i >> 1) % 2) - 0.5F) * 0.1F);
|
||||||
double d2 = player.posZ + (double)(((float)((i >> 2) % 2) - 0.5F) * player.width * 0.8F);
|
double d2 = player.posZ + (double)(((float)((i >> 2) % 2) - 0.5F) * player.width * 0.8F);
|
||||||
BlockPos blockpos = new BlockPos(d0, d1 + (double)player.getEyeHeight(), d2);
|
BlockPos blockpos = new BlockPos(d0, d1 + (double)player.getEyeHeight(), d2);
|
||||||
@@ -516,7 +514,7 @@ public class SpectatorRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void renderWaterOverlayTexture(float partialTicks, EntityPlayer player) {
|
public void renderWaterOverlayTexture(float partialTicks, EntityPlayer player) {
|
||||||
this.mc.getTextureManager().bindTexture(mc.entityRenderer.itemRenderer.RES_UNDERWATER_OVERLAY);
|
this.mc.getTextureManager().bindTexture(ItemRenderer.RES_UNDERWATER_OVERLAY);
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
Tessellator tessellator = Tessellator.getInstance();
|
||||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||||
float f1 = player.getBrightness(partialTicks);
|
float f1 = player.getBrightness(partialTicks);
|
||||||
|
|||||||
@@ -27,8 +27,4 @@ public class OpenEmbeddedChannel extends EmbeddedChannel {
|
|||||||
}
|
}
|
||||||
return pipeline().close();
|
return pipeline().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelFuture manualClose() {
|
|
||||||
return pipeline().close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class ReplayHandler {
|
|||||||
try {
|
try {
|
||||||
File tempFile = File.createTempFile(ReplayFile.ENTRY_PATHS, "json");
|
File tempFile = File.createTempFile(ReplayFile.ENTRY_PATHS, "json");
|
||||||
|
|
||||||
ReplayFileIO.writeKeyframeRegistryToFile(repo, tempFile);
|
ReplayFileIO.write(repo, tempFile);
|
||||||
|
|
||||||
ReplayMod.replayFileAppender.registerModifiedFile(tempFile, ReplayFile.ENTRY_PATHS, getReplayFile());
|
ReplayMod.replayFileAppender.registerModifiedFile(tempFile, ReplayFile.ENTRY_PATHS, getReplayFile());
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
@@ -82,15 +82,13 @@ public class ReplayHandler {
|
|||||||
for(Keyframe kf : new ArrayList<Keyframe>(keyframes)) {
|
for(Keyframe kf : new ArrayList<Keyframe>(keyframes)) {
|
||||||
if(kf instanceof MarkerKeyframe) keyframes.remove(kf);
|
if(kf instanceof MarkerKeyframe) keyframes.remove(kf);
|
||||||
}
|
}
|
||||||
for(MarkerKeyframe marker : m) {
|
Collections.addAll(keyframes, m);
|
||||||
keyframes.add(marker);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(write) {
|
if(write) {
|
||||||
try {
|
try {
|
||||||
File tempFile = File.createTempFile(ReplayFile.ENTRY_MARKERS, "json");
|
File tempFile = File.createTempFile(ReplayFile.ENTRY_MARKERS, "json");
|
||||||
|
|
||||||
ReplayFileIO.writeMarkersToFile(m, tempFile);
|
ReplayFileIO.write(m, tempFile);
|
||||||
|
|
||||||
ReplayMod.replayFileAppender.registerModifiedFile(tempFile, ReplayFile.ENTRY_MARKERS, getReplayFile());
|
ReplayMod.replayFileAppender.registerModifiedFile(tempFile, ReplayFile.ENTRY_MARKERS, getReplayFile());
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
@@ -110,9 +108,7 @@ public class ReplayHandler {
|
|||||||
|
|
||||||
keyframes = new ArrayList<Keyframe>(Arrays.asList(kfs));
|
keyframes = new ArrayList<Keyframe>(Arrays.asList(kfs));
|
||||||
|
|
||||||
for(MarkerKeyframe mk : markers) {
|
Collections.addAll(keyframes, markers);
|
||||||
keyframes.add(mk);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(selectedKeyframe instanceof MarkerKeyframe)) selectedKeyframe = null;
|
if(!(selectedKeyframe instanceof MarkerKeyframe)) selectedKeyframe = null;
|
||||||
|
|
||||||
@@ -460,9 +456,7 @@ public class ReplayHandler {
|
|||||||
keyframes = new ArrayList<Keyframe>();
|
keyframes = new ArrayList<Keyframe>();
|
||||||
|
|
||||||
if(!resetMarkers) {
|
if(!resetMarkers) {
|
||||||
for(MarkerKeyframe mk : markers) {
|
Collections.addAll(keyframes, markers);
|
||||||
keyframes.add(mk);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!(selectedKeyframe instanceof MarkerKeyframe))
|
if(!(selectedKeyframe instanceof MarkerKeyframe))
|
||||||
selectKeyframe(null);
|
selectKeyframe(null);
|
||||||
@@ -540,7 +534,9 @@ public class ReplayHandler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
ReplayMod.overlay.resetUI(true);
|
ReplayMod.overlay.resetUI(true);
|
||||||
} catch(Exception e) {} // TODO proper handling
|
} catch(Exception e) {
|
||||||
|
// TODO: Fix exceptionsudo
|
||||||
|
}
|
||||||
|
|
||||||
//Load lighting and trigger update
|
//Load lighting and trigger update
|
||||||
ReplayMod.replaySettings.setLightingEnabled(ReplayMod.replaySettings.isLightingEnabled());
|
ReplayMod.replaySettings.setLightingEnabled(ReplayMod.replaySettings.isLightingEnabled());
|
||||||
@@ -594,7 +590,7 @@ public class ReplayHandler {
|
|||||||
currentReplayFile.close();
|
currentReplayFile.close();
|
||||||
|
|
||||||
File markerFile = File.createTempFile(ReplayFile.ENTRY_MARKERS, "json");
|
File markerFile = File.createTempFile(ReplayFile.ENTRY_MARKERS, "json");
|
||||||
ReplayFileIO.writeMarkersToFile(getMarkers(), markerFile);
|
ReplayFileIO.write(getMarkers(), markerFile);
|
||||||
ReplayMod.replayFileAppender.registerModifiedFile(markerFile, ReplayFile.ENTRY_MARKERS, ReplayHandler.getReplayFile());
|
ReplayMod.replayFileAppender.registerModifiedFile(markerFile, ReplayFile.ENTRY_MARKERS, ReplayHandler.getReplayFile());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -673,18 +669,6 @@ public class ReplayHandler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PositionKeyframe getLastPositionKeyframe() {
|
|
||||||
ArrayList<Keyframe> rev = new ArrayList<Keyframe>(getKeyframes());
|
|
||||||
Collections.reverse(rev);
|
|
||||||
|
|
||||||
for(Keyframe k : rev) {
|
|
||||||
if(k instanceof PositionKeyframe) {
|
|
||||||
return (PositionKeyframe)k;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void syncTimeCursor(boolean shiftMode) {
|
public static void syncTimeCursor(boolean shiftMode) {
|
||||||
selectKeyframe(null);
|
selectKeyframe(null);
|
||||||
|
|
||||||
|
|||||||
@@ -21,21 +21,15 @@ public class ReplayProcess {
|
|||||||
|
|
||||||
private static Minecraft mc = Minecraft.getMinecraft();
|
private static Minecraft mc = Minecraft.getMinecraft();
|
||||||
|
|
||||||
private static long startRealTime;
|
|
||||||
private static int lastRealReplayTime;
|
private static int lastRealReplayTime;
|
||||||
private static long lastRealTime = 0;
|
private static long lastRealTime = 0;
|
||||||
|
|
||||||
private static boolean linear = false;
|
private static boolean linear = false;
|
||||||
|
|
||||||
private static Position lastPosition = null;
|
|
||||||
private static int lastTimestamp = -1;
|
|
||||||
|
|
||||||
private static SplinePoint motionSpline = null;
|
private static SplinePoint motionSpline = null;
|
||||||
private static LinearPoint motionLinear = null;
|
private static LinearPoint motionLinear = null;
|
||||||
private static LinearTimestamp timeLinear = null;
|
private static LinearTimestamp timeLinear = null;
|
||||||
|
|
||||||
private static double lastSpeed = 1f;
|
|
||||||
|
|
||||||
private static double previousReplaySpeed = 0;
|
private static double previousReplaySpeed = 0;
|
||||||
|
|
||||||
private static boolean calculated = false;
|
private static boolean calculated = false;
|
||||||
@@ -44,9 +38,6 @@ public class ReplayProcess {
|
|||||||
private static boolean blocked = false;
|
private static boolean blocked = false;
|
||||||
private static boolean deepBlock = false;
|
private static boolean deepBlock = false;
|
||||||
private static boolean requestFinish = false;
|
private static boolean requestFinish = false;
|
||||||
private static float lastPartialTicks, lastRenderPartialTicks;
|
|
||||||
private static int lastTicks;
|
|
||||||
private static boolean resetTimer = false;
|
|
||||||
private static boolean firstTime = false;
|
private static boolean firstTime = false;
|
||||||
|
|
||||||
public static boolean isVideoRecording() {
|
public static boolean isVideoRecording() {
|
||||||
@@ -56,7 +47,6 @@ public class ReplayProcess {
|
|||||||
private static void resetProcess() {
|
private static void resetProcess() {
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
|
|
||||||
lastPosition = null;
|
|
||||||
motionSpline = null;
|
motionSpline = null;
|
||||||
motionLinear = null;
|
motionLinear = null;
|
||||||
timeLinear = null;
|
timeLinear = null;
|
||||||
@@ -65,11 +55,8 @@ public class ReplayProcess {
|
|||||||
|
|
||||||
blocked = deepBlock = false;
|
blocked = deepBlock = false;
|
||||||
|
|
||||||
startRealTime = System.currentTimeMillis();
|
lastRealTime = System.currentTimeMillis();
|
||||||
lastRealTime = startRealTime;
|
|
||||||
lastRealReplayTime = 0;
|
lastRealReplayTime = 0;
|
||||||
lastTimestamp = -1;
|
|
||||||
lastSpeed = 1f;
|
|
||||||
linear = ReplayMod.replaySettings.isLinearMovement();
|
linear = ReplayMod.replaySettings.isLinearMovement();
|
||||||
|
|
||||||
previousReplaySpeed = ReplayMod.replaySender.getReplaySpeed();
|
previousReplaySpeed = ReplayMod.replaySender.getReplaySpeed();
|
||||||
@@ -162,9 +149,6 @@ public class ReplayProcess {
|
|||||||
|
|
||||||
if(firstTime) {
|
if(firstTime) {
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
lastPartialTicks = 100;
|
|
||||||
lastRenderPartialTicks = 100;
|
|
||||||
lastTicks = 100;
|
|
||||||
mc.timer.renderPartialTicks = 100;
|
mc.timer.renderPartialTicks = 100;
|
||||||
mc.timer.elapsedPartialTicks = 100;
|
mc.timer.elapsedPartialTicks = 100;
|
||||||
mc.timer.elapsedTicks = 100;
|
mc.timer.elapsedTicks = 100;
|
||||||
@@ -278,9 +262,7 @@ public class ReplayProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!(nextTime == null || lastTime == null)) {
|
if(!(nextTime == null || lastTime == null)) {
|
||||||
if(lastTimeStamp == nextTimeStamp) curSpeed = 0f;
|
curSpeed = ((double) ((nextTime.getTimestamp() - lastTime.getTimestamp()))) / ((double) ((nextTimeStamp - lastTimeStamp)));
|
||||||
else
|
|
||||||
curSpeed = ((double) ((nextTime.getTimestamp() - lastTime.getTimestamp()))) / ((double) ((nextTimeStamp - lastTimeStamp)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lastTimeStamp == nextTimeStamp) {
|
if(lastTimeStamp == nextTimeStamp) {
|
||||||
@@ -315,7 +297,9 @@ public class ReplayProcess {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(posCount == 1) {
|
if(posCount == 1) {
|
||||||
pos = ReplayHandler.getFirstPositionKeyframe().getPosition();
|
PositionKeyframe keyframe = ReplayHandler.getFirstPositionKeyframe();
|
||||||
|
assert keyframe != null;
|
||||||
|
pos = keyframe.getPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,11 +318,6 @@ public class ReplayProcess {
|
|||||||
|
|
||||||
if(!isVideoRecording()) ReplayMod.replaySender.setReplaySpeed(curSpeed);
|
if(!isVideoRecording()) ReplayMod.replaySender.setReplaySpeed(curSpeed);
|
||||||
//if(curSpeed > 0)
|
//if(curSpeed > 0)
|
||||||
lastSpeed = curSpeed;
|
|
||||||
|
|
||||||
lastPartialTicks = mc.timer.elapsedPartialTicks;
|
|
||||||
lastRenderPartialTicks = mc.timer.renderPartialTicks;
|
|
||||||
lastTicks = mc.timer.elapsedTicks;
|
|
||||||
|
|
||||||
if(curTimestamp != null)
|
if(curTimestamp != null)
|
||||||
ReplayMod.replaySender.sendPacketsTill(curTimestamp);
|
ReplayMod.replaySender.sendPacketsTill(curTimestamp);
|
||||||
|
|||||||
@@ -291,10 +291,6 @@ public class ReplaySender extends ChannelInboundHandlerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(p instanceof S03PacketTimeUpdate) {
|
|
||||||
p = TimeHandler.getTimePacket((S03PacketTimeUpdate) p);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p instanceof S48PacketResourcePackSend) {
|
if(p instanceof S48PacketResourcePackSend) {
|
||||||
S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
S48PacketResourcePackSend packet = (S48PacketResourcePackSend) p;
|
||||||
String url = packet.func_179783_a();
|
String url = packet.func_179783_a();
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
package eu.crushedpixel.replaymod.replay;
|
|
||||||
|
|
||||||
import net.minecraft.network.play.server.S03PacketTimeUpdate;
|
|
||||||
|
|
||||||
public class TimeHandler {
|
|
||||||
|
|
||||||
private static long actualDaytime;
|
|
||||||
private static long desiredDaytime;
|
|
||||||
|
|
||||||
private static boolean timeOverridden = false;
|
|
||||||
|
|
||||||
public static boolean isTimeOverridden() {
|
|
||||||
return timeOverridden;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setTimeOverridden(boolean overridden) {
|
|
||||||
timeOverridden = overridden;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setDesiredDaytime(long ddt) {
|
|
||||||
desiredDaytime = ddt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static S03PacketTimeUpdate getTimePacket(S03PacketTimeUpdate packet) {
|
|
||||||
if(!timeOverridden) return packet;
|
|
||||||
return new S03PacketTimeUpdate(packet.func_149366_c(), desiredDaytime, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package eu.crushedpixel.replaymod.settings;
|
package eu.crushedpixel.replaymod.settings;
|
||||||
|
|
||||||
import eu.crushedpixel.replaymod.video.frame.FrameRenderer;
|
import eu.crushedpixel.replaymod.video.frame.FrameRenderer;
|
||||||
|
import lombok.Data;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.Validate.*;
|
import static org.apache.commons.lang3.Validate.*;
|
||||||
|
|
||||||
|
@Data
|
||||||
public final class RenderOptions {
|
public final class RenderOptions {
|
||||||
private FrameRenderer renderer;
|
private FrameRenderer renderer;
|
||||||
private String bitrate = "10M";
|
private String bitrate = "10M";
|
||||||
@@ -24,22 +26,10 @@ public final class RenderOptions {
|
|||||||
"-c:v libvpx -b:v %BITRATE% %FILENAME%.webm";
|
"-c:v libvpx -b:v %BITRATE% %FILENAME%.webm";
|
||||||
private int writerQueueSize = Integer.parseInt(System.getProperty("replaymod.render.writerQueueSize", "1"));
|
private int writerQueueSize = Integer.parseInt(System.getProperty("replaymod.render.writerQueueSize", "1"));
|
||||||
|
|
||||||
public FrameRenderer getRenderer() {
|
|
||||||
return renderer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRenderer(FrameRenderer renderer) {
|
public void setRenderer(FrameRenderer renderer) {
|
||||||
this.renderer = notNull(renderer);
|
this.renderer = notNull(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBitrate() {
|
|
||||||
return bitrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBitrate(String bitrate) {
|
|
||||||
this.bitrate = bitrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFps() {
|
public int getFps() {
|
||||||
return fps;
|
return fps;
|
||||||
}
|
}
|
||||||
@@ -49,74 +39,10 @@ public final class RenderOptions {
|
|||||||
this.fps = fps;
|
this.fps = fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWaitForChunks() {
|
|
||||||
return waitForChunks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWaitForChunks(boolean waitForChunks) {
|
|
||||||
this.waitForChunks = waitForChunks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isLinearMovement() {
|
|
||||||
return isLinearMovement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLinearMovement(boolean isLinearMovement) {
|
|
||||||
this.isLinearMovement = isLinearMovement;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDefaultSky() {
|
public boolean isDefaultSky() {
|
||||||
return skyColor == -1;
|
return skyColor == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkyColor() {
|
|
||||||
return skyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSkyColor(int skyColor) {
|
|
||||||
this.skyColor = skyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWidth() {
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWidth(int width) {
|
|
||||||
this.width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHeight() {
|
|
||||||
return height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeight(int height) {
|
|
||||||
this.height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExportCommand() {
|
|
||||||
return exportCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExportCommand(String exportCommand) {
|
|
||||||
this.exportCommand = exportCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExportCommandArgs() {
|
|
||||||
return exportCommandArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExportCommandArgs(String exportCommandArgs) {
|
|
||||||
this.exportCommandArgs = exportCommandArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWriterQueueSize() {
|
|
||||||
return writerQueueSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWriterQueueSize(int writerQueueSize) {
|
|
||||||
this.writerQueueSize = writerQueueSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderOptions copy() {
|
public RenderOptions copy() {
|
||||||
RenderOptions copy = new RenderOptions();
|
RenderOptions copy = new RenderOptions();
|
||||||
copy.renderer = this.renderer;
|
copy.renderer = this.renderer;
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ public class SoundHandler {
|
|||||||
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod:renderSuccess");
|
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod:renderSuccess");
|
||||||
|
|
||||||
public void playRenderSuccessSound() {
|
public void playRenderSuccessSound() {
|
||||||
mc.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(successSoundLocation, 1.0F));
|
mc.getSoundHandler().playSound(PositionedSoundRecord.create(successSoundLocation, 1.0F));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,7 @@ public class VersionValidator {
|
|||||||
String version = Runtime.class.getPackage().getSpecificationVersion();
|
String version = Runtime.class.getPackage().getSpecificationVersion();
|
||||||
if(version != null) {
|
if(version != null) {
|
||||||
String[] split = version.split("\\.");
|
String[] split = version.split("\\.");
|
||||||
if(split.length > 1) {
|
isValid = split.length > 1 && Integer.valueOf(split[1]) >= 7;
|
||||||
isValid = Integer.valueOf(split[1]) >= 7;
|
|
||||||
} else {
|
|
||||||
isValid = false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class EnchantmentTimer {
|
|||||||
recordingTime += amount;
|
recordingTime += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused") // Called by ASM
|
||||||
public static long getEnchantmentTime() {
|
public static long getEnchantmentTime() {
|
||||||
if(!(ReplayHandler.isInPath() && ReplayProcess.isVideoRecording())) {
|
if(!(ReplayHandler.isInPath() && ReplayProcess.isVideoRecording())) {
|
||||||
if(ReplayHandler.isInReplay()) {
|
if(ReplayHandler.isInReplay()) {
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ public class EmailAddressUtils {
|
|||||||
public static boolean isValidEmailAddress(String mail) {
|
public static boolean isValidEmailAddress(String mail) {
|
||||||
try {
|
try {
|
||||||
String[] spl1 = mail.split("@");
|
String[] spl1 = mail.split("@");
|
||||||
String[] spl2 = spl1[1].split("\\.");
|
|
||||||
String suffix = spl2[1];
|
|
||||||
|
|
||||||
return spl1[0].equals(URLEncoder.encode(spl1[0], "UTF-8")) && spl1[1].equals(URLEncoder.encode(spl1[1], "UTF-8"));
|
return spl1[0].equals(URLEncoder.encode(spl1[0], "UTF-8")) && spl1[1].equals(URLEncoder.encode(spl1[1], "UTF-8"));
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user