use of com.skelril.nitro.registry.item.ICustomItem in project Skree by Skelril.
the class CustomItemSystem method render.
// Invoked via reflection
@SuppressWarnings("unused")
private void render(Object item) {
if (item instanceof Item && item instanceof ICustomItem) {
if (Sponge.getPlatform().getExecutionType().isClient()) {
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
ItemModelMesher mesher = renderItem.getItemModelMesher();
Optional<ItemMeshDefinition> optMeshDefinition = ((ICustomItem) item).__getCustomMeshDefinition();
if (optMeshDefinition.isPresent()) {
mesher.register((Item) item, optMeshDefinition.get());
}
List<String> variants = ((ICustomItem) item).__getMeshDefinitions();
List<ResourceLocation> modelResources = new ArrayList<>();
for (int i = 0; i < variants.size(); ++i) {
ModelResourceLocation resourceLocation = new ModelResourceLocation("skree:" + variants.get(i), "inventory");
if (!optMeshDefinition.isPresent()) {
mesher.register((Item) item, i, resourceLocation);
}
modelResources.add(resourceLocation);
}
ModelBakery.registerItemVariants((Item) item, modelResources.toArray(new ResourceLocation[modelResources.size()]));
}
} else {
throw new IllegalArgumentException("Invalid custom item!");
}
}
Aggregations