aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorFlorian Rinke <develop@torui.de>2021-10-02 09:57:38 +0200
committerFlorian Rinke <develop@torui.de>2021-10-02 09:57:38 +0200
commit95200b244614e946226828f1924f368add400332 (patch)
tree208e204d09224926da3bf4a8369630e43b3c8e38 /src/main
parentd90d562d1b02ed042b7adf92ce56fe1f5a8592ac (diff)
downloadCOFL-95200b244614e946226828f1924f368add400332.tar.gz
COFL-95200b244614e946226828f1924f368add400332.tar.bz2
COFL-95200b244614e946226828f1924f368add400332.zip
added PlaySound #7. Needs Testing
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/torui/coflsky/CoflSkyCommand.java5
-rw-r--r--src/main/java/de/torui/coflsky/WSCommandHandler.java19
-rw-r--r--src/main/java/de/torui/coflsky/core/CommandType.java4
3 files changed, 24 insertions, 4 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSkyCommand.java b/src/main/java/de/torui/coflsky/CoflSkyCommand.java
index 1a63ce8..6b8ae07 100644
--- a/src/main/java/de/torui/coflsky/CoflSkyCommand.java
+++ b/src/main/java/de/torui/coflsky/CoflSkyCommand.java
@@ -72,10 +72,11 @@ public class CoflSkyCommand extends CommandBase {
.setChatStyle(new ChatStyle().setChatClickEvent(new ClickEvent(Action.RUN_COMMAND, "/cofl start")))
);
break;
- //case "debug":
+ case "debug":
// WSCommandHandler.HandleCommand(new Command(CommandType.Execute, "/me hewwo"), sender.getCommandSenderEntity());
// WSCommandHandler.HandleCommand(new Command(CommandType.WriteToChat, "{ \"text\": \"Clickable Texts are fun\", \"onClick\": \"me Hello World\"}"), sender.getCommandSenderEntity());
- // break;
+ WSCommandHandler.HandleCommand(new Command(CommandType.PlaySound, "random.explode"), sender.getCommandSenderEntity());
+ break;
case "callback":
CallbackCommand(args);
break;
diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java
index 8eb1a78..03dd686 100644
--- a/src/main/java/de/torui/coflsky/WSCommandHandler.java
+++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java
@@ -4,6 +4,13 @@ import de.torui.coflsky.core.Command;
import de.torui.coflsky.core.WriteToChatCommand;
import de.torui.coflsky.websocket.WSClient;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.ISound;
+import net.minecraft.client.audio.PositionedSound;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.client.audio.SoundCategory;
+import net.minecraft.client.audio.SoundEventAccessorComposite;
+import net.minecraft.client.audio.SoundHandler;
+import net.minecraft.client.audio.SoundManager;
import net.minecraft.command.ICommandManager;
import net.minecraft.entity.Entity;
import net.minecraft.event.ClickEvent;
@@ -12,6 +19,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.IChatComponent;
+import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.sound.SoundEvent;
@@ -26,6 +34,8 @@ public class WSCommandHandler {
case Execute:
Execute(cmd, sender);
break;
+ case PlaySound:
+ PlaySound(cmd, sender);
default:
break;
}
@@ -34,7 +44,14 @@ public class WSCommandHandler {
}
private static void PlaySound(Command cmd, Entity sender) {
-
+
+ //Minecraft.getMinecraft().theWorld.playSoundAtEntity(sender, "random.explode",1f, 1f);
+
+ SoundHandler handler = Minecraft.getMinecraft().getSoundHandler();
+
+ //random.explode
+ PositionedSoundRecord psr = PositionedSoundRecord.create(new ResourceLocation(cmd.getData()));
+ handler.playSound(psr);
}
private static void Execute(Command cmd, Entity sender) {
diff --git a/src/main/java/de/torui/coflsky/core/CommandType.java b/src/main/java/de/torui/coflsky/core/CommandType.java
index a6657a9..2771470 100644
--- a/src/main/java/de/torui/coflsky/core/CommandType.java
+++ b/src/main/java/de/torui/coflsky/core/CommandType.java
@@ -13,5 +13,7 @@ public enum CommandType {
TokenLogin,
@SerializedName("tokenLogin")
- Clicked;
+ Clicked,
+ @SerializedName("playSound")
+ PlaySound;
}