Renamed "Camera Tilt" to "Camera Roll" (new naming convention!)

Changed Camera Roll to use Degree Values
Started adding Timeline Position Editing to GuiEditKeyframe
This commit is contained in:
CrushedPixel
2015-05-22 17:06:36 +02:00
parent 9396687802
commit cbbc50a37a
15 changed files with 166 additions and 49 deletions

View File

@@ -9,7 +9,7 @@ import java.util.ListIterator;
import static org.objectweb.asm.Opcodes.*; import static org.objectweb.asm.Opcodes.*;
public class CameraTiltingCT implements IClassTransformer { public class CameraRollCT implements IClassTransformer {
private static final String REPLAY_HANDLER = "eu/crushedpixel/replaymod/replay/ReplayHandler"; private static final String REPLAY_HANDLER = "eu/crushedpixel/replaymod/replay/ReplayHandler";
private static final String CLASS_NAME = "net.minecraft.client.renderer.EntityRenderer"; private static final String CLASS_NAME = "net.minecraft.client.renderer.EntityRenderer";
@@ -47,7 +47,7 @@ public class CameraTiltingCT implements IClassTransformer {
* public void orientCamera(float f) { * public void orientCamera(float f) {
* ... * ...
* if (ReplayHandler.isInReplay()) { * if (ReplayHandler.isInReplay()) {
* GL11.glRotated(Math.toRadians(ReplayHandler.getCameraTilt()), 0, 0, 1); * GL11.glRotated(ReplayHandler.getCameraTilt(), 0, 0, 1);
* } * }
* ... * ...
* } * }
@@ -58,7 +58,6 @@ public class CameraTiltingCT implements IClassTransformer {
iter.add(new JumpInsnNode(IFEQ, l)); iter.add(new JumpInsnNode(IFEQ, l));
iter.add(new MethodInsnNode(INVOKESTATIC, REPLAY_HANDLER, "getCameraTilt", "()F", false)); iter.add(new MethodInsnNode(INVOKESTATIC, REPLAY_HANDLER, "getCameraTilt", "()F", false));
iter.add(new InsnNode(F2D)); iter.add(new InsnNode(F2D));
iter.add(new MethodInsnNode(INVOKESTATIC, "java/lang/Math", "toRadians", "(D)D", false));
iter.add(new LdcInsnNode(0D)); iter.add(new LdcInsnNode(0D));
iter.add(new LdcInsnNode(0D)); iter.add(new LdcInsnNode(0D));
iter.add(new LdcInsnNode(1D)); iter.add(new LdcInsnNode(1D));

View File

@@ -14,7 +14,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
public class ClassTransformer implements IClassTransformer { public class EnchantmentTimerCT implements IClassTransformer {
@Override @Override
public byte[] transform(String name, String transformedName, public byte[] transform(String name, String transformedName,

View File

@@ -9,8 +9,8 @@ public class LoadingPlugin implements IFMLLoadingPlugin {
@Override @Override
public String[] getASMTransformerClass() { public String[] getASMTransformerClass() {
return new String[]{ return new String[]{
CameraTiltingCT.class.getName(), CameraRollCT.class.getName(),
ClassTransformer.class.getName() EnchantmentTimerCT.class.getName()
}; };
} }

View File

@@ -557,7 +557,7 @@ public class GuiReplayOverlay extends Gui {
if(liftedSinceSelection) { if(liftedSinceSelection) {
ReplayHandler.setRealTimelineCursor(real_pos); ReplayHandler.setRealTimelineCursor(real_pos);
} else if(ReplayHandler.getSelectedKeyframe() != null) { } else if(ReplayHandler.getSelectedKeyframe() != null) {
int tolerance = Math.round(abs_width / (float) width); int tolerance = 2 * Math.round(abs_width / (float) width);
if(Math.abs(selectionTimestamp - real_pos) > tolerance || overcameToleranceSinceSelection) { if(Math.abs(selectionTimestamp - real_pos) > tolerance || overcameToleranceSinceSelection) {
ReplayHandler.setRealTimelineCursor(real_pos); ReplayHandler.setRealTimelineCursor(real_pos);

View File

@@ -108,12 +108,12 @@ public class KeyInputHandler {
ReplayMod.overlay.playOrPause(); ReplayMod.overlay.playOrPause();
} }
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROTATE_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) { if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_CLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 1 : 5); ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? 0.2f : 1);
} }
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROTATE_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) { if(kb.getKeyDescription().equals(KeybindRegistry.KEY_ROLL_COUNTERCLOCKWISE) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !ReplayHandler.isInPath()) {
ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? -1 : -5); ReplayHandler.addCameraTilt(Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL) ? -0.2f : -1);
} }
if(kb.getKeyDescription().equals(KeybindRegistry.KEY_RESET_TILT) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) { if(kb.getKeyDescription().equals(KeybindRegistry.KEY_RESET_TILT) && (kb.isKeyDown() || kb.getKeyCode() == keyCode) && !found && !ReplayHandler.isInPath()) {

View File

@@ -76,6 +76,13 @@ public class GuiConstants {
public static final int KEYFRAME_EDITOR_Z_INPUT = 6006; public static final int KEYFRAME_EDITOR_Z_INPUT = 6006;
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_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_SEC_INPUT = 6014;
public static final int KEYFRAME_EDITOR_REAL_MS_INPUT = 6015;
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 = 0101;

View File

@@ -4,6 +4,8 @@ import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
import eu.crushedpixel.replaymod.holders.Keyframe; import eu.crushedpixel.replaymod.holders.Keyframe;
import eu.crushedpixel.replaymod.holders.Position; import eu.crushedpixel.replaymod.holders.Position;
import eu.crushedpixel.replaymod.holders.PositionKeyframe; import eu.crushedpixel.replaymod.holders.PositionKeyframe;
import eu.crushedpixel.replaymod.replay.ReplayHandler;
import eu.crushedpixel.replaymod.utils.TimestampUtils;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
@@ -20,8 +22,11 @@ public class GuiEditKeyframe extends GuiScreen {
private GuiButton saveButton, cancelButton; private GuiButton saveButton, cancelButton;
private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw; private GuiNumberInput xCoord, yCoord, zCoord, pitch, yaw, roll;
private GuiNumberInput min, sec, ms;
private List<GuiNumberInput> inputs = new ArrayList<GuiNumberInput>(); private List<GuiNumberInput> inputs = new ArrayList<GuiNumberInput>();
private List<GuiNumberInput> posInputs = new ArrayList<GuiNumberInput>();
private int virtualHeight = 200; private int virtualHeight = 200;
private int virtualY; private int virtualY;
@@ -31,7 +36,7 @@ public class GuiEditKeyframe extends GuiScreen {
private boolean save; private boolean save;
private boolean posKeyframe; private boolean posKeyframe;
private int w, w2; private int w, w2, w3;
private int totalWidth; private int totalWidth;
private int left; private int left;
@@ -51,6 +56,17 @@ public class GuiEditKeyframe extends GuiScreen {
saveButton = new GuiButton(GuiConstants.KEYFRAME_EDITOR_SAVE_BUTTON, 0, 0, 100, 20, I18n.format("replaymod.gui.save")); saveButton = new GuiButton(GuiConstants.KEYFRAME_EDITOR_SAVE_BUTTON, 0, 0, 100, 20, I18n.format("replaymod.gui.save"));
cancelButton = new GuiButton(GuiConstants.KEYFRAME_EDITOR_CANCEL_BUTTON, 0, 0, 100, 20, I18n.format("replaymod.gui.cancel")); cancelButton = new GuiButton(GuiConstants.KEYFRAME_EDITOR_CANCEL_BUTTON, 0, 0, 100, 20, I18n.format("replaymod.gui.cancel"));
//Real Time Input
int timestamp = keyframe.getRealTimestamp();
min = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_MIN_INPUT, fontRendererObj, 0, 0, 30, 0, 10, TimestampUtils.getMinutesFromTimestamp(timestamp), false);
sec = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_SEC_INPUT, fontRendererObj, 0, 0, 25, 0, 59, TimestampUtils.getSecondsFromTimestamp(timestamp), false);
ms = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_REAL_SEC_INPUT, fontRendererObj, 0, 0, 35, 0, 999, TimestampUtils.getMillisecondsFromTimestamp(timestamp), false);
inputs.add(min);
inputs.add(sec);
inputs.add(ms);
//Position/Virtual Time Input
if(posKeyframe) { if(posKeyframe) {
Position pos = ((PositionKeyframe)keyframe).getPosition(); Position pos = ((PositionKeyframe)keyframe).getPosition();
xCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_X_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getX()), true); xCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_X_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getX()), true);
@@ -58,28 +74,45 @@ public class GuiEditKeyframe extends GuiScreen {
zCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_Z_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getZ()), true); zCoord = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_Z_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getZ()), true);
yaw = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_YAW_INPUT, fontRendererObj, 0, 0, 100, -90d, 90d, round(pos.getYaw()), true); yaw = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_YAW_INPUT, fontRendererObj, 0, 0, 100, -90d, 90d, round(pos.getYaw()), true);
pitch = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_PITCH_INPUT, fontRendererObj, 0, 0, 100, -180d, 180d, round(pos.getPitch()), true); pitch = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_PITCH_INPUT, fontRendererObj, 0, 0, 100, -180d, 180d, round(pos.getPitch()), true);
roll = new GuiNumberInput(GuiConstants.KEYFRAME_EDITOR_ROLL_INPUT, fontRendererObj, 0, 0, 100, null, null, round(pos.getRoll()), true);
inputs.add(xCoord); posInputs.add(xCoord);
inputs.add(yCoord); posInputs.add(yCoord);
inputs.add(zCoord); posInputs.add(zCoord);
inputs.add(yaw); posInputs.add(yaw);
inputs.add(pitch); posInputs.add(pitch);
posInputs.add(roll);
inputs.addAll(posInputs);
} }
} }
w3 = fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes"))+5+min.width+5+
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.seconds"))+5+sec.width+5+
fontRendererObj.getStringWidth(I18n.format("replaymod.gui.milliseconds"))+5+ms.width;
int l = (this.width-w3)/2;
min.xPosition = l;
sec.xPosition = l + min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5;
ms.xPosition = l + min.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.minutes")) + 5
+ sec.width + 5 + fontRendererObj.getStringWidth(I18n.format("replaymod.gui.seconds")) + 5;
min.yPosition = sec.yPosition = ms.yPosition = virtualY+virtualHeight-60;
if(posKeyframe) { if(posKeyframe) {
w = Math.max(fontRendererObj.getStringWidth(I18n.format("replaymod.gui.editkeyframe.xpos")), 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")),
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"))));
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;
int i=0; int i = 0;
for(GuiNumberInput input : inputs) { for(GuiNumberInput input : posInputs) {
input.xPosition = i < 3 ? x : left+totalWidth-100; input.xPosition = i < 3 ? x : left+totalWidth-100;
input.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30; input.yPosition = i < 3 ? virtualY + 20 + i*30 : virtualY + 20 + (i-3)*30;
i++; i++;
@@ -98,6 +131,17 @@ public class GuiEditKeyframe extends GuiScreen {
@Override @Override
public void onGuiClosed() { public void onGuiClosed() {
if(!save) {
ReplayHandler.removeKeyframe(keyframe);
ReplayHandler.addKeyframe(keyframeBackup);
ReplayHandler.selectKeyframe(keyframeBackup);
} else {
if(posKeyframe) {
((PositionKeyframe)keyframe).setPosition(new Position(xCoord.getValue(false), yCoord.getValue(false),
zCoord.getValue(false), new Float(pitch.getValue(false)), new Float(yaw.getValue(false)),
new Float(roll.getValue(false))));
}
}
Keyboard.enableRepeatEvents(false); Keyboard.enableRepeatEvents(false);
} }
@@ -106,7 +150,11 @@ public class GuiEditKeyframe extends GuiScreen {
for(GuiNumberInput input : inputs) { for(GuiNumberInput input : inputs) {
if(input != null) input.textboxKeyTyped(typedChar, keyCode); if(input != null) input.textboxKeyTyped(typedChar, keyCode);
} }
super.keyTyped(typedChar, keyCode);
if(keyCode == Keyboard.KEY_ESCAPE) {
save = false;
mc.displayGuiScreen(null);
}
} }
@Override @Override
@@ -135,6 +183,7 @@ public class GuiEditKeyframe extends GuiScreen {
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.zpos"), left, virtualY + 87, Color.WHITE.getRGB()); drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.zpos"), left, virtualY + 87, Color.WHITE.getRGB());
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camyaw"), left+totalWidth-100-5-w2, virtualY + 27, Color.WHITE.getRGB()); drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camyaw"), left+totalWidth-100-5-w2, virtualY + 27, Color.WHITE.getRGB());
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.campitch"), left+totalWidth-100-5-w2, virtualY + 57, Color.WHITE.getRGB()); drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.campitch"), left+totalWidth-100-5-w2, virtualY + 57, Color.WHITE.getRGB());
drawString(fontRendererObj, I18n.format("replaymod.gui.editkeyframe.camroll"), left+totalWidth-100-5-w2, virtualY + 87, Color.WHITE.getRGB());
} }
for(GuiNumberInput input : inputs) { for(GuiNumberInput input : inputs) {
@@ -147,4 +196,16 @@ public class GuiEditKeyframe extends GuiScreen {
private double round(double val) { private double round(double val) {
return Math.round(val*100.0) / 100.0; return Math.round(val*100.0) / 100.0;
} }
@Override
protected void actionPerformed(GuiButton button) throws IOException {
if(!button.enabled) return;
if(button.id == GuiConstants.KEYFRAME_EDITOR_SAVE_BUTTON) {
save = true;
mc.displayGuiScreen(null);
} else if(button.id == GuiConstants.KEYFRAME_EDITOR_CANCEL_BUTTON) {
save = false;
mc.displayGuiScreen(null);
}
}
} }

View File

@@ -15,7 +15,18 @@ public class GuiNumberInput extends GuiTextField {
this.minimum = minimum; this.minimum = minimum;
this.maximum = maximum; this.maximum = maximum;
this.acceptFloats = acceptFloats; this.acceptFloats = acceptFloats;
if(defaultValue != null) setText(""+defaultValue); if(defaultValue != null) {
if(acceptFloats) {
setText("" + defaultValue);
} else {
setText("" + (int)Math.round(defaultValue));
}
}
}
public GuiNumberInput(int id, FontRenderer fontRenderer,
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);
} }
@Override @Override
@@ -27,11 +38,25 @@ public class GuiNumberInput extends GuiTextField {
} else { } else {
val = Integer.valueOf(getText() + text); val = Integer.valueOf(getText() + text);
} }
if(minimum != null && val < minimum) return; if(minimum != null && val < minimum) {
if(maximum != null && val > maximum) return; 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;
}
super.writeText(text); super.writeText(text);
} catch(NumberFormatException e) { } catch(NumberFormatException e) {
} }
} }
public Double getValue(boolean nullable) {
try {
return Double.valueOf(getText());
} catch(Exception e) {
return nullable ? null : 0d;
}
}
} }

View File

@@ -2,6 +2,7 @@ package eu.crushedpixel.replaymod.gui.replaystudio;
import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput; import eu.crushedpixel.replaymod.gui.elements.GuiNumberInput;
import eu.crushedpixel.replaymod.studio.StudioImplementation; import eu.crushedpixel.replaymod.studio.StudioImplementation;
import eu.crushedpixel.replaymod.utils.TimestampUtils;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import org.lwjgl.input.Keyboard; import org.lwjgl.input.Keyboard;
@@ -50,7 +51,7 @@ public class GuiTrimPart extends GuiStudioPart {
int secs = valueOf(startSecInput.getText()); int secs = valueOf(startSecInput.getText());
int ms = valueOf(startMsInput.getText()); int ms = valueOf(startMsInput.getText());
return (mins * 60 * 1000) + (secs * 1000) + ms; return TimestampUtils.calculateTimestamp(mins, secs, ms);
} }
private int getEndTimestamp() { private int getEndTimestamp() {
@@ -58,7 +59,7 @@ public class GuiTrimPart extends GuiStudioPart {
int secs = valueOf(endSecInput.getText()); int secs = valueOf(endSecInput.getText());
int ms = valueOf(endMsInput.getText()); int ms = valueOf(endMsInput.getText());
return (mins * 60 * 1000) + (secs * 1000) + ms; return TimestampUtils.calculateTimestamp(mins, secs, ms);
} }
@Override @Override
@@ -106,12 +107,12 @@ public class GuiTrimPart extends GuiStudioPart {
public void drawScreen(int mouseX, int mouseY, float partialTicks) { public void drawScreen(int mouseX, int mouseY, float partialTicks) {
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.start")+":", 30, yPos + 7, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.start")+":", 30, yPos + 7, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, I18n.format("replaymod.gui.end")+":", 30, yPos + 7 + 30, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.end")+":", 30, yPos + 7 + 30, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "m", 105, yPos + 7, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.minutes"), 105, yPos + 7, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "m", 105, yPos + 7 + 30, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.minutes"), 105, yPos + 7 + 30, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "s", 150, yPos + 7, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.seconds"), 150, yPos + 7, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "s", 150, yPos + 7 + 30, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.seconds"), 150, yPos + 7 + 30, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "ms", 200, yPos + 7, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.milliseconds"), 200, yPos + 7, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "ms", 200, yPos + 7 + 30, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, I18n.format("replaymod.gui.milliseconds"), 200, yPos + 7 + 30, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "Timestamp: " + getStartTimestamp(), 230, yPos + 7, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, "Timestamp: " + getStartTimestamp(), 230, yPos + 7, Color.WHITE.getRGB());
drawString(mc.fontRendererObj, "Timestamp: " + getEndTimestamp(), 230, yPos + 30 + 7, Color.WHITE.getRGB()); drawString(mc.fontRendererObj, "Timestamp: " + getEndTimestamp(), 230, yPos + 30 + 7, Color.WHITE.getRGB());

