General warning cleanup

This commit is contained in:
johni0702
2015-07-19 16:18:34 +02:00
parent 4f718ab302
commit 6422558028
31 changed files with 88 additions and 281 deletions

View File

@@ -10,6 +10,7 @@ import eu.crushedpixel.replaymod.api.replay.SearchQuery;
import eu.crushedpixel.replaymod.api.replay.holders.*;
import eu.crushedpixel.replaymod.gui.elements.listeners.ProgressUpdateListener;
import eu.crushedpixel.replaymod.online.authentication.AuthenticationHash;
import eu.crushedpixel.replaymod.utils.Api;
import net.minecraft.client.Minecraft;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
@@ -195,6 +196,7 @@ public class ApiClient {
return invokeAndReturn(builder, Favorites.class).getFavorited();
}
@Api
public void removeFile(String auth, int file) throws IOException, ApiException {
QueryBuilder builder = new QueryBuilder(ReplayModApiMethods.remove_file);
builder.put("auth", auth);

View File

@@ -1,7 +1,6 @@
package eu.crushedpixel.replaymod.api.replay;
import com.google.gson.Gson;
import eu.crushedpixel.replaymod.api.ApiException;
import eu.crushedpixel.replaymod.api.replay.holders.ApiError;
import eu.crushedpixel.replaymod.api.replay.holders.Category;
import eu.crushedpixel.replaymod.gui.online.GuiUploadFile;
@@ -24,8 +23,7 @@ public class FileUploader {
private GuiUploadFile parent;
public void uploadFile(GuiUploadFile gui, String auth, String filename, List<String> tags, File file, Category category, String description)
throws IOException, ApiException, RuntimeException {
public void uploadFile(GuiUploadFile gui, String auth, String filename, List<String> tags, File file, Category category, String description) {
boolean success = false;
String info = null;

View File

@@ -14,7 +14,7 @@ public class AssetFileUtils {
return ImageIO.getReaderFileSuffixes();
}
return null;
throw new UnsupportedOperationException("Unknown replay asset type: " + clazz);
}
public static String[] getAllAvailableExtensions() {

View File

@@ -91,7 +91,7 @@ public class CustomImageObject implements GuiEntryListEntry {
return null;
}
if(resourceLocation != null && !ResourceHelper.isRegistered(resourceLocation)) {
if(!ResourceHelper.isRegistered(resourceLocation)) {
ResourceHelper.registerResource(resourceLocation);
Minecraft.getMinecraft().getTextureManager().loadTexture(resourceLocation, dynamicTexture);
dynamicTexture.updateDynamicTexture();

View File

@@ -8,7 +8,6 @@ import org.objectweb.asm.tree.*;
import java.util.ListIterator;
import static org.objectweb.asm.Opcodes.*;
import static org.objectweb.asm.Opcodes.INVOKESTATIC;
public class SoundManagerCT implements IClassTransformer {

View File

@@ -9,17 +9,12 @@ import net.minecraft.crash.CrashReport;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ReportedException;
import net.minecraftforge.client.event.MouseEvent;
import org.lwjgl.LWJGLException;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
public class MinecraftTicker {
public static void runMouseKeyboardTick(Minecraft mc) throws IllegalAccessException, IllegalArgumentException,
InvocationTargetException, IOException, LWJGLException {
public static void runMouseKeyboardTick(Minecraft mc) {
ReplayMod.mouseInputHandler.mouseEvent(new MouseEvent());
if(mc.thePlayer == null) return;
try {

View File

@@ -2,8 +2,6 @@ package eu.crushedpixel.replaymod.gui;
public class GuiConstants {
public static final int MAIN_MENU_UPDATE_BUTTON = 8765;
public static final int CENTER_DOWNLOADED_REPLAYS_BUTTON = 2001;
public static final int CENTER_SEARCH_BUTTON = 2002;
public static final int CENTER_BACK_BUTTON = 2003;
@@ -61,17 +59,8 @@ public class GuiConstants {
public static final int PLAYER_OVERVIEW_SHOW_ALL = 101;
public static final int PLAYER_OVERVIEW_REMEMBER = -10;
public static final int RENDER_SETTINGS_RENDER_BUTTON = 9002;
public static final int RENDER_SETTINGS_CANCEL_BUTTON = 9003;
public static final int RENDER_SETTINGS_INTERPOLATION_BUTTON = 9007;
public static final int RENDER_SETTINGS_FORCECHUNKS_BUTTON = 9008;
public static final int RENDER_SETTINGS_FRAMERATE_SLIDER = 9009;
public static final int RENDER_SETTINGS_STATIC_CAMERA = 9012;
public static final int RENDER_SETTINGS_ADVANCED_BUTTON = 9013;
public static final int RENDER_SETTINGS_COLOR_PICKER = 9014;
public static final int RENDER_SETTINGS_ENABLE_GREENSCREEN = 9015;
public static final int RENDER_SETTINGS_OUTPUT_CHOOSER = 9016;
public static final int RENDER_SETTINGS_RENDER_NAMETAGS = 9017;
public static final int REPLAY_SETTINGS_RECORDSERVER_ID = 9004;
public static final int REPLAY_SETTINGS_RECORDSP_ID = 9005;
@@ -83,5 +72,4 @@ public class GuiConstants {
public static final int REPLAY_SETTINGS_CLEARCALLBACK_ID = 9014;
public static final int REPLAY_EDITING_CANCEL_BUTTON = 1234;
public static final int REPLAY_DOWNLOADING_CANCEL_BUTTON = 2345;
}

View File

@@ -11,6 +11,7 @@ import eu.crushedpixel.replaymod.gui.elements.timelines.GuiTimeline;
import eu.crushedpixel.replaymod.gui.overlay.GuiReplayOverlay;
import eu.crushedpixel.replaymod.holders.*;
import eu.crushedpixel.replaymod.interpolation.KeyframeList;
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
import eu.crushedpixel.replaymod.replay.ReplayHandler;
import eu.crushedpixel.replaymod.utils.MouseUtils;
import eu.crushedpixel.replaymod.utils.ReplayFile;
@@ -30,6 +31,8 @@ import java.io.IOException;
import java.util.List;
import java.util.UUID;
import org.lwjgl.util.Point;
public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOverlay {
private boolean initialized = false;
@@ -50,16 +53,12 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
private GuiDraggingNumberInput scaleXInput, scaleYInput, scaleZInput;
private GuiDraggingNumberInput opacityInput;
private NumberInputGroup anchorNumberInputs, positionNumberInputs, orientationNumberInputs, scaleNumberInputs, opacityNumberInputs;
private NumberPositionInputGroup anchorNumberInputs, positionNumberInputs, orientationNumberInputs, scaleNumberInputs;
private NumberValueInputGroup opacityNumberInputs;
@Getter
private GuiObjectKeyframeTimeline objectKeyframeTimeline;
private GuiScrollbar timelineScrollbar;
private GuiTexturedButton zoomInButton, zoomOutButton;
private ComposedElement anchorInputs, positionInputs, scaleInputs, orientationInputs, opacityInputs, numberInputs;
private ComposedElement disableElements, allElements;
private static final int KEYFRAME_BUTTON_X = 80;
@@ -257,19 +256,19 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
int inputWidth = 40;
anchorInputs = new ComposedElement(anchorXInput, anchorYInput, anchorZInput);
positionInputs = new ComposedElement(positionXInput, positionYInput, positionZInput);
orientationInputs = new ComposedElement(orientationXInput, orientationYInput, orientationZInput);
scaleInputs = new ComposedElement(scaleXInput, scaleYInput, scaleZInput);
opacityInputs = new ComposedElement(opacityInput);
numberInputs = new ComposedElement(anchorInputs, positionInputs, orientationInputs, scaleInputs, opacityInputs);
ComposedElement anchorInputs = new ComposedElement(anchorXInput, anchorYInput, anchorZInput);
ComposedElement positionInputs = new ComposedElement(positionXInput, positionYInput, positionZInput);
ComposedElement orientationInputs = new ComposedElement(orientationXInput, orientationYInput, orientationZInput);
ComposedElement scaleInputs = new ComposedElement(scaleXInput, scaleYInput, scaleZInput);
ComposedElement opacityInputs = new ComposedElement(opacityInput);
ComposedElement numberInputs = new ComposedElement(anchorInputs, positionInputs, orientationInputs, scaleInputs, opacityInputs);
for(int i = numberInputs.getParts().size()-1; i >= 0; i--) {
int yPos = this.height-5-10-(25*(numberInputs.getParts().size()-i));
DelegatingElement button = keyframeButton(10, yPos, i);
GuiString label = new GuiString(35, yPos + 6, Color.WHITE, labelStrings[i]);
ComposedElement child = (ComposedElement)numberInputs.getParts().get(i);
ComposedElement child = (ComposedElement) numberInputs.getParts().get(i);
int x = 0;
for(GuiElement el : child.getParts()) {
GuiDraggingNumberInput dni = (GuiDraggingNumberInput)el;
@@ -294,10 +293,10 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
objectKeyframeTimeline = new GuiObjectKeyframeTimeline(timelineX, timelineY, timelineWidth, timelineHeight);
disableElements.addPart(objectKeyframeTimeline);
timelineScrollbar = new GuiScrollbar(timelineX, this.height-15, timelineWidth-21) {
GuiScrollbar timelineScrollbar = new GuiScrollbar(timelineX, this.height - 15, timelineWidth - 21) {
@Override
public void dragged() {
objectKeyframeTimeline.timeStart = (float)sliderPosition;
objectKeyframeTimeline.timeStart = (float) sliderPosition;
}
};
@@ -306,14 +305,14 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
disableElements.addPart(timelineScrollbar);
zoomInButton = GuiReplayOverlay.texturedButton(width - 28, this.height-15, 40, 20, 9, new Runnable() {
GuiTexturedButton zoomInButton = GuiReplayOverlay.texturedButton(width - 28, this.height - 15, 40, 20, 9, new Runnable() {
@Override
public void run() {
objectKeyframeTimeline.zoom = Math.max(0.025f, objectKeyframeTimeline.zoom - ZOOM_STEPS);
}
}, "replaymod.gui.ingame.menu.zoomin");
zoomOutButton = GuiReplayOverlay.texturedButton(width - 18, this.height-15, 40, 30, 9, new Runnable() {
GuiTexturedButton zoomOutButton = GuiReplayOverlay.texturedButton(width - 18, this.height - 15, 40, 30, 9, new Runnable() {
@Override
public void run() {
@@ -467,17 +466,17 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
saveOnQuit();
}
public abstract class NumberInputGroup implements NumberValueChangeListener {
public abstract class NumberInputGroup<T extends KeyframeValue> implements NumberValueChangeListener {
KeyframeList toModify;
KeyframeList<T> toModify;
public void setUnderlyingKeyframeList(KeyframeList toModify) {
public void setUnderlyingKeyframeList(KeyframeList<T> toModify) {
this.toModify = toModify;
}
}
public class NumberValueInputGroup extends NumberInputGroup {
public class NumberValueInputGroup extends NumberInputGroup<NumberValue> {
public NumberValueInputGroup(KeyframeList<NumberValue> toModify, GuiNumberInput input) {
this.toModify = toModify;
@@ -486,6 +485,7 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
}
@Override
@SuppressWarnings("unchecked")
public void onValueChange(double value) {
NumberValue numberValue = new NumberValue(value);
@@ -498,7 +498,7 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
}
}
public class NumberPositionInputGroup extends NumberInputGroup {
public class NumberPositionInputGroup extends NumberInputGroup<Position> {
public NumberPositionInputGroup(KeyframeList<Position> toModify, GuiNumberInput xInput, GuiNumberInput yInput, GuiNumberInput zInput) {
this.toModify = toModify;
@@ -514,6 +514,7 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
private GuiNumberInput xInput, yInput, zInput;
@Override
@SuppressWarnings("unchecked")
public void onValueChange(double value) {
Position position = new Position(xInput.getPreciseValue(), yInput.getPreciseValue(), zInput.getPreciseValue());
@@ -561,10 +562,10 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
if(transformations != null) {
for(int i = 0; i < 5; i++) {
KeyframeList keyframes = transformations.getKeyframeListByID(i);
KeyframeList<?> keyframes = transformations.getKeyframeListByID(i);
//Draw Keyframe logos
for(Keyframe kf : (List<Keyframe>) keyframes) {
for(Keyframe kf : keyframes) {
drawKeyframe(kf, (int)(i * (height / 5f)) + 10, bodyWidth, leftTime, rightTime, segmentLength);
}
}
@@ -609,9 +610,8 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
int lower = upper + KEYFRAME_SIZE;
if(mouseY >= upper && mouseY <= lower) {
KeyframeList keyframes = transformations.getKeyframeListByID(i);
Keyframe closest = keyframes.getClosestKeyframeForTimestamp(time, tolerance);
selectedKeyframe = closest;
selectedKeyframe = keyframes.getClosestKeyframeForTimestamp(time, tolerance);
if(selectedKeyframe != null) {
selectedKeyframeRow = i;
@@ -662,6 +662,7 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
this.dragging = false;
}
@SuppressWarnings("unchecked")
public void addKeyframe(int line) {
CustomImageObject currentObject = objectList.getElement(objectList.getSelectionIndex());
if(currentObject != null) {
@@ -672,32 +673,32 @@ public class GuiObjectManager extends GuiScreen implements GuiReplayOverlay.NoOv
switch(line) {
case 0:
kf = new Keyframe(timestamp, new Position(
kf = new Keyframe<Position>(timestamp, new Position(
anchorXInput.getPreciseValue(),
anchorYInput.getPreciseValue(),
anchorZInput.getPreciseValue()));
break;
case 1:
kf = new Keyframe(timestamp, new Position(
kf = new Keyframe<Position>(timestamp, new Position(
positionXInput.getPreciseValue(),
positionYInput.getPreciseValue(),
positionZInput.getPreciseValue()));
break;
case 2:
kf = new Keyframe(timestamp, new Position(
kf = new Keyframe<Position>(timestamp, new Position(
orientationXInput.getPreciseValue(),
orientationYInput.getPreciseValue(),
orientationZInput.getPreciseValue()));
break;
case 3:
kf = new Keyframe(timestamp, new Position(
kf = new Keyframe<Position>(timestamp, new Position(
scaleXInput.getPreciseValue(),
scaleYInput.getPreciseValue(),
scaleZInput.getPreciseValue()));
break;
case 4:
kf = new Keyframe(timestamp, new NumberValue(
kf = new Keyframe<NumberValue>(timestamp, new NumberValue(
opacityInput.getPreciseValue()
));
break;

View File

@@ -1,91 +0,0 @@
package eu.crushedpixel.replaymod.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.MathHelper;
public class GuiVideoQualitySlider extends GuiButton {
public boolean dragging;
private String displayKey;
private float sliderValue;
public GuiVideoQualitySlider(int buttonId, int p_i45017_2_, int p_i45017_3_, float d, String displayKey) {
super(buttonId, p_i45017_2_, p_i45017_3_, 150, 20, "");
this.sliderValue = normalizeValue(d);
this.displayString = displayKey + ": " + translate(d);
this.displayKey = displayKey;
}
private final String DRAFT = I18n.format("replaymod.gui.settings.videoquality.draft");
private final String NORMAL = I18n.format("replaymod.gui.settings.videoquality.normal");
private final String GOOD= I18n.format("replaymod.gui.settings.videoquality.good");
private final String BEST = I18n.format("replaymod.gui.settings.videoquality.best");
private String translate(float value) {
if(value <= 0.3) {
return DRAFT;
} else if(value <= 0.5) {
return NORMAL;
} else if(value <= 0.7) {
return GOOD;
}
return BEST;
}
protected int getHoverState(boolean mouseOver) {
return 0;
}
@Override
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
if(this.visible) {
if(this.dragging) {
sliderValue = (float) (mouseX - (this.xPosition + 4)) / (float) (this.width - 8);
sliderValue = MathHelper.clamp_float(sliderValue, 0.0F, 1.0F);
float f = denormalizeValue(sliderValue);
f = snapValue(f);
sliderValue = normalizeValue(f);
this.displayString = displayKey + ": " + translate(f);
}
mc.getTextureManager().bindTexture(buttonTextures);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.drawTexturedModalRect(this.xPosition + (int)Math.ceil(sliderValue * (float) (this.width - 8)), this.yPosition, 0, 66, 4, 20);
this.drawTexturedModalRect(this.xPosition + (int)Math.ceil(sliderValue * (float) (this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
}
}
public float getQuality() {
return snapValue(denormalizeValue(sliderValue));
}
private float snapValue(float val) {
int i = Math.round(val * 10);
return i / 10f;
}
private float normalizeValue(float val) {
return (val - 0.1f) / 0.8f;
}
private float denormalizeValue(float val) {
//Transfers the value ranging from 0.0 to 1.0 to the scale of 0.1 to 0.9
float r = 0.8f * val;
return 0.1f + r;
}
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
if(super.mousePressed(mc, mouseX, mouseY)) {
this.dragging = true;
return true;
} else {
return false;
}
}
public void mouseReleased(int mouseX, int mouseY) {
this.dragging = false;
}
}

View File

@@ -1,29 +0,0 @@
package eu.crushedpixel.replaymod.gui;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiTextField;
public class PasswordTextField extends GuiTextField {
public PasswordTextField(int p_i45542_1_, FontRenderer p_i45542_2_,
int p_i45542_3_, int p_i45542_4_, int p_i45542_5_, int p_i45542_6_) {
super(p_i45542_1_, p_i45542_2_, p_i45542_3_, p_i45542_4_, p_i45542_5_,
p_i45542_6_);
}
@Override
public void drawTextBox() {
String prev = getText();
String pw = "";
for(int i = 0; i < prev.length(); i++) {
pw += "*";
}
text = pw;
super.drawTextBox();
text = prev;
}
}

View File

@@ -138,8 +138,8 @@ public class GuiDropdown<T extends GuiEntryListEntry> extends GuiAdvancedTextFie
}
public boolean mouseClickedResult(int xPos, int yPos) {
if(!isEnabled) return false;
boolean success = false;
if(!isEnabled) return success;
if(xPos > xPosition + width - height && xPos < xPosition + width && yPos > yPosition && yPos < yPosition + height) {
open = !open;
} else {

View File

@@ -1,12 +1,9 @@
package eu.crushedpixel.replaymod.gui.elements;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
public class GuiNumberInputWithText extends GuiNumberInput {
private final Minecraft mc = Minecraft.getMinecraft();
private String suffix;
public GuiNumberInputWithText(FontRenderer fontRenderer,

View File

@@ -136,14 +136,13 @@ public class GuiKeyframeTimeline extends GuiTimeline {
int i = iterator.nextIndex();
int nextSpectatorKeyframeRealTime = -1;
while(iterator.hasNext()) {
if (iterator.hasNext()) {
Keyframe<AdvancedPosition> kf2 = iterator.next();
if(kf.getValue().getSpectatedEntityID()
.equals(kf2.getValue().getSpectatedEntityID())) {
nextSpectatorKeyframeRealTime = kf2.getRealTimestamp();
}
break;
}
int i2 = iterator.previousIndex();
@@ -172,12 +171,11 @@ public class GuiKeyframeTimeline extends GuiTimeline {
int i = iterator.nextIndex();
int nextTimeKeyframeRealTime = -1;
while(iterator.hasNext()) {
if (iterator.hasNext()) {
Keyframe<TimestampValue> kf2 = iterator.next();
if(kf.getValue().asInt() > kf2.getValue().asInt()) {
nextTimeKeyframeRealTime = kf2.getRealTimestamp();
}
break;
}
int i2 = iterator.previousIndex();
@@ -232,7 +230,7 @@ public class GuiKeyframeTimeline extends GuiTimeline {
y += 0;
//If Spectator Keyframe, use different texture
if(((Keyframe<AdvancedPosition>) kf).getValue().getSpectatedEntityID() != null) {
if(((AdvancedPosition) kf.getValue()).getSpectatedEntityID() != null) {
textureX = KEYFRAME_SPEC_X;
textureY = KEYFRAME_SPEC_Y;
}

View File

@@ -36,7 +36,7 @@ import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.util.Point;
import java.awt.*;
import java.awt.Color;
import java.io.IOException;
import java.util.List;
@@ -191,7 +191,7 @@ public class GuiReplayOverlay extends Gui {
boolean selected = ReplayHandler.getSelectedKeyframe() != null && ReplayHandler.getSelectedKeyframe().getValue() instanceof AdvancedPosition;
boolean camera;
if(selected) {
camera = ((Keyframe<AdvancedPosition>)ReplayHandler.getSelectedKeyframe()).getValue().getSpectatedEntityID() == null;
camera = ((AdvancedPosition)ReplayHandler.getSelectedKeyframe().getValue()).getSpectatedEntityID() == null;
} else {
camera = ReplayHandler.isCamera();
}
@@ -616,9 +616,10 @@ public class GuiReplayOverlay extends Gui {
GlStateManager.color(1, 1, 1, 1);
GlStateManager.enableAlpha();
GlStateManager.disableLighting();
Gui.drawModalRectWithCustomSizedTexture(xPos-width, HEIGHT - 10 - 13,
Gui.drawModalRectWithCustomSizedTexture(xPos - width, HEIGHT - 10 - 13,
100, 0, 20, 13, TEXTURE_SIZE, TEXTURE_SIZE);
//noinspection UnusedAssignment
xPos -= width + 5;
}

View File

@@ -9,6 +9,7 @@ import net.minecraft.client.resources.I18n;
import java.awt.*;
import java.io.IOException;
import java.util.List;
public class GuiReplayEditingProcess extends GuiScreen {
@@ -48,6 +49,8 @@ public class GuiReplayEditingProcess extends GuiScreen {
cancelButton.width = 150;
cancelButton.yPosition = this.height - 5 - 20;
@SuppressWarnings("unchecked")
List<GuiButton> buttonList = this.buttonList;
buttonList.add(cancelButton);
initialized = true;

View File

@@ -4,7 +4,6 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@NoArgsConstructor
@@ -24,6 +23,7 @@ public class KeyframeSet implements GuiEntryListEntry {
this.name = name;
}
@SuppressWarnings("unchecked")
public void setKeyframes(Keyframe[] keyframes) {
List<Keyframe<AdvancedPosition>> posKFList = new ArrayList<Keyframe<AdvancedPosition>>();
List<Keyframe<TimestampValue>> timeKFList = new ArrayList<Keyframe<TimestampValue>>();
@@ -44,10 +44,10 @@ public class KeyframeSet implements GuiEntryListEntry {
}
public Keyframe[] getKeyframes() {
List<Keyframe> kfList = new ArrayList<Keyframe>();
Collections.addAll(kfList, positionKeyframes);
Collections.addAll(kfList, timeKeyframes);
return kfList.toArray(new Keyframe[kfList.size()]);
Keyframe[] keyframes = new Keyframe[positionKeyframes.length + timeKeyframes.length];
System.arraycopy(positionKeyframes, 0, keyframes, 0, positionKeyframes.length);
System.arraycopy(timeKeyframes, 0, keyframes, positionKeyframes.length, timeKeyframes.length);
return keyframes;
}
public int getTimeKeyframeCount() {

View File

@@ -1,12 +1,11 @@
package eu.crushedpixel.replaymod.interpolation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.List;
public abstract class BasicSpline {
public void calcNaturalCubic(List valueCollection, Field val, Collection<Cubic> cubicCollection) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
public void calcNaturalCubic(List valueCollection, Field val, Collection<Cubic> cubicCollection) throws IllegalArgumentException, IllegalAccessException {
int num = valueCollection.size() - 1;
double[] gamma = new double[num + 1];

View File

@@ -3,6 +3,8 @@ package eu.crushedpixel.replaymod.interpolation;
import eu.crushedpixel.replaymod.utils.ReflectionUtils;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Vector;
@@ -11,7 +13,7 @@ public class GenericSplineInterpolation<T extends KeyframeValue> extends BasicSp
private Field[] fields;
private Vector<T> points;
private Vector<Cubic>[] cubics = new Vector[0];
private List<Vector<Cubic>> cubics = Collections.emptyList();
public GenericSplineInterpolation() {
this.points = new Vector<T>();
@@ -24,10 +26,6 @@ public class GenericSplineInterpolation<T extends KeyframeValue> extends BasicSp
this.fields = fields.toArray(new Field[fields.size()]);
}
public Vector<T> getPoints() {
return points;
}
@Override
public void prepare() {
if(fields.length <= 0) {
@@ -35,12 +33,13 @@ public class GenericSplineInterpolation<T extends KeyframeValue> extends BasicSp
" has to contain at least one Field");
}
if(!points.isEmpty()) {
cubics = new Vector[fields.length];
for(int i=0; i<fields.length; i++) {
cubics[i] = new Vector<Cubic>();
cubics = new ArrayList<Vector<Cubic>>(fields.length);
for (Field field : fields) {
Vector<Cubic> vec = new Vector<Cubic>();
cubics.add(vec);
try {
calcNaturalCubic(points, fields[i], cubics[i]);
} catch(Exception e) {
calcNaturalCubic(points, field, vec);
} catch (Exception e) {
e.printStackTrace();
}
}
@@ -51,15 +50,15 @@ public class GenericSplineInterpolation<T extends KeyframeValue> extends BasicSp
}
public void applyPoint(float position, T toEdit) {
Vector<Cubic> first = cubics[0];
Vector<Cubic> first = cubics.get(0);
position = position * first.size();
int cubicNum = (int) Math.min(cubics[0].size() - 1, position);
int cubicNum = (int) Math.min(first.size() - 1, position);
float cubicPos = (position - cubicNum);
int i = 0;
for(Field f : fields) {
try {
f.set(toEdit, cubics[i].get(cubicNum).eval(cubicPos));
f.set(toEdit, cubics.get(i).get(cubicNum).eval(cubicPos));
} catch(Exception e) {
e.printStackTrace();
}

View File

@@ -157,7 +157,8 @@ public class KeyframeList<K extends KeyframeValue> extends ArrayList<Keyframe<K>
if(first() == null) return null;
if(size() == 1) return first().getValue();
K toApply = (K)first().getValue().newInstance();
@SuppressWarnings("unchecked")
K toApply = (K) first().getValue().newInstance();
if(previousCallLinear != (Boolean)linear) {
interpolation = linear ? new GenericLinearInterpolation<K>() : new GenericSplineInterpolation<K>();

View File

@@ -9,6 +9,6 @@ package eu.crushedpixel.replaymod.interpolation;
*/
public interface KeyframeValue {
public KeyframeValue newInstance();
KeyframeValue newInstance();
}

View File

@@ -17,15 +17,11 @@ public class WindowsUriScheme extends UriScheme {
private void regAdd(String args) throws IOException, InterruptedException {
Process process = Runtime.getRuntime().exec("REG ADD HKCU\\Software\\Classes" + args);
try {
if (process.waitFor() != 0) {
StringBuilderWriter writer = new StringBuilderWriter();
IOUtils.copy(process.getInputStream(), writer);
IOUtils.copy(process.getErrorStream(), writer);
throw new IOException(writer.toString());
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
if (process.waitFor() != 0) {
StringBuilderWriter writer = new StringBuilderWriter();
IOUtils.copy(process.getInputStream(), writer);
IOUtils.copy(process.getErrorStream(), writer);
throw new IOException(writer.toString());
}
}
}

View File

@@ -116,7 +116,7 @@ public class PacketListener extends DataListener {
}
@SuppressWarnings("unchecked")
private byte[] getPacketData(Packet packet) throws IOException {
private byte[] getPacketData(Packet packet) {
if(packet instanceof S0FPacketSpawnMob) {
S0FPacketSpawnMob p = (S0FPacketSpawnMob) packet;
if (p.field_149043_l == null) {

View File

@@ -125,11 +125,7 @@ public class ReplayHandler {
positionKeyframes.clear();
timeKeyframes.clear();
for(Keyframe kf : kfs) {
if(kf.getValue() instanceof AdvancedPosition) {
positionKeyframes.add(kf);
} else if(kf.getValue() instanceof TimestampValue) {
timeKeyframes.add(kf);
}
addKeyframe(kf);
}
fireKeyframesModifyEvent();
@@ -264,17 +260,15 @@ public class ReplayHandler {
Float a = null;
Float b;
for(Keyframe kf : positionKeyframes) {
if(!(kf.getValue() instanceof AdvancedPosition)) continue;
Keyframe<AdvancedPosition> pkf = (Keyframe<AdvancedPosition>)kf;
AdvancedPosition pos = pkf.getValue();
for(Keyframe<AdvancedPosition> kf : positionKeyframes) {
AdvancedPosition pos = kf.getValue();
b = (float)pos.getYaw() % 360;
if(a != null) {
float diff = b-a;
if(Math.abs(diff) > 180) {
b = a - (360 - diff) % 360;
pos.setYaw(b);
pkf.setValue(pos);
kf.setValue(pos);
}
}
a = b;
@@ -283,6 +277,7 @@ public class ReplayHandler {
fireKeyframesModifyEvent();
}
@SuppressWarnings("unchecked")
public static void addKeyframe(Keyframe keyframe) {
if(keyframe.getValue() instanceof AdvancedPosition) {
addPositionKeyframe(keyframe);
@@ -420,12 +415,10 @@ public class ReplayHandler {
PlayerHandler.loadPlayerVisibilityConfiguration(visibility);
//load assets
AssetRepository assets = currentReplayFile.assetRepository().get();
assetRepository = assets;
assetRepository = currentReplayFile.assetRepository().get();
//load custom image objects
CustomObjectRepository objectRepository = currentReplayFile.customImageObjects().get();
customImageObjects = objectRepository;
customImageObjects = currentReplayFile.customImageObjects().get();
if(customImageObjects == null) customImageObjects = new CustomObjectRepository();
ReplayMod.replaySender = new ReplaySender(currentReplayFile, asyncMode);
@@ -578,10 +571,6 @@ public class ReplayHandler {
return customImageObjects.getObjects();
}
public static void addCustomImageObject(CustomImageObject object) {
customImageObjects.getObjects().add(object);
}
public static void setCustomImageObjects(List<CustomImageObject> objects) {
customImageObjects.setObjects(new ArrayList<CustomImageObject>(objects));
}

View File

@@ -192,9 +192,7 @@ public class ReplayProcess {
if(timeLinear == null) {
timeLinear = new GenericLinearInterpolation<TimestampValue>();
for(Keyframe<TimestampValue> kf : ReplayHandler.getTimeKeyframes()) {
if(kf.getValue() instanceof TimestampValue) {
timeLinear.addPoint(kf.getValue());
}
timeLinear.addPoint(kf.getValue());
}
}

View File

@@ -77,11 +77,6 @@ public class ReplaySettings {
return (Boolean) ReplayOptions.linear.getValue();
}
public void setLinearMovement(boolean linear) {
ReplayOptions.linear.setValue(linear);
rewriteSettings();
}
public boolean isLightingEnabled() {
return (Boolean) ReplayOptions.lighting.getValue();
}
@@ -92,15 +87,6 @@ public class ReplaySettings {
rewriteSettings();
}
public boolean getWaitForChunks() {
return (Boolean) RenderOptions.waitForChunks.getValue();
}
public void setWaitForChunks(boolean wait) {
RenderOptions.waitForChunks.setValue(wait);
rewriteSettings();
}
public boolean showPathPreview() { return (Boolean) ReplayOptions.previewPath.getValue(); }
public void setShowPathPreview(boolean show) {

View File

@@ -10,7 +10,6 @@ import java.io.InputStream;
public class SoundHandler {
private final Minecraft mc = Minecraft.getMinecraft();
private final ResourceLocation successSoundLocation = new ResourceLocation("replaymod", "renderSuccess.wav");
public void playRenderSuccessSound() {

View File

@@ -14,10 +14,6 @@ public class ProgressFilter implements StreamFilter {
private ProgressUpdateListener listener;
private float minPerc, maxPerc;
public ProgressFilter(long total, ProgressUpdateListener progressUpdateListener) {
this(total, progressUpdateListener, 0, 1);
}
public ProgressFilter(long total, ProgressUpdateListener progressUpdateListener, float minPerc, float maxPerc) {
this.total = total;

View File

@@ -3,10 +3,6 @@ package eu.crushedpixel.replaymod.timer;
import eu.crushedpixel.replaymod.events.handlers.MinecraftTicker;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Timer;
import org.lwjgl.LWJGLException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
public class ReplayTimer extends Timer {
@@ -36,14 +32,6 @@ public class ReplayTimer extends Timer {
if (timerSpeed == 0) {
try {
MinecraftTicker.runMouseKeyboardTick(Minecraft.getMinecraft());
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (LWJGLException e) {
e.printStackTrace();
} catch (OutOfMemoryError e) {
// Disable passive mode and reset timer speed so we can use the buttons on the OOM screen
passive = false;

View File

@@ -132,7 +132,7 @@ public class ReplayFileIO {
return new PacketData(bb, timestamp);
}
public static Packet deserializePacket(byte[] bytes) throws InstantiationException, IllegalAccessException, IOException {
public static Packet deserializePacket(byte[] bytes) {
try {
ByteBuf bb = Unpooled.wrappedBuffer(bytes);
PacketBuffer pb = new PacketBuffer(bb);
@@ -148,7 +148,7 @@ public class ReplayFileIO {
}
}
public static byte[] serializePacket(Packet packet) throws IOException {
public static byte[] serializePacket(Packet packet) {
ByteBuf bb = Unpooled.buffer();
packetSerializer.encode(EnumConnectionState.PLAY, packet, bb);
bb.readerIndex(0);

View File

@@ -73,9 +73,8 @@ public class VideoRenderer implements RenderInfo {
/**
* Render this video.
* @return {@code true} if rendering was successful, {@code false} if the user aborted rendering (or the window was closed)
* @throws IOException {@link Minecraft#runTick()} can apparently throw these, don't question it!
*/
public boolean renderVideo() throws IOException {
public boolean renderVideo() {
setup();
// Because this might take some time to prepare we'll render the GUI at least once to not confuse the user

View File

@@ -248,11 +248,6 @@ replaymod.gui.settings.interpolation=Path Interpolation
replaymod.gui.settings.pathpreview=Show Path Preview
replaymod.gui.settings.keyframecleancallback=Clear Confirmation
replaymod.gui.settings.videoquality.draft=Draft
replaymod.gui.settings.videoquality.normal=Normal
replaymod.gui.settings.videoquality.good=Good
replaymod.gui.settings.videoquality.best=Best
replaymod.gui.settings.warning.linea=WARNING: Recording settings will be
replaymod.gui.settings.warning.lineb=applied the next time you join a world.