mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-18 11:29:08 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
299e9d835d | ||
|
|
30f0835a21 | ||
|
|
3717d2d46e | ||
|
|
d69fd20a8b |
No files matched your search
@@ -26,12 +26,20 @@ public final class CaptureGate {
|
||||
public static final boolean TOOL_ATTACHED = detectCaptureTool();
|
||||
public static boolean markersThisFrame = true;
|
||||
public static boolean tracyConnected;
|
||||
private static boolean toolAttached = TOOL_ATTACHED;
|
||||
|
||||
private CaptureGate() {}
|
||||
|
||||
public static void refresh() {
|
||||
tracyConnected = Tracy.isConnected();
|
||||
markersThisFrame = gateValue(FORCED, TOOL_ATTACHED, tracyConnected);
|
||||
markersThisFrame = gateValue(FORCED, toolAttached, tracyConnected);
|
||||
}
|
||||
|
||||
static void probeGlTool() {
|
||||
if (RenderSystem.hasExtension("GL_EXT_debug_tool")) {
|
||||
toolAttached = true;
|
||||
LOGGER.info("Capture tool detected via GL_EXT_debug_tool; instrumentation enabled");
|
||||
}
|
||||
}
|
||||
|
||||
static boolean gateValue(boolean forced, boolean toolAttached, boolean tracyConnected) {
|
||||
@@ -39,7 +47,7 @@ public final class CaptureGate {
|
||||
}
|
||||
|
||||
public static boolean enabledAtStartup() {
|
||||
return FORCED || TOOL_ATTACHED;
|
||||
return FORCED || toolAttached;
|
||||
}
|
||||
|
||||
private static boolean detectCaptureTool() {
|
||||
|
||||
@@ -458,6 +458,7 @@ public class GLStateManager {
|
||||
static void init(Runnable initCallback) {
|
||||
final GLContextState glCtx = ctx();
|
||||
RenderSystem.initRenderer();
|
||||
CaptureGate.probeGlTool();
|
||||
|
||||
GLSMFramebuffer.queryDefaultDrawBuffer();
|
||||
|
||||
|
||||
@@ -443,7 +443,7 @@ public class RenderSystem {
|
||||
return clipDistanceEmulated;
|
||||
}
|
||||
|
||||
private static boolean hasExtension(String name) {
|
||||
static boolean hasExtension(String name) {
|
||||
final int count = GLSMQueries.glGetInteger(GL30.GL_NUM_EXTENSIONS);
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (name.equals(GLSMQueries.glGetStringi(GL11.GL_EXTENSIONS, i))) return true;
|
||||
|
||||
@@ -6,6 +6,8 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class StateSet {
|
||||
|
||||
public static final int R_DEPTH = 1;
|
||||
@@ -79,28 +81,47 @@ public final class StateSet {
|
||||
public static final StateSet CUTOUT = buildCutout();
|
||||
public static final StateSet MASKS = buildMasks();
|
||||
public static final StateSet CULL = buildCull();
|
||||
public static final StateSet BLOCK_ENTITY_PASS = buildBlockEntityPass();
|
||||
|
||||
private static CowStateStack<?>[] batchMembers() {
|
||||
return new CowStateStack<?>[] {
|
||||
GLSMBlend.getBlendState(), GLSMDepthStencilAlpha.getAlphaState(), GLSMDepthStencilAlpha.getDepthState(),
|
||||
GLSMBlend.getColorMask(), GLSMRasterizer.getPolygonState(),
|
||||
GLSMTextures.getTextures().getTextureUnitBindings(0), GLSMTextures.getTextures().getTextureUnitBindings(1),
|
||||
GLSMTextures.getActiveTextureUnitStack(),
|
||||
GLSMBlend.getBlendMode(), GLSMDepthStencilAlpha.getAlphaTest(), GLSMDepthStencilAlpha.getDepthTest(),
|
||||
GLSMLighting.getLightingState(), GLSMRasterizer.getCullState(), GLSMRasterizer.getPolygonOffsetFillState(),
|
||||
GLSMTextures.getTextures().getTextureUnitStates(0), GLSMTextures.getTextures().getTextureUnitStates(1),
|
||||
GLSMLighting.getLightStates()[0], GLSMLighting.getLightStates()[1],
|
||||
GLSMLighting.getLightDataStates()[0], GLSMLighting.getLightDataStates()[1],
|
||||
GLSMLighting.getColorMaterial(), GLSMLighting.getColorMaterialFace(), GLSMLighting.getColorMaterialParameter(),
|
||||
GLSMLighting.getLightModel(), GLSMLighting.getFrontMaterial(), GLSMLighting.getBackMaterial(),
|
||||
GLSMLighting.getNormalizeState(), GLSMLighting.getRescaleNormalState()
|
||||
};
|
||||
}
|
||||
|
||||
private static StateSet buildBatch() {
|
||||
return new StateSet(0,
|
||||
ids(
|
||||
GLSMBlend.getBlendState(), GLSMDepthStencilAlpha.getAlphaState(), GLSMDepthStencilAlpha.getDepthState(),
|
||||
GLSMBlend.getColorMask(), GLSMRasterizer.getPolygonState(),
|
||||
GLSMTextures.getTextures().getTextureUnitBindings(0), GLSMTextures.getTextures().getTextureUnitBindings(1),
|
||||
GLSMTextures.getActiveTextureUnitStack(),
|
||||
GLSMBlend.getBlendMode(), GLSMDepthStencilAlpha.getAlphaTest(), GLSMDepthStencilAlpha.getDepthTest(),
|
||||
GLSMLighting.getLightingState(), GLSMRasterizer.getCullState(), GLSMRasterizer.getPolygonOffsetFillState(),
|
||||
GLSMTextures.getTextures().getTextureUnitStates(0), GLSMTextures.getTextures().getTextureUnitStates(1),
|
||||
GLSMLighting.getLightStates()[0], GLSMLighting.getLightStates()[1],
|
||||
GLSMLighting.getLightDataStates()[0], GLSMLighting.getLightDataStates()[1],
|
||||
GLSMLighting.getColorMaterial(), GLSMLighting.getColorMaterialFace(), GLSMLighting.getColorMaterialParameter(),
|
||||
GLSMLighting.getLightModel(), GLSMLighting.getFrontMaterial(), GLSMLighting.getBackMaterial(),
|
||||
GLSMLighting.getNormalizeState(), GLSMLighting.getRescaleNormalState()
|
||||
),
|
||||
ids(batchMembers()),
|
||||
R_BLEND | R_DEPTH | R_COLOR_MASK | R_POLYGON | R_TEXTURE | R_ACTIVE_UNIT,
|
||||
B_FRAG_COLORBUF | B_LIGHTING,
|
||||
true);
|
||||
}
|
||||
|
||||
private static StateSet buildBlockEntityPass() {
|
||||
final CowStateStack<?>[] batch = batchMembers();
|
||||
final CowStateStack<?>[] all = Arrays.copyOf(batch, batch.length + 4);
|
||||
all[batch.length] = GLSMCurrentAttribs.getColor();
|
||||
all[batch.length + 1] = GLSMFog.getFogState();
|
||||
all[batch.length + 2] = GLSMFog.getFogMode();
|
||||
all[batch.length + 3] = GLSMRasterizer.getShadeModelState();
|
||||
return new StateSet(0,
|
||||
ids(all),
|
||||
R_BLEND | R_DEPTH | R_COLOR_MASK | R_POLYGON | R_TEXTURE | R_ACTIVE_UNIT,
|
||||
B_FRAG_COLORBUF | B_LIGHTING | B_CURRENT | B_FRAG_FOG,
|
||||
true);
|
||||
}
|
||||
|
||||
private static StateSet buildFont() {
|
||||
return new StateSet(0,
|
||||
ids(
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.gtnewhorizons.angelica.glsm.GLDebug;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMTextureLifetime;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.backend.BackendManager;
|
||||
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
|
||||
|
||||
import static com.gtnewhorizons.angelica.glsm.backend.BackendManager.RENDER_BACKEND;
|
||||
|
||||
@@ -16,11 +17,18 @@ public final class FrameHooks {
|
||||
private static boolean gameLoopStarted;
|
||||
private static long frameCounter;
|
||||
private static boolean frameGroupActive;
|
||||
private static String framePrefix = "frame:";
|
||||
private static String buildLabel = "";
|
||||
|
||||
public static void bootstrapFirstFrame() {
|
||||
DisplayListManager.abortIfLeaked();
|
||||
if (!gameLoopStarted) {
|
||||
gameLoopStarted = true;
|
||||
final GLSMInitConfig config = GLStateManager.getInitConfig();
|
||||
if (config != null && !config.getBuildLabel().isEmpty()) {
|
||||
buildLabel = config.getBuildLabel();
|
||||
framePrefix = buildLabel + " frame:";
|
||||
}
|
||||
RENDER_BACKEND.onFrameBegin();
|
||||
pushFrameGroup();
|
||||
}
|
||||
@@ -48,8 +56,10 @@ public final class FrameHooks {
|
||||
}
|
||||
|
||||
private static void pushFrameGroup() {
|
||||
final boolean wasConnected = CaptureGate.tracyConnected;
|
||||
CaptureGate.refresh();
|
||||
GLDebug.pushGroup("frame:", frameCounter);
|
||||
if (CaptureGate.tracyConnected && !wasConnected && !buildLabel.isEmpty()) Tracy.message(buildLabel);
|
||||
GLDebug.pushGroup(framePrefix, frameCounter);
|
||||
frameGroupActive = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ public final class GLSMInitConfig {
|
||||
@Getter private final Runnable postInitCallback;
|
||||
private final boolean dsaEnabled;
|
||||
@Getter private final boolean noErrorChecks;
|
||||
@Getter private final String buildLabel;
|
||||
|
||||
private GLSMInitConfig(Builder builder) {
|
||||
this.lwjglDebug = builder.lwjglDebug;
|
||||
@@ -27,6 +28,7 @@ public final class GLSMInitConfig {
|
||||
this.displayHeight = builder.displayHeight;
|
||||
this.postInitCallback = builder.postInitCallback;
|
||||
this.dsaEnabled = builder.dsaEnabled;
|
||||
this.buildLabel = builder.buildLabel;
|
||||
}
|
||||
|
||||
public boolean isDSAEnabled() {
|
||||
@@ -46,6 +48,7 @@ public final class GLSMInitConfig {
|
||||
private Runnable postInitCallback = null;
|
||||
private boolean dsaEnabled = true;
|
||||
private boolean noErrorChecks;
|
||||
private String buildLabel = "";
|
||||
|
||||
private Builder() {}
|
||||
|
||||
@@ -85,6 +88,11 @@ public final class GLSMInitConfig {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder buildLabel(String buildLabel) {
|
||||
this.buildLabel = buildLabel == null ? "" : buildLabel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GLSMInitConfig build() {
|
||||
return new GLSMInitConfig(this);
|
||||
}
|
||||
|
||||
@@ -167,6 +167,33 @@ public class GLSM_StateSet_GLTest {
|
||||
|| GLSMBlend.getColorMask().blue || GLSMBlend.getColorMask().alpha, "cache color mask - not a HAND member, must stay toggled");
|
||||
}
|
||||
|
||||
@Test
|
||||
void blockEntityPassRestoresColorFogAndShadeModelOnTopOfBatchButNotStencil() {
|
||||
GLSMCurrentAttribs.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
GLSMFog.disableFog();
|
||||
GLSMFog.glFogf(GL11.GL_FOG_END, 64.0f);
|
||||
GLSMRasterizer.glShadeModel(GL11.GL_SMOOTH);
|
||||
GLSMDepthStencilAlpha.glDepthMask(true);
|
||||
GLSMEnable.glDisable(GL11.GL_STENCIL_TEST);
|
||||
|
||||
final int d = GLSMAttribStack.pushState(StateSet.BLOCK_ENTITY_PASS);
|
||||
GLSMCurrentAttribs.glColor4f(0.2f, 0.4f, 0.6f, 0.8f);
|
||||
GLSMFog.enableFog();
|
||||
GLSMFog.glFogf(GL11.GL_FOG_END, 8.0f);
|
||||
GLSMRasterizer.glShadeModel(GL11.GL_FLAT);
|
||||
GLSMDepthStencilAlpha.glDepthMask(false);
|
||||
GLSMEnable.glEnable(GL11.GL_STENCIL_TEST);
|
||||
GLSMAttribStack.popStateTo(d);
|
||||
|
||||
assertEquals(1.0f, GLSMCurrentAttribs.getColor().getRed(), "cache color red");
|
||||
assertEquals(1.0f, GLSMCurrentAttribs.getColor().getAlpha(), "cache color alpha");
|
||||
assertFalse(GLSMFog.getFogMode().isEnabled(), "fog enable restored by BLOCK_ENTITY_PASS pop");
|
||||
assertEquals(64.0f, GLSMFog.getFogState().getEnd(), "cache fog end");
|
||||
assertEquals(GL11.GL_SMOOTH, GLSMRasterizer.getShadeModelState().getValue(), "cache shade model");
|
||||
assertTrue(GLSMDepthStencilAlpha.getDepthState().isEnabled(), "depth mask restored, as in BATCH");
|
||||
verifyIsEnabled(GL11.GL_STENCIL_TEST, true, "Stencil test - not a BLOCK_ENTITY_PASS member, must stay toggled");
|
||||
}
|
||||
|
||||
@Test
|
||||
void masksRestoresDepthMaskAndColorMaskButNotDepthTestEnable() {
|
||||
GLSMDepthStencilAlpha.glDepthMask(true);
|
||||
|
||||
@@ -36,6 +36,7 @@ tasks.withType<JavaExec>().matching { it.name.startsWith("runClient") }.configur
|
||||
for (name in forwardedRunProperties) {
|
||||
jvmArgs("-D$name=${System.getProperty(name)}")
|
||||
}
|
||||
jvmArgs("-Dangelica.buildVersion=${project.version}")
|
||||
}
|
||||
|
||||
val isMacOs = org.gradle.internal.os.OperatingSystem.current().isMacOsX
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
# Translucent TESR ordering scene for a generated superflat (windows-flyby-kit/make_world.py). Needs
|
||||
# -Dangelica.debug.testBlocks=true. $x $y $z is the flight start; ground-standing level is $y-2. Start facing south (yaw 0),
|
||||
# pitch 15. Blocks: test_tesr_provider (0 translucent red, 1 additive purple), test_tesr_model (0 box pane,
|
||||
# 1 Tessellator pane, 2 stacked A/B/A panes), test_tesr_decal, test_tesr_glow; metadata + 8 draws in the solid pass.
|
||||
|
||||
gamerule doMobSpawning false
|
||||
|
||||
# translucent pass: three rows, materials shifted per row so every column stacks three different ones
|
||||
setblock $x-2 $y $z+6 angelica:test_tesr_provider 0 replace
|
||||
setblock $x-1 $y $z+6 angelica:test_tesr_provider 1 replace
|
||||
setblock $x+0 $y $z+6 angelica:test_tesr_model 0 replace
|
||||
setblock $x+1 $y $z+6 angelica:test_tesr_model 1 replace
|
||||
setblock $x-2 $y $z+8 angelica:test_tesr_provider 1 replace
|
||||
setblock $x-1 $y $z+8 angelica:test_tesr_model 0 replace
|
||||
setblock $x+0 $y $z+8 angelica:test_tesr_model 1 replace
|
||||
setblock $x+1 $y $z+8 angelica:test_tesr_provider 0 replace
|
||||
setblock $x-2 $y $z+10 angelica:test_tesr_model 0 replace
|
||||
setblock $x-1 $y $z+10 angelica:test_tesr_model 1 replace
|
||||
setblock $x+0 $y $z+10 angelica:test_tesr_provider 0 replace
|
||||
setblock $x+1 $y $z+10 angelica:test_tesr_provider 1 replace
|
||||
|
||||
# solid pass: the same rows two blocks higher
|
||||
setblock $x-2 $y+2 $z+6 angelica:test_tesr_provider 8 replace
|
||||
setblock $x-1 $y+2 $z+6 angelica:test_tesr_provider 9 replace
|
||||
setblock $x+0 $y+2 $z+6 angelica:test_tesr_model 8 replace
|
||||
setblock $x+1 $y+2 $z+6 angelica:test_tesr_model 9 replace
|
||||
setblock $x-2 $y+2 $z+8 angelica:test_tesr_provider 9 replace
|
||||
setblock $x-1 $y+2 $z+8 angelica:test_tesr_model 8 replace
|
||||
setblock $x+0 $y+2 $z+8 angelica:test_tesr_model 9 replace
|
||||
setblock $x+1 $y+2 $z+8 angelica:test_tesr_provider 8 replace
|
||||
setblock $x-2 $y+2 $z+10 angelica:test_tesr_model 8 replace
|
||||
setblock $x-1 $y+2 $z+10 angelica:test_tesr_model 9 replace
|
||||
setblock $x+0 $y+2 $z+10 angelica:test_tesr_provider 8 replace
|
||||
setblock $x+1 $y+2 $z+10 angelica:test_tesr_provider 9 replace
|
||||
|
||||
# one tile entity submitting translucent A, additive B, translucent A; a depth-equal decal
|
||||
setblock $x-7 $y $z+8 angelica:test_tesr_model 2 replace
|
||||
setblock $x-7 $y+1 $z+8 angelica:test_tesr_decal 0 replace
|
||||
|
||||
# light blue glass wall: glow and provider panes in front, a provider pane behind. The panes behind the wall and
|
||||
# under the water show only when block entities draw before translucent terrain.
|
||||
setblock $x+5 $y-1 $z+14 stained_glass 3 replace
|
||||
setblock $x+5 $y $z+14 stained_glass 3 replace
|
||||
setblock $x+5 $y+1 $z+14 stained_glass 3 replace
|
||||
setblock $x+6 $y-1 $z+14 stained_glass 3 replace
|
||||
setblock $x+6 $y $z+14 stained_glass 3 replace
|
||||
setblock $x+6 $y+1 $z+14 stained_glass 3 replace
|
||||
setblock $x+7 $y-1 $z+14 stained_glass 3 replace
|
||||
setblock $x+7 $y $z+14 stained_glass 3 replace
|
||||
setblock $x+7 $y+1 $z+14 stained_glass 3 replace
|
||||
setblock $x+8 $y-1 $z+14 stained_glass 3 replace
|
||||
setblock $x+8 $y $z+14 stained_glass 3 replace
|
||||
setblock $x+8 $y+1 $z+14 stained_glass 3 replace
|
||||
setblock $x+9 $y-1 $z+14 stained_glass 3 replace
|
||||
setblock $x+9 $y $z+14 stained_glass 3 replace
|
||||
setblock $x+9 $y+1 $z+14 stained_glass 3 replace
|
||||
setblock $x+6 $y $z+13 angelica:test_tesr_glow 0 replace
|
||||
setblock $x+8 $y $z+13 angelica:test_tesr_provider 0 replace
|
||||
setblock $x+7 $y $z+15 angelica:test_tesr_provider 0 replace
|
||||
|
||||
# water pool with a provider pane under the surface
|
||||
setblock $x-10 $y-4 $z+12 water 0 replace
|
||||
setblock $x-10 $y-3 $z+12 water 0 replace
|
||||
setblock $x-10 $y-4 $z+13 water 0 replace
|
||||
setblock $x-10 $y-3 $z+13 water 0 replace
|
||||
setblock $x-10 $y-4 $z+14 water 0 replace
|
||||
setblock $x-10 $y-3 $z+14 water 0 replace
|
||||
setblock $x-9 $y-4 $z+12 water 0 replace
|
||||
setblock $x-9 $y-3 $z+12 water 0 replace
|
||||
setblock $x-9 $y-4 $z+13 water 0 replace
|
||||
setblock $x-9 $y-3 $z+13 water 0 replace
|
||||
setblock $x-9 $y-4 $z+14 water 0 replace
|
||||
setblock $x-9 $y-3 $z+14 water 0 replace
|
||||
setblock $x-8 $y-4 $z+12 water 0 replace
|
||||
setblock $x-8 $y-3 $z+12 water 0 replace
|
||||
setblock $x-8 $y-4 $z+13 water 0 replace
|
||||
setblock $x-8 $y-3 $z+13 water 0 replace
|
||||
setblock $x-8 $y-4 $z+14 water 0 replace
|
||||
setblock $x-8 $y-3 $z+14 water 0 replace
|
||||
setblock $x-9 $y-4 $z+13 angelica:test_tesr_provider 0 replace
|
||||
|
||||
# control: a lone pane with sky behind it
|
||||
setblock $x+5 $y+2 $z+8 angelica:test_tesr_provider 0 replace
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gtnewhorizons.angelica.common;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class BlockTesrTranslucentTest extends Block {
|
||||
|
||||
private final Supplier<TileEntity> tile;
|
||||
|
||||
public BlockTesrTranslucentTest(Supplier<TileEntity> tile) {
|
||||
super(Material.glass);
|
||||
this.tile = tile;
|
||||
setHardness(0.3f);
|
||||
setLightOpacity(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTileEntity(int metadata) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata) {
|
||||
return tile.get();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.gtnewhorizons.angelica.common;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public abstract class TileTesrTranslucentTest extends TileEntity {
|
||||
|
||||
private static final int SOLID_PASS = 8;
|
||||
|
||||
public int variant() {
|
||||
return getBlockMetadata() & ~SOLID_PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRenderInPass(int pass) {
|
||||
return pass == ((getBlockMetadata() & SOLID_PASS) != 0 ? 0 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class Provider extends TileTesrTranslucentTest {}
|
||||
|
||||
public static class Model extends TileTesrTranslucentTest {}
|
||||
|
||||
public static class Decal extends TileTesrTranslucentTest {}
|
||||
|
||||
public static class Glow extends TileTesrTranslucentTest {}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.gtnewhorizons.angelica.compat.spark;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassVisitor;
|
||||
import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public final class SparkKnownSources {
|
||||
private static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
private static final String PLUGIN = "me/lucko/spark/forge/plugin/Forge1710SparkPlugin";
|
||||
private static final String SOURCE_METADATA = "me.lucko.spark.common.sampler.source.SourceMetadata";
|
||||
|
||||
private static MethodHandle constructor;
|
||||
private static boolean failed;
|
||||
|
||||
private SparkKnownSources() {}
|
||||
|
||||
public static boolean mixinApplies() {
|
||||
try (InputStream stream = SparkKnownSources.class.getResourceAsStream("/" + PLUGIN + ".class")) {
|
||||
if (stream == null) {
|
||||
return false;
|
||||
}
|
||||
final boolean[] declared = new boolean[1];
|
||||
new ClassReader(stream).accept(new ClassVisitor(Opcodes.ASM5) {
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
||||
if ("getKnownSources".equals(name) && "()Ljava/util/Collection;".equals(desc)) {
|
||||
declared[0] = true;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
|
||||
if (declared[0]) {
|
||||
LOGGER.info("spark already reports mod sources; skipping");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable t) {
|
||||
LOGGER.warn("Could not inspect spark plugin class; not adding mod sources", t);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Collection<Object> gather(ClassLoader loader) {
|
||||
if (failed) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
try {
|
||||
if (constructor == null) constructor = MethodHandles.publicLookup().findConstructor(Class.forName(SOURCE_METADATA, false, loader),
|
||||
MethodType.methodType(void.class, String.class, String.class, String.class, String.class));
|
||||
final List<ModContainer> mods = Loader.instance().getActiveModList();
|
||||
final List<Object> sources = new ArrayList<>(mods.size());
|
||||
for (int i = 0; i < mods.size(); i++) {
|
||||
final ModContainer mod = mods.get(i);
|
||||
sources.add(constructor.invoke(mod.getModId(), mod.getVersion(), (String) null, (String) null));
|
||||
}
|
||||
return sources;
|
||||
} catch (Throwable t) {
|
||||
failed = true;
|
||||
LOGGER.warn("Could not build spark mod sources; profiles will omit mod versions", t);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.gtnewhorizons.angelica.mixins;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.MixinBuilder;
|
||||
import com.gtnewhorizons.angelica.api.BlockLightProvider;
|
||||
import com.gtnewhorizons.angelica.compat.spark.SparkKnownSources;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.config.SystemProperties;
|
||||
@@ -641,6 +642,13 @@ public enum Mixins implements IMixins {
|
||||
)
|
||||
),
|
||||
|
||||
SPARK_MOD_SOURCES(new MixinBuilder("Mod versions in spark 1.7.10 profiles")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.SPARK)
|
||||
.setApplyIf(SparkKnownSources::mixinApplies)
|
||||
.addClientMixins("spark.MixinForge1710SparkPlugin")
|
||||
),
|
||||
|
||||
ANGELICA_TEXTURE(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins(
|
||||
|
||||
@@ -32,6 +32,7 @@ public enum TargetedMod implements ITargetMod {
|
||||
OPENBLOCKS(null, "OpenBlocks"),
|
||||
RAILCRAFT(null, "Railcraft"),
|
||||
SECURITYCRAFT(null, "securitycraft"),
|
||||
SPARK(null, "spark"),
|
||||
STARMINER("jp.mc.ancientred.starminer.core.SMPlugin", "modJ_StarMiner"),
|
||||
SUPERNOVA("com.mitchej123.supernova.core.SupernovaCore", "supernova"),
|
||||
THAUMCRAFT(null, "Thaumcraft"),
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.common.BlockError;
|
||||
import com.gtnewhorizons.angelica.common.BlockIsbrhTest;
|
||||
import com.gtnewhorizons.angelica.common.TileEntityClipPlaneTest;
|
||||
import com.gtnewhorizons.angelica.common.TileTesrTranslucentTest;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -75,6 +76,7 @@ import com.gtnewhorizons.angelica.rendering.ClipPlaneTestRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.FpsReducer;
|
||||
import com.gtnewhorizons.angelica.rendering.FramePacer;
|
||||
import com.gtnewhorizons.angelica.rendering.IsbrhTestRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.TesrTranslucentTestRenderers;
|
||||
import com.gtnewhorizons.angelica.rendering.TextureSamplers;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasSetup;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasWorldRenderer;
|
||||
@@ -150,6 +152,10 @@ public final class ClientProxy extends CommonProxy {
|
||||
BlockIsbrhTest.renderId = RenderingRegistry.getNextAvailableRenderId();
|
||||
RenderingRegistry.registerBlockHandler(BlockIsbrhTest.renderId, new IsbrhTestRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityClipPlaneTest.class, new ClipPlaneTestRenderer());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTesrTranslucentTest.Provider.class, new TesrTranslucentTestRenderers.Provider());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTesrTranslucentTest.Model.class, new TesrTranslucentTestRenderers.Model());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTesrTranslucentTest.Decal.class, new TesrTranslucentTestRenderers.Decal());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileTesrTranslucentTest.Glow.class, new TesrTranslucentTestRenderers.Glow());
|
||||
}
|
||||
AngelicaJar.configureShaderDiskCache(event.getSourceFile());
|
||||
if (AngelicaConfig.enableIris) {
|
||||
|
||||
@@ -2,13 +2,18 @@ package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import com.gtnewhorizons.angelica.common.BlockClipPlaneTest;
|
||||
import com.gtnewhorizons.angelica.common.BlockIsbrhTest;
|
||||
import com.gtnewhorizons.angelica.common.BlockTesrTranslucentTest;
|
||||
import com.gtnewhorizons.angelica.common.BlockTest;
|
||||
import com.gtnewhorizons.angelica.common.TileEntityClipPlaneTest;
|
||||
import com.gtnewhorizons.angelica.common.TileTesrTranslucentTest;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CommonProxy {
|
||||
|
||||
@@ -18,9 +23,18 @@ public class CommonProxy {
|
||||
GameRegistry.registerBlock(new BlockIsbrhTest(), "test_isbrh");
|
||||
GameRegistry.registerBlock(new BlockClipPlaneTest(), "test_clip_plane");
|
||||
GameRegistry.registerTileEntity(TileEntityClipPlaneTest.class, "angelica:test_clip_plane");
|
||||
registerTesrTest("test_tesr_provider", TileTesrTranslucentTest.Provider.class, TileTesrTranslucentTest.Provider::new);
|
||||
registerTesrTest("test_tesr_model", TileTesrTranslucentTest.Model.class, TileTesrTranslucentTest.Model::new);
|
||||
registerTesrTest("test_tesr_decal", TileTesrTranslucentTest.Decal.class, TileTesrTranslucentTest.Decal::new);
|
||||
registerTesrTest("test_tesr_glow", TileTesrTranslucentTest.Glow.class, TileTesrTranslucentTest.Glow::new);
|
||||
}
|
||||
}
|
||||
|
||||
private static void registerTesrTest(String name, Class<? extends TileEntity> tile, Supplier<TileEntity> factory) {
|
||||
GameRegistry.registerBlock(new BlockTesrTranslucentTest(factory), name);
|
||||
GameRegistry.registerTileEntity(tile, "angelica:" + name);
|
||||
}
|
||||
|
||||
public void init(FMLInitializationEvent event) {}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {}
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.api.tesr.TesrMaterial;
|
||||
import com.gtnewhorizons.angelica.api.tesr.TesrMeshProvider;
|
||||
import com.gtnewhorizons.angelica.api.tesr.TesrMeshSink;
|
||||
import com.gtnewhorizons.angelica.common.TileTesrTranslucentTest;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMBlend;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMCurrentAttribs;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMDepthStencilAlpha;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMEnable;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMMatrices;
|
||||
import com.gtnewhorizons.angelica.utils.WorkaroundUtils;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public final class TesrTranslucentTestRenderers {
|
||||
|
||||
private static final double HALF = 0.4375;
|
||||
|
||||
private TesrTranslucentTestRenderers() {}
|
||||
|
||||
private static void pane(Tessellator t, double half) {
|
||||
rect(t, -half, -half, half, half);
|
||||
}
|
||||
|
||||
private static void rect(Tessellator t, double x0, double y0, double x1, double y1) {
|
||||
t.setNormal(0f, 0f, -1f);
|
||||
t.addVertexWithUV(0.5 + x0, 0.5 + y0, 0.5, 0, 1);
|
||||
t.addVertexWithUV(0.5 + x0, 0.5 + y1, 0.5, 0, 0);
|
||||
t.addVertexWithUV(0.5 + x1, 0.5 + y1, 0.5, 1, 0);
|
||||
t.addVertexWithUV(0.5 + x1, 0.5 + y0, 0.5, 1, 1);
|
||||
}
|
||||
|
||||
private static void drawPane(double half) {
|
||||
final Tessellator t = Tessellator.instance;
|
||||
t.startDrawingQuads();
|
||||
pane(t, half);
|
||||
t.draw();
|
||||
}
|
||||
|
||||
private static void apply(TesrMaterial material) {
|
||||
if (material.transparency() == TesrMaterial.Transparency.ADDITIVE) {
|
||||
GLSMBlend.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
} else {
|
||||
GLSMBlend.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
GLSMCurrentAttribs.glColor4f(material.colorRed(), material.colorGreen(), material.colorBlue(), material.colorAlpha());
|
||||
}
|
||||
|
||||
private abstract static class PaneRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
void begin(double x, double y, double z) {
|
||||
bindTexture(WorkaroundUtils.GL_TEXTURE_2D_WORKAROUND);
|
||||
GLSMMatrices.glPushMatrix();
|
||||
GLSMMatrices.glTranslated(x, y, z);
|
||||
GLSMEnable.glDisable(GL11.GL_CULL_FACE);
|
||||
GLSMEnable.glEnable(GL11.GL_BLEND);
|
||||
}
|
||||
|
||||
static void end() {
|
||||
GLSMCurrentAttribs.glColor4f(1f, 1f, 1f, 1f);
|
||||
GLSMBlend.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
GLSMEnable.glDisable(GL11.GL_BLEND);
|
||||
GLSMEnable.glEnable(GL11.GL_CULL_FACE);
|
||||
GLSMMatrices.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Provider extends PaneRenderer implements TesrMeshProvider {
|
||||
|
||||
private static final TesrMaterial[] MATERIALS = {
|
||||
TesrMaterial.builder().color(1f, 0f, 0f, 0.5f).translucent().noCull().build(),
|
||||
TesrMaterial.builder().color(0.5f, 0f, 0.5f, 1f).additive().noCull().build() };
|
||||
private static final Object[] KEYS = { new Object(), new Object() };
|
||||
|
||||
private static int kind(TileEntity te) {
|
||||
return ((TileTesrTranslucentTest) te).variant() == 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object angelica$meshKey(TileEntity te) {
|
||||
return KEYS[kind(te)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void angelica$build(TesrMeshSink sink, TileEntity te) {
|
||||
pane(sink.angelica$bucket(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, WorkaroundUtils.GL_TEXTURE_2D_WORKAROUND, MATERIALS[kind(te)]), HALF);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) {
|
||||
begin(x, y, z);
|
||||
apply(MATERIALS[kind(te)]);
|
||||
drawPane(HALF);
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Model extends PaneRenderer {
|
||||
|
||||
private static final TesrMaterial TRANSLUCENT_GREEN = TesrMaterial.builder().color(0f, 1f, 0f, 0.5f).translucent().build();
|
||||
private static final TesrMaterial TRANSLUCENT_YELLOW = TesrMaterial.builder().color(1f, 1f, 0f, 0.5f).translucent().build();
|
||||
private static final TesrMaterial TRANSLUCENT_MAGENTA = TesrMaterial.builder().color(1f, 0f, 1f, 0.5f).translucent().build();
|
||||
private static final TesrMaterial ADDITIVE_CYAN = TesrMaterial.builder().color(0f, 0.6f, 0.6f, 1f).additive().build();
|
||||
|
||||
private final ModelBase model = new ModelBase() {};
|
||||
private final ModelRenderer base = new ModelRenderer(model, 0, 0);
|
||||
private final ModelRenderer pane = paneAt(0f);
|
||||
private final ModelRenderer paneFar = paneAt(0.16f);
|
||||
private final ModelRenderer paneNear = paneAt(-0.16f);
|
||||
|
||||
public Model() {
|
||||
base.addBox(-1f, 7f, -1f, 2, 1, 2);
|
||||
}
|
||||
|
||||
private ModelRenderer paneAt(float z) {
|
||||
final ModelRenderer renderer = new ModelRenderer(model, 0, 0);
|
||||
renderer.addBox(-7f, -7f, z, 14, 14, 0);
|
||||
return renderer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) {
|
||||
final float scale = 1f / 16f;
|
||||
bindTexture(WorkaroundUtils.GL_TEXTURE_2D_WORKAROUND);
|
||||
GLSMMatrices.glPushMatrix();
|
||||
GLSMMatrices.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
GLSMCurrentAttribs.glColor4f(1f, 1f, 1f, 1f);
|
||||
base.render(scale);
|
||||
GLSMEnable.glEnable(GL11.GL_BLEND);
|
||||
switch (((TileTesrTranslucentTest) te).variant()) {
|
||||
case 0 -> {
|
||||
apply(TRANSLUCENT_GREEN);
|
||||
pane.render(scale);
|
||||
}
|
||||
case 1 -> {
|
||||
apply(TRANSLUCENT_YELLOW);
|
||||
GLSMMatrices.glTranslated(-0.5, -0.5, -0.5);
|
||||
drawPane(HALF);
|
||||
}
|
||||
default -> {
|
||||
apply(TRANSLUCENT_MAGENTA);
|
||||
paneFar.render(scale);
|
||||
apply(ADDITIVE_CYAN);
|
||||
pane.render(scale);
|
||||
apply(TRANSLUCENT_GREEN);
|
||||
paneNear.render(scale);
|
||||
}
|
||||
}
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Decal extends PaneRenderer implements TesrMeshProvider {
|
||||
|
||||
private static final TesrMaterial WRITER = TesrMaterial.builder().color(1f, 1f, 1f, 0.5f).translucent().noCull().build();
|
||||
private static final TesrMaterial DECAL = TesrMaterial.builder().color(0f, 0f, 0f, 0.8f).translucent().depthEqual().noCull().build();
|
||||
private static final Object KEY = new Object();
|
||||
private static final double INNER = HALF / 2;
|
||||
|
||||
private static void writer(Tessellator t) {
|
||||
rect(t, -HALF, INNER, HALF, HALF);
|
||||
rect(t, -HALF, -HALF, HALF, -INNER);
|
||||
rect(t, -HALF, -INNER, -INNER, INNER);
|
||||
rect(t, INNER, -INNER, HALF, INNER);
|
||||
pane(t, INNER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object angelica$meshKey(TileEntity te) {
|
||||
return KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void angelica$build(TesrMeshSink sink, TileEntity te) {
|
||||
writer(sink.angelica$bucket(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, WorkaroundUtils.GL_TEXTURE_2D_WORKAROUND, WRITER));
|
||||
pane(sink.angelica$bucket(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, WorkaroundUtils.GL_TEXTURE_2D_WORKAROUND, DECAL), INNER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) {
|
||||
begin(x, y, z);
|
||||
apply(WRITER);
|
||||
final Tessellator t = Tessellator.instance;
|
||||
t.startDrawingQuads();
|
||||
writer(t);
|
||||
t.draw();
|
||||
GLSMDepthStencilAlpha.glDepthFunc(GL11.GL_EQUAL);
|
||||
apply(DECAL);
|
||||
drawPane(INNER);
|
||||
GLSMDepthStencilAlpha.glDepthFunc(GL11.GL_LEQUAL);
|
||||
end();
|
||||
}
|
||||
}
|
||||
|
||||
public static final class Glow extends PaneRenderer {
|
||||
|
||||
private static final TesrMaterial TRANSLUCENT_ORANGE = TesrMaterial.builder().color(1f, 0.5f, 0f, 0.6f).translucent().build();
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTicks) {
|
||||
begin(x, y, z);
|
||||
apply(TRANSLUCENT_ORANGE);
|
||||
GLSMDepthStencilAlpha.glDepthMask(false);
|
||||
drawPane(HALF);
|
||||
GLSMDepthStencilAlpha.glDepthMask(true);
|
||||
end();
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
-38
@@ -1,19 +1,19 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.bop.FogBiomeCache;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.client.ForgeHooksClient;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
@@ -37,15 +37,21 @@ import org.embeddedt.embeddium.impl.render.viewport.frustum.SimpleFrustum;
|
||||
import org.joml.FrustumIntersection;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.cubicchunks.CubicChunksAPI;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightWorldRenderer;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMAttribStack;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMBlend;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMCurrentAttribs;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMDepthStencilAlpha;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMMatrices;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMRasterizer;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMTextures;
|
||||
import com.gtnewhorizons.angelica.glsm.StateSet;
|
||||
import com.gtnewhorizons.angelica.glsm.ffp.FfpExtendedAttribs;
|
||||
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITileEntityBoundingBoxCache;
|
||||
@@ -66,6 +72,8 @@ import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHold
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.TesrAttribution;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.TesrBatchRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.TesrLifecycle;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.coderbot.iris.pipeline.ShadowRenderer;
|
||||
|
||||
public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, AngelicaRenderSectionManager, BlockRenderLayer, TileEntity, CeleritasWorldRenderer.TileEntityRenderContext> implements IDynamicLightWorldRenderer {
|
||||
@@ -75,6 +83,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
private static final Tracy.ZoneId Z_TESR_DISPATCH = Tracy.zoneId("tesrDispatch", Tracy.COLOR_CLIENT);
|
||||
private static final Tracy.ZoneId Z_TESR_MODEL_PARTS = Tracy.zoneId("tesrModelParts", Tracy.COLOR_CLIENT);
|
||||
private static final Tracy.ZoneId Z_TESR_RENDER_TE = Tracy.zoneId("tesrRenderTE", Tracy.COLOR_CLIENT);
|
||||
private static final long P_BLOCK_ENTITIES_RENDERED = Tracy.plotHandle("blockEntitiesRendered");
|
||||
|
||||
private final Minecraft mc;
|
||||
private static CeleritasWorldRenderer instance;
|
||||
@@ -95,9 +104,11 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
private final ObjectArrayList<TileEntity> frameTEs = new ObjectArrayList<>();
|
||||
private final ObjectArrayList<TileEntity> frameOverride = new ObjectArrayList<>();
|
||||
|
||||
// For sorting transparent TESRs
|
||||
private final TileEntityOrderer tileEntityOrderer = new TileEntityOrderer();
|
||||
private final ArrayList<TileEntity> sortedTileEntities = new ArrayList<>();
|
||||
private final TileEntityDepthOrder depthOrder = new TileEntityDepthOrder();
|
||||
private final Matrix4f savedTextureMatrix = new Matrix4f();
|
||||
private PassOne passOne = PassOne.NONE;
|
||||
|
||||
private enum PassOne { NONE, PENDING, DRAWN_EARLY }
|
||||
|
||||
private CeleritasWorldRenderer(Minecraft mc) {
|
||||
// Private constructor for singleton
|
||||
@@ -172,7 +183,6 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
DynamicLights.setActiveRenderer(null);
|
||||
this.frameTEs.clear();
|
||||
this.frameOverride.clear();
|
||||
this.sortedTileEntities.clear();
|
||||
ShadowRenderer.visibleTileEntities.clear();
|
||||
ShadowRenderer.globalTileEntities.clear();
|
||||
TesrLifecycle.reset();
|
||||
@@ -408,6 +418,58 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
GLSMCurrentAttribs.glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
public void renderBlockEntitiesBeforeTranslucent(float partialTicks) {
|
||||
if (passOne != PassOne.PENDING) return;
|
||||
passOne = PassOne.DRAWN_EARLY;
|
||||
if (frameOverride.isEmpty()) return;
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
final int previousPass = MinecraftForgeClient.getRenderPass();
|
||||
final int depth = GLSMAttribStack.pushState(StateSet.BLOCK_ENTITY_PASS);
|
||||
savedTextureMatrix.set(GLSMTextures.getTextures().getTextureUnitMatrix(0));
|
||||
GLSMMatrices.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GLSMMatrices.glPushMatrix();
|
||||
try {
|
||||
GLSMDepthStencilAlpha.glDepthMask(true);
|
||||
GLSMDepthStencilAlpha.enableAlphaTest();
|
||||
GLSMTextures.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
GLSMTextures.enableTexture();
|
||||
GLSMCurrentAttribs.glColor4f(1f, 1f, 1f, 1f);
|
||||
if (mc.gameSettings.fancyGraphics) {
|
||||
GLSMBlend.disableBlend();
|
||||
GLSMRasterizer.glShadeModel(GL11.GL_FLAT);
|
||||
}
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
mc.entityRenderer.enableLightmap(partialTicks);
|
||||
ForgeHooksClient.setRenderPass(1);
|
||||
renderBlockEntitiesInPhase(partialTicks);
|
||||
} finally {
|
||||
ForgeHooksClient.setRenderPass(previousPass);
|
||||
GLSMMatrices.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GLSMMatrices.glPopMatrix();
|
||||
GLSMMatrices.setTextureMatrix(0, savedTextureMatrix);
|
||||
GLSMAttribStack.popStateTo(depth);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean takeLatePassOne() {
|
||||
final boolean late = passOne != PassOne.DRAWN_EARLY;
|
||||
passOne = PassOne.NONE;
|
||||
return late;
|
||||
}
|
||||
|
||||
public void renderBlockEntitiesInPhase(float partialTicks) {
|
||||
if (Iris.enabled) {
|
||||
GbufferPrograms.beginBlockEntities();
|
||||
GbufferPrograms.setBlockEntityDefaults();
|
||||
}
|
||||
try {
|
||||
final int rendered = renderBlockEntities(partialTicks);
|
||||
if (Tracy.ENABLED) Tracy.plotInt(P_BLOCK_ENTITIES_RENDERED, rendered);
|
||||
} finally {
|
||||
if (Iris.enabled) GbufferPrograms.endBlockEntities();
|
||||
}
|
||||
}
|
||||
|
||||
public int renderBlockEntities(float partialTicks) {
|
||||
AngelicaTesrMeshCache.INSTANCE.tick();
|
||||
final int pass = MinecraftForgeClient.getRenderPass();
|
||||
@@ -442,6 +504,9 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
this.teTransform = null;
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_TESR_DISPATCH);
|
||||
try {
|
||||
if (ClientProxy.options().performance.translucencySorting) {
|
||||
depthOrder.sortBackToFront(frameTEs, teCamX, teCamY, teCamZ);
|
||||
}
|
||||
for (int i = 0; i < frameTEs.size(); i++) {
|
||||
final TileEntity te = frameTEs.get(i);
|
||||
if (!(te instanceof OverridesShouldRenderInPass)) {
|
||||
@@ -458,23 +523,17 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
} finally {
|
||||
if (Tracy.ENABLED) Tracy.endZone();
|
||||
}
|
||||
passOne = PassOne.PENDING;
|
||||
} else {
|
||||
if (Tracy.ENABLED) Tracy.beginZone(Z_TESR_DISPATCH);
|
||||
try {
|
||||
sortedTileEntities.clear();
|
||||
for (int i = 0; i < frameOverride.size(); i++) {
|
||||
final TileEntity te = frameOverride.get(i);
|
||||
if (te.shouldRenderInPass(pass)) {
|
||||
sortedTileEntities.add(te);
|
||||
dispatchTE(te, partialTicks);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (sortedTileEntities.size() > 1 && ClientProxy.options().performance.translucencySorting) {
|
||||
sortedTileEntities.sort(tileEntityOrderer.setLastCameraState(lastCameraState));
|
||||
}
|
||||
for (int i = 0; i < sortedTileEntities.size(); i++) {
|
||||
dispatchTE(sortedTileEntities.get(i), partialTicks);
|
||||
}
|
||||
count = sortedTileEntities.size();
|
||||
} finally {
|
||||
if (Tracy.ENABLED) Tracy.endZone();
|
||||
}
|
||||
@@ -673,27 +732,4 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private static class TileEntityOrderer implements Comparator<TileEntity> {
|
||||
public CameraState lastCameraState;
|
||||
|
||||
public TileEntityOrderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public TileEntityOrderer setLastCameraState(CameraState lastCameraState) {
|
||||
this.lastCameraState = lastCameraState;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(TileEntity te1, TileEntity te2) {
|
||||
final double x = this.lastCameraState.x();
|
||||
final double y = this.lastCameraState.y();
|
||||
final double z = this.lastCameraState.z();
|
||||
final double d1 = te1.getDistanceFrom(x, y, z);
|
||||
final double d2 = te2.getDistanceFrom(x, y, z);
|
||||
return Double.compare(d2, d1);
|
||||
}
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
final class TileEntityDepthOrder {
|
||||
|
||||
private static final int RADIX_BITS = 8;
|
||||
private static final int BUCKETS = 1 << RADIX_BITS;
|
||||
|
||||
private final int[] counts = new int[BUCKETS];
|
||||
private int[] keys = new int[0];
|
||||
private int[] keysScratch = new int[0];
|
||||
private int[] order = new int[0];
|
||||
private int[] orderScratch = new int[0];
|
||||
private TileEntity[] entities = new TileEntity[0];
|
||||
|
||||
void sortBackToFront(ObjectArrayList<TileEntity> list, double camX, double camY, double camZ) {
|
||||
final int n = list.size();
|
||||
if (n < 2) return;
|
||||
final Object[] source = list.elements();
|
||||
if (keys.length < n) {
|
||||
final int capacity = source.length;
|
||||
keys = new int[capacity];
|
||||
keysScratch = new int[capacity];
|
||||
order = new int[capacity];
|
||||
orderScratch = new int[capacity];
|
||||
entities = new TileEntity[capacity];
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
final TileEntity te = (TileEntity) source[i];
|
||||
final double dx = te.xCoord + 0.5 - camX;
|
||||
final double dy = te.yCoord + 0.5 - camY;
|
||||
final double dz = te.zCoord + 0.5 - camZ;
|
||||
keys[i] = Integer.MAX_VALUE - Float.floatToRawIntBits((float) (dx * dx + dy * dy + dz * dz));
|
||||
order[i] = i;
|
||||
entities[i] = te;
|
||||
}
|
||||
final int[] sorted = sortOrder(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
source[i] = entities[sorted[i]];
|
||||
entities[sorted[i]] = null;
|
||||
}
|
||||
}
|
||||
|
||||
private int[] sortOrder(int n) {
|
||||
int[] keyIn = keys, keyOut = keysScratch;
|
||||
int[] idxIn = order, idxOut = orderScratch;
|
||||
for (int shift = 0; shift < Integer.SIZE; shift += RADIX_BITS) {
|
||||
Arrays.fill(counts, 0);
|
||||
for (int i = 0; i < n; i++) counts[(keyIn[i] >>> shift) & (BUCKETS - 1)]++;
|
||||
if (counts[(keyIn[0] >>> shift) & (BUCKETS - 1)] == n) continue;
|
||||
int sum = 0;
|
||||
for (int b = 0; b < BUCKETS; b++) {
|
||||
final int c = counts[b];
|
||||
counts[b] = sum;
|
||||
sum += c;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
final int dst = counts[(keyIn[i] >>> shift) & (BUCKETS - 1)]++;
|
||||
keyOut[dst] = keyIn[i];
|
||||
idxOut[dst] = idxIn[i];
|
||||
}
|
||||
final int[] k = keyIn;
|
||||
keyIn = keyOut;
|
||||
keyOut = k;
|
||||
final int[] x = idxIn;
|
||||
idxIn = idxOut;
|
||||
idxOut = x;
|
||||
}
|
||||
keys = keyIn;
|
||||
keysScratch = keyOut;
|
||||
order = idxIn;
|
||||
orderScratch = idxOut;
|
||||
return idxIn;
|
||||
}
|
||||
}
|
||||
@@ -412,6 +412,14 @@ public class SodiumGameOptionPages {
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
)
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.block_entities_before_translucent_terrain.name"))
|
||||
.setTooltip(I18n.format("sodium.options.block_entities_before_translucent_terrain.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> opts.performance.blockEntitiesBeforeTranslucentTerrain = value, opts -> opts.performance.blockEntitiesBeforeTranslucentTerrain)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build()
|
||||
)
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.use_entity_culling.name"))
|
||||
.setTooltip(I18n.format("sodium.options.use_entity_culling.tooltip"))
|
||||
|
||||
@@ -234,6 +234,7 @@ public class SodiumGameOptions {
|
||||
public boolean useBlockFaceCulling = true;
|
||||
public boolean useCompactVertexFormat = true;
|
||||
public boolean translucencySorting = true;
|
||||
public boolean blockEntitiesBeforeTranslucentTerrain = true;
|
||||
public boolean useRenderPassOptimization = true;
|
||||
public int cpuRenderAheadLimit = 3;
|
||||
}
|
||||
|
||||
@@ -91,6 +91,8 @@ sodium.options.animate_only_visible_textures.name=Animate Only Visible Textures
|
||||
sodium.options.animate_only_visible_textures.tooltip=If enabled, only animated textures determined to be visible will be updated. This can provide a significant boost to frame rates on some hardware, especially with heavier resource packs. If you experience issues with some textures not being animated, try disabling this option.
|
||||
sodium.options.translucency_sorting.name=Translucency Sorting
|
||||
sodium.options.translucency_sorting.tooltip=If enabled, translucent terrain (water, stained glass, ice) and translucent tile entities are sorted back to front so overlapping layers draw correctly. Disabling improves performance in scenes with lots of translucent blocks but causes layering artifacts. Changing this reloads chunks.
|
||||
sodium.options.block_entities_before_translucent_terrain.name=Tile Entities Before Translucent Terrain
|
||||
sodium.options.block_entities_before_translucent_terrain.tooltip=If enabled, translucent tile entities are drawn before translucent terrain (water, stained glass, ice), so that the latter does not hide the former behind it. Tile Entities in front of terrain may hide the terrain, and glows in front of terrain may appear behind it.
|
||||
sodium.options.cpu_render_ahead_limit.name=CPU Render-Ahead Limit
|
||||
sodium.options.cpu_render_ahead_limit.tooltip=How many frames the CPU may run ahead of the GPU. Lower values cut input latency, higher values smooth out uneven frame times. Very low or high values may create frame rate instability. 0 disables it; the SDL-GPU backend ignores it and applies its own backpressure.
|
||||
sodium.options.cpu_render_ahead_limit.value=%s frame(s)
|
||||
|
||||
+2
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.mixins.early.angelica.startup;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.core.GTNHLibCore;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.client.rendering.TextureTracker;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.SystemProperties;
|
||||
@@ -47,6 +48,7 @@ public class MixinInitGLStateManager {
|
||||
.noErrorChecks(AngelicaConfig.disableErrorChecks && GTNHLibCore.isObf() && !AngelicaMod.lwjglDebug)
|
||||
.enableDSA(AngelicaConfig.enableDSA)
|
||||
.postInitCallback(SelectionBoxRenderer::init)
|
||||
.buildLabel("Angelica " + Tags.VERSION)
|
||||
.build());
|
||||
BackendStartGuard.disarm();
|
||||
|
||||
|
||||
+19
-15
@@ -9,6 +9,7 @@ import com.gtnewhorizons.angelica.glsm.GLSMEnable;
|
||||
import com.gtnewhorizons.angelica.glsm.GLSMTextures;
|
||||
import com.gtnewhorizons.angelica.glsm.profiling.Tracy;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt;
|
||||
import com.gtnewhorizons.angelica.proxy.ClientProxy;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
|
||||
@@ -18,7 +19,6 @@ import com.gtnewhorizons.angelica.rendering.tesr.ModelPartBatcher;
|
||||
import com.gtnewhorizons.angelica.rendering.tesr.TesrBatchRenderer;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
@@ -34,6 +34,7 @@ import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import org.embeddedt.embeddium.impl.gl.device.RenderDevice;
|
||||
import org.embeddedt.embeddium.impl.render.terrain.SimpleWorldRenderer;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
@@ -63,7 +64,6 @@ import static org.joml.Math.lerp;
|
||||
*/
|
||||
@Mixin(value = RenderGlobal.class, priority = 900)
|
||||
public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
@Unique private static final long P_BLOCK_ENTITIES_RENDERED = Tracy.plotHandle("blockEntitiesRendered");
|
||||
@Unique private static final Tracy.ZoneId Z_MT_QUEUE = Tracy.zoneId("mtQueue", Tracy.COLOR_TERRAIN);
|
||||
|
||||
@Shadow public Minecraft mc;
|
||||
@@ -146,10 +146,13 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
pipeline = Iris.getPipelineManager().getPipelineNullable();
|
||||
if (pass == 0) {
|
||||
pipeline.setPhase(WorldRenderingPhase.TERRAIN_SOLID);
|
||||
} else if (pass == 1) {
|
||||
if (!ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
|
||||
iris$beginTranslucents(pipeline, Camera.INSTANCE);
|
||||
}
|
||||
} else if (pass == 1 && !ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
|
||||
iris$beginTranslucents(pipeline, Camera.INSTANCE);
|
||||
}
|
||||
}
|
||||
if (pass == 1) {
|
||||
celeritas$renderBlockEntitiesBeforeTranslucent(partialTicks);
|
||||
if (pipeline != null) {
|
||||
pipeline.setPhase(WorldRenderingPhase.TERRAIN_TRANSLUCENT);
|
||||
this.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
}
|
||||
@@ -276,17 +279,18 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/RenderHelper;enableStandardItemLighting()V", ordinal = 0))
|
||||
private void celeritas$enterBlockEntities() {}
|
||||
|
||||
@Unique
|
||||
private void celeritas$renderBlockEntitiesBeforeTranslucent(double partialTicks) {
|
||||
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) return;
|
||||
if (!ClientProxy.options().performance.blockEntitiesBeforeTranslucentTerrain) return;
|
||||
if (this.mc.entityRenderer.debugViewDirection != 0) return;
|
||||
this.celeritas$renderer.renderBlockEntitiesBeforeTranslucent((float) partialTicks);
|
||||
}
|
||||
|
||||
@Surround.Return("blockEntities")
|
||||
private void celeritas$renderTileEntities(@Surround.Local(argsOnly = true) float partialTicks) {
|
||||
if (Iris.enabled) {
|
||||
GbufferPrograms.beginBlockEntities();
|
||||
GbufferPrograms.setBlockEntityDefaults();
|
||||
}
|
||||
final int blockEntitiesRendered = this.celeritas$renderer.renderBlockEntities(partialTicks);
|
||||
if (Tracy.ENABLED) Tracy.plotInt(P_BLOCK_ENTITIES_RENDERED, blockEntitiesRendered);
|
||||
if (Iris.enabled) {
|
||||
GbufferPrograms.endBlockEntities();
|
||||
}
|
||||
if (MinecraftForgeClient.getRenderPass() == 1 && !this.celeritas$renderer.takeLatePassOne()) return;
|
||||
this.celeritas$renderer.renderBlockEntitiesInPhase(partialTicks);
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/RenderGlobal;tileEntities:Ljava/util/List;", opcode = Opcodes.GETFIELD))
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.spark;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.spark.SparkKnownSources;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Pseudo;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Pseudo
|
||||
@Mixin(targets = "me.lucko.spark.forge.plugin.Forge1710SparkPlugin", remap = false)
|
||||
public abstract class MixinForge1710SparkPlugin {
|
||||
@Unique
|
||||
public Collection<Object> getKnownSources() {
|
||||
return SparkKnownSources.gather(getClass().getClassLoader());
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class TileEntityDepthOrderTest {
|
||||
|
||||
private static TileEntity at(int x, int y, int z) {
|
||||
final TileEntity te = new TileEntity();
|
||||
te.xCoord = x;
|
||||
te.yCoord = y;
|
||||
te.zCoord = z;
|
||||
return te;
|
||||
}
|
||||
|
||||
@Test
|
||||
void sortsFarthestFirstAndKeepsTiesInListOrder() {
|
||||
final TileEntity near = at(0, 0, 2);
|
||||
final TileEntity far = at(0, 0, 181);
|
||||
final TileEntity mid = at(0, 0, 5);
|
||||
final TileEntity midOpposite = at(0, 0, -5);
|
||||
final ObjectArrayList<TileEntity> list = new ObjectArrayList<>(Arrays.asList(near, far, mid, midOpposite));
|
||||
new TileEntityDepthOrder().sortBackToFront(list, 0.5, 0.5, 0.5);
|
||||
assertEquals(Arrays.asList(far, mid, midOpposite, near), list);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user