-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,414 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Bug Report | ||
description: File a bug report | ||
title: "[Bug]: " | ||
labels: ["bug"] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this bug report! | ||
Before proceeding, please make sure to do this first. 📋 | ||
- Ensure you are running the **latest** version of the mod. | ||
- A similar issue hasn't been filled before. | ||
- type: textarea | ||
id: what-happened | ||
attributes: | ||
label: What happened? | ||
description: Also tell us, what did you expect to happen? | ||
placeholder: Tell us what you see! | ||
value: "A bug happened!" | ||
validations: | ||
required: true | ||
- type: textarea | ||
attributes: | ||
label: Screenshots | ||
description: If applicable, add screenshots to help explain your problem. | ||
validations: | ||
required: false | ||
- type: input | ||
attributes: | ||
label: Logs | ||
description: | | ||
If available, add logs to help identify your problem. | ||
Please upload your log to [Github Gist](https://gist.github.com/), [mslo.gs](https://mclo.gs/) or any other pasting platform. | ||
validations: | ||
required: false | ||
- type: input | ||
id: mod-version | ||
attributes: | ||
label: Mod Version | ||
description: What version of the mod are you running? | ||
validations: | ||
required: true | ||
- type: input | ||
id: mc-version | ||
attributes: | ||
label: Minecraft Version | ||
description: What version of Minecraft are you running? | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: Suggesting Ideas | 💡 | ||
url: https://github.com/constellation-mc/commander/discussions/categories/ideas | ||
about: If you have a suggestion, please post it here. Be sure to check pinned to see how to make a good suggestion! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Crash Report | ||
description: File a crash report | ||
title: "[Crash]: " | ||
labels: ["crash"] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Thanks for taking the time to fill out this crash report! | ||
Before proceeding, please make sure to do this first. 📋 | ||
- Ensure you are running the **latest** version of the mod. | ||
- A similar report hasn't been filled before. | ||
- type: textarea | ||
id: what-happened | ||
attributes: | ||
label: What happened? | ||
description: Please explain in detail how this crash happened. | ||
validations: | ||
required: true | ||
- type: input | ||
attributes: | ||
label: Logs | ||
description: | | ||
`latest.log` or `crash-20xx-xx-xx_xx.xx.xx-(client/server).log`. | ||
Please upload your log to [Github Gist](https://gist.github.com/), [mslo.gs](https://mclo.gs/) or any other pasting platform. | ||
validations: | ||
required: true | ||
- type: input | ||
id: mod-version | ||
attributes: | ||
label: Mod Version | ||
description: What version of the mod are you running? | ||
validations: | ||
required: true | ||
- type: input | ||
id: mc-version | ||
attributes: | ||
label: Minecraft Version | ||
description: What version of Minecraft are you running? | ||
validations: | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Automatically build the project and run any configured tests for every push | ||
# and submitted pull request. This can help catch issues that only occur on | ||
# certain platforms or Java versions, and provides a first line of defence | ||
# against bad commits. | ||
|
||
name: build | ||
on: [ pull_request, push ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repository | ||
uses: actions/checkout@v4.1.1 | ||
- name: validate gradle wrapper | ||
uses: gradle/wrapper-validation-action@v2.1.1 | ||
- name: setup jdk 17 | ||
uses: actions/setup-java@v4.1.0 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
cache: gradle | ||
- name: make gradle wrapper executable | ||
run: chmod +x ./gradlew | ||
- name: build | ||
run: ./gradlew build | ||
- name: Retrieve Version #https://stackoverflow.com/questions/71089787/how-to-get-version-name-from-android-gradle-file-in-github-actions | ||
run: | | ||
echo "VERSION_INFORMATION=$(${{github.workspace}}/gradlew -q printVersionName)" >> $GITHUB_ENV | ||
echo "GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV | ||
- name: capture build artifacts | ||
uses: actions/upload-artifact@v4.3.1 | ||
with: | ||
name: ${{ env.VERSION_INFORMATION }} [${{ env.GIT_HASH }}] #https://stackoverflow.com/questions/58886293/getting-current-branch-and-commit-hash-in-github-action | ||
path: build/libs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
name: publish | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version_type: | ||
description: "The type of this version. e.g alpha" | ||
type: choice | ||
default: beta | ||
options: | ||
- release | ||
- beta | ||
- alpha | ||
required: false | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repository | ||
uses: actions/checkout@v4.1.1 | ||
- name: validate gradle wrapper | ||
uses: gradle/wrapper-validation-action@v2.1.1 | ||
- name: setup jdk 17 | ||
uses: actions/setup-java@v4.1.0 | ||
with: | ||
distribution: 'temurin' | ||
java-version: 17 | ||
- name: make gradle wrapper executable | ||
run: chmod +x ./gradlew | ||
- name: build | ||
run: ./gradlew build | ||
- name: retrieve version #https://stackoverflow.com/questions/71089787/how-to-get-version-name-from-android-gradle-file-in-github-actions | ||
run: | | ||
echo "VERSION_INFORMATION=$(${{github.workspace}}/gradlew -q printVersionName)" >> $GITHUB_ENV | ||
echo "VERSION_PLAIN=$(${{github.workspace}}/gradlew -q printVersion)" >> $GITHUB_ENV | ||
- name: publish minecraft mods | ||
uses: Kir-Antipov/mc-publish@v3.3.0 | ||
with: | ||
version-type: ${{ inputs.version_type }} | ||
changelog-file: CHANGELOG.md | ||
name: ${{ env.VERSION_INFORMATION }} | ||
version: ${{ env.VERSION_PLAIN }} | ||
|
||
game-versions: | | ||
1.20.1 | ||
loaders: | | ||
fabric | ||
java: | | ||
17 | ||
github-tag: ${{ env.VERSION_PLAIN }} | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
github-commitish: ${{ github.sha }} | ||
github-prerelease: false | ||
|
||
#modrinth-id: TseYlb0f | ||
modrinth-token: ${{ secrets.MODRINTH_TOKEN }} | ||
modrinth-featured: true | ||
modrinth-unfeature-mode: subset | ||
modrinth-dependencies: | | ||
fabric-api(required) | ||
dark-matter(embedded) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Commander | ||
|
||
### Quick Introduction | ||
|
||
**Commander** introduces a new event system to the data pack format. | ||
|
||
Each file placed in `commander/events` represents an event subscription. Commander mirrors some fabric events under the `commander` namespace. e.g. `server_tick/start` | ||
|
||
```json | ||
{ | ||
"event": "namespace:event", //the event this file subscribes to. | ||
"parameters": null, //optional parameters block | ||
"commands": [ | ||
{ | ||
"type": "namespace:command", //command type | ||
"condition": { //optional conditions block. Uses the vanilla predicates system | ||
"condition": "minecraft:random_chance", | ||
"chance": 0.5 | ||
}, | ||
"parameter": null, //misc command parameters | ||
"parameter_2": 2 | ||
} | ||
] | ||
} | ||
``` | ||
|
||
`parameters` is a block of addition subscription info. Can be omitted if the event does not expect any parameters. | ||
|
||
`commands` block defines actions the event will perform when invoked. Commands don't always interact with the game world, some commands are purely logical (`commander:random`), some are service commands (`commander:cancel`). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
# Done to increase the memory available to gradle. | ||
org.gradle.jvmargs=-Xmx1G | ||
|
||
# Fabric Properties | ||
# check these on https://modmuss50.me/fabric.html | ||
minecraft_version=1.20.4 | ||
yarn_mappings=24w11a+build.5 | ||
loader_version=0.15.7 | ||
|
||
# check these on https://modmuss50.me/fabric.html | ||
minecraft_version=1.20.1 | ||
yarn_mappings=1.20.1+build.10 | ||
loader_version=0.15.7 | ||
# Mod Properties | ||
mod_version = 0.0.1 | ||
maven_group = me.melontini | ||
archives_base_name = commander | ||
|
||
mod_version=0.0.1 | ||
maven_group=me.melontini | ||
archives_base_name=commander | ||
# Dependencies | ||
# check this on https://modmuss50.me/fabric.html | ||
fabric_version=0.96.11+1.20.5 | ||
# check this on https://modmuss50.me/fabric.html | ||
fabric_version=0.92.0+1.20.1 | ||
dark_matter=941b55fd97 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
jdk: | ||
- openjdk17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
package me.melontini.commander; | ||
|
||
import me.melontini.commander.command.builtin.BuiltInCommands; | ||
import me.melontini.commander.command.selector.BuiltInSelectors; | ||
import me.melontini.commander.data.DynamicEventManager; | ||
import me.melontini.commander.event.builtin.BuiltInEvents; | ||
import me.melontini.dark_matter.api.data.loading.ServerReloadersEvent; | ||
import net.fabricmc.api.ModInitializer; | ||
import net.minecraft.util.Identifier; | ||
|
||
//TODO: | ||
// Better validation during `apply` | ||
// Wrap most common/server fabric events. | ||
public class Commander implements ModInitializer { | ||
|
||
public static Identifier id(String path) { | ||
return new Identifier("commander", path); | ||
} | ||
|
||
@Override | ||
public void onInitialize() { | ||
ServerReloadersEvent.EVENT.register(context -> context.register(new DynamicEventManager())); | ||
|
||
BuiltInEvents.init(); | ||
BuiltInCommands.init(); | ||
BuiltInSelectors.init(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package me.melontini.commander.command; | ||
|
||
import me.melontini.commander.event.EventContext; | ||
|
||
|
||
public interface Command { | ||
boolean execute(EventContext context); | ||
CommandType type(); | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/me/melontini/commander/command/CommandType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package me.melontini.commander.command; | ||
|
||
import com.mojang.serialization.Codec; | ||
|
||
public record CommandType(Codec<? extends Command> codec) { | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
return obj == this; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/me/melontini/commander/command/ConditionedCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package me.melontini.commander.command; | ||
|
||
import com.mojang.serialization.*; | ||
import me.melontini.commander.data.types.CommandTypes; | ||
import me.melontini.commander.event.EventContext; | ||
import me.melontini.commander.util.MagicCodecs; | ||
import net.minecraft.loot.condition.LootCondition; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import java.util.stream.Stream; | ||
|
||
public record ConditionedCommand(Optional<LootCondition> condition, Command other) { | ||
|
||
public static final Codec<ConditionedCommand> CODEC = new MapCodec<ConditionedCommand>() { | ||
@Override | ||
public <T> RecordBuilder<T> encode(ConditionedCommand input, DynamicOps<T> ops, RecordBuilder<T> prefix) { | ||
var r = ((MapCodecCodec<Command>) CommandTypes.CODEC).codec().encode(input.other(), ops, prefix); | ||
input.condition().map(condition1 -> MagicCodecs.LOOT_CONDITION.encodeStart(ops, condition1)).ifPresent(tDataResult -> r.add("condition", tDataResult)); | ||
return r; | ||
} | ||
|
||
@Override | ||
public <T> DataResult<ConditionedCommand> decode(DynamicOps<T> ops, MapLike<T> input) { | ||
var r = ((MapCodecCodec<Command>) CommandTypes.CODEC).codec().decode(ops, input); | ||
T condition = input.get("condition"); | ||
if (condition == null) return r.map(command -> new ConditionedCommand(Optional.empty(), command)); | ||
return r.map(command -> MagicCodecs.LOOT_CONDITION.parse(ops, condition).map(condition1 -> new ConditionedCommand(Optional.of(condition1), command))).flatMap(Function.identity()); | ||
} | ||
|
||
@Override | ||
public <T> Stream<T> keys(DynamicOps<T> ops) { | ||
return Stream.of("condition").map(ops::createString); | ||
} | ||
}.codec(); | ||
|
||
public boolean execute(EventContext context) { | ||
if (!this.condition.map(condition1 -> condition1.test(context.lootContext())).orElse(true)) return false; | ||
return other().execute(context); | ||
} | ||
} |
Oops, something went wrong.