Skip to content

Commit

Permalink
Add RenderMaterial to RenderTypeGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaMode committed Dec 5, 2024
1 parent 13d8149 commit 1f47190
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
import net.fabricmc.fabric.api.renderer.v1.mesh.Mesh;
import net.fabricmc.fabric.api.renderer.v1.mesh.MeshBuilder;
import net.fabricmc.fabric.api.renderer.v1.mesh.QuadView;
import net.minecraft.client.renderer.block.model.BakedQuad;
Expand Down Expand Up @@ -69,7 +70,7 @@ private Simple(boolean hasAmbientOcclusion, boolean usesBlockLight, boolean isGu
this.overrides = overrides;
this.particle = particle;
this.renderTypes = renderTypes;
this.material = RendererAccess.INSTANCE.getRenderer().materialFinder().blendMode(BlendMode.fromRenderLayer(renderTypes.block())).find();
this.material = renderTypes.material();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.github.fabricators_of_create.porting_lib.render_types;

import net.fabricmc.fabric.api.renderer.v1.RendererAccess;
import net.fabricmc.fabric.api.renderer.v1.material.BlendMode;
import net.fabricmc.fabric.api.renderer.v1.material.RenderMaterial;
import net.minecraft.client.renderer.RenderType;

/**
Expand All @@ -8,12 +11,16 @@
* {@code entityFabulous} may support custom render targets and other aspects of the fabulous pipeline, or can otherwise
* be the same as {@code entity}.
*/
public record RenderTypeGroup(RenderType block, RenderType entity, RenderType entityFabulous) {
public record RenderTypeGroup(RenderType block, RenderType entity, RenderType entityFabulous, RenderMaterial material) {
public RenderTypeGroup {
if ((block == null) != (entity == null) || (block == null) != (entityFabulous == null))
throw new IllegalArgumentException("The render types in a group must either be all null, or all non-null.");
}

public RenderTypeGroup(RenderType block, RenderType entity, RenderType entityFabulous) {
this(block, entity, entityFabulous, RendererAccess.INSTANCE.getRenderer().materialFinder().blendMode(BlendMode.fromRenderLayer(block)).find());
}

public RenderTypeGroup(RenderType block, RenderType entity) {
this(block, entity, entity);
}
Expand Down

0 comments on commit 1f47190

Please sign in to comment.