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

com.magistuarmory.item.ShieldsSupply Maven / Gradle / Ivy

package com.magistuarmory.item;

import com.magistuarmory.EpicKnights;
import dev.architectury.registry.registries.RegistrySupplier;
import net.minecraft.client.renderer.Sheets;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.entity.BannerPattern;

import java.util.function.BiFunction;
import java.util.function.Consumer;


public class ShieldsSupply extends ItemsSupply
{
	public String shieldName;

	public String woodTexture;
	public String stoneTexture;
	public String ironTexture;
	public String goldTexture;
	public String diamondTexture;
	public String netheriteTexture;

	public String copperTexture;
	public String steelTexture;
	public String silverTexture;
	public String tinTexture;
	public String bronzeTexture;

	public ShieldsSupply(BiFunction> workshop, String shieldName)
	{
		super(workshop, new Item.Properties());

		this.shieldName = shieldName;

		this.woodTexture = "entity/" + ModItemTier.WOOD.getMaterialName() + "_" + shieldName;
		this.stoneTexture = "entity/" + ModItemTier.STONE.getMaterialName() + "_" + shieldName;
		this.ironTexture = "entity/" + ModItemTier.IRON.getMaterialName() + "_" + shieldName;
		this.goldTexture = "entity/" + ModItemTier.GOLD.getMaterialName() + "_" + shieldName;
		this.diamondTexture = "entity/" + ModItemTier.DIAMOND.getMaterialName() + "_" + shieldName;
		this.copperTexture = "entity/" + ModItemTier.COPPER.getMaterialName() + "_" + shieldName;
		this.steelTexture = "entity/" + ModItemTier.STEEL.getMaterialName() + "_" + shieldName;
		this.silverTexture = "entity/" + ModItemTier.SILVER.getMaterialName() + "_" + shieldName;
		this.netheriteTexture = "entity/" + ModItemTier.NETHERITE.getMaterialName() + "_" + shieldName;
		this.tinTexture = "entity/" + ModItemTier.TIN.getMaterialName() + "_" + shieldName;
		this.bronzeTexture = "entity/" + ModItemTier.BRONZE.getMaterialName() + "_" + shieldName;
	}

	public void stitchWithoutPatterns(TextureAtlas atlas, Consumer adder)
	{
		if (atlas.m_118330_() == Sheets.f_110738_)
		{
			String[] textures = new String[] { this.woodTexture, this.stoneTexture, this.ironTexture, this.goldTexture, this.diamondTexture, this.netheriteTexture, this.copperTexture, this.steelTexture, this.silverTexture, this.netheriteTexture, this.tinTexture, this.bronzeTexture };
			for (String texture : textures)
			{
				adder.accept(new ResourceLocation(EpicKnights.ID, texture + "_nopattern"));
			}
		}
	}

	public void stitch(TextureAtlas atlas, Consumer adder)
	{
		if (atlas.m_118330_() == Sheets.f_110738_)
		{
			String[] textures = new String[] { this.woodTexture, this.stoneTexture, this.ironTexture, this.goldTexture, this.diamondTexture, this.netheriteTexture, this.copperTexture, this.steelTexture, this.silverTexture, this.netheriteTexture, this.tinTexture, this.bronzeTexture };
			for (String texture : textures)
			{
				ResourceLocation location1 = new ResourceLocation(EpicKnights.ID, texture + "_pattern");
				adder.accept(location1);
				ResourceLocation location2 = new ResourceLocation(EpicKnights.ID, texture + "_nopattern");
				adder.accept(location2);
			}

			for (ResourceKey resourcekey : Registry.f_235736_.m_214010_())
			{
				String filename = resourcekey.m_135782_().m_135815_();
				if (filename.contains(":"))
					filename = filename.split(":")[1];
				ResourceLocation location = new ResourceLocation(EpicKnights.ID, "entity/" + this.shieldName + "/" + filename);
				adder.accept(location);
			}
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy