Skip to content

Commit

Permalink
Merge pull request #8 from SettingDust/1.20.1
Browse files Browse the repository at this point in the history
Backport to 1.20.1
  • Loading branch information
Pyrofab authored Jan 5, 2024
2 parents 48cf116 + 88540b4 commit 4ec5ea9
Show file tree
Hide file tree
Showing 70 changed files with 1,855 additions and 451 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
Expand Down
17 changes: 14 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import net.fabricmc.loom.task.RemapJarTask

plugins {
id 'fabric-loom' version "1.0.+"
id 'fabric-loom' version "1.4.+"
id 'io.github.ladysnake.chenille' version '0.11.3'
id 'io.github.juuxel.loom-quiltflower' version "1.6.0"
}

archivesBaseName = project.archives_base_name
Expand Down Expand Up @@ -51,6 +50,18 @@ dependencies {

// Test dependencies
modImplementation(libs.elmendorf)

testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"
}

test {
useJUnitPlatform()
maxHeapSize = '1G'
workingDir(project.layout.buildDirectory)
testLogging {
events("passed", "skipped", "failed")
}
}

processResources {
Expand Down Expand Up @@ -117,4 +128,4 @@ publishing {
}
}
}
}
}
44 changes: 44 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
------------------------------------------------------
Version 1.4.0-mc1.20.1
------------------------------------------------------

**Mod Interactions**
- REI no longer appears on the RPG dialogue screen variant

------------------------------------------------------
Version 1.3.1-mc1.20.1
------------------------------------------------------
**Fixes**
- Fixed the `/blabber` command failing to find dialogues added through regular datapacks

------------------------------------------------------
Version 1.3.0-mc1.20.1
------------------------------------------------------
**Additions**
- Added a new `DialogueActionV2` interface that lets mods act upon the interlocutor in a dialogue

------------------------------------------------------
Version 1.2.0-mc1.20.1
------------------------------------------------------
**Additions**
- Dialogues now support advanced text components, like entity selectors and scores
- You can now specify an *interlocutor* when starting a dialogue
- The interlocutor entity can be referred to in commands and texts using a new entity selector, `@interlocutor`
- It can also be referred to using a new loot condition, `blabber:interlocutor_properties`

**Changes**
- Dialogues can now be reloaded using the `/reload` command

