Add first person spectator keyframes to simplepathing

This commit is contained in:
johni0702
2016-08-01 22:50:48 +02:00
parent de6e05d0f8
commit 36c973d13a
8 changed files with 233 additions and 219 deletions

View File

@@ -50,7 +50,9 @@ public class CameraProperties extends AbstractPropertyGroup {
@Override
public void applyToGame(Triple<Double, Double, Double> value, @NonNull Object replayHandler) {
((ReplayHandler) replayHandler).getCameraEntity().setCameraPosition(value.getLeft(), value.getMiddle(), value.getRight());
ReplayHandler handler = ((ReplayHandler) replayHandler);
handler.spectateCamera();
handler.getCameraEntity().setCameraPosition(value.getLeft(), value.getMiddle(), value.getRight());
}
@Override
@@ -86,7 +88,9 @@ public class CameraProperties extends AbstractPropertyGroup {
@Override
public void applyToGame(Triple<Float, Float, Float> value, @NonNull Object replayHandler) {
((ReplayHandler) replayHandler).getCameraEntity().setCameraRotation(value.getLeft(), value.getMiddle(), value.getRight());
ReplayHandler handler = ((ReplayHandler) replayHandler);
handler.spectateCamera();
handler.getCameraEntity().setCameraRotation(value.getLeft(), value.getMiddle(), value.getRight());
}
@Override

View File

@@ -0,0 +1,51 @@
package com.replaymod.pathing.properties;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.replaymod.replay.ReplayHandler;
import com.replaymod.replaystudio.pathing.property.AbstractProperty;
import com.replaymod.replaystudio.pathing.property.PropertyPart;
import com.replaymod.replaystudio.pathing.property.PropertyParts;
import lombok.NonNull;
import net.minecraft.entity.Entity;
import net.minecraft.world.World;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
/**
* Property for the camera spectating an entity.
*/
public class SpectatorProperty extends AbstractProperty<Integer> {
public static final SpectatorProperty PROPERTY = new SpectatorProperty();
public final PropertyPart<Integer> ENTITY_ID = new PropertyParts.ForInteger(this, false);
private SpectatorProperty() {
super("spectate", "replaymod.gui.playeroverview.spectate", null, -1);
}
@Override
public Collection<PropertyPart<Integer>> getParts() {
return Collections.singletonList(ENTITY_ID);
}
@Override
public void applyToGame(Integer value, @NonNull Object replayHandler) {
ReplayHandler handler = ((ReplayHandler) replayHandler);
World world = handler.getCameraEntity().getEntityWorld();
// Lookup entity by id, returns null if an entity with the id does not exists
Entity target = world.getEntityByID(value);
// Spectate entity, when called with null, returns to camera
handler.spectateEntity(target);
}
@Override
public void toJson(JsonWriter writer, Integer value) throws IOException {
writer.value(value);
}
@Override
public Integer fromJson(JsonReader reader) throws IOException {
return reader.nextInt();
}
}