feat: stay C1 (/point set fully op)
This commit is contained in:
parent
efc83b6dfa
commit
929cdc5967
|
@ -102,9 +102,9 @@ public class NewPoint implements CommandExecutor {
|
|||
if (n <= 4) {
|
||||
setPoint(index, location, world);
|
||||
} else {
|
||||
if (index % 3 == 0) {
|
||||
// Anchor control point
|
||||
location = player.getLocation();
|
||||
switch (index % 3) {
|
||||
case 0:
|
||||
// Anchor point
|
||||
Location shift = location.clone().subtract(Camera.controlPoints.get(index));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
|
@ -113,7 +113,45 @@ public class NewPoint implements CommandExecutor {
|
|||
// First or last anchor
|
||||
}
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
case 1:
|
||||
// Control point after an anchor
|
||||
if (index - 2 >= 0) {
|
||||
// Get anchor-location direction
|
||||
Location anchor = Camera.controlPoints.get(index - 1);
|
||||
double currentDistance = anchor.distance(location);
|
||||
Location currentVect = anchor.clone().subtract(location).multiply(1 / currentDistance);
|
||||
|
||||
// Get anchor-corresponding distance
|
||||
Location correspondingControl = Camera.controlPoints.get(index - 2);
|
||||
double correspondingDistance = anchor.distance(correspondingControl);
|
||||
|
||||
// Keep correcponding at the same distance
|
||||
// but along the anchor-location direction
|
||||
setPoint(index - 2, anchor.clone().add(currentVect.multiply(correspondingDistance)), world);
|
||||
}
|
||||
// Move control point
|
||||
setPoint(index, location, world);
|
||||
break;
|
||||
case 2:
|
||||
// Control point before an anchor
|
||||
if (index + 2 < n) {
|
||||
// Get anchor-location direction
|
||||
Location anchor = Camera.controlPoints.get(index + 1);
|
||||
double currentDistance = anchor.distance(location);
|
||||
Location currentVect = anchor.clone().subtract(location).multiply(1 / currentDistance);
|
||||
|
||||
// Get anchor-corresponding distance
|
||||
Location correspondingControl = Camera.controlPoints.get(index + 2);
|
||||
double correspondingDistance = anchor.distance(correspondingControl);
|
||||
|
||||
// Keep correcponding at the same distance
|
||||
// but along the anchor-location direction
|
||||
setPoint(index + 2, anchor.clone().add(currentVect.multiply(correspondingDistance)), world);
|
||||
}
|
||||
// Move control point
|
||||
setPoint(index, location, world);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,23 +23,10 @@ import org.bukkit.Material;
|
|||
public class ShowCurve implements CommandExecutor {
|
||||
|
||||
public static List<ArmorStand> controlPointsArmorStands = new ArrayList<>();
|
||||
private static ItemStack cameraHead = initCameraHead();
|
||||
private static ItemStack cameraHeadAnchor = new ItemStack(Material.OBSERVER);
|
||||
private static ItemStack cameraHeadControl = new ItemStack(Material.DISPENSER);
|
||||
public static int showTaskID = -1;
|
||||
|
||||
private static ItemStack initCameraHead() {
|
||||
// ItemStack cameraHead = new ItemStack(Material.PLAYER_HEAD);
|
||||
// SkullMeta skullMeta = (SkullMeta) cameraHead.getItemMeta();
|
||||
// skullMeta.setOwningPlayer(
|
||||
// Bukkit.getOfflinePlayer(
|
||||
// UUID.fromString("c9560dfb-a792-4226-ad06-db1b6dc40b95")));
|
||||
// cameraHead.setItemMeta(skullMeta);
|
||||
ItemStack cameraHead = new ItemStack(Material.OBSERVER);
|
||||
return cameraHead;
|
||||
}
|
||||
|
||||
// c9560dfb-a792-4226-ad06-db1b6dc40b95
|
||||
// c9560dfba7924226ad06db1b6dc40b95
|
||||
|
||||
// This method is called, when somebody uses our command
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
@ -52,8 +39,13 @@ public class ShowCurve implements CommandExecutor {
|
|||
|
||||
if (ShowCurve.showTaskID < 0) {
|
||||
// Show control points
|
||||
int i = 0;
|
||||
for (ArmorStand as : controlPointsArmorStands) {
|
||||
as.getEquipment().setHelmet(cameraHead);
|
||||
if (i % 3 == 0)
|
||||
as.getEquipment().setHelmet(cameraHeadAnchor);
|
||||
else
|
||||
as.getEquipment().setHelmet(cameraHeadControl);
|
||||
i++;
|
||||
}
|
||||
|
||||
// Start showing curve
|
||||
|
@ -98,7 +90,10 @@ public class ShowCurve implements CommandExecutor {
|
|||
as.setMarker(true);
|
||||
as.addScoreboardTag("controlPoint");
|
||||
if (showTaskID > 0)
|
||||
as.getEquipment().setHelmet(cameraHead);
|
||||
if ((Camera.controlPoints.size() - 1) % 3 == 0)
|
||||
as.getEquipment().setHelmet(cameraHeadAnchor);
|
||||
else
|
||||
as.getEquipment().setHelmet(cameraHeadControl);
|
||||
controlPointsArmorStands.add(as);
|
||||
}
|
||||
|
||||
|
@ -109,7 +104,10 @@ public class ShowCurve implements CommandExecutor {
|
|||
as.setMarker(true);
|
||||
as.addScoreboardTag("controlPoint");
|
||||
if (showTaskID > 0)
|
||||
as.getEquipment().setHelmet(cameraHead);
|
||||
if ((Camera.controlPoints.size() - 1) % 3 == 0)
|
||||
as.getEquipment().setHelmet(cameraHeadAnchor);
|
||||
else
|
||||
as.getEquipment().setHelmet(cameraHeadControl);
|
||||
controlPointsArmorStands.add(index, as);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue