diff --git a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectDust.java b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectDust.java index 247fe232a..f77cbc910 100644 --- a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectDust.java +++ b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectDust.java @@ -52,7 +52,7 @@ public class CommandIrisObjectDust extends MortarCommand { } sender.player().getInventory().addItem(WandSVC.createDust()); - sender.player().playSound(sender.player().getLocation(), Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f); + sender.playSound(Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f); return true; } diff --git a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectWand.java b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectWand.java index d8c476c91..2d938e120 100644 --- a/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectWand.java +++ b/src/main/java/com/volmit/iris/core/command/object/CommandIrisObjectWand.java @@ -53,7 +53,7 @@ public class CommandIrisObjectWand extends MortarCommand { } sender.player().getInventory().addItem(WandSVC.createWand()); - sender.player().playSound(sender.player().getLocation(), Sound.ITEM_ARMOR_EQUIP_NETHERITE, 1f, 1.5f); + sender.playSound(Sound.ITEM_ARMOR_EQUIP_NETHERITE, 1f, 1.5f); return true; } diff --git a/src/main/java/com/volmit/iris/core/decrees/DecObject.java b/src/main/java/com/volmit/iris/core/decrees/DecObject.java index 5cc763a9b..dfc7af2b2 100644 --- a/src/main/java/com/volmit/iris/core/decrees/DecObject.java +++ b/src/main/java/com/volmit/iris/core/decrees/DecObject.java @@ -1,20 +1,30 @@ package com.volmit.iris.core.decrees; +import com.volmit.iris.core.service.WandSVC; import com.volmit.iris.engine.object.objects.IrisObject; +import com.volmit.iris.engine.object.objects.IrisObjectPlacement; +import com.volmit.iris.engine.object.objects.IrisObjectPlacementScaleInterpolator; +import com.volmit.iris.engine.object.objects.IrisObjectRotation; +import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.decree.DecreeExecutor; import com.volmit.iris.util.decree.DecreeOrigin; import com.volmit.iris.util.decree.annotations.Decree; import com.volmit.iris.util.decree.annotations.Param; +import com.volmit.iris.util.format.C; +import com.volmit.iris.util.math.Direction; import com.volmit.iris.util.scheduling.Queue; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.data.BlockData; +import org.bukkit.inventory.ItemStack; import java.text.NumberFormat; import java.util.*; import java.util.stream.Collectors; -@Decree(name = "object", origin = DecreeOrigin.PLAYER, description = "Iris object manipulation") +@Decree(name = "object", origin = DecreeOrigin.PLAYER, studio = true, description = "Iris object manipulation") public class DecObject implements DecreeExecutor { @Decree(description = "Check the composition of an object") @@ -83,4 +93,114 @@ public class DecObject implements DecreeExecutor { } } } + + @Decree(description = "Get a powder that reveals objects", studio = true) + public void dust() { + player().getInventory().addItem(WandSVC.createDust()); + sender().playSound(Sound.AMBIENT_SOUL_SAND_VALLEY_ADDITIONS, 1f, 1.5f); + } + + @Decree(description = "Contract a selection based on your looking direction", aliases = "-") + public void contract( + @Param(description = "The amount to inset by", defaultValue = "1") + int amount + ){ + if (!WandSVC.isHoldingWand(player())) { + sender().sendMessage("Hold your wand."); + return; + } + + + Location[] b = WandSVC.getCuboid(player().getInventory().getItemInMainHand()); + Location a1 = b[0].clone(); + Location a2 = b[1].clone(); + Cuboid cursor = new Cuboid(a1, a2); + Direction d = Direction.closest(player().getLocation().getDirection()).reverse(); + assert d != null; + cursor = cursor.expand(d, -amount); + b[0] = cursor.getLowerNE(); + b[1] = cursor.getUpperSW(); + player().getInventory().setItemInMainHand(WandSVC.createWand(b[0], b[1])); + player().updateInventory(); + sender().playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 1f, 0.55f); + } + + @Decree(description = "Set point 1 to look", aliases = "p1") + public void position1( + @Param(description = "Whether to use your current position, or where you look", defaultValue = "true") + boolean here + ){ + if (!WandSVC.isHoldingWand(player())) { + sender().sendMessage("Ready your Wand."); + return; + } + + ItemStack wand = player().getInventory().getItemInMainHand(); + + if (WandSVC.isWand(wand)) { + Location[] g = WandSVC.getCuboid(wand); + + if (!here) { + // TODO: WARNING HEIGHT + g[1] = player().getTargetBlock(null, 256).getLocation().clone(); + } else { + g[1] = player().getLocation().getBlock().getLocation().clone().add(0, -1, 0); + } + player().setItemInHand(WandSVC.createWand(g[0], g[1])); + } + } + + @Decree(description = "Set point 2 to look", aliases = "p2") + public void position2( + @Param(description = "Whether to use your current position, or where you look", defaultValue = "true") + boolean here + ){ + if (!WandSVC.isHoldingWand(player())) { + sender().sendMessage("Ready your Wand."); + return; + } + + ItemStack wand = player().getInventory().getItemInMainHand(); + + if (WandSVC.isWand(wand)) { + Location[] g = WandSVC.getCuboid(wand); + + if (!here) { + // TODO: WARNING HEIGHT + g[0] = player().getTargetBlock(null, 256).getLocation().clone(); + } else { + g[0] = player().getLocation().getBlock().getLocation().clone().add(0, -1, 0); + } + player().setItemInHand(WandSVC.createWand(g[0], g[1])); + } + } + + @Decree(description = "Paste an object") + public void paste( + @Param(description = "The object to paste") + IrisObject object, + @Param(description = "Whether or not to edit the object (need to hold wand)", defaultValue = "false") + boolean edit, + @Param(description = "The amount of degrees to rotate by", defaultValue = "0") + int rotate, + @Param(description = "The factor by which to scale the object placement", defaultValue = "1") + double scale, + @Param(description = "The scale interpolator to use", defaultValue = "none") + IrisObjectPlacementScaleInterpolator interpolator + ){ + double maxScale = getMaxScale(object); + if (scale < maxScale){ + sender().sendMessage(C.YELLOW + "Indicated scale exceeds maximum. Downscaled to maximum: " + maxScale); + scale = maxScale; + } + + IrisObjectPlacement placement = new IrisObjectPlacement(); + placement.setRotation(IrisObjectRotation.of(0, rotate, 0)); + sender().player().getWorld().playSound(sender().player().getLocation(), Sound.BLOCK_ENCHANTMENT_TABLE_USE, 1f, 1.5f); + + } + + private double getMaxScale(IrisObject object){ + return Double.max(10 - object.getBlocks().size() / 10000d, 1); + } } diff --git a/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java b/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java index f99f55d2a..64550b482 100644 --- a/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java +++ b/src/main/java/com/volmit/iris/util/decree/handlers/VectorHandler.java @@ -33,6 +33,15 @@ import org.bukkit.util.BlockVector; import org.bukkit.util.Vector; public class VectorHandler implements DecreeParameterHandler { + + private static final KList randoms = new KList<>( + "here", + "0,0,0", + "0,0", + "look", + "player:" + ); + @Override public KList getPossibilities() { KList vx = new KList<>(); @@ -107,6 +116,6 @@ public class VectorHandler implements DecreeParameterHandler { @Override public String getRandomDefault() { - return M.r(0.5) ? "0,0" : "0,0,0"; + return randoms.getRandom(); } } diff --git a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java index c5fb3e30d..d3f5decdf 100644 --- a/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java +++ b/src/main/java/com/volmit/iris/util/plugin/MortarCommand.java @@ -73,7 +73,7 @@ public abstract class MortarCommand implements ICommand { } if (sender.isPlayer() && IrisSettings.get().getGeneral().isCommandSounds()) { - sender.player().playSound(sender.player().getLocation(), Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f); + sender.playSound(Sound.ENTITY_ITEM_FRAME_ROTATE_ITEM, 0.25f, 1.7f); } return v; diff --git a/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java b/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java index 504f3a381..b211bc62d 100644 --- a/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java +++ b/src/main/java/com/volmit/iris/util/plugin/VolmitSender.java @@ -33,6 +33,7 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.title.Title; import org.bukkit.Server; +import org.bukkit.Sound; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.permissions.Permission; @@ -473,4 +474,10 @@ public class VolmitSender implements CommandSender { sendMessage(i.getPath() + "()"); } } + + public void playSound(Sound sound, float volume, float pitch) { + if (isPlayer()) { + player().playSound(player().getLocation(), sound, volume, pitch); + } + } }