mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
PlaySound in volmitsender
This commit is contained in:
parent
7d859661ba
commit
198820d95d
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,15 @@ import org.bukkit.util.BlockVector;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
|
||||
private static final KList<String> randoms = new KList<>(
|
||||
"here",
|
||||
"0,0,0",
|
||||
"0,0",
|
||||
"look",
|
||||
"player:<name>"
|
||||
);
|
||||
|
||||
@Override
|
||||
public KList<Vector> getPossibilities() {
|
||||
KList<Vector> vx = new KList<>();
|
||||
@ -107,6 +116,6 @@ public class VectorHandler implements DecreeParameterHandler<Vector> {
|
||||
|
||||
@Override
|
||||
public String getRandomDefault() {
|
||||
return M.r(0.5) ? "0,0" : "0,0,0";
|
||||
return randoms.getRandom();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user