View File

@@ -6,8 +6,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
public class Position { public class Position {
private double x, y, z; private double x, y, z;
private float pitch, yaw; private float pitch, yaw, roll;
private float rotation = 0;
public Position(Entity e) { public Position(Entity e) {
this.x = e.posX; this.x = e.posX;
@@ -17,13 +16,13 @@ public class Position {
this.yaw = e.rotationYaw; this.yaw = e.rotationYaw;
} }
public Position(double x, double y, double z, float pitch, float yaw, float rotation) { public Position(double x, double y, double z, float pitch, float yaw, float roll) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.z = z; this.z = z;
this.pitch = pitch; this.pitch = pitch;
this.yaw = yaw; this.yaw = yaw;
this.rotation = rotation; 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) {
@@ -74,13 +73,13 @@ public class Position {
this.yaw = yaw; this.yaw = yaw;
} }
public float getRotation() { return rotation; } public float getRoll() { return roll; }
public void setRotation(float rotation) { this.rotation = rotation; } public void setRoll(float roll) { this.roll = roll; }
@Override @Override
public String toString() { public String toString() {
return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch; return "X=" + x + ", Y=" + y + ", Z=" + z + ", Yaw=" + yaw + ", Pitch=" + pitch + ", Roll="+roll;
} }
@Override @Override
@@ -99,7 +98,7 @@ public class Position {
.append(z) .append(z)
.append(pitch) .append(pitch)
.append(yaw) .append(yaw)
.append(rotation) .append(roll)
.toHashCode(); .toHashCode();
} }
} }

