Skip to content

Commit

Permalink
Add an option using material tags to add an existing material to a em…
Browse files Browse the repository at this point in the history
…bellishment stat type
  • Loading branch information
KnightMiner committed Feb 26, 2024
1 parent a797b75 commit 0e9624d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"replace": false,
"values": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"replace": false,
"values": []
}
5 changes: 5 additions & 0 deletions src/main/java/slimeknights/tconstruct/common/TinkerTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,11 @@ private static void init() {}
/** Materials available in nether */
public static final TagKey<IMaterial> NETHER = tag("nether");

/** Tag override to add an existing material to the plate embellishment. Typically better to do via the render info but this is an alternative for addons to use. */
public static final TagKey<IMaterial> PLATE_EMBELLISHMENT = tag("generator_stat_type/plate");
/** Tag override to add an existing material to the slime embellishment Typically better to do via the render info but this is an alternative for addons to use. */
public static final TagKey<IMaterial> SLIME_EMBELLISHMENT = tag("generator_stat_type/slimesuit");

private static TagKey<IMaterial> tag(String name) {
return MaterialManager.getTag(TConstruct.getResource(name));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public MaterialTagProvider(DataGenerator generator, ExistingFileHelper existingF

@Override
protected void addTags() {
tag(TinkerTags.Materials.PLATE_EMBELLISHMENT);
tag(TinkerTags.Materials.SLIME_EMBELLISHMENT);
tag(TinkerTags.Materials.NETHER).add(
// tier 1
MaterialIds.wood, MaterialIds.flint, MaterialIds.rock, MaterialIds.bone,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
import slimeknights.tconstruct.library.client.data.spritetransformer.ISpriteTransformer;
import slimeknights.tconstruct.library.client.data.spritetransformer.RecolorSpriteTransformer;
import slimeknights.tconstruct.library.client.materials.MaterialRenderInfoJson.MaterialGeneratorJson;
import slimeknights.tconstruct.library.materials.IMaterialRegistry;
import slimeknights.tconstruct.library.materials.MaterialRegistry;
import slimeknights.tconstruct.library.materials.definition.MaterialId;
import slimeknights.tconstruct.library.materials.definition.MaterialManager;
import slimeknights.tconstruct.library.materials.definition.MaterialVariantId;
import slimeknights.tconstruct.library.materials.stats.MaterialStatsId;
import slimeknights.tconstruct.tools.stats.ExtraMaterialStats;
Expand Down Expand Up @@ -105,10 +107,14 @@ public boolean supportStatType(MaterialStatsId statType) {
return true;
}
// if material registry is loaded and we are not ignoring it, allow checking that
// also allow a tag as an override, useful mainly for making existing materials a new embellishment
if (!ignoreMaterialStats && MaterialRegistry.isFullyLoaded()) {
return MaterialRegistry.getInstance().getMaterialStats(new MaterialId(texture), statType).isPresent();
IMaterialRegistry materials = MaterialRegistry.getInstance();
MaterialId id = new MaterialId(texture);
return materials.getMaterialStats(id, statType).isPresent()
|| materials.isInTag(id, MaterialManager.getTag(new ResourceLocation(statType.getNamespace(), "generator_stat_type/" + statType.getPath())));
}
return super.supportStatType(statType);
return false;
}
}

Expand Down

0 comments on commit 0e9624d

Please sign in to comment.