|
public class MyRenderTypes |
|
{ |
|
// Accessor functon, ensures that you don't use the raw methods below unintentionally. |
|
public static RenderType brightSolid(ResourceLocation texture) |
|
{ |
|
return CustomRenderTypes.BRIGHT_SOLID.apply(texture); |
|
} |
|
|
|
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = GuidebookMod.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) |
|
public static class ModClientEvents |
|
{ |
|
@SubscribeEvent |
|
public static void shaderRegistry(RegisterShadersEvent event) throws IOException |
|
{ |
|
// Adds a shader to the list, the callback runs when loading is complete. |
|
event.registerShader(new ShaderInstance(event.getResourceManager(), new ResourceLocation("gbook:rendertype_bright_solid"), DefaultVertexFormat.NEW_ENTITY), shaderInstance -> { |
|
CustomRenderTypes.brightSolidShader = shaderInstance; |
|
}); |
|
} |
|
} |
|
|
|
// Keep private because this stuff isn't meant to be public |
|
private static class CustomRenderTypes extends RenderType |
|
{ |
|
// Holds the object loaded via RegisterShadersEvent |
|
private static ShaderInstance brightSolidShader; |
|
|
|
// Shader state for use in the render type, the supplier ensures it updates automatically with resource reloads |
|
private static final ShaderStateShard RENDERTYPE_BRIGHT_SOLID_SHADER = new ShaderStateShard(() -> brightSolidShader); |
|
|
|
// Dummy constructor needed to make java happy |
|
private CustomRenderTypes(String s, VertexFormat v, VertexFormat.Mode m, int i, boolean b, boolean b2, Runnable r, Runnable r2) |
|
{ |
|
super(s, v, m, i, b, b2, r, r2); |
|
throw new IllegalStateException("This class is not meant to be constructed!"); |
|
} |
|
|
|
// The memoize caches the output value for each input, meaning the expensive registration process doesn't have to rerun |
|
public static Function<ResourceLocation, RenderType> BRIGHT_SOLID = Util.memoize(CustomRenderTypes::brightSolid); |
|
|
|
// Defines the RenderType. Make sure the name is unique by including your MODID in the name. |
|
private static RenderType brightSolid(ResourceLocation locationIn) |
|
{ |
|
RenderType.CompositeState rendertype$state = RenderType.CompositeState.builder() |
|
.setShaderState(RENDERTYPE_BRIGHT_SOLID_SHADER) |
|
.setTextureState(new RenderStateShard.TextureStateShard(locationIn, false, false)) |
|
.setTransparencyState(NO_TRANSPARENCY) |
|
.setLightmapState(NO_LIGHTMAP) |
|
.setOverlayState(NO_OVERLAY) |
|
.createCompositeState(true); |
|
return create("gbook_bright_solid", DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, rendertype$state); |
|
} |
|
} |
|
} |
hey, quick question, in my case I got a core shader particle.json and a post shader effect.json. My particle.json shader is supposed to overwrite the default particle.json core shader. Does this get done automatically or do I also need to do the above for it?