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

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

The newest version!
package com.magistuarmory.client.render.tileentity;

import com.magistuarmory.EpicKnights;
import com.magistuarmory.block.PaviseBlockEntity;
import com.magistuarmory.client.render.model.ModModels;
import com.magistuarmory.client.render.model.block.PaviseBlockModel;
import com.mojang.datafixers.util.Pair;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.class_1088;
import net.minecraft.class_1767;
import net.minecraft.class_1921;
import net.minecraft.class_2215;
import net.minecraft.class_2582;
import net.minecraft.class_2680;
import net.minecraft.class_2960;
import net.minecraft.class_4587;
import net.minecraft.class_4588;
import net.minecraft.class_4597;
import net.minecraft.class_4608;
import net.minecraft.class_4722;
import net.minecraft.class_4730;
import net.minecraft.class_5614;
import net.minecraft.class_630;
import net.minecraft.class_6880;
import net.minecraft.class_7718;
import net.minecraft.class_7833;
import net.minecraft.class_827;
import net.minecraft.class_918;
import java.util.List;


@Environment(EnvType.CLIENT)
public class PaviseBlockRenderer implements class_827
{
	public static String DIR_PREFIX = "entity/pavese/";
	
	PaviseBlockModel model;
	class_630 handle;
	class_630 plate;
	
	public PaviseBlockRenderer(class_5614.class_5615 context)
	{
		this.model = new PaviseBlockModel(context.method_32140(ModModels.PAVISE_BLOCK_LOCATION));
		this.handle = this.model.handle();
		this.plate = this.model.plate();
	}

	@Override
	public int method_33893() 
	{
		return 128;
	}

	@Override
	public void render(PaviseBlockEntity pavise, float f, class_4587 pose, class_4597 buffer, int p, int overlay)
	{
		pose.method_22903();
		class_2680 blockstate = pavise.method_11010();
		pose.method_46416(0.5F, 0.5F, 0.5F);
		float yrot = -class_7718.method_45482(blockstate.method_11654(class_2215.field_9924));
		pose.method_22907(class_7833.field_40716.rotationDegrees(yrot));
		pose.method_22903();
		pose.method_22905(1.0F, -1.0F, -1.0F);
		boolean painted = pavise.isPainted();
		class_4730 material = new class_4730(class_4722.field_21707, new class_2960(EpicKnights.ID, "entity/" + pavise.getShieldId() + (painted ? "_pattern" : "_nopattern")));
		class_4588 vertexconsumer = material.method_24148().method_24108(class_918.method_29711(buffer, this.model.method_23500(material.method_24144()), true, pavise.hasFoil()));
		this.handle.method_22698(pose, vertexconsumer, p, class_4608.field_21444);
		this.plate.method_22698(pose, vertexconsumer, p, class_4608.field_21444);
		if (painted)
		{
			List, class_1767>> list = pavise.getPatterns();
			renderPatterns(pose, buffer, p, class_4608.field_21444, list, this.plate, class_1088.field_20847, pavise.hasFoil());
		}
		pose.method_22909();
		pose.method_22909();
	}

	public static void renderPatterns(class_4587 pose, class_4597 buffer, int p, int overlay, List, class_1767>> list, class_630 part, class_4730 basematerial, boolean hasfoil)
	{
		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, DIR_PREFIX + 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