2021-11-24 01:17:37 +01:00
|
|
|
package de.ellpeck.actuallyadditions.data;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
|
|
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
2021-12-30 18:30:01 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
|
2021-11-24 17:57:31 +01:00
|
|
|
import de.ellpeck.actuallyadditions.mod.items.ActuallyItems;
|
2021-11-24 01:17:37 +01:00
|
|
|
import net.minecraft.block.Block;
|
2021-11-26 00:51:59 +01:00
|
|
|
import net.minecraft.block.WallBlock;
|
2021-11-24 01:17:37 +01:00
|
|
|
import net.minecraft.data.DataGenerator;
|
|
|
|
import net.minecraft.item.Item;
|
2021-11-26 00:51:59 +01:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2021-11-24 01:17:37 +01:00
|
|
|
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
|
|
|
import net.minecraftforge.client.model.generators.ModelFile;
|
2021-12-30 18:30:01 +01:00
|
|
|
import net.minecraftforge.client.model.generators.loaders.DynamicBucketModelBuilder;
|
2021-11-24 01:17:37 +01:00
|
|
|
import net.minecraftforge.common.data.ExistingFileHelper;
|
|
|
|
import net.minecraftforge.fml.RegistryObject;
|
|
|
|
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
|
|
public class ItemModelGenerator extends ItemModelProvider {
|
|
|
|
public ItemModelGenerator(DataGenerator generator, ExistingFileHelper existingFileHelper) {
|
|
|
|
super(generator, ActuallyAdditions.MODID, existingFileHelper);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void registerModels() {
|
|
|
|
// Items
|
|
|
|
//simpleItem(ActuallyItems.BOOKLET); // will require complex I think
|
|
|
|
|
|
|
|
// All items?
|
2021-11-24 17:57:31 +01:00
|
|
|
ActuallyItems.SIMPLE_ITEMS.forEach(this::simpleItem);
|
2021-11-24 01:17:37 +01:00
|
|
|
|
|
|
|
// Toolsets
|
|
|
|
/* ActuallyItems.ALL_TOOL_SETS.stream()
|
|
|
|
.map(ToolSet::getItemGroup)
|
|
|
|
.flatMap(Collection::stream)
|
|
|
|
.forEach(item -> simpleItem(() -> item));*/
|
|
|
|
|
|
|
|
|
|
|
|
// Blocks
|
2021-12-30 18:30:01 +01:00
|
|
|
ActuallyBlocks.BLOCKS.getEntries().stream().filter(b -> !b.get().getRegistryName().getPath().contains("oil")).forEach(this::registerBlockModel);
|
|
|
|
|
|
|
|
withExistingParent(InitFluids.CANOLA_OIL.getBucket().getRegistryName().getPath(), "forge:item/bucket")
|
|
|
|
.customLoader((builder, template) -> DynamicBucketModelBuilder.begin(builder, template).fluid(InitFluids.CANOLA_OIL.get()));
|
2021-11-24 01:17:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void registerBlockModel(RegistryObject<Block> block) {
|
2021-11-26 00:51:59 +01:00
|
|
|
String path = block.get().getRegistryName().getPath();
|
2021-11-24 01:17:37 +01:00
|
|
|
if (block.get() instanceof WallBlock) {
|
|
|
|
String name = path;
|
2021-11-26 00:51:59 +01:00
|
|
|
path = "block/" + path.replace("_wall", "_block");
|
2021-11-24 01:17:37 +01:00
|
|
|
withExistingParent(name, new ResourceLocation("block/wall_inventory"))
|
|
|
|
.texture("wall", modLoc(path));
|
|
|
|
return;
|
|
|
|
}
|
2021-11-26 00:51:59 +01:00
|
|
|
getBuilder(path).parent(new ModelFile.UncheckedModelFile(modLoc("block/" + path)));
|
2021-11-24 01:17:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void simpleItem(Supplier<Item> item) {
|
|
|
|
String path = item.get().getRegistryName().getPath();
|
|
|
|
singleTexture(path, mcLoc("item/handheld"), "layer0", modLoc("item/" + path));
|
|
|
|
}
|
|
|
|
}
|