Add a basic fallback model for the bucket and cells when no renderer is present.

This commit is contained in:
modmuss50 2020-07-25 19:22:15 +01:00
parent 70dedfdaa3
commit 481634d29f

View file

@ -29,12 +29,14 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.model.ModelLoadingRegistry;
import net.fabricmc.fabric.api.client.rendereregistry.v1.BlockEntityRendererRegistry;
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
import net.minecraft.client.item.ModelPredicateProvider;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.ModelBakeSettings;
import net.minecraft.client.render.model.ModelLoader;
import net.minecraft.client.render.model.UnbakedModel;
import net.minecraft.client.render.model.json.JsonUnbakedModel;
import net.minecraft.client.texture.Sprite;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.client.util.SpriteIdentifier;
@ -92,6 +94,10 @@ public class TechRebornClient implements ClientModInitializer {
ModelLoadingRegistry.INSTANCE.registerVariantProvider(resourceManager -> (modelIdentifier, modelProviderContext) -> {
if (modelIdentifier.getNamespace().equals(TechReborn.MOD_ID)) {
if (modelIdentifier.getPath().equals("cell")) {
if (!RendererAccess.INSTANCE.hasRenderer()) {
return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"techreborn:item/cell_background\"}}");
}
return new UnbakedModel() {
@Override
public Collection<Identifier> getModelDependencies() {
@ -113,6 +119,10 @@ public class TechRebornClient implements ClientModInitializer {
}
Fluid fluid = Registry.FLUID.get(new Identifier(TechReborn.MOD_ID, modelIdentifier.getPath().split("_bucket")[0]));
if (modelIdentifier.getPath().endsWith("_bucket") && fluid != Fluids.EMPTY) {
if (!RendererAccess.INSTANCE.hasRenderer()) {
return JsonUnbakedModel.deserialize("{\"parent\":\"minecraft:item/generated\",\"textures\":{\"layer0\":\"minecraft:item/bucket\"}}");
}
return new UnbakedModel() {
@Override
public Collection<Identifier> getModelDependencies() {