All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.magistuarmory.client.render.tileentity.HeraldryItemStackRenderer Maven / Gradle / Ivy

There is a newer version: 8.10
Show newest version
package com.magistuarmory.client.render.tileentity;

import com.magistuarmory.EpicKnights;
import com.magistuarmory.client.render.model.ModModels;
import com.magistuarmory.client.render.model.item.*;
import com.mojang.datafixers.util.Pair;
import java.util.List;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_1747;
import net.minecraft.class_1767;
import net.minecraft.class_1799;
import net.minecraft.class_1819;
import net.minecraft.class_1921;
import net.minecraft.class_2573;
import net.minecraft.class_2582;
import net.minecraft.class_2960;
import net.minecraft.class_310;
import net.minecraft.class_3879;
import net.minecraft.class_4587;
import net.minecraft.class_4588;
import net.minecraft.class_4597;
import net.minecraft.class_4722;
import net.minecraft.class_4730;
import net.minecraft.class_5617;
import net.minecraft.class_630;
import net.minecraft.class_6880;
import net.minecraft.class_756;
import net.minecraft.class_811;
import net.minecraft.class_918;
import net.minecraft.world.item.*;

@Environment(EnvType.CLIENT)
public class HeraldryItemStackRenderer extends class_756
{
	private class_3879 model;
	private final String name;
	private final class_2960 locationPattern;
	private final class_2960 locationNoPattern;
	private final String patternsDirectory;

	public HeraldryItemStackRenderer(String id, String name)
	{
		super(class_310.method_1551().method_31975(), class_310.method_1551().method_31974());
		this.name = name;
		this.locationPattern = new class_2960(EpicKnights.ID, "entity/" + id + "_pattern");
		this.locationNoPattern = new class_2960(EpicKnights.ID, "entity/" + id + "_nopattern");
		this.patternsDirectory = "entity/" + name + "/";
	}
	
	public void loadModel(class_5617.class_5618 context)
	{
		this.model = new MedievalShieldModel(context.method_32167(ModModels.createLocation(name)));
	}

	@Override
	public void method_3166(class_1799 stack, class_811 transform, class_4587 pose, class_4597 buffer, int p, int overlay)
	{
		if (this.model instanceof MedievalShieldModel shieldmodel)
		{
			boolean flag = class_1747.method_38072(stack) != null;
			pose.method_22903();
			pose.method_22905(1.0F, -1.0F, -1.0F);
			class_4730 material = flag ? new class_4730(class_4722.field_21707, locationPattern) : new class_4730(class_4722.field_21707, locationNoPattern);
			class_4588 vertexconsumer = material.method_24148().method_24108(class_918.method_29711(buffer, this.model.method_23500(material.method_24144()), true, stack.method_7958()));
			shieldmodel.handle().method_22699(pose, vertexconsumer, p, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
			if (flag)
			{
				List, class_1767>> list = class_2573.method_24280(class_1819.method_8013(stack), class_2573.method_24281(stack));
				this.renderPatterns(pose, buffer, p, overlay, shieldmodel.plate(), material, list, stack.method_7958());
			}
			else
			{
				shieldmodel.plate().method_22699(pose, vertexconsumer, p, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
			}

			pose.method_22909();
		}
	}

	public void renderPatterns(class_4587 pose, class_4597 buffer, int p, int overlay, class_630 part, class_4730 basematerial, List, class_1767>> list, boolean hasfoil)
	{
		part.method_22698(pose, basematerial.method_30001(buffer, class_1921::method_23576, hasfoil), p, overlay);

		for(int i = 0; i < 17 && i < list.size(); ++i)
		{
			Pair, class_1767> pair = list.get(i);
			float[] color = pair.getSecond().method_7787();
			if (pair.getFirst().method_40230().isPresent())
			{
				class_4730 material = new class_4730(class_4722.field_21707, new class_2960(EpicKnights.ID, this.patternsDirectory + pair.getFirst().method_40230().get().method_29177().method_12832()));
				part.method_22699(pose, material.method_30001(buffer, class_1921::method_23588, hasfoil), p, overlay, color[0], color[1], color[2], 1.0F);
			}
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy