Class Material
java.lang.Object
codechicken.lib.gui.modular.sprite.Material
This is similar to Minecraft's
Material
This contains the essential data required to render an atlas sprite.
The primary purpose of this class is to make porting between MC versions easier. It also allows for loading sprites from a custom texture atlas. Minecraft's material class can only load from vanilla atlases.
Created by brandon3055 on 20/08/2023
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.resources.ResourceLocationcom.mojang.blaze3d.vertex.VertexConsumerbuffer(net.minecraft.client.renderer.MultiBufferSource buffers, Function<net.minecraft.resources.ResourceLocation, net.minecraft.client.renderer.RenderType> typeBuilder) Convenience method to create a vertex consumer using this materials render type.static MaterialConvenient method for getting a material from a vanilla texture atlas.static @Nullable MaterialfromSprite(@Nullable net.minecraft.client.renderer.texture.TextureAtlasSprite sprite) Create a material from an existing sprite.net.minecraft.client.resources.model.Materialnet.minecraft.client.renderer.RenderTyperenderType(Function<net.minecraft.resources.ResourceLocation, net.minecraft.client.renderer.RenderType> typeBuilder) Returns the cached render type for this material.net.minecraft.client.renderer.texture.TextureAtlasSpritesprite()net.minecraft.resources.ResourceLocationtexture()
-
Constructor Details
-
Material
public Material(net.minecraft.resources.ResourceLocation atlasLocation, net.minecraft.resources.ResourceLocation texture, Function<net.minecraft.resources.ResourceLocation, net.minecraft.client.renderer.texture.TextureAtlasSprite> spriteFunction)
-
-
Method Details
-
atlasLocation
public net.minecraft.resources.ResourceLocation atlasLocation() -
texture
public net.minecraft.resources.ResourceLocation texture() -
sprite
public net.minecraft.client.renderer.texture.TextureAtlasSprite sprite() -
renderType
public net.minecraft.client.renderer.RenderType renderType(Function<net.minecraft.resources.ResourceLocation, net.minecraft.client.renderer.RenderType> typeBuilder) Returns the cached render type for this material. The supplied function will be used to create the render type the first time this method is called.- Parameters:
typeBuilder- a function that will be used to create the render type if it does not already exist.- Returns:
- The render type for this material.
-
buffer
public com.mojang.blaze3d.vertex.VertexConsumer buffer(net.minecraft.client.renderer.MultiBufferSource buffers, Function<net.minecraft.resources.ResourceLocation, net.minecraft.client.renderer.RenderType> typeBuilder) Convenience method to create a vertex consumer using this materials render type.- Parameters:
buffers- bugger source.typeBuilder- a function that will be used to create the render type if it does not already exist.
-
getVanillaMat
public net.minecraft.client.resources.model.Material getVanillaMat() -
fromAtlas
public static Material fromAtlas(net.minecraft.resources.ResourceLocation atlasLocation, String texture) Convenient method for getting a material from a vanilla texture atlas.- Returns:
- an un-cached material from a vanilla atlas.
-
fromSprite
@Nullable public static @Nullable Material fromSprite(@Nullable @Nullable net.minecraft.client.renderer.texture.TextureAtlasSprite sprite) Create a material from an existing sprite. Note: This will only work with sprites from a vanilla atlas.
-