feat: move anchors
This commit is contained in:
parent
fd2a06524e
commit
efc83b6dfa
|
@ -48,19 +48,24 @@ public class NewPoint implements CommandExecutor {
|
||||||
|
|
||||||
public static void addPoint(Location point, World world) {
|
public static void addPoint(Location point, World world) {
|
||||||
Camera.controlPoints.add(point);
|
Camera.controlPoints.add(point);
|
||||||
Camera.broadlog("Point added: " + Camera.prettyLocation(point));
|
|
||||||
ShowCurve.add(point, world);
|
ShowCurve.add(point, world);
|
||||||
|
Camera.broadlog("Point added: " + Camera.prettyLocation(point));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPoint(int index, Location point, World world) {
|
||||||
|
Camera.controlPoints.set(index, point);
|
||||||
|
ShowCurve.set(index, point, world);
|
||||||
|
Camera.broadlog("Point n°" + index + " set: " + Camera.prettyLocation(point));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void add(String[] args) {
|
public static void add(String[] args) {
|
||||||
World world = player.getWorld();
|
World world = player.getWorld();
|
||||||
location = player.getLocation();
|
location = player.getLocation();
|
||||||
|
int n = Camera.controlPoints.size();
|
||||||
|
|
||||||
if (Camera.controlPoints.size() < 4) {
|
if (n < 4) {
|
||||||
addPoint(location, world);
|
addPoint(location, world);
|
||||||
} else {
|
} else {
|
||||||
int n = Camera.controlPoints.size();
|
|
||||||
|
|
||||||
Location P2 = Camera.controlPoints.get(n - 2);
|
Location P2 = Camera.controlPoints.get(n - 2);
|
||||||
Location P3 = Camera.controlPoints.get(n - 1);
|
Location P3 = Camera.controlPoints.get(n - 1);
|
||||||
Location P4 = P3.clone().multiply(2).subtract(P2);
|
Location P4 = P3.clone().multiply(2).subtract(P2);
|
||||||
|
@ -89,10 +94,28 @@ public class NewPoint implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void set(String[] args) {
|
public static void set(String[] args) {
|
||||||
|
World world = player.getWorld();
|
||||||
|
int n = Camera.controlPoints.size();
|
||||||
index = Integer.parseInt(args[1]);
|
index = Integer.parseInt(args[1]);
|
||||||
location = player.getLocation();
|
location = player.getLocation();
|
||||||
Camera.controlPoints.set(index, location);
|
|
||||||
Camera.broadlog("Point n°" + index + " set: " + Camera.prettyLocation(location));
|
if (n <= 4) {
|
||||||
ShowCurve.set(index, location, player.getWorld());
|
setPoint(index, location, world);
|
||||||
|
} else {
|
||||||
|
if (index % 3 == 0) {
|
||||||
|
// Anchor control point
|
||||||
|
location = player.getLocation();
|
||||||
|
Location shift = location.clone().subtract(Camera.controlPoints.get(index));
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
try {
|
||||||
|
setPoint(index + i - 1, Camera.controlPoints.get(index + i - 1).clone().add(shift), world);
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
// First or last anchor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,13 @@ public class ShowCurve implements CommandExecutor {
|
||||||
public static int showTaskID = -1;
|
public static int showTaskID = -1;
|
||||||
|
|
||||||
private static ItemStack initCameraHead() {
|
private static ItemStack initCameraHead() {
|
||||||
ItemStack cameraHead = new ItemStack(Material.PLAYER_HEAD);
|
// ItemStack cameraHead = new ItemStack(Material.PLAYER_HEAD);
|
||||||
SkullMeta skullMeta = (SkullMeta) cameraHead.getItemMeta();
|
// SkullMeta skullMeta = (SkullMeta) cameraHead.getItemMeta();
|
||||||
skullMeta.setOwningPlayer(
|
// skullMeta.setOwningPlayer(
|
||||||
Bukkit.getOfflinePlayer(
|
// Bukkit.getOfflinePlayer(
|
||||||
UUID.fromString("c9560dfb-a792-4226-ad06-db1b6dc40b95")));
|
// UUID.fromString("c9560dfb-a792-4226-ad06-db1b6dc40b95")));
|
||||||
cameraHead.setItemMeta(skullMeta);
|
// cameraHead.setItemMeta(skullMeta);
|
||||||
|
ItemStack cameraHead = new ItemStack(Material.OBSERVER);
|
||||||
return cameraHead;
|
return cameraHead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,14 +114,7 @@ public class ShowCurve implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void set(int index, Location point, World world) {
|
public static void set(int index, Location point, World world) {
|
||||||
ArmorStand as = world.spawn(point, ArmorStand.class);
|
controlPointsArmorStands.get(index).teleport(point);
|
||||||
as.setGravity(false);
|
|
||||||
as.setVisible(false);
|
|
||||||
as.setMarker(true);
|
|
||||||
as.addScoreboardTag("controlPoint");
|
|
||||||
if (showTaskID > 0)
|
|
||||||
as.getEquipment().setHelmet(cameraHead);
|
|
||||||
controlPointsArmorStands.set(index, as).remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rm(int index) {
|
public static void rm(int index) {
|
||||||
|
|
Loading…
Reference in a new issue