Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into 1.20.4-f…
Browse files Browse the repository at this point in the history
…abric
  • Loading branch information
melontini committed Apr 27, 2024
2 parents 3c3607b + 53d89ec commit 6c040be
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
### What's New:

* Added `hasContext` function to expressions. Allows checking if loot context has the required parameter: `if(hasContext("tool"), "Hi", "Bye")`
* Slightly improved error messages returned by `cmd:arithmetica`.
20 changes: 8 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,6 @@ sourcesJar {
from delombok
}

tasks.register('printVersionName') {
doLast {
println "${project.mod_version} (${project.minecraft_version})"
}
}

tasks.register('printVersion') {
doLast {
println version
}
}

// configure the maven publication
publishing {
publications {
Expand Down Expand Up @@ -219,6 +207,14 @@ publishMods {
requires("fabric-api")
embeds("dark-matter")
}
curseforge {
projectId = "1009687"
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
minecraftVersions.add("${project.minecraft_version}")

requires("fabric-api")
embeds("dark-matter")
}
github {
repository = "constellation-mc/commander"
accessToken = providers.environmentVariable("GITHUB_TOKEN")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.9
# Mod Properties
mod_version=0.3.1
mod_version=0.3.2
maven_group=me.melontini
archives_base_name=commander
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@
import me.melontini.dark_matter.api.data.codecs.ExtraCodecs;
import net.minecraft.loot.context.LootContextParameter;
import net.minecraft.util.Identifier;

import java.util.Objects;
import org.jetbrains.annotations.Nullable;

public class ExtractionTypes {

private static final BiMap<Identifier, LootContextParameter<?>> KNOWN_PARAMETERS = HashBiMap.create();
public static final Codec<LootContextParameter<?>> CODEC = ExtraCodecs.mapLookup(Identifier.CODEC, KNOWN_PARAMETERS);

public static LootContextParameter<?> getParameter(Identifier identifier) {
return Objects.requireNonNull(KNOWN_PARAMETERS.get(identifier), () -> "No such loot context parameter %s!".formatted(identifier));
public static @Nullable LootContextParameter<?> getParameter(Identifier identifier) {
return KNOWN_PARAMETERS.get(identifier);
}

public static void register(LootContextParameter<?> parameter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,19 @@ public static class MapBasedDataAccessor implements DataAccessorIfc {

@Override
public @Nullable EvaluationValue getData(String variable) {
var id = new Identifier(variable.replace("__idcl__", ":"));
var r = Identifier.validate(variable.replace("__idcl__", ":"));
if (r.error().isPresent()) {
throw new CmdEvalException("%s - %s".formatted(variable.replace("__idcl__", ":"), r.error().orElseThrow().message()));
}

var id = r.result().orElseThrow();
var func = overrides.get(id);
if (func != null) return CONFIGURATION.getEvaluationValueConverter().convertObject(func.apply(LOCAL.get()), CONFIGURATION);

var object = LOCAL.get().get(ExtractionTypes.getParameter(id));
var param = ExtractionTypes.getParameter(id);
if (param == null) throw new CmdEvalException("%s is not a registered loot context parameter!".formatted(id));

var object = LOCAL.get().get(param);
if (object == null) return null;
return CONFIGURATION.getEvaluationValueConverter().convertObject(object, CONFIGURATION);
}
Expand Down

0 comments on commit 6c040be

Please sign in to comment.