From 0b82bbd32d9119a40933d59b6ce6d9eefd63804e Mon Sep 17 00:00:00 2001 From: Ultimate <63293118+UltimateBoi@users.noreply.github.com> Date: Sun, 3 Mar 2024 20:45:33 +0000 Subject: [PATCH 1/7] Update Order.java Added play sound once order has been outdated --- src/main/java/dev/meyi/bn/json/Order.java | 31 ++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/meyi/bn/json/Order.java b/src/main/java/dev/meyi/bn/json/Order.java index eaf46b6..72bd39e 100644 --- a/src/main/java/dev/meyi/bn/json/Order.java +++ b/src/main/java/dev/meyi/bn/json/Order.java @@ -1,11 +1,39 @@ package dev.meyi.bn.json; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.util.ResourceLocation; import dev.meyi.bn.BazaarNotifier; import dev.meyi.bn.json.resp.BazaarItem; import dev.meyi.bn.utilities.RenderUtils; public class Order { + public static void playCustomSound(String soundName, float volume, float pitch) { // Horrible implementation placing the code here 😂 sorry. do whatever though + Minecraft mc = Minecraft.getInstance(); + SoundHandler soundHandler = mc.getSoundHandler(); + + ResourceLocation soundLocation = new ResourceLocation("minecraft", soundName); + + soundHandler.play(new CustomSound(soundLocation, volume, pitch, false)); + } + + static class CustomSound extends net.minecraft.client.audio.Sound { + + public CustomSound(ResourceLocation soundLocation, float volume, float pitch, boolean repeat) { + super(soundLocation, volume, pitch, repeat); + } + + @Override + public float getVolume() { + return super.getVolume(); + } + + @Override + public float getPitch() { + return super.getPitch(); + } + } public String product; public int startAmount; @@ -113,6 +141,7 @@ public void updateStatus() { RenderUtils.chatNotification(this, "MATCHED"); } else if (OrderStatus.OUTDATED.equals(newOrderStatus)) { RenderUtils.chatNotification(this, "OUTDATED"); + playCustomSound("entity.player.levelup", 1.0f, 1.0f); // Plays sound once order is outdated. TODO: Maybe make toggleable (later) } this.orderStatus = newOrderStatus; } @@ -129,4 +158,4 @@ public enum OrderType { this.longName = longName; } } -} \ No newline at end of file +} From c03b9f0c32b1acd7104e7384799d48e180b5bcc4 Mon Sep 17 00:00:00 2001 From: Ultimate Date: Mon, 4 Mar 2024 23:57:50 +0000 Subject: [PATCH 2/7] Fixed --- .../dev/meyi/bn/config/Configuration.java | 5 ++++ src/main/java/dev/meyi/bn/json/Order.java | 29 ++----------------- .../java/dev/meyi/bn/utilities/Defaults.java | 1 + .../dev/meyi/bn/utilities/RenderUtils.java | 4 +++ 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/main/java/dev/meyi/bn/config/Configuration.java b/src/main/java/dev/meyi/bn/config/Configuration.java index 70d45ff..3be137a 100644 --- a/src/main/java/dev/meyi/bn/config/Configuration.java +++ b/src/main/java/dev/meyi/bn/config/Configuration.java @@ -66,6 +66,11 @@ public Configuration() { ) public boolean showChatMessages = Defaults.SEND_CHAT_MESSAGES; + @JsonName("sendSound") + @Switch(name = "Send Sound for Outdated Orders") + + public boolean sendSound = Defaults.SEND_SOUND; + @JsonName("collectionCheck") @Switch(name = "Collection checks", category = "Crafting Module", diff --git a/src/main/java/dev/meyi/bn/json/Order.java b/src/main/java/dev/meyi/bn/json/Order.java index 72bd39e..52a01fe 100644 --- a/src/main/java/dev/meyi/bn/json/Order.java +++ b/src/main/java/dev/meyi/bn/json/Order.java @@ -9,32 +9,6 @@ import dev.meyi.bn.utilities.RenderUtils; public class Order { - public static void playCustomSound(String soundName, float volume, float pitch) { // Horrible implementation placing the code here 😂 sorry. do whatever though - Minecraft mc = Minecraft.getInstance(); - SoundHandler soundHandler = mc.getSoundHandler(); - - ResourceLocation soundLocation = new ResourceLocation("minecraft", soundName); - - soundHandler.play(new CustomSound(soundLocation, volume, pitch, false)); - } - - static class CustomSound extends net.minecraft.client.audio.Sound { - - public CustomSound(ResourceLocation soundLocation, float volume, float pitch, boolean repeat) { - super(soundLocation, volume, pitch, repeat); - } - - @Override - public float getVolume() { - return super.getVolume(); - } - - @Override - public float getPitch() { - return super.getPitch(); - } - } - public String product; public int startAmount; public double pricePerUnit; @@ -141,7 +115,8 @@ public void updateStatus() { RenderUtils.chatNotification(this, "MATCHED"); } else if (OrderStatus.OUTDATED.equals(newOrderStatus)) { RenderUtils.chatNotification(this, "OUTDATED"); - playCustomSound("entity.player.levelup", 1.0f, 1.0f); // Plays sound once order is outdated. TODO: Maybe make toggleable (later) + RenderUtils.sendSound(); + } this.orderStatus = newOrderStatus; } diff --git a/src/main/java/dev/meyi/bn/utilities/Defaults.java b/src/main/java/dev/meyi/bn/utilities/Defaults.java index 1cfb2ac..5e325d2 100644 --- a/src/main/java/dev/meyi/bn/utilities/Defaults.java +++ b/src/main/java/dev/meyi/bn/utilities/Defaults.java @@ -19,6 +19,7 @@ public class Defaults { public static final boolean PROFIT_PER_MIL = true; public static final boolean COLLECTION_CHECKING = false; public static final boolean SEND_CHAT_MESSAGES = true; + public static final boolean SEND_SOUND = false; public static final boolean USE_BUY_ORDERS = true; public static final boolean SUGGESTION_SHOW_ENCHANTMENTS = true; public static final boolean BANK_RAW_DIFFERENCE = false; diff --git a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java index a315f57..9db9022 100644 --- a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java +++ b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java @@ -80,6 +80,10 @@ public static int getStringWidth(String string) { return fontRenderer.getStringWidth(string); } + public static void sendSound() { + if (!BazaarNotifier.config.sendSound) return; + Minecraft.getMinecraft().thePlayer.playSound("ENTITY_PLAYER_LEVELUP", 1.0F, 1.0F); + } public static void chatNotification(Order order, String notification) { if (!BazaarNotifier.config.showChatMessages) { return; From b543a618d18ac8ca31ce763ff9f954d61d53f687 Mon Sep 17 00:00:00 2001 From: Ultimate Date: Tue, 5 Mar 2024 00:16:41 +0000 Subject: [PATCH 3/7] Fix 2 --- src/main/java/dev/meyi/bn/json/Order.java | 5 +---- src/main/java/dev/meyi/bn/utilities/RenderUtils.java | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/meyi/bn/json/Order.java b/src/main/java/dev/meyi/bn/json/Order.java index 52a01fe..5306ecf 100644 --- a/src/main/java/dev/meyi/bn/json/Order.java +++ b/src/main/java/dev/meyi/bn/json/Order.java @@ -1,12 +1,9 @@ package dev.meyi.bn.json; -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.SoundHandler; -import net.minecraft.util.ResourceLocation; - import dev.meyi.bn.BazaarNotifier; import dev.meyi.bn.json.resp.BazaarItem; import dev.meyi.bn.utilities.RenderUtils; +import net.minecraft.client.Minecraft; public class Order { public String product; diff --git a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java index 9db9022..4d3e690 100644 --- a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java +++ b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java @@ -82,7 +82,7 @@ public static int getStringWidth(String string) { public static void sendSound() { if (!BazaarNotifier.config.sendSound) return; - Minecraft.getMinecraft().thePlayer.playSound("ENTITY_PLAYER_LEVELUP", 1.0F, 1.0F); + Minecraft.getMinecraft().thePlayer.playSound("mob.horse.donkey.death", 2.0F, 1.0F); } public static void chatNotification(Order order, String notification) { if (!BazaarNotifier.config.showChatMessages) { From 92a66ec2b93212a194c7e5f66b6bd706c18ad12e Mon Sep 17 00:00:00 2001 From: Ultimate Date: Tue, 5 Mar 2024 00:23:34 +0000 Subject: [PATCH 4/7] Update RenderUtils.java --- src/main/java/dev/meyi/bn/utilities/RenderUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java index 4d3e690..756145a 100644 --- a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java +++ b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java @@ -82,7 +82,7 @@ public static int getStringWidth(String string) { public static void sendSound() { if (!BazaarNotifier.config.sendSound) return; - Minecraft.getMinecraft().thePlayer.playSound("mob.horse.donkey.death", 2.0F, 1.0F); + Minecraft.getMinecraft().thePlayer.playSound("mob.horse.donkey.death", 2.0F, 1.0F); // Todo: add option for which sound to play (possibly) } public static void chatNotification(Order order, String notification) { if (!BazaarNotifier.config.showChatMessages) { From 09868d7d2a5e75b1545ab5e2886844380ec64aea Mon Sep 17 00:00:00 2001 From: Ultimate Date: Mon, 25 Mar 2024 20:34:32 +0000 Subject: [PATCH 5/7] Removed import net.minecraft.client.Minecraft; --- src/main/java/dev/meyi/bn/json/Order.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/dev/meyi/bn/json/Order.java b/src/main/java/dev/meyi/bn/json/Order.java index 5306ecf..5fd56f8 100644 --- a/src/main/java/dev/meyi/bn/json/Order.java +++ b/src/main/java/dev/meyi/bn/json/Order.java @@ -3,7 +3,6 @@ import dev.meyi.bn.BazaarNotifier; import dev.meyi.bn.json.resp.BazaarItem; import dev.meyi.bn.utilities.RenderUtils; -import net.minecraft.client.Minecraft; public class Order { public String product; From df06864f56e62b225f3f0b6798d4e14ce6d25f01 Mon Sep 17 00:00:00 2001 From: Ultimate <63293118+UltimateBoi@users.noreply.github.com> Date: Sun, 2 Jun 2024 02:15:42 +0100 Subject: [PATCH 6/7] Update README.md Spelling error on the link that caused a 404 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3bb5c33..9d94204 100644 --- a/README.md +++ b/README.md @@ -28,4 +28,4 @@ Join the discord server: https://discord.com/invite/wjpJSVSwvD
-[License](https://github.com/symt/BazaarNotifier/blob/master/license.txt) | [Site](https://meyi.dev) +[License](https://github.com/symt/BazaarNotifier/blob/master/LICENSE.txt) | [Site](https://meyi.dev) From 2f8e1d453cf9e90a6bf5e50622490c768de7214f Mon Sep 17 00:00:00 2001 From: symt <28537235+symt@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:25:26 -0500 Subject: [PATCH 7/7] minor refactoring --- src/main/java/dev/meyi/bn/json/Order.java | 3 +-- src/main/java/dev/meyi/bn/utilities/RenderUtils.java | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/dev/meyi/bn/json/Order.java b/src/main/java/dev/meyi/bn/json/Order.java index 5fd56f8..b48250f 100644 --- a/src/main/java/dev/meyi/bn/json/Order.java +++ b/src/main/java/dev/meyi/bn/json/Order.java @@ -111,8 +111,7 @@ public void updateStatus() { RenderUtils.chatNotification(this, "MATCHED"); } else if (OrderStatus.OUTDATED.equals(newOrderStatus)) { RenderUtils.chatNotification(this, "OUTDATED"); - RenderUtils.sendSound(); - + RenderUtils.sendSound(); // might be loud if multiple become oudated at the same time } this.orderStatus = newOrderStatus; } diff --git a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java index 756145a..ad7989d 100644 --- a/src/main/java/dev/meyi/bn/utilities/RenderUtils.java +++ b/src/main/java/dev/meyi/bn/utilities/RenderUtils.java @@ -81,8 +81,10 @@ public static int getStringWidth(String string) { } public static void sendSound() { - if (!BazaarNotifier.config.sendSound) return; - Minecraft.getMinecraft().thePlayer.playSound("mob.horse.donkey.death", 2.0F, 1.0F); // Todo: add option for which sound to play (possibly) + if (BazaarNotifier.config.sendSound) { + Minecraft.getMinecraft().thePlayer.playSound("mob.horse.donkey.death", 2.0F, 1.0F); + // TODO: add option for which sound to play (possibly) + } } public static void chatNotification(Order order, String notification) { if (!BazaarNotifier.config.showChatMessages) {