Created @Interpolate annotation for Interpolators to know which fields to interpolate (instead of all public fields)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import eu.crushedpixel.replaymod.interpolation.Interpolate;
|
||||
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -8,6 +9,7 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class Point extends KeyframeValue {
|
||||
|
||||
@Interpolate
|
||||
public double x, y;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import eu.crushedpixel.replaymod.interpolation.Interpolate;
|
||||
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -14,7 +15,9 @@ import net.minecraft.entity.Entity;
|
||||
@EqualsAndHashCode(callSuper=true)
|
||||
public class Position extends KeyframeValue {
|
||||
|
||||
@Interpolate
|
||||
public double x, y, z;
|
||||
@Interpolate
|
||||
public double pitch, yaw, roll;
|
||||
|
||||
private Integer spectatedEntityID;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.holders;
|
||||
|
||||
import eu.crushedpixel.replaymod.interpolation.Interpolate;
|
||||
import eu.crushedpixel.replaymod.interpolation.KeyframeValue;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -8,6 +9,7 @@ import lombok.NoArgsConstructor;
|
||||
@NoArgsConstructor
|
||||
public class TimestampValue extends KeyframeValue {
|
||||
|
||||
@Interpolate
|
||||
public double value;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.interpolation;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,7 +22,7 @@ public class GenericLinearInterpolation<T extends KeyframeValue> implements Inte
|
||||
|
||||
List<Field> fields = new ArrayList<Field>();
|
||||
for(Field f : point.getClass().getDeclaredFields()) {
|
||||
if(Modifier.isPublic(f.getModifiers())) {
|
||||
if(f.isAnnotationPresent(Interpolate.class)) {
|
||||
fields.add(f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package eu.crushedpixel.replaymod.interpolation;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
@@ -22,7 +21,7 @@ public class GenericSplineInterpolation<T extends KeyframeValue> extends BasicSp
|
||||
|
||||
List<Field> fields = new ArrayList<Field>();
|
||||
for(Field f : point.getClass().getDeclaredFields()) {
|
||||
if(Modifier.isPublic(f.getModifiers())) {
|
||||
if(f.isAnnotationPresent(Interpolate.class)) {
|
||||
fields.add(f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package eu.crushedpixel.replaymod.interpolation;
|
||||
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Interpolate {
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package eu.crushedpixel.replaymod.interpolation;
|
||||
|
||||
/**
|
||||
* An abstract class that GenericSplineInterpolation can process.
|
||||
* Subclasses simply have to declare at least one <b>public</b> double field,
|
||||
* Subclasses simply have to annotate at least one field with @Interpolate,
|
||||
* and the GenericSplineInterpolation will interpolate these.
|
||||
* <br><br>
|
||||
* It is recommended for KeyframeValue subclasses to have a @NoArgsConstructor annotation.
|
||||
|
||||
Reference in New Issue
Block a user