generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 30 additions & 9 deletions
39
src/main/java/io/github/debuggyteam/architecture_extensions/util/SafeRenderLayer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,34 @@ | ||
package io.github.debuggyteam.architecture_extensions.util; | ||
|
||
public enum SafeRenderLayer { | ||
SOLID, | ||
TRANSLUCENT, | ||
CUTOUT; | ||
|
||
public static SafeRenderLayer combine(SafeRenderLayer first, SafeRenderLayer second) { | ||
if (first == TRANSLUCENT || second == TRANSLUCENT) return TRANSLUCENT; | ||
if (first == CUTOUT || second == CUTOUT) return CUTOUT; | ||
return SOLID; | ||
import java.util.function.Supplier; | ||
|
||
import org.quiltmc.loader.api.minecraft.ClientOnly; | ||
|
||
import net.minecraft.client.render.RenderLayer; | ||
|
||
public enum SafeRenderLayer implements @ClientOnly Supplier<RenderLayer> { | ||
SOLID(0), | ||
TRANSLUCENT(2), | ||
CUTOUT(1); | ||
|
||
private final int priority; | ||
|
||
SafeRenderLayer(int priority) { | ||
this.priority = priority; | ||
} | ||
|
||
@ClientOnly | ||
@Override | ||
public RenderLayer get() { | ||
return switch (this) { | ||
case SOLID -> RenderLayer.getSolid(); | ||
case TRANSLUCENT -> RenderLayer.getTranslucent(); | ||
case CUTOUT -> RenderLayer.getCutout(); | ||
}; | ||
} | ||
|
||
public static SafeRenderLayer choose(SafeRenderLayer first, SafeRenderLayer second) { | ||
if (second.priority > first.priority) return second; | ||
return first; | ||
} | ||
} |