Refactored and reformatted code to use less static variables
This commit is contained in:
@@ -12,6 +12,9 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class FileCopyHandler extends Thread {
|
||||
|
||||
private Queue<Pair<File, File>> filesToMove = new ConcurrentLinkedQueue<Pair<File, File>>();
|
||||
private boolean shutdown = false;
|
||||
|
||||
public FileCopyHandler() {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
@Override
|
||||
@@ -21,8 +24,6 @@ public class FileCopyHandler extends Thread {
|
||||
}));
|
||||
}
|
||||
|
||||
private Queue<Pair<File, File>> filesToMove = new ConcurrentLinkedQueue<Pair<File, File>>();
|
||||
|
||||
public void registerModifiedFile(File tempFile, File destination) {
|
||||
filesToMove.add(Pair.of(tempFile, destination));
|
||||
|
||||
@@ -37,8 +38,6 @@ public class FileCopyHandler extends Thread {
|
||||
shutdown = true;
|
||||
}
|
||||
|
||||
private boolean shutdown = false;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(!shutdown || !filesToMove.isEmpty()) {
|
||||
@@ -52,7 +51,8 @@ public class FileCopyHandler extends Thread {
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch(Exception e) {}
|
||||
} catch(Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,27 @@
|
||||
package eu.crushedpixel.replaymod.registry;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class KeybindRegistry {
|
||||
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static final String KEY_LIGHTING = "Toggle Lighting";
|
||||
public static final String KEY_THUMBNAIL = "Create Thumbnail";
|
||||
public static final String KEY_SPECTATE = "Spectate Entity";
|
||||
|
||||
public static void initialize() {
|
||||
List<KeyBinding> bindings = new ArrayList<KeyBinding>(Arrays.asList(mc.gameSettings.keyBindings));
|
||||
|
||||
bindings.add(new KeyBinding(KEY_LIGHTING, Keyboard.KEY_V, "Replay Mod"));
|
||||
bindings.add(new KeyBinding(KEY_THUMBNAIL, Keyboard.KEY_B, "Replay Mod"));
|
||||
bindings.add(new KeyBinding(KEY_SPECTATE, Keyboard.KEY_C, "Replay Mod"));
|
||||
|
||||
mc.gameSettings.keyBindings = bindings.toArray(new KeyBinding[bindings.size()]);
|
||||
}
|
||||
public static final String KEY_LIGHTING = "Toggle Lighting";
|
||||
public static final String KEY_THUMBNAIL = "Create Thumbnail";
|
||||
public static final String KEY_SPECTATE = "Spectate Entity";
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static void initialize() {
|
||||
List<KeyBinding> bindings = new ArrayList<KeyBinding>(Arrays.asList(mc.gameSettings.keyBindings));
|
||||
|
||||
bindings.add(new KeyBinding(KEY_LIGHTING, Keyboard.KEY_V, "Replay Mod"));
|
||||
bindings.add(new KeyBinding(KEY_THUMBNAIL, Keyboard.KEY_B, "Replay Mod"));
|
||||
bindings.add(new KeyBinding(KEY_SPECTATE, Keyboard.KEY_C, "Replay Mod"));
|
||||
|
||||
mc.gameSettings.keyBindings = bindings.toArray(new KeyBinding[bindings.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,38 @@
|
||||
package eu.crushedpixel.replaymod.registry;
|
||||
|
||||
import eu.crushedpixel.replaymod.ReplayMod;
|
||||
import eu.crushedpixel.replaymod.timer.MCTimerHandler;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.GameSettings.Options;
|
||||
import net.minecraft.util.Timer;
|
||||
import eu.crushedpixel.replaymod.replay.ReplayHandler;
|
||||
import eu.crushedpixel.replaymod.timer.MCTimerHandler;
|
||||
|
||||
public class LightingHandler {
|
||||
|
||||
private static float initialGamma = 0;
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
public static void setInitialGamma(float gamma) {
|
||||
initialGamma = gamma;
|
||||
}
|
||||
|
||||
public static void setLighting(boolean lighting) {
|
||||
if(lighting) {
|
||||
if(!enabled) {
|
||||
initialGamma = Minecraft.getMinecraft().gameSettings.getOptionFloatValue(Options.GAMMA);
|
||||
}
|
||||
Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, 1000);
|
||||
}
|
||||
else Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, initialGamma);
|
||||
|
||||
enabled = lighting;
|
||||
|
||||
try {
|
||||
if(ReplayHandler.isPaused()) {
|
||||
MCTimerHandler.advancePartialTicks(1);
|
||||
MCTimerHandler.advanceRenderPartialTicks(1);
|
||||
} else {
|
||||
Minecraft.getMinecraft().entityRenderer.updateCameraAndRender(0);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static float initialGamma = 0;
|
||||
|
||||
private static boolean enabled = false;
|
||||
|
||||
//TODO: Properly reset Gamma on game start
|
||||
//TODO: Properly handle manual gamma changes while in Replay
|
||||
public static void setLighting(boolean lighting) {
|
||||
if(lighting) {
|
||||
if(!enabled) {
|
||||
initialGamma = Minecraft.getMinecraft().gameSettings.getOptionFloatValue(Options.GAMMA);
|
||||
}
|
||||
Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, 1000);
|
||||
} else Minecraft.getMinecraft().gameSettings.setOptionFloatValue(Options.GAMMA, initialGamma);
|
||||
|
||||
enabled = lighting;
|
||||
|
||||
try {
|
||||
if(ReplayMod.replaySender.paused()) {
|
||||
MCTimerHandler.advancePartialTicks(1);
|
||||
MCTimerHandler.advanceRenderPartialTicks(1);
|
||||
} else {
|
||||
Minecraft.getMinecraft().entityRenderer.updateCameraAndRender(0);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,83 +1,49 @@
|
||||
package eu.crushedpixel.replaymod.registry;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.network.play.server.S0CPacketSpawnPlayer;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import eu.crushedpixel.replaymod.reflection.MCPNames;
|
||||
|
||||
public class ReplayGuiRegistry {
|
||||
|
||||
//private static Field renderHand;
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static boolean hidden = false;
|
||||
|
||||
/*
|
||||
static {
|
||||
try {
|
||||
//renderHand = EntityRenderer.class.getDeclaredField(MCPNames.field("field_175074_C"));
|
||||
//renderHand.setAccessible(true);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static void hide() {
|
||||
if(hidden) return;
|
||||
GuiIngameForge.renderExperiance = false;
|
||||
GuiIngameForge.renderArmor = false;
|
||||
GuiIngameForge.renderAir = false;
|
||||
GuiIngameForge.renderHealth = false;
|
||||
GuiIngameForge.renderHotbar = false;
|
||||
GuiIngameForge.renderFood = false;
|
||||
GuiIngameForge.renderBossHealth = false;
|
||||
GuiIngameForge.renderCrosshairs = false;
|
||||
GuiIngameForge.renderHelmet = false;
|
||||
GuiIngameForge.renderPortal = false;
|
||||
GuiIngameForge.renderHealthMount = false;
|
||||
GuiIngameForge.renderJumpBar = false;
|
||||
GuiIngameForge.renderObjective = false;
|
||||
|
||||
/*
|
||||
try {
|
||||
renderHand.set(mc.entityRenderer, false);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
hidden = true;
|
||||
}
|
||||
|
||||
public static void show() {
|
||||
mc.gameSettings.hideGUI = false;
|
||||
|
||||
GuiIngameForge.renderExperiance = true;
|
||||
GuiIngameForge.renderArmor = true;
|
||||
GuiIngameForge.renderAir = true;
|
||||
GuiIngameForge.renderHealth = true;
|
||||
GuiIngameForge.renderHotbar = true;
|
||||
GuiIngameForge.renderFood = true;
|
||||
GuiIngameForge.renderBossHealth = true;
|
||||
GuiIngameForge.renderCrosshairs = true;
|
||||
GuiIngameForge.renderHelmet = true;
|
||||
GuiIngameForge.renderPortal = true;
|
||||
GuiIngameForge.renderHealthMount = true;
|
||||
GuiIngameForge.renderJumpBar = true;
|
||||
GuiIngameForge.renderObjective = true;
|
||||
|
||||
/*
|
||||
try {
|
||||
renderHand.set(mc.entityRenderer, true);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
hidden = false;
|
||||
}
|
||||
public static boolean hidden = false;
|
||||
private static Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
public static void hide() {
|
||||
if(hidden) return;
|
||||
GuiIngameForge.renderExperiance = false;
|
||||
GuiIngameForge.renderArmor = false;
|
||||
GuiIngameForge.renderAir = false;
|
||||
GuiIngameForge.renderHealth = false;
|
||||
GuiIngameForge.renderHotbar = false;
|
||||
GuiIngameForge.renderFood = false;
|
||||
GuiIngameForge.renderBossHealth = false;
|
||||
GuiIngameForge.renderCrosshairs = false;
|
||||
GuiIngameForge.renderHelmet = false;
|
||||
GuiIngameForge.renderPortal = false;
|
||||
GuiIngameForge.renderHealthMount = false;
|
||||
GuiIngameForge.renderJumpBar = false;
|
||||
GuiIngameForge.renderObjective = false;
|
||||
|
||||
hidden = true;
|
||||
}
|
||||
|
||||
public static void show() {
|
||||
mc.gameSettings.hideGUI = false;
|
||||
|
||||
GuiIngameForge.renderExperiance = true;
|
||||
GuiIngameForge.renderArmor = true;
|
||||
GuiIngameForge.renderAir = true;
|
||||
GuiIngameForge.renderHealth = true;
|
||||
GuiIngameForge.renderHotbar = true;
|
||||
GuiIngameForge.renderFood = true;
|
||||
GuiIngameForge.renderBossHealth = true;
|
||||
GuiIngameForge.renderCrosshairs = true;
|
||||
GuiIngameForge.renderHelmet = true;
|
||||
GuiIngameForge.renderPortal = true;
|
||||
GuiIngameForge.renderHealthMount = true;
|
||||
GuiIngameForge.renderJumpBar = true;
|
||||
GuiIngameForge.renderObjective = true;
|
||||
|
||||
hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user