2020-11-01 15:11:04 +01:00
|
|
|
package de.ellpeck.actuallyadditions.data;
|
|
|
|
|
|
|
|
import de.ellpeck.actuallyadditions.common.ActuallyAdditions;
|
2020-11-01 18:58:08 +01:00
|
|
|
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
2020-11-20 20:57:44 +01:00
|
|
|
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
2020-11-21 11:57:36 +01:00
|
|
|
import de.ellpeck.actuallyadditions.common.items.ToolSet;
|
2020-11-01 15:11:04 +01:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.data.DataGenerator;
|
2020-11-20 20:57:44 +01:00
|
|
|
import net.minecraft.item.Item;
|
2020-11-01 15:11:04 +01:00
|
|
|
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
|
|
|
import net.minecraftforge.client.model.generators.ModelFile;
|
2020-11-01 20:32:55 +01:00
|
|
|
import net.minecraftforge.common.data.ExistingFileHelper;
|
2020-11-01 18:58:08 +01:00
|
|
|
import net.minecraftforge.fml.RegistryObject;
|
2020-11-01 15:11:04 +01:00
|
|
|
|
2020-11-21 11:57:36 +01:00
|
|
|
import java.util.Collection;
|
2020-11-20 20:57:44 +01:00
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
2020-11-01 15:11:04 +01:00
|
|
|
public class GeneratorItemModels extends ItemModelProvider {
|
|
|
|
public GeneratorItemModels(DataGenerator generator, ExistingFileHelper existingFileHelper) {
|
|
|
|
super(generator, ActuallyAdditions.MOD_ID, existingFileHelper);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void registerModels() {
|
2020-11-20 20:57:44 +01:00
|
|
|
ActuallyItems.SIMPLE_ITEMS.forEach(this::simpleItem);
|
2020-11-21 11:57:36 +01:00
|
|
|
|
|
|
|
// Toolsets
|
|
|
|
ActuallyItems.ALL_TOOL_SETS.stream()
|
|
|
|
.map(ToolSet::getItemGroup)
|
|
|
|
.flatMap(Collection::stream)
|
|
|
|
.forEach(item -> simpleItem(() -> item));
|
|
|
|
|
2020-11-01 18:58:08 +01:00
|
|
|
ActuallyBlocks.BLOCKS.getEntries().forEach(this::registerBlockModel);
|
2020-11-01 15:11:04 +01:00
|
|
|
}
|
|
|
|
|
2020-11-01 18:58:08 +01:00
|
|
|
private void registerBlockModel(RegistryObject<Block> block) {
|
|
|
|
String path = block.get().getRegistryName().getPath();
|
2020-11-01 15:11:04 +01:00
|
|
|
getBuilder(path).parent(new ModelFile.UncheckedModelFile(modLoc("block/" + path)));
|
|
|
|
}
|
|
|
|
|
2020-11-20 20:57:44 +01:00
|
|
|
private void simpleItem(Supplier<Item> item) {
|
|
|
|
String path = item.get().getRegistryName().getPath();
|
|
|
|
singleTexture(path, mcLoc("item/handheld"), "layer0", modLoc("item/" + path));
|
|
|
|
}
|
|
|
|
|
2020-11-01 15:11:04 +01:00
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return "Item Models";
|
|
|
|
}
|
|
|
|
}
|