mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
Generate all itemblock models
This commit is contained in:
1 parent
512945af89
commit
b9e4f33b88
357 files changed
+1571
-1102
No files matched your search
@@ -43,9 +43,9 @@ public class MiscellaneousIcons {
|
||||
|
||||
public TextureAtlasSprite alfPortalTex,
|
||||
lightRelayWorldIcon,
|
||||
lightRelayWorldIconRed,
|
||||
lightRelayWorldIconGreen,
|
||||
lightRelayWorldIconPurple,
|
||||
lightRelayDetectorWorldIcon,
|
||||
lightRelayForkWorldIcon,
|
||||
lightRelayToggleWorldIcon,
|
||||
alchemyCatalystOverlay,
|
||||
conjurationCatalystOverlay,
|
||||
enchanterOverlay,
|
||||
@@ -197,10 +197,6 @@ public class MiscellaneousIcons {
|
||||
|
||||
evt.addSprite(prefix("block/alfheim_portal_swirl"));
|
||||
evt.addSprite(prefix("block/alfheim_portal_swirl"));
|
||||
evt.addSprite(prefix("block/luminizer"));
|
||||
evt.addSprite(prefix("block/luminizer_detector"));
|
||||
evt.addSprite(prefix("block/luminizer_fork"));
|
||||
evt.addSprite(prefix("block/luminizer_toggle"));
|
||||
evt.addSprite(prefix("block/alchemy_catalyst_overlay"));
|
||||
evt.addSprite(prefix("block/conjuration_catalyst_overlay"));
|
||||
evt.addSprite(prefix("block/enchanter_overlay"));
|
||||
@@ -234,10 +230,10 @@ public class MiscellaneousIcons {
|
||||
}
|
||||
|
||||
alfPortalTex = get(evt.getMap(), "block/alfheim_portal_swirl");
|
||||
lightRelayWorldIcon = get(evt.getMap(), "block/luminizer");
|
||||
lightRelayWorldIconRed = get(evt.getMap(), "block/luminizer_detector");
|
||||
lightRelayWorldIconGreen = get(evt.getMap(), "block/luminizer_fork");
|
||||
lightRelayWorldIconPurple = get(evt.getMap(), "block/luminizer_toggle");
|
||||
lightRelayWorldIcon = get(evt.getMap(), "block/light_relay");
|
||||
lightRelayDetectorWorldIcon = get(evt.getMap(), "block/detector_light_relay");
|
||||
lightRelayForkWorldIcon = get(evt.getMap(), "block/fork_light_relay");
|
||||
lightRelayToggleWorldIcon = get(evt.getMap(), "block/toggle_light_relay");
|
||||
alchemyCatalystOverlay = get(evt.getMap(), "block/alchemy_catalyst_overlay");
|
||||
conjurationCatalystOverlay = get(evt.getMap(), "block/conjuration_catalyst_overlay");
|
||||
enchanterOverlay = get(evt.getMap(), "block/enchanter_overlay");
|
||||
|
||||
@@ -270,6 +270,7 @@ public class ClientProxy implements IProxy {
|
||||
RenderTypeLookup.setRenderLayer(ModBlocks.ghostRail, RenderType.getCutout());
|
||||
RenderTypeLookup.setRenderLayer(ModBlocks.solidVines, RenderType.getCutout());
|
||||
|
||||
RenderTypeLookup.setRenderLayer(ModBlocks.corporeaCrystalCube, RenderType.getTranslucent());
|
||||
RenderTypeLookup.setRenderLayer(ModBlocks.manaGlass, RenderType.getTranslucent());
|
||||
RenderTypeLookup.setRenderLayer(ModFluffBlocks.managlassPane, RenderType.getTranslucent());
|
||||
RenderTypeLookup.setRenderLayer(ModBlocks.elfGlass, RenderType.getTranslucent());
|
||||
|
||||
@@ -50,9 +50,9 @@ public class RenderTileLightRelay extends TileEntityRenderer<TileLightRelay> {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (sprites.isEmpty()) {
|
||||
sprites.put(LuminizerVariant.DEFAULT, MiscellaneousIcons.INSTANCE.lightRelayWorldIcon);
|
||||
sprites.put(LuminizerVariant.DETECTOR, MiscellaneousIcons.INSTANCE.lightRelayWorldIconRed);
|
||||
sprites.put(LuminizerVariant.FORK, MiscellaneousIcons.INSTANCE.lightRelayWorldIconGreen);
|
||||
sprites.put(LuminizerVariant.TOGGLE, MiscellaneousIcons.INSTANCE.lightRelayWorldIconPurple);
|
||||
sprites.put(LuminizerVariant.DETECTOR, MiscellaneousIcons.INSTANCE.lightRelayDetectorWorldIcon);
|
||||
sprites.put(LuminizerVariant.FORK, MiscellaneousIcons.INSTANCE.lightRelayForkWorldIcon);
|
||||
sprites.put(LuminizerVariant.TOGGLE, MiscellaneousIcons.INSTANCE.lightRelayToggleWorldIcon);
|
||||
}
|
||||
|
||||
TextureAtlasSprite iicon = sprites.get(((BlockLightRelay) state.getBlock()).variant);
|
||||
|
||||
@@ -226,20 +226,20 @@ public class BlockstateProvider extends BlockStateProvider {
|
||||
particleOnly(remainingBlocks, bellows, prefix("block/livingwood"));
|
||||
particleOnly(remainingBlocks, brewery, prefix("block/livingrock"));
|
||||
particleOnly(remainingBlocks, corporeaIndex, prefix("block/elementium_block"));
|
||||
particleOnly(remainingBlocks, lightRelayDetector, prefix("block/luminizer_detector"));
|
||||
particleOnly(remainingBlocks, lightRelayDetector, prefix("block/detector_light_relay"));
|
||||
simpleBlock(fakeAir, models().getBuilder(Registry.BLOCK.getKey(ModBlocks.fakeAir).getPath()));
|
||||
remainingBlocks.remove(fakeAir);
|
||||
particleOnly(remainingBlocks, lightRelayFork, prefix("block/luminizer_fork"));
|
||||
particleOnly(remainingBlocks, lightRelayFork, prefix("block/fork_light_relay"));
|
||||
particleOnly(remainingBlocks, gaiaHead, new ResourceLocation("block/soul_sand"));
|
||||
particleOnly(remainingBlocks, gaiaHeadWall, new ResourceLocation("block/soul_sand"));
|
||||
particleOnly(remainingBlocks, gaiaPylon, prefix("block/elementium_block"));
|
||||
particleOnly(remainingBlocks, hourglass, prefix("block/mana_glass"));
|
||||
particleOnly(remainingBlocks, lightRelayDefault, prefix("block/luminizer"));
|
||||
particleOnly(remainingBlocks, lightRelayDefault, prefix("block/light_relay"));
|
||||
particleOnly(remainingBlocks, manaFlame, new ResourceLocation("block/fire_0"));
|
||||
particleOnly(remainingBlocks, manaPylon, prefix("block/manasteel_block"));
|
||||
particleOnly(remainingBlocks, naturaPylon, prefix("block/terrasteel_block"));
|
||||
particleOnly(remainingBlocks, teruTeruBozu, new ResourceLocation("block/white_wool"));
|
||||
particleOnly(remainingBlocks, lightRelayToggle, prefix("block/luminizer_toggle"));
|
||||
particleOnly(remainingBlocks, lightRelayToggle, prefix("block/toggle_light_relay"));
|
||||
|
||||
// Block groups
|
||||
Predicate<Block> flowers = b -> b instanceof BlockSpecialFlower
|
||||
@@ -465,8 +465,9 @@ public class BlockstateProvider extends BlockStateProvider {
|
||||
blocks.remove(b);
|
||||
}
|
||||
|
||||
// ? extends T technically not correct, but is more convenient in ItemModelProvider
|
||||
@SafeVarargs
|
||||
private static <T> Iterable<T> takeAll(Set<T> src, T... items) {
|
||||
public static <T> Collection<T> takeAll(Set<? extends T> src, T... items) {
|
||||
List<T> ret = Arrays.asList(items);
|
||||
if (!src.removeAll(ret)) {
|
||||
Botania.LOGGER.warn("takeAll array didn't yield anything ({})", Arrays.toString(items));
|
||||
@@ -474,7 +475,7 @@ public class BlockstateProvider extends BlockStateProvider {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static <T> Iterable<T> takeAll(Set<T> src, Predicate<T> pred) {
|
||||
public static <T> Collection<T> takeAll(Set<T> src, Predicate<T> pred) {
|
||||
List<T> ret = new ArrayList<>();
|
||||
|
||||
Iterator<T> iter = src.iterator();
|
||||
|
||||
@@ -9,23 +9,38 @@
|
||||
package vazkii.botania.data;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.block.PaneBlock;
|
||||
import net.minecraft.block.WallBlock;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraftforge.client.model.generators.ExistingFileHelper;
|
||||
|
||||
import vazkii.botania.common.block.BlockModDoubleFlower;
|
||||
import vazkii.botania.common.block.BlockModFlower;
|
||||
import vazkii.botania.common.block.BlockSpecialFlower;
|
||||
import net.minecraftforge.client.model.generators.ModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.ModelFile;
|
||||
import vazkii.botania.common.block.*;
|
||||
import vazkii.botania.common.block.decor.BlockFloatingFlower;
|
||||
import vazkii.botania.common.block.decor.BlockModMushroom;
|
||||
import vazkii.botania.common.block.decor.BlockPetalBlock;
|
||||
import vazkii.botania.common.block.decor.BlockShinyFlower;
|
||||
import vazkii.botania.common.block.mana.BlockPool;
|
||||
import vazkii.botania.common.block.mana.BlockSpreader;
|
||||
import vazkii.botania.common.block.string.BlockRedString;
|
||||
import vazkii.botania.common.item.material.ItemPetal;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
import static vazkii.botania.data.BlockstateProvider.takeAll;
|
||||
|
||||
public class ItemModelProvider extends net.minecraftforge.client.model.generators.ItemModelProvider {
|
||||
public ItemModelProvider(DataGenerator generator, ExistingFileHelper existingFileHelper) {
|
||||
@@ -34,22 +49,143 @@ public class ItemModelProvider extends net.minecraftforge.client.model.generator
|
||||
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
Registry.ITEM.stream().filter(i -> LibMisc.MOD_ID.equals(Registry.ITEM.getKey(i).getNamespace()))
|
||||
.forEach(i -> {
|
||||
// todo 1.15 expand to all item models that simply reference their parent
|
||||
if (i instanceof BlockItem) {
|
||||
Block b = ((BlockItem) i).getBlock();
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
if (b instanceof BlockSpecialFlower || b instanceof BlockModMushroom
|
||||
|| b instanceof BlockModFlower) {
|
||||
withExistingParent(name, "item/generated").texture("layer0", prefix("block/" + name));
|
||||
} else if (b instanceof BlockFloatingFlower || b instanceof BlockRedString) {
|
||||
withExistingParent(name, prefix("block/" + name));
|
||||
} else if (b instanceof BlockModDoubleFlower) {
|
||||
withExistingParent(name, "item/generated").texture("layer0", prefix("block/" + name + "_top"));
|
||||
}
|
||||
}
|
||||
});
|
||||
Set<Item> items = Registry.ITEM.stream().filter(i -> LibMisc.MOD_ID.equals(Registry.ITEM.getKey(i).getNamespace()))
|
||||
.collect(Collectors.toSet());
|
||||
registerItemBlocks(takeAll(items, i -> i instanceof BlockItem).stream().map(i -> (BlockItem) i).collect(Collectors.toSet()));
|
||||
}
|
||||
|
||||
private void registerItemBlocks(Set<BlockItem> itemBlocks) {
|
||||
// Manually written
|
||||
itemBlocks.remove(ModBlocks.corporeaCrystalCube.asItem());
|
||||
|
||||
String animatedTorchName = Registry.ITEM.getKey(ModBlocks.animatedTorch.asItem()).getPath();
|
||||
withExistingParent(animatedTorchName, "item/generated")
|
||||
.texture("layer0", new ResourceLocation("block/redstone_torch"))
|
||||
.texture("layer1", prefix("block/animated_torch_glimmer"));
|
||||
itemBlocks.remove(ModBlocks.animatedTorch.asItem());
|
||||
|
||||
String gaiaHeadName = Registry.ITEM.getKey(ModBlocks.gaiaHead.asItem()).getPath();
|
||||
withExistingParent(gaiaHeadName, "item/template_skull");
|
||||
itemBlocks.remove(ModBlocks.gaiaHead.asItem());
|
||||
|
||||
takeAll(itemBlocks, i -> i.getBlock() instanceof BlockModDoubleFlower).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
withExistingParent(name, "item/generated").texture("layer0", prefix("block/" + name + "_top"));
|
||||
});
|
||||
|
||||
takeAll(itemBlocks, i -> i.getBlock() instanceof BlockPetalBlock).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
withExistingParent(name, prefix("block/petal_block"));
|
||||
});
|
||||
|
||||
takeAll(itemBlocks, i -> i.getBlock() instanceof PaneBlock).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
String baseName = name.substring(0, name.length() - "_pane".length());
|
||||
withExistingParent(name, "item/generated")
|
||||
.texture("layer0", prefix("block/" + baseName));
|
||||
});
|
||||
|
||||
Predicate<BlockItem> defaultGenerated = i -> {
|
||||
Block b = i.getBlock();
|
||||
return b instanceof BlockSpecialFlower || b instanceof BlockModMushroom
|
||||
|| b instanceof BlockLightRelay
|
||||
|| b instanceof BlockModFlower
|
||||
|| b == ModBlocks.ghostRail;
|
||||
};
|
||||
takeAll(itemBlocks, defaultGenerated).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
withExistingParent(name, "item/generated").texture("layer0", prefix("block/" + name));
|
||||
});
|
||||
|
||||
takeAll(itemBlocks, i -> i.getBlock() instanceof BlockPool).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
withExistingParent(name, prefix("block/" + name))
|
||||
.override().predicate(prefix("full"), 1).model(getExistingFile(prefix("block/" + name + "_full"))).end();
|
||||
});
|
||||
|
||||
takeAll(itemBlocks, i -> i.getBlock() instanceof WallBlock).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
String baseName = name.substring(0, name.length() - "_wall".length());
|
||||
withExistingParent(name, new ResourceLocation("block/wall_inventory"))
|
||||
.texture("wall", prefix("block/" + baseName));
|
||||
});
|
||||
|
||||
takeAll(itemBlocks, i -> i.getBlock() instanceof BlockSpreader).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
String material;
|
||||
if (i.getBlock() == ModBlocks.elvenSpreader) {
|
||||
material = "dreamwood";
|
||||
} else if (i.getBlock() == ModBlocks.gaiaSpreader) {
|
||||
material = name + "_material";
|
||||
} else {
|
||||
material = "livingwood";
|
||||
}
|
||||
withExistingParent(name, prefix("block/shapes/spreader_item"))
|
||||
.texture("side", prefix("block/" + name + "_side"))
|
||||
.texture("material", prefix("block/" + material))
|
||||
.texture("inside", prefix("block/" + name + "_inside"));
|
||||
});
|
||||
|
||||
takeAll(itemBlocks, ModBlocks.avatar.asItem(), ModBlocks.bellows.asItem(),
|
||||
ModBlocks.brewery.asItem(), ModBlocks.corporeaIndex.asItem(), ModBlocks.gaiaPylon.asItem(),
|
||||
ModBlocks.hourglass.asItem(), ModBlocks.manaPylon.asItem(), ModBlocks.naturaPylon.asItem(), ModBlocks.teruTeruBozu.asItem())
|
||||
.forEach(this::builtinEntity);
|
||||
|
||||
takeAll(itemBlocks, i -> i instanceof ItemPetal).forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
withExistingParent(name, "item/generated").texture("layer0", prefix("item/petal"));
|
||||
});
|
||||
|
||||
String dreamwoodFenceName = Registry.ITEM.getKey(ModFluffBlocks.dreamwoodFence.asItem()).getPath();
|
||||
withExistingParent(dreamwoodFenceName, "block/fence_inventory")
|
||||
.texture("texture", prefix("block/dreamwood_planks"));
|
||||
itemBlocks.remove(ModFluffBlocks.dreamwoodFence.asItem());
|
||||
|
||||
String livingwoodFenceName = Registry.ITEM.getKey(ModFluffBlocks.livingwoodFence.asItem()).getPath();
|
||||
withExistingParent(livingwoodFenceName, "block/fence_inventory")
|
||||
.texture("texture", prefix("block/livingwood_planks"));
|
||||
itemBlocks.remove(ModFluffBlocks.livingwoodFence.asItem());
|
||||
|
||||
String elfGlassName = Registry.ITEM.getKey(ModBlocks.elfGlass.asItem()).getPath();
|
||||
withExistingParent(elfGlassName, prefix("block/elf_glass_0"));
|
||||
itemBlocks.remove(ModBlocks.elfGlass.asItem());
|
||||
|
||||
itemBlocks.forEach(i -> {
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
withExistingParent(name, prefix("block/" + name));
|
||||
});
|
||||
}
|
||||
|
||||
private void builtinEntity(Item i) {
|
||||
// [VanillaCopy] from item/chest.json
|
||||
String name = Registry.ITEM.getKey(i).getPath();
|
||||
getBuilder(name).parent(new ModelFile.UncheckedModelFile("builtin/entity"))
|
||||
.transforms()
|
||||
.transform(ModelBuilder.Perspective.GUI)
|
||||
.rotation(30, 45, 0)
|
||||
.scale(0.625F)
|
||||
.end()
|
||||
.transform(ModelBuilder.Perspective.GROUND)
|
||||
.translation(0, 3, 0)
|
||||
.scale(0.25F)
|
||||
.end()
|
||||
.transform(ModelBuilder.Perspective.HEAD)
|
||||
.rotation(0, 180, 0)
|
||||
.end()
|
||||
.transform(ModelBuilder.Perspective.FIXED)
|
||||
.rotation(0, 180, 0)
|
||||
.scale(0.5F)
|
||||
.end()
|
||||
.transform(ModelBuilder.Perspective.THIRDPERSON_RIGHT)
|
||||
.rotation(75, 315, 0)
|
||||
.translation(0, 2.5F, 0)
|
||||
.scale(0.375F)
|
||||
.end()
|
||||
.transform(ModelBuilder.Perspective.FIRSTPERSON_RIGHT)
|
||||
.rotation(0, 315, 0)
|
||||
.scale(0.4F)
|
||||
.end()
|
||||
.end();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
Reference in new issue
Block a user