Skip to content

Commit

Permalink
Fix empty models not being able to attune on variants
Browse files Browse the repository at this point in the history
Closes #41
Closes #70
  • Loading branch information
Shadows-of-Fire committed Jan 9, 2025
1 parent 7b86f25 commit 18e9d6b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version=6.1.1
# Dependencies
mcVersion=1.21.1
javaVersion=21
forgeVersion=21.1.60
forgeVersion=21.1.90
parchmentVersion=2024.07.28-1.21
jeiVersion=19.8.4.113
jadeVersion=15.1.6
Expand Down
2 changes: 1 addition & 1 deletion src/generated/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ config="hostilenetworks.mixins.json"
[[dependencies.hostilenetworks]]
modId="neoforge"
type="required"
versionRange="[21.1.60,)"
versionRange="[21.1.90,)"
ordering="NONE"
side="BOTH"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.function.Function;
import java.util.stream.Stream;

import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
Expand Down Expand Up @@ -105,6 +106,10 @@ public Codec<? extends DataModel> getCodec() {
return CODEC;
}

public Stream<EntityType<?>> entityAndVariants() {
return Stream.concat(Stream.of(this.entity), this.variants.stream());
}

public static DataResult<DataModel> validate(DataModel model) {
if (model.name().getStyle().getColor() == null) {
return DataResult.error(() -> "A data model must supply a color for the name component.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ protected void onReload() {

@Override
protected void validateItem(ResourceLocation key, DataModel model) {
if (this.modelsByType.containsKey(model.entity())) {
String msg = "Attempted to register two models (%s and %s) for Entity Type %s!";
throw new UnsupportedOperationException(String.format(msg, key, this.getKey(this.modelsByType.get(model.entity())), EntityType.getKey(model.entity())));
}
this.modelsByType.put(model.entity(), model);
model.entityAndVariants().forEach(type -> {
if (this.modelsByType.containsKey(type)) {
String msg = "Attempted to register two models (%s and %s) for Entity Type %s!";
throw new UnsupportedOperationException(String.format(msg, key, this.getKey(this.modelsByType.get(type)), EntityType.getKey(type)));
}
this.modelsByType.put(type, model);
});
}

@Nullable
Expand Down

0 comments on commit 18e9d6b

Please sign in to comment.