diff options
author | Florian Rinke <develop@torui.de> | 2021-10-11 20:55:06 +0200 |
---|---|---|
committer | Florian Rinke <develop@torui.de> | 2021-10-11 20:55:06 +0200 |
commit | fc4baf800cb5526350a98eadda0ce70e93f24bc6 (patch) | |
tree | c8d73235c971a342cb4c5a1d4b3182a073180ecd /src | |
parent | 3e28db2478b08d54cdf63ddec86b4446e41ff6b2 (diff) | |
download | COFL-fc4baf800cb5526350a98eadda0ce70e93f24bc6.tar.gz COFL-fc4baf800cb5526350a98eadda0ce70e93f24bc6.tar.bz2 COFL-fc4baf800cb5526350a98eadda0ce70e93f24bc6.zip |
update PlaySound
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/torui/coflsky/CoflSky.java | 2 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/CoflSkyCommand.java | 20 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/WSCommandHandler.java | 11 | ||||
-rw-r--r-- | src/main/java/de/torui/coflsky/core/SoundCommand.java | 27 |
4 files changed, 53 insertions, 7 deletions
diff --git a/src/main/java/de/torui/coflsky/CoflSky.java b/src/main/java/de/torui/coflsky/CoflSky.java index 85d05b6..1ff879e 100644 --- a/src/main/java/de/torui/coflsky/CoflSky.java +++ b/src/main/java/de/torui/coflsky/CoflSky.java @@ -21,7 +21,7 @@ import net.minecraftforge.fml.relauncher.Side; public class CoflSky { public static final String MODID = "CoflSky"; - public static final String VERSION = "1.1-Alpha"; + public static final String VERSION = "1.2-Alpha"; public static WSClientWrapper Wrapper; public static KeyBinding[] keyBindings; diff --git a/src/main/java/de/torui/coflsky/CoflSkyCommand.java b/src/main/java/de/torui/coflsky/CoflSkyCommand.java index 7eacc16..f35be3c 100644 --- a/src/main/java/de/torui/coflsky/CoflSkyCommand.java +++ b/src/main/java/de/torui/coflsky/CoflSkyCommand.java @@ -1,5 +1,6 @@ package de.torui.coflsky; +import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -7,6 +8,8 @@ import de.torui.coflsky.core.Command; import de.torui.coflsky.core.CommandType; import de.torui.coflsky.core.StringCommand; import de.torui.coflsky.minecraft_integration.CoflSessionManager; +import de.torui.coflsky.minecraft_integration.CoflSessionManager.CoflSession; +import de.torui.coflsky.minecraft_integration.PlayerDataProvider; import de.torui.coflsky.websocket.WSClient; import net.minecraft.client.Minecraft; import net.minecraft.command.CommandBase; @@ -72,7 +75,7 @@ public class CoflSkyCommand extends CommandBase { 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()); - WSCommandHandler.HandleCommand(new Command(CommandType.PlaySound, "\"minecraft:random.explode\""), sender.getCommandSenderEntity()); + WSCommandHandler.HandleCommand(new Command(CommandType.PlaySound, "{\"name\":\"random.orb\",\"pitch\":0.5}"), sender.getCommandSenderEntity()); break; case "callback": CallbackCommand(args); @@ -111,7 +114,20 @@ public class CoflSkyCommand extends CommandBase { String version = System.getProperty("java.version"); String detailedVersion = System.getProperty("java.vm.version"); - return vendor + " " + name + " " + version + " " + detailedVersion + "|Connection = " + (CoflSky.Wrapper!=null?CoflSky.Wrapper.GetStatus():"UNINITIALIZED_WRAPPER"); + String status = vendor + " " + name + " " + version + " " + detailedVersion + "|Connection = " + (CoflSky.Wrapper!=null?CoflSky.Wrapper.GetStatus():"UNINITIALIZED_WRAPPER"); + try { + status += " uri=" + CoflSky.Wrapper.socket.uri.toString(); + } catch(NullPointerException npe) {} + + + try { + CoflSession session = CoflSessionManager.GetCoflSession(PlayerDataProvider.getUsername()); + String sessionString = WSClient.gson.toJson(session); + status += " session=" + sessionString; + } catch (IOException e) { + } + + return status; } public void CommandNotRecognized(String[] args, ICommandSender sender) { diff --git a/src/main/java/de/torui/coflsky/WSCommandHandler.java b/src/main/java/de/torui/coflsky/WSCommandHandler.java index dd74d87..4dbb500 100644 --- a/src/main/java/de/torui/coflsky/WSCommandHandler.java +++ b/src/main/java/de/torui/coflsky/WSCommandHandler.java @@ -1,6 +1,7 @@ package de.torui.coflsky; import de.torui.coflsky.core.Command; +import de.torui.coflsky.core.SoundCommand; import de.torui.coflsky.core.WriteToChatCommand; import de.torui.coflsky.websocket.WSClient; import net.minecraft.client.Minecraft; @@ -37,8 +38,10 @@ public class WSCommandHandler { break; case PlaySound: PlaySound(cmd, sender); + break; case ChatMessage: ChatMessage(cmd); + break; default: break; } @@ -48,14 +51,14 @@ public class WSCommandHandler { private static void PlaySound(Command cmd, Entity sender) { - // Minecraft.getMinecraft().theWorld.playSoundAtEntity(sender, - // "random.explode",1f, 1f); - + SoundCommand sc = WSClient.gson.fromJson(cmd.getData(), SoundCommand.class); + SoundHandler handler = Minecraft.getMinecraft().getSoundHandler(); // random.explode PositionedSoundRecord psr = PositionedSoundRecord - .create(new ResourceLocation(WSClient.gson.fromJson(cmd.getData(), String.class))); + .create(new ResourceLocation(sc.Name), sc.Pitch); + handler.playSound(psr); } diff --git a/src/main/java/de/torui/coflsky/core/SoundCommand.java b/src/main/java/de/torui/coflsky/core/SoundCommand.java new file mode 100644 index 0000000..bdba82d --- /dev/null +++ b/src/main/java/de/torui/coflsky/core/SoundCommand.java @@ -0,0 +1,27 @@ +package de.torui.coflsky.core; + +import com.google.gson.annotations.SerializedName; + +public class SoundCommand { + @SerializedName("name") + public String Name; + + @SerializedName("pitch") + public float Pitch; + + + + public SoundCommand() { + super(); + } + + + + public SoundCommand(String name, float pitch) { + super(); + Name = name; + Pitch = pitch; + } + + +} |