Remove lots of old code
Add some additional config settings Update jGui and ReplayStudio
This commit is contained in:
68
src/main/java/com/replaymod/core/LoadingPlugin.java
Executable file
68
src/main/java/com/replaymod/core/LoadingPlugin.java
Executable file
@@ -0,0 +1,68 @@
|
||||
package com.replaymod.core;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.CoreModManager;
|
||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
import org.spongepowered.asm.mixin.MixinEnvironment;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Map;
|
||||
|
||||
public class LoadingPlugin implements IFMLLoadingPlugin {
|
||||
|
||||
public LoadingPlugin() {
|
||||
MixinBootstrap.init();
|
||||
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.replaymod.json");
|
||||
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.recording.replaymod.json");
|
||||
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.render.replaymod.json");
|
||||
MixinEnvironment.getDefaultEnvironment().addConfiguration("mixins.replay.replaymod.json");
|
||||
|
||||
CodeSource codeSource = getClass().getProtectionDomain().getCodeSource();
|
||||
if (codeSource != null) {
|
||||
URL location = codeSource.getLocation();
|
||||
try {
|
||||
File file = new File(location.toURI());
|
||||
if (file.isFile()) {
|
||||
// This forces forge to reexamine the jar file for FML mods
|
||||
// Should eventually be handled by Mixin itself, maybe?
|
||||
CoreModManager.getLoadedCoremods().remove(file.getName());
|
||||
}
|
||||
} catch (URISyntaxException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
LogManager.getLogger().warn("No CodeSource, if this is not a development environment we might run into problems!");
|
||||
LogManager.getLogger().warn(getClass().getProtectionDomain());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
return new String[]{
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModContainerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSetupClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessTransformerClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,20 +4,10 @@ import com.google.common.io.Files;
|
||||
import com.google.common.util.concurrent.ListenableFutureTask;
|
||||
import com.replaymod.core.gui.RestoreReplayGui;
|
||||
import com.replaymod.core.handler.MainMenuHandler;
|
||||
import com.replaymod.replay.ReplaySender;
|
||||
import com.replaymod.replaystudio.util.I18n;
|
||||
import de.johni0702.minecraft.gui.container.GuiScreen;
|
||||
import eu.crushedpixel.replaymod.chat.ChatMessageHandler;
|
||||
import eu.crushedpixel.replaymod.events.handlers.MouseInputHandler;
|
||||
import eu.crushedpixel.replaymod.events.handlers.TickAndRenderListener;
|
||||
import eu.crushedpixel.replaymod.events.handlers.keyboard.KeyInputHandler;
|
||||
import eu.crushedpixel.replaymod.registry.KeybindRegistry;
|
||||
import eu.crushedpixel.replaymod.registry.ReplayFileAppender;
|
||||
import eu.crushedpixel.replaymod.registry.UploadedFileHandler;
|
||||
import eu.crushedpixel.replaymod.renderer.CustomObjectRenderer;
|
||||
import eu.crushedpixel.replaymod.settings.ReplaySettings;
|
||||
import eu.crushedpixel.replaymod.sound.SoundHandler;
|
||||
import eu.crushedpixel.replaymod.utils.OpenGLUtils;
|
||||
import com.replaymod.render.utils.SoundHandler;
|
||||
import com.replaymod.core.utils.OpenGLUtils;
|
||||
import eu.crushedpixel.replaymod.utils.TooltipRenderer;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -25,7 +15,6 @@ import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.util.*;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -74,31 +63,11 @@ public class ReplayMod {
|
||||
|
||||
private static final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
@Deprecated
|
||||
public static ReplaySettings replaySettings;
|
||||
@Deprecated
|
||||
public static Configuration config;
|
||||
@Deprecated
|
||||
public static boolean firstMainMenu = true;
|
||||
@Deprecated
|
||||
public static ChatMessageHandler chatMessageHandler = new ChatMessageHandler();
|
||||
@Deprecated
|
||||
public static KeyInputHandler keyInputHandler = new KeyInputHandler();
|
||||
@Deprecated
|
||||
public static MouseInputHandler mouseInputHandler = new MouseInputHandler();
|
||||
@Deprecated
|
||||
public static ReplaySender replaySender;
|
||||
@Deprecated
|
||||
public static int TP_DISTANCE_LIMIT = 128;
|
||||
@Deprecated
|
||||
public static ReplayFileAppender replayFileAppender;
|
||||
@Deprecated
|
||||
public static UploadedFileHandler uploadedFileHandler;
|
||||
@Deprecated
|
||||
public static TooltipRenderer tooltipRenderer;
|
||||
@Deprecated
|
||||
public static CustomObjectRenderer customObjectRenderer;
|
||||
@Deprecated
|
||||
public static SoundHandler soundHandler = new SoundHandler();
|
||||
|
||||
private final KeyBindingRegistry keyBindingRegistry = new KeyBindingRegistry();
|
||||
@@ -117,7 +86,7 @@ public class ReplayMod {
|
||||
}
|
||||
|
||||
public File getReplayFolder() throws IOException {
|
||||
File folder = new File(replaySettings.getRecordingPath());
|
||||
File folder = new File(getSettingsRegistry().get(Setting.RECORDING_PATH));
|
||||
FileUtils.forceMkdir(folder);
|
||||
return folder;
|
||||
}
|
||||
@@ -133,23 +102,15 @@ public class ReplayMod {
|
||||
config = new Configuration(event.getSuggestedConfigurationFile());
|
||||
config.load();
|
||||
settingsRegistry.setConfiguration(config);
|
||||
|
||||
uploadedFileHandler = new UploadedFileHandler(event.getModConfigurationDirectory());
|
||||
|
||||
replaySettings = new ReplaySettings();
|
||||
|
||||
replayFileAppender = new ReplayFileAppender();
|
||||
FMLCommonHandler.instance().bus().register(replayFileAppender);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
getSettingsRegistry().register(Setting.class);
|
||||
|
||||
new MainMenuHandler().register();
|
||||
|
||||
FMLCommonHandler.instance().bus().register(keyInputHandler);
|
||||
FMLCommonHandler.instance().bus().register(keyBindingRegistry);
|
||||
FMLCommonHandler.instance().bus().register(mouseInputHandler);
|
||||
MinecraftForge.EVENT_BUS.register(mouseInputHandler);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -159,16 +120,6 @@ public class ReplayMod {
|
||||
if(!FMLClientHandler.instance().hasOptifine())
|
||||
GameSettings.Options.RENDER_DISTANCE.setValueMax(64f);
|
||||
|
||||
TickAndRenderListener tarl = new TickAndRenderListener();
|
||||
FMLCommonHandler.instance().bus().register(tarl);
|
||||
MinecraftForge.EVENT_BUS.register(tarl);
|
||||
|
||||
customObjectRenderer = new CustomObjectRenderer();
|
||||
FMLCommonHandler.instance().bus().register(customObjectRenderer);
|
||||
MinecraftForge.EVENT_BUS.register(customObjectRenderer);
|
||||
|
||||
KeybindRegistry.initialize();
|
||||
|
||||
tooltipRenderer = new TooltipRenderer();
|
||||
|
||||
if (System.getProperty("replaymod.render.file") != null) {
|
||||
@@ -360,7 +311,7 @@ public class ReplayMod {
|
||||
}
|
||||
|
||||
private void printToChat(boolean warning, String message, Object... args) {
|
||||
if (ReplayMod.replaySettings.isShowNotifications()) {
|
||||
if (getSettingsRegistry().get(Setting.NOTIFICATIONS)) {
|
||||
// Some nostalgia: "§8[§6Replay Mod§8]§r Your message goes here"
|
||||
ChatStyle coloredDarkGray = new ChatStyle().setColor(EnumChatFormatting.DARK_GRAY);
|
||||
ChatStyle coloredGold = new ChatStyle().setColor(EnumChatFormatting.GOLD);
|
||||
|
||||
18
src/main/java/com/replaymod/core/Setting.java
Normal file
18
src/main/java/com/replaymod/core/Setting.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package com.replaymod.core;
|
||||
|
||||
public final class Setting<T> extends SettingsRegistry.SettingKeys<T> {
|
||||
public static final Setting<Boolean> NOTIFICATIONS = make("notifications", "notifications", true);
|
||||
public static final Setting<String> RECORDING_PATH = advanced("recordingPath", null, "./replay_recordings/");
|
||||
|
||||
private static <T> Setting<T> make(String key, String displayName, T defaultValue) {
|
||||
return new Setting<>("core", key, displayName, defaultValue);
|
||||
}
|
||||
|
||||
private static <T> Setting<T> advanced(String key, String displayName, T defaultValue) {
|
||||
return new Setting<>("advanced", key, displayName, defaultValue);
|
||||
}
|
||||
|
||||
public Setting(String category, String key, String displayString, T defaultValue) {
|
||||
super(category, key, displayString == null ? null : "replaymod.gui.settings." + displayString, defaultValue);
|
||||
}
|
||||
}
|
||||
49
src/main/java/com/replaymod/core/utils/OpenGLUtils.java
Normal file
49
src/main/java/com/replaymod/core/utils/OpenGLUtils.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class OpenGLUtils {
|
||||
public static final int VIEWPORT_MAX_WIDTH;
|
||||
public static final int VIEWPORT_MAX_HEIGHT;
|
||||
|
||||
static {
|
||||
IntBuffer buffer = BufferUtils.createIntBuffer(16);
|
||||
GL11.glGetInteger(GL11.GL_MAX_VIEWPORT_DIMS, buffer);
|
||||
VIEWPORT_MAX_WIDTH = buffer.get();
|
||||
VIEWPORT_MAX_HEIGHT = buffer.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic init method which has to be called from the OpenGL thread so the variables in this class
|
||||
* can be initialized successfully.
|
||||
* Does not perform any work on its own.
|
||||
*/
|
||||
public static void init() {
|
||||
}
|
||||
|
||||
public static void drawRotatedRectWithCustomSizedTexture(int x, int y, float rotation, float u, float v, int width, int height, float textureWidth, float textureHeight) {
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
float f4 = 1.0F / textureWidth;
|
||||
float f5 = 1.0F / textureHeight;
|
||||
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||
GlStateManager.translate(x+(width/2), y+(width/2), 0);
|
||||
GlStateManager.rotate(rotation, 0, 0, 1);
|
||||
worldrenderer.startDrawingQuads();
|
||||
worldrenderer.addVertexWithUV(-width / 2, height / 2, 0.0D, (double) (u * f4), (double) ((v + (float) height) * f5));
|
||||
worldrenderer.addVertexWithUV(width/2, height/2, 0.0D, (double)((u + (float)width) * f4), (double)((v + (float)height) * f5));
|
||||
worldrenderer.addVertexWithUV(width/2, -height/2, 0.0D, (double)((u + (float)width) * f4), (double)(v * f5));
|
||||
worldrenderer.addVertexWithUV(-width/2, -height/2, 0.0D, (double)(u * f4), (double)(v * f5));
|
||||
tessellator.draw();
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
9
src/main/java/com/replaymod/core/utils/Patterns.java
Normal file
9
src/main/java/com/replaymod/core/utils/Patterns.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Patterns {
|
||||
public static final Pattern ALPHANUMERIC_UNDERSCORE = Pattern.compile("^[a-z0-9_]*$", Pattern.CASE_INSENSITIVE);
|
||||
public static final Pattern ALPHANUMERIC_COMMA = Pattern.compile("^[a-z0-9,]*$", Pattern.CASE_INSENSITIVE);
|
||||
public static final Pattern ALPHANUMERIC_SPACE_HYPHEN_UNDERSCORE = Pattern.compile("^[a-z0-9 \\-_]*$", Pattern.CASE_INSENSITIVE);
|
||||
}
|
||||
74
src/main/java/com/replaymod/core/utils/Utils.java
Normal file
74
src/main/java/com/replaymod/core/utils/Utils.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package com.replaymod.core.utils;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.util.Dimension;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Utils {
|
||||
|
||||
public static final BufferedImage DEFAULT_THUMBNAIL;
|
||||
|
||||
static {
|
||||
BufferedImage thumbnail;
|
||||
try {
|
||||
thumbnail = ImageIO.read(Utils.class.getClassLoader().getResourceAsStream("default_thumb.jpg"));
|
||||
} catch (Exception e) {
|
||||
thumbnail = new BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR);
|
||||
e.printStackTrace();
|
||||
}
|
||||
DEFAULT_THUMBNAIL = thumbnail;
|
||||
}
|
||||
|
||||
public static String convertSecondsToShortString(int seconds) {
|
||||
int hours = seconds/(60*60);
|
||||
int min = seconds/60 - hours*60;
|
||||
int sec = seconds - ((min*60) + (hours*60*60));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if(hours > 0) builder.append(String.format("%02d", hours)).append(":");
|
||||
builder.append(String.format("%02d", min)).append(":");
|
||||
builder.append(String.format("%02d", sec));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static Dimension fitIntoBounds(ReadableDimension toFit, ReadableDimension bounds) {
|
||||
int width = toFit.getWidth();
|
||||
int height = toFit.getHeight();
|
||||
|
||||
float w = (float) width / bounds.getWidth();
|
||||
float h = (float) height / bounds.getHeight();
|
||||
|
||||
if (w > h) {
|
||||
height = (int) (height / w);
|
||||
width = (int) (width / w);
|
||||
} else {
|
||||
height = (int) (height / h);
|
||||
width = (int) (width / h);
|
||||
}
|
||||
|
||||
return new Dimension(width, height);
|
||||
}
|
||||
|
||||
public static boolean isValidEmailAddress(String mail) {
|
||||
return mail.matches("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$");
|
||||
}
|
||||
|
||||
public static ResourceLocation getResourceLocationForPlayerUUID(UUID uuid) {
|
||||
NetworkPlayerInfo info = Minecraft.getMinecraft().getNetHandler().getPlayerInfo(uuid);
|
||||
ResourceLocation skinLocation;
|
||||
if (info != null && info.hasLocationSkin()) {
|
||||
skinLocation = info.getLocationSkin();
|
||||
} else {
|
||||
skinLocation = DefaultPlayerSkin.getDefaultSkin(uuid);
|
||||
}
|
||||
return skinLocation;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user