Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.blockentity.PipeBlockEntity;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags;
import com.gregtechceu.gtceu.api.data.tag.TagPrefix;
import com.gregtechceu.gtceu.api.item.PipeBlockItem;
import com.gregtechceu.gtceu.api.item.tool.GTToolType;
Expand Down Expand Up @@ -72,7 +73,7 @@ public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material materi
}

public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material material) {
this(properties, tagPrefix, material, true);
this(properties, tagPrefix, material, !material.hasFlag(MaterialFlags.CUSTOM_TEXTURE));
}

@OnlyIn(Dist.CLIENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKeys;
import com.gregtechceu.gtceu.api.item.tool.MaterialToolTier;
import com.gregtechceu.gtceu.api.registry.registrate.BuilderBase;
import com.gregtechceu.gtceu.client.renderer.item.TagPrefixItemRenderer;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.common.data.GTMedicalConditions;
import com.gregtechceu.gtceu.integration.kjs.helpers.MaterialStackWrapper;
Expand Down Expand Up @@ -93,6 +94,10 @@ public class Material implements Comparable<Material> {
@Getter
private List<TagKey<Item>> itemTags = new ArrayList<>();

@Setter
@Getter
private TagPrefixItemRenderer.MaterialModel customModel;

private String calculateChemicalFormula() {
if (chemicalFormula != null) return this.chemicalFormula;
if (materialInfo.element != null) {
Expand Down Expand Up @@ -595,6 +600,9 @@ public static class Builder extends BuilderBase<Material> {
* "material.<name>" for the Translation Key.
* @since GTCEu 2.0.0
*/

private TagPrefixItemRenderer.MaterialModel customModel;

public Builder(ResourceLocation resourceLocation) {
super(resourceLocation);
String name = resourceLocation.getPath();
Expand Down Expand Up @@ -1833,6 +1841,11 @@ public Builder addDefaultEnchant(Enchantment enchant, int level) {
return this;
}

public Builder customModel(TagPrefixItemRenderer.MaterialModel customModel) {
this.customModel = customModel;
return this;
}

/**
* Verify the passed information and finalize the Material.
*
Expand Down Expand Up @@ -1870,6 +1883,9 @@ public Material buildAndRegister() {
if (ignoredTagPrefixes != null) {
ignoredTagPrefixes.forEach(p -> p.setIgnored(mat));
}

mat.setCustomModel(customModel);

return mat;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,7 @@ public String toString() {
public static final MaterialFlag HIGH_SIFTER_OUTPUT = new MaterialFlag.Builder("high_sifter_output")
.requireProps(PropertyKey.GEM, PropertyKey.ORE)
.build();

public static final MaterialFlag CUSTOM_TEXTURE = new MaterialFlag.Builder("custom_texture")
.build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gregtechceu.gtceu.GTCEu;
import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags;
import com.gregtechceu.gtceu.api.data.chemical.material.properties.DustProperty;
import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey;
import com.gregtechceu.gtceu.api.data.tag.TagPrefix;
Expand Down Expand Up @@ -41,7 +42,7 @@ public TagPrefixItem(Properties properties, TagPrefix tagPrefix, Material materi
super(properties);
this.tagPrefix = tagPrefix;
this.material = material;
if (GTCEu.isClientSide()) {
if (GTCEu.isClientSide() && !material.hasFlag(MaterialFlags.CUSTOM_TEXTURE)) {
TagPrefixItemRenderer.create(this, tagPrefix.materialIconType(), material.getMaterialIconSet());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;

import com.tterrag.registrate.providers.DataGenContext;
import com.tterrag.registrate.providers.RegistrateItemModelProvider;

import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -46,4 +49,9 @@ private TagPrefixItemRenderer(Item item, MaterialIconType type, MaterialIconSet
this.type = type;
this.iconSet = iconSet;
}

public interface MaterialModel {

void generate(DataGenContext<Item, Item> ctx, RegistrateItemModelProvider prov);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gregtechceu.gtceu.api.block.MaterialBlock;
import com.gregtechceu.gtceu.api.block.MaterialPipeBlock;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags;
import com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey;
import com.gregtechceu.gtceu.api.data.chemical.material.registry.MaterialRegistry;
import com.gregtechceu.gtceu.api.data.tag.TagPrefix;
Expand Down Expand Up @@ -73,22 +74,33 @@ public static void generateMaterialBlocks() {
}

private static void registerMaterialBlock(TagPrefix tagPrefix, Material material, GTRegistrate registrate) {
MATERIAL_BLOCKS_BUILDER.put(tagPrefix, material, registrate
var blockBuilder = registrate
.block(tagPrefix.idPattern().formatted(material.getName()),
properties -> tagPrefix.blockConstructor().create(properties, tagPrefix, material))
.initialProperties(() -> Blocks.IRON_BLOCK)
.properties(p -> tagPrefix.blockProperties().properties().apply(p).noLootTable())
.transform(GTBlocks.unificationBlock(tagPrefix, material))
.addLayer(tagPrefix.blockProperties().renderType())
.setData(ProviderType.BLOCKSTATE, NonNullBiConsumer.noop())
.setData(ProviderType.LANG, NonNullBiConsumer.noop())
.setData(ProviderType.LOOT, NonNullBiConsumer.noop())
.color(() -> MaterialBlock::tintedColor)
.item((b, p) -> tagPrefix.blockItemConstructor().create(b, p, tagPrefix, material))
.model(NonNullBiConsumer.noop())
.color(() -> () -> MaterialBlockItem.tintColor(material))
.build()
.register());
.setData(ProviderType.LOOT, NonNullBiConsumer.noop());

if (!material.hasFlag(MaterialFlags.CUSTOM_TEXTURE)) {
blockBuilder.setData(ProviderType.BLOCKSTATE, NonNullBiConsumer.noop())
.color(() -> MaterialBlock::tintedColor);
}

var itemBuilder = blockBuilder
.item((b, p) -> tagPrefix.blockItemConstructor().create(b, p, tagPrefix, material));

if (!material.hasFlag(MaterialFlags.CUSTOM_TEXTURE)) {
itemBuilder.model(NonNullBiConsumer.noop())
.color(() -> () -> MaterialBlockItem.tintColor(material));
}

itemBuilder.build();

// TODO: Allow custom model for each tagPrefix
MATERIAL_BLOCKS_BUILDER.put(tagPrefix, material, blockBuilder.register());
}

// Material Ore Blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,23 @@ public static void generateMaterialItems() {
}

private static void generateMaterialItem(TagPrefix tagPrefix, Material material, GTRegistrate registrate) {
MATERIAL_ITEMS_BUILDER.put(tagPrefix, material, registrate
.item(tagPrefix.idPattern().formatted(material.getName()),
properties -> tagPrefix.itemConstructor()
.create(material.hasFlag(MaterialFlags.FIRE_RESISTANT) ? properties.fireResistant() :
properties, tagPrefix, material))
var builder = registrate.item(tagPrefix.idPattern().formatted(material.getName()),
properties -> tagPrefix.itemConstructor()
.create(material.hasFlag(MaterialFlags.FIRE_RESISTANT) ? properties.fireResistant() :
properties, tagPrefix, material))
.setData(ProviderType.LANG, NonNullBiConsumer.noop())
.transform(GTItems.unificationItem(tagPrefix, material))
.properties(p -> p.stacksTo(tagPrefix.maxStackSize()))
.model(NonNullBiConsumer.noop())
.color(() -> () -> TagPrefixItem.tintColor(material))
.onRegister(GTItems::cauldronInteraction)
.register());
.onRegister(GTItems::cauldronInteraction);

if (!material.hasFlag(MaterialFlags.CUSTOM_TEXTURE)) {
builder.model(NonNullBiConsumer.noop())
.color(() -> () -> TagPrefixItem.tintColor(material));
} else if (material.getCustomModel() != null) {
builder.model(material.getCustomModel()::generate);
}

MATERIAL_ITEMS_BUILDER.put(tagPrefix, material, builder.register());
}

// Material Tools
Expand Down
Loading