com.magistuarmory.client.render.fabric.ModRenderImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of 1.20.2-epic-knights-fabric Show documentation
Show all versions of 1.20.2-epic-knights-fabric Show documentation
mod that adds medieval stuff to the game
The newest version!
package com.magistuarmory.client.render.fabric;
import com.magistuarmory.EpicKnights;
import com.magistuarmory.client.render.ModRender;
import com.magistuarmory.client.render.entity.layer.ArmorDecorationLayer;
import com.magistuarmory.client.render.entity.layer.HorseArmorDecorationLayer;
import com.magistuarmory.client.render.model.decoration.ArmorDecorationModelSet;
import com.magistuarmory.client.render.tileentity.HeraldryItemStackRenderer;
import com.magistuarmory.fabric.client.render.entity.layer.MedievalArmorLayer;
import com.magistuarmory.fabric.client.render.tileentity.HeraldryItemStackRendererFabric;
import com.magistuarmory.item.MedievalShieldItem;
import com.magistuarmory.api.item.ModItemsProvider;
import com.magistuarmory.item.ModItems;
import dev.architectury.registry.registries.RegistrySupplier;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendering.v1.ArmorRenderer;
import net.fabricmc.fabric.api.client.rendering.v1.BuiltinItemRendererRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.LivingEntityFeatureRendererRegistrationCallback;
import net.minecraft.class_1007;
import net.minecraft.class_1299;
import net.minecraft.class_1309;
import net.minecraft.class_1792;
import net.minecraft.class_2960;
import net.minecraft.class_5617;
import net.minecraft.class_572;
import net.minecraft.class_910;
import net.minecraft.class_922;
@Environment(EnvType.CLIENT)
public class ModRenderImpl
{
static void addLayers(ModItemsProvider content, class_1299 extends class_1309> entitytype, class_922, ?> renderer, LivingEntityFeatureRendererRegistrationCallback.RegistrationHelper helper, class_5617.class_5618 context)
{
if (content.armorDecorationItems.isEmpty())
return;
if (renderer.method_4038() instanceof class_572)
helper.register(new ArmorDecorationLayer(new ArmorDecorationModelSet<>(content.armorDecorationItems, context), renderer, context, new class_2960(EpicKnights.ID, "surcoat")));
else if (renderer instanceof class_1007 renderer0)
helper.register(new ArmorDecorationLayer(new ArmorDecorationModelSet<>(content.armorDecorationItems, context), renderer0, context, new class_2960(EpicKnights.ID, "surcoat")));
if (renderer instanceof class_910 renderer0 && content instanceof ModItems)
helper.register(new HorseArmorDecorationLayer(renderer0, context, new class_2960(content.modId, "textures/entity/horse/armor/caparison.png"), "caparison"));
}
public static void setupPlatform(ModItemsProvider content)
{
for (RegistrySupplier extends class_1792> supplier : content.armorItems)
ArmorRenderer.register(new MedievalArmorLayer(), supplier.get());
for (RegistrySupplier extends MedievalShieldItem> supplier : content.shieldItems)
if (supplier.get().is3d())
BuiltinItemRendererRegistry.INSTANCE.register(supplier.get(), (BuiltinItemRendererRegistry.DynamicItemRenderer) supplier.get().getRenderer());
}
public static void registerModelsLoadListener(ModItemsProvider content)
{
LivingEntityFeatureRendererRegistrationCallback.EVENT.register((entitytype, renderer, helper, context) -> {
ModRender.loadModels(content, context);
addLayers(content, entitytype, renderer, helper, context);
});
}
public static HeraldryItemStackRenderer createHeraldryItemStackRenderer(String id, class_2960 location)
{
return new HeraldryItemStackRendererFabric(id, location);
}
}