Skip to content

Commit 6d5b0ea

Browse files
committed
option to mute selling sounds oh and half complete boss stuff ig
1 parent ef3c1b6 commit 6d5b0ea

File tree

11 files changed

+222
-10
lines changed

11 files changed

+222
-10
lines changed

src/main/java/dev/lycanea/mwonmod/Config.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ public class Config {
7575
@SerialEntry
7676
public boolean codespaceHider = true;
7777

78+
@TickBox
79+
@AutoGen(category = "QOL", group = "Misc")
80+
@SerialEntry
81+
public boolean muteSellingSound = true;
82+
7883
//Auction
7984

8085
@TickBox

src/main/java/dev/lycanea/mwonmod/Mwonmod.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import net.minecraft.block.entity.BlockEntity;
2525
import net.minecraft.block.entity.SignBlockEntity;
2626
import net.minecraft.client.MinecraftClient;
27-
import net.minecraft.client.font.TextRenderer;
2827
import net.minecraft.client.gui.DrawContext;
2928
import net.minecraft.client.gui.tooltip.HoveredTooltipPositioner;
3029
import net.minecraft.client.gui.tooltip.TooltipComponent;
@@ -84,6 +83,8 @@ public void onInitializeClient() {
8483

8584
itemData = loadJsonFile(ITEM_DATA_PATH);
8685

86+
BossState.init();
87+
8788
RegionLoader.init();
8889
RegionRenderer.init();
8990
RegionUpdater.init();
@@ -149,6 +150,7 @@ public static JsonObject loadJsonFile(String PATH) {
149150
}
150151

151152
private void renderHUDOverlay(DrawContext context) {
153+
// we really should move this to a seperate class and... clean it up more
152154
MinecraftClient client = MinecraftClient.getInstance();
153155
if (Config.HANDLER.instance().debugMode) {
154156
List<String> debugLines = new ArrayList<>(List.of(
@@ -167,6 +169,7 @@ private void renderHUDOverlay(DrawContext context) {
167169
if (GameState.trophies != null) debugLines.add("CURRENT TROPHIES: " + GameState.trophies);
168170
if (GameState.karma != null) debugLines.add("CURRENT KARMA: " + GameState.karma);
169171
if (GameState.melonJoin != null) debugLines.add("MWON TIMER: " + Duration.between(GameState.melonJoin, LocalDateTime.now()).getSeconds());
172+
if (BossState.boss != null) debugLines.add("CURRENT BOSS: " + BossState.boss.bossID);
170173

171174
assert MinecraftClient.getInstance().player != null;
172175
BlockPos pos = MinecraftClient.getInstance().player.getBlockPos().add(-plot_origin.x, 0, -plot_origin.y);
@@ -175,7 +178,7 @@ private void renderHUDOverlay(DrawContext context) {
175178
}
176179
debugLines.add("PLOTSPACE POS: " + pos);
177180

178-
int startY = context.getScaledWindowHeight() - 390;
181+
int startY = context.getScaledWindowHeight() /2 - debugLines.toArray().length*5;
179182
drawDebugLines(context, client, debugLines, startY, 10, 0xFF82B7ED);
180183
}
181184
if (!(client.player == null) && !(client.world == null) && onMelonKing()) {

src/main/java/dev/lycanea/mwonmod/mixin/ActionBarMixin.java renamed to src/main/java/dev/lycanea/mwonmod/mixin/InGameHudMixin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import java.util.regex.Pattern;
1515

1616
@Mixin(InGameHud.class)
17-
public class ActionBarMixin {
17+
public class InGameHudMixin {
1818
@Inject(method = "setOverlayMessage", at = @At("HEAD"))
1919
private void onSetOverlayMessage(Text message, boolean tinted, CallbackInfo ci) {
2020
Matcher MelonKingActionbarMatcher = Pattern.compile("Trophies: (?<trophy>\\d*) Karma: (?<karma>\\d*) Medals: (?<medals>\\d*)").matcher(message.getString());
@@ -24,4 +24,9 @@ private void onSetOverlayMessage(Text message, boolean tinted, CallbackInfo ci)
2424
GameState.medals = Integer.valueOf(MelonKingActionbarMatcher.group("medals"));
2525
}
2626
}
27+
28+
@Inject(method = "setTitle", at = @At("HEAD"))
29+
private void onSetTitle(Text message, CallbackInfo ci) {
30+
// Mwonmod.LOGGER.info("Title: {}", message.getString());
31+
}
2732
}

src/main/java/dev/lycanea/mwonmod/mixin/OnPacketMixin.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.dfonline.flint.util.Toaster;
44
import dev.lycanea.mwonmod.Config;
55
import dev.lycanea.mwonmod.Mwonmod;
6+
import dev.lycanea.mwonmod.util.BossState;
67
import dev.lycanea.mwonmod.util.GameState;
78

89
import com.google.gson.JsonObject;
@@ -17,6 +18,7 @@
1718
import net.minecraft.network.packet.Packet;
1819
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
1920
import net.minecraft.network.packet.s2c.play.OpenScreenS2CPacket;
21+
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
2022
import net.minecraft.text.HoverEvent;
2123
import net.minecraft.text.Text;
2224
import org.spongepowered.asm.mixin.Mixin;
@@ -37,6 +39,11 @@ private static <T extends PacketListener> void onGameMessage(Packet<T> packet, P
3739
if (packet instanceof GameMessageS2CPacket(Text content, boolean overlay)) {
3840
handleChatPacket(content, overlay, ci);
3941
}
42+
if (packet instanceof PlaySoundS2CPacket PlaySoundS2CPacket && Mwonmod.onMelonKing()) {
43+
if (Objects.equals(PlaySoundS2CPacket.getSound().getIdAsString(), "minecraft:entity.sheep.shear") && Config.HANDLER.instance().muteSellingSound) {
44+
ci.cancel();
45+
}
46+
}
4047
if (packet instanceof OpenScreenS2CPacket openScreenPacket) {
4148
if (Mwonmod.onMelonKing()) {
4249
Text screenTitle = openScreenPacket.getName();
@@ -68,15 +75,23 @@ private static void handleChatPacket(Text content, boolean overlay, CallbackInfo
6875

6976
Toaster.toast(
7077
Component.text("MwonMod"),
71-
Component.text("Using Alpha version ", mainStyle)
78+
Component.text("Version: ", mainStyle)
7279
.append(versionComponent)
73-
.append(Component.text(", please report bugs on the Discord!", mainStyle))
80+
.append(Component.text(", bugs may occur!", mainStyle))
7481
);
7582

7683
GameState.melonJoin = LocalDateTime.now();
7784
}
7885

7986
if (!Mwonmod.onMelonKing()) return;
87+
if (message.equals("» All combatants perished, so the battle was lost.")) {
88+
BossState.updateBoss(null);
89+
}
90+
if (BossState.dialogueToBoss.containsKey(message)) {
91+
String bossID = BossState.dialogueToBoss.get(message);
92+
BossState.updateBoss(bossID);
93+
}
94+
8095
if (Config.HANDLER.instance().hideSellFailMessage && Objects.equals(message, "> You don't have any Super Enchanted Melons. Get them by cooking four Enchanted Melon Slices, which are gotten by cooking four Melon Slices.")) {
8196
ci.cancel();
8297
}
@@ -115,6 +130,9 @@ private static void handleChatPacket(Text content, boolean overlay, CallbackInfo
115130
} else if (kingMatcher.find()) {
116131
assert MinecraftClient.getInstance().player != null;
117132
if (Config.HANDLER.instance().kingChangeNotification) {
133+
GameState.bank_gold = 0;
134+
GameState.coins = 0;
135+
BossState.updateBoss(null);
118136
GameState.currentMonarch = kingMatcher.group(1);
119137
Mwonmod.notification("New Monarch", kingMatcher.group(1));
120138
}

src/main/java/dev/lycanea/mwonmod/music/CustomMusicManager.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.lycanea.mwonmod.music;
22

3+
import dev.lycanea.mwonmod.util.BossState;
34
import net.minecraft.client.MinecraftClient;
45
import net.minecraft.client.sound.SoundInstance;
56
import net.minecraft.sound.SoundEvent;
@@ -14,6 +15,13 @@ public static void setCurrentSong(CustomSong song) {
1415
currentSong = song;
1516
}
1617

18+
public static void init() {
19+
BossState.BossChangeCallback.EVENT.register((previousBoss, currentBoss) -> {
20+
21+
return null;
22+
});
23+
}
24+
1725
public static void tick(MinecraftClient client) {
1826
// client.options.getSoundVolumeOption(SoundCategory.MUSIC).setValue(0.0);
1927

@@ -33,15 +41,15 @@ private static void playSong(MinecraftClient client, CustomSong song) {
3341
if (soundId == null) return;
3442

3543
SoundEvent soundEvent = SoundEvent.of(soundId);
36-
LoopingSoundInstance sound = new LoopingSoundInstance(soundEvent);
44+
CustomMusicSoundInstance sound = new CustomMusicSoundInstance(soundEvent);
3745
currentSound = sound;
3846

3947
client.getSoundManager().play(sound);
4048
}
4149

4250
public static void stopCurrentSong(MinecraftClient client) {
4351
if (currentSound != null) {
44-
if (currentSound instanceof LoopingSoundInstance looping) {
52+
if (currentSound instanceof CustomMusicSoundInstance looping) {
4553
looping.stop();
4654
}
4755
client.getSoundManager().stop(currentSound);

src/main/java/dev/lycanea/mwonmod/music/LoopingSoundInstance.java renamed to src/main/java/dev/lycanea/mwonmod/music/CustomMusicSoundInstance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import net.minecraft.sound.SoundEvent;
77
import net.minecraft.util.math.random.Random;
88

9-
public class LoopingSoundInstance extends AbstractSoundInstance implements TickableSoundInstance {
9+
public class CustomMusicSoundInstance extends AbstractSoundInstance implements TickableSoundInstance {
1010
private boolean done = false;
1111

12-
public LoopingSoundInstance(SoundEvent soundEvent) {
12+
public CustomMusicSoundInstance(SoundEvent soundEvent) {
1313
super(soundEvent, SoundCategory.MUSIC, Random.create());
1414
this.volume = 1.0f;
1515
this.pitch = 1.0f;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package dev.lycanea.mwonmod.util;
2+
3+
public class Boss {
4+
public String bossID;
5+
// public BossPhase phase; // we arent gonna... bother with phases for now
6+
7+
public Boss(String bossID) {
8+
this.bossID = bossID;
9+
}
10+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package dev.lycanea.mwonmod.util;
2+
3+
import com.google.gson.JsonElement;
4+
import com.google.gson.JsonObject;
5+
import net.fabricmc.fabric.api.event.Event;
6+
import net.fabricmc.fabric.api.event.EventFactory;
7+
import net.minecraft.util.ActionResult;
8+
9+
import java.util.HashMap;
10+
import java.util.Map;
11+
12+
import static dev.lycanea.mwonmod.Mwonmod.loadJsonFile;
13+
14+
public class BossState {
15+
public static Boss boss;
16+
public static Map<String, String> dialogueToBoss = new HashMap<>();
17+
18+
private static final String BOSS_DATA_PATH = "assets/mwonmod/data/bosses.json";
19+
20+
public static void init() {
21+
JsonObject boss_dataJson = loadJsonFile(BOSS_DATA_PATH);
22+
if (boss_dataJson != null) {
23+
for (String boss_id : boss_dataJson.keySet()) {
24+
// each boss
25+
for (JsonElement jsonElement : boss_dataJson.get(boss_id).getAsJsonObject().get("dialogue").getAsJsonArray()) {
26+
// each dialogue
27+
String dialogue = jsonElement.getAsString();
28+
dialogueToBoss.put(dialogue, boss_id);
29+
}
30+
}
31+
}
32+
}
33+
34+
public static void updateBoss(String updatedBossID) {
35+
Boss updatedBoss = new Boss(updatedBossID);
36+
ActionResult result = BossChangeCallback.EVENT.invoker().trigger(boss, updatedBoss);
37+
boss = updatedBoss;
38+
}
39+
40+
public interface BossChangeCallback {
41+
Event<BossChangeCallback> EVENT = EventFactory.createArrayBacked(BossChangeCallback.class,
42+
(listeners) -> (Boss previousBoss, Boss currentBoss) -> {
43+
for (BossChangeCallback event : listeners) {
44+
ActionResult result = event.trigger(previousBoss, currentBoss);
45+
46+
if (result != ActionResult.PASS) { // all this actionresult stuff is useless but idk im copying from the fabric docs
47+
return result;
48+
}
49+
}
50+
51+
return ActionResult.PASS;
52+
});
53+
ActionResult trigger(Boss previousBoss, Boss currentBoss);
54+
}
55+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"pumpkin_king_easy": {
3+
"dialogue": [
4+
"Pumpkin King > It’s beautiful out, no?",
5+
"Pumpkin King > Peace and quiet, free from the stressful tasks brought upon us by interkingdom politics.",
6+
"Pumpkin King > A bit too quiet, some might say. I am more than aware of the crimes your people have committed.",
7+
"Pumpkin King > A king of taproots, ripped away from his people and throne. Though an absentee king, how much involvement is too much?",
8+
"Pumpkin King > The monarch of fungal networks, slaughtered, in spite of all his advantages. It was a lesson of hubris you failed to learn.",
9+
"Pumpkin King > The eldest lord of the grass, his legacy burned from history itself. Now nothing more than a page in the books, no thanks to you.",
10+
"Pumpkin King > Your predecessor, a poetic reflection of your fate. Time is cruel, but most of all to the realm you hail from.",
11+
"Pumpkin King > And now, me. Your journey could have ended, but I was not a friend, but a mere road block.",
12+
"Pumpkin King > ...Why?",
13+
"> His words flitter away like smoke through your fingers. Order was never your cup of melon juice.",
14+
"> He can only speak to you in a language you know intimately.",
15+
"> Your journey ends here, the hands of war stretched thin enough to snap in two. After all, when you reach the top, there's only one way to go.",
16+
"> Down."
17+
],
18+
"phases": [
19+
{"audio": "mwonmod:pumpkin_king_phaseOne"}
20+
],
21+
"arena": "economics_room"
22+
},
23+
24+
"carrot_king_normal": {
25+
"dialogue": [
26+
"Carrot King > It appears you have fallen for my trap.",
27+
"Carrot King > Your rash decision to attack my kingdom shall only end in the loss of your lives.",
28+
"Carrot King > Now fight, or die trying!",
29+
"Carrot King > Freeze!",
30+
"Carrot King > Fry!",
31+
"Carrot King > Feel the wrath of the Carrot Kingdom!",
32+
"Carrot King > You have exhausted my machinery.",
33+
"Carrot King > I doubt you will be simply leaving me be, though.",
34+
"Carrot King > I suppose I should have forseen an event such as this.",
35+
"Carrot King > Though I was not expecting there to be so many of you.",
36+
"Carrot King > I could have sworn I have seen some of your faces more than once...",
37+
"Carrot King > In fact, it's almost as if your soldiers simply cannot die."
38+
],
39+
"phases": [
40+
{"trigger": 2, "name": "phase1"}, {"trigger": 6, "name": "defeat"}
41+
]
42+
},
43+
"mushroom_king_normal": {
44+
"dialogue": [
45+
"Mushroom King > Your kingdom's technology is inferior to mine by far.",
46+
"Mushroom King > Yet still, you have the audacity to challenge me in battle?",
47+
"Mushroom King > Then let us see who will reign victorious.",
48+
"Mushroom King > I hear of your undying soldiers, words from the Taproot himself. Meet my own.",
49+
"Mushroom King > Come here, cowards!",
50+
"Mushroom King > Feel the full force of my machine!",
51+
"Mushroom King > You have... slain me, it seems...",
52+
"Mushroom King > If you have defeated me despite my best attempts...",
53+
"Mushroom King > ...Then so be it."
54+
],
55+
"phases": [
56+
{"trigger": 2, "name": "phase1"}, {"trigger": 6, "name": "defeat"}
57+
]
58+
},
59+
"wheat_king_normal": {
60+
"dialogue": [
61+
"Wheat King > My kingdom was destroyed centuries before the first historians came to be.",
62+
"Wheat King > Yet still, I live on, the magic from my spires giving me what little vitality I have left.",
63+
"Wheat King > And you wish to destroy that? What would you gain from such acts?",
64+
"Wheat King > Though, if I cannot convince you otherwise, then it seems we must do battle.",
65+
"Wheat King > Respect your elders!",
66+
"Wheat King > You dare destroy half of what I use to live?",
67+
"Wheat King > This shall not bode well for you.",
68+
"Wheat King > You broke them both...",
69+
"Wheat King > I suppose that marks the end of my fragile life.",
70+
"Wheat King > I cannot live on without their magic...",
71+
"Wheat King > So this shall be my final farewell.",
72+
"Wheat King > I despise you."
73+
],
74+
"phases": [
75+
{"trigger": 3, "name": "phase1"}, {"trigger": 6, "name": "half_killed"}, {"trigger": 7, "name": "defeat"}
76+
]
77+
},
78+
"melon_king_normal": {
79+
"dialogue": [
80+
"Melon King > I knew I would see you again.",
81+
"Melon King > Neither of us are going anywhere.",
82+
"Melon King > At least not any time soon.",
83+
"Melon King > That said...",
84+
"Melon King > How about a rematch?",
85+
"Melon King > I can't... do this... anymore...",
86+
"Melon King > Slay me... and claim... your reward...",
87+
"Melon King > Well, there's no point in hiding it.",
88+
"Melon King > You know what comes next.",
89+
"title spam dialogue",
90+
"Melon King > I can't... keep going...",
91+
"Melon King > Despite my best efforts...",
92+
"Melon King > Despite all the power I've used against you...",
93+
"Melon King > You just keep coming back...",
94+
"Melon King > Once and once again...",
95+
"Melon King > I would envy you, Toxicpid...",
96+
"Melon King > But your suffering is...",
97+
"Melon King > Far greater than my own...",
98+
"Melon King > Regardless... it seems that...",
99+
"Melon King > This is the end of the road for me...",
100+
"Melon King > Yet still, I have a feeling...",
101+
"Melon King > We shall meet again."
102+
],
103+
"phases": [
104+
{"trigger": 4, "name": "phase1"}, {"trigger": 5, "name": "fakeout"}, {"trigger": 8, "name": "phase2"}, {"trigger": 10, "name": "defeat"}
105+
]
106+
}
107+
}

src/main/resources/assets/mwonmod/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"yacl3.config.mwonmod:config.preventAttackingWithHoe": "Prevent Attacking With Hoe",
1818
"yacl3.config.mwonmod:config.codespaceHider": "Melon King Codespace Hider",
1919
"yacl3.config.mwonmod:config.showPercentageInInventoryOverview": "Show Percentage in Inventory Overview",
20+
"yacl3.config.mwonmod:config.muteSellingSound": "Mute Selling Sound",
2021

2122
"yacl3.config.mwonmod:config.category.Auction": "Auction Improvements",
2223
"yacl3.config.mwonmod:config.category.Auction.group.Timers": "Timers",

0 commit comments

Comments
 (0)