mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-20 20:32:14 +00:00
Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f5c9fa3301 | ||
|
|
d6a6d3b525 | ||
|
|
f079bed977 | ||
|
|
c9ec40e94b | ||
|
|
8380f3853d | ||
|
|
534ae6b05c | ||
|
|
68d523d3df | ||
|
|
2f22a7b3ad | ||
|
|
7b79b90dd6 |
No files matched your search
+2
-3
@@ -108,8 +108,7 @@ dependencies {
|
||||
|
||||
compileOnly("curse.maven:minefactory-reloaded-66672:2277486")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.1.10:dev") // Mixin Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.1.10:dev")
|
||||
|
||||
compileOnly(rfg.deobf("maven.modrinth:ntmspace:X5593_H261"))
|
||||
|
||||
@@ -126,7 +125,7 @@ dependencies {
|
||||
transformedMod("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
||||
|
||||
// Better Crashes
|
||||
compileOnly("com.github.GTNewHorizons:BetterCrashes:1.4.0-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:BetterCrashes:1.4.1-GTNH:dev")
|
||||
|
||||
afterEvaluate {
|
||||
dependencies {
|
||||
|
||||
@@ -75,11 +75,9 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
public BatchingFontRenderer(FontRenderer underlying, int[] charWidth, byte[] glyphWidth,
|
||||
int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
public BatchingFontRenderer(FontRenderer underlying, int[] charWidth, int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
this.underlying = underlying;
|
||||
this.charWidth = charWidth;
|
||||
this.glyphWidth = glyphWidth;
|
||||
this.colorCode = colorCode;
|
||||
this.locationFontTexture = locationFontTexture;
|
||||
|
||||
@@ -92,7 +90,6 @@ public class BatchingFontRenderer {
|
||||
|
||||
FontProviderMC.get(this.isSGA).charWidth = this.charWidth;
|
||||
FontProviderMC.get(this.isSGA).locationFontTexture = this.locationFontTexture;
|
||||
FontProviderUnicode.get().glyphWidth = this.glyphWidth;
|
||||
|
||||
//noinspection deprecation
|
||||
fontShaderId = FontAAShader.getProgram().getProgramId();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import lombok.Setter;
|
||||
import lombok.Value;
|
||||
@@ -46,7 +45,7 @@ public final class FontProviderCustom implements FontProvider {
|
||||
default -> null;
|
||||
};
|
||||
if (Objects.equals(myFontName, "(none)")) {
|
||||
font = null;
|
||||
this.font = null;
|
||||
return;
|
||||
}
|
||||
int fontPos = -1;
|
||||
@@ -58,10 +57,10 @@ public final class FontProviderCustom implements FontProvider {
|
||||
}
|
||||
if (fontPos == -1) {
|
||||
LOGGER.info("Could not find previously set font \"{}\". ", myFontName);
|
||||
font = null;
|
||||
this.font = null;
|
||||
return;
|
||||
}
|
||||
font = availableFonts[fontPos].deriveFont(currentFontQuality);
|
||||
this.font = availableFonts[fontPos].deriveFont(this.currentFontQuality);
|
||||
}
|
||||
private static class InstLoader {
|
||||
static final FontProviderCustom instance0 = new FontProviderCustom((byte)0);
|
||||
@@ -71,8 +70,8 @@ public final class FontProviderCustom implements FontProvider {
|
||||
public static FontProviderCustom getFallback() { return InstLoader.instance1; }
|
||||
|
||||
public void reloadFont(int fontID) {
|
||||
currentFontQuality = FontConfig.customFontQuality;
|
||||
font = FontStrategist.getAvailableFonts()[fontID].deriveFont(currentFontQuality);
|
||||
this.currentFontQuality = FontConfig.customFontQuality;
|
||||
this.font = FontStrategist.getAvailableFonts()[fontID].deriveFont(this.currentFontQuality);
|
||||
|
||||
File[] files = new File(getFontDir()).listFiles();
|
||||
if (files != null) {
|
||||
@@ -94,7 +93,7 @@ public final class FontProviderCustom implements FontProvider {
|
||||
}
|
||||
}
|
||||
|
||||
fontAtlases = new FontAtlas[ATLAS_COUNT];
|
||||
this.fontAtlases = new FontAtlas[ATLAS_COUNT];
|
||||
}
|
||||
|
||||
private String getFontDir() {
|
||||
@@ -134,50 +133,44 @@ public final class FontProviderCustom implements FontProvider {
|
||||
}
|
||||
|
||||
void construct(Font font) {
|
||||
float separator = currentFontQuality / 3f;
|
||||
int atlasChars = 0;
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
final char ch = (char) (i + ATLAS_SIZE * this.id);
|
||||
if (font.canDisplay(ch)) { atlasChars++; }
|
||||
}
|
||||
if (atlasChars == 0) { return; }
|
||||
|
||||
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
g2d.setFont(font);
|
||||
FontMetrics fm = g2d.getFontMetrics();
|
||||
g2d.dispose();
|
||||
int width = 0;
|
||||
int actualChars = 0;
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (font.canDisplay(ch)) {
|
||||
width += (int) (separator + fm.charWidth(ch));
|
||||
actualChars++;
|
||||
}
|
||||
}
|
||||
if (actualChars == 0) {
|
||||
return;
|
||||
}
|
||||
final int atlasTilesX = (int) Math.ceil(Math.sqrt(actualChars) * 1.5f);
|
||||
final int atlasTilesY = (int) Math.ceil((double) actualChars / atlasTilesX);
|
||||
LOGGER.info("constructing custom font atlas (ID {}) of nominal size {} chars, actual: {}, {} rows by {} columns",
|
||||
this.id, ATLAS_SIZE, actualChars, atlasTilesX, atlasTilesY);
|
||||
width = 0;
|
||||
actualChars = 0;
|
||||
|
||||
final int atlasTilesX = (int) Math.ceil(Math.sqrt(atlasChars) * 1.5f);
|
||||
final int atlasTilesY = (int) Math.ceil((double) atlasChars / atlasTilesX);
|
||||
final float charSeparator = currentFontQuality / 3f;
|
||||
int rowWidth = 0;
|
||||
int maxRowWidth = 0;
|
||||
atlasChars = 0;
|
||||
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
if (actualChars % atlasTilesX == 0) {
|
||||
maxRowWidth = Math.max(maxRowWidth, width);
|
||||
width = 0;
|
||||
if (atlasChars % atlasTilesX == 0) {
|
||||
maxRowWidth = Math.max(maxRowWidth, rowWidth);
|
||||
rowWidth = 0;
|
||||
}
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (font.canDisplay(ch)) {
|
||||
width += (int) (separator + fm.charWidth(ch));
|
||||
actualChars++;
|
||||
rowWidth += (int) (charSeparator + fm.charWidth(ch));
|
||||
atlasChars++;
|
||||
}
|
||||
}
|
||||
maxRowWidth = Math.max(maxRowWidth, width);
|
||||
maxRowWidth = Math.max(maxRowWidth, rowWidth);
|
||||
|
||||
final int lineHeight = fm.getHeight();
|
||||
final float desc = fm.getDescent();
|
||||
|
||||
final int imageWidth = (int) (maxRowWidth + separator);
|
||||
final int imageHeight = (int) ((separator + lineHeight) * atlasTilesY + separator);
|
||||
final int imageWidth = (int) (maxRowWidth + charSeparator);
|
||||
final int imageHeight = (int) ((charSeparator + lineHeight) * atlasTilesY + charSeparator);
|
||||
|
||||
image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
g2d = image.createGraphics();
|
||||
@@ -192,35 +185,34 @@ public final class FontProviderCustom implements FontProvider {
|
||||
fm = g2d.getFontMetrics();
|
||||
|
||||
int tileX = 0, tileY = 0; // position in atlas tiles
|
||||
int imgX = (int) separator; // position in pixels
|
||||
int imgX = (int) charSeparator; // position in pixels
|
||||
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
final char ch = (char) (i + ATLAS_SIZE * this.id);
|
||||
if (!font.canDisplay(ch)) { continue; }
|
||||
|
||||
if (tileX >= atlasTilesX) {
|
||||
tileX = 0;
|
||||
imgX = (int) separator;
|
||||
imgX = (int) charSeparator;
|
||||
tileY++;
|
||||
}
|
||||
|
||||
final int charWidth = fm.charWidth(ch);
|
||||
final float charAspectRatio = (float) charWidth / lineHeight;
|
||||
final float inset = currentFontQuality / 16;
|
||||
g2d.drawString(Character.toString(ch), imgX, (lineHeight + separator) * (tileY + 1) - desc);
|
||||
g2d.drawString(Character.toString(ch), imgX, (lineHeight + charSeparator) * (tileY + 1) - desc);
|
||||
final float uStart = (float) (imgX - inset * charAspectRatio) / imageWidth;
|
||||
final float vStart = ((lineHeight + separator) * (tileY + 1) - lineHeight - inset) / imageHeight;
|
||||
final float vStart = ((lineHeight + charSeparator) * (tileY + 1) - lineHeight - inset) / imageHeight;
|
||||
final float xAdvance = charAspectRatio * 8 * charWidth / (charWidth + 2 * inset * charAspectRatio);
|
||||
final float glyphW = charAspectRatio * 8 + 1;
|
||||
final float uSz = (float) (charWidth + 2 * inset * charAspectRatio) / imageWidth;
|
||||
final float vSz = (float) (lineHeight + 2 * inset) / imageHeight;
|
||||
glyphData[i] = new GlyphData(uStart, vStart, xAdvance, glyphW, uSz, vSz);
|
||||
imgX += (int) (charWidth + separator);
|
||||
this.glyphData[i] = new GlyphData(uStart, vStart, xAdvance, glyphW, uSz, vSz);
|
||||
imgX += (int) (charWidth + charSeparator);
|
||||
tileX++;
|
||||
}
|
||||
g2d.dispose();
|
||||
try {
|
||||
LOGGER.info("writing custom font atlas texture ({}x{} px) to {}", imageWidth, imageHeight, getAtlasFullPath(this.id));
|
||||
Files.createDirectories(Paths.get(getFontDir()));
|
||||
ImageIO.write(image, "png", new File(getAtlasFullPath(this.id)));
|
||||
} catch (IOException e) {
|
||||
@@ -232,18 +224,18 @@ public final class FontProviderCustom implements FontProvider {
|
||||
|
||||
private FontAtlas getAtlas(char chr) {
|
||||
int id = chr / ATLAS_SIZE;
|
||||
FontAtlas fa = fontAtlases[id];
|
||||
FontAtlas fa = this.fontAtlases[id];
|
||||
if (fa == null) {
|
||||
fa = new FontAtlas(id);
|
||||
fa.construct(font);
|
||||
fa.construct(this.font);
|
||||
this.fontAtlases[id] = fa;
|
||||
}
|
||||
fontAtlases[id] = fa;
|
||||
return fa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlyphAvailable(char chr) {
|
||||
if (font == null) { return false; }
|
||||
if (this.font == null) { return false; }
|
||||
return (getAtlas(chr).glyphData[chr % ATLAS_SIZE] != null);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public final class FontProviderUnicode implements FontProvider {
|
||||
|
||||
private FontProviderUnicode() {}
|
||||
private FontProviderUnicode() {
|
||||
try {
|
||||
InputStream inputstream = Minecraft.getMinecraft().getResourceManager()
|
||||
.getResource(new ResourceLocation("font/glyph_sizes.bin")).getInputStream();
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
inputstream.read(this.glyphWidth);
|
||||
}
|
||||
catch (IOException ioexception) {
|
||||
throw new RuntimeException(ioexception);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InstLoader { static final FontProviderUnicode instance = new FontProviderUnicode(); }
|
||||
public static FontProviderUnicode get() { return FontProviderUnicode.InstLoader.instance; }
|
||||
|
||||
private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256];
|
||||
public byte[] glyphWidth;
|
||||
private final byte[] glyphWidth = new byte[65536];
|
||||
|
||||
private ResourceLocation getUnicodePageLocation(int page) {
|
||||
final ResourceLocation lookup = unicodePageLocations[page];
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.gtnewhorizons.neid.mixins.interfaces.IExtendedBlockStorageMixin;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import ru.fewizz.idextender.Hooks;
|
||||
|
||||
public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
public boolean hasSky;
|
||||
@@ -39,12 +38,6 @@ public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
System.arraycopy(((IExtendedBlockStorageMixin)(Object)storage).getBlock16BMetaArray(), 0, block16BMetaArray, 0, block16BMetaArray.length);
|
||||
}
|
||||
}
|
||||
else if (ModStatus.isOldNEIDLoaded){
|
||||
final short[] blockLSBArray = Hooks.get(this);
|
||||
System.arraycopy(Hooks.get(storage), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
// getBlockMSBArray is nuked in asm version
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
else {
|
||||
final byte[] blockLSBArray = this.getBlockLSBArray();
|
||||
System.arraycopy(storage.getBlockLSBArray(), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
|
||||
@@ -12,15 +12,8 @@ public class ModStatus {
|
||||
public static final Logger LOGGER = LogManager.getLogger("ModCompat");
|
||||
|
||||
public static BackhandReflectionCompat backhandCompat;
|
||||
/**
|
||||
* Mixin Version
|
||||
*/
|
||||
public static boolean isNEIDLoaded;
|
||||
/**
|
||||
* ASM Version
|
||||
*/
|
||||
public static boolean isOldNEIDLoaded;
|
||||
public static boolean isBetterCrashesLoaded;
|
||||
public static boolean isNEIDLoaded;
|
||||
public static boolean isNEIDMetadataExtended;
|
||||
public static boolean isLotrLoaded;
|
||||
public static boolean isChunkAPILoaded;
|
||||
@@ -42,7 +35,6 @@ public class ModStatus {
|
||||
|
||||
isBetterCrashesLoaded = Loader.isModLoaded("bettercrashes");
|
||||
isNEIDLoaded = Loader.isModLoaded("neid");
|
||||
isOldNEIDLoaded = Loader.isModLoaded("notenoughIDs");
|
||||
isLotrLoaded = Loader.isModLoaded("lotr");
|
||||
isChunkAPILoaded = Loader.isModLoaded("chunkapi");
|
||||
isEIDBiomeLoaded = Loader.isModLoaded("endlessids_biome");
|
||||
|
||||
@@ -162,6 +162,7 @@ public enum Mixins implements IMixins {
|
||||
, "rendering.MixinPlayerManager"
|
||||
, "rendering.MixinRenderBlocks"
|
||||
, "rendering.MixinRenderingRegistry"
|
||||
, "rendering.MixinTessellator"
|
||||
, "rendering.MixinTileEntity"
|
||||
, "rendering.MixinTileEntityMobSpawner"
|
||||
, "rendering.MixinTileEntityRendererDispatcher"
|
||||
@@ -178,6 +179,8 @@ public enum Mixins implements IMixins {
|
||||
, "celeritas.terrain.MixinRenderGlobal"
|
||||
, "celeritas.terrain.MixinRenderSectionManager"
|
||||
, "celeritas.terrain.MixinWorldClient"
|
||||
, "celeritas.frustum.MixinClippingHelper"
|
||||
, "celeritas.frustum.MixinClippingHelperImpl"
|
||||
, "celeritas.frustum.MixinFrustrum"
|
||||
, "celeritas.features.culling.MixinEffectRenderer"
|
||||
, "celeritas.features.mipmaps.MixinTextureAtlasSprite"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import org.joml.FrustumIntersection;
|
||||
|
||||
public interface ClippingHelperExt {
|
||||
FrustumIntersection celeritas$getFrustumIntersection();
|
||||
void celeritas$updateFrustumIntersection();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
public interface StateAwareTessellator {
|
||||
/**
|
||||
* True if the vertex originated from a RenderBlocks method call with the enableAO flag set.
|
||||
*/
|
||||
int RENDERED_WITH_VANILLA_AO = 0x1;
|
||||
|
||||
void angelica$setAppliedAo(boolean flag);
|
||||
|
||||
int[] angelica$getVertexStates();
|
||||
}
|
||||
+10
-8
@@ -26,27 +26,29 @@ public final class TileEntityRenderBoundsRegistry {
|
||||
|
||||
public static boolean isAlwaysInfiniteExtent(TileEntity te) {
|
||||
final Class<? extends TileEntity> clazz = te.getClass();
|
||||
byte result = classRegistry.getByte(clazz);
|
||||
|
||||
if (result != UNKNOWN) {
|
||||
return result == INFINITE;
|
||||
synchronized (classRegistry) {
|
||||
final byte result = classRegistry.getByte(clazz);
|
||||
if (result != UNKNOWN) return result == INFINITE;
|
||||
}
|
||||
|
||||
return probeAndCache(te, clazz);
|
||||
}
|
||||
|
||||
private static boolean probeAndCache(TileEntity te, Class<? extends TileEntity> clazz) {
|
||||
boolean isInfinite = false;
|
||||
try {
|
||||
AxisAlignedBB aabb = te.getRenderBoundingBox();
|
||||
final AxisAlignedBB aabb = te.getRenderBoundingBox();
|
||||
isInfinite = isInfiniteExtentsBox(aabb);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
classRegistry.put(clazz, isInfinite ? INFINITE : FINITE);
|
||||
synchronized (classRegistry) {
|
||||
classRegistry.put(clazz, isInfinite ? INFINITE : FINITE);
|
||||
}
|
||||
return isInfinite;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
classRegistry.clear();
|
||||
synchronized (classRegistry) {
|
||||
classRegistry.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
-33
@@ -3,10 +3,10 @@ package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
|
||||
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.BlockRenderContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexEncoder;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.LightDataCache;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.QuadLightingHelper;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.VanillaDiffuseProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.WorldSlice;
|
||||
import lombok.Getter;
|
||||
@@ -110,7 +110,8 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material, boolean isShaderPackOverride,
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, int[] vertexStates,
|
||||
ChunkBuildBuffers buffers, Material material, boolean isShaderPackOverride,
|
||||
boolean blockAllowsSmoothLighting) {
|
||||
if (vertexCount == 0) {
|
||||
return;
|
||||
@@ -127,8 +128,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
final boolean celeritasSmoothLighting = AngelicaMod.options().quality.useCeleritasSmoothLighting;
|
||||
final boolean shaderActive = IrisApi.getInstance().isShaderPackInUse();
|
||||
final boolean useAoCalculation = lightPipelineReady && (separateAo || celeritasSmoothLighting || shaderActive);
|
||||
final boolean stripDiffuse = shaderActive && BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading();
|
||||
final boolean shade = false; // Vanilla bakes it, or we remove it - so no need to shade
|
||||
final boolean shouldApplyDiffuse = !BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading();
|
||||
final ChunkColorWriter colorEncoder = separateAo ? ChunkColorWriter.SEPARATE_AO : ChunkColorWriter.EMBEDDIUM;
|
||||
|
||||
int ptr = 0;
|
||||
@@ -140,11 +140,14 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
final int worldX = originX + blockX;
|
||||
final int worldY = originY + blockY;
|
||||
final int worldZ = originZ + blockZ;
|
||||
final boolean isEmissive = useAoCalculation && QuadLightingHelper.isBlockEmissive(blockAccess, worldX, worldY, worldZ);
|
||||
|
||||
int stateIdx = 0;
|
||||
|
||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||
float uSum = 0, vSum = 0;
|
||||
|
||||
int quadState = -1;
|
||||
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
final var vertex = vertices[vIdx];
|
||||
vertex.x = Float.intBitsToFloat(rawBuffer[ptr++]);
|
||||
@@ -161,6 +164,8 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
vertex.color = rawBuffer[ptr++];
|
||||
vertex.vanillaNormal = rawBuffer[ptr++];
|
||||
vertex.light = rawBuffer[ptr++];
|
||||
|
||||
quadState &= vertexStates[stateIdx++];
|
||||
}
|
||||
|
||||
final int trueNormal = QuadUtil.calculateNormal(vertices);
|
||||
@@ -171,34 +176,16 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
animatedSprites.add(sprite);
|
||||
}
|
||||
|
||||
// Strip vanilla's baked diffuse when shaders want oldLighting=false - multiply by an inversion factor
|
||||
// instead of attempting to mixin/asm all the places that bake it in
|
||||
if (stripDiffuse) {
|
||||
final float inverseDiffuse = VanillaDiffuseProvider.INSTANCE.getInverseDiffuse(facing);
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
vertices[vIdx].color = VanillaDiffuseProvider.multiplyColor(vertices[vIdx].color, inverseDiffuse);
|
||||
}
|
||||
}
|
||||
|
||||
if (useAoCalculation) {
|
||||
final boolean quadIsFullBright = QuadLightingHelper.isQuadFullBright(vertices);
|
||||
|
||||
if (isEmissive || quadIsFullBright) {
|
||||
Arrays.fill(quadLightData.br, 1.0f);
|
||||
if (isEmissive) {
|
||||
Arrays.fill(quadLightData.lm, LightDataAccess.FULL_BRIGHT);
|
||||
} else {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quadLightData.lm[i] = vertices[i].light;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quadView.setup(trueNormal, blockX, blockY, blockZ);
|
||||
final ModelQuadFacing lightFace = quadView.getLightFace();
|
||||
final LightPipeline pipeline = blockAllowsSmoothLighting ? smoothLightPipeline : flatLightPipeline;
|
||||
final ModelQuadFacing cullFace = quadView.getCullFace();
|
||||
pipeline.calculate(quadView, worldX, worldY, worldZ, quadLightData, cullFace, lightFace, shade, true);
|
||||
}
|
||||
// If block used vanilla AO, then we can safely compute our own lighting data and ignore what vanilla
|
||||
// computed. We suppress vanilla emitting the brightness/color in MixinRenderBlocks.
|
||||
// Otherwise, we need to use the block's lightmap values as they are as the ISBRH may have
|
||||
// specified its own lightmaps for visual purposes (e.g. fullbright)
|
||||
if (useAoCalculation && (quadState & StateAwareTessellator.RENDERED_WITH_VANILLA_AO) != 0) {
|
||||
quadView.setup(trueNormal, blockX, blockY, blockZ);
|
||||
final ModelQuadFacing lightFace = quadView.getLightFace();
|
||||
final LightPipeline pipeline = blockAllowsSmoothLighting ? smoothLightPipeline : flatLightPipeline;
|
||||
final ModelQuadFacing cullFace = quadView.getCullFace();
|
||||
pipeline.calculate(quadView, worldX, worldY, worldZ, quadLightData, cullFace, lightFace, shouldApplyDiffuse, true);
|
||||
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
final var vertex = vertices[vIdx];
|
||||
@@ -207,6 +194,14 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
vertex.light = quadLightData.lm[vIdx];
|
||||
}
|
||||
} else {
|
||||
if (!shouldApplyDiffuse) {
|
||||
// Calculate the inverse of the expected diffuse constant and apply it to the color to fake
|
||||
// diffuse not having been applied
|
||||
final float inverseDiffuse = VanillaDiffuseProvider.INSTANCE.getInverseDiffuse(facing);
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
vertices[vIdx].color = VanillaDiffuseProvider.multiplyColor(vertices[vIdx].color, inverseDiffuse);
|
||||
}
|
||||
}
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
vertices[vIdx].trueNormal = trueNormal;
|
||||
}
|
||||
|
||||
+8
-10
@@ -2,6 +2,8 @@ package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
|
||||
import com.gtnewhorizons.angelica.rendering.TileEntityRenderBoundsRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.BlockRenderContext;
|
||||
@@ -135,8 +137,8 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
|
||||
if (block.hasTileEntity(meta)) {
|
||||
final TileEntity tileEntity = region.getTileEntity(x, y, z);
|
||||
if (TileEntityRendererDispatcher.instance.hasSpecialRenderer(tileEntity)) {
|
||||
renderData.globalBlockEntities.add(tileEntity);
|
||||
if (tileEntity != null && TileEntityRendererDispatcher.instance.hasSpecialRenderer(tileEntity)) {
|
||||
(TileEntityRenderBoundsRegistry.isAlwaysInfiniteExtent(tileEntity) ? renderData.globalBlockEntities : renderData.culledBlockEntities).add(tileEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,15 +250,11 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
block.canRenderInPass(pass);
|
||||
tessellator.startDrawingQuads();
|
||||
renderBlocks.renderBlockByRenderType(block, x, y, z);
|
||||
// In modern versions, block models can specify whether to enable AO or not, but here we must
|
||||
// rely on render ID heuristics to figure out which models would have turned it off
|
||||
int vanillaRenderId = block.getRenderType();
|
||||
boolean blockAllowsSmoothLighting = Minecraft.isAmbientOcclusionEnabled() // smooth lighting on
|
||||
&& block.getLightValue() == 0 // does not emit real block light
|
||||
&& vanillaRenderId != 1 // is not a "cross" block
|
||||
&& vanillaRenderId != 40; // is not a double plant block
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount, buffers, passMaterial,
|
||||
isShaderPackOverride, blockAllowsSmoothLighting);
|
||||
&& block.getLightValue() == 0; // does not emit real block light
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount,
|
||||
((StateAwareTessellator)tessellator).angelica$getVertexStates(),
|
||||
buffers, passMaterial, isShaderPackOverride, blockAllowsSmoothLighting);
|
||||
tessellator.reset();
|
||||
tessellator.isDrawing = false;
|
||||
|
||||
|
||||
+145
-1
@@ -21,6 +21,7 @@ import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.embeddedt.embeddium.impl.gl.device.CommandList;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.ChunkRenderMatrices;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderSection;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.data.MinecraftBuiltRenderSectionData;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.lists.ChunkRenderList;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.lists.SortedRenderLists;
|
||||
@@ -31,6 +32,8 @@ import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -48,6 +51,12 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
// the volume of a section multiplied by the number of sections to be checked at most
|
||||
private static final double MAX_ENTITY_CHECK_VOLUME = 16 * 16 * 16 * 15;
|
||||
|
||||
// For sorting transparent TESRs
|
||||
private RenderSectionOrderer renderSectionOrderer = new RenderSectionOrderer();
|
||||
private TileEntityOrderer tileEntityOrderer = new TileEntityOrderer();
|
||||
private ArrayList<RenderSection> sortedRenderSections = new ArrayList<>();
|
||||
private ArrayList<TileEntity> sortedTileEntities = new ArrayList<>();
|
||||
|
||||
private CeleritasWorldRenderer(Minecraft mc) {
|
||||
// Private constructor for singleton
|
||||
this.mc = mc;
|
||||
@@ -219,9 +228,97 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
GLStateManager.glColor4f(1, 1, 1, 1);
|
||||
}
|
||||
|
||||
private int renderCulledTileEntities(TileEntityRenderContext renderContext) {
|
||||
int count = 0;
|
||||
SortedRenderLists renderLists = renderSectionManager.getRenderLists();
|
||||
Iterator<ChunkRenderList> renderListIterator = renderLists.iterator();
|
||||
|
||||
while (renderListIterator.hasNext()) {
|
||||
var renderList = renderListIterator.next();
|
||||
|
||||
var renderRegion = renderList.getRegion();
|
||||
var renderSectionIterator = renderList.sectionsWithEntitiesIterator();
|
||||
|
||||
if (renderSectionIterator == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (renderSectionIterator.hasNext()) {
|
||||
var renderSectionId = renderSectionIterator.nextByteAsInt();
|
||||
var renderSection = renderRegion.getSection(renderSectionId);
|
||||
|
||||
if (renderSection == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var context = renderSection.getBuiltContext();
|
||||
|
||||
if (!(context instanceof MinecraftBuiltRenderSectionData<?, ?> mcData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// noinspection unchecked
|
||||
var blockEntities = (List<TileEntity>) mcData.culledBlockEntities;
|
||||
|
||||
if (blockEntities.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (TileEntity te : blockEntities) {
|
||||
if (te.shouldRenderInPass(renderContext.pass)) sortedTileEntities.add(te);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sortedTileEntities.sort(tileEntityOrderer.setLastCameraState(lastCameraState));
|
||||
this.renderBlockEntityList(sortedTileEntities, renderContext);
|
||||
|
||||
return sortedTileEntities.size();
|
||||
}
|
||||
|
||||
private int renderGlobalTileEntities(TileEntityRenderContext renderContext) {
|
||||
int count = 0;
|
||||
sortedRenderSections.clear();
|
||||
sortedRenderSections.addAll(renderSectionManager.getSectionsWithGlobalEntities());
|
||||
sortedRenderSections.sort(renderSectionOrderer.setLastCameraState(lastCameraState));
|
||||
for (var renderSection : sortedRenderSections) {
|
||||
sortedTileEntities.clear();
|
||||
var builtContext = renderSection.getBuiltContext();
|
||||
|
||||
if (!(builtContext instanceof MinecraftBuiltRenderSectionData<?, ?> mcData)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// noinspection unchecked
|
||||
var blockEntities = (List<TileEntity>) mcData.globalBlockEntities;
|
||||
|
||||
if (blockEntities.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (TileEntity te : blockEntities) {
|
||||
if (te.shouldRenderInPass(renderContext.pass)) sortedTileEntities.add(te);
|
||||
}
|
||||
|
||||
count += sortedTileEntities.size();
|
||||
|
||||
sortedTileEntities.sort(tileEntityOrderer.setLastCameraState(lastCameraState));
|
||||
this.renderBlockEntityList(sortedTileEntities, renderContext);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public int renderBlockEntities(float partialTicks) {
|
||||
final int pass = MinecraftForgeClient.getRenderPass();
|
||||
return super.renderBlockEntities(teRenderContext.set(partialTicks, pass));
|
||||
teRenderContext.set(partialTicks, pass);
|
||||
if (pass == 0 || !AngelicaMod.options().performance.translucencySorting) {
|
||||
return super.renderBlockEntities(teRenderContext);
|
||||
}
|
||||
int count = 0;
|
||||
count += this.renderCulledTileEntities(teRenderContext);
|
||||
count += this.renderGlobalTileEntities(teRenderContext);
|
||||
return count;
|
||||
}
|
||||
|
||||
private void renderTE(TileEntity tileEntity, int pass, float partialTicks) {
|
||||
@@ -284,4 +381,51 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RenderSectionOrderer implements Comparator<RenderSection> {
|
||||
|
||||
public CameraState lastCameraState;
|
||||
|
||||
public RenderSectionOrderer() {
|
||||
super();
|
||||
}
|
||||
|
||||
public RenderSectionOrderer setLastCameraState(CameraState lastCameraState) {
|
||||
this.lastCameraState = lastCameraState;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(RenderSection render1, RenderSection render2) {
|
||||
final float x = (float) this.lastCameraState.x();
|
||||
final float y = (float) this.lastCameraState.y();
|
||||
final float z = (float) this.lastCameraState.z();
|
||||
final float d1 = render1.getSquaredDistance(x, y, z);
|
||||
final float d2 = render2.getSquaredDistance(x, y, z);
|
||||
return Float.compare(d2, d1);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.light;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
|
||||
|
||||
public final class QuadLightingHelper {
|
||||
private QuadLightingHelper() {}
|
||||
|
||||
// Known emissive brightness values set by mods/vanilla
|
||||
public static final int FULL_BRIGHT_15 = (15 << 20) | (15 << 4); // 15728880
|
||||
public static final int FULL_BRIGHT_14 = (14 << 20) | (14 << 4); // 14680288
|
||||
|
||||
public static boolean isBlockEmissive(IBlockAccess world, int x, int y, int z) {
|
||||
final Block block = world.getBlock(x, y, z);
|
||||
try {
|
||||
return block.getMixedBrightnessForBlock(EmptyBlockAccess.INSTANCE, x, y, z) == FULL_BRIGHT_15;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isQuadFullBright(ChunkVertexEncoder.Vertex[] vertices) {
|
||||
final int first = vertices[0].light;
|
||||
|
||||
// Must be a known emissive brightness value
|
||||
if (first != FULL_BRIGHT_15 && first != FULL_BRIGHT_14) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// All 4 vertices must have the same value
|
||||
for (int i = 1; i < 4; i++) {
|
||||
if (vertices[i].light != first) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -689,7 +689,7 @@ public class ShadowRenderer {
|
||||
// Render all opaque terrain unless pack requests not to
|
||||
if (shouldRenderTerrain) {
|
||||
mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
rg.sortAndRender(mc.thePlayer, 0, playerCamera.getPartialTicks());
|
||||
rg.sortAndRender(mc.renderViewEntity, 0, playerCamera.getPartialTicks());
|
||||
}
|
||||
|
||||
// Reset viewport in case terrain rendering changed it
|
||||
@@ -746,7 +746,7 @@ public class ShadowRenderer {
|
||||
// It doesn't matter a ton, since this just means that they won't be sorted in the getNormal rendering pass.
|
||||
// Just something to watch out for, however...
|
||||
if (shouldRenderTranslucent) {
|
||||
rg.sortAndRender(mc.thePlayer, 1, playerCamera.getPartialTicks());
|
||||
rg.sortAndRender(mc.renderViewEntity, 1, playerCamera.getPartialTicks());
|
||||
}
|
||||
|
||||
// Note: Apparently tripwire isn't rendered in the shadow pass.
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ public abstract class MixinFontRenderer implements FontRendererAccessor, IFontPa
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void angelica$injectBatcher(GameSettings settings, ResourceLocation fontLocation, TextureManager texManager,
|
||||
boolean unicodeMode, CallbackInfo ci) {
|
||||
angelica$batcher = new BatchingFontRenderer((FontRenderer) (Object) this, this.charWidth, this.glyphWidth, this.colorCode, this.locationFontTexture);
|
||||
angelica$batcher = new BatchingFontRenderer((FontRenderer) (Object) this, this.charWidth, this.colorCode, this.locationFontTexture);
|
||||
}
|
||||
|
||||
@Unique
|
||||
|
||||
+10
-3
@@ -13,17 +13,24 @@ public abstract class MixinTextureAtlasSprite implements SpriteExtension {
|
||||
|
||||
@Override
|
||||
public void celeritas$markActive() {
|
||||
((IPatchedTextureAtlasSprite) this).markNeedsAnimationUpdate();
|
||||
if (this instanceof IPatchedTextureAtlasSprite patched) {
|
||||
patched.markNeedsAnimationUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean celeritas$shouldUpdate() {
|
||||
return ((IPatchedTextureAtlasSprite) this).needsAnimationUpdate();
|
||||
if (this instanceof IPatchedTextureAtlasSprite patched) {
|
||||
return patched.needsAnimationUpdate();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ModifyReturnValue(method = {"getMinU", "getInterpolatedU"}, at = @At("RETURN"))
|
||||
private float celeritas$markActiveOnUVAccess(float original) {
|
||||
((IPatchedTextureAtlasSprite) this).markNeedsAnimationUpdate();
|
||||
if (this instanceof IPatchedTextureAtlasSprite patched) {
|
||||
patched.markNeedsAnimationUpdate();
|
||||
}
|
||||
return original;
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.celeritas.frustum;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ClippingHelperExt;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelper;
|
||||
import org.joml.FrustumIntersection;
|
||||
import org.joml.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(ClippingHelper.class)
|
||||
public class MixinClippingHelper implements ClippingHelperExt {
|
||||
|
||||
@Shadow public float[] projectionMatrix;
|
||||
@Shadow public float[] modelviewMatrix;
|
||||
|
||||
@Unique private final FrustumIntersection celeritas$frustumIntersection = new FrustumIntersection();
|
||||
@Unique private final Matrix4f celeritas$projMatrix = new Matrix4f();
|
||||
@Unique private final Matrix4f celeritas$mvMatrix = new Matrix4f();
|
||||
|
||||
@Override
|
||||
public FrustumIntersection celeritas$getFrustumIntersection() {
|
||||
return this.celeritas$frustumIntersection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void celeritas$updateFrustumIntersection() {
|
||||
this.celeritas$projMatrix.set(this.projectionMatrix);
|
||||
this.celeritas$mvMatrix.set(this.modelviewMatrix);
|
||||
this.celeritas$frustumIntersection.set(this.celeritas$projMatrix.mul(this.celeritas$mvMatrix));
|
||||
}
|
||||
|
||||
/**
|
||||
* @author mitchej123
|
||||
* @reason Replace vanilla frustum check with JOML
|
||||
*/
|
||||
@Overwrite
|
||||
public boolean isBoxInFrustum(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
if (Double.isInfinite(minX) || Double.isInfinite(minY) || Double.isInfinite(minZ)
|
||||
|| Double.isInfinite(maxX) || Double.isInfinite(maxY) || Double.isInfinite(maxZ)) {
|
||||
return true;
|
||||
}
|
||||
return this.celeritas$frustumIntersection.testAab(
|
||||
(float) minX, (float) minY, (float) minZ,
|
||||
(float) maxX, (float) maxY, (float) maxZ
|
||||
);
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.celeritas.frustum;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ClippingHelperExt;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(ClippingHelperImpl.class)
|
||||
public class MixinClippingHelperImpl {
|
||||
|
||||
@Inject(method = "init", at = @At("RETURN"))
|
||||
private void celeritas$runUpdateFrustumIntersection(CallbackInfo ci) {
|
||||
((ClippingHelperExt) this).celeritas$updateFrustumIntersection();
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.celeritas.frustum;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ClippingHelperExt;
|
||||
import net.minecraft.client.renderer.culling.ClippingHelper;
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
@@ -19,7 +20,7 @@ public abstract class MixinFrustrum implements ViewportProvider {
|
||||
// Shadow frustum subclasses override this via their own ViewportProvider impl.
|
||||
// This default handles vanilla Frustrum only.
|
||||
return new Viewport(
|
||||
this.clippingHelper::isBoxInFrustum,
|
||||
((ClippingHelperExt) this.clippingHelper).celeritas$getFrustumIntersection()::testAab,
|
||||
new Vector3d(this.xPosition, this.yPosition, this.zPosition)
|
||||
);
|
||||
}
|
||||
|
||||
+55
-4
@@ -3,6 +3,9 @@ package com.gtnewhorizons.angelica.mixins.early.rendering;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.common.BlockError;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
|
||||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
@@ -11,16 +14,23 @@ import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(RenderBlocks.class)
|
||||
public abstract class MixinRenderBlocks {
|
||||
@Shadow
|
||||
public abstract boolean renderStandardBlockWithColorMultiplier(Block p_147736_1_, int p_147736_2_, int p_147736_3_, int p_147736_4_, float p_147736_5_, float p_147736_6_, float p_147736_7_);
|
||||
|
||||
@Unique
|
||||
private static final ObjectOpenHashSet<String> isbrhExceptionCache = new ObjectOpenHashSet<>();
|
||||
@@ -36,6 +46,8 @@ public abstract class MixinRenderBlocks {
|
||||
@Unique
|
||||
private boolean isRenderingByType = false;
|
||||
|
||||
private boolean applyingCeleritasAO = false;
|
||||
|
||||
@Inject(method = "renderBlockByRenderType", at = @At("HEAD"))
|
||||
private void renderingByTypeEnable(CallbackInfoReturnable<Boolean> ci) {
|
||||
this.isRenderingByType = true;
|
||||
@@ -84,14 +96,37 @@ public abstract class MixinRenderBlocks {
|
||||
return handleISBRHException(rb, world, x, y, z, block, modelId);
|
||||
}
|
||||
|
||||
@Redirect(method = "renderStandardBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;isAmbientOcclusionEnabled()Z"))
|
||||
private boolean checkAOEnabled() {
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason When vanilla would render with AO, hijack the rendering logic and render using flat lighting instead.
|
||||
*/
|
||||
@Inject(method = { "renderStandardBlockWithAmbientOcclusion", "renderStandardBlockWithAmbientOcclusionPartial" }, at = @At("HEAD"), cancellable = true)
|
||||
private void handleCeleritasAo(Block block, int x, int y, int z, float r, float g, float b, CallbackInfoReturnable<Boolean> cir) {
|
||||
if ((this.isRenderingByType && Minecraft.isAmbientOcclusionEnabled() && AngelicaMod.options().quality.useCeleritasSmoothLighting) ||
|
||||
(Iris.enabled && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo())) {
|
||||
return false; // Force sodium pipeline with Iris or for standard blocks rendered from renderBlockByRenderType when using AO
|
||||
this.applyingCeleritasAO = true;
|
||||
try {
|
||||
cir.setReturnValue(this.renderStandardBlockWithColorMultiplier(block, x, y, z, r, g, b));
|
||||
} finally {
|
||||
this.applyingCeleritasAO = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Minecraft.isAmbientOcclusionEnabled();
|
||||
/* Disable diffuse when celeritas AO is in use */
|
||||
@ModifyExpressionValue(method = "renderStandardBlockWithColorMultiplier", at = @At(value = "CONSTANT", args = "floatValue=0.5", ordinal = 0))
|
||||
private float noBottomDiffuse(float original) {
|
||||
return this.applyingCeleritasAO ? 1.0f : original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderStandardBlockWithColorMultiplier", at = @At(value = "CONSTANT", args = "floatValue=0.6", ordinal = 0))
|
||||
private float noXDiffuse(float original) {
|
||||
return this.applyingCeleritasAO ? 1.0f : original;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = "renderStandardBlockWithColorMultiplier", at = @At(value = "CONSTANT", args = "floatValue=0.8", ordinal = 0))
|
||||
private float noZDiffuse(float original) {
|
||||
return this.applyingCeleritasAO ? 1.0f : original;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@@ -113,4 +148,20 @@ public abstract class MixinRenderBlocks {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ModifyExpressionValue(method = { "renderFaceXPos", "renderFaceYPos", "renderFaceZPos",
|
||||
"renderFaceXNeg", "renderFaceYNeg", "renderFaceZNeg" },
|
||||
at = @At(value = "FIELD", opcode = Opcodes.GETFIELD, target = "Lnet/minecraft/client/renderer/RenderBlocks;enableAO:Z"))
|
||||
private boolean applyAOBrightness(boolean original, @Local(ordinal = 0) Tessellator tessellator) {
|
||||
((StateAwareTessellator)tessellator).angelica$setAppliedAo(this.applyingCeleritasAO);
|
||||
return original;
|
||||
}
|
||||
|
||||
@Inject(method = { "renderFaceXPos", "renderFaceYPos", "renderFaceZPos",
|
||||
"renderFaceXNeg", "renderFaceYNeg", "renderFaceZNeg" },
|
||||
at = @At("RETURN"))
|
||||
private void resetAOFlag(Block p_147764_1_, double p_147764_2_, double p_147764_4_, double p_147764_6_, IIcon p_147764_8_, CallbackInfo ci,
|
||||
@Local(ordinal = 0) Tessellator tessellator) {
|
||||
((StateAwareTessellator)tessellator).angelica$setAppliedAo(false);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(Tessellator.class)
|
||||
public class MixinTessellator implements StateAwareTessellator {
|
||||
@Unique
|
||||
private final IntArrayList vertexStates = new IntArrayList();
|
||||
|
||||
@Unique
|
||||
private boolean appliedAo;
|
||||
|
||||
@Inject(method = "addVertex", at = @At("RETURN"))
|
||||
private void addElementState(CallbackInfo ci) {
|
||||
int state = 0;
|
||||
if (appliedAo) {
|
||||
state |= StateAwareTessellator.RENDERED_WITH_VANILLA_AO;
|
||||
}
|
||||
this.vertexStates.add(state);
|
||||
}
|
||||
|
||||
@Inject(method = "reset", at = @At("RETURN"))
|
||||
private void resetVertexStates(CallbackInfo ci) {
|
||||
this.vertexStates.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void angelica$setAppliedAo(boolean flag) {
|
||||
this.appliedAo = flag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] angelica$getVertexStates() {
|
||||
return this.vertexStates.elements();
|
||||
}
|
||||
}
|
||||
+24
-1
@@ -2,7 +2,10 @@ package com.gtnewhorizons.angelica.mixins.early.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITileEntityBoundingBoxCache;
|
||||
import com.gtnewhorizons.angelica.rendering.TileEntityRenderBoundsRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
@@ -20,7 +23,27 @@ public abstract class MixinTileEntity implements ITileEntityBoundingBoxCache {
|
||||
@Shadow public int yCoord;
|
||||
@Shadow public int zCoord;
|
||||
|
||||
@Shadow public abstract AxisAlignedBB getRenderBoundingBox();
|
||||
@Shadow(remap = false) public static final AxisAlignedBB INFINITE_EXTENT_AABB = null;
|
||||
|
||||
/**
|
||||
* @author mitchej123
|
||||
* @reason Less fallback to INFINITE_EXTENT_AABB for blocks like signs,
|
||||
*/
|
||||
@Overwrite(remap = false)
|
||||
@SideOnly(Side.CLIENT)
|
||||
public AxisAlignedBB getRenderBoundingBox() {
|
||||
final Block type = getBlockType();
|
||||
AxisAlignedBB bb = INFINITE_EXTENT_AABB;
|
||||
if (type == Blocks.enchanting_table) {
|
||||
bb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
|
||||
} else if (type == Blocks.chest || type == Blocks.trapped_chest) {
|
||||
bb = AxisAlignedBB.getBoundingBox(xCoord - 1, yCoord, zCoord - 1, xCoord + 2, yCoord + 2, zCoord + 2);
|
||||
} else if (type != null && type != Blocks.beacon) {
|
||||
final AxisAlignedBB cbb = type.getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord, zCoord);
|
||||
bb = cbb != null ? cbb : AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
|
||||
}
|
||||
return bb;
|
||||
}
|
||||
|
||||
@Unique private int angelica$cachedBBX = Integer.MIN_VALUE;
|
||||
@Unique private int angelica$cachedBBY = Integer.MIN_VALUE;
|
||||
|
||||
Reference in new issue
Block a user