Skip to content

Commit

Permalink
Fix dialogue ids not being re-synced on datapack reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyrofab committed Nov 9, 2023
1 parent 1649d4a commit 1acfaae
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
------------------------------------------------------
Version 1.3.1
------------------------------------------------------
**Fixes**
- Fixed the `/blabber` command failing to find dialogues added through regular datapacks

------------------------------------------------------
Version 1.3.0
------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx2G
java_version=17

# Mod Properties
mod_version = 1.3.0
mod_version = 1.3.1
maven_group = org.ladysnake
archives_base_name = blabber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public void onInitializeClient() {
BlabberScreenRegistry.register(DialogueLayout.RPG_LAYOUT_ID, BlabberRpgDialogueScreen::new);
HandledScreens.register(BlabberRegistrar.DIALOGUE_SCREEN_HANDLER, BlabberClient::createDialogueScreen);
ClientConfigurationNetworking.registerGlobalReceiver(DialogueListPacket.TYPE, (packet, responseSender) -> DialogueRegistry.setClientIds(packet.dialogueIds()));
ClientPlayNetworking.registerGlobalReceiver(DialogueListPacket.TYPE, (packet, player, responseSender) -> DialogueRegistry.setClientIds(packet.dialogueIds()));
ClientPlayNetworking.registerGlobalReceiver(ChoiceAvailabilityPacket.TYPE, (packet, player, responseSender) -> {
if (player.currentScreenHandler instanceof DialogueScreenHandler dialogueScreenHandler) {
dialogueScreenHandler.handleAvailabilityUpdate(packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.gson.JsonParseException;
import com.mojang.serialization.JsonOps;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourceReloadListenerKeys;
import net.fabricmc.fabric.api.resource.SimpleResourceReloadListener;
Expand All @@ -35,6 +36,7 @@
import net.minecraft.util.profiler.Profiler;
import org.ladysnake.blabber.Blabber;
import org.ladysnake.blabber.impl.common.model.DialogueTemplate;
import org.ladysnake.blabber.impl.common.packets.DialogueListPacket;
import org.ladysnake.blabber.impl.common.validation.DialogueLoadingException;
import org.ladysnake.blabber.impl.common.validation.DialogueValidator;
import org.ladysnake.blabber.impl.common.validation.ValidationResult;
Expand Down Expand Up @@ -107,7 +109,10 @@ public Collection<Identifier> getFabricDependencies() {
@Override
public void endDataPackReload(MinecraftServer server, LifecycledResourceManager resourceManager, boolean success) {
if (success) {
Set<Identifier> dialogueIds = DialogueRegistry.getIds();
DialogueListPacket idSyncPacket = new DialogueListPacket(dialogueIds);
for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) {
ServerPlayNetworking.send(player, idSyncPacket);
PlayerDialogueTracker.get(player).updateDialogue();
}
}
Expand Down

0 comments on commit 1acfaae

Please sign in to comment.