View File

@@ -22,7 +22,7 @@ public class LinearPoint extends LinearInterpolation<Position> {
float pitch = (float)getInterpolatedValue(first.getPitch(), second.getPitch(), perc); float pitch = (float)getInterpolatedValue(first.getPitch(), second.getPitch(), perc);
float yaw = (float)getInterpolatedValue(first.getYaw(), second.getYaw(), perc); float yaw = (float)getInterpolatedValue(first.getYaw(), second.getYaw(), perc);
float rot = (float)getInterpolatedValue(first.getRotation(), second.getRotation(), perc); float rot = (float)getInterpolatedValue(first.getRoll(), second.getRoll(), perc);
Position inter = new Position(x, y, z, pitch, yaw, rot); Position inter = new Position(x, y, z, pitch, yaw, rot);

View File

@@ -16,8 +16,8 @@ public class KeybindRegistry {
public static final String KEY_CLEAR_KEYFRAMES = "replaymod.input.clearkeyframes"; public static final String KEY_CLEAR_KEYFRAMES = "replaymod.input.clearkeyframes";
public static final String KEY_SYNC_TIMELINE = "replaymod.input.synctimeline"; public static final String KEY_SYNC_TIMELINE = "replaymod.input.synctimeline";
public static final String KEY_KEYFRAME_PRESETS = "replaymod.input.keyframerepository"; public static final String KEY_KEYFRAME_PRESETS = "replaymod.input.keyframerepository";
public static final String KEY_ROTATE_CLOCKWISE = "replaymod.input.rotateclockwise"; public static final String KEY_ROLL_CLOCKWISE = "replaymod.input.rollclockwise";
public static final String KEY_ROTATE_COUNTERCLOCKWISE = "replaymod.input.rotatecounterclockwise"; public static final String KEY_ROLL_COUNTERCLOCKWISE = "replaymod.input.rollcounterclockwise";
public static final String KEY_RESET_TILT = "replaymod.input.resettilt"; public static final String KEY_RESET_TILT = "replaymod.input.resettilt";
public static final String KEY_PLAY_PAUSE = "replaymod.input.playpause"; public static final String KEY_PLAY_PAUSE = "replaymod.input.playpause";
private static Minecraft mc = Minecraft.getMinecraft(); private static Minecraft mc = Minecraft.getMinecraft();
@@ -31,9 +31,9 @@ public class KeybindRegistry {
bindings.add(new KeyBinding(KEY_SYNC_TIMELINE, Keyboard.KEY_V, "replaymod.title")); bindings.add(new KeyBinding(KEY_SYNC_TIMELINE, Keyboard.KEY_V, "replaymod.title"));
bindings.add(new KeyBinding(KEY_CLEAR_KEYFRAMES, Keyboard.KEY_C, "replaymod.title")); bindings.add(new KeyBinding(KEY_CLEAR_KEYFRAMES, Keyboard.KEY_C, "replaymod.title"));
bindings.add(new KeyBinding(KEY_KEYFRAME_PRESETS, Keyboard.KEY_X, "replaymod.title")); bindings.add(new KeyBinding(KEY_KEYFRAME_PRESETS, Keyboard.KEY_X, "replaymod.title"));
bindings.add(new KeyBinding(KEY_ROTATE_CLOCKWISE, Keyboard.KEY_L, "replaymod.title")); bindings.add(new KeyBinding(KEY_ROLL_CLOCKWISE, Keyboard.KEY_L, "replaymod.title"));
bindings.add(new KeyBinding(KEY_RESET_TILT, Keyboard.KEY_K, "replaymod.title")); bindings.add(new KeyBinding(KEY_RESET_TILT, Keyboard.KEY_K, "replaymod.title"));
bindings.add(new KeyBinding(KEY_ROTATE_COUNTERCLOCKWISE, Keyboard.KEY_J, "replaymod.title")); bindings.add(new KeyBinding(KEY_ROLL_COUNTERCLOCKWISE, Keyboard.KEY_J, "replaymod.title"));
bindings.add(new KeyBinding(KEY_PLAY_PAUSE, Keyboard.KEY_P, "replaymod.title")); bindings.add(new KeyBinding(KEY_PLAY_PAUSE, Keyboard.KEY_P, "replaymod.title"));
mc.gameSettings.keyBindings = bindings.toArray(new KeyBinding[bindings.size()]); mc.gameSettings.keyBindings = bindings.toArray(new KeyBinding[bindings.size()]);

View File

@@ -333,7 +333,7 @@ public class ReplayProcess {
} }
} }
ReplayHandler.setCameraTilt(pos.getRotation()); ReplayHandler.setCameraTilt(pos.getRoll());
Integer curTimestamp = null; Integer curTimestamp = null;
if(timeLinear != null && timeCount > 1) { if(timeLinear != null && timeCount > 1) {

View File

@@ -0,0 +1,20 @@
package eu.crushedpixel.replaymod.utils;
public class TimestampUtils {
public static int getMinutesFromTimestamp(long timestamp) {
return (int)((timestamp / (1000*60)) % 60);
}
public static int getSecondsFromTimestamp(long timestamp) {
return (int)(timestamp / 1000) % 60;
}
public static int getMillisecondsFromTimestamp(long timestamp) {
return(int)(timestamp % 1000);
}
public static int calculateTimestamp(int min, int sec, int ms) {
return (min * 60 * 1000) + (sec * 1000) + ms;
}
}

View File

@@ -73,6 +73,10 @@ replaymod.gui.register=Register
replaymod.gui.mail=Email Address replaymod.gui.mail=Email Address
replaymod.gui.loading=Loading replaymod.gui.loading=Loading
replaymod.gui.minutes=min
replaymod.gui.seconds=sec
replaymod.gui.milliseconds=ms
replaymod.gui.unknownerror=An unknown error occured replaymod.gui.unknownerror=An unknown error occured
replaymod.gui.exit=Exit Replay replaymod.gui.exit=Exit Replay
@@ -203,8 +207,8 @@ replaymod.input.playeroverview=Player Overview
replaymod.input.clearkeyframes=Clear Keyframes replaymod.input.clearkeyframes=Clear Keyframes
replaymod.input.synctimeline=Synchronize Timeline replaymod.input.synctimeline=Synchronize Timeline
replaymod.input.keyframerepository=Open Keyframe Presets replaymod.input.keyframerepository=Open Keyframe Presets
replaymod.input.rotateclockwise=Rotate Clockwise replaymod.input.rollclockwise=Roll Clockwise
replaymod.input.rotatecounterclockwise=Rotate Counterclockwise replaymod.input.rollcounterclockwise=Roll Counterclockwise
replaymod.input.resettilt=Reset Camera Tilt replaymod.input.resettilt=Reset Camera Tilt
replaymod.input.playpause=Play/Pause Replay replaymod.input.playpause=Play/Pause Replay
@@ -228,3 +232,4 @@ replaymod.gui.editkeyframe.ypos=Y Position
replaymod.gui.editkeyframe.zpos=Z Position replaymod.gui.editkeyframe.zpos=Z Position
replaymod.gui.editkeyframe.campitch=Camera Pitch replaymod.gui.editkeyframe.campitch=Camera Pitch
replaymod.gui.editkeyframe.camyaw=Camera Yaw replaymod.gui.editkeyframe.camyaw=Camera Yaw
replaymod.gui.editkeyframe.camroll=Camera Roll