mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-22 13:19:44 +00:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43c1749468 | ||
|
|
ffc7a9eedc | ||
|
|
0f101db163 | ||
|
|
c8dbf79ab9 | ||
|
|
e05d6cd9c5 | ||
|
|
53cb7e436a | ||
|
|
d9a3e8b609 | ||
|
|
1e458fa368 | ||
|
|
02736af5ec | ||
|
|
91c3cbeedb | ||
|
|
ae1605553c | ||
|
|
1cd270fdd0 |
No files matched your search
+9
-8
@@ -49,16 +49,19 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.11")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.107")
|
||||
|
||||
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.7") { transitive = false }
|
||||
|
||||
compileOnly("org.projectlombok:lombok:1.18.34") { transitive = false }
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
|
||||
// Use modern models+textures to inject QuadProviders
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.8.5:dev')
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.8.0:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.7.7:dev")
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-4.g6b42bca") {
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
@@ -67,18 +70,18 @@ dependencies {
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.31-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.90-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev')
|
||||
|
||||
// Notfine Deps
|
||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles-Expanded:2.2.2-GTNH:dev")
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles-Expanded:2.1.15-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.13:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.14.6-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.54-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.9:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.8.4:dev")
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.8:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.3:dev") { transitive = false }
|
||||
|
||||
@@ -93,8 +96,6 @@ dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.1.10:dev") // Mixin Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:ntm-space-1121235:6974420"))
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675"))
|
||||
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
|
||||
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
|
||||
|
||||
+1
-9
@@ -96,9 +96,7 @@ usesMixinDebug = false
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
|
||||
# Specify the package that contains all of your Mixins. The package must exist or
|
||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||
# it must match with this or the build will fail.
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
mixinsPackage = mixins
|
||||
|
||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||
@@ -174,12 +172,6 @@ curseForgeRelations = requiredDependency\:gtnhlib
|
||||
# projects. New projects should not use this parameter.
|
||||
# customArchiveBaseName =
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
||||
# runClientWorkingDirectory = run/client
|
||||
|
||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
||||
# runServerWorkingDirectory = run/server
|
||||
|
||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
||||
# The check is ONLY performed if the version is a git tag.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.48'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gtnewhorizons.angelica;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
|
||||
import com.gtnewhorizons.angelica.common.BlockError;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.proxy.CommonProxy;
|
||||
@@ -14,11 +12,11 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
@Mod(
|
||||
modid = MOD_ID,
|
||||
modid = "angelica",
|
||||
name = "Angelica",
|
||||
version = Tags.VERSION,
|
||||
dependencies = """
|
||||
required-after:gtnhlib@[0.6.6,);\
|
||||
required-after:gtnhlib@[0.7.7,);\
|
||||
before:lwjgl3ify@[1.5.3,);\
|
||||
after:hodgepodge@[2.4.4,);\
|
||||
after:CodeChickenCore@[1.2.0,);\
|
||||
@@ -28,8 +26,6 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
|
||||
public class AngelicaMod {
|
||||
public static final String MOD_ID = "angelica";
|
||||
|
||||
@SidedProxy(clientSide = "com.gtnewhorizons.angelica.proxy.ClientProxy", serverSide = "com.gtnewhorizons.angelica.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -161,6 +162,15 @@ public class BatchingFontRenderer {
|
||||
pushQuadIdx(vtxId);
|
||||
}
|
||||
|
||||
private void pushTexRect(float x, float y, float w, float h, float itOff, int rgba, float uStart, float vStart, float uSz, float vSz) {
|
||||
final int vtxId = vtxWriterIndex;
|
||||
pushVtx(x + itOff, y, rgba, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(x - itOff, y + h, rgba, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(x + itOff + w, y, rgba, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(x - itOff + w, y + h, rgba, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId);
|
||||
}
|
||||
|
||||
private int pushQuadIdx(int startV) {
|
||||
final int idx = idxWriterIndex;
|
||||
batchIndices.put(idx, startV);
|
||||
@@ -268,6 +278,8 @@ public class BatchingFontRenderer {
|
||||
int fontAAModeLast = -1;
|
||||
int fontAAStrengthLast = -1;
|
||||
private void flushBatch() {
|
||||
final int prevProgram = GLStateManager.glGetInteger(GL20.GL_CURRENT_PROGRAM);
|
||||
|
||||
// Sort&Draw
|
||||
batchCommands.sort(FontDrawCmd.DRAW_ORDER_COMPARATOR);
|
||||
|
||||
@@ -282,10 +294,11 @@ public class BatchingFontRenderer {
|
||||
GLStateManager.tryBlendFuncSeparate(blendSrcRGB, blendDstRGB, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
if (FontConfig.fontAAMode != 0) {
|
||||
final boolean canUseAA = FontConfig.fontAAMode != 0 && prevProgram == 0;
|
||||
if (canUseAA) {
|
||||
GL20.glVertexAttribPointer(texBoundAttrLocation, 4, false, 0, batchVtxTexBounds);
|
||||
GL20.glEnableVertexAttribArray(texBoundAttrLocation);
|
||||
lastActiveProgram = GLStateManager.getActiveProgram();
|
||||
lastActiveProgram = prevProgram;
|
||||
GLStateManager.glUseProgram(fontShaderId);
|
||||
if (FontConfig.fontAAMode != fontAAModeLast) {
|
||||
fontAAModeLast = FontConfig.fontAAMode;
|
||||
@@ -296,6 +309,8 @@ public class BatchingFontRenderer {
|
||||
GL20.glUniform1f(AAStrength, FontConfig.fontAAStrength / 120.f);
|
||||
}
|
||||
}
|
||||
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
|
||||
GL11.glTexCoordPointer(2, 0, batchVtxTexCoords);
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, batchVtxColors);
|
||||
@@ -304,6 +319,9 @@ public class BatchingFontRenderer {
|
||||
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
||||
GLStateManager.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
|
||||
GL11.glNormal3f(0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Use plain for loop to avoid allocations
|
||||
final FontDrawCmd[] cmdsData = batchCommands.elements();
|
||||
final int cmdsSize = batchCommands.size();
|
||||
@@ -326,7 +344,7 @@ public class BatchingFontRenderer {
|
||||
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, batchIndices);
|
||||
}
|
||||
if (FontConfig.fontAAMode != 0) {
|
||||
if (canUseAA) {
|
||||
GLStateManager.glUseProgram(lastActiveProgram);
|
||||
GL20.glDisableVertexAttribArray(texBoundAttrLocation);
|
||||
}
|
||||
@@ -509,49 +527,44 @@ public class BatchingFontRenderer {
|
||||
final float vSz = fontProvider.getVSize(chr);
|
||||
final float itOff = curItalic ? 1.0F : 0.0F; // italic offset
|
||||
final float shadowOffset = fontProvider.getShadowOffset();
|
||||
final int shadowCopies = FontConfig.shadowCopies;
|
||||
final int boldCopies = FontConfig.boldCopies;
|
||||
final ResourceLocation texture = fontProvider.getTexture(chr);
|
||||
|
||||
final int vtxId = vtxWriterIndex;
|
||||
final int idxId = idxWriterIndex;
|
||||
|
||||
int vtxCount = 0;
|
||||
|
||||
if (enableShadow) {
|
||||
pushVtx(curX + itOff + shadowOffset, heightNorth + shadowOffset, curShadowColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX - itOff + shadowOffset, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff + shadowOffset, heightNorth + shadowOffset, curShadowColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
for (int n = 1; n <= shadowCopies; n++) {
|
||||
final float shadowOffsetPart = shadowOffset * ((float) n / shadowCopies);
|
||||
pushTexRect(curX + shadowOffsetPart, heightNorth + shadowOffsetPart, glyphW - 1.0f, heightSouth, itOff, curShadowColor, uStart, vStart, uSz, vSz);
|
||||
|
||||
if (curBold) {
|
||||
final float shadowOffset2 = 2.0f * shadowOffset;
|
||||
pushVtx(curX + itOff + shadowOffset2, heightNorth + shadowOffset, curShadowColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX - itOff + shadowOffset2, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff + shadowOffset2, heightNorth + shadowOffset, curShadowColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset2, heightNorth + heightSouth + shadowOffset, curShadowColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
if (curBold) {
|
||||
pushTexRect(curX + 2.0f * shadowOffsetPart, heightNorth + shadowOffsetPart, glyphW - 1.0f, heightSouth, itOff, curShadowColor, uStart, vStart, uSz, vSz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pushVtx(curX + itOff, heightNorth, curColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX - itOff, heightNorth + heightSouth, curColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff, heightNorth, curColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff, heightNorth + heightSouth, curColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
pushTexRect(curX, heightNorth, glyphW - 1.0f, heightSouth, itOff, curColor, uStart, vStart, uSz, vSz);
|
||||
|
||||
if (curBold) {
|
||||
pushVtx(shadowOffset + curX + itOff, heightNorth, curColor, uStart, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX - itOff, heightNorth + heightSouth, curColor, uStart, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F + itOff, heightNorth, curColor, uStart + uSz, vStart, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F - itOff, heightNorth + heightSouth, curColor, uStart + uSz, vStart + vSz, uStart, uStart + uSz, vStart, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
for (int n = 1; n <= boldCopies; n++) {
|
||||
final float shadowOffsetPart = shadowOffset * ((float) n / boldCopies);
|
||||
pushTexRect(curX + shadowOffsetPart, heightNorth, glyphW - 1.0f, heightSouth, itOff, curColor, uStart, vStart, uSz, vSz);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Vertex-per-char counts for different configurations
|
||||
default: 4
|
||||
shadow only: 4(1 + shadowCopies)
|
||||
bold only: 4(1 + boldCopies)
|
||||
both: 4(1 + 2 * shadowCopies + boldCopies)
|
||||
*/
|
||||
int charCount = 1;
|
||||
if (enableShadow) { charCount += shadowCopies * (curBold ? 2 : 1); }
|
||||
if (curBold) { charCount += boldCopies; }
|
||||
final int vtxCount = 4 * charCount;
|
||||
pushDrawCmd(idxId, vtxCount / 2 * 3, texture, chr > 255);
|
||||
|
||||
curX += (xAdvance + (curBold ? shadowOffset : 0.0f)) + getGlyphSpacing();
|
||||
underlineEndX = curX;
|
||||
strikethroughEndX = curX;
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.client.gui.GuiSlot;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.awt.Font;
|
||||
@@ -26,6 +27,8 @@ public class FontConfigScreen extends GuiScreen {
|
||||
private final GuiScreen parent;
|
||||
private final String title;
|
||||
private final String searchPrompt;
|
||||
private final String testAreaPrompt;
|
||||
private List<String> testAreaInfo;
|
||||
private String currentPrimaryFontName;
|
||||
private String currentFallbackFontName;
|
||||
private FontList fontList;
|
||||
@@ -33,10 +36,31 @@ public class FontConfigScreen extends GuiScreen {
|
||||
private int selectedFallbackFontListPos = -1;
|
||||
private ArrayList<Font> displayedFonts;
|
||||
private GuiTextField searchBox;
|
||||
private GuiTextField testArea;
|
||||
private int sliderPages = 0;
|
||||
private int displayedSliderPage = 0;
|
||||
private final int sliderWidth = 160;
|
||||
private final int sliderHeight = 20;
|
||||
|
||||
// need to save these separately
|
||||
private IrisButton fwdButton;
|
||||
private IrisButton backButton;
|
||||
|
||||
SliderClone.Option optFontQuality = new SliderClone.Option(6, 72, 6);
|
||||
SliderClone.Option optShadowOffset = new SliderClone.Option(0, 2, 0.05f);
|
||||
SliderClone.Option optShadowCopies = new SliderClone.Option(1, 8, 1);
|
||||
SliderClone.Option optBoldCopies = new SliderClone.Option(1, 8, 1);
|
||||
SliderClone.Option optGlyphAspect = new SliderClone.Option(-1, 1, 0.05f);
|
||||
SliderClone.Option optGlyphScale = new SliderClone.Option(0.1f, 3, 0.05f);
|
||||
SliderClone.Option optWhitespaceScale = new SliderClone.Option(0.1f, 3, 0.05f);
|
||||
SliderClone.Option optGlyphSpacing = new SliderClone.Option(-2f, 2f, 0.05f);
|
||||
SliderClone.Option optFontAAMode = new SliderClone.Option(0, 2, 1);
|
||||
SliderClone.Option optFontAAStrength = new SliderClone.Option(1, 24, 1);
|
||||
|
||||
public FontConfigScreen(GuiScreen parent) {
|
||||
this.title = I18n.format("options.angelica.fontconfig.title");
|
||||
this.searchPrompt = I18n.format("options.angelica.fontconfig.searchprompt");
|
||||
this.testAreaPrompt = I18n.format("options.angelica.fontconfig.testareaprompt");
|
||||
this.parent = parent;
|
||||
this.currentPrimaryFontName = FontConfig.customFontNamePrimary;
|
||||
this.currentFallbackFontName = FontConfig.customFontNameFallback;
|
||||
@@ -51,65 +75,175 @@ public class FontConfigScreen extends GuiScreen {
|
||||
}
|
||||
}
|
||||
|
||||
SliderClone.Option optFontQuality = new SliderClone.Option(6, 72, 6);
|
||||
SliderClone.Option optShadowOffset = new SliderClone.Option(0, 2, 0.05f);
|
||||
SliderClone.Option optGlyphAspect = new SliderClone.Option(-1, 1, 0.05f);
|
||||
SliderClone.Option optGlyphScale = new SliderClone.Option(0.1f, 3, 0.05f);
|
||||
SliderClone.Option optWhitespaceScale = new SliderClone.Option(0.1f, 3, 0.05f);
|
||||
SliderClone.Option optGlyphSpacing = new SliderClone.Option(-2f, 2f, 0.05f);
|
||||
SliderClone.Option optFontAAMode = new SliderClone.Option(0, 2, 1);
|
||||
SliderClone.Option optFontAAStrength = new SliderClone.Option(1, 24, 1);
|
||||
|
||||
public void initGui() {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
searchBox = new GuiTextField(this.fontRendererObj, this.width / 2 - 120, 24, 240, 20);
|
||||
searchBox.setMaxStringLength(64);
|
||||
fontList = new FontList();
|
||||
testArea = new GuiTextField(this.fontRendererObj, this.width * 5 / 6 - this.width / 7, 63 - 10, this.width * 2 / 7, 20);
|
||||
testArea.setMaxStringLength(512);
|
||||
testArea.setText(I18n.format("options.angelica.fontconfig.testareaexample"));
|
||||
initButtons();
|
||||
}
|
||||
|
||||
private void initButtons() {
|
||||
this.buttonList.add(new IrisButton(this.width / 2 - 81 - 165, this.height - 20 - 7, 162, 20,
|
||||
final int halfWidth = this.width / 2;
|
||||
final int sliderSpacing = 4;
|
||||
|
||||
final int x1 = halfWidth - sliderWidth - sliderSpacing;
|
||||
final int x2 = halfWidth;
|
||||
final int x3 = halfWidth + sliderWidth + sliderSpacing;
|
||||
final int y3 = this.height - 65 + 2 * (sliderHeight + sliderSpacing);
|
||||
|
||||
this.buttonList.add(new IrisButton(x1 - sliderWidth / 2, y3 - sliderHeight / 2, sliderWidth, sliderHeight,
|
||||
FontConfig.enableCustomFont ? I18n.format("options.angelica.fontconfig.disable_custom_font") :
|
||||
I18n.format("options.angelica.fontconfig.enable_custom_font"), this::toggleCustomFont));
|
||||
this.buttonList.add(new IrisButton(this.width / 2 - 80, this.height - 20 - 7, 160, 20,
|
||||
this.buttonList.add(new IrisButton(x2 - sliderWidth / 2, y3 - sliderHeight / 2, sliderWidth, sliderHeight,
|
||||
I18n.format("options.angelica.fontconfig.reset_values"), this::resetValues));
|
||||
this.buttonList.add(new IrisButton(this.width / 2 - 81 + 165, this.height - 20 - 7, 162, 20,
|
||||
this.buttonList.add(new IrisButton(x3 - sliderWidth / 2, y3 - sliderHeight / 2, sliderWidth, sliderHeight,
|
||||
I18n.format("gui.done"), button -> this.onClose()));
|
||||
|
||||
// might refactor later, feeling too lazy at the moment
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 186, this.height - 40 - 11, 120, 20,
|
||||
optFontQuality, FontConfig.customFontQuality, this::setFontQuality,
|
||||
value -> I18n.format("options.angelica.fontconfig.font_quality", String.format("%2.0f", value)),
|
||||
"options.angelica.fontconfig.font_quality.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 186, this.height - 60 - 15, 120, 20,
|
||||
optShadowOffset, FontConfig.fontShadowOffset, value -> FontConfig.fontShadowOffset = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.shadow_offset", String.format("x%3.2f", value)),
|
||||
"options.angelica.fontconfig.shadow_offset.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 62, this.height - 40 - 11, 120, 20,
|
||||
optGlyphAspect, FontConfig.glyphAspect, value -> FontConfig.glyphAspect = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.glyph_aspect", String.format("%3.2f", value)),
|
||||
"options.angelica.fontconfig.glyph_aspect.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 - 62, this.height - 60 - 15, 120, 20,
|
||||
optGlyphScale, FontConfig.glyphScale, value -> FontConfig.glyphScale = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.glyph_scale", String.format("x%3.2f", value)),
|
||||
"options.angelica.fontconfig.glyph_scale.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 62, this.height - 40 - 11, 120, 20,
|
||||
optWhitespaceScale, FontConfig.whitespaceScale, value -> FontConfig.whitespaceScale = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.whitespace_scale", String.format("x%3.2f", value)),
|
||||
"options.angelica.fontconfig.whitespace_scale.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 62, this.height - 60 - 15, 120, 20,
|
||||
optGlyphSpacing, FontConfig.glyphSpacing, value -> FontConfig.glyphSpacing = value,
|
||||
value -> I18n.format("options.angelica.fontconfig.glyph_spacing", String.format("%3.2f", value)),
|
||||
"options.angelica.fontconfig.glyph_spacing.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 186, this.height - 40 - 11, 120, 20,
|
||||
optFontAAStrength, FontConfig.fontAAStrength, value -> FontConfig.fontAAStrength = value.intValue(),
|
||||
value -> I18n.format("options.angelica.fontconfig.font_aa_strength", String.format("%.0f", value)),
|
||||
"options.angelica.fontconfig.font_aa_strength.tooltip"));
|
||||
this.buttonList.add(new SliderClone( this.width / 2 - 60 + 186, this.height - 60 - 15, 120, 20,
|
||||
optFontAAMode, FontConfig.fontAAMode, value -> FontConfig.fontAAMode = value.intValue(),
|
||||
this::fontAAModeFormat,
|
||||
"options.angelica.fontconfig.aamode.tooltip"));
|
||||
backButton = new IrisButton(halfWidth - 20 - 224, this.height - 89 - 10, 40, 20,
|
||||
"<", button -> this.switchPage(-1));
|
||||
fwdButton = new IrisButton(halfWidth - 20 + 224, this.height - 89 - 10, 40, 20,
|
||||
">", button -> this.switchPage(1));
|
||||
this.buttonList.add(fwdButton);
|
||||
this.buttonList.add(backButton);
|
||||
|
||||
initSliders();
|
||||
}
|
||||
|
||||
private void initSliders() {
|
||||
ArrayList<SliderClone> sliders = new ArrayList<>();
|
||||
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optFontQuality)
|
||||
.initialValue(FontConfig.customFontQuality)
|
||||
.setter(this::setFontQuality)
|
||||
.langKey("options.angelica.fontconfig.font_quality")
|
||||
.formatString("%2.0f")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optShadowOffset)
|
||||
.initialValue(FontConfig.fontShadowOffset)
|
||||
.setter(value -> FontConfig.fontShadowOffset = value)
|
||||
.langKey("options.angelica.fontconfig.shadow_offset")
|
||||
.formatString("x%3.2f")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optGlyphAspect)
|
||||
.initialValue(FontConfig.glyphAspect)
|
||||
.setter(value -> FontConfig.glyphAspect = value)
|
||||
.langKey("options.angelica.fontconfig.glyph_aspect")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optGlyphScale)
|
||||
.initialValue(FontConfig.glyphScale)
|
||||
.setter(value -> FontConfig.glyphScale = value)
|
||||
.langKey("options.angelica.fontconfig.glyph_scale")
|
||||
.formatString("x%3.2f")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optFontAAStrength)
|
||||
.initialValue(FontConfig.fontAAStrength)
|
||||
.setter(value -> FontConfig.fontAAStrength = value.intValue())
|
||||
.langKey("options.angelica.fontconfig.font_aa_strength")
|
||||
.formatString("%.0f")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optFontAAMode)
|
||||
.initialValue(FontConfig.fontAAMode)
|
||||
.setter(value -> FontConfig.fontAAMode = value.intValue())
|
||||
.formatter(this::fontAAModeFormat)
|
||||
.langKey("options.angelica.fontconfig.aamode")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optWhitespaceScale)
|
||||
.initialValue(FontConfig.whitespaceScale)
|
||||
.setter(value -> FontConfig.whitespaceScale = value)
|
||||
.langKey("options.angelica.fontconfig.whitespace_scale")
|
||||
.formatString("x%3.2f")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optGlyphSpacing)
|
||||
.initialValue(FontConfig.glyphSpacing)
|
||||
.setter(value -> FontConfig.glyphSpacing = value)
|
||||
.langKey("options.angelica.fontconfig.glyph_spacing")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optShadowCopies)
|
||||
.initialValue(FontConfig.shadowCopies)
|
||||
.setter(value -> FontConfig.shadowCopies = value.intValue())
|
||||
.langKey("options.angelica.fontconfig.shadow_copies")
|
||||
.formatString("%.0f")
|
||||
.build()
|
||||
);
|
||||
sliders.add(new SliderClone.SliderCloneBuilder()
|
||||
.width(sliderWidth)
|
||||
.height(sliderHeight)
|
||||
.option(optBoldCopies)
|
||||
.initialValue(FontConfig.boldCopies)
|
||||
.setter(value -> FontConfig.boldCopies = value.intValue())
|
||||
.langKey("options.angelica.fontconfig.bold_copies")
|
||||
.formatString("%.0f")
|
||||
.build()
|
||||
);
|
||||
|
||||
final int halfWidth = this.width / 2;
|
||||
final int sliderSpacing = 4;
|
||||
|
||||
final int x1 = halfWidth - sliderWidth - sliderSpacing;
|
||||
final int x2 = halfWidth;
|
||||
final int x3 = halfWidth + sliderWidth + sliderSpacing;
|
||||
final int y1 = this.height - 65;
|
||||
final int y2 = this.height - 65 + sliderHeight + sliderSpacing;
|
||||
|
||||
this.sliderPages = sliders.size() / 6;
|
||||
this.displayedSliderPage = Math.min(this.displayedSliderPage, this.sliderPages);
|
||||
|
||||
this.backButton.enabled = (this.displayedSliderPage != 0);
|
||||
this.fwdButton.enabled = (this.displayedSliderPage != this.sliderPages);
|
||||
|
||||
final int start = 6 * this.displayedSliderPage;
|
||||
final int end = Math.min(6 * (this.displayedSliderPage + 1), sliders.size());
|
||||
List<SliderClone> s = sliders.subList(start, end);
|
||||
try {
|
||||
s.get(0).setCenterPosition(x1, y1);
|
||||
s.get(1).setCenterPosition(x1, y2);
|
||||
s.get(2).setCenterPosition(x2, y1);
|
||||
s.get(3).setCenterPosition(x2, y2);
|
||||
s.get(4).setCenterPosition(x3, y1);
|
||||
s.get(5).setCenterPosition(x3, y2);
|
||||
} catch (IndexOutOfBoundsException ignored) {
|
||||
// we're on the last page and it has less than 6 sliders to display
|
||||
}
|
||||
this.buttonList.addAll(s);
|
||||
}
|
||||
|
||||
private void onClose() {
|
||||
@@ -141,6 +275,8 @@ public class FontConfigScreen extends GuiScreen {
|
||||
} catch (ConfigException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
currentPrimaryFontName = null;
|
||||
currentFallbackFontName = null;
|
||||
selectedPrimaryFontListPos = -1;
|
||||
selectedFallbackFontListPos = -1;
|
||||
FontStrategist.customFontInUse = false;
|
||||
@@ -156,6 +292,12 @@ public class FontConfigScreen extends GuiScreen {
|
||||
I18n.format("options.angelica.fontconfig.enable_custom_font");
|
||||
}
|
||||
|
||||
private void switchPage(int offset) {
|
||||
this.displayedSliderPage = MathHelper.clamp_int(this.displayedSliderPage + offset, 0, this.sliderPages);
|
||||
this.buttonList.removeIf(guiButton -> guiButton instanceof SliderClone);
|
||||
this.initSliders();
|
||||
}
|
||||
|
||||
private int qualityLast = FontConfig.customFontQuality;
|
||||
|
||||
private void setFontQuality(float quality) {
|
||||
@@ -179,7 +321,7 @@ public class FontConfigScreen extends GuiScreen {
|
||||
private long lastStillTime = 0;
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
super.drawDefaultBackground();
|
||||
drawBackground(0);
|
||||
fontList.drawScreen(mouseX, mouseY, delta);
|
||||
searchBox.drawTextBox();
|
||||
// I bet you thought this was drawn inside the search box, not on top of it.
|
||||
@@ -191,6 +333,34 @@ public class FontConfigScreen extends GuiScreen {
|
||||
drawCenteredString(this.fontRendererObj, this.title, (int) (this.width * 0.5), 8, 0xFFFFFF);
|
||||
drawCenteredString(this.fontRendererObj, I18n.format("options.angelica.fontconfig.currentfonts",
|
||||
FontConfig.customFontNamePrimary, FontConfig.customFontNameFallback), (int) (this.width * 0.5), this.height - 92, 0xFFFFFF);
|
||||
|
||||
if (this.testAreaInfo == null) {
|
||||
this.testAreaInfo = this.fontRendererObj.listFormattedStringToWidth(
|
||||
I18n.format("options.angelica.fontconfig.testareainfo"), this.width / 4
|
||||
);
|
||||
}
|
||||
int cumulativeY = 73;
|
||||
for (String s : this.testAreaInfo) {
|
||||
drawCenteredString(this.fontRendererObj, s, this.width * 5 / 6, cumulativeY, 0xFFFFFF);
|
||||
cumulativeY += this.fontRendererObj.FONT_HEIGHT;
|
||||
}
|
||||
cumulativeY += 4;
|
||||
this.testArea.yPosition = cumulativeY;
|
||||
this.testArea.drawTextBox();
|
||||
if (!this.testArea.isFocused() && this.testArea.getText().isEmpty()) {
|
||||
this.drawCenteredString(this.fontRendererObj, this.testAreaPrompt,
|
||||
this.testArea.xPosition + this.fontRendererObj.getStringWidth(this.testAreaPrompt) / 2 + 4,
|
||||
this.testArea.yPosition + this.testArea.height / 2 - 4, 0xFFFFFF);
|
||||
}
|
||||
List<String> testText = this.fontRendererObj.listFormattedStringToWidth(
|
||||
this.testArea.getText().replace('&', '§'), this.width / 4
|
||||
);
|
||||
cumulativeY += this.testArea.height + 4;
|
||||
for (String s : testText) {
|
||||
drawCenteredString(this.fontRendererObj, s, this.width * 5 / 6, cumulativeY, 0xFFFFFF);
|
||||
cumulativeY += this.fontRendererObj.FONT_HEIGHT;
|
||||
}
|
||||
|
||||
super.drawScreen(mouseX, mouseY, delta);
|
||||
|
||||
for (GuiButton guiButton : buttonList) {
|
||||
@@ -235,10 +405,18 @@ public class FontConfigScreen extends GuiScreen {
|
||||
if (this.searchBox.isFocused()) {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
this.searchBox.setFocused(false);
|
||||
return;
|
||||
}
|
||||
this.searchBox.textboxKeyTyped(typedChar, keyCode);
|
||||
this.displayedFonts = filterFonts(this.searchBox.getText().toLowerCase());
|
||||
}
|
||||
if (this.testArea.isFocused()) {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
this.testArea.setFocused(false);
|
||||
return;
|
||||
}
|
||||
this.testArea.textboxKeyTyped(typedChar, keyCode);
|
||||
}
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
this.onClose();
|
||||
}
|
||||
@@ -248,12 +426,14 @@ public class FontConfigScreen extends GuiScreen {
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.searchBox.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.testArea.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.fontList.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
this.searchBox.updateCursorCounter();
|
||||
this.testArea.updateCursorCounter();
|
||||
}
|
||||
|
||||
// this could be more efficient, but it's good enough as is
|
||||
@@ -281,7 +461,7 @@ public class FontConfigScreen extends GuiScreen {
|
||||
class FontList extends GuiSlot {
|
||||
|
||||
public FontList() {
|
||||
super(FontConfigScreen.this.mc, FontConfigScreen.this.width, FontConfigScreen.this.height, 52, FontConfigScreen.this.height - 100, 18);
|
||||
super(FontConfigScreen.this.mc, FontConfigScreen.this.width * 2 / 3, FontConfigScreen.this.height, 52, FontConfigScreen.this.height - 102, 18);
|
||||
}
|
||||
|
||||
private void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
@@ -328,7 +508,7 @@ public class FontConfigScreen extends GuiScreen {
|
||||
|
||||
@Override
|
||||
protected int getScrollBarX() {
|
||||
return this.width * 11 / 12 - 5;
|
||||
return this.width * 15 / 16 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -340,7 +520,7 @@ public class FontConfigScreen extends GuiScreen {
|
||||
protected void elementClicked(int index, boolean doubleClicked, int mouseX, int mouseY) {}
|
||||
|
||||
protected void drawBackground() {
|
||||
drawDefaultBackground();
|
||||
// do nothing, the font list doesn't occupy the entire screen
|
||||
}
|
||||
|
||||
protected void drawSlot(int index, int x, int y, int p_148126_4_, Tessellator tessellator, int p_148126_6_, int p_148126_7_) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
@@ -43,6 +46,53 @@ public class SliderClone extends GuiButton {
|
||||
this.tooltipKey = tooltipKey;
|
||||
}
|
||||
|
||||
public static SliderCloneBuilder builder() {
|
||||
return new SliderCloneBuilder();
|
||||
}
|
||||
|
||||
public void setCenterPosition(int x, int y) {
|
||||
this.xPosition = x - this.width / 2;
|
||||
this.yPosition = y - this.height / 2;
|
||||
}
|
||||
|
||||
@Accessors(fluent = true) @Setter
|
||||
public static class SliderCloneBuilder {
|
||||
private int x = 0, y = 0; // center position, not a corner
|
||||
private int width = 144, height = 20;
|
||||
private Option option;
|
||||
private float initialValue;
|
||||
private Consumer<Float> setter;
|
||||
private String formatString = "%3.2f";
|
||||
private String langKey;
|
||||
|
||||
// overrides: if null, these get set to default values
|
||||
private String tooltipKey;
|
||||
private Function<Float, String> formatter;
|
||||
|
||||
public SliderClone build() {
|
||||
if (this.formatter == null) {
|
||||
this.formatter = value -> I18n.format(this.langKey, String.format(this.formatString, value));
|
||||
}
|
||||
|
||||
if (this.tooltipKey == null) {
|
||||
this.tooltipKey = this.langKey + ".tooltip";
|
||||
}
|
||||
|
||||
return new SliderClone(
|
||||
this.x - this.width / 2,
|
||||
this.y - this.height / 2,
|
||||
this.width,
|
||||
this.height,
|
||||
this.option,
|
||||
this.initialValue,
|
||||
this.setter,
|
||||
this.formatter,
|
||||
this.tooltipKey
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns 0 if the button is disabled, 1 if the mouse is NOT hovering over this button and 2 if it IS hovering over
|
||||
* this button.
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
package com.gtnewhorizons.angelica.common;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.client.model.ModelISBRH.JSON_ISBRH_ID;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ModeledBlock;
|
||||
import com.gtnewhorizons.angelica.utils.AssetLoader;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/// Unline {@link BlockError}, this *is* registered on both sides. It's intended to test functionality in a SP
|
||||
/// development environment.
|
||||
public class BlockTest extends Block {
|
||||
import static com.gtnewhorizons.angelica.models.VanillaModels.LECTERN;
|
||||
|
||||
public class BlockTest extends Block implements ModeledBlock {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private QuadProvider model;
|
||||
|
||||
public BlockTest() {
|
||||
super(Material.wood);
|
||||
setHardness(0.7f);
|
||||
|
||||
super(Material.rock);
|
||||
this.setBlockTextureName("missingno");
|
||||
this.setModel((world, pos, block, meta, dir, random, color, quadPool) -> {
|
||||
if (meta < 2 || meta > 5) meta = 2;
|
||||
return LECTERN.models[meta - 2].getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,6 +36,13 @@ public class BlockTest extends Block {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
for (String s : AssetLoader.testTexs) {
|
||||
reg.registerIcon(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
|
||||
*/
|
||||
@@ -29,16 +50,11 @@ public class BlockTest extends Block {
|
||||
public int onBlockPlaced(@NotNull World worldIn, int x, int y, int z, int side, float subX, float subY, float subZ, int meta) {
|
||||
|
||||
// Face NORTH if placed up or down
|
||||
final var s = ForgeDirection.getOrientation(side);
|
||||
final ForgeDirection s = DirectionUtil.ALL_DIRECTIONS[side];
|
||||
if (s == ForgeDirection.UP || s == ForgeDirection.DOWN)
|
||||
return 2;
|
||||
|
||||
// Face the placed side
|
||||
return side;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return JSON_ISBRH_ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
public class BufferWriter {
|
||||
// Adapted from Neodymium
|
||||
|
||||
private final ByteBuffer buf;
|
||||
|
||||
private final FloatBuffer floatBuffer;
|
||||
private final ShortBuffer shortBuffer;
|
||||
private final IntBuffer intBuffer;
|
||||
|
||||
public BufferWriter(ByteBuffer buf) {
|
||||
this.buf = buf;
|
||||
this.floatBuffer = buf.asFloatBuffer();
|
||||
this.shortBuffer = buf.asShortBuffer();
|
||||
this.intBuffer = buf.asIntBuffer();
|
||||
}
|
||||
|
||||
private void incrementPosition(int add) {
|
||||
buf.position(buf.position() + add);
|
||||
floatBuffer.position(buf.position() / 4);
|
||||
shortBuffer.position(buf.position() / 2);
|
||||
intBuffer.position(buf.position() / 4);
|
||||
}
|
||||
|
||||
public void writeFloat(float x) {
|
||||
try {
|
||||
floatBuffer.put(x);
|
||||
|
||||
incrementPosition(4);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeInt(int x) {
|
||||
intBuffer.put(x);
|
||||
|
||||
incrementPosition(4);
|
||||
}
|
||||
|
||||
public void writeByte(byte x) {
|
||||
buf.put(x); // this increments the buffer position by 1
|
||||
|
||||
incrementPosition(0);
|
||||
}
|
||||
|
||||
public int position() {
|
||||
return buf.position();
|
||||
}
|
||||
|
||||
public void writeShort(short s) {
|
||||
shortBuffer.put(s);
|
||||
|
||||
incrementPosition(2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ItemVBOQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public ItemVBOQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
|
||||
// Normals + Padding
|
||||
buf.putInt(quad.getNormal(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionColorTextureQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionColorTextureQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Color
|
||||
buf.putInt(quad.getColor(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionTextureColorQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionTextureColorQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
|
||||
// Color
|
||||
buf.putInt(quad.getColor(idx));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.writers.IWriteQuads;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionTextureQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionTextureQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(QuadView quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(QuadView quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(QuadView quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableSodiumFluidRendering;
|
||||
|
||||
@Config.Comment("Inject BakedModel rendering into some vanilla blocks")
|
||||
@Config.Comment("Inject QuadProvider rendering into some vanilla blocks")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean injectQPRendering;
|
||||
@@ -167,40 +167,6 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean removeUnicodeEvenScaling;
|
||||
|
||||
@Config.Comment({"Block corners and edges between chunks might have \"cracks\" (various lines/dots) in them.",
|
||||
"While using \"Compact Vertex Format\" makes the situation even worse.",
|
||||
"This option fixes it.",
|
||||
"Requires texture reloading (F3 + T) after changing this option to take effect"})
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean fixBlockCrack;
|
||||
|
||||
@Config.Comment({
|
||||
"The \"epsilon\" value for the fixBlockCrack option. ",
|
||||
"Set this a bit higher if you can still see lines/dots between solid blocks in dark areas.",
|
||||
"May cause intense flickering (z-fighting) between blocks if the value is too high"
|
||||
})
|
||||
@Config.RangeDouble(min = 0, max = 0.005)
|
||||
@Config.DefaultDouble(0.001)
|
||||
public static double blockCrackFixEpsilon;
|
||||
|
||||
@Config.Comment("Block classes that have bugs when rendering with the fixBlockCrack can be put here to avoid manipulating them")
|
||||
@Config.DefaultStringList({
|
||||
"net.minecraft.block.BlockCauldron",
|
||||
"net.minecraft.block.BlockStairs"
|
||||
})
|
||||
public static String[] blockCrackFixBlacklist;
|
||||
|
||||
@Config.Comment({"Block classes that have render pass other than 0 but still need to be manipulated.",
|
||||
"Add a block class here if you see flickering (z-fighting) with fixBlockCrack enabled"
|
||||
})
|
||||
@Config.DefaultStringList({
|
||||
"gregtech.common.blocks.BlockOres",
|
||||
"shukaro.artifice.block.world.BlockOre",
|
||||
"bartworks.system.material.BWMetaGeneratedOres",
|
||||
"gtPlusPlus.core.block.base.BlockBaseOre",
|
||||
})
|
||||
public static String[] blockCrackFixRenderPassWhitelist;
|
||||
|
||||
@Config.Comment("Register HardcodedCustomUniforms in Iris Shaders. May help with compatibility in certain shader packs")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableHardcodedCustomUniforms;
|
||||
|
||||
@@ -11,7 +11,6 @@ public class AngelicaGuiConfig extends SimpleGuiConfig {
|
||||
"Angelica",
|
||||
true,
|
||||
AngelicaConfig.class,
|
||||
CompatConfig.class,
|
||||
FontConfig.class
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.Config;
|
||||
|
||||
@Config(modid = "angelica", filename = "angelica-compat", category = "compat")
|
||||
@Config(modid = "angelica", filename = "angelica-compat")
|
||||
public class CompatConfig {
|
||||
|
||||
@Config.Comment("Apply fixes to the LOTR mod")
|
||||
@@ -44,24 +44,4 @@ public class CompatConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixSecurityCraft;
|
||||
|
||||
@Config.Comment("Apply tweaks to NTM:Space")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean tweakNTMSpace;
|
||||
|
||||
@Config.Comment("Apply fixes to NTM:Space")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixNTMSpace;
|
||||
|
||||
@Config.Comment("Disables rendering of the planet below the player at high altitudes [Requires tweakNTMSpace]")
|
||||
@Config.DefaultEnum("ShadersOnly")
|
||||
public static altitudePlanetRendererState NTMSpace_disableAltitudePlanetRenderer;
|
||||
public enum altitudePlanetRendererState {
|
||||
Always,
|
||||
ShadersOnly,
|
||||
Never
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,16 @@ public class FontConfig {
|
||||
@Config.RangeFloat(min = 0F, max = 2F)
|
||||
public static float fontShadowOffset;
|
||||
|
||||
@Config.Comment("The number of shadows to be drawn behind text at various offsets.")
|
||||
@Config.DefaultInt(1)
|
||||
@Config.RangeInt(min = 1, max = 8)
|
||||
public static int shadowCopies;
|
||||
|
||||
@Config.Comment("The number of bold copies to be drawn behind text at various offsets.")
|
||||
@Config.DefaultInt(2)
|
||||
@Config.RangeInt(min = 1, max = 8)
|
||||
public static int boldCopies;
|
||||
|
||||
@Config.Comment("Influences the aspect ratio of each glyph.")
|
||||
@Config.DefaultFloat(0F)
|
||||
@Config.RangeFloat(min = -1F, max = 1F)
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.gtnewhorizons.angelica.glsm.stacks.LightModelStateStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.LightStateStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.MaterialStateStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.MatrixModeStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.TextureBindingStack;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.ViewPortStateStack;
|
||||
import com.gtnewhorizons.angelica.glsm.states.Color4;
|
||||
import com.gtnewhorizons.angelica.glsm.states.ISettableState;
|
||||
@@ -66,7 +67,6 @@ import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
|
||||
import java.lang.Math;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -1513,8 +1513,8 @@ public class GLStateManager {
|
||||
GL11.glNewList(list, mode);
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS);
|
||||
int size = stacks.size();
|
||||
|
||||
final int size = stacks.size();
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for(int i = 0; i < size; i++) {
|
||||
IStateStack<?> stack = stacks.get(i);
|
||||
|
||||
@@ -1525,6 +1525,12 @@ public class GLStateManager {
|
||||
if(glListMode == GL11.GL_COMPILE) {
|
||||
pushState(GL11.GL_ALL_ATTRIB_BITS);
|
||||
}
|
||||
|
||||
// Band-aid fix to prevent color & texture leaks
|
||||
color.setRed(-1);
|
||||
color.setGreen(-1);
|
||||
color.setBlue(-1);
|
||||
textures.getTextureUnitBindings(getActiveTextureUnit()).setBinding(-1);
|
||||
}
|
||||
|
||||
public static void glEndList() {
|
||||
@@ -1540,12 +1546,33 @@ public class GLStateManager {
|
||||
final Set<Map.Entry<IStateStack<?>, ISettableState<?>>> changedStates = new ObjectArraySet<>();
|
||||
for(Map.Entry<IStateStack<?>, ISettableState<?>> entry : glListStates.entrySet()) {
|
||||
// If the current stack state is different than the copy of the state at the start
|
||||
if(!((ISettableState<?>)entry.getKey()).sameAs(entry.getValue())) {
|
||||
if(!((ISettableState<?>)entry.getKey()).sameAs(entry.getValue())
|
||||
&& !(entry.getKey() instanceof TextureBinding)
|
||||
&& !(entry.getKey() instanceof Color4)) {
|
||||
// Then we want to put into the change set the stack and the copy of the state now
|
||||
changedStates.add(new AbstractMap.SimpleEntry<>(entry.getKey(), (ISettableState<?>) ((ISettableState<?>) entry.getKey()).copy()));
|
||||
}
|
||||
}
|
||||
if(changedStates.size() != 0) {
|
||||
|
||||
final TextureBindingStack activeBinding = textures.getTextureUnitBindings(getActiveTextureUnit());
|
||||
if (activeBinding.getBinding() != -1) {
|
||||
changedStates.add(new AbstractMap.SimpleEntry<>(
|
||||
activeBinding,
|
||||
activeBinding.copy()
|
||||
));
|
||||
} else {
|
||||
activeBinding.set(glListStates.get(activeBinding));
|
||||
}
|
||||
if (color.getRed() != -1 || color.getGreen() != -1 || color.getBlue() != -1) {
|
||||
changedStates.add(new AbstractMap.SimpleEntry<>(
|
||||
color,
|
||||
color.copy()
|
||||
));
|
||||
} else {
|
||||
color.set(glListStates.get(color));
|
||||
}
|
||||
|
||||
if(!changedStates.isEmpty()) {
|
||||
glListChanges.put(glListId, changedStates);
|
||||
}
|
||||
if(glListMode == GL11.GL_COMPILE) {
|
||||
@@ -1566,8 +1593,9 @@ public class GLStateManager {
|
||||
} else {
|
||||
trySyncProgram();
|
||||
GL11.glCallList(list);
|
||||
if(glListChanges.containsKey(list)) {
|
||||
for(Map.Entry<IStateStack<?>, ISettableState<?>> entry : glListChanges.get(list)) {
|
||||
final Set<Map.Entry<IStateStack<?>, ISettableState<?>>> changes = glListChanges.get(list);
|
||||
if(changes != null) {
|
||||
for(Map.Entry<IStateStack<?>, ISettableState<?>> entry : changes) {
|
||||
// Set the stack to the cached state at the end of the call list compilation
|
||||
((ISettableState<?>)entry.getKey()).set(entry.getValue());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
package com.gtnewhorizons.angelica.glsm.debug;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.states.TextureUnitArray;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -9,14 +26,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.joml.Matrix4f;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
// Adapted from https://github.com/makamys/CoreTweaks/blob/master/src/main/java/makamys/coretweaks/util/OpenGLDebugging.java;
|
||||
// originally from https://github.com/TheGreyGhost/MinecraftByExample/blob/1-8final/src/main/java/minecraftbyexample/usefultools/OpenGLdebugging.java
|
||||
|
||||
@@ -30,7 +39,7 @@ public class OpenGLDebugging {
|
||||
public static final String GL_GET_INTEGERV = "glGetIntegerv()";
|
||||
public static final String GL_GET_FLOATV = "glGetFloatv()";
|
||||
|
||||
public class GLproperty {
|
||||
public static class GLproperty {
|
||||
|
||||
public GLproperty(int glConstant, String name, String description, String category, String fetchCommand) {
|
||||
this.gLConstant = glConstant;
|
||||
@@ -445,11 +454,12 @@ public class OpenGLDebugging {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkGLSM() {
|
||||
public static String getGLSMErrorLog() {
|
||||
StringBuilder error = new StringBuilder();
|
||||
boolean mismatch = false;
|
||||
for (int i = 0; i < instance.propertyList.length; ++i) {
|
||||
final GLproperty gLProperty = instance.propertyList[i];
|
||||
if(gLProperty.fetchCommand.equals(GL_GET_FLOATV) && gLProperty.name.endsWith("_MATRIX")) {
|
||||
if (gLProperty.fetchCommand.equals(GL_GET_FLOATV) && gLProperty.name.endsWith("_MATRIX")) {
|
||||
final Matrix4f cached = gLProperty.getAsMatrix4f(true);
|
||||
final Matrix4f uncached = gLProperty.getAsMatrix4f(false);
|
||||
// Some precision issues due to RAD vs degrees, and translated (vs f)
|
||||
@@ -461,14 +471,87 @@ public class OpenGLDebugging {
|
||||
final String cached = gLProperty.getAsString(true);
|
||||
final String uncached = gLProperty.getAsString(false);
|
||||
if (!cached.equals(uncached)) {
|
||||
LOGGER.error("GLSM mismatch: " + gLProperty.name + " cached: " + cached + " uncached: " + uncached);
|
||||
error.append("GLSM mismatch: " + gLProperty.name + " cached: " + cached + " uncached: " + uncached);
|
||||
error.append('\n');
|
||||
mismatch = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
final TextureUnitArray textureUnits = GLStateManager.getTextures();
|
||||
int currentActiveTexture = GLStateManager.getActiveTextureUnit();
|
||||
for (int i = 0; i < textureUnits.textureMatricies.length; i++) {
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + i);
|
||||
final boolean cached = GLStateManager.glIsEnabled(GL11.GL_TEXTURE_2D);
|
||||
final boolean uncached = GL11.glIsEnabled(GL11.GL_TEXTURE_2D);
|
||||
if (cached != uncached) {
|
||||
error.append("GLSM mismatch: " + "GL_TEXTURE_2D" + " cached: " + cached + " uncached: " + uncached + ", texture unit: GL_TEXTURE" + i);
|
||||
error.append('\n');
|
||||
mismatch = true;
|
||||
}
|
||||
}
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + currentActiveTexture);
|
||||
if (!mismatch) {
|
||||
return null;
|
||||
}
|
||||
return error.toString();
|
||||
}
|
||||
|
||||
public static void checkGLSM() {
|
||||
String output = getGLSMErrorLog();
|
||||
|
||||
if (output == null) {
|
||||
LOGGER.info("GLSM state matches!");
|
||||
} else {
|
||||
LOGGER.error(output);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyTexture(ResourceLocation resource, File output) {
|
||||
Object object = Minecraft.getMinecraft().renderEngine.mapTextureObjects.get(resource);
|
||||
|
||||
if (object != null) {
|
||||
copyTexture(((ITextureObject) object).getGlTextureId(), output);
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyTexture(int textureID, File output) {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
|
||||
|
||||
int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_WIDTH);
|
||||
int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, 0, GL11.GL_TEXTURE_HEIGHT);
|
||||
|
||||
BufferedImage bufferedimage = new BufferedImage(width, height, 1);
|
||||
final int[] pixelValues = ((DataBufferInt) bufferedimage.getRaster().getDataBuffer()).getData();
|
||||
IntBuffer pixelBuffer = BufferUtils.createIntBuffer(pixelValues.length);
|
||||
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, pixelBuffer);
|
||||
pixelBuffer.get(pixelValues);
|
||||
|
||||
// Flip texture
|
||||
final int halfHeight = height / 2;
|
||||
final int[] rowBuffer = new int[width];
|
||||
for (int y = 0; y < halfHeight; y++) {
|
||||
final int top = y * width;
|
||||
final int bottom = (height - 1 - y) * width;
|
||||
|
||||
System.arraycopy(pixelValues, top, rowBuffer, 0, width);
|
||||
System.arraycopy(pixelValues, bottom, pixelValues, top, width);
|
||||
System.arraycopy(rowBuffer, 0, pixelValues, bottom, width);
|
||||
}
|
||||
|
||||
File dir = output.getParentFile();
|
||||
dir.mkdirs();
|
||||
copyBufferedImageToFile(bufferedimage, output);
|
||||
bufferedimage.flush();
|
||||
}
|
||||
|
||||
|
||||
private static void copyBufferedImageToFile(BufferedImage image, File file) {
|
||||
try {
|
||||
ImageIO.write(image, "png", file);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -125,9 +125,9 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
boolean rfbLoaded = Launch.blackboard.getOrDefault("angelica.rfbPluginLoaded", Boolean.FALSE) == Boolean.TRUE;
|
||||
if (!rfbLoaded) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.AngelicaLateTweaker");
|
||||
if (AngelicaConfig.enableSodium) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.SodiumLateTweaker");
|
||||
}
|
||||
}
|
||||
if (AngelicaConfig.enableSodium) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.SodiumLateTweaker");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class AngelicaRedirectorTransformer implements IClassTransformer {
|
||||
private final String[] exclusions;
|
||||
|
||||
public AngelicaRedirectorTransformer() {
|
||||
inner = new AngelicaRedirector();
|
||||
inner = new AngelicaRedirector(AngelicaTweaker.isObfEnv());
|
||||
exclusions = inner.getTransformerExclusions();
|
||||
}
|
||||
|
||||
|
||||
+18
-24
@@ -1,24 +1,26 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.transformers;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.AngelicaRedirector;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.SodiumBlockTransform;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SodiumBlockTransformer implements IClassTransformer {
|
||||
|
||||
private final SodiumBlockTransform inner;
|
||||
private final String[] exclusions;
|
||||
|
||||
public SodiumBlockTransformer() {
|
||||
this.inner = new SodiumBlockTransform(AngelicaTweaker.isObfEnv());
|
||||
this.exclusions = inner.getTransformerExclusions();
|
||||
this.inner.setSodiumSetting();
|
||||
}
|
||||
private static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
Pair.of("minY", "field_149760_C"),
|
||||
Pair.of("minZ", "field_149754_D"),
|
||||
Pair.of("maxX", "field_149755_E"),
|
||||
Pair.of("maxY", "field_149756_F"),
|
||||
Pair.of("maxZ", "field_149757_G")
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete the global vanilla bounding box fields off the Block object. {@link AngelicaRedirector}
|
||||
@@ -27,20 +29,12 @@ public class SodiumBlockTransformer implements IClassTransformer {
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
for (String exclusion : exclusions) {
|
||||
if (transformedName.startsWith(exclusion)) return basicClass;
|
||||
}
|
||||
|
||||
if (!inner.shouldTransform(basicClass)) {
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
final boolean changed = inner.transformClassNode(transformedName, cn);
|
||||
if (changed) {
|
||||
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
if ("net.minecraft.block.Block".equals(transformedName)) {
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
cn.fields.removeIf(field -> BlockBoundsFields.stream().anyMatch(pair -> field.name.equals(pair.getLeft()) || field.name.equals(pair.getRight())));
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.loading.rfb;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.rfb.transformers.RFBAngelicaRedirector;
|
||||
import com.gtnewhorizons.angelica.loading.rfb.transformers.RFBSodiumBlockTransformer;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.PluginContext;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RetroFuturaBootstrap;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformer;
|
||||
@@ -26,8 +25,7 @@ public class AngelicaRfbPlugin implements RfbPlugin {
|
||||
|
||||
final boolean isObf = RetroFuturaBootstrap.API.launchClassLoader().findClassMetadata("net.minecraft.world.World") == null;
|
||||
return new RfbClassTransformer[] {
|
||||
new RFBAngelicaRedirector(),
|
||||
new RFBSodiumBlockTransformer(isObf)
|
||||
new RFBAngelicaRedirector(isObf)
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -16,8 +16,8 @@ public class RFBAngelicaRedirector implements RfbClassTransformer {
|
||||
|
||||
private final AngelicaRedirector inner;
|
||||
|
||||
public RFBAngelicaRedirector() {
|
||||
inner = new AngelicaRedirector();
|
||||
public RFBAngelicaRedirector(boolean isObf) {
|
||||
inner = new AngelicaRedirector(isObf);
|
||||
}
|
||||
|
||||
@Pattern("[a-z0-9-]+")
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.loading.rfb.transformers;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.SodiumBlockTransform;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.ClassNodeHandle;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.ExtensibleClassLoader;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformer;
|
||||
import org.intellij.lang.annotations.Pattern;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
public class RFBSodiumBlockTransformer implements RfbClassTransformer {
|
||||
|
||||
private final SodiumBlockTransform inner;
|
||||
|
||||
public RFBSodiumBlockTransformer(boolean isObf) {
|
||||
inner = new SodiumBlockTransform(isObf);
|
||||
}
|
||||
|
||||
@Pattern("[a-z0-9-]+")
|
||||
@Override
|
||||
public @NotNull String id() {
|
||||
return "sodiumblocktransform";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String @Nullable [] sortAfter() {
|
||||
return new String[]{"*", "mixin:mixin"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String @Nullable [] sortBefore() {
|
||||
return new String[]{"lwjgl3ify:redirect"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String @Nullable [] additionalExclusions() {
|
||||
return inner.getTransformerExclusions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldTransformClass(@NotNull ExtensibleClassLoader classLoader,
|
||||
@NotNull RfbClassTransformer.Context context, @Nullable Manifest manifest, @NotNull String className,
|
||||
@NotNull ClassNodeHandle classNode) {
|
||||
if (!classNode.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
if (!classNode.isOriginal()) {
|
||||
// If a class is already a transformed ClassNode, conservatively continue processing.
|
||||
return true;
|
||||
}
|
||||
return inner.shouldTransform(classNode.getOriginalBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transformClass(@NotNull ExtensibleClassLoader classLoader, @NotNull RfbClassTransformer.Context context,
|
||||
@Nullable Manifest manifest, @NotNull String className, @NotNull ClassNodeHandle classNode) {
|
||||
final boolean changed = inner.transformClassNode(className, classNode.getNode());
|
||||
if (changed) {
|
||||
classNode.computeMaxs();
|
||||
AngelicaClassDump.dumpRFBClass(className, classNode, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
+135
-1
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This transformer redirects many GL calls to our custom GLStateManager
|
||||
@@ -34,6 +35,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* IT SHOULD NOT CALL ANY CODE FROM THE MAIN MOD
|
||||
*/
|
||||
public final class AngelicaRedirector {
|
||||
// TODO(Alexdoru) properly split this class in two because currently this class is doing
|
||||
// two very different things :
|
||||
// - redirect the GL calls to our GL manager class
|
||||
// - replace the block fields with a thread safe replacement (only if Sodium is enabled)
|
||||
|
||||
public AngelicaRedirector(boolean isObf) {
|
||||
IS_OBF = isObf;
|
||||
}
|
||||
|
||||
private final boolean IS_OBF;
|
||||
|
||||
private static final boolean ASSERT_MAIN_THREAD = Boolean.getBoolean("angelica.assertMainThread");
|
||||
private static final boolean LOG_SPAM = Boolean.getBoolean("angelica.redirectorLogspam");
|
||||
@@ -45,20 +56,48 @@ public final class AngelicaRedirector {
|
||||
private static final String GL14 = "org/lwjgl/opengl/GL14";
|
||||
private static final String GL20 = "org/lwjgl/opengl/GL20";
|
||||
private static final String Project = "org/lwjgl/util/glu/Project";
|
||||
|
||||
private static final String BlockClass = "net/minecraft/block/Block";
|
||||
private static final String BlockPackage = "net/minecraft/block/Block";
|
||||
|
||||
private static final String OpenGlHelper = "net/minecraft/client/renderer/OpenGlHelper";
|
||||
private static final String EXTBlendFunc = "org/lwjgl/opengl/EXTBlendFuncSeparate";
|
||||
private static final String ARBMultiTexture = "org/lwjgl/opengl/ARBMultitexture";
|
||||
private static final String MinecraftClient = "net.minecraft.client";
|
||||
private static final String SplashProgress = "cpw.mods.fml.client.SplashProgress";
|
||||
private static final String ThreadedBlockData = "com/gtnewhorizons/angelica/glsm/ThreadedBlockData";
|
||||
private static final Set<String> ExcludedMinecraftMainThreadChecks = ImmutableSet.of(
|
||||
"startGame", "func_71384_a",
|
||||
"initializeTextures", "func_77474_a"
|
||||
);
|
||||
private static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
Pair.of("minY", "field_149760_C"),
|
||||
Pair.of("minZ", "field_149754_D"),
|
||||
Pair.of("maxX", "field_149755_E"),
|
||||
Pair.of("maxY", "field_149756_F"),
|
||||
Pair.of("maxZ", "field_149757_G")
|
||||
);
|
||||
/** All classes in <tt>net.minecraft.block.*</tt> are the block subclasses save for these. */
|
||||
private static final String[] VanillaBlockExclusions = {
|
||||
"net/minecraft/block/IGrowable",
|
||||
"net/minecraft/block/ITileEntityProvider",
|
||||
"net/minecraft/block/BlockEventData",
|
||||
"net/minecraft/block/BlockSourceImpl",
|
||||
"net/minecraft/block/material/"
|
||||
};
|
||||
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, GL20, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, Project);
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(GL11, GL13, GL14, GL20, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, BlockPackage, Project);
|
||||
private static final Map<String, Map<String, String>> methodRedirects = new HashMap<>();
|
||||
private static final Map<Integer, String> glCapRedirects = new HashMap<>();
|
||||
|
||||
private static final Set<String> moddedBlockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
private static final Set<String> blockOwnerExclusions = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
|
||||
// Needed because the config is loaded in LaunchClassLoader, but we need to access it in the parent system loader.
|
||||
private static final MethodHandle angelicaConfigSodiumEnabledGetter;
|
||||
|
||||
static {
|
||||
glCapRedirects.put(org.lwjgl.opengl.GL11.GL_ALPHA_TEST, "AlphaTest");
|
||||
glCapRedirects.put(org.lwjgl.opengl.GL11.GL_BLEND, "Blend");
|
||||
@@ -181,6 +220,41 @@ public final class AngelicaRedirector {
|
||||
methodRedirects.put(EXTBlendFunc, RedirectMap.newMap().add("glBlendFuncSeparateEXT", "tryBlendFuncSeparate"));
|
||||
methodRedirects.put(ARBMultiTexture, RedirectMap.newMap().add("glActiveTextureARB"));
|
||||
methodRedirects.put(Project, RedirectMap.newMap().add("gluPerspective"));
|
||||
|
||||
try {
|
||||
final Class<?> angelicaConfig = Class.forName("com.gtnewhorizons.angelica.config.AngelicaConfig", true, Launch.classLoader);
|
||||
angelicaConfigSodiumEnabledGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableSodium", boolean.class);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSodiumEnabled() {
|
||||
try {
|
||||
return (boolean) angelicaConfigSodiumEnabledGetter.invokeExact();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isVanillaBlockSubclass(String className) {
|
||||
if (className.startsWith(BlockPackage)) {
|
||||
for (String exclusion : VanillaBlockExclusions) {
|
||||
if (className.startsWith(exclusion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isBlockSubclass(String className) {
|
||||
return isVanillaBlockSubclass(className) || moddedBlockSubclasses.contains(className);
|
||||
}
|
||||
|
||||
private String getFieldName(Pair<String, String> fieldPair) {
|
||||
return IS_OBF ? fieldPair.getRight() : fieldPair.getLeft();
|
||||
}
|
||||
|
||||
public String[] getTransformerExclusions() {
|
||||
@@ -202,6 +276,30 @@ public final class AngelicaRedirector {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Track subclasses of Block
|
||||
if (!isVanillaBlockSubclass(cn.name) && isBlockSubclass(cn.superName)) {
|
||||
moddedBlockSubclasses.add(cn.name);
|
||||
cstPoolParser.addString(cn.name);
|
||||
}
|
||||
|
||||
// Check if this class shadows any fields of the parent class
|
||||
if (moddedBlockSubclasses.contains(cn.name)) {
|
||||
// If a superclass shadows, then so do we, because JVM will resolve a reference on our class to that
|
||||
// superclass
|
||||
boolean doWeShadow;
|
||||
if (blockOwnerExclusions.contains(cn.superName)) {
|
||||
doWeShadow = true;
|
||||
} else {
|
||||
// Check if we declare any known field names
|
||||
doWeShadow = BlockBoundsFields.stream().anyMatch(pair ->
|
||||
cn.fields.stream().anyMatch(field -> field.name.equals(getFieldName(pair))));
|
||||
}
|
||||
if (doWeShadow) {
|
||||
LOGGER.info("Class '{}' shadows one or more block bounds fields, these accesses won't be redirected!", cn.name);
|
||||
blockOwnerExclusions.add(cn.name);
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (MethodNode mn : cn.methods) {
|
||||
if (transformedName.equals("net.minecraft.client.renderer.OpenGlHelper") && (mn.name.equals("glBlendFunc") || mn.name.equals("func_148821_a"))) {
|
||||
@@ -262,6 +360,42 @@ public final class AngelicaRedirector {
|
||||
redirectInMethod = true;
|
||||
}
|
||||
}
|
||||
} else if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if (!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && isSodiumEnabled()) {
|
||||
Pair<String, String> fieldToRedirect = BlockBoundsFields.stream()
|
||||
.filter(pair -> fNode.name.equals(getFieldName(pair)))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (fieldToRedirect != null) {
|
||||
if (LOG_SPAM) {
|
||||
LOGGER.info("Redirecting Block.{} in {} to thread-safe wrapper", fNode.name, transformedName);
|
||||
}
|
||||
// Perform the redirect
|
||||
fNode.name = fieldToRedirect.getLeft(); // use unobfuscated name
|
||||
fNode.owner = ThreadedBlockData;
|
||||
// Inject getter before the field access, to turn Block -> ThreadedBlockData
|
||||
final MethodInsnNode getter = new MethodInsnNode(Opcodes.INVOKESTATIC, ThreadedBlockData, "get", "(L" + BlockClass + ";)L" + ThreadedBlockData + ";", false);
|
||||
if (node.getOpcode() == Opcodes.GETFIELD) {
|
||||
mn.instructions.insertBefore(fNode, getter);
|
||||
} else if (node.getOpcode() == Opcodes.PUTFIELD) {
|
||||
// FIXME: this code assumes doubles
|
||||
// Stack: Block, double
|
||||
final InsnList beforePut = new InsnList();
|
||||
beforePut.add(new InsnNode(Opcodes.DUP2_X1));
|
||||
// Stack: double, Block, double
|
||||
beforePut.add(new InsnNode(Opcodes.POP2));
|
||||
// Stack: double, Block
|
||||
beforePut.add(getter);
|
||||
// Stack: double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.DUP_X2));
|
||||
// Stack: ThreadedBlockData, double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.POP));
|
||||
// Stack: ThreadedBlockData, double
|
||||
mn.instructions.insertBefore(fNode, beforePut);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ASSERT_MAIN_THREAD && redirectInMethod && !transformedName.startsWith(SplashProgress) && !(transformedName.startsWith(MinecraftClient) && ExcludedMinecraftMainThreadChecks.contains(mn.name))) {
|
||||
|
||||
-211
@@ -1,211 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.loading.shared.transformers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizon.gtnhlib.asm.ClassConstantPoolParser;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
import org.objectweb.asm.tree.FieldInsnNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.InsnList;
|
||||
import org.objectweb.asm.tree.InsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SodiumBlockTransform {
|
||||
|
||||
public SodiumBlockTransform(boolean isObf) {
|
||||
this.IS_OBF = isObf;
|
||||
}
|
||||
|
||||
private final boolean IS_OBF;
|
||||
|
||||
private static final boolean LOG_SPAM = Boolean.getBoolean("angelica.redirectorLogspam");
|
||||
private static final Logger LOGGER = LogManager.getLogger("SodiumBlockTransformer");
|
||||
private static final String BlockClass = "net/minecraft/block/Block";
|
||||
private static final String BlockPackage = "net/minecraft/block/Block";
|
||||
private static final String ThreadedBlockData = "com/gtnewhorizons/angelica/glsm/ThreadedBlockData";
|
||||
private static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
Pair.of("minY", "field_149760_C"),
|
||||
Pair.of("minZ", "field_149754_D"),
|
||||
Pair.of("maxX", "field_149755_E"),
|
||||
Pair.of("maxY", "field_149756_F"),
|
||||
Pair.of("maxZ", "field_149757_G")
|
||||
);
|
||||
/** All classes in <tt>net.minecraft.block.*</tt> are the block subclasses save for these. */
|
||||
private static final String[] VanillaBlockExclusions = {
|
||||
"net/minecraft/block/IGrowable",
|
||||
"net/minecraft/block/ITileEntityProvider",
|
||||
"net/minecraft/block/BlockEventData",
|
||||
"net/minecraft/block/BlockSourceImpl",
|
||||
"net/minecraft/block/material/"
|
||||
};
|
||||
|
||||
private static final ClassConstantPoolParser cstPoolParser = new ClassConstantPoolParser(BlockPackage);
|
||||
private static final Set<String> moddedBlockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
private static final Set<String> blockOwnerExclusions = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Needed because the config is loaded in LaunchClassLoader, but we need to access it in the parent system loader.
|
||||
private static final MethodHandle angelicaConfigSodiumEnabledGetter;
|
||||
private static boolean isSodiumEnabled;
|
||||
|
||||
static {
|
||||
try {
|
||||
final Class<?> angelicaConfig = Class.forName("com.gtnewhorizons.angelica.config.AngelicaConfig", true, Launch.classLoader);
|
||||
angelicaConfigSodiumEnabledGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableSodium", boolean.class);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSodiumEnabled() {
|
||||
if (isSodiumEnabled) return true;
|
||||
try {
|
||||
return (boolean) angelicaConfigSodiumEnabledGetter.invokeExact();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isVanillaBlockSubclass(String className) {
|
||||
if (className.startsWith(BlockPackage)) {
|
||||
for (String exclusion : VanillaBlockExclusions) {
|
||||
if (className.startsWith(exclusion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isBlockSubclass(String className) {
|
||||
return isVanillaBlockSubclass(className) || moddedBlockSubclasses.contains(className);
|
||||
}
|
||||
|
||||
private String getFieldName(Pair<String, String> fieldPair) {
|
||||
return IS_OBF ? fieldPair.getRight() : fieldPair.getLeft();
|
||||
}
|
||||
|
||||
public String[] getTransformerExclusions() {
|
||||
return new String[]{
|
||||
"org.lwjgl",
|
||||
"com.gtnewhorizons.angelica.glsm.",
|
||||
"com.gtnewhorizons.angelica.transform",
|
||||
"me.eigenraven.lwjgl3ify"
|
||||
};
|
||||
}
|
||||
|
||||
public boolean shouldTransform(byte[] basicClass) {
|
||||
return cstPoolParser.find(basicClass, true);
|
||||
}
|
||||
|
||||
/** @return Was the class changed? */
|
||||
public boolean transformClassNode(String transformedName, ClassNode cn) {
|
||||
if (cn == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("net.minecraft.block.Block".equals(transformedName) && isSodiumEnabled()) {
|
||||
cn.fields.removeIf(field -> BlockBoundsFields.stream().anyMatch(pair -> field.name.equals(pair.getLeft()) || field.name.equals(pair.getRight())));
|
||||
}
|
||||
|
||||
// Track subclasses of Block
|
||||
if (!isVanillaBlockSubclass(cn.name) && isBlockSubclass(cn.superName)) {
|
||||
moddedBlockSubclasses.add(cn.name);
|
||||
cstPoolParser.addString(cn.name);
|
||||
}
|
||||
|
||||
// Check if this class shadows any fields of the parent class
|
||||
if (moddedBlockSubclasses.contains(cn.name)) {
|
||||
// If a superclass shadows, then so do we, because JVM will resolve a reference on our class to that
|
||||
// superclass
|
||||
boolean doWeShadow;
|
||||
if (blockOwnerExclusions.contains(cn.superName)) {
|
||||
doWeShadow = true;
|
||||
} else {
|
||||
// Check if we declare any known field names
|
||||
boolean b = false;
|
||||
for (Pair<String, String> pair : BlockBoundsFields) {
|
||||
boolean result = false;
|
||||
for (FieldNode field : cn.fields) {
|
||||
if (field.name.equals(getFieldName(pair))) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result) {
|
||||
b = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
doWeShadow = b;
|
||||
}
|
||||
if (doWeShadow) {
|
||||
LOGGER.info("Class '{}' shadows one or more block bounds fields, these accesses won't be redirected!", cn.name);
|
||||
blockOwnerExclusions.add(cn.name);
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
for (MethodNode mn : cn.methods) {
|
||||
for (AbstractInsnNode node : mn.instructions.toArray()) {
|
||||
if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if (!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && isSodiumEnabled()) {
|
||||
Pair<String, String> fieldToRedirect = BlockBoundsFields.stream()
|
||||
.filter(pair -> fNode.name.equals(getFieldName(pair)))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (fieldToRedirect != null) {
|
||||
if (LOG_SPAM) {
|
||||
LOGGER.info("Redirecting Block.{} in {} to thread-safe wrapper", fNode.name, transformedName);
|
||||
}
|
||||
// Perform the redirect
|
||||
fNode.name = fieldToRedirect.getLeft(); // use unobfuscated name
|
||||
fNode.owner = ThreadedBlockData;
|
||||
// Inject getter before the field access, to turn Block -> ThreadedBlockData
|
||||
final MethodInsnNode getter = new MethodInsnNode(Opcodes.INVOKESTATIC, ThreadedBlockData, "get", "(L" + BlockClass + ";)L" + ThreadedBlockData + ";", false);
|
||||
if (node.getOpcode() == Opcodes.GETFIELD) {
|
||||
mn.instructions.insertBefore(fNode, getter);
|
||||
} else if (node.getOpcode() == Opcodes.PUTFIELD) {
|
||||
// FIXME: this code assumes doubles
|
||||
// Stack: Block, double
|
||||
final InsnList beforePut = new InsnList();
|
||||
beforePut.add(new InsnNode(Opcodes.DUP2_X1));
|
||||
// Stack: double, Block, double
|
||||
beforePut.add(new InsnNode(Opcodes.POP2));
|
||||
// Stack: double, Block
|
||||
beforePut.add(getter);
|
||||
// Stack: double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.DUP_X2));
|
||||
// Stack: ThreadedBlockData, double, ThreadedBlockData
|
||||
beforePut.add(new InsnNode(Opcodes.POP));
|
||||
// Stack: ThreadedBlockData, double
|
||||
mn.instructions.insertBefore(fNode, beforePut);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
public void setSodiumSetting() {
|
||||
isSodiumEnabled = true;
|
||||
}
|
||||
}
|
||||
@@ -77,14 +77,7 @@ public enum Mixins implements IMixins {
|
||||
, "angelica.dynamiclights.MixinItemRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
ANGELICA_FIX_BLOCK_CRACK(
|
||||
new MixinBuilder("Block corners and edges between chunks might have \"cracks\" in them. This option fixes it")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.bugfixes.MixinRenderBlocks_CrackFix")
|
||||
.addExcludedMod(TargetedMod.FALSETWEAKS)
|
||||
.setApplyIf(() -> AngelicaConfig.fixBlockCrack)),
|
||||
|
||||
|
||||
ANGELICA_FIX_FLUID_RENDERER_CHECKING_BLOCK_AGAIN(
|
||||
new MixinBuilder("Fix RenderBlockFluid reading the block type from the world access multiple times")
|
||||
.setPhase(Phase.EARLY)
|
||||
@@ -283,17 +276,6 @@ public enum Mixins implements IMixins {
|
||||
.addRequiredMod(TargetedMod.MINEFACTORY_RELOADED)
|
||||
.setApplyIf(() -> CompatConfig.fixMinefactoryReloaded)
|
||||
.addClientMixins("client.minefactoryreloaded.MixinRedNetCableRenderer")),
|
||||
|
||||
NTM_SPACE_TWEAKS(new MixinBuilder("Support for 'Disable Horizon' & 'disableAltitudePlanetRenderer' options in NTM:Space")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.NTM_SPACE)
|
||||
.setApplyIf(() -> CompatConfig.tweakNTMSpace)
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_Tweaks")),
|
||||
NTM_SPACE_SHADER_COMPAT(new MixinBuilder("Multiple shader fixes for NTM:Space")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.NTM_SPACE)
|
||||
.setApplyIf(() -> CompatConfig.fixNTMSpace && AngelicaConfig.enableIris)
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_ShaderCompat")),
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new MixinBuilder("Add animation speedup support to Campfire Backport")
|
||||
.setPhase(Phase.LATE)
|
||||
@@ -593,6 +575,13 @@ public enum Mixins implements IMixins {
|
||||
.addClientMixins("mcpatcherforge.ctm_cc.MixinTextureMap")
|
||||
),
|
||||
//End from NotFine
|
||||
|
||||
QPR(new MixinBuilder("Adds a QuadProvider field to blocks without populating it")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins(
|
||||
"angelica.models.MixinBlock",
|
||||
"angelica.models.MixinBlockOldLeaf")),
|
||||
|
||||
;
|
||||
|
||||
private final MixinBuilder builder;
|
||||
|
||||
@@ -14,9 +14,7 @@ public enum TargetedMod implements ITargetMod {
|
||||
DYNAMIC_SURROUNDINGS_MIST("org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround"),
|
||||
DYNAMIC_SURROUNDINGS_ORIGINAL("org.blockartistry.mod.DynSurround.asm.TransformLoader", "dsurround"),
|
||||
EXTRAUTILS(null, "ExtraUtilities"),
|
||||
FALSETWEAKS("com.falsepattern.falsetweaks.asm.CoreLoadingPlugin", "falsetweaks"),
|
||||
MINEFACTORY_RELOADED(null, "MineFactoryReloaded"),
|
||||
NTM_SPACE("com.hbm.dim.SolarSystem"),
|
||||
IC2("ic2.core.coremod.IC2core", "IC2"),
|
||||
NATURA(null, "Natura"),
|
||||
SECURITYCRAFT(null, "securitycraft"),
|
||||
@@ -26,10 +24,7 @@ public enum TargetedMod implements ITargetMod {
|
||||
WITCHERY(null, "witchery");
|
||||
|
||||
private final TargetModBuilder builder;
|
||||
|
||||
TargetedMod(String targetClass) {
|
||||
this.builder = new TargetModBuilder().setTargetClass(targetClass);
|
||||
}
|
||||
|
||||
TargetedMod(String coreModClass, String modId) {
|
||||
this.builder = new TargetModBuilder().setCoreModClass(coreModClass).setModId(modId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
|
||||
public interface ModeledBlock {
|
||||
|
||||
QuadProvider getModel();
|
||||
void setModel(QuadProvider model);
|
||||
}
|
||||
@@ -0,0 +1,191 @@
|
||||
package com.gtnewhorizons.angelica.models;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.IBlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.ModelLoader;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.Variant;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.json.ModelLocation;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.BlockColoredCube;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.BlockStaticCube;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.Column3Rot;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.template.Model4Rot;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class VanillaModels {
|
||||
|
||||
private static boolean init = false;
|
||||
|
||||
public static final BlockStaticCube STONE = new BlockStaticCube("stone");
|
||||
public static final BlockStaticCube GLASS = new BlockStaticCube("glass");
|
||||
|
||||
public static BlockColoredCube OAK_LEAVES;
|
||||
public static BlockColoredCube SPRUCE_LEAVES;
|
||||
public static BlockColoredCube BIRCH_LEAVES;
|
||||
public static BlockColoredCube JUNGLE_LEAVES;
|
||||
public static QuadProvider OLD_LEAF = new QuadProvider() {
|
||||
@Override
|
||||
public int getColor(IBlockAccess world, IBlockPos pos, Block block, int meta, Random random) {
|
||||
return QuadProvider.getDefaultColor(world, pos, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
return (switch (meta % 4) {
|
||||
case 0 -> OAK_LEAVES;
|
||||
case 1 -> SPRUCE_LEAVES;
|
||||
case 2 -> BIRCH_LEAVES;
|
||||
case 3 -> JUNGLE_LEAVES;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static BlockColoredCube ACACIA_LEAVES;
|
||||
public static BlockColoredCube DARK_OAK_LEAVES;
|
||||
public static QuadProvider NEW_LEAF = new QuadProvider() {
|
||||
@Override
|
||||
public int getColor(IBlockAccess world, IBlockPos pos, Block block, int meta, Random random) {
|
||||
return QuadProvider.getDefaultColor(world, pos, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
return (switch (meta % 2) {
|
||||
case 0 -> ACACIA_LEAVES;
|
||||
case 1 -> DARK_OAK_LEAVES;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static Column3Rot OAK_LOG;
|
||||
public static Column3Rot SPRUCE_LOG;
|
||||
public static Column3Rot BIRCH_LOG;
|
||||
public static Column3Rot JUNGLE_LOG;
|
||||
public static BlockStaticCube OAK_WOOD;
|
||||
public static BlockStaticCube BIRCH_WOOD;
|
||||
public static BlockStaticCube SPRUCE_WOOD;
|
||||
public static BlockStaticCube JUNGLE_WOOD;
|
||||
public static QuadProvider OLD_LOG = new QuadProvider() {
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
|
||||
if (meta > 11) {
|
||||
return (switch (meta) {
|
||||
case 12 -> OAK_WOOD;
|
||||
case 13 -> SPRUCE_WOOD;
|
||||
case 14 -> BIRCH_WOOD;
|
||||
case 15 -> JUNGLE_WOOD;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
|
||||
Column3Rot ret = switch (meta % 4) {
|
||||
case 0 -> OAK_LOG;
|
||||
case 1 -> SPRUCE_LOG;
|
||||
case 2 -> BIRCH_LOG;
|
||||
case 3 -> JUNGLE_LOG;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
};
|
||||
|
||||
return (switch (meta / 4) {
|
||||
case 0 -> ret.updown();
|
||||
case 1 -> ret.eastwest();
|
||||
case 2 -> ret.northsouth();
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static Column3Rot ACACIA_LOG;
|
||||
public static Column3Rot DARK_OAK_LOG;
|
||||
public static BlockStaticCube ACACIA_WOOD;
|
||||
public static BlockStaticCube DARK_OAK_WOOD;
|
||||
public static QuadProvider NEW_LOG = new QuadProvider() {
|
||||
@Override
|
||||
public List<QuadView> getQuads(IBlockAccess world, IBlockPos pos, Block block, int meta, ForgeDirection dir, Random random, int color, Supplier<QuadView> quadPool) {
|
||||
|
||||
if (meta > 11) {
|
||||
return (switch (meta) {
|
||||
case 12 -> ACACIA_WOOD;
|
||||
case 13 -> DARK_OAK_WOOD;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
|
||||
Column3Rot ret = switch (meta % 4) {
|
||||
case 0 -> ACACIA_LOG;
|
||||
case 1 -> DARK_OAK_LOG;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
};
|
||||
|
||||
return (switch (meta / 4) {
|
||||
case 0 -> ret.updown();
|
||||
case 1 -> ret.eastwest();
|
||||
case 2 -> ret.northsouth();
|
||||
default -> throw new IllegalStateException("Unexpected value: " + meta);
|
||||
}).getQuads(world, pos, block, meta, dir, random, color, quadPool);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Variant workbench = new Variant(
|
||||
new ModelLocation("block/crafting_table"),
|
||||
0,
|
||||
0,
|
||||
true
|
||||
);
|
||||
public static QuadProvider WORKBENCH;
|
||||
|
||||
public static Model4Rot LECTERN;
|
||||
|
||||
public static void init() {
|
||||
|
||||
if (init) {
|
||||
throw new RuntimeException("Vanilla models were baked twice!");
|
||||
}
|
||||
|
||||
if (AngelicaConfig.injectQPRendering) {
|
||||
|
||||
ACACIA_LEAVES = new BlockColoredCube("leaves_acacia");
|
||||
BIRCH_LEAVES = new BlockColoredCube("leaves_birch");
|
||||
DARK_OAK_LEAVES = new BlockColoredCube("leaves_big_oak");
|
||||
JUNGLE_LEAVES = new BlockColoredCube("leaves_jungle");
|
||||
OAK_LEAVES = new BlockColoredCube("leaves_oak");
|
||||
SPRUCE_LEAVES = new BlockColoredCube("leaves_spruce");
|
||||
|
||||
ACACIA_LOG = new Column3Rot(new ModelLocation("block/acacia_log"));
|
||||
BIRCH_LOG = new Column3Rot(new ModelLocation("block/birch_log"));
|
||||
DARK_OAK_LOG = new Column3Rot(new ModelLocation("block/dark_oak_log"));
|
||||
JUNGLE_LOG = new Column3Rot(new ModelLocation("block/jungle_log"));
|
||||
OAK_LOG = new Column3Rot(new ModelLocation("block/oak_log"));
|
||||
SPRUCE_LOG = new Column3Rot(new ModelLocation("block/spruce_log"));
|
||||
|
||||
ACACIA_WOOD = new BlockStaticCube("log_acacia");
|
||||
BIRCH_WOOD = new BlockStaticCube("log_birch");
|
||||
DARK_OAK_WOOD = new BlockStaticCube("log_big_oak");
|
||||
JUNGLE_WOOD = new BlockStaticCube("log_jungle");
|
||||
OAK_WOOD = new BlockStaticCube("log_oak");
|
||||
SPRUCE_WOOD = new BlockStaticCube("log_spruce");
|
||||
|
||||
ModelLoader.registerModels(VanillaModels::loadModels,
|
||||
workbench);
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableTestBlocks)
|
||||
LECTERN = new Model4Rot(new ModelLocation("block/lectern"));
|
||||
|
||||
init = true;
|
||||
}
|
||||
|
||||
public static void loadModels() {
|
||||
WORKBENCH = ModelLoader.getModel(workbench);
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.loading.ModelRegistry;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -39,7 +35,6 @@ import jss.notfine.core.Settings;
|
||||
import me.jellysquid.mods.sodium.client.SodiumDebugScreenHandler;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.client.IrisDebugScreenHandler;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -76,7 +71,6 @@ public class ClientProxy extends CommonProxy {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
ModelRegistry.registerModid(MOD_ID);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@@ -114,23 +108,6 @@ public class ClientProxy extends CommonProxy {
|
||||
Iris.INSTANCE.fmlInitEvent();
|
||||
FMLCommonHandler.instance().bus().register(Iris.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(Iris.INSTANCE);
|
||||
|
||||
VertexFormat.registerSetupBufferStateOverride((vertexFormat, l) -> {
|
||||
if (vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL
|
||||
|| vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
IrisVertexFormats.TERRAIN.setupBufferState(l);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
VertexFormat.registerClearBufferStateOverride(vertexFormat -> {
|
||||
if (vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL
|
||||
|| vertexFormat == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
IrisVertexFormats.TERRAIN.clearBufferState();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.gtnewhorizons.angelica.render;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VBOManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
@@ -60,7 +59,6 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
private final Minecraft mc = Minecraft.getMinecraft();
|
||||
private final ResourceLocation texture = new ResourceLocation("textures/environment/clouds.png");
|
||||
|
||||
private int displayList = -1;
|
||||
private VertexBuffer vbo;
|
||||
private int cloudMode = -1;
|
||||
private int renderDistance = -1;
|
||||
@@ -68,6 +66,7 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
private int scaleMult = -1;
|
||||
|
||||
private DynamicTexture COLOR_TEX = null;
|
||||
private int texColor;
|
||||
|
||||
private int texW;
|
||||
private int texH;
|
||||
@@ -224,10 +223,7 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
|
||||
vertices(tess);
|
||||
|
||||
if(displayList == -1) {
|
||||
this.displayList = VBOManager.generateDisplayLists(1);
|
||||
}
|
||||
this.vbo = VBOManager.registerVBO(this.displayList, TessellatorManager.stopCapturingToVBO(FORMAT));
|
||||
this.vbo = TessellatorManager.stopCapturingToVBO(FORMAT);
|
||||
}
|
||||
|
||||
private int fullCoord(double coord, int scale) { // Corrects misalignment of UV offset when on negative coords.
|
||||
@@ -305,7 +301,7 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
|
||||
// Translate the texture.
|
||||
GLStateManager.glMatrixMode(GL11.GL_TEXTURE);
|
||||
GLStateManager.glTranslated(offU * PX_SIZE, offV * PX_SIZE, 0);
|
||||
GLStateManager.glTranslatef(offU * PX_SIZE, offV * PX_SIZE, 0);
|
||||
GLStateManager.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
|
||||
GLStateManager.disableCull();
|
||||
@@ -328,15 +324,19 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
b = tempB;
|
||||
}
|
||||
|
||||
if (COLOR_TEX == null)
|
||||
COLOR_TEX = new DynamicTexture(1, 1);
|
||||
|
||||
// Apply a color multiplier through a texture upload if shaders aren't supported.
|
||||
COLOR_TEX.getTextureData()[0] = 255 << 24
|
||||
final int newColor = 0xFF000000
|
||||
| ((int) (r * 255)) << 16
|
||||
| ((int) (g * 255)) << 8
|
||||
| (int) (b * 255);
|
||||
COLOR_TEX.updateDynamicTexture();
|
||||
if (texColor != newColor) {
|
||||
if (COLOR_TEX == null) {
|
||||
COLOR_TEX = new DynamicTexture(1, 1);
|
||||
}
|
||||
COLOR_TEX.getTextureData()[0] = newColor;
|
||||
COLOR_TEX.updateDynamicTexture();
|
||||
texColor = newColor;
|
||||
}
|
||||
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, COLOR_TEX.getGlTextureId());
|
||||
|
||||
@@ -27,18 +27,21 @@ package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.HashCommon;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import java.nio.ByteBuffer;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemRenderListManager {
|
||||
// Least used element is at position 0. This is in theory slightly faster.
|
||||
private static final Object2ObjectLinkedOpenHashMap<ItemProp, CachedVBO> vboCache = new Object2ObjectLinkedOpenHashMap<>(64);
|
||||
@@ -97,7 +100,7 @@ public class ItemRenderListManager {
|
||||
}
|
||||
|
||||
public static void post(CapturingTessellator tessellator, VertexBuffer vbo) {
|
||||
final var quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
final int size = quads.size();
|
||||
|
||||
final int needed = (DefaultVertexFormat.POSITION_TEXTURE_NORMAL.getVertexSize() * size) << 2;
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import glowredman.txloader.Asset;
|
||||
import glowredman.txloader.TXLoaderCore;
|
||||
|
||||
public class AssetLoader {
|
||||
|
||||
// Texture paths from modern, starting with "minecraft/textures/"
|
||||
public static final String[] injectTexs = {
|
||||
"block/stone",
|
||||
"block/crafting_table_front",
|
||||
"block/crafting_table_side",
|
||||
"block/crafting_table_top",
|
||||
"block/oak_planks",
|
||||
"block/acacia_log_top",
|
||||
"block/acacia_log",
|
||||
"block/birch_log_top",
|
||||
"block/birch_log",
|
||||
"block/dark_oak_log_top",
|
||||
"block/dark_oak_log",
|
||||
"block/jungle_log_top",
|
||||
"block/jungle_log",
|
||||
"block/oak_log_top",
|
||||
"block/oak_log",
|
||||
"block/spruce_log_top",
|
||||
"block/spruce_log"
|
||||
};
|
||||
|
||||
// Any equivalents from 7.10, starting with "minecraft/"
|
||||
// This can't be automatic because some of them are inconsistent
|
||||
public static final String[] oldInjectTexs = {
|
||||
"blocks/stone",
|
||||
"blocks/crafting_table_front",
|
||||
"blocks/crafting_table_side",
|
||||
"blocks/crafting_table_top",
|
||||
"blocks/planks_oak",
|
||||
"blocks/log_acacia_top",
|
||||
"blocks/log_acacia",
|
||||
"blocks/log_birch_top",
|
||||
"blocks/log_birch",
|
||||
"blocks/log_big_oak_top",
|
||||
"blocks/log_big_oak",
|
||||
"blocks/log_jungle_top",
|
||||
"blocks/log_jungle",
|
||||
"blocks/log_oak_top",
|
||||
"blocks/log_oak",
|
||||
"blocks/log_spruce_top",
|
||||
"blocks/log_spruce"
|
||||
};
|
||||
|
||||
public static final String[] testTexs = {
|
||||
"block/lectern_base",
|
||||
"block/lectern_front",
|
||||
"block/lectern_base",
|
||||
"block/lectern_sides",
|
||||
"block/lectern_top",
|
||||
"block/oak_planks"
|
||||
};
|
||||
|
||||
public static void load() {
|
||||
|
||||
if (AngelicaConfig.injectQPRendering || AngelicaConfig.enableTestBlocks) {
|
||||
addModelAssets(
|
||||
"block/block",
|
||||
"block/cube",
|
||||
"block/cube_all",
|
||||
"block/cube_column"
|
||||
);
|
||||
}
|
||||
|
||||
// For textures, we first clone old assets to their locations in modern, then copy any modern textures we don't
|
||||
// have equivalents for (only the lectern rn). Models are always downloaded, 7.10 doesn't have any.
|
||||
if (AngelicaConfig.injectQPRendering) {
|
||||
addModelAssets(
|
||||
"block/stone",
|
||||
"block/crafting_table",
|
||||
"block/acacia_log",
|
||||
"block/birch_log",
|
||||
"block/dark_oak_log",
|
||||
"block/jungle_log",
|
||||
"block/oak_log",
|
||||
"block/spruce_log");
|
||||
addTexAssets(oldInjectTexs, injectTexs, "1.7.10");
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableTestBlocks) {
|
||||
addModelAssets("block/lectern");
|
||||
addTexAssets(testTexs, testTexs, "1.20.4");
|
||||
}
|
||||
}
|
||||
|
||||
private static void addModelAssets(String... resourcePaths) {
|
||||
for (String path : resourcePaths) {
|
||||
TXLoaderCore.getAssetBuilder("minecraft/models/" + path + ".json")
|
||||
.setVersion("1.20.4")
|
||||
.setSource(Asset.Source.CLIENT)
|
||||
.add();
|
||||
}
|
||||
}
|
||||
|
||||
private static void addTexAssets(String[] resourcePaths, String[] destPaths, String version) {
|
||||
for (int i = 0; i < resourcePaths.length; ++i) {
|
||||
TXLoaderCore.getAssetBuilder("minecraft/textures/" + resourcePaths[i] + ".png")
|
||||
.setOverride("minecraft/textures/blocks/" + destPaths[i] + ".png")
|
||||
.setVersion(version)
|
||||
.setSource(Asset.Source.CLIENT)
|
||||
.add();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ObjectPooler<T> {
|
||||
private final Supplier<T> instanceSupplier;
|
||||
private final ArrayList<T> availableInstances;
|
||||
|
||||
public ObjectPooler(Supplier<T> instanceSupplier) {
|
||||
this.instanceSupplier = instanceSupplier;
|
||||
this.availableInstances = new ArrayList<>();
|
||||
}
|
||||
|
||||
public T getInstance() {
|
||||
if(this.availableInstances.isEmpty()) {
|
||||
return this.instanceSupplier.get();
|
||||
}
|
||||
return this.availableInstances.remove(this.availableInstances.size() - 1);
|
||||
}
|
||||
|
||||
public void releaseInstance(T instance) {
|
||||
this.availableInstances.add(instance);
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,6 @@ public enum Settings {
|
||||
DynamicLights.ShaderForce = (boolean) this.option.getStore();
|
||||
}
|
||||
},
|
||||
HORIZON_DISABLE(new NotFineOptionTickBox(true, OptionImpact.LOW)),
|
||||
FOG_DISABLE(new NotFineOptionTickBox(false, OptionImpact.LOW)),
|
||||
FOG_NEAR_DISTANCE(new NotFineOptionSliderPercentage(75, 1, 100, 1, OptionImpact.LOW)),
|
||||
GUI_BACKGROUND(new NotFineOptionCycling<>(BackgroundSelect.DEFAULT, null)) {
|
||||
|
||||
@@ -213,7 +213,6 @@ public class NotFineGameOptionPages {
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.HORIZON_DISABLE.option)
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.build());
|
||||
|
||||
@@ -4,19 +4,30 @@ package jss.notfine.render;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VBOManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.util.RandomXoshiro256StarStar;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderStars {
|
||||
|
||||
//private static final ResourceLocation locationStarsPng = new ResourceLocation("textures/colormap/stars.png");
|
||||
|
||||
public static void reloadStarRenderList(RenderGlobal render) {
|
||||
TessellatorManager.startCapturing();
|
||||
renderStars();
|
||||
VBOManager.registerVBO(render.starGLCallList, TessellatorManager.stopCapturingToVBO(DefaultVertexFormat.POSITION));
|
||||
|
||||
if(AngelicaConfig.enableVBO) {
|
||||
TessellatorManager.startCapturing();
|
||||
renderStars();
|
||||
VBOManager.registerVBO(render.starGLCallList, TessellatorManager.stopCapturingToVBO(DefaultVertexFormat.POSITION));
|
||||
} else {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glNewList(render.starGLCallList, GL11.GL_COMPILE);
|
||||
renderStars();
|
||||
GL11.glEndList();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderStars() {
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class ScrollBarComponent extends AbstractWidget {
|
||||
|
||||
protected static final int SCROLL_OFFSET = 15;
|
||||
protected static final int SCROLL_OFFSET = 6;
|
||||
|
||||
protected final Dim2i dim;
|
||||
|
||||
|
||||
@@ -89,7 +89,6 @@ public class SodiumGameOptionPages {
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.HORIZON_DISABLE.option)
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.add(Settings.VOID_FOG.option);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Light pipelines allow model quads for any location in the world to be lit using various backends, including fluids
|
||||
@@ -18,5 +18,5 @@ public interface LightPipeline {
|
||||
* @param face The pre-computed facing vector of the quad
|
||||
* @param shade True if the block is shaded by ambient occlusion
|
||||
*/
|
||||
void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ModelQuadFacing cullFace, ModelQuadFacing face, boolean shade);
|
||||
void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade);
|
||||
}
|
||||
+6
-6
@@ -1,11 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import me.jellysquid.mods.sodium.client.util.StateUtil;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* The light data cache is used to make accessing the light data and occlusion properties of blocks cheaper. The data
|
||||
@@ -26,15 +26,15 @@ public abstract class LightDataAccess {
|
||||
public static final ThreadLocal<BlockPos> DynamicLightsPos = ThreadLocal.withInitial(BlockPos::new);
|
||||
protected WorldSlice world;
|
||||
|
||||
public long get(int x, int y, int z, ModelQuadFacing d1, ModelQuadFacing d2) {
|
||||
return this.get(x + d1.getStepX() + d2.getStepX(), y + d1.getStepY() + d2.getStepY(), z + d1.getStepZ() + d2.getStepZ());
|
||||
public long get(int x, int y, int z, ForgeDirection d1, ForgeDirection d2) {
|
||||
return this.get(x + d1.offsetX + d2.offsetX, y + d1.offsetY + d2.offsetY, z + d1.offsetZ + d2.offsetZ);
|
||||
}
|
||||
|
||||
public long get(int x, int y, int z, ModelQuadFacing dir) {
|
||||
return this.get(x + dir.getStepX(), y + dir.getStepY(), z + dir.getStepZ());
|
||||
public long get(int x, int y, int z, ForgeDirection dir) {
|
||||
return this.get(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
}
|
||||
|
||||
public long get(BlockPos pos, ModelQuadFacing dir) {
|
||||
public long get(BlockPos pos, ForgeDirection dir) {
|
||||
return this.get(pos.x, pos.y, pos.z, dir);
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,17 +1,17 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.flat;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import java.util.Arrays;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A light pipeline which implements "classic-style" lighting through simply using the light value of the adjacent
|
||||
* block to a face.
|
||||
@@ -27,7 +27,7 @@ public class FlatLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ModelQuadFacing cullFace, ModelQuadFacing face, boolean shade) {
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
int lightmap;
|
||||
|
||||
// To match vanilla behavior, use the cull face if it exists/is available
|
||||
@@ -57,7 +57,7 @@ public class FlatLightPipeline implements LightPipeline {
|
||||
* behind tinted glass. {@link LightDataAccess} cannot efficiently store lightmaps computed with
|
||||
* inconsistent values so this method exists to mirror vanilla behavior as closely as possible.
|
||||
*/
|
||||
private int getOffsetLightmap(BlockPos pos, ModelQuadFacing face) {
|
||||
private int getOffsetLightmap(BlockPos pos, ForgeDirection face) {
|
||||
int lightmap = LightDataAccess.getLightMap(this.lightCache.get(pos, face));
|
||||
// If the block light is not 15 (max)...
|
||||
if ((lightmap & 0xF0) != 0xF0) {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.getLightMap;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackAO;
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackFO;
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.unpackOP;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import static me.jellysquid.mods.sodium.client.model.light.cache.ArrayLightDataCache.getLightMap;
|
||||
|
||||
class AoFaceData {
|
||||
public final int[] lm = new int[4];
|
||||
@@ -18,7 +18,7 @@ class AoFaceData {
|
||||
|
||||
private int flags;
|
||||
|
||||
public void initLightData(LightDataAccess cache, BlockPos pos, ModelQuadFacing direction, boolean offset) {
|
||||
public void initLightData(LightDataAccess cache, BlockPos pos, ForgeDirection direction, boolean offset) {
|
||||
final int x = pos.x;
|
||||
final int y = pos.y;
|
||||
final int z = pos.z;
|
||||
@@ -28,9 +28,9 @@ class AoFaceData {
|
||||
final int adjZ;
|
||||
|
||||
if (offset) {
|
||||
adjX = x + direction.getStepX();
|
||||
adjY = y + direction.getStepY();
|
||||
adjZ = z + direction.getStepZ();
|
||||
adjX = x + direction.offsetX;
|
||||
adjY = y + direction.offsetY;
|
||||
adjZ = z + direction.offsetZ;
|
||||
} else {
|
||||
adjX = x;
|
||||
adjY = y;
|
||||
@@ -50,7 +50,7 @@ class AoFaceData {
|
||||
|
||||
final float caao = unpackAO(adjWord);
|
||||
|
||||
var faces = AoNeighborInfo.get(direction).faces;
|
||||
ForgeDirection[] faces = AoNeighborInfo.get(direction).faces;
|
||||
|
||||
final long e0 = cache.get(adjX, adjY, adjZ, faces[0]);
|
||||
final int e0lm = getLightMap(e0);
|
||||
|
||||
+126
-134
@@ -1,141 +1,13 @@
|
||||
package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Y;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Z;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Y;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Z;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* The neighbor information for each face of a block, used when performing smooth lighting in order to calculate
|
||||
* the occlusion of each corner.
|
||||
*/
|
||||
enum AoNeighborInfo {
|
||||
EAST(new ModelQuadFacing[] { NEG_Y, POS_Y, NEG_Z, POS_Z }, 0.6F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = 1.0f - y;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[1] = lm0[0];
|
||||
lm1[2] = lm0[1];
|
||||
lm1[3] = lm0[2];
|
||||
lm1[0] = lm0[3];
|
||||
|
||||
ao1[1] = ao0[0];
|
||||
ao1[2] = ao0[1];
|
||||
ao1[3] = ao0[2];
|
||||
ao1[0] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return 1.0f - x;
|
||||
}
|
||||
},
|
||||
UP(new ModelQuadFacing[] { POS_X, NEG_X, NEG_Z, POS_Z }, 1.0F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = x;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[2] = lm0[0];
|
||||
lm1[3] = lm0[1];
|
||||
lm1[0] = lm0[2];
|
||||
lm1[1] = lm0[3];
|
||||
|
||||
ao1[2] = ao0[0];
|
||||
ao1[3] = ao0[1];
|
||||
ao1[0] = ao0[2];
|
||||
ao1[1] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return 1.0f - y;
|
||||
}
|
||||
},
|
||||
SOUTH(new ModelQuadFacing[] { NEG_X, POS_X, NEG_Y, POS_Y }, 0.8F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = y;
|
||||
final float v = 1.0f - x;
|
||||
|
||||
out[0] = u * v;
|
||||
out[1] = (1.0f - u) * v;
|
||||
out[2] = (1.0f - u) * (1.0f - v);
|
||||
out[3] = u * (1.0f - v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[0] = lm0[0];
|
||||
lm1[1] = lm0[1];
|
||||
lm1[2] = lm0[2];
|
||||
lm1[3] = lm0[3];
|
||||
|
||||
ao1[0] = ao0[0];
|
||||
ao1[1] = ao0[1];
|
||||
ao1[2] = ao0[2];
|
||||
ao1[3] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return 1.0f - z;
|
||||
}
|
||||
},
|
||||
WEST(new ModelQuadFacing[] { POS_Y, NEG_Y, NEG_Z, POS_Z }, 0.6F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = y;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[3] = lm0[0];
|
||||
lm1[0] = lm0[1];
|
||||
lm1[1] = lm0[2];
|
||||
lm1[2] = lm0[3];
|
||||
|
||||
ao1[3] = ao0[0];
|
||||
ao1[0] = ao0[1];
|
||||
ao1[1] = ao0[2];
|
||||
ao1[2] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return x;
|
||||
}
|
||||
},
|
||||
DOWN(new ModelQuadFacing[] { NEG_X, POS_X, NEG_Z, POS_Z }, 0.5F) {
|
||||
DOWN(new ForgeDirection[] { ForgeDirection.WEST, ForgeDirection.EAST, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 0.5F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
@@ -165,7 +37,37 @@ enum AoNeighborInfo {
|
||||
return y;
|
||||
}
|
||||
},
|
||||
NORTH(new ModelQuadFacing[] { POS_Y, NEG_Y, POS_X, NEG_X }, 0.8F) {
|
||||
UP(new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 1.0F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = x;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[2] = lm0[0];
|
||||
lm1[3] = lm0[1];
|
||||
lm1[0] = lm0[2];
|
||||
lm1[1] = lm0[3];
|
||||
|
||||
ao1[2] = ao0[0];
|
||||
ao1[3] = ao0[1];
|
||||
ao1[0] = ao0[2];
|
||||
ao1[1] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return 1.0f - y;
|
||||
}
|
||||
},
|
||||
NORTH(new ForgeDirection[] { ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.EAST, ForgeDirection.WEST }, 0.8F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = 1.0f - x;
|
||||
@@ -194,13 +96,103 @@ enum AoNeighborInfo {
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return z;
|
||||
}
|
||||
},
|
||||
SOUTH(new ForgeDirection[] { ForgeDirection.WEST, ForgeDirection.EAST, ForgeDirection.DOWN, ForgeDirection.UP }, 0.8F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = y;
|
||||
final float v = 1.0f - x;
|
||||
|
||||
out[0] = u * v;
|
||||
out[1] = (1.0f - u) * v;
|
||||
out[2] = (1.0f - u) * (1.0f - v);
|
||||
out[3] = u * (1.0f - v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[0] = lm0[0];
|
||||
lm1[1] = lm0[1];
|
||||
lm1[2] = lm0[2];
|
||||
lm1[3] = lm0[3];
|
||||
|
||||
ao1[0] = ao0[0];
|
||||
ao1[1] = ao0[1];
|
||||
ao1[2] = ao0[2];
|
||||
ao1[3] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return 1.0f - z;
|
||||
}
|
||||
},
|
||||
WEST(new ForgeDirection[] { ForgeDirection.UP, ForgeDirection.DOWN, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 0.6F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = y;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[3] = lm0[0];
|
||||
lm1[0] = lm0[1];
|
||||
lm1[1] = lm0[2];
|
||||
lm1[2] = lm0[3];
|
||||
|
||||
ao1[3] = ao0[0];
|
||||
ao1[0] = ao0[1];
|
||||
ao1[1] = ao0[2];
|
||||
ao1[2] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return x;
|
||||
}
|
||||
},
|
||||
EAST(new ForgeDirection[] { ForgeDirection.DOWN, ForgeDirection.UP, ForgeDirection.NORTH, ForgeDirection.SOUTH }, 0.6F) {
|
||||
@Override
|
||||
public void calculateCornerWeights(float x, float y, float z, float[] out) {
|
||||
final float u = z;
|
||||
final float v = 1.0f - y;
|
||||
|
||||
out[0] = v * u;
|
||||
out[1] = v * (1.0f - u);
|
||||
out[2] = (1.0f - v) * (1.0f - u);
|
||||
out[3] = (1.0f - v) * u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapCorners(int[] lm0, float[] ao0, int[] lm1, float[] ao1) {
|
||||
lm1[1] = lm0[0];
|
||||
lm1[2] = lm0[1];
|
||||
lm1[3] = lm0[2];
|
||||
lm1[0] = lm0[3];
|
||||
|
||||
ao1[1] = ao0[0];
|
||||
ao1[2] = ao0[1];
|
||||
ao1[3] = ao0[2];
|
||||
ao1[0] = ao0[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDepth(float x, float y, float z) {
|
||||
return 1.0f - x;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The direction of each corner block from this face, which can be retrieved by offsetting the position of the origin
|
||||
* block by the direction vector.
|
||||
*/
|
||||
public final ModelQuadFacing[] faces;
|
||||
public final ForgeDirection[] faces;
|
||||
|
||||
/**
|
||||
* The constant brightness modifier for this face. This data exists to emulate the results of the OpenGL lighting
|
||||
@@ -208,7 +200,7 @@ enum AoNeighborInfo {
|
||||
*/
|
||||
public final float strength;
|
||||
|
||||
AoNeighborInfo(ModelQuadFacing[] directions, float strength) {
|
||||
AoNeighborInfo(ForgeDirection[] directions, float strength) {
|
||||
this.faces = directions;
|
||||
this.strength = strength;
|
||||
}
|
||||
@@ -251,7 +243,7 @@ enum AoNeighborInfo {
|
||||
/**
|
||||
* @return Returns the {@link AoNeighborInfo} which corresponds with the specified direction
|
||||
*/
|
||||
public static AoNeighborInfo get(@NotNull ModelQuadFacing direction) {
|
||||
public static AoNeighborInfo get(ForgeDirection direction) {
|
||||
return VALUES[direction.ordinal()];
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -2,14 +2,14 @@ package me.jellysquid.mods.sodium.client.model.light.smooth;
|
||||
|
||||
import com.google.common.math.DoubleMath;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.LightDataAccess;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ModelQuadFacing cullFace, ModelQuadFacing face, boolean shade) {
|
||||
public void calculate(ModelQuadView quad, BlockPos pos, QuadLightData out, ForgeDirection cullFace, ForgeDirection face, boolean shade) {
|
||||
this.updateCachedData(pos.asLong());
|
||||
|
||||
final int flags = quad.getFlags();
|
||||
@@ -107,7 +107,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
* have two contributing sides.
|
||||
* Flags: IS_ALIGNED, !IS_PARTIAL
|
||||
*/
|
||||
private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
private void applyAlignedFullFace(AoNeighborInfo neighborInfo, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
final AoFaceData faceData = this.getCachedFaceData(pos, dir, true);
|
||||
neighborInfo.mapCorners(faceData.lm, faceData.ao, out.lm, out.br);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
* Calculates the light data for a grid-aligned quad that does not cover the entire block volume's face.
|
||||
* Flags: IS_ALIGNED, IS_PARTIAL
|
||||
*/
|
||||
private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
private void applyAlignedPartialFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -130,13 +130,13 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is the same as {@link #applyNonParallelFace(AoNeighborInfo, ModelQuadView, BlockPos, ModelQuadFacing,
|
||||
* This method is the same as {@link #applyNonParallelFace(AoNeighborInfo, ModelQuadView, BlockPos, ForgeDirection,
|
||||
* QuadLightData)} but with the check for a depth of approximately 0 removed. If the quad is parallel but not
|
||||
* aligned, all of its vertices will have the same depth and this depth must be approximately greater than 0,
|
||||
* meaning the check for 0 will always return false.
|
||||
* Flags: !IS_ALIGNED, IS_PARALLEL
|
||||
*/
|
||||
private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
private void applyParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -163,7 +163,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
/**
|
||||
* Flags: !IS_ALIGNED, !IS_PARALLEL
|
||||
*/
|
||||
private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ModelQuadFacing dir, QuadLightData out) {
|
||||
private void applyNonParallelFace(AoNeighborInfo neighborInfo, ModelQuadView quad, BlockPos pos, ForgeDirection dir, QuadLightData out) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// Clamp the vertex positions to the block's boundaries to prevent weird errors in lighting
|
||||
final float cx = clamp(quad.getX(i));
|
||||
@@ -188,7 +188,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
}
|
||||
}
|
||||
|
||||
private void applyAlignedPartialFaceVertex(BlockPos pos, ModelQuadFacing dir, float[] w, int i, QuadLightData out, boolean offset) {
|
||||
private void applyAlignedPartialFaceVertex(BlockPos pos, ForgeDirection dir, float[] w, int i, QuadLightData out, boolean offset) {
|
||||
final AoFaceData faceData = this.getCachedFaceData(pos, dir, offset);
|
||||
|
||||
if (!faceData.hasUnpackedLightData()) {
|
||||
@@ -203,7 +203,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
out.lm[i] = getLightMapCoord(sl, bl);
|
||||
}
|
||||
|
||||
private void applyInsetPartialFaceVertex(BlockPos pos, ModelQuadFacing dir, float n1d, float n2d, float[] w, int i, QuadLightData out) {
|
||||
private void applyInsetPartialFaceVertex(BlockPos pos, ForgeDirection dir, float n1d, float n2d, float[] w, int i, QuadLightData out) {
|
||||
final AoFaceData n1 = this.getCachedFaceData(pos, dir, false);
|
||||
|
||||
if (!n1.hasUnpackedLightData()) {
|
||||
@@ -225,7 +225,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
out.lm[i] = getLightMapCoord(sl, bl);
|
||||
}
|
||||
|
||||
private void applySidedBrightness(QuadLightData out, ModelQuadFacing face, boolean shade) {
|
||||
private void applySidedBrightness(QuadLightData out, ForgeDirection face, boolean shade) {
|
||||
if(AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading()) {
|
||||
return;
|
||||
}
|
||||
@@ -241,7 +241,7 @@ public class SmoothLightPipeline implements LightPipeline {
|
||||
/**
|
||||
* Returns the cached data for a given facing or calculates it if it hasn't been cached.
|
||||
*/
|
||||
private AoFaceData getCachedFaceData(BlockPos pos, ModelQuadFacing face, boolean offset) {
|
||||
private AoFaceData getCachedFaceData(BlockPos pos, ForgeDirection face, boolean offset) {
|
||||
|
||||
final AoFaceData data = this.cachedFaceData[offset ? face.ordinal() : face.ordinal() + 6];
|
||||
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class GlyphVertexWriterFallback extends VertexWriterFallback implements GlyphVertexSink {
|
||||
|
||||
+27
@@ -3,8 +3,35 @@ package me.jellysquid.mods.sodium.client.model.vertex.formats.line;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
public interface LineVertexSink extends VertexSink {
|
||||
VertexFormat VERTEX_FORMAT = DefaultVertexFormat.POSITION_COLOR;
|
||||
|
||||
/**
|
||||
* Writes a line vertex to the sink.
|
||||
*
|
||||
* @param x The x-position of the vertex
|
||||
* @param y The y-position of the vertex
|
||||
* @param z The z-position of the vertex
|
||||
* @param color The ABGR-packed color of the vertex
|
||||
*/
|
||||
void vertexLine(float x, float y, float z, int color);
|
||||
|
||||
/**
|
||||
* Writes a line vertex to the sink using unpacked normalized colors. This is slower than
|
||||
* {@link LineVertexSink#vertexLine(float, float, float, int)} as it needs to pack the colors
|
||||
* each call.
|
||||
*
|
||||
* @param x The x-position of the vertex
|
||||
* @param y The y-position of the vertex
|
||||
* @param z The z-position of the vertex
|
||||
* @param r The normalized red component of the vertex's color
|
||||
* @param g The normalized green component of the vertex's color
|
||||
* @param b The normalized blue component of the vertex's color
|
||||
* @param a The normalized alpha component of the vertex's color
|
||||
*/
|
||||
default void vertexLine(float x, float y, float z, float r, float g, float b, float a) {
|
||||
this.vertexLine(x, y, z, ColorABGR.pack(r, g, b, a));
|
||||
}
|
||||
}
|
||||
+14
@@ -5,9 +5,23 @@ import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.LineVertexSink;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class LineVertexBufferWriterNio extends VertexBufferWriterNio implements LineVertexSink {
|
||||
public LineVertexBufferWriterNio(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, VanillaVertexTypes.LINES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexLine(float x, float y, float z, int color) {
|
||||
int i = this.writeOffset;
|
||||
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
buffer.putFloat(i, x);
|
||||
buffer.putFloat(i + 4, y);
|
||||
buffer.putFloat(i + 8, z);
|
||||
buffer.putInt(i + 12, color);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
}
|
||||
+13
@@ -1,5 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
@@ -10,4 +12,15 @@ public class LineVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imple
|
||||
super(backingBuffer, VanillaVertexTypes.LINES);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexLine(float x, float y, float z, int color) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
}
|
||||
+8
@@ -3,6 +3,7 @@ package me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.line.LineVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class LineVertexWriterFallback extends VertexWriterFallback implements LineVertexSink {
|
||||
@@ -10,4 +11,11 @@ public class LineVertexWriterFallback extends VertexWriterFallback implements Li
|
||||
super(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void vertexLine(float x, float y, float z, int color) {
|
||||
VertexConsumer consumer = this.consumer;
|
||||
consumer.vertex(x, y, z);
|
||||
consumer.color(ColorABGR.unpackRed(color), ColorABGR.unpackGreen(color), ColorABGR.unpackBlue(color), ColorABGR.unpackAlpha(color));
|
||||
consumer.next();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.particle.ParticleVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class ParticleVertexWriterFallback extends VertexWriterFallback implements ParticleVertexSink {
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class QuadVertexWriterFallback extends VertexWriterFallback implements QuadVertexSink {
|
||||
@@ -20,7 +20,7 @@ public class QuadVertexWriterFallback extends VertexWriterFallback implements Qu
|
||||
consumer.texture(u, v);
|
||||
consumer.overlay(overlay);
|
||||
consumer.light(light);
|
||||
consumer.normal(NormI8.unpackX(normal), NormI8.unpackY(normal), NormI8.unpackZ(normal));
|
||||
consumer.normal(Norm3b.unpackX(normal), Norm3b.unpackY(normal), Norm3b.unpackZ(normal));
|
||||
consumer.next();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorABGR;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.fallback.VertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.BasicScreenQuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
|
||||
|
||||
public class BasicScreenQuadVertexWriterFallback extends VertexWriterFallback implements BasicScreenQuadVertexSink {
|
||||
|
||||
@@ -28,6 +28,7 @@ import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCache
|
||||
import me.jellysquid.mods.sodium.client.util.math.FrustumExtended;
|
||||
import me.jellysquid.mods.sodium.common.util.ListUtil;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.gl.shader.ProgramCreator;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.coderbot.iris.pipeline.ShadowRenderer;
|
||||
import net.coderbot.iris.shadows.ShadowRenderingState;
|
||||
@@ -51,6 +52,7 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import org.joml.Vector3d;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@@ -359,6 +361,9 @@ public class SodiumWorldRenderer {
|
||||
if(AngelicaConfig.enableIris) {
|
||||
final Block block = tileEntity.getWorldObj().getBlock(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
|
||||
CapturedRenderingState.INSTANCE.setCurrentBlockEntity(Block.getIdFromBlock(block));
|
||||
GL20.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
|
||||
GL20.glVertexAttrib2f(ProgramCreator.MC_MID_TEX_COORD, 0.5f, 0.5f);
|
||||
GL20.glVertexAttrib4f(ProgramCreator.AT_TANGENT, 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
GbufferPrograms.beginBlockEntities();
|
||||
}
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity, partialTicks);
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.HORIZONTAL_DIRECTIONS;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Z;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_X;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Z;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class ChunkRenderColumn<T extends ChunkGraphicsState> {
|
||||
@@ -53,7 +48,7 @@ public class ChunkRenderColumn<T extends ChunkGraphicsState> {
|
||||
}
|
||||
|
||||
public boolean areNeighborsPresent() {
|
||||
for (var dir : HORIZONTAL_DIRECTIONS) {
|
||||
for (ForgeDirection dir : DirectionUtil.HORIZONTAL_DIRECTIONS) {
|
||||
ChunkRenderColumn<T> adj = this.adjacent[dir.ordinal()];
|
||||
|
||||
if (adj == null) {
|
||||
@@ -63,13 +58,13 @@ public class ChunkRenderColumn<T extends ChunkGraphicsState> {
|
||||
ForgeDirection corner;
|
||||
|
||||
// Access the adjacent corner chunk from the neighbor in this direction
|
||||
if (dir == NEG_Z) {
|
||||
if (dir == ForgeDirection.NORTH) {
|
||||
corner = ForgeDirection.EAST;
|
||||
} else if (dir == POS_Z) {
|
||||
} else if (dir == ForgeDirection.SOUTH) {
|
||||
corner = ForgeDirection.WEST;
|
||||
} else if (dir == NEG_X) {
|
||||
} else if (dir == ForgeDirection.WEST) {
|
||||
corner = ForgeDirection.NORTH;
|
||||
} else if (dir == POS_X) {
|
||||
} else if (dir == ForgeDirection.EAST) {
|
||||
corner = ForgeDirection.SOUTH;
|
||||
} else {
|
||||
continue;
|
||||
|
||||
+10
-9
@@ -1,17 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Setter;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferArena;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferSegment;
|
||||
@@ -50,6 +42,15 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Util;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Shader-based chunk renderer which makes use of a custom memory allocator on top of large buffer objects to allow
|
||||
* for draw call batching without buffer switching.
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferSegment;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexFormat;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.oneshot;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexAttributeBinding;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.GlVertexFormat;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.oneshot;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.DrawCommandList;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
|
||||
|
||||
+4
-3
@@ -1,10 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
@@ -26,6 +24,9 @@ import net.coderbot.iris.sodium.block_context.ContextAwareVertexWriter;
|
||||
import net.minecraft.block.Block;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A collection of temporary buffers for each worker thread which will be used to build chunk meshes for given render
|
||||
* passes. This makes a best-effort attempt to pick a suitable size for each scratch buffer, but will never try to
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.compile.buffers;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
|
||||
|
||||
+7
-7
@@ -1,14 +1,14 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.cull;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
|
||||
public class ChunkFaceFlags {
|
||||
public static final int UP = of(ModelQuadFacing.POS_Y);
|
||||
public static final int DOWN = of(ModelQuadFacing.NEG_Y);
|
||||
public static final int WEST = of(ModelQuadFacing.NEG_X);
|
||||
public static final int EAST = of(ModelQuadFacing.POS_X);
|
||||
public static final int NORTH = of(ModelQuadFacing.NEG_Z);
|
||||
public static final int SOUTH = of(ModelQuadFacing.POS_Z);
|
||||
public static final int UP = of(ModelQuadFacing.UP);
|
||||
public static final int DOWN = of(ModelQuadFacing.DOWN);
|
||||
public static final int WEST = of(ModelQuadFacing.WEST);
|
||||
public static final int EAST = of(ModelQuadFacing.EAST);
|
||||
public static final int NORTH = of(ModelQuadFacing.NORTH);
|
||||
public static final int SOUTH = of(ModelQuadFacing.SOUTH);
|
||||
public static final int UNASSIGNED = of(ModelQuadFacing.UNASSIGNED);
|
||||
|
||||
public static final int ALL = all();
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChunkMeshData {
|
||||
public static final ChunkMeshData EMPTY = new ChunkMeshData();
|
||||
|
||||
|
||||
+8
-7
@@ -1,10 +1,17 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.data;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionData;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ISpriteExt;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumMap;
|
||||
@@ -12,12 +19,6 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* The render data for a chunk render container containing all the information about which meshes are attached, the
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.region;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import me.jellysquid.mods.sodium.client.gl.arena.GlBufferArena;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.CommandList;
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionDataBuilder;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
@@ -10,9 +11,6 @@ import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderContainer;
|
||||
@@ -23,7 +21,6 @@ import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkMeshData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderBounds;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.WorldUtil;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheLocal;
|
||||
import me.jellysquid.mods.sodium.client.util.MathUtil;
|
||||
import me.jellysquid.mods.sodium.client.util.task.CancellationSource;
|
||||
@@ -43,6 +40,10 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
* Rebuilds all the meshes of a chunk for each given render pass with non-occluded blocks. The result is then uploaded
|
||||
* to graphics memory on the main thread.
|
||||
@@ -185,7 +186,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
ChunkRenderManager.setWorldRenderPass(pass);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(fluid.getBlock(), ExtendedDataHelper.FLUID_RENDER_TYPE);
|
||||
|
||||
cache.getBlockRenderer().renderFluidLogged(cache.getWorldSlice(), fluid, renderBlocks, pos, buffers.get(pass), seed);
|
||||
cache.getBlockRenderer().renderFluidLogged(fluid, renderBlocks, pos, buffers.get(pass), seed);
|
||||
}
|
||||
}
|
||||
if (canRenderInPass(block, pass) && !shouldUseSodiumFluidRendering(block)) {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.gl.buffer.VertexData;
|
||||
import me.jellysquid.mods.sodium.client.gl.util.BufferSlice;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.ChunkGraphicsState;
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.occlusion;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ByteLinkedOpenHashMap;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockOcclusionCache {
|
||||
private static final byte UNCACHED_VALUE = (byte) 127;
|
||||
@@ -25,12 +25,12 @@ public class BlockOcclusionCache {
|
||||
* @param facing The facing direction of the side to check
|
||||
* @return True if the block side facing {@param dir} is not occluded, otherwise false
|
||||
*/
|
||||
public boolean shouldDrawSide(Block block, int meta, IBlockAccess view, BlockPos pos, ModelQuadFacing facing) {
|
||||
if (facing == ModelQuadFacing.UNASSIGNED)
|
||||
public boolean shouldDrawSide(Block block, int meta, IBlockAccess view, BlockPos pos, ForgeDirection facing) {
|
||||
if (facing == ForgeDirection.UNKNOWN)
|
||||
return true;
|
||||
|
||||
final BlockPos adjPos = this.cpos;
|
||||
adjPos.set(pos.getX() + facing.getStepX(), pos.getY() + facing.getStepY(), pos.getZ() + facing.getStepZ());
|
||||
adjPos.set(pos.getX() + facing.offsetX, pos.getY() + facing.offsetY, pos.getZ() + facing.offsetZ);
|
||||
|
||||
final Block adjState = view.getBlock(adjPos.x, adjPos.y, adjPos.z);
|
||||
|
||||
|
||||
+115
-40
@@ -3,23 +3,27 @@ package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorMixer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadOrientation;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.util.ModelQuadUtil;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadProvider;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.QuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadOrientation;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ModeledBlock;
|
||||
import com.gtnewhorizons.angelica.utils.ObjectPooler;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightMode;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.Quad;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuffers;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.render.occlusion.BlockOcclusionCache;
|
||||
import me.jellysquid.mods.sodium.client.util.ModelQuadUtil;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
import me.jellysquid.mods.sodium.client.util.rand.XoRoShiRoRandom;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -27,8 +31,12 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockRenderer {
|
||||
private static final BlockPos POS_ZERO = new BlockPos(0, 0, 0);
|
||||
|
||||
@@ -41,6 +49,10 @@ public class BlockRenderer {
|
||||
private boolean useSeparateAo;
|
||||
|
||||
private final LightPipelineProvider lighters;
|
||||
private final BlockOcclusionCache occlusionCache;
|
||||
|
||||
private final ObjectPooler<QuadView> quadPool = new ObjectPooler<>(Quad::new);
|
||||
// TODO: Use modern model API, and store them here
|
||||
|
||||
|
||||
public BlockRenderer(LightPipelineProvider lighters) {
|
||||
@@ -48,9 +60,10 @@ public class BlockRenderer {
|
||||
// TODO: Sodium - AO Setting
|
||||
this.useAmbientOcclusion = Minecraft.getMinecraft().gameSettings.ambientOcclusion > 0;
|
||||
this.useSodiumAO = SodiumClientMod.options().quality.useSodiumAO;
|
||||
this.occlusionCache = new BlockOcclusionCache();
|
||||
}
|
||||
|
||||
public boolean renderFluidLogged(IBlockAccess world, Fluid fluid, RenderBlocks renderBlocks, BlockPos pos, ChunkModelBuffers buffers, long seed) {
|
||||
public boolean renderFluidLogged(Fluid fluid, RenderBlocks renderBlocks, BlockPos pos, ChunkModelBuffers buffers, long seed) {
|
||||
if (fluid == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -60,7 +73,6 @@ public class BlockRenderer {
|
||||
}
|
||||
|
||||
boolean rendered = false;
|
||||
final int emitted = block.getLightValue(world, pos.x, pos.y, pos.z);
|
||||
|
||||
try {
|
||||
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
|
||||
@@ -74,12 +86,12 @@ public class BlockRenderer {
|
||||
tess.setOffset(POS_ZERO);
|
||||
tess.setTranslation(-pos.x, -pos.y, -pos.z);
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
final var quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
tess.resetOffset();
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, emitted, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
@@ -98,34 +110,60 @@ public class BlockRenderer {
|
||||
boolean rendered = false;
|
||||
|
||||
this.useSeparateAo = AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
|
||||
final int emitted = block.getLightValue(world, pos.x, pos.y, pos.z);
|
||||
|
||||
try {
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.startDrawingQuads();
|
||||
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
|
||||
// is done in subchunk-relative coordinates
|
||||
tess.setOffset(POS_ZERO);
|
||||
tess.setTranslation(-pos.x, -pos.y, -pos.z);
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
final var quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
tess.resetOffset();
|
||||
final QuadProvider model = ((ModeledBlock) block).getModel();
|
||||
|
||||
if (model != null) {
|
||||
|
||||
final int color = model.getColor(world, pos, block, meta, random);
|
||||
|
||||
for (ForgeDirection dir : DirectionUtil.ALL_DIRECTIONS) {
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, emitted, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
List<QuadView> quads;
|
||||
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
} finally {
|
||||
TessellatorManager.cleanup();
|
||||
if (!cull || this.occlusionCache.shouldDrawSide(block, meta, world, pos, dir)) {
|
||||
quads = model.getQuads(world, pos, block, meta, dir, random, color, this.quadPool::getInstance);
|
||||
if (quads.isEmpty()) continue;
|
||||
|
||||
this.renderQuadList(pos, lighter, buffers, quads, ModelQuadFacing.fromDirection(dir), true);
|
||||
rendered = true;
|
||||
|
||||
if (model.isDynamic())
|
||||
for (QuadView q : quads) this.quadPool.releaseInstance(q);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
try {
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.startDrawingQuads();
|
||||
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
|
||||
// is done in subchunk-relative coordinates
|
||||
tess.setOffset(POS_ZERO);
|
||||
tess.setTranslation(-pos.x, -pos.y, -pos.z);
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
tess.resetOffset();
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
} finally {
|
||||
TessellatorManager.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private void renderQuadList(BlockPos pos, LightPipeline lighter, int emitted, ChunkModelBuffers buffers, List<ModelQuadViewMutable> quads, ModelQuadFacing facing, boolean useSodiumLight) {
|
||||
private void renderQuadList(BlockPos pos, LightPipeline lighter, ChunkModelBuffers buffers, List<QuadView> quads, ModelQuadFacing facing, boolean useSodiumLight) {
|
||||
final ForgeDirection cullFace = ModelQuadFacing.toDirection(facing);
|
||||
|
||||
final ModelVertexSink sink = buffers.getSink(facing);
|
||||
sink.ensureCapacity(quads.size() * 4);
|
||||
|
||||
@@ -134,25 +172,25 @@ public class BlockRenderer {
|
||||
// This is a very hot allocation, iterate over it manually
|
||||
// noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0, quadsSize = quads.size(); i < quadsSize; i++) {
|
||||
final var quad = quads.get(i);
|
||||
final QuadView quad = quads.get(i);
|
||||
|
||||
final QuadLightData light = this.cachedQuadLightData;
|
||||
|
||||
if (quad.getNormalFace() != facing)
|
||||
if (quad.getFace() != cullFace)
|
||||
continue;
|
||||
|
||||
if (useSodiumLight || this.useSeparateAo)
|
||||
lighter.calculate(quad, pos, light, facing, quad.getLightFace(), quad.hasAmbientOcclusion());
|
||||
lighter.calculate(quad, pos, light, cullFace, quad.getLightFace(), quad.isShade());
|
||||
|
||||
this.renderQuad(sink, quad, emitted, light, renderData, useSodiumLight);
|
||||
this.renderQuad(sink, quad, light, renderData, useSodiumLight);
|
||||
}
|
||||
|
||||
sink.flush();
|
||||
}
|
||||
|
||||
private void renderQuad(ModelVertexSink sink, ModelQuadView quad, int emitted, QuadLightData light, ChunkRenderData.Builder renderData, boolean useSodiumLight) {
|
||||
private void renderQuad(ModelVertexSink sink, QuadView quad, QuadLightData light, ChunkRenderData.Builder renderData, boolean useSodiumLight) {
|
||||
|
||||
final ModelQuadOrientation order = (useSodiumLight || this.useSeparateAo) ? ModelQuadOrientation.orientByBrightness(light.br, light.lm) : ModelQuadOrientation.NORMAL;
|
||||
final ModelQuadOrientation order = (useSodiumLight || this.useSeparateAo) ? ModelQuadOrientation.orient(light.br) : ModelQuadOrientation.NORMAL;
|
||||
|
||||
int shaderBlockId = quad.getShaderBlockId();
|
||||
for (int dstIndex = 0; dstIndex < 4; dstIndex++) {
|
||||
@@ -169,23 +207,60 @@ public class BlockRenderer {
|
||||
color |= ((int) (ao * 255.0f)) << 24;
|
||||
} else {
|
||||
|
||||
color = (useSodiumLight) ? ColorMixer.mulSingleWithoutAlpha(quad.getColor(srcIndex), (int)(light.br[srcIndex] * 255)) : quad.getColor(srcIndex);
|
||||
color = (useSodiumLight) ? ColorABGR.mul(quad.getColor(srcIndex), light.br[srcIndex]) : quad.getColor(srcIndex);
|
||||
}
|
||||
|
||||
final float u = quad.getTexU(srcIndex);
|
||||
final float v = quad.getTexV(srcIndex);
|
||||
|
||||
final int lm = (useSeparateAo) ? ModelQuadUtil.mergeBakedLight(quad.getLight(srcIndex), emitted, light.lm[srcIndex]) :
|
||||
final int lm = (useSeparateAo) ? ModelQuadUtil.mergeBakedLight(quad.getLight(srcIndex), light.lm[srcIndex]) :
|
||||
(useSodiumLight) ? light.lm[srcIndex] : quad.getLight(srcIndex);
|
||||
|
||||
sink.writeQuad(x, y, z, color, u, v, lm, shaderBlockId);
|
||||
}
|
||||
|
||||
final TextureAtlasSprite sprite = (TextureAtlasSprite) quad.celeritas$getSprite();
|
||||
final TextureAtlasSprite sprite = quad.rubidium$getSprite();
|
||||
|
||||
if (sprite != null) {
|
||||
renderData.addSprite(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Flags {
|
||||
boolean hasTexture;
|
||||
public boolean hasBrightness;
|
||||
public boolean hasColor;
|
||||
public boolean hasNormals;
|
||||
|
||||
public Flags(byte flags) {
|
||||
hasTexture = (flags & 1) != 0;
|
||||
hasBrightness = (flags & 2) != 0;
|
||||
hasColor = (flags & 4) != 0;
|
||||
hasNormals = (flags & 8) != 0;
|
||||
}
|
||||
|
||||
public Flags(boolean hasTexture, boolean hasBrightness, boolean hasColor, boolean hasNormals) {
|
||||
this.hasTexture = hasTexture;
|
||||
this.hasBrightness = hasBrightness;
|
||||
this.hasColor = hasColor;
|
||||
this.hasNormals = hasNormals;
|
||||
}
|
||||
|
||||
public byte toByte() {
|
||||
byte flags = 0;
|
||||
if(hasTexture) {
|
||||
flags |= 1;
|
||||
}
|
||||
if(hasBrightness) {
|
||||
flags |= 2;
|
||||
}
|
||||
if(hasColor) {
|
||||
flags |= 4;
|
||||
}
|
||||
if(hasNormals) {
|
||||
flags |= 8;
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,23 @@
|
||||
package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.HORIZONTAL_DIRECTIONS;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.NEG_Y;
|
||||
import static com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing.POS_Y;
|
||||
import static org.joml.Math.lerp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorARGB;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.ColorMixer;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuad;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuad;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadView;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.ModelQuadViewMutable;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFacing;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.quad.properties.ModelQuadFlags;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.DirectionUtil;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import java.util.Arrays;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightMode;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipeline;
|
||||
import me.jellysquid.mods.sodium.client.model.light.LightPipelineProvider;
|
||||
import me.jellysquid.mods.sodium.client.model.light.data.QuadLightData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuffers;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.ModelVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
|
||||
import me.jellysquid.mods.sodium.client.util.color.ColorARGB;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -33,6 +29,10 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.joml.Math.lerp;
|
||||
|
||||
public class FluidRenderer {
|
||||
private static final float EPSILON = 0.001f;
|
||||
private final LightPipelineProvider lpp;
|
||||
@@ -48,10 +48,10 @@ public class FluidRenderer {
|
||||
private final TextureAtlasSprite missingTex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:missing");
|
||||
|
||||
public FluidRenderer(LightPipelineProvider lpp) {
|
||||
int normal = NormI8.pack(0.0f, 1.0f, 0.0f);
|
||||
int normal = Norm3b.pack(0.0f, 1.0f, 0.0f);
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
this.quad.setForgeNormal(i, normal);
|
||||
this.quad.setNormal(i, normal);
|
||||
}
|
||||
|
||||
this.lpp = lpp;
|
||||
@@ -69,8 +69,8 @@ public class FluidRenderer {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
private boolean isSideExposed(IBlockAccess world, int x, int y, int z, ModelQuadFacing dir, float height) {
|
||||
BlockPos pos = this.scratchPos.set(x + dir.getStepX(), y + dir.getStepY(), z + dir.getStepZ());
|
||||
private boolean isSideExposed(IBlockAccess world, int x, int y, int z, ForgeDirection dir, float height) {
|
||||
BlockPos pos = this.scratchPos.set(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
Block block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
|
||||
if (block.getMaterial().isOpaque()) {
|
||||
@@ -79,7 +79,7 @@ public class FluidRenderer {
|
||||
// Hoist these checks to avoid allocating the shape below
|
||||
if (renderAsFullCube) {
|
||||
// The top face always be inset, so if the shape above is a full cube it can't possibly occlude
|
||||
return dir == POS_Y;
|
||||
return dir == ForgeDirection.UP;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class FluidRenderer {
|
||||
// Check for occluded sides; if everything is occluded, don't render
|
||||
boolean sfUp = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.UP, fluid);
|
||||
boolean sfDown = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.DOWN, fluid) ||
|
||||
!this.isSideExposed(world, posX, posY, posZ, NEG_Y, 0.8888889F);
|
||||
!this.isSideExposed(world, posX, posY, posZ, ForgeDirection.DOWN, 0.8888889F);
|
||||
boolean sfNorth = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.NORTH, fluid);
|
||||
boolean sfSouth = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.SOUTH, fluid);
|
||||
boolean sfWest = this.isFluidOccluded(world, posX, posY, posZ, ForgeDirection.WEST, fluid);
|
||||
@@ -142,7 +142,7 @@ public class FluidRenderer {
|
||||
|
||||
quad.setFlags(0);
|
||||
|
||||
if (!sfUp && this.isSideExposed(world, posX, posY, posZ, POS_Y, Math.min(Math.min(h1, h2), Math.min(h3, h4)))) {
|
||||
if (!sfUp && this.isSideExposed(world, posX, posY, posZ, ForgeDirection.UP, Math.min(Math.min(h1, h2), Math.min(h3, h4)))) {
|
||||
h1 -= 0.001F;
|
||||
h2 -= 0.001F;
|
||||
h3 -= 0.001F;
|
||||
@@ -157,7 +157,7 @@ public class FluidRenderer {
|
||||
|
||||
if (velocity.x == 0.0D && velocity.z == 0.0D) {
|
||||
sprite = sprites[0];
|
||||
facing = ModelQuadFacing.POS_Y;
|
||||
facing = ModelQuadFacing.UP;
|
||||
u1 = sprite.getInterpolatedU(0.0D);
|
||||
v1 = sprite.getInterpolatedV(0.0D);
|
||||
u2 = u1;
|
||||
@@ -204,7 +204,7 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, 1.0F, h3, 1.0F, u3, v3);
|
||||
this.setVertex(quad, 3, 1.0F, h4, 0.0f, u4, v4);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, POS_Y, 1.0F, hc, slice);
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.UP, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, facing, false);
|
||||
|
||||
if (WorldUtil.method_15756(slice, this.scratchPos.set(posX, posY + 1, posZ), fluid)) {
|
||||
@@ -213,7 +213,7 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 1, 1.0F, h3, 1.0F, u3, v3);
|
||||
this.setVertex(quad, 0, 1.0F, h4, 0.0f, u4, v4);
|
||||
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.NEG_Y, true);
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.DOWN, true);
|
||||
}
|
||||
|
||||
rendered = true;
|
||||
@@ -233,15 +233,15 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, 1.0F, yOffset, 0.0f, maxU, minV);
|
||||
this.setVertex(quad, 3, 1.0F, yOffset, 1.0F, maxU, maxV);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, NEG_Y, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.NEG_Y, false);
|
||||
this.calculateQuadColors(quad, pos, lighter, ForgeDirection.DOWN, 1.0F, hc, slice);
|
||||
this.flushQuad(buffers, quad, ModelQuadFacing.DOWN, false);
|
||||
|
||||
rendered = true;
|
||||
}
|
||||
|
||||
quad.setFlags(ModelQuadFlags.IS_ALIGNED);
|
||||
|
||||
for (var facing : HORIZONTAL_DIRECTIONS) {
|
||||
for (ForgeDirection dir : DirectionUtil.HORIZONTAL_DIRECTIONS) {
|
||||
float c1;
|
||||
float c2;
|
||||
float x1;
|
||||
@@ -249,8 +249,8 @@ public class FluidRenderer {
|
||||
float x2;
|
||||
float z2;
|
||||
|
||||
switch (facing) {
|
||||
case NEG_Z:
|
||||
switch (dir) {
|
||||
case NORTH:
|
||||
if (sfNorth) {
|
||||
continue;
|
||||
}
|
||||
@@ -262,7 +262,7 @@ public class FluidRenderer {
|
||||
z1 = 0.001f;
|
||||
z2 = z1;
|
||||
break;
|
||||
case POS_Z:
|
||||
case SOUTH:
|
||||
if (sfSouth) {
|
||||
continue;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ public class FluidRenderer {
|
||||
z1 = 0.999f;
|
||||
z2 = z1;
|
||||
break;
|
||||
case NEG_X:
|
||||
case WEST:
|
||||
if (sfWest) {
|
||||
continue;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class FluidRenderer {
|
||||
z1 = 1.0F;
|
||||
z2 = 0.0f;
|
||||
break;
|
||||
case POS_X:
|
||||
case EAST:
|
||||
if (sfEast) {
|
||||
continue;
|
||||
}
|
||||
@@ -302,10 +302,10 @@ public class FluidRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.isSideExposed(world, posX, posY, posZ, facing, Math.max(c1, c2))) {
|
||||
int adjX = posX + facing.getStepX();
|
||||
int adjY = posY + facing.getStepY();
|
||||
int adjZ = posZ + facing.getStepZ();
|
||||
if (this.isSideExposed(world, posX, posY, posZ, dir, Math.max(c1, c2))) {
|
||||
int adjX = posX + dir.offsetX;
|
||||
int adjY = posY + dir.offsetY;
|
||||
int adjZ = posZ + dir.offsetZ;
|
||||
|
||||
TextureAtlasSprite sprite = sprites[1];
|
||||
TextureAtlasSprite oSprite = sprites[2];
|
||||
@@ -333,9 +333,11 @@ public class FluidRenderer {
|
||||
this.setVertex(quad, 2, x1, yOffset, z1, u1, v3);
|
||||
this.setVertex(quad, 3, x1, c1, z1, u1, v1);
|
||||
|
||||
float br = facing.getStepZ() != 0 ? 0.8F : 0.6F;
|
||||
float br = dir.offsetZ != 0 ? 0.8F : 0.6F;
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, facing, br, hc, slice);
|
||||
ModelQuadFacing facing = ModelQuadFacing.fromDirection(dir);
|
||||
|
||||
this.calculateQuadColors(quad, pos, lighter, dir, br, hc, slice);
|
||||
this.flushQuad(buffers, quad, facing, false);
|
||||
|
||||
if (sprite != oSprite) {
|
||||
@@ -354,7 +356,7 @@ public class FluidRenderer {
|
||||
return rendered;
|
||||
}
|
||||
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPos pos, LightPipeline lighter, ModelQuadFacing dir, float brightness, boolean colorized, WorldSlice slice) {
|
||||
private void calculateQuadColors(ModelQuadView quad, BlockPos pos, LightPipeline lighter, ForgeDirection dir, float brightness, boolean colorized, WorldSlice slice) {
|
||||
QuadLightData light = this.quadLightData;
|
||||
lighter.calculate(quad, pos, light, null, dir, false);
|
||||
|
||||
@@ -370,7 +372,7 @@ public class FluidRenderer {
|
||||
color &= 0x00FFFFFF;
|
||||
color |= ((int) (ao * 255.0f)) << 24;
|
||||
} else {
|
||||
color = ColorMixer.mulSingleWithoutAlpha(color, (int)(ao * 255));
|
||||
color = ColorABGR.mul(color, ao);
|
||||
}
|
||||
this.quadColors[i] = color;
|
||||
}
|
||||
@@ -408,7 +410,7 @@ public class FluidRenderer {
|
||||
vertexIdx += lightOrder;
|
||||
}
|
||||
|
||||
TextureAtlasSprite sprite = (TextureAtlasSprite) quad.celeritas$getSprite();
|
||||
TextureAtlasSprite sprite = quad.rubidium$getSprite();
|
||||
|
||||
if (sprite != null) {
|
||||
buffers.getRenderData().addSprite(sprite);
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client.render.pipeline;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLiquid;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
/**
|
||||
* Contains methods stripped from BlockState or FluidState that didn't actually need to be there. Technically these
|
||||
* could be a mixin to Block or Fluid, but that's annoying while not actually providing any benefit.
|
||||
*/
|
||||
public class WorldUtil {
|
||||
|
||||
public static Vector3d getVelocity(IBlockAccess world, int x, int y, int z, Block thizz) {
|
||||
|
||||
Vector3d velocity = new Vector3d();
|
||||
int decay = getEffectiveFlowDecay(world, x, y, z, thizz);
|
||||
|
||||
for (var dire : ModelQuadFacing.HORIZONTAL_DIRECTIONS) {
|
||||
|
||||
int adjX = x + dire.getStepX();
|
||||
int adjZ = z + dire.getStepZ();
|
||||
|
||||
int adjDecay = getEffectiveFlowDecay(world, adjX, y, adjZ, thizz);
|
||||
|
||||
if (adjDecay < 0) {
|
||||
|
||||
if (!world.getBlock(adjX, y, adjZ).getMaterial().blocksMovement()) {
|
||||
|
||||
adjDecay = getEffectiveFlowDecay(world, adjX, y - 1, adjZ, thizz);
|
||||
|
||||
if (adjDecay >= 0) {
|
||||
|
||||
adjDecay -= (decay - 8);
|
||||
velocity = velocity.add((adjX - x) * adjDecay, 0, (adjZ - z) * adjDecay);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
adjDecay -= decay;
|
||||
velocity = velocity.add((adjX - x) * adjDecay, 0, (adjZ - z) * adjDecay);
|
||||
}
|
||||
}
|
||||
|
||||
if (world.getBlockMetadata(x, y, z) >= 8) {
|
||||
|
||||
if (thizz.isBlockSolid(world, x, y, z - 1, 2) || thizz.isBlockSolid(world, x, y, z + 1, 3)
|
||||
|| thizz.isBlockSolid(world, x - 1, y, z, 4)
|
||||
|| thizz.isBlockSolid(world, x + 1, y, z, 5)
|
||||
|| thizz.isBlockSolid(world, x, y + 1, z - 1, 2)
|
||||
|| thizz.isBlockSolid(world, x, y + 1, z + 1, 3)
|
||||
|| thizz.isBlockSolid(world, x - 1, y + 1, z, 4)
|
||||
|| thizz.isBlockSolid(world, x + 1, y + 1, z, 5)) {
|
||||
velocity = velocity.normalize().add(0.0D, -6.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
if (velocity.x == 0 && velocity.y == 0 && velocity.z == 0) return velocity.zero();
|
||||
return velocity.normalize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if any block in a 3x3x3 cube is not the same fluid and not an opaque full cube. Equivalent to
|
||||
* FluidState::method_15756 in modern.
|
||||
*/
|
||||
public static boolean method_15756(IBlockAccess world, BlockPos pos, Fluid fluid) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
Block block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
if (!block.isOpaqueCube() && getFluid(block) != fluid) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns fluid height as a percentage of the block; 0 is none and 1 is full.
|
||||
*/
|
||||
public static float getFluidHeight(Fluid fluid, int meta) {
|
||||
return fluid == null ? 0 : 1 - BlockLiquid.getLiquidHeightPercent(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the flow decay but converts values indicating falling liquid (values >=8) to their effective source block
|
||||
* value of zero
|
||||
*/
|
||||
public static int getEffectiveFlowDecay(IBlockAccess world, int x, int y, int z, Block thiz) {
|
||||
|
||||
if (world.getBlock(x, y, z).getMaterial() != thiz.getMaterial()) {
|
||||
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
int decay = world.getBlockMetadata(x, y, z);
|
||||
return decay >= 8 ? 0 : decay;
|
||||
}
|
||||
}
|
||||
|
||||
// I believe forge mappings in modern say BreakableBlock, while yarn says TransparentBlock.
|
||||
// I have a sneaking suspicion isOpaque is neither, but it works for now
|
||||
public static boolean shouldDisplayFluidOverlay(Block block) {
|
||||
return !block.getMaterial().isOpaque() || block.getMaterial() == Material.leaves;
|
||||
}
|
||||
|
||||
public static boolean isFluidBlock(Block block) {
|
||||
return block instanceof IFluidBlock || block instanceof BlockLiquid;
|
||||
}
|
||||
|
||||
public static Fluid getFluid(Block b) {
|
||||
if (b instanceof IFluidBlock fluidBlock) return fluidBlock.getFluid();
|
||||
if (b instanceof BlockLiquid) {
|
||||
if (b.getMaterial() == Material.water) return FluidRegistry.WATER;
|
||||
if (b.getMaterial() == Material.lava) return FluidRegistry.LAVA;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to method_15748 in 1.16.5
|
||||
*/
|
||||
public static boolean isEmptyOrSame(Fluid fluid, Fluid otherFluid) {
|
||||
return otherFluid == null || fluid == otherFluid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to method_15749 in 1.16.5
|
||||
*/
|
||||
public static boolean method_15749(IBlockAccess world, Fluid thiz, BlockPos pos, ForgeDirection dir) {
|
||||
Block b = world.getBlock(pos.x, pos.y, pos.z);
|
||||
Fluid f = getFluid(b);
|
||||
if (f == thiz) {
|
||||
return false;
|
||||
}
|
||||
if (dir == ForgeDirection.UP) {
|
||||
return true;
|
||||
}
|
||||
return b.getMaterial() != Material.ice && b.isSideSolid(world, pos.x, pos.y, pos.z, dir);
|
||||
}
|
||||
}
|
||||
@@ -24,4 +24,7 @@ public class MathUtil {
|
||||
return (a + b + 1) * (a + b) / 2 + b;
|
||||
}
|
||||
|
||||
public static boolean fuzzy_eq(float a, float b) {
|
||||
return Math.abs(a - b) < 1e-5;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package me.jellysquid.mods.sodium.client.util;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Provides some utilities and constants for interacting with vanilla's model quad vertex format.
|
||||
*
|
||||
* This is the current vertex format used by Minecraft for chunk meshes and model quads. Internally, it uses integer
|
||||
* arrays for store baked quad data, and as such the following table provides both the byte and int indices.
|
||||
*
|
||||
* Byte Index Integer Index Name Format Fields
|
||||
* 0 ..11 0..2 Position 3 floats x, y, z
|
||||
* 12..15 3 Color 4 unsigned bytes a, r, g, b
|
||||
* 16..23 4..5 Block Texture 2 floats u, v
|
||||
* 24..27 6 Light Texture 2 shorts u, v
|
||||
* 28..30 7 Normal 3 unsigned bytes x, y, z
|
||||
* 31 Padding 1 byte
|
||||
*/
|
||||
public class ModelQuadUtil {
|
||||
// Integer indices for vertex attributes, useful for accessing baked quad data
|
||||
public static final int POSITION_INDEX = 0,
|
||||
COLOR_INDEX = 3,
|
||||
TEXTURE_INDEX = 4,
|
||||
LIGHT_INDEX = 6,
|
||||
NORMAL_INDEX = 7;
|
||||
|
||||
// Size of vertex format in 4-byte integers
|
||||
public static final int VERTEX_SIZE = 8;
|
||||
public static final int VERTEX_SIZE_BYTES = VERTEX_SIZE * 4;
|
||||
|
||||
// Cached array of normals for every facing to avoid expensive computation
|
||||
static final int[] NORMALS = new int[ForgeDirection.VALID_DIRECTIONS.length];
|
||||
|
||||
static {
|
||||
for (int i = 0; i < NORMALS.length; i++) {
|
||||
final ForgeDirection dir = ForgeDirection.VALID_DIRECTIONS[i];
|
||||
NORMALS[i] = Norm3b.pack(dir.offsetX, dir.offsetY, dir.offsetZ);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normal vector for a model quad with the given {@param facing}.
|
||||
*/
|
||||
public static int getFacingNormal(ForgeDirection facing) {
|
||||
return NORMALS[facing.ordinal()];
|
||||
}
|
||||
|
||||
public static int getFacingNormal(ForgeDirection facing, int bakedNormal) {
|
||||
if(!hasNormal(bakedNormal))
|
||||
return NORMALS[facing.ordinal()];
|
||||
return bakedNormal;
|
||||
}
|
||||
|
||||
public static boolean hasNormal(int n) {
|
||||
return (n & 0xFFFFFF) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param vertexIndex The index of the vertex to access
|
||||
* @return The starting offset of the vertex's attributes
|
||||
*/
|
||||
public static int vertexOffset(int vertexIndex) {
|
||||
return vertexIndex * VERTEX_SIZE;
|
||||
}
|
||||
|
||||
public static int mergeBakedLight(int packedLight, int calcLight) {
|
||||
// bail early in most cases
|
||||
if (packedLight == 0)
|
||||
return calcLight;
|
||||
|
||||
final int psl = (packedLight >> 16) & 0xFF;
|
||||
final int csl = (calcLight >> 16) & 0xFF;
|
||||
final int pbl = (packedLight) & 0xFF;
|
||||
final int cbl = (calcLight) & 0xFF;
|
||||
final int bl = Math.max(pbl, cbl);
|
||||
final int sl = Math.max(psl, csl);
|
||||
return (sl << 16) | bl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package me.jellysquid.mods.sodium.client.util;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
/**
|
||||
* Provides some utilities for working with packed normal vectors. Each getNormal component provides 8 bits of
|
||||
* precision in the range of [-1.0,1.0].
|
||||
*
|
||||
* | 32 | 24 | 16 | 8 |
|
||||
* | 0000 0000 | 0110 1100 | 0110 1100 | 0110 1100 |
|
||||
* | Padding | X | Y | Z |
|
||||
*/
|
||||
public class Norm3b {
|
||||
/**
|
||||
* The maximum value of a getNormal's vector component.
|
||||
*/
|
||||
private static final float COMPONENT_RANGE = 127.0f;
|
||||
|
||||
/**
|
||||
* Constant value which can be multiplied with a floating-point vector component to get the normalized value. The
|
||||
* multiplication is slightly faster than a floating point division, and this code is a hot path which justifies it.
|
||||
*/
|
||||
private static final float NORM = 1.0f / COMPONENT_RANGE;
|
||||
|
||||
static int pack(Vector3i norm) {
|
||||
return pack(norm.x, norm.y, norm.z);
|
||||
}
|
||||
|
||||
public static int pack(Vector3f dir) {
|
||||
return pack(dir.x, dir.y, dir.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Packs the specified vector components into a 32-bit integer in XYZ ordering with the 8 bits of padding at the
|
||||
* end.
|
||||
* @param x The x component of the getNormal's vector
|
||||
* @param y The y component of the getNormal's vector
|
||||
* @param z The z component of the getNormal's vector
|
||||
*/
|
||||
public static int pack(float x, float y, float z) {
|
||||
int normX = encode(x);
|
||||
int normY = encode(y);
|
||||
int normZ = encode(z);
|
||||
|
||||
return (normZ << 16) | (normY << 8) | normX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a float in the range of -1.0..1.0 to a normalized unsigned integer in the range of 0..255 which can then
|
||||
* be passed to graphics memory.
|
||||
*/
|
||||
private static int encode(float comp) {
|
||||
// TODO: is the clamp necessary here? our inputs should always be normalized vector components
|
||||
return ((int) (MathHelper.clamp_float(comp, -1.0F, 1.0F) * COMPONENT_RANGE) & 255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the x-component of the packed getNormal, denormalizing it to a float in the range of -1.0..1.0.
|
||||
* @param norm The packed getNormal
|
||||
*/
|
||||
public static float unpackX(int norm) {
|
||||
return ((byte) (norm & 0xFF)) * NORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the y-component of the packed getNormal, denormalizing it to a float in the range of -1.0..1.0.
|
||||
* @param norm The packed getNormal
|
||||
*/
|
||||
public static float unpackY(int norm) {
|
||||
return ((byte) ((norm >> 8) & 0xFF)) * NORM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the z-component of the packed getNormal, denormalizing it to a float in the range of -1.0..1.0.
|
||||
* @param norm The packed getNormal
|
||||
*/
|
||||
public static float unpackZ(int norm) {
|
||||
return ((byte) ((norm >> 16) & 0xFF)) * NORM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
/**
|
||||
* Provides some utilities for packing and unpacking color components from packed integer colors in ABGR format, which
|
||||
* is used by OpenGL for color vectors.
|
||||
*
|
||||
* | 32 | 24 | 16 | 8 |
|
||||
* | 0110 1100 | 0110 1100 | 0110 1100 | 0110 1100 |
|
||||
* | Alpha | Blue | Green | Red |
|
||||
*/
|
||||
public class ColorABGR implements ColorU8 {
|
||||
/**
|
||||
* Packs the specified color components into ABGR format.
|
||||
* @param r The red component of the color
|
||||
* @param g The green component of the color
|
||||
* @param b The blue component of the color
|
||||
* @param a The alpha component of the color
|
||||
*/
|
||||
public static int pack(int r, int g, int b, int a) {
|
||||
return (a & 0xFF) << 24 | (b & 0xFF) << 16 | (g & 0xFF) << 8 | (r & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ColorABGR#pack(int, int, int, int)
|
||||
*/
|
||||
public static int pack(float r, float g, float b, float a) {
|
||||
return pack((int) (r * COMPONENT_RANGE), (int) (g * COMPONENT_RANGE), (int) (b * COMPONENT_RANGE), (int) (a * COMPONENT_RANGE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiplies the RGB components of the packed ABGR color using the given scale factors.
|
||||
* @param color The ABGR packed color to be multiplied
|
||||
* @param rw The red component scale factor
|
||||
* @param gw The green component scale factor
|
||||
* @param bw The blue component scale factor
|
||||
*/
|
||||
public static int mul(int color, float rw, float gw, float bw) {
|
||||
float r = unpackRed(color) * rw;
|
||||
float g = unpackGreen(color) * gw;
|
||||
float b = unpackBlue(color) * bw;
|
||||
|
||||
return pack((int) r, (int) g, (int) b, 0xFF);
|
||||
}
|
||||
|
||||
public static int mul(int color, float w) {
|
||||
return mul(color, w, w, w);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackRed(int color) {
|
||||
return color & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The green color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackGreen(int color) {
|
||||
return color >> 8 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The blue color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackBlue(int color) {
|
||||
return color >> 16 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ABGR color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackAlpha(int color) {
|
||||
return color >> 24 & 0xFF;
|
||||
}
|
||||
|
||||
public static int pack(float r, float g, float b) {
|
||||
return pack(r, g, b, 255);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
/**
|
||||
* Provides some utilities for packing and unpacking color components from packed integer colors in ARGB format. This
|
||||
* packed format is used by most of Minecraft, but special care must be taken to pack it into ABGR format before passing
|
||||
* it to OpenGL attributes.
|
||||
*
|
||||
* | 32 | 24 | 16 | 8 |
|
||||
* | 0110 1100 | 0110 1100 | 0110 1100 | 0110 1100 |
|
||||
* | Alpha | Red | Green | Blue |
|
||||
*/
|
||||
public class ColorARGB implements ColorU8 {
|
||||
/**
|
||||
* Packs the specified color components into big-endian format for consumption by OpenGL.
|
||||
* @param r The red component of the color
|
||||
* @param g The green component of the color
|
||||
* @param b The blue component of the color
|
||||
* @param a The alpha component of the color
|
||||
*/
|
||||
public static int pack(int r, int g, int b, int a) {
|
||||
return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackAlpha(int color) {
|
||||
return color >> 24 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The red color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackRed(int color) {
|
||||
return color >> 16 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The green color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackGreen(int color) {
|
||||
return color >> 8 & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param color The packed 32-bit ARGB color to unpack
|
||||
* @return The blue color component in the range of 0..255
|
||||
*/
|
||||
public static int unpackBlue(int color) {
|
||||
return color & 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-packs the ARGB color into a aBGR color with the specified alpha component.
|
||||
*/
|
||||
public static int toABGR(int color, int alpha) {
|
||||
return Integer.reverseBytes(color << 8 | alpha);
|
||||
}
|
||||
|
||||
public static int toABGR(int color) {
|
||||
return Integer.reverseBytes(color << 8);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
public class ColorMixer {
|
||||
private static final long MASK1 = 0x00FF00FF;
|
||||
private static final long MASK2 = 0xFF00FF00;
|
||||
|
||||
/**
|
||||
* Mixes two ARGB colors using the given ratios. Use {@link ColorMixer#getStartRatio(float)} and
|
||||
* {@link ColorMixer#getEndRatio(float)} to convert a floating-point ratio into a integer ratio.
|
||||
*
|
||||
* This method takes 64-bit inputs to avoid overflows when mixing the alpha channel. The helper method
|
||||
* {@link ColorMixer#mixARGB(int, int, int, int)} can be used with 32-bit inputs.
|
||||
*
|
||||
* @param c1 The first (starting) color to blend with in ARGB format
|
||||
* @param c2 The second (ending) color to blend with in ARGB format
|
||||
* @param f1 The ratio of the color {@param c1} as calculated by {@link ColorMixer#getStartRatio(float)}
|
||||
* @param f2 The ratio of the color {@param c2} as calculated by {@link ColorMixer#getEndRatio(float)}
|
||||
* @return The result of ((c1 * f1) + (c2 * f2) as an ARGB-encoded color
|
||||
*/
|
||||
public static long mixARGB(long c1, long c2, int f1, int f2) {
|
||||
return ((((((c1 & MASK1) * f1) + ((c2 & MASK1) * f2)) >> 8) & MASK1) |
|
||||
(((((c1 & MASK2) * f1) + ((c2 & MASK2) * f2)) >> 8) & MASK2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to convert 32-bit integers to 64-bit integers and back.
|
||||
* @see ColorMixer#mixARGB(long, long, int, int)
|
||||
*/
|
||||
public static int mixARGB(int c1, int c2, int f1, int f2) {
|
||||
return (int) mixARGB(Integer.toUnsignedLong(c1), Integer.toUnsignedLong(c2), f1, f2);
|
||||
}
|
||||
|
||||
public static int getStartRatio(float frac) {
|
||||
return (int) (256 * frac);
|
||||
}
|
||||
|
||||
public static int getEndRatio(float frac) {
|
||||
return 256 - getStartRatio(frac);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
public interface ColorU8 {
|
||||
/**
|
||||
* The maximum value of a color component.
|
||||
*/
|
||||
float COMPONENT_RANGE = 255.0f;
|
||||
|
||||
/**
|
||||
* Constant value which can be multiplied with a floating-point color component to get the normalized value. The
|
||||
* multiplication is slightly faster than a floating point division, and this code is a hot path which justifies it.
|
||||
*/
|
||||
float NORM = 1.0f / COMPONENT_RANGE;
|
||||
|
||||
/**
|
||||
* Normalizes a color component to the range of 0..1.
|
||||
*/
|
||||
static float normalize(float v) {
|
||||
return v * NORM;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package me.jellysquid.mods.sodium.client.util.color;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import static org.joml.Math.lerp;
|
||||
|
||||
public class FastCubicSampler {
|
||||
private static final double[] DENSITY_CURVE = new double[] { 0.0D, 1.0D, 4.0D, 6.0D, 4.0D, 1.0D, 0.0D };
|
||||
private static final int DIAMETER = 6;
|
||||
|
||||
private static Vector3d unpackRgb(int rgb) {
|
||||
return new Vector3d((rgb >> 16 & 255) / 255.0, (rgb >> 8 & 255) / 255.0, (rgb & 255) / 255.0);
|
||||
}
|
||||
|
||||
public static Vector3d sampleColor(Vector3d pos, ColorFetcher colorFetcher, Function<Vector3d, Vector3d> transformer) {
|
||||
int intX = MathHelper.floor_double(pos.x);
|
||||
int intY = MathHelper.floor_double(pos.y);
|
||||
int intZ = MathHelper.floor_double(pos.z);
|
||||
|
||||
int[] values = new int[DIAMETER * DIAMETER * DIAMETER];
|
||||
|
||||
for(int x = 0; x < DIAMETER; ++x) {
|
||||
int blockX = (intX - 2) + x;
|
||||
|
||||
for(int y = 0; y < DIAMETER; ++y) {
|
||||
int blockY = (intY - 2) + y;
|
||||
|
||||
for(int z = 0; z < DIAMETER; ++z) {
|
||||
int blockZ = (intZ - 2) + z;
|
||||
|
||||
values[index(x, y, z)] = colorFetcher.fetch(blockX, blockY, blockZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fast path! Skip blending the colors if all inputs are the same
|
||||
if (isHomogenousArray(values)) {
|
||||
// Take the first color if it's homogenous (all elements are the same...)
|
||||
return transformer.apply(unpackRgb(values[0]));
|
||||
}
|
||||
|
||||
double deltaX = pos.x - (double)intX;
|
||||
double deltaY = pos.y - (double)intY;
|
||||
double deltaZ = pos.z - (double)intZ;
|
||||
|
||||
Vector3d sum = new Vector3d();
|
||||
double totalFactor = 0.0D;
|
||||
|
||||
for(int x = 0; x < DIAMETER; ++x) {
|
||||
double densityX = lerp(DENSITY_CURVE[x + 1], DENSITY_CURVE[x], deltaX);
|
||||
|
||||
for(int y = 0; y < DIAMETER; ++y) {
|
||||
double densityY = lerp(DENSITY_CURVE[y + 1], DENSITY_CURVE[y], deltaY);
|
||||
|
||||
for(int z = 0; z < DIAMETER; ++z) {
|
||||
double densityZ = lerp(DENSITY_CURVE[z + 1], DENSITY_CURVE[z], deltaZ);
|
||||
|
||||
double factor = densityX * densityY * densityZ;
|
||||
totalFactor += factor;
|
||||
|
||||
Vector3d color = transformer.apply(unpackRgb(values[index(x, y, z)]));
|
||||
sum.add(color.mul(factor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sum.mul(1.0D / totalFactor);
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
private static int index(int x, int y, int z) {
|
||||
return (DIAMETER * DIAMETER * z) + (DIAMETER * y) + x;
|
||||
}
|
||||
|
||||
public interface ColorFetcher {
|
||||
int fetch(int x, int y, int z);
|
||||
}
|
||||
|
||||
private static boolean isHomogenousArray(int[] arr) {
|
||||
int val = arr[0];
|
||||
|
||||
for (int i = 1; i < arr.length; i++) {
|
||||
if (arr[i] != val) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.util.math;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import me.jellysquid.mods.sodium.client.util.Norm3b;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -21,14 +21,14 @@ public class MatrixUtil {
|
||||
public static int transformPackedNormal(int norm, Matrix3f matrix) {
|
||||
Matrix3fExtended mat = MatrixUtil.getExtendedMatrix(matrix);
|
||||
|
||||
float normX1 = NormI8.unpackX(norm);
|
||||
float normY1 = NormI8.unpackY(norm);
|
||||
float normZ1 = NormI8.unpackZ(norm);
|
||||
float normX1 = Norm3b.unpackX(norm);
|
||||
float normY1 = Norm3b.unpackY(norm);
|
||||
float normZ1 = Norm3b.unpackZ(norm);
|
||||
|
||||
float normX2 = mat.transformVecX(normX1, normY1, normZ1);
|
||||
float normY2 = mat.transformVecY(normX1, normY1, normZ1);
|
||||
float normZ2 = mat.transformVecZ(normX1, normY1, normZ1);
|
||||
|
||||
return NormI8.pack(normX2, normY2, normZ2);
|
||||
return Norm3b.pack(normX2, normY2, normZ2);
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class XoRoShiRoRandom extends Random {
|
||||
return (int) this.nextLong(n);
|
||||
}
|
||||
|
||||
public long nextLong(final long n) {
|
||||
private long nextLong(final long n) {
|
||||
if (n <= 0) {
|
||||
throw new IllegalArgumentException("illegal bound " + n + " (must be positive)");
|
||||
}
|
||||
@@ -147,4 +147,4 @@ public class XoRoShiRoRandom extends Random {
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
package me.jellysquid.mods.sodium.client.world;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.model.quad.properties.ModelQuadFacing;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.IBlockAccessExtended;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import java.util.Arrays;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSection;
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -463,17 +464,17 @@ public class WorldSlice implements IBlockAccessExtended, FLBlockAccess {
|
||||
return z << TABLE_BITS | x;
|
||||
}
|
||||
|
||||
/// Modern checks if the sky is darkened, which only happens in the nether. However, I think 1.7.10's hasNoSky is
|
||||
/// close enough.
|
||||
public float getBrightness(ModelQuadFacing direction, boolean shaded) {
|
||||
// Modern checks if the sky is darkened, which only happens in the nether. However, I think 1.7.10's hasNoSky is
|
||||
// close enough.
|
||||
public float getBrightness(ForgeDirection direction, boolean shaded) {
|
||||
|
||||
if (!shaded) {
|
||||
return world.provider.hasNoSky ? 0.9f : 1.0f;
|
||||
}
|
||||
return switch (direction) {
|
||||
case NEG_Y -> 0.5f;
|
||||
case POS_Y -> 1.0f;
|
||||
case NEG_Z, POS_Z -> 0.8f;
|
||||
case DOWN -> 0.5f;
|
||||
case UP -> 1.0f;
|
||||
case NORTH, SOUTH -> 0.8f;
|
||||
default -> 0.6f;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,16 +11,22 @@ import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
|
||||
public class ProgramCreator {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(ProgramCreator.class);
|
||||
|
||||
public static final int MC_ENTITY = 11;
|
||||
public static final int MC_MID_TEX_COORD = 12;
|
||||
public static final int AT_TANGENT = 13;
|
||||
public static final int AT_MIDBLOCK = 14;
|
||||
|
||||
public static int create(String name, GlShader... shaders) {
|
||||
int program = GL20.glCreateProgram();
|
||||
|
||||
// TODO: This is *really* hardcoded, we need to refactor this to support external calls to glBindAttribLocation
|
||||
RenderSystem.bindAttributeLocation(program, 11, "mc_Entity");
|
||||
RenderSystem.bindAttributeLocation(program, 12, "mc_midTexCoord");
|
||||
RenderSystem.bindAttributeLocation(program, 13, "at_tangent");
|
||||
RenderSystem.bindAttributeLocation(program, 14, "at_midBlock");
|
||||
RenderSystem.bindAttributeLocation(program, MC_ENTITY, "mc_Entity");
|
||||
RenderSystem.bindAttributeLocation(program, MC_MID_TEX_COORD, "mc_midTexCoord");
|
||||
RenderSystem.bindAttributeLocation(program, AT_TANGENT, "at_tangent");
|
||||
RenderSystem.bindAttributeLocation(program, AT_MIDBLOCK, "at_midBlock");
|
||||
|
||||
for (GlShader shader : shaders) {
|
||||
GL20.glAttachShader(program, shader.getHandle());
|
||||
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import java.nio.ByteBuffer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class EntityVertexBufferWriterNio extends VertexBufferWriterNio implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.ENTITY.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityNio quad = new QuadViewEntity.QuadViewEntityNio();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public EntityVertexBufferWriterNio(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedQuadVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
buffer.putFloat(i, x);
|
||||
buffer.putFloat(i + 4, y);
|
||||
buffer.putFloat(i + 8, z);
|
||||
buffer.putInt(i + 12, color);
|
||||
buffer.putFloat(i + 16, u);
|
||||
buffer.putFloat(i + 20, v);
|
||||
buffer.putInt(i + 24, overlay);
|
||||
buffer.putInt(i + 28, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(buffer, i, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = NormI8.unpackX(normal);
|
||||
normalY = NormI8.unpackY(normal);
|
||||
normalZ = NormI8.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
buffer.putFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
buffer.putFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
buffer.putInt(i + 32 - STRIDE * vertex, normal);
|
||||
buffer.putInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
-94
@@ -1,94 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memPutFloat;
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memPutInt;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class EntityVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.ENTITY.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityUnsafe quad = new QuadViewEntity.QuadViewEntityUnsafe();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public EntityVertexBufferWriterUnsafe(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedQuadVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
long i = this.writePointer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
memPutFloat(i + 16, u);
|
||||
memPutFloat(i + 20, v);
|
||||
memPutInt(i + 24, overlay);
|
||||
memPutInt(i + 28, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
long i = this.writePointer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(writePointer, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = NormI8.unpackX(normal);
|
||||
normalY = NormI8.unpackY(normal);
|
||||
normalZ = NormI8.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (long vertex = 0; vertex < 4; vertex++) {
|
||||
memPutFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
memPutFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
memPutInt(i + 32 - STRIDE * vertex, normal);
|
||||
memPutInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer.GlyphVertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.BlittableVertexType;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.VanillaVertexType;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
|
||||
public class ExtendedGlyphVertexType implements VanillaVertexType<GlyphVertexSink>, BlittableVertexType<GlyphVertexSink> {
|
||||
public static final ExtendedGlyphVertexType INSTANCE = new ExtendedGlyphVertexType();
|
||||
|
||||
@Override
|
||||
public GlyphVertexSink createFallbackWriter(VertexConsumer vertexConsumer) {
|
||||
return new GlyphVertexWriterFallback(vertexConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GlyphVertexSink createBufferWriter(VertexBufferView buffer, boolean direct) {
|
||||
return direct ? new GlyphVertexBufferWriterUnsafe(buffer) : new GlyphVertexBufferWriterNio(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getVertexFormat() {
|
||||
return IrisVertexFormats.TERRAIN;
|
||||
}
|
||||
|
||||
public BlittableVertexType<GlyphVertexSink> asBlittable() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.VertexConsumer;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer.QuadVertexWriterFallback;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.BlittableVertexType;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.VanillaVertexType;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
|
||||
public class ExtendedQuadVertexType implements VanillaVertexType<QuadVertexSink>, BlittableVertexType<QuadVertexSink> {
|
||||
public static final ExtendedQuadVertexType INSTANCE = new ExtendedQuadVertexType();
|
||||
|
||||
@Override
|
||||
public QuadVertexSink createFallbackWriter(VertexConsumer vertexConsumer) {
|
||||
return new QuadVertexWriterFallback(vertexConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QuadVertexSink createBufferWriter(VertexBufferView buffer, boolean direct) {
|
||||
return direct ? new EntityVertexBufferWriterUnsafe(buffer) : new EntityVertexBufferWriterNio(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VertexFormat getVertexFormat() {
|
||||
return IrisVertexFormats.ENTITY;
|
||||
}
|
||||
|
||||
public BlittableVertexType<QuadVertexSink> asBlittable() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import java.nio.ByteBuffer;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterNio;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class GlyphVertexBufferWriterNio extends VertexBufferWriterNio implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.TERRAIN.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityNio quad = new QuadViewEntity.QuadViewEntityNio();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public GlyphVertexBufferWriterNio(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedGlyphVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
buffer.putFloat(i, x);
|
||||
buffer.putFloat(i + 4, y);
|
||||
buffer.putFloat(i + 8, z);
|
||||
buffer.putInt(i + 12, color);
|
||||
buffer.putFloat(i + 16, u);
|
||||
buffer.putFloat(i + 20, v);
|
||||
buffer.putInt(i + 24, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
int i = this.writeOffset;
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(byteBuffer, writeOffset, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = NormI8.unpackX(normal);
|
||||
normalY = NormI8.unpackY(normal);
|
||||
normalZ = NormI8.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (int vertex = 0; vertex < 4; vertex++) {
|
||||
buffer.putFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
buffer.putFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
buffer.putInt(i + 28 - STRIDE * vertex, normal);
|
||||
buffer.putInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
-93
@@ -1,93 +0,0 @@
|
||||
package net.coderbot.iris.sodium.vertex_format.entity_xhfp;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memPutFloat;
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memPutInt;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.cel.api.util.NormI8;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.GlyphVertexSink;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.formats.quad.QuadVertexSink;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe implements QuadVertexSink, GlyphVertexSink {
|
||||
private static final int STRIDE = IrisVertexFormats.TERRAIN.getVertexSize();
|
||||
|
||||
private final QuadViewEntity.QuadViewEntityUnsafe quad = new QuadViewEntity.QuadViewEntityUnsafe();
|
||||
private final Vector3f saveNormal = new Vector3f();
|
||||
|
||||
private int vertexCount;
|
||||
private float uSum;
|
||||
private float vSum;
|
||||
|
||||
public GlyphVertexBufferWriterUnsafe(VertexBufferView backingBuffer) {
|
||||
super(backingBuffer, ExtendedGlyphVertexType.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
long i = this.writePointer;
|
||||
|
||||
vertexCount++;
|
||||
uSum += u;
|
||||
vSum += v;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
memPutFloat(i + 16, u);
|
||||
memPutFloat(i + 20, v);
|
||||
memPutInt(i + 24, light);
|
||||
|
||||
if (vertexCount == 4) {
|
||||
this.endQuad(normal);
|
||||
}
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
writeQuad(x, y, z, color, u, v, light, 0, 0);
|
||||
}
|
||||
|
||||
private void endQuad(int normal) {
|
||||
this.vertexCount = 0;
|
||||
|
||||
long i = this.writePointer;
|
||||
|
||||
uSum *= 0.25;
|
||||
vSum *= 0.25;
|
||||
|
||||
quad.setup(writePointer, STRIDE);
|
||||
|
||||
float normalX, normalY, normalZ;
|
||||
|
||||
if (normal == 0) {
|
||||
NormalHelper.computeFaceNormal(saveNormal, quad);
|
||||
normalX = saveNormal.x;
|
||||
normalY = saveNormal.y;
|
||||
normalZ = saveNormal.z;
|
||||
normal = NormalHelper.packNormal(saveNormal, 0.0F);
|
||||
} else {
|
||||
normalX = NormI8.unpackX(normal);
|
||||
normalY = NormI8.unpackY(normal);
|
||||
normalZ = NormI8.unpackZ(normal);
|
||||
}
|
||||
|
||||
int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);
|
||||
|
||||
for (long vertex = 0; vertex < 4; vertex++) {
|
||||
memPutFloat(i + 36 - STRIDE * vertex, uSum);
|
||||
memPutFloat(i + 40 - STRIDE * vertex, vSum);
|
||||
memPutInt(i + 28 - STRIDE * vertex, normal);
|
||||
memPutInt(i + 44 - STRIDE * vertex, tangent);
|
||||
}
|
||||
|
||||
uSum = 0;
|
||||
vSum = 0;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.coderbot.iris.texture.pbr;
|
||||
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
@@ -32,13 +32,13 @@ public enum PBRType {
|
||||
public ResourceLocation appendToFileLocation(ResourceLocation location) {
|
||||
String domain = location.getResourceDomain();
|
||||
String path = location.getResourcePath();
|
||||
String newPath;
|
||||
|
||||
try {
|
||||
URI uri = new URI(null, null, path, null);
|
||||
String cleanPath = uri.getPath();
|
||||
String newPath;
|
||||
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(cleanPath);
|
||||
int extensionIndex = safeIndexOfExtension(cleanPath);
|
||||
if (extensionIndex != -1) {
|
||||
newPath = cleanPath.substring(0, extensionIndex) + suffix + cleanPath.substring(extensionIndex);
|
||||
} else {
|
||||
@@ -48,17 +48,11 @@ public enum PBRType {
|
||||
URI newUri = new URI(null, null, newPath, null);
|
||||
newPath = newUri.getPath();
|
||||
|
||||
return new ResourceLocation(domain, newPath);
|
||||
} catch (URISyntaxException e) {
|
||||
String fallback = path.replace(':', '/');
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(fallback);
|
||||
if (extensionIndex != -1) {
|
||||
newPath = fallback.substring(0, extensionIndex) + suffix + fallback.substring(extensionIndex);
|
||||
} else {
|
||||
newPath = fallback + suffix;
|
||||
}
|
||||
Iris.logger.error("Failed to append PBR suffix to resource location for " + path, e);
|
||||
return location;
|
||||
}
|
||||
|
||||
return new ResourceLocation(domain, newPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,4 +70,19 @@ public enum PBRType {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Helper method to safely find the index of the file extension
|
||||
// Using this to avoid issues with ':' in paths (any block with meta).
|
||||
private static int safeIndexOfExtension(String input) {
|
||||
if (input == null) return -1;
|
||||
|
||||
// Avoid dots in directory names or leading/trailing dots
|
||||
int lastSlash = Math.max(input.lastIndexOf('/'), input.lastIndexOf('\\'));
|
||||
int nameStart = lastSlash + 1;
|
||||
int lastDot = input.lastIndexOf('.');
|
||||
if (lastDot == -1 || lastDot <= nameStart || lastDot == input.length() - 1) {
|
||||
return -1;
|
||||
}
|
||||
return lastDot;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package net.coderbot.iris.vertices;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormatElement;
|
||||
|
||||
public class IrisVertexFormats {
|
||||
public static final VertexFormatElement ENTITY_ELEMENT;
|
||||
public static final VertexFormatElement MID_TEXTURE_ELEMENT;
|
||||
public static final VertexFormatElement TANGENT_ELEMENT;
|
||||
public static final VertexFormatElement MID_BLOCK_ELEMENT;
|
||||
|
||||
public static final VertexFormat TERRAIN;
|
||||
public static final VertexFormat ENTITY;
|
||||
|
||||
static {
|
||||
ENTITY_ELEMENT = new VertexFormatElement(11, VertexFormatElement.Type.SHORT, VertexFormatElement.Usage.GENERIC, 2);
|
||||
MID_TEXTURE_ELEMENT = new VertexFormatElement(12, VertexFormatElement.Type.FLOAT, VertexFormatElement.Usage.GENERIC, 2);
|
||||
TANGENT_ELEMENT = new VertexFormatElement(13, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, 4);
|
||||
MID_BLOCK_ELEMENT = new VertexFormatElement(14, VertexFormatElement.Type.BYTE, VertexFormatElement.Usage.GENERIC, 3);
|
||||
|
||||
ImmutableList.Builder<VertexFormatElement> terrainElements = ImmutableList.builder();
|
||||
ImmutableList.Builder<VertexFormatElement> entityElements = ImmutableList.builder();
|
||||
|
||||
terrainElements.add(DefaultVertexFormat.POSITION_ELEMENT); // 12
|
||||
terrainElements.add(DefaultVertexFormat.COLOR_ELEMENT); // 16
|
||||
terrainElements.add(DefaultVertexFormat.TEXTURE_ELEMENT); // 24
|
||||
terrainElements.add(DefaultVertexFormat.LIGHT_ELEMENT); // 28
|
||||
terrainElements.add(DefaultVertexFormat.NORMAL_ELEMENT); // 31
|
||||
terrainElements.add(DefaultVertexFormat.PADDING_ELEMENT); // 32
|
||||
terrainElements.add(ENTITY_ELEMENT); // 36
|
||||
terrainElements.add(MID_TEXTURE_ELEMENT); // 44
|
||||
terrainElements.add(TANGENT_ELEMENT); // 48
|
||||
terrainElements.add(MID_BLOCK_ELEMENT); // 51
|
||||
terrainElements.add(DefaultVertexFormat.PADDING_ELEMENT); // 52
|
||||
|
||||
entityElements.add(DefaultVertexFormat.POSITION_ELEMENT); // 12
|
||||
entityElements.add(DefaultVertexFormat.COLOR_ELEMENT); // 16
|
||||
entityElements.add(DefaultVertexFormat.TEXTURE_ELEMENT); // 24
|
||||
entityElements.add(DefaultVertexFormat.LIGHT_ELEMENT); // 28
|
||||
entityElements.add(DefaultVertexFormat.NORMAL_ELEMENT); // 31
|
||||
entityElements.add(DefaultVertexFormat.PADDING_ELEMENT); // 32
|
||||
entityElements.add(MID_TEXTURE_ELEMENT); // 40
|
||||
entityElements.add(TANGENT_ELEMENT); // 44
|
||||
|
||||
TERRAIN = new VertexFormat(terrainElements.build());
|
||||
ENTITY = new VertexFormat(entityElements.build());
|
||||
}
|
||||
}
|
||||
@@ -139,11 +139,16 @@ options.angelica.fontconfig=Font Configuration...
|
||||
options.angelica.fontconfig.title=Font Configuration
|
||||
options.angelica.fontconfig.currentfonts=Primary font: §e%s§r Fallback font: §b%s
|
||||
options.angelica.fontconfig.searchprompt=§7§oSearch fonts...
|
||||
options.angelica.fontconfig.testareaprompt=§7§oTest area...
|
||||
options.angelica.fontconfig.testareainfo=Enter text below to see how it renders. Use & for formatting.
|
||||
options.angelica.fontconfig.testareaexample=&d&lHerobrine&r was &7&m&oNOT&r &nhere
|
||||
options.angelica.fontconfig.disable_custom_font=Disable Custom Font
|
||||
options.angelica.fontconfig.enable_custom_font=Enable Custom Font
|
||||
options.angelica.fontconfig.reset_values=Reset Values
|
||||
options.angelica.fontconfig.font_quality=Custom Font Quality: %s
|
||||
options.angelica.fontconfig.shadow_offset=Shadow Offset: %s
|
||||
options.angelica.fontconfig.shadow_copies=Shadow Copies: %s
|
||||
options.angelica.fontconfig.bold_copies=Bold Copies: %s
|
||||
options.angelica.fontconfig.glyph_scale=Glyph Scale: %s
|
||||
options.angelica.fontconfig.glyph_aspect=Glyph Aspect: %s
|
||||
options.angelica.fontconfig.whitespace_scale=Whitespace Size: %s
|
||||
@@ -153,7 +158,9 @@ options.angelica.fontconfig.aamode.aa_none=Font AA: OFF
|
||||
options.angelica.fontconfig.aamode.aa_4x=Font AA: 4x MSAA
|
||||
options.angelica.fontconfig.aamode.aa_16x=Font AA: 16x MSAA
|
||||
options.angelica.fontconfig.font_quality.tooltip=The quality at which custom fonts are rendered, making them less pixelated at the expense of some performance and memory.
|
||||
options.angelica.fontconfig.shadow_offset.tooltip=The distance at which the fonts' shadows are drawn. Also affects the way §lbold§r text is drawn; turn this down if you see double text.
|
||||
options.angelica.fontconfig.shadow_offset.tooltip=The distance at which the fonts' shadows are drawn. Also affects the way §lbold§r text is drawn.
|
||||
options.angelica.fontconfig.shadow_copies.tooltip=The number of shadows to be drawn behind text, all offset so as to provide a fake 3D effect.
|
||||
options.angelica.fontconfig.bold_copies.tooltip=The number of text copies drawn when rendering bold text. Can improve the appearance of bold text with thinner custom fonts.
|
||||
options.angelica.fontconfig.glyph_scale.tooltip=The scale of each individual glyph. Extreme values might make your game unplayable.
|
||||
options.angelica.fontconfig.glyph_aspect.tooltip=The aspect ratio of each individual glyph.
|
||||
options.angelica.fontconfig.whitespace_scale.tooltip=The scaling factor of blank characters like spaces.
|
||||
|
||||
@@ -2,6 +2,8 @@ options.button.shader=光影包……
|
||||
|
||||
options.chunks=%s 区块
|
||||
options.entityShadows=实体阴影
|
||||
options.droppedItems=%s 个物品
|
||||
options.droppedItems.max=无限制
|
||||
sodium.option_impact.low=低
|
||||
sodium.option_impact.medium=中
|
||||
sodium.option_impact.high=高
|
||||
@@ -29,6 +31,8 @@ sodium.options.leaves_quality.name=树叶质量
|
||||
sodium.options.leaves_quality.tooltip=控制树叶的渲染质量。
|
||||
sodium.options.grass_quality.name=草方块质量
|
||||
sodium.options.grass_quality.tooltip=控制草方块侧面的质量。
|
||||
sodium.options.sodium_smooth_lighting.name=Sodium平滑光照
|
||||
sodium.options.sodium_smooth_lighting.tooltip=如果启用,将调用钠模组的平滑光照,此选项仅在平滑光照启用时生效。
|
||||
sodium.options.particle_quality.name=粒子效果
|
||||
sodium.options.particle_quality.tooltip=控制可同时在画面上渲染的最大粒子数量。
|
||||
sodium.options.smooth_lighting.tooltip=控制方块是否平滑光照和渲染。这会略微增加重新加载区块所需的时间,但不会影响帧率(FPS)。
|
||||
@@ -38,7 +42,7 @@ sodium.options.entity_distance.tooltip=实体渲染的距离修正乘数。更
|
||||
sodium.options.entity_shadows.tooltip=如果启用,将在生物和其他实体下方渲染简单的阴影。
|
||||
sodium.options.vignette.name=晕影
|
||||
sodium.options.vignette.tooltip=如果启用,将在玩家的画面上显示晕影效果。除非你的显卡像素填充率有限,否则这不太可能对帧率产生影响。
|
||||
sodium.options.mipmap_levels.tooltip=控制将用于方块模型纹理的MipMap的数量。较高的值可以更好地渲染远处的方块,但可能会对许多纹理动画的性能产生不利影响。
|
||||
sodium.options.mipmap_levels.tooltip=控制多级纹理的生成等级。较高的等级可以更好地渲染远处的方块,但可能会对许多纹理动画的性能产生不利影响。
|
||||
sodium.options.use_chunk_multidraw.name=使用区块多重绘制
|
||||
sodium.options.use_chunk_multidraw.tooltip=多重绘制允许通过更少的绘制请求来进行多区块渲染,在大大减少了渲染世界时的CPU负载的同时也可能提高了GPU利用率。此选项可能会让一些图形驱动程序出现问题,因此如果遇到相关问题,应尝试禁用它。
|
||||
sodium.options.use_vertex_objects.name=使用顶点数组对象
|
||||
@@ -61,7 +65,7 @@ sodium.options.cpu_render_ahead_limit.name=CPU 预渲染限制
|
||||
sodium.options.cpu_render_ahead_limit.tooltip=指定CPU可以在GPU上等待完成渲染的最大帧数。非常低或非常高的值都可能会导致帧率(FPS)不稳定。
|
||||
sodium.options.cpu_render_ahead_limit.value=%s 帧
|
||||
sodium.options.allow_direct_memory_access.name=允许直接内存访问
|
||||
sodium.options.allow_direct_memory_access.tooltip=如果启用,将允许某些关键代码路径使用直接内存访问来提高性能。这通常会大大减少区块和实体渲染的 CPU 开销,但会使诊断某些错误和崩溃变得更加困难。只有您被要求这么做或知道在做什么时,才应该禁用它。
|
||||
sodium.options.allow_direct_memory_access.tooltip=如果启用,一些关键代码将被允许通过直接读写内存来提高性能。这通常会大大减少区块和实体渲染的CPU开销,但会使诊断某些错误和崩溃变得更加困难。只有您被要求这么做或知道在做什么时,才应该禁用它。
|
||||
sodium.options.ignore_driver_blacklist.name=忽略驱动程序冲突
|
||||
sodium.options.ignore_driver_blacklist.tooltip=如果启用,已知的硬件/驱动程序配置不兼容性将被忽略,以允许您启用那些可能导致游戏问题的配置.请勿更改此项除非您确切知道您在做什么.更改此选项后,必须保存、关闭,然后重新打开设置菜单。
|
||||
sodium.options.enable_memory_tracing.name=启用内存跟踪
|
||||
@@ -78,10 +82,10 @@ sodium.options.chunk_update_threads.tooltip=指定用于区块构建的线程数
|
||||
sodium.options.always_defer_chunk_updates.name=始终推迟区块更新
|
||||
sodium.options.always_defer_chunk_updates.tooltip=如果启用,渲染将永远不会等待区块更新完成,即使它们很重要。这在某些情况下可以极大地提高帧率(FPS),但可能会在游戏时产生明显的视觉滞后。
|
||||
sodium.options.use_no_error_context.name=使用禁用错误检查的上下文
|
||||
sodium.options.use_no_error_context.tooltip=如果启用,OpenGL上下文将在禁用错误检查的情况下创建。这可能会略微提高性能,但也会增加游戏崩溃的风险,而不会优雅地处理OpenGL错误。如果遇到无法解释的突然崩溃,则应禁用此选项。
|
||||
sodium.options.use_no_error_context.tooltip=如果启用,OpenGL日志将不包含详细错误信息。这可能略微提高性能,但也可能因为无法精确处理OpenGL错误而导致游戏崩溃。如遇到不明原因的突然崩溃,则应禁用此选项。
|
||||
sodium.options.threads.value=%s 线程
|
||||
sodium.options.use_gl_state_cache.name=使用GL状态缓存
|
||||
sodium.options.use_gl_state_cache.tooltip=如果启用,OpenGL状态缓存将减少冗余状态更改的次数.这可以提高性能,但也可能导致一些模组出现问题.每次重启游戏时此项将重置.
|
||||
sodium.options.use_gl_state_cache.name=启用GL状态缓存
|
||||
sodium.options.use_gl_state_cache.tooltip=如果启用,OpenGL状态缓存将减少冗余状态更改的次数。这可以提高性能,但也可能导致一些模组出现问题。每次重启游戏时此项将重置。
|
||||
sodium.options.default=默认
|
||||
sodium.options.buttons.undo=撤销
|
||||
sodium.options.buttons.apply=应用
|
||||
@@ -89,7 +93,7 @@ sodium.options.buttons.donate=给JellySquid买杯咖啡!
|
||||
options.dynamic_fov=动态视场
|
||||
options.dynamic_fov.tooltip=如果启用,游戏视场将根据玩家速度发生变化.
|
||||
options.framerate=%s FPS
|
||||
iris.shaders.toggled=光影包已切换到 %s!
|
||||
iris.shaders.toggled=光影包已切换为 %s!
|
||||
iris.shaders.disabled=光影包已禁用!
|
||||
options.iris.apply=应用
|
||||
options.iris.refresh=刷新
|
||||
@@ -122,12 +126,48 @@ options.iris.setToDefault=将选项设为默认值?
|
||||
options.iris.profile=配置文件
|
||||
options.iris.profile.custom=自定义
|
||||
options.iris.shadowDistance=最大阴影距离
|
||||
options.iris.shadowDistance.sodium_tooltip=最大阴影距离
|
||||
options.iris.shadowDistance.enabled=更改渲染阴影的最远距离。超出此距离的地形和实体不会投射出阴影。减少阴影渲染距离可以显著提高性能。
|
||||
options.iris.shadowDistance.disabled=当前光影包已重设阴影渲染距离,无法更改.
|
||||
options.iris.shadowDistance.disabled=当前光影包已重设阴影渲染距离,无法更改
|
||||
options.iris.gui.hide=隐藏 GUI
|
||||
options.iris.gui.show=显示 GUI
|
||||
options.dynamic_lights=动态光源
|
||||
options.dynamic_lights.tooltip=启用动态光源. 模式选择: OFF - 关闭, FASTEST - 500ms延迟, FAST - 250ms延迟, FANCY - 无延迟. 如果正在使用光影则此功能被禁用.
|
||||
options.dynamic_lights.tooltip=启用动态光源,模式选择:OFF-关闭,FASTEST-500ms延迟,FAST-250ms延迟,FANCY-无延迟
|
||||
options.dynamic_lights_shader_force=强制启用动态光源
|
||||
options.dynamic_lights_shader_force.tooltip=启用-启用光影时仍显示动态光源;禁用-启用光影时禁用动态光源。
|
||||
options.angelica.fontconfig=字体配置...
|
||||
options.angelica.fontconfig.title=字体配置
|
||||
options.angelica.fontconfig.currentfonts=主字体:§e%s§r 备用字体:§b%s
|
||||
options.angelica.fontconfig.searchprompt=§7§o搜索字体...
|
||||
options.angelica.fontconfig.disable_custom_font=禁用自定义字体
|
||||
options.angelica.fontconfig.enable_custom_font=启用自定义字体
|
||||
options.angelica.fontconfig.reset_values=恢复默认配置
|
||||
options.angelica.fontconfig.font_quality=字体渲染质量:%s
|
||||
options.angelica.fontconfig.shadow_offset=阴影偏移:%s
|
||||
options.angelica.fontconfig.glyph_scale=字体缩放:%s
|
||||
options.angelica.fontconfig.glyph_aspect=字体宽高比:%s
|
||||
options.angelica.fontconfig.whitespace_scale=空白字符大小:%s
|
||||
options.angelica.fontconfig.glyph_spacing=字符间距:%s
|
||||
options.angelica.fontconfig.font_aa_strength=字体抗锯齿强度:%s
|
||||
options.angelica.fontconfig.aamode.aa_none=抗锯齿:关闭
|
||||
options.angelica.fontconfig.aamode.aa_4x=抗锯齿:4x MSAA
|
||||
options.angelica.fontconfig.aamode.aa_16x=抗锯齿:16x MSAA
|
||||
options.angelica.fontconfig.font_quality.tooltip=自定义字体渲染质量,使其不那么像素化,但会牺牲一些性能与内存占用。
|
||||
options.angelica.fontconfig.shadow_offset.tooltip=字体衬底阴影偏移的距离。同时影响§l粗体§r文本的绘制方式;如果看到重影的文本,请调低此值。
|
||||
options.angelica.fontconfig.glyph_scale.tooltip=字体大小的缩放比例。极端值可能使游戏难以游玩。
|
||||
options.angelica.fontconfig.glyph_aspect.tooltip=字体的的宽高比例
|
||||
options.angelica.fontconfig.whitespace_scale.tooltip=空白字符(如空格)的缩放比例
|
||||
options.angelica.fontconfig.glyph_spacing.tooltip=字符之间的间距
|
||||
options.angelica.fontconfig.font_aa_strength.tooltip=抗锯齿所使用的采样间距。过大可能导致字体看起来模糊,过小可能导致锯齿。请根据您的实际情况选择最佳值。
|
||||
options.angelica.fontconfig.aamode.tooltip=抗锯齿模式。可以显著改善缩放或斜角观看文本的外观和可读性,但会牺牲一些性能。
|
||||
options.angelica.droppedItemLimit=掉落物渲染数量上限
|
||||
options.angelica.droppedItemLimit.tooltip=将被渲染的掉落物的最大数量。较小的值可以提高性能。
|
||||
options.angelica.mobSpawnerRenderDistance=刷怪笼渲染距离
|
||||
options.angelica.mobSpawnerRenderDistance.tooltip=刷怪笼内旋转实体的渲染距离
|
||||
options.angelica.itemdisplaylistcount=物品渲染器缓存限制
|
||||
options.angelica.itemdisplaylistcount.tooltip=优化物品渲染器中的缓存数量上限。较高的值将显著提高性能,但可能导致显存占用增加
|
||||
options.angelica.sleepbeforeswap=备用FPS限制器
|
||||
options.angelica.sleepbeforeswap.tooltip=切换到备用FPS限制器,可以降低帧波动,但会略微增加延迟。最多只会造成一帧的延迟,且在较高帧率下影响较小。
|
||||
pack.iris.select.title=选择
|
||||
pack.iris.configure.title=配置
|
||||
label.iris.true=开启
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent": "block/cube_all",
|
||||
"parent": "blocks/cube_all",
|
||||
"textures": {
|
||||
"all": "angelica:test_block"
|
||||
}
|
||||
|
||||
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user