------------------------------------------------------
Version 1.1.0-mc1.20.1
------------------------------------------------------
**Additions**
- A new dialogue screen you can use : the RPG layout, ideal for dynamic NPC dialogues with short choices
- This new layout can be chosen on a per-dialogue basis - look at [the documentation](https://ladysnake.org/wiki/blabber#layout) for details

**Changes**
- Updated the French localization

**Fixes**
- Fixed scrolling in the dialogue screen behaving erratically

------------------------------------------------------
Version 1.0.0-mc1.20.1
------------------------------------------------------
Expand Down
91 changes: 0 additions & 91 deletions dialogue.schema.json

This file was deleted.

6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ org.gradle.jvmargs=-Xmx2G
# check these on https://fabricmc.net/versions.html
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22
loader_version=0.15.3
java_version=17

# Mod Properties
mod_version = 1.0.0-mc1.20.1
mod_version = 1.4.0-mc1.20.1
maven_group = org.ladysnake
archives_base_name = blabber

# Dependencies
fabric_version=0.90.4+1.20.1
fabric_version=0.91.0+1.20.1

# Publishing
license_header = LGPL
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[versions]
cca = "5.2.0"
elmendorf = "0.11.0"
emi = "1.0.23+1.20.2"
emi = "1.0.29+1.20.1"
fpa = "0.2-SNAPSHOT"
mcAnnotations = "1.0"
modmenu = "7.2.2"
rei = "13.0.666"
rei = "12.0.684"

[libraries]
cca-base = { module = "dev.onyxstudios.cardinal-components-api:cardinal-components-base", version.ref = "cca" }
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
50 changes: 47 additions & 3 deletions src/main/java/org/ladysnake/blabber/Blabber.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Blabber
* Copyright (C) 2022-2023 Ladysnake
* Copyright (C) 2022-2024 Ladysnake
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -17,19 +17,25 @@
*/
package org.ladysnake.blabber;

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.serialization.Codec;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.registry.Registry;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import org.ladysnake.blabber.api.DialogueActionV2;
import org.ladysnake.blabber.impl.common.BlabberCommand;
import org.ladysnake.blabber.impl.common.BlabberRegistrar;
import org.ladysnake.blabber.impl.common.CommandDialogueAction;
import org.ladysnake.blabber.impl.common.DialogueInitializationException;
import org.ladysnake.blabber.impl.common.PlayerDialogueTracker;
import org.ladysnake.blabber.impl.common.machine.DialogueStateMachine;

Expand All @@ -47,12 +53,39 @@ public static Identifier id(String path) {
* <p>This operation closes the player's {@linkplain PlayerEntity#currentScreenHandler current screen handler},
* if any, and opens a new dialogue screen instead.
*
* <p>A dialogue may fail to start if it contains malformed texts as per {@link net.minecraft.text.Texts#parse(ServerCommandSource, Text, Entity, int)}.
* In that case, this method will throw a {@link DialogueInitializationException}.
*
* @param player the player for whom to initiate a dialogue
* @param id the identifier for the dialogue
* @throws IllegalArgumentException if {@code id} is not a valid dialogue in this game instance
* @throws DialogueInitializationException if the dialogue failed to initialize
*/
public static void startDialogue(ServerPlayerEntity player, Identifier id) {
PlayerDialogueTracker.get(player).startDialogue(id);
startDialogue(player, id, null);
}

/**
* Starts a dialogue
*
* <p>This operation closes the player's {@linkplain PlayerEntity#currentScreenHandler current screen handler},
* if any, and opens a new dialogue screen instead.
*
* <p>A dialogue may fail to start if it contains malformed texts as per {@link net.minecraft.text.Texts#parse(ServerCommandSource, Text, Entity, int)}.
* In that case, this method will throw a {@link DialogueInitializationException}.
*
* @param player the player for whom to initiate a dialogue
* @param id the identifier for the dialogue
* @param interlocutor the entity with which the player is conversing
* @throws IllegalArgumentException if {@code id} is not a valid dialogue in this game instance
* @throws DialogueInitializationException if the dialogue failed to initialize
*/
public static void startDialogue(ServerPlayerEntity player, Identifier id, @Nullable Entity interlocutor) {
try {
PlayerDialogueTracker.get(player).startDialogue(id, interlocutor);
} catch (CommandSyntaxException e) {
throw new DialogueInitializationException("Failed to parse texts in dialogue template " + id, e);
}
}

/**
Expand Down Expand Up @@ -82,14 +115,25 @@ public static void registerAction(Identifier actionId, DialogueAction action) {
registerAction(actionId, Codec.unit(action));
}

/**
* Register a basic {@link DialogueAction} to handle dialogue choices.
*
* @param actionId the identifier used to reference the action in dialogue definition files
* @param action the action to run when triggered by a player
* @see #registerAction(Identifier, Codec)
*/
public static void registerAction(Identifier actionId, DialogueActionV2 action) {
registerAction(actionId, Codec.unit(action));
}

/**
* Register a configurable {@link DialogueAction} to handle dialogue choices.
*
* @param actionId the identifier used to reference the action in dialogue definition files
* @param codec a codec for deserializing dialogue actions using the given value
* @see #registerAction(Identifier, DialogueAction)
*/
public static void registerAction(Identifier actionId, Codec<? extends DialogueAction> codec) {
public static void registerAction(Identifier actionId, Codec<? extends DialogueActionV2> codec) {
Registry.register(BlabberRegistrar.ACTION_REGISTRY, actionId, codec);
}

Expand Down
17 changes: 15 additions & 2 deletions src/main/java/org/ladysnake/blabber/DialogueAction.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Blabber
* Copyright (C) 2022-2023 Ladysnake
* Copyright (C) 2022-2024 Ladysnake
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand All @@ -17,14 +17,27 @@
*/
package org.ladysnake.blabber;

import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import org.ladysnake.blabber.api.DialogueActionV2;

/**
* @see DialogueActionV2
* @see Blabber#registerAction(Identifier, DialogueAction)
*/
@FunctionalInterface
public interface DialogueAction {
public interface DialogueAction extends DialogueActionV2 {
/**
* Handles a dialogue action triggered by the given player.
*
* @param player the player executing the action
*/
void handle(ServerPlayerEntity player);

@Override
default void handle(ServerPlayerEntity player, @Nullable Entity interlocutor) {
this.handle(player);
}
}
Loading

0 comments on commit 4ec5ea9

Please sign in to comment.