mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-17 11:05:04 +00:00
Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b67eaa474 | ||
|
|
c9d59c3b90 | ||
|
|
fa7ff74fec | ||
|
|
a34a3ebd39 | ||
|
|
2e7476d287 | ||
|
|
3244071012 | ||
|
|
7035dbde02 | ||
|
|
97ae04c2fa | ||
|
|
e7fa7f62d0 | ||
|
|
ea39712749 | ||
|
|
66dd3eaa94 | ||
|
|
270697cd10 | ||
|
|
2b53a851ef | ||
|
|
34b6efde7b | ||
|
|
86edb721da | ||
|
|
39c5f4bf7b | ||
|
|
5dc54bb1da | ||
|
|
7924769ab1 | ||
|
|
8afe2e2ccf | ||
|
|
e8dd60e088 | ||
|
|
9a621405ba | ||
|
|
45a677030d | ||
|
|
4d531022d2 | ||
|
|
48ba2160ad | ||
|
|
334ec81f9b | ||
|
|
86c726e50b | ||
|
|
e6d778dad3 | ||
|
|
dce5013ffb | ||
|
|
6eef63619c | ||
|
|
a8153fa0f7 | ||
|
|
49c04cf776 | ||
|
|
85b0277a66 | ||
|
|
0525b31262 | ||
|
|
fdb2053c50 | ||
|
|
31abbcce32 |
No files matched your search
@@ -7,7 +7,7 @@
|
||||
* It's a cute angle -mitchej123
|
||||
* It's the angel that pulls you out of OptiFine's hell -Roadhog360
|
||||
|
||||
## **Beta Quality - Here there be Dragons**
|
||||
## **Beta Quality - Here there be Dragons**
|
||||
* Shaders - Beta
|
||||
* Complementary & BSL mostly function, but have some bugs
|
||||
* Sildurs, Seus, and any other shader probably doesn't work
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
# Required Dependencies
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.19
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.6.20
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.7.0
|
||||
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
@@ -27,7 +27,6 @@
|
||||
|
||||
# Known Incompatibilities
|
||||
* FalseTweaks - Not currently planned (Looking for volunteers) [Might work if you effectively disable most of the mod]
|
||||
* SmoothFont - Not currently planned (Looking for volunteers)
|
||||
* RPLE - Not currently planned (Looking for volunteers)
|
||||
* LiteLoader - Install [LiteloaderLoader](https://github.com/Midnight145/LiteloaderLoader)
|
||||
|
||||
@@ -42,6 +41,7 @@
|
||||
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 0.4.5 or above
|
||||
* CodeChicken[Core](https://github.com/GTNewHorizons/CodeChickenCore/releases)/[Lib](https://github.com/GTNewHorizons/CodeChickenLib/releases) <1.2.0 - Threading issues, use 1.3.0+
|
||||
* Neodymium - Untested, but unlikely to be compatible. (Chunk Meshing is definitely incompatible, other features might work depending on config)
|
||||
* SmoothFont - Equivalent functionality added
|
||||
|
||||
# Credits
|
||||
* ShadersMod
|
||||
|
||||
@@ -4,6 +4,8 @@ plugins {
|
||||
|
||||
minecraft {
|
||||
extraRunJvmArguments.add("-Dangelica.enableTestBlocks=true")
|
||||
extraRunJvmArguments.add("-Dangelica.dumpClass=true")
|
||||
//extraRunJvmArguments.add("-Dangelica.redirectorLogspam=true")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
|
||||
+12
-12
@@ -49,7 +49,7 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.30")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.107")
|
||||
|
||||
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.7") { transitive = false }
|
||||
|
||||
@@ -57,11 +57,11 @@ dependencies {
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
|
||||
// Use modern models+textures to inject QuadProviders
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.8.2:dev')
|
||||
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.6.20:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.40: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
|
||||
@@ -70,20 +70,20 @@ dependencies {
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.29-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.1: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.1.7-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.5:dev") { transitive = false }
|
||||
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.13.10-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.2:dev")
|
||||
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.7.1:dev")
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.8:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.2:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.3:dev") { transitive = false }
|
||||
|
||||
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api") { transitive = false }
|
||||
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0003:dev") { transitive = false }
|
||||
@@ -93,7 +93,7 @@ dependencies {
|
||||
|
||||
compileOnly("curse.maven:minefactory-reloaded-66672:2277486")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.1.6:dev") // Mixin Version
|
||||
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:campfirebackport-387444:4611675"))
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ modId = angelica
|
||||
modGroup = com.gtnewhorizons.angelica
|
||||
|
||||
# Whether to use modGroup as the maven publishing group.
|
||||
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
||||
# When false, com.github.GTNewHorizons is used.
|
||||
useModGroupForPublishing = false
|
||||
|
||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||
@@ -151,7 +151,7 @@ modrinthProjectId = angelica
|
||||
# type can be one of [project, version],
|
||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
||||
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||
modrinthRelations = required-project\:gtnhlib
|
||||
|
||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.37'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.ILateMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.LateMixin;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
import com.gtnewhorizons.angelica.mixins.Mixins;
|
||||
|
||||
import java.util.List;
|
||||
@@ -9,6 +10,7 @@ import java.util.Set;
|
||||
|
||||
@LateMixin
|
||||
public class AngelicaLateMixins implements ILateMixinLoader {
|
||||
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
return "mixins.angelica.late.json";
|
||||
@@ -16,7 +18,6 @@ public class AngelicaLateMixins implements ILateMixinLoader {
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedMods) {
|
||||
return Mixins.getLateMixins(loadedMods);
|
||||
return IMixins.getLateMixins(Mixins.class, loadedMods);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +1,30 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
|
||||
import cpw.mods.fml.client.SplashProgress;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import jss.util.RandomXoshiro256StarStar;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
import net.coderbot.iris.gl.program.ProgramBuilder;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
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.GL20;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
/**
|
||||
* A batching replacement for {@code FontRenderer}
|
||||
*
|
||||
@@ -30,8 +34,6 @@ public class BatchingFontRenderer {
|
||||
|
||||
/** The underlying FontRenderer object that's being accelerated */
|
||||
protected FontRenderer underlying;
|
||||
/** Cached locations for each unicode page atlas */
|
||||
private final ResourceLocation[] unicodePageLocations;
|
||||
/** Array of width of all the characters in default.png */
|
||||
protected int[] charWidth = new int[256];
|
||||
/** Array of the start/end column (in upper/lower nibble) for every glyph in the /font directory. */
|
||||
@@ -43,39 +45,38 @@ public class BatchingFontRenderer {
|
||||
private int[] colorCode;
|
||||
/** Location of the primary font atlas to bind. */
|
||||
protected final ResourceLocation locationFontTexture;
|
||||
private final RandomXoshiro256StarStar fontRandom = new RandomXoshiro256StarStar();
|
||||
|
||||
/** The full list of characters present in the default Minecraft font, excluding the Unicode font */
|
||||
@SuppressWarnings("UnnecessaryUnicodeEscape")
|
||||
private static final String MCFONT_CHARS = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000";
|
||||
private final int AAMode;
|
||||
private final int AAStrength;
|
||||
private final int texBoundAttrLocation;
|
||||
private final int fontShaderId;
|
||||
|
||||
private static final short[] MCFONT_ASCII_LUT = new short[512];
|
||||
private static final Char2ShortOpenHashMap MCFONT_UNI_LUT = new Char2ShortOpenHashMap();
|
||||
final boolean isSGA;
|
||||
final boolean isSplash;
|
||||
|
||||
static {
|
||||
Arrays.fill(MCFONT_ASCII_LUT, (short) -1);
|
||||
for (short i = 0; i < MCFONT_CHARS.length(); i++) {
|
||||
char ch = MCFONT_CHARS.charAt(i);
|
||||
if (ch < MCFONT_ASCII_LUT.length) {
|
||||
MCFONT_ASCII_LUT[ch] = i;
|
||||
} else {
|
||||
MCFONT_UNI_LUT.put(ch, i);
|
||||
private static class FontAAShader {
|
||||
|
||||
private static Program fontShader = null;
|
||||
public static Program getProgram() {
|
||||
if (fontShader == null) {
|
||||
String vsh, fsh;
|
||||
try {
|
||||
fsh = new String(IOUtils.toByteArray(Objects.requireNonNull(FontAAShader.class.getResourceAsStream("/assets/angelica/shaders/fontFilter.fsh"))), StandardCharsets.UTF_8);
|
||||
vsh = new String(IOUtils.toByteArray(Objects.requireNonNull(FontAAShader.class.getResourceAsStream("/assets/angelica/shaders/fontFilter.vsh"))), StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
ProgramBuilder builder = ProgramBuilder.begin("fontFilter", vsh, null, fsh, ImmutableSet.of(0));
|
||||
fontShader = builder.build();
|
||||
}
|
||||
return fontShader;
|
||||
}
|
||||
}
|
||||
|
||||
public static int lookupMcFontPosition(char ch) {
|
||||
if (ch < MCFONT_ASCII_LUT.length) {
|
||||
return MCFONT_ASCII_LUT[ch];
|
||||
} else {
|
||||
return MCFONT_UNI_LUT.getOrDefault(ch, (short) -1);
|
||||
}
|
||||
}
|
||||
|
||||
public BatchingFontRenderer(FontRenderer underlying, ResourceLocation[] unicodePageLocations, int[] charWidth,
|
||||
byte[] glyphWidth, int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
public BatchingFontRenderer(FontRenderer underlying, int[] charWidth, byte[] glyphWidth,
|
||||
int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
this.underlying = underlying;
|
||||
this.unicodePageLocations = unicodePageLocations;
|
||||
this.charWidth = charWidth;
|
||||
this.glyphWidth = glyphWidth;
|
||||
this.colorCode = colorCode;
|
||||
@@ -84,6 +85,20 @@ public class BatchingFontRenderer {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
batchCommandPool.add(new FontDrawCmd());
|
||||
}
|
||||
|
||||
this.isSGA = Objects.equals(this.locationFontTexture.getResourcePath(), "textures/font/ascii_sga.png");
|
||||
// noinspection deprecation
|
||||
this.isSplash = underlying instanceof SplashProgress.SplashFontRenderer;
|
||||
|
||||
FontProviderMC.get(this.isSGA).charWidth = this.charWidth;
|
||||
FontProviderMC.get(this.isSGA).locationFontTexture = this.locationFontTexture;
|
||||
FontProviderUnicode.get().glyphWidth = this.glyphWidth;
|
||||
|
||||
//noinspection deprecation
|
||||
fontShaderId = FontAAShader.getProgram().getProgramId();
|
||||
AAMode = GL20.glGetUniformLocation(fontShaderId, "aaMode");
|
||||
AAStrength = GL20.glGetUniformLocation(fontShaderId, "strength");
|
||||
texBoundAttrLocation = GL20.glGetAttribLocation(fontShaderId, "texBounds");
|
||||
}
|
||||
|
||||
// === Batched rendering
|
||||
@@ -99,17 +114,22 @@ public class BatchingFontRenderer {
|
||||
private ByteBuffer batchVtxColors = memAlloc(INITIAL_BATCH_SIZE * 4);
|
||||
private FloatBuffer batchVtxTexCoords = memAllocFloat(INITIAL_BATCH_SIZE * 2);
|
||||
private IntBuffer batchIndices = memAllocInt(INITIAL_BATCH_SIZE / 2 * 3);
|
||||
private FloatBuffer batchVtxTexBounds = memAllocFloat(INITIAL_BATCH_SIZE * 4);
|
||||
private final ObjectArrayList<FontDrawCmd> batchCommands = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
|
||||
private final ObjectArrayList<FontDrawCmd> batchCommandPool = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
|
||||
|
||||
private int blendSrcRGB = GL11.GL_SRC_ALPHA;
|
||||
private int blendDstRGB = GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
|
||||
/** */
|
||||
private void pushVtx(float x, float y, int rgba, float u, float v) {
|
||||
private void pushVtx(float x, float y, int rgba, float u, float v, float uMin, float uMax, float vMin, float vMax) {
|
||||
final int oldCap = batchVtxPositions.capacity() / 2;
|
||||
if (vtxWriterIndex >= oldCap) {
|
||||
final int newCap = oldCap * 2;
|
||||
batchVtxPositions = memRealloc(batchVtxPositions, newCap * 2);
|
||||
batchVtxColors = memRealloc(batchVtxColors, newCap * 4);
|
||||
batchVtxTexCoords = memRealloc(batchVtxTexCoords, newCap * 2);
|
||||
batchVtxTexBounds = memRealloc(batchVtxTexBounds, newCap * 4);
|
||||
final int oldIdxCap = batchIndices.capacity();
|
||||
final int newIdxCap = oldIdxCap * 2;
|
||||
batchIndices = memRealloc(batchIndices, newIdxCap);
|
||||
@@ -126,15 +146,19 @@ public class BatchingFontRenderer {
|
||||
batchVtxColors.put(idx4 + 3, (byte) ((rgba >> 24) & 0xFF));
|
||||
batchVtxTexCoords.put(idx2, u);
|
||||
batchVtxTexCoords.put(idx2 + 1, v);
|
||||
batchVtxTexBounds.put(idx4, uMin);
|
||||
batchVtxTexBounds.put(idx4 + 1, uMax);
|
||||
batchVtxTexBounds.put(idx4 + 2, vMin);
|
||||
batchVtxTexBounds.put(idx4 + 3, vMax);
|
||||
vtxWriterIndex++;
|
||||
}
|
||||
|
||||
private void pushUntexRect(float x, float y, float w, float h, int rgba) {
|
||||
final int vtxId = vtxWriterIndex;
|
||||
pushVtx(x, y, rgba, 0, 0);
|
||||
pushVtx(x, y + h, rgba, 0, 0);
|
||||
pushVtx(x + w, y, rgba, 0, 0);
|
||||
pushVtx(x + w, y + h, rgba, 0, 0);
|
||||
pushVtx(x, y, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushVtx(x, y + h, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushVtx(x + w, y, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushVtx(x + w, y + h, rgba, 0, 0, 0, 0, 0, 0);
|
||||
pushQuadIdx(vtxId);
|
||||
}
|
||||
|
||||
@@ -241,6 +265,9 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
int lastActiveProgram;
|
||||
int fontAAModeLast = -1;
|
||||
int fontAAStrengthLast = -1;
|
||||
private void flushBatch() {
|
||||
// Sort&Draw
|
||||
batchCommands.sort(FontDrawCmd.DRAW_ORDER_COMPARATOR);
|
||||
@@ -253,9 +280,23 @@ public class BatchingFontRenderer {
|
||||
GLStateManager.enableTexture();
|
||||
GLStateManager.enableAlphaTest();
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.tryBlendFuncSeparate(blendSrcRGB, blendDstRGB, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.glShadeModel(GL11.GL_FLAT);
|
||||
|
||||
if (FontConfig.fontAAMode != 0) {
|
||||
GL20.glVertexAttribPointer(texBoundAttrLocation, 4, false, 0, batchVtxTexBounds);
|
||||
GL20.glEnableVertexAttribArray(texBoundAttrLocation);
|
||||
lastActiveProgram = GLStateManager.getActiveProgram();
|
||||
GLStateManager.glUseProgram(fontShaderId);
|
||||
if (FontConfig.fontAAMode != fontAAModeLast) {
|
||||
fontAAModeLast = FontConfig.fontAAMode;
|
||||
GL20.glUniform1i(AAMode, FontConfig.fontAAMode);
|
||||
}
|
||||
if (FontConfig.fontAAStrength != fontAAStrengthLast) {
|
||||
fontAAStrengthLast = FontConfig.fontAAStrength;
|
||||
GL20.glUniform1f(AAStrength, FontConfig.fontAAStrength / 120.f);
|
||||
}
|
||||
}
|
||||
GL11.glTexCoordPointer(2, 0, batchVtxTexCoords);
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, batchVtxColors);
|
||||
@@ -284,20 +325,11 @@ public class BatchingFontRenderer {
|
||||
batchIndices.limit(cmd.startVtx + cmd.idxCount);
|
||||
batchIndices.position(cmd.startVtx);
|
||||
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int scaleFactor = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight).getScaleFactor();
|
||||
boolean shouldApplyFilter = cmd.isUnicode && scaleFactor % 2 != 0;
|
||||
|
||||
if (shouldApplyFilter) {
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
|
||||
}
|
||||
GL11.glDrawElements(GL11.GL_TRIANGLES, batchIndices);
|
||||
|
||||
if (shouldApplyFilter) {
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
|
||||
GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
}
|
||||
}
|
||||
if (FontConfig.fontAAMode != 0) {
|
||||
GLStateManager.glUseProgram(lastActiveProgram);
|
||||
GL20.glDisableVertexAttribArray(texBoundAttrLocation);
|
||||
}
|
||||
|
||||
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
@@ -326,17 +358,28 @@ public class BatchingFontRenderer {
|
||||
return (what >= fromInclusive) && (what <= toInclusive);
|
||||
}
|
||||
|
||||
private ResourceLocation getUnicodePageLocation(int page) {
|
||||
final ResourceLocation lookup = unicodePageLocations[page];
|
||||
if (lookup == null) {
|
||||
final ResourceLocation rl = new ResourceLocation(String.format(
|
||||
"textures/font/unicode_page_%02x.png",
|
||||
page));
|
||||
unicodePageLocations[page] = rl;
|
||||
return rl;
|
||||
} else {
|
||||
return lookup;
|
||||
}
|
||||
public boolean forceDefaults() {
|
||||
return this.isSGA || this.isSplash;
|
||||
}
|
||||
|
||||
public float getGlyphScaleX() {
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale * Math.pow(2, FontConfig.glyphAspect)) * (FontStrategist.customFontInUse ? 1.5f : 1);
|
||||
}
|
||||
|
||||
public float getGlyphScaleY() {
|
||||
return forceDefaults() ? 1 : (float) (FontConfig.glyphScale / Math.pow(2, FontConfig.glyphAspect)) * (FontStrategist.customFontInUse ? 1.5f : 1);
|
||||
}
|
||||
|
||||
public float getGlyphSpacing() {
|
||||
return forceDefaults() ? 0 : FontConfig.glyphSpacing;
|
||||
}
|
||||
|
||||
public float getWhitespaceScale() {
|
||||
return forceDefaults() ? 1 : FontConfig.whitespaceScale;
|
||||
}
|
||||
|
||||
public float getShadowOffset() {
|
||||
return forceDefaults() ? 1 : FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
private static final char FORMATTING_CHAR = 167; // §
|
||||
@@ -349,6 +392,9 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
final int shadowColor = (color & 0xfcfcfc) >> 2 | color & 0xff000000;
|
||||
|
||||
FontProviderMC.get(this.isSGA).charWidth = this.charWidth;
|
||||
FontProviderMC.get(this.isSGA).locationFontTexture = this.locationFontTexture;
|
||||
|
||||
this.beginBatch();
|
||||
float curX = anchorX;
|
||||
try {
|
||||
@@ -368,10 +414,14 @@ public class BatchingFontRenderer {
|
||||
boolean curStrikethrough = false;
|
||||
boolean curUnderline = false;
|
||||
|
||||
final float underlineY = anchorY + underlying.FONT_HEIGHT - 1.0f;
|
||||
final float glyphScaleY = getGlyphScaleY();
|
||||
final float heightNorth = anchorY + (underlying.FONT_HEIGHT - 1.0f) * (0.5f - glyphScaleY / 2);
|
||||
final float heightSouth = (underlying.FONT_HEIGHT - 1.0f) * glyphScaleY;
|
||||
|
||||
final float underlineY = heightNorth + (underlying.FONT_HEIGHT - 1.0f) * glyphScaleY;
|
||||
float underlineStartX = 0.0f;
|
||||
float underlineEndX = 0.0f;
|
||||
final float strikethroughY = anchorY + (float) (underlying.FONT_HEIGHT / 2) - 1.0F;
|
||||
final float strikethroughY = heightNorth + ((float) (underlying.FONT_HEIGHT / 2) - 1.0f) * glyphScaleY;
|
||||
float strikethroughStartX = 0.0f;
|
||||
float strikethroughEndX = 0.0f;
|
||||
|
||||
@@ -383,7 +433,7 @@ public class BatchingFontRenderer {
|
||||
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, glyphScaleY, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
underlineStartX = underlineEndX;
|
||||
}
|
||||
@@ -393,7 +443,7 @@ public class BatchingFontRenderer {
|
||||
strikethroughStartX,
|
||||
strikethroughY,
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
glyphScaleY,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
strikethroughStartX = strikethroughEndX;
|
||||
@@ -440,67 +490,27 @@ public class BatchingFontRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
if (curRandom && lutIndex != -1) {
|
||||
int randomReplacementIndex;
|
||||
do {
|
||||
randomReplacementIndex = fontRandom.nextInt(this.charWidth.length);
|
||||
} while (this.charWidth[lutIndex] != this.charWidth[randomReplacementIndex]);
|
||||
|
||||
lutIndex = randomReplacementIndex;
|
||||
chr = MCFONT_CHARS.charAt(lutIndex);
|
||||
if (curRandom) {
|
||||
chr = FontProviderMC.get(this.isSGA).getRandomReplacement(chr);
|
||||
}
|
||||
|
||||
FontProvider fontProvider = FontStrategist.getFontProvider(this, chr, FontConfig.enableCustomFont, unicodeFlag);
|
||||
|
||||
// Check ASCII space, NBSP, NNBSP
|
||||
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
|
||||
curX += 4;
|
||||
curX += 4 * this.getWhitespaceScale();
|
||||
continue;
|
||||
}
|
||||
|
||||
final float uStart;
|
||||
final float vStart;
|
||||
final float xAdvance;
|
||||
final float glyphW;
|
||||
final float uSz;
|
||||
final float vSz;
|
||||
final float uStart = fontProvider.getUStart(chr);
|
||||
final float vStart = fontProvider.getVStart(chr);
|
||||
final float xAdvance = fontProvider.getXAdvance(chr) * getGlyphScaleX();
|
||||
final float glyphW = fontProvider.getGlyphW(chr) * getGlyphScaleX();
|
||||
final float uSz = fontProvider.getUSize(chr);
|
||||
final float vSz = fontProvider.getVSize(chr);
|
||||
final float itOff = curItalic ? 1.0F : 0.0F; // italic offset
|
||||
final float shadowOffset;
|
||||
final ResourceLocation texture;
|
||||
|
||||
if (lutIndex == -1 || unicodeFlag) {
|
||||
if (glyphWidth[chr] == 0) {
|
||||
continue;
|
||||
}
|
||||
// Draw unicode char
|
||||
shadowOffset = 0.5F;
|
||||
final int uniPage = chr / 256;
|
||||
texture = getUnicodePageLocation(uniPage);
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
uStart = ((float) (chr % 16 * 16) + startColumnF + 0.21f) / 256.0f;
|
||||
vStart = ((float) ((chr & 255) / 16 * 16) + 0.21f) / 256.0f;
|
||||
final float chrWidth = endColumnF - startColumnF - 0.02F;
|
||||
glyphW = chrWidth / 2.0f + 1.0f;
|
||||
xAdvance = (endColumnF - startColumnF) / 2.0F + 1.0F;
|
||||
uSz = (chrWidth - 0.42f) / 256.0f;
|
||||
vSz = (16.0f - 0.42f) / 256.0f;
|
||||
|
||||
} else {
|
||||
// Draw "ASCII" char
|
||||
shadowOffset = 1.0F;
|
||||
uStart = ((lutIndex % 16) * 8) / 128.0F;
|
||||
vStart = (float) ((lutIndex / 16) * 8) / 128.0F;
|
||||
xAdvance = this.charWidth[lutIndex];
|
||||
if (xAdvance == 0) {
|
||||
continue;
|
||||
}
|
||||
glyphW = xAdvance - 0.01F;
|
||||
uSz = (glyphW - 1.0F) / 128.0F;
|
||||
vSz = 7.99F / 128.0F;
|
||||
texture = locationFontTexture;
|
||||
}
|
||||
final float shadowOffset = fontProvider.getShadowOffset();
|
||||
final ResourceLocation texture = fontProvider.getTexture(chr);
|
||||
|
||||
final int vtxId = vtxWriterIndex;
|
||||
final int idxId = idxWriterIndex;
|
||||
@@ -508,80 +518,49 @@ public class BatchingFontRenderer {
|
||||
int vtxCount = 0;
|
||||
|
||||
if (enableShadow) {
|
||||
pushVtx(curX + itOff + shadowOffset, anchorY + shadowOffset, curShadowColor, uStart, vStart);
|
||||
pushVtx(
|
||||
curX - itOff + shadowOffset,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart,
|
||||
vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff + shadowOffset,
|
||||
anchorY + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
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;
|
||||
|
||||
if (curBold) {
|
||||
final float shadowOffset2 = 2.0f * shadowOffset;
|
||||
pushVtx(curX + itOff + shadowOffset2, anchorY + shadowOffset, curShadowColor, uStart, vStart);
|
||||
pushVtx(
|
||||
curX - itOff + shadowOffset2,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart,
|
||||
vStart + vSz);
|
||||
pushVtx(
|
||||
curX + glyphW - 1.0F + itOff + shadowOffset2,
|
||||
anchorY + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset2,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
pushVtx(curX + itOff, anchorY, curColor, uStart, vStart);
|
||||
pushVtx(curX - itOff, anchorY + 7.99F, curColor, uStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff, anchorY, curColor, uStart + uSz, vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff, anchorY + 7.99F, curColor, uStart + uSz, vStart + 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;
|
||||
|
||||
if (curBold) {
|
||||
pushVtx(shadowOffset + curX + itOff, anchorY, curColor, uStart, vStart);
|
||||
pushVtx(shadowOffset + curX - itOff, anchorY + 7.99F, curColor, uStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F + itOff, anchorY, curColor, uStart + uSz, vStart);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F - itOff,
|
||||
anchorY + 7.99F,
|
||||
curColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
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;
|
||||
}
|
||||
|
||||
pushDrawCmd(idxId, vtxCount / 2 * 3, texture, chr > 255);
|
||||
curX += xAdvance + (curBold ? shadowOffset : 0.0f);
|
||||
curX += (xAdvance + (curBold ? shadowOffset : 0.0f)) + getGlyphSpacing();
|
||||
underlineEndX = curX;
|
||||
strikethroughEndX = curX;
|
||||
}
|
||||
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, glyphScaleY, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
}
|
||||
if (curStrikethrough && strikethroughStartX != strikethroughEndX) {
|
||||
@@ -590,7 +569,7 @@ public class BatchingFontRenderer {
|
||||
strikethroughStartX,
|
||||
strikethroughY,
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
glyphScaleY,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
}
|
||||
@@ -601,4 +580,25 @@ public class BatchingFontRenderer {
|
||||
return curX + (enableShadow ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
public float getCharWidthFine(char chr) {
|
||||
if (chr == FORMATTING_CHAR) { return -1; }
|
||||
|
||||
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
|
||||
return 4 * this.getWhitespaceScale();
|
||||
}
|
||||
|
||||
FontProvider fp = FontStrategist.getFontProvider(this, chr, FontConfig.enableCustomFont, underlying.getUnicodeFlag());
|
||||
|
||||
return fp.getXAdvance(chr) * this.getGlyphScaleX();
|
||||
}
|
||||
|
||||
public void overrideBlendFunc(int srcRgb, int dstRgb) {
|
||||
blendSrcRGB = srcRgb;
|
||||
blendDstRGB = dstRgb;
|
||||
}
|
||||
|
||||
public void resetBlendFunc() {
|
||||
blendSrcRGB = GL11.GL_SRC_ALPHA;
|
||||
blendDstRGB = GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface FontProvider {
|
||||
|
||||
/**
|
||||
* For use with §k. Should fetch a character of the same width as provided.
|
||||
*/
|
||||
char getRandomReplacement(char chr);
|
||||
boolean isGlyphAvailable(char chr);
|
||||
float getUStart(char chr);
|
||||
float getVStart(char chr);
|
||||
float getXAdvance(char chr);
|
||||
float getGlyphW(char chr);
|
||||
float getUSize(char chr);
|
||||
float getVSize(char chr);
|
||||
float getShadowOffset();
|
||||
ResourceLocation getTexture(char chr);
|
||||
}
|
||||
@@ -0,0 +1,300 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import lombok.Setter;
|
||||
import lombok.Value;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureUtil;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class FontProviderCustom implements FontProvider {
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
public static final String FONT_DIR = "fonts/custom/";
|
||||
static final int ATLAS_SIZE = 128;
|
||||
static final int ATLAS_COUNT = 512;
|
||||
private final byte id; // 0 - primary font, 1 - fallback font
|
||||
private FontAtlas[] fontAtlases = new FontAtlas[ATLAS_COUNT];
|
||||
private float currentFontQuality = FontConfig.customFontQuality;
|
||||
@Setter
|
||||
private Font font;
|
||||
|
||||
private FontProviderCustom(byte id) {
|
||||
this.id = id;
|
||||
Font[] availableFonts = FontStrategist.getAvailableFonts();
|
||||
if (availableFonts.length == 0) {
|
||||
LOGGER.fatal("There seem to be no fonts available on this system! Disabling custom font and throwing an exception in an attempt to restore the session.");
|
||||
FontConfig.enableCustomFont = false;
|
||||
ConfigurationManager.save(FontConfig.class);
|
||||
throw new RuntimeException();
|
||||
}
|
||||
String myFontName = switch (this.id) {
|
||||
case 0 -> FontConfig.customFontNamePrimary;
|
||||
case 1 -> FontConfig.customFontNameFallback;
|
||||
default -> null;
|
||||
};
|
||||
if (Objects.equals(myFontName, "(none)")) {
|
||||
font = null;
|
||||
return;
|
||||
}
|
||||
int fontPos = -1;
|
||||
for (int i = 0; i < availableFonts.length; i++) {
|
||||
if (Objects.equals(myFontName, availableFonts[i].getFontName())) {
|
||||
fontPos = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fontPos == -1) {
|
||||
LOGGER.info("Could not find previously set font \"{}\". ", myFontName);
|
||||
font = null;
|
||||
return;
|
||||
}
|
||||
font = availableFonts[fontPos].deriveFont(currentFontQuality);
|
||||
}
|
||||
private static class InstLoader {
|
||||
static final FontProviderCustom instance0 = new FontProviderCustom((byte)0);
|
||||
static final FontProviderCustom instance1 = new FontProviderCustom((byte)1);
|
||||
}
|
||||
public static FontProviderCustom getPrimary() { return InstLoader.instance0; }
|
||||
public static FontProviderCustom getFallback() { return InstLoader.instance1; }
|
||||
|
||||
public void reloadFont(int fontID) {
|
||||
currentFontQuality = FontConfig.customFontQuality;
|
||||
font = FontStrategist.getAvailableFonts()[fontID].deriveFont(currentFontQuality);
|
||||
|
||||
File[] files = new File(getFontDir()).listFiles();
|
||||
if (files != null) {
|
||||
for (File f : files) {
|
||||
if (!Files.isSymbolicLink(f.toPath())) {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TextureManager tm = Minecraft.getMinecraft().getTextureManager();
|
||||
Map mapTextureObjects = tm.mapTextureObjects;
|
||||
for (int i = 0; i < ATLAS_COUNT; i++) {
|
||||
ResourceLocation key = new ResourceLocation(getAtlasResourceName(i));
|
||||
if (mapTextureObjects.containsKey(key)) {
|
||||
ITextureObject obj = (ITextureObject) mapTextureObjects.get(key);
|
||||
TextureUtil.deleteTexture(obj.getGlTextureId());
|
||||
mapTextureObjects.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
fontAtlases = new FontAtlas[ATLAS_COUNT];
|
||||
}
|
||||
|
||||
private String getFontDir() {
|
||||
return FONT_DIR + "f" + this.id + "/";
|
||||
}
|
||||
|
||||
private String getAtlasFilename(int atlasId) {
|
||||
return "f" + this.id + "p" + atlasId;
|
||||
}
|
||||
|
||||
String getAtlasResourceName(int atlasId) {
|
||||
return "minecraft:angelica_c" + getAtlasFilename(atlasId);
|
||||
}
|
||||
|
||||
String getAtlasFullPath(int atlasId) {
|
||||
return getFontDir() + getAtlasFilename(atlasId) + ".png";
|
||||
}
|
||||
|
||||
@Value
|
||||
private class GlyphData {
|
||||
float uStart;
|
||||
float vStart;
|
||||
float xAdvance;
|
||||
float glyphW;
|
||||
float uSz;
|
||||
float vSz;
|
||||
}
|
||||
|
||||
private class FontAtlas {
|
||||
|
||||
GlyphData[] glyphData = new GlyphData[ATLAS_SIZE];
|
||||
private ResourceLocation texture;
|
||||
private final int id;
|
||||
|
||||
FontAtlas(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
void construct(Font font) {
|
||||
float separator = currentFontQuality / 3f;
|
||||
|
||||
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
g2d.setFont(font);
|
||||
FontMetrics fm = g2d.getFontMetrics();
|
||||
g2d.dispose();
|
||||
int width = 0;
|
||||
int actualChars = 0;
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (font.canDisplay(ch)) {
|
||||
width += (int) (separator + fm.charWidth(ch));
|
||||
actualChars++;
|
||||
}
|
||||
}
|
||||
if (actualChars == 0) {
|
||||
return;
|
||||
}
|
||||
final int atlasTilesX = (int) Math.ceil(Math.sqrt(actualChars) * 1.5f);
|
||||
final int atlasTilesY = (int) Math.ceil((double) actualChars / atlasTilesX);
|
||||
LOGGER.info("constructing custom font atlas (ID {}) of nominal size {} chars, actual: {}, {} rows by {} columns",
|
||||
this.id, ATLAS_SIZE, actualChars, atlasTilesX, atlasTilesY);
|
||||
width = 0;
|
||||
actualChars = 0;
|
||||
int maxRowWidth = 0;
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
if (actualChars % atlasTilesX == 0) {
|
||||
maxRowWidth = Math.max(maxRowWidth, width);
|
||||
width = 0;
|
||||
}
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (font.canDisplay(ch)) {
|
||||
width += (int) (separator + fm.charWidth(ch));
|
||||
actualChars++;
|
||||
}
|
||||
}
|
||||
maxRowWidth = Math.max(maxRowWidth, width);
|
||||
|
||||
final int lineHeight = fm.getHeight();
|
||||
final float desc = fm.getDescent();
|
||||
|
||||
final int imageWidth = (int) (maxRowWidth + separator);
|
||||
final int imageHeight = (int) ((separator + lineHeight) * atlasTilesY + separator);
|
||||
|
||||
image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_ARGB);
|
||||
g2d = image.createGraphics();
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
||||
g2d.setFont(font);
|
||||
fm = g2d.getFontMetrics();
|
||||
|
||||
int tileX = 0, tileY = 0; // position in atlas tiles
|
||||
int imgX = (int) separator; // position in pixels
|
||||
|
||||
for (int i = 0; i < ATLAS_SIZE; i++) {
|
||||
final char ch = (char)(i + ATLAS_SIZE * this.id);
|
||||
if (!font.canDisplay(ch)) { continue; }
|
||||
|
||||
if (tileX >= atlasTilesX) {
|
||||
tileX = 0;
|
||||
imgX = (int) separator;
|
||||
tileY++;
|
||||
}
|
||||
|
||||
final int charWidth = fm.charWidth(ch);
|
||||
final float charAspectRatio = (float) charWidth / lineHeight;
|
||||
final float inset = currentFontQuality / 16;
|
||||
g2d.drawString(Character.toString(ch), imgX, (lineHeight + separator) * (tileY + 1) - desc);
|
||||
final float uStart = (float) (imgX - inset * charAspectRatio) / imageWidth;
|
||||
final float vStart = ((lineHeight + separator) * (tileY + 1) - lineHeight - inset) / imageHeight;
|
||||
final float xAdvance = charAspectRatio * 8 * charWidth / (charWidth + 2 * inset * charAspectRatio);
|
||||
final float glyphW = charAspectRatio * 8 + 1;
|
||||
final float uSz = (float) (charWidth + 2 * inset * charAspectRatio) / imageWidth;
|
||||
final float vSz = (float) (lineHeight + 2 * inset) / imageHeight;
|
||||
glyphData[i] = new GlyphData(uStart, vStart, xAdvance, glyphW, uSz, vSz);
|
||||
imgX += (int) (charWidth + separator);
|
||||
tileX++;
|
||||
}
|
||||
g2d.dispose();
|
||||
try {
|
||||
LOGGER.info("writing custom font atlas texture ({}x{} px) to {}", imageWidth, imageHeight, getAtlasFullPath(this.id));
|
||||
Files.createDirectories(Paths.get(getFontDir()));
|
||||
ImageIO.write(image, "png", new File(getAtlasFullPath(this.id)));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.texture = new ResourceLocation(getAtlasResourceName(this.id));
|
||||
}
|
||||
}
|
||||
|
||||
private FontAtlas getAtlas(char chr) {
|
||||
int id = chr / ATLAS_SIZE;
|
||||
FontAtlas fa = fontAtlases[id];
|
||||
if (fa == null) {
|
||||
fa = new FontAtlas(id);
|
||||
fa.construct(font);
|
||||
}
|
||||
fontAtlases[id] = fa;
|
||||
return fa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlyphAvailable(char chr) {
|
||||
if (font == null) { return false; }
|
||||
return (getAtlas(chr).glyphData[chr % ATLAS_SIZE] != null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getRandomReplacement(char chr) {
|
||||
return chr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUStart(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].uStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVStart(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].vStart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].xAdvance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].glyphW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUSize(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].uSz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVSize(char chr) {
|
||||
return getAtlas(chr).glyphData[chr % ATLAS_SIZE].vSz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowOffset() {
|
||||
return FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
return getAtlas(chr).texture;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
|
||||
import jss.util.RandomXoshiro256StarStar;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public final class FontProviderMC implements FontProvider {
|
||||
|
||||
/**
|
||||
* The full list of characters present in the default Minecraft font, excluding the Unicode font
|
||||
*/
|
||||
@SuppressWarnings("UnnecessaryUnicodeEscape")
|
||||
private static final String MCFONT_CHARS = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u2302\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000";
|
||||
|
||||
private FontProviderMC() {}
|
||||
private static class InstLoader {
|
||||
static final FontProviderMC instance = new FontProviderMC();
|
||||
static final FontProviderMC instanceSGA = new FontProviderMC();
|
||||
}
|
||||
public static FontProviderMC get(boolean isSGA) {
|
||||
return (isSGA ? InstLoader.instanceSGA : InstLoader.instance);
|
||||
}
|
||||
|
||||
private static final Char2ShortOpenHashMap MCFONT_ASCII_MAP = new Char2ShortOpenHashMap();
|
||||
ResourceLocation locationFontTexture = null;
|
||||
private final RandomXoshiro256StarStar fontRandom = new RandomXoshiro256StarStar();
|
||||
public int[] charWidth;
|
||||
|
||||
static {
|
||||
for (short i = 0; i < MCFONT_CHARS.length(); i++) {
|
||||
MCFONT_ASCII_MAP.put(MCFONT_CHARS.charAt(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
public int lookupMcFontPosition(char ch) {
|
||||
if (isGlyphAvailable(ch)) {
|
||||
return MCFONT_ASCII_MAP.get(ch);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlyphAvailable(char chr) {
|
||||
return MCFONT_ASCII_MAP.containsKey(chr);
|
||||
}
|
||||
|
||||
public char getRandomReplacement(char chr){
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
if (lutIndex != -1) {
|
||||
int randomReplacementIndex;
|
||||
do {
|
||||
randomReplacementIndex = fontRandom.nextInt(this.charWidth.length);
|
||||
} while (this.charWidth[lutIndex] != this.charWidth[randomReplacementIndex]);
|
||||
|
||||
lutIndex = randomReplacementIndex;
|
||||
return MCFONT_CHARS.charAt(lutIndex);
|
||||
}
|
||||
return chr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUStart(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return ((lutIndex % 16) * 8) / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVStart(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return (float) ((lutIndex / 16) * 8) / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return charWidth[lutIndex];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return charWidth[lutIndex] - 0.01F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUSize(char chr) {
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
return (charWidth[lutIndex] - 1.01F) / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVSize(char chr) {
|
||||
return 7.99F / 128.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowOffset() {
|
||||
return FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
return locationFontTexture;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public final class FontProviderUnicode implements FontProvider {
|
||||
|
||||
private FontProviderUnicode() {}
|
||||
private static class InstLoader { static final FontProviderUnicode instance = new FontProviderUnicode(); }
|
||||
public static FontProviderUnicode get() { return FontProviderUnicode.InstLoader.instance; }
|
||||
|
||||
private static final ResourceLocation[] unicodePageLocations = new ResourceLocation[256];
|
||||
public byte[] glyphWidth;
|
||||
|
||||
private ResourceLocation getUnicodePageLocation(int page) {
|
||||
final ResourceLocation lookup = unicodePageLocations[page];
|
||||
if (lookup == null) {
|
||||
final ResourceLocation rl = new ResourceLocation(String.format(
|
||||
"textures/font/unicode_page_%02x.png",
|
||||
page));
|
||||
unicodePageLocations[page] = rl;
|
||||
return rl;
|
||||
} else {
|
||||
return lookup;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGlyphAvailable(char chr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getRandomReplacement(char chr) {
|
||||
return chr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUStart(char chr) {
|
||||
final float startColumnF = (float)(this.glyphWidth[chr] >>> 4);
|
||||
return ((float) (chr % 16 * 16) + startColumnF + 0.21f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVStart(char chr) {
|
||||
return ((float) ((chr & 255) / 16 * 16) + 0.21f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getXAdvance(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
return (endColumnF - startColumnF) / 2.0F + 1.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphW(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
final float chrWidth = endColumnF - startColumnF - 0.02F;
|
||||
return chrWidth / 2.0f + 1.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getUSize(char chr) {
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
final float chrWidth = endColumnF - startColumnF - 0.02F;
|
||||
return (chrWidth - 0.42f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVSize(char chr) {
|
||||
return (16.0f - 0.42f) / 256.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowOffset() {
|
||||
return FontConfig.fontShadowOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(char chr) {
|
||||
final int uniPage = chr / 256;
|
||||
return getUnicodePageLocation(uniPage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import com.google.common.collect.HashMultiset;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ResourceAccessor;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.DefaultResourcePack;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.io.File;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class FontStrategist {
|
||||
|
||||
@Getter
|
||||
private static final Font[] availableFonts;
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
public static boolean customFontInUse;
|
||||
|
||||
static {
|
||||
// get available fonts without duplicates (250 copies of dialog.plain need not apply)
|
||||
Font[] availableFontsDirty = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
|
||||
HashMap<String, Font> fontSet = new HashMap<>();
|
||||
HashMultiset<String> duplicates = HashMultiset.create(); // for debugging
|
||||
|
||||
for (Font font : availableFontsDirty) {
|
||||
String fontName = font.getFontName();
|
||||
if (fontSet.containsKey(fontName)) {
|
||||
duplicates.add(fontName);
|
||||
} else {
|
||||
fontSet.put(fontName, font);
|
||||
}
|
||||
}
|
||||
|
||||
if (!duplicates.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder(duplicates.size() + " duplicate font(s) found in the list reported by Java: ");
|
||||
for (Iterator<String> iter = duplicates.stream().distinct().iterator(); iter.hasNext(); ) {
|
||||
String dupe = iter.next();
|
||||
sb.append(duplicates.count(dupe)).append("x ").append(dupe);
|
||||
if (iter.hasNext()) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
sb.append(". Some fonts may be missing from the font selection menu.");
|
||||
LOGGER.warn(sb.toString());
|
||||
}
|
||||
|
||||
availableFonts = fontSet.values().stream().sorted(Comparator.comparing(Font::getFontName)).toArray(Font[]::new);
|
||||
|
||||
// create and add the resource pack that provides fonts
|
||||
HashMap<String, File> packMap = new HashMap<>();
|
||||
for (int i = 0; i < FontProviderCustom.ATLAS_COUNT; i++) {
|
||||
packMap.put(FontProviderCustom.getPrimary().getAtlasResourceName(i), new File(FontProviderCustom.getPrimary().getAtlasFullPath(i)));
|
||||
packMap.put(FontProviderCustom.getFallback().getAtlasResourceName(i), new File(FontProviderCustom.getFallback().getAtlasFullPath(i)));
|
||||
}
|
||||
|
||||
DefaultResourcePack fontResourcePack = new DefaultResourcePack(packMap);
|
||||
List defaultResourcePacks = ((ResourceAccessor) Minecraft.getMinecraft()).angelica$getDefaultResourcePacks();
|
||||
defaultResourcePacks.add(fontResourcePack);
|
||||
Minecraft.getMinecraft().refreshResources();
|
||||
|
||||
// determine if a custom font is in use based on config values
|
||||
boolean primaryFontFound = false;
|
||||
boolean fallbackFontFound = false;
|
||||
for (Font availableFont : availableFonts) {
|
||||
if (Objects.equals(FontConfig.customFontNamePrimary, availableFont.getFontName())) {
|
||||
primaryFontFound = true;
|
||||
break;
|
||||
}
|
||||
if (Objects.equals(FontConfig.customFontNameFallback, availableFont.getFontName())) {
|
||||
fallbackFontFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
customFontInUse = (FontConfig.enableCustomFont && (primaryFontFound || fallbackFontFound));
|
||||
}
|
||||
|
||||
/**
|
||||
Lets you get a FontProvider per char while respecting font priority and fallbacks, the unicode flag, whether or not
|
||||
SGA is on, if we're in a splash screen, if a font can even display a character in the first place, etc.
|
||||
*/
|
||||
public static FontProvider getFontProvider(BatchingFontRenderer me, char chr, boolean customFontEnabled, boolean forceUnicode) {
|
||||
if (me.isSGA && FontProviderMC.get(true).isGlyphAvailable(chr)) {
|
||||
return FontProviderMC.get(true);
|
||||
}
|
||||
if (customFontEnabled && !me.isSplash) {
|
||||
FontProvider fp;
|
||||
fp = FontProviderCustom.getPrimary();
|
||||
if (fp.isGlyphAvailable(chr)) { return fp; }
|
||||
fp = FontProviderCustom.getFallback();
|
||||
if (fp.isGlyphAvailable(chr)) { return fp; }
|
||||
return FontProviderUnicode.get();
|
||||
} else {
|
||||
if (!forceUnicode && FontProviderMC.get(false).isGlyphAvailable(chr)) {
|
||||
return FontProviderMC.get(false);
|
||||
} else {
|
||||
return FontProviderUnicode.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void reloadCustomFontProviders() {
|
||||
FontProviderCustom.getPrimary().setFont(null);
|
||||
FontProviderCustom.getFallback().setFont(null);
|
||||
boolean primaryFontFound = false;
|
||||
boolean fallbackFontFound = false;
|
||||
for (int i = 0; i < availableFonts.length; i++) {
|
||||
if (Objects.equals(FontConfig.customFontNamePrimary, availableFonts[i].getFontName())) {
|
||||
FontProviderCustom.getPrimary().reloadFont(i);
|
||||
primaryFontFound = true;
|
||||
}
|
||||
if (Objects.equals(FontConfig.customFontNameFallback, availableFonts[i].getFontName())) {
|
||||
FontProviderCustom.getFallback().reloadFont(i);
|
||||
fallbackFontFound = true;
|
||||
}
|
||||
if (primaryFontFound && fallbackFontFound) { break; }
|
||||
}
|
||||
customFontInUse = (FontConfig.enableCustomFont && (primaryFontFound || fallbackFontFound));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigException;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizons.angelica.client.font.FontStrategist;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import net.coderbot.iris.gui.element.widget.IrisButton;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
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 org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FontConfigScreen extends GuiScreen {
|
||||
|
||||
private static final Font[] availableFonts = FontStrategist.getAvailableFonts();
|
||||
private final GuiScreen parent;
|
||||
private final String title;
|
||||
private final String searchPrompt;
|
||||
private String currentPrimaryFontName;
|
||||
private String currentFallbackFontName;
|
||||
private FontList fontList;
|
||||
private int selectedPrimaryFontListPos = -1;
|
||||
private int selectedFallbackFontListPos = -1;
|
||||
private ArrayList<Font> displayedFonts;
|
||||
private GuiTextField searchBox;
|
||||
|
||||
public FontConfigScreen(GuiScreen parent) {
|
||||
this.title = I18n.format("options.angelica.fontconfig.title");
|
||||
this.searchPrompt = I18n.format("options.angelica.fontconfig.searchprompt");
|
||||
this.parent = parent;
|
||||
this.currentPrimaryFontName = FontConfig.customFontNamePrimary;
|
||||
this.currentFallbackFontName = FontConfig.customFontNameFallback;
|
||||
this.displayedFonts = new ArrayList<>(Arrays.asList(availableFonts));
|
||||
for (int i = 0; i < availableFonts.length; i++) {
|
||||
if (Objects.equals(this.currentPrimaryFontName, availableFonts[i].getFontName())) {
|
||||
selectedPrimaryFontListPos = i;
|
||||
}
|
||||
if (Objects.equals(this.currentFallbackFontName, availableFonts[i].getFontName())) {
|
||||
selectedFallbackFontListPos = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
initButtons();
|
||||
}
|
||||
|
||||
private void initButtons() {
|
||||
this.buttonList.add(new IrisButton(this.width / 2 - 81 - 165, this.height - 20 - 7, 162, 20,
|
||||
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,
|
||||
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,
|
||||
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"));
|
||||
}
|
||||
|
||||
private void onClose() {
|
||||
applyChanges(true);
|
||||
this.mc.displayGuiScreen(parent);
|
||||
}
|
||||
|
||||
private void applyChanges(boolean finalApply) {
|
||||
int pos;
|
||||
pos = selectedPrimaryFontListPos;
|
||||
if (pos >= 0 && pos < displayedFonts.size()) {
|
||||
FontConfig.customFontNamePrimary = displayedFonts.get(pos).getFontName();
|
||||
}
|
||||
pos = selectedFallbackFontListPos;
|
||||
if (pos >= 0 && pos < displayedFonts.size()) {
|
||||
FontConfig.customFontNameFallback = displayedFonts.get(pos).getFontName();
|
||||
}
|
||||
|
||||
FontStrategist.reloadCustomFontProviders();
|
||||
|
||||
if (finalApply) {
|
||||
ConfigurationManager.save(FontConfig.class);
|
||||
}
|
||||
}
|
||||
|
||||
private void resetValues(IrisButton button) {
|
||||
try {
|
||||
ConfigurationManager.getConfigElements(FontConfig.class).forEach(elem -> elem.set(elem.getDefault()));
|
||||
} catch (ConfigException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
selectedPrimaryFontListPos = -1;
|
||||
selectedFallbackFontListPos = -1;
|
||||
FontStrategist.customFontInUse = false;
|
||||
super.buttonList.clear();
|
||||
this.initButtons();
|
||||
}
|
||||
|
||||
private void toggleCustomFont(IrisButton button) {
|
||||
FontConfig.enableCustomFont = !FontConfig.enableCustomFont;
|
||||
applyChanges(false);
|
||||
button.displayString = FontConfig.enableCustomFont ?
|
||||
I18n.format("options.angelica.fontconfig.disable_custom_font") :
|
||||
I18n.format("options.angelica.fontconfig.enable_custom_font");
|
||||
}
|
||||
|
||||
private int qualityLast = FontConfig.customFontQuality;
|
||||
|
||||
private void setFontQuality(float quality) {
|
||||
FontConfig.customFontQuality = (int) quality;
|
||||
if (qualityLast != (int) quality) {
|
||||
applyChanges(false);
|
||||
}
|
||||
qualityLast = (int) quality;
|
||||
}
|
||||
|
||||
private String fontAAModeFormat(float AAmode) {
|
||||
return switch ((int) AAmode) {
|
||||
case 2 -> I18n.format("options.angelica.fontconfig.aamode.aa_16x");
|
||||
case 1 -> I18n.format("options.angelica.fontconfig.aamode.aa_4x");
|
||||
default -> I18n.format("options.angelica.fontconfig.aamode.aa_none");
|
||||
};
|
||||
}
|
||||
|
||||
private float lastMouseX = 0;
|
||||
private float lastMouseY = 0;
|
||||
private long lastStillTime = 0;
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
super.drawDefaultBackground();
|
||||
fontList.drawScreen(mouseX, mouseY, delta);
|
||||
searchBox.drawTextBox();
|
||||
// I bet you thought this was drawn inside the search box, not on top of it.
|
||||
if (!this.searchBox.isFocused() && this.searchBox.getText().isEmpty()) {
|
||||
this.drawCenteredString(this.fontRendererObj, this.searchPrompt,
|
||||
this.searchBox.xPosition + this.fontRendererObj.getStringWidth(this.searchPrompt) / 2 + 4,
|
||||
this.searchBox.yPosition + this.searchBox.height / 2 - 4, 0xFFFFFF);
|
||||
}
|
||||
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);
|
||||
super.drawScreen(mouseX, mouseY, delta);
|
||||
|
||||
for (GuiButton guiButton : buttonList) {
|
||||
if (!(guiButton instanceof SliderClone slider)) { continue; }
|
||||
final int top = slider.yPosition;
|
||||
final int bot = slider.yPosition + slider.height;
|
||||
final int left = slider.xPosition;
|
||||
final int right = slider.xPosition + slider.width;
|
||||
if (mouseY < top || mouseY >= bot || mouseX < left || mouseX >= right) { continue; }
|
||||
if (mouseX == lastMouseX && mouseY == lastMouseY) {
|
||||
if (lastStillTime == 0) {
|
||||
lastStillTime = System.currentTimeMillis();
|
||||
}
|
||||
if (lastStillTime + 500L < System.currentTimeMillis()) {
|
||||
displayTooltip(mouseX, mouseY, slider.tooltipKey);
|
||||
}
|
||||
} else {
|
||||
lastStillTime = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
lastMouseX = mouseX;
|
||||
lastMouseY = mouseY;
|
||||
}
|
||||
|
||||
private void displayTooltip(int x, int y, String langKey) {
|
||||
List<String> lines = this.fontRendererObj.listFormattedStringToWidth(I18n.format(langKey), this.width / 2);
|
||||
this.drawHoveringText(lines, x, y, this.fontRendererObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton guiButton) {
|
||||
if (guiButton.enabled) {
|
||||
if (guiButton instanceof IrisButton irisButton) {
|
||||
irisButton.onPress();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char typedChar, int keyCode) {
|
||||
if (this.searchBox.isFocused()) {
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
this.searchBox.setFocused(false);
|
||||
}
|
||||
this.searchBox.textboxKeyTyped(typedChar, keyCode);
|
||||
this.displayedFonts = filterFonts(this.searchBox.getText().toLowerCase());
|
||||
}
|
||||
if (keyCode == Keyboard.KEY_ESCAPE) {
|
||||
this.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.searchBox.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
this.fontList.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen() {
|
||||
this.searchBox.updateCursorCounter();
|
||||
}
|
||||
|
||||
// this could be more efficient, but it's good enough as is
|
||||
private ArrayList<Font> filterFonts(String search) {
|
||||
ArrayList<Font> results;
|
||||
if (search == null || search.isEmpty()) {
|
||||
results = new ArrayList<>(Arrays.asList(availableFonts));
|
||||
} else {
|
||||
results = Arrays.stream(availableFonts).filter((font -> font.getFontName().toLowerCase().contains(search))).collect(Collectors.toCollection(ArrayList::new));
|
||||
}
|
||||
|
||||
selectedPrimaryFontListPos = -1;
|
||||
selectedFallbackFontListPos = -1;
|
||||
for (int i = 0; i < results.size(); i++) {
|
||||
if (Objects.equals(currentPrimaryFontName, results.get(i).getFontName())) {
|
||||
selectedPrimaryFontListPos = i;
|
||||
}
|
||||
if (Objects.equals(currentFallbackFontName, results.get(i).getFontName())) {
|
||||
selectedFallbackFontListPos = i;
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
class FontList extends GuiSlot {
|
||||
|
||||
public FontList() {
|
||||
super(FontConfigScreen.this.mc, FontConfigScreen.this.width, FontConfigScreen.this.height, 52, FontConfigScreen.this.height - 100, 18);
|
||||
}
|
||||
|
||||
private void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
if (mouseY < this.top || mouseY > this.bottom) { return; }
|
||||
|
||||
int listLeftBound = this.width / 2 - this.getListWidth() / 2;
|
||||
int listRightBound = this.width / 2 + this.getListWidth() / 2;
|
||||
if (mouseX < listLeftBound || mouseX > listRightBound) { return; }
|
||||
|
||||
int mousePosInList = mouseY - this.top - this.headerPadding + (int)this.amountScrolled - 4;
|
||||
int slotIndex = mousePosInList / this.slotHeight;
|
||||
if (slotIndex < 0 || slotIndex >= this.getSize()) { return; }
|
||||
|
||||
if (mouseButton == 0) {
|
||||
onElemClicked(slotIndex, false);
|
||||
} else if (mouseButton == 1) {
|
||||
onElemClicked(slotIndex, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onElemClicked(int index, boolean rightClick) {
|
||||
if (!rightClick) {
|
||||
selectedPrimaryFontListPos = index;
|
||||
currentPrimaryFontName = displayedFonts.get(index).getFontName();
|
||||
} else {
|
||||
selectedFallbackFontListPos = index;
|
||||
currentFallbackFontName = displayedFonts.get(index).getFontName();
|
||||
}
|
||||
applyChanges(false);
|
||||
}
|
||||
|
||||
protected boolean isSelected(int index) {
|
||||
return (index == selectedPrimaryFontListPos || index == selectedFallbackFontListPos);
|
||||
}
|
||||
|
||||
protected int getSize() {
|
||||
return displayedFonts.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentHeight() {
|
||||
return this.getSize() * 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getScrollBarX() {
|
||||
return this.width * 11 / 12 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getListWidth() {
|
||||
return this.width * 2 / 3;
|
||||
}
|
||||
|
||||
// see onElemClicked for the proper version that supports right-clicking
|
||||
protected void elementClicked(int index, boolean doubleClicked, int mouseX, int mouseY) {}
|
||||
|
||||
protected void drawBackground() {
|
||||
drawDefaultBackground();
|
||||
}
|
||||
|
||||
protected void drawSlot(int index, int x, int y, int p_148126_4_, Tessellator tessellator, int p_148126_6_, int p_148126_7_) {
|
||||
int color = 0xffffff;
|
||||
if (index == selectedPrimaryFontListPos) {
|
||||
color &= 0xffff55;
|
||||
}
|
||||
if (index == selectedFallbackFontListPos) {
|
||||
color &= 0x55ffff;
|
||||
}
|
||||
drawCenteredString(fontRendererObj, displayedFonts.get(index).getFontName(), this.width / 2, y + 1, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class SliderClone extends GuiButton {
|
||||
|
||||
private final Function<Float, String> displayStringFormatter;
|
||||
private final Consumer<Float> valueSetter;
|
||||
private final Option option;
|
||||
private float sliderPercentage;
|
||||
public final String tooltipKey;
|
||||
public boolean mouseDragging;
|
||||
|
||||
@AllArgsConstructor
|
||||
public static class Option {
|
||||
float min;
|
||||
float max;
|
||||
float step;
|
||||
|
||||
float denormalize(float alpha) {
|
||||
float lerp = min * (1 - alpha) + max * alpha;
|
||||
return Math.round(lerp / step) * step;
|
||||
}
|
||||
float normalize(float value) {
|
||||
return (value - min) / (max - min);
|
||||
}
|
||||
}
|
||||
|
||||
public SliderClone(int x, int y, int width, int height, Option option, float initialValue,
|
||||
Consumer<Float> setter, Function<Float, String> formatter, String tooltipKey) {
|
||||
super(0, x, y, width, height, "");
|
||||
this.option = option;
|
||||
this.sliderPercentage = option.normalize(initialValue);
|
||||
this.displayString = formatter.apply(initialValue);
|
||||
this.valueSetter = setter;
|
||||
this.displayStringFormatter = formatter;
|
||||
this.tooltipKey = 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.
|
||||
*/
|
||||
public int getHoverState(boolean mouseOver) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the mouse button is dragged. Equivalent of MouseListener.mouseDragged(MouseEvent e).
|
||||
*/
|
||||
protected void mouseDragged(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (this.visible) {
|
||||
if (this.mouseDragging) {
|
||||
this.sliderPercentage = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
|
||||
|
||||
if (this.sliderPercentage < 0.0F) {
|
||||
this.sliderPercentage = 0.0F;
|
||||
}
|
||||
|
||||
if (this.sliderPercentage > 1.0F) {
|
||||
this.sliderPercentage = 1.0F;
|
||||
}
|
||||
|
||||
float f = this.option.denormalize(this.sliderPercentage);
|
||||
valueSetter.accept(f);
|
||||
this.sliderPercentage = this.option.normalize(f);
|
||||
this.displayString = displayStringFormatter.apply(f);
|
||||
}
|
||||
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
this.drawTexturedModalRect(this.xPosition + (int)(this.sliderPercentage * (float)(this.width - 8)), this.yPosition, 0, 66, 4, 20);
|
||||
this.drawTexturedModalRect(this.xPosition + (int)(this.sliderPercentage * (float)(this.width - 8)) + 4, this.yPosition, 196, 66, 4, 20);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the mouse has been pressed on this control. Equivalent of MouseListener.mousePressed(MouseEvent e).
|
||||
*/
|
||||
public boolean mousePressed(Minecraft mc, int mouseX, int mouseY) {
|
||||
if (super.mousePressed(mc, mouseX, mouseY)) {
|
||||
this.sliderPercentage = (float)(mouseX - (this.xPosition + 4)) / (float)(this.width - 8);
|
||||
|
||||
if (this.sliderPercentage < 0.0F) {
|
||||
this.sliderPercentage = 0.0F;
|
||||
}
|
||||
|
||||
if (this.sliderPercentage > 1.0F) {
|
||||
this.sliderPercentage = 1.0F;
|
||||
}
|
||||
|
||||
float f = this.option.denormalize(this.sliderPercentage);
|
||||
valueSetter.accept(f);
|
||||
this.sliderPercentage = this.option.normalize(f);
|
||||
this.displayString = displayStringFormatter.apply(f);
|
||||
this.mouseDragging = true;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired when the mouse button is released. Equivalent of MouseListener.mouseReleased(MouseEvent e).
|
||||
*/
|
||||
public void mouseReleased(int mouseX, int mouseY) {
|
||||
this.mouseDragging = false;
|
||||
}
|
||||
}
|
||||
@@ -26,17 +26,7 @@ public class BlockError extends Block {
|
||||
public BlockError() {
|
||||
super(Material.rock);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||
if (event.map.getTextureType() == 0) {
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
icons[i] = event.map.registerIcon("angelica:error_block_" + i);
|
||||
}
|
||||
}
|
||||
MinecraftForge.EVENT_BUS.register(new EventHandler());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,4 +35,15 @@ public class BlockError extends Block {
|
||||
return meta >= 0 && meta < icons.length ? icons[meta] : null;
|
||||
}
|
||||
|
||||
public static class EventHandler{
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||
if (event.map.getTextureType() == 0) {
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
icons[i] = event.map.registerIcon("angelica:error_block_" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,15 +143,15 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableZoom;
|
||||
|
||||
@Config.Comment("Optimizes in-world item rendering [Experimental]")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.Comment("Optimizes in-world item rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeInWorldItemRendering_WIP;
|
||||
public static boolean optimizeInWorldItemRendering;
|
||||
|
||||
@Config.Comment("Max amount of display lists to cache for optimized item rendering. Higher number will use more VRAM")
|
||||
@Config.DefaultInt(256)
|
||||
@Config.RangeInt(min = 64, max = 1024)
|
||||
public static int itemRendererDisplayListCacheSize;
|
||||
@Config.Comment("Upper limit for the amount of VBO's to cache for optimized item rendering. Higher number can potentially use more VRAM.")
|
||||
@Config.DefaultInt(512)
|
||||
@Config.RangeInt(min = 256, max = 1024)
|
||||
public static int itemRendererCacheSize;
|
||||
|
||||
@Config.Comment("Render distance for the spinning mob inside mod spawners")
|
||||
@Config.DefaultDouble(16D)
|
||||
|
||||
@@ -6,6 +6,12 @@ import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class AngelicaGuiConfig extends SimpleGuiConfig {
|
||||
public AngelicaGuiConfig(GuiScreen parent) throws ConfigException {
|
||||
super(parent, AngelicaConfig.class, "angelica", "Angelica");
|
||||
super(parent,
|
||||
"angelica",
|
||||
"Angelica",
|
||||
true,
|
||||
AngelicaConfig.class,
|
||||
FontConfig.class
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.Config;
|
||||
|
||||
@Config(modid = "angelica", category = "customfont")
|
||||
public class FontConfig {
|
||||
@Config.Comment("Whether or not to use custom fonts when drawing text.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableCustomFont;
|
||||
|
||||
@Config.Comment("Name of the primary custom font. Best not to set it from here.")
|
||||
@Config.DefaultString("(none)")
|
||||
public static String customFontNamePrimary;
|
||||
|
||||
@Config.Comment("Name of the fallback custom font. Best not to set it from here.")
|
||||
@Config.DefaultString("(none)")
|
||||
public static String customFontNameFallback;
|
||||
|
||||
@Config.Comment("The quality at which custom fonts are rendered, making them less pixelated but increasing memory usage.")
|
||||
@Config.DefaultInt(30)
|
||||
@Config.RangeInt(min = 6, max = 72)
|
||||
public static int customFontQuality;
|
||||
|
||||
@Config.Comment("Controls the distance at which the font's shadow is drawn.")
|
||||
@Config.DefaultFloat(1F)
|
||||
@Config.RangeFloat(min = 0F, max = 2F)
|
||||
public static float fontShadowOffset;
|
||||
|
||||
@Config.Comment("Influences the aspect ratio of each glyph.")
|
||||
@Config.DefaultFloat(0F)
|
||||
@Config.RangeFloat(min = -1F, max = 1F)
|
||||
public static float glyphAspect;
|
||||
|
||||
@Config.Comment("Scale of each glyph, whitespace excluded.")
|
||||
@Config.DefaultFloat(1F)
|
||||
@Config.RangeFloat(min = 0.1F, max = 3F)
|
||||
public static float glyphScale;
|
||||
|
||||
@Config.Comment("Whitespace scale.")
|
||||
@Config.DefaultFloat(1F)
|
||||
@Config.RangeFloat(min = 0.1F, max = 3F)
|
||||
public static float whitespaceScale;
|
||||
|
||||
@Config.Comment("Adds extra spacing between glyphs.")
|
||||
@Config.DefaultFloat(0F)
|
||||
@Config.RangeFloat(min = -2F, max = 2F)
|
||||
public static float glyphSpacing;
|
||||
|
||||
@Config.Comment("Controls font antialiasing. 0 = none, 1 = 4x MSAA, 2 = 16x MSAA.")
|
||||
@Config.DefaultInt(2)
|
||||
@Config.RangeInt(min = 0, max = 2)
|
||||
public static int fontAAMode;
|
||||
|
||||
@Config.Comment("Affects font antialiasing sample spacing. Higher values increase blur.")
|
||||
@Config.DefaultInt(7)
|
||||
@Config.RangeInt(min = 1, max = 24)
|
||||
public static int fontAAStrength;
|
||||
}
|
||||
@@ -43,6 +43,20 @@ public class Feature {
|
||||
}
|
||||
|
||||
private static final Map<Integer, Set<IStateStack<?>>> attribToFeatures = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Helper method to add all texture gen states (S, T, R, Q) for all texture units to a collection.
|
||||
* Used by both GL_ENABLE_BIT and GL_TEXTURE_BIT.
|
||||
*/
|
||||
private static void addTextureGenStates(Set<IStateStack<?>> collection) {
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
collection.add(GLStateManager.textures.getTexGenSStates(i));
|
||||
collection.add(GLStateManager.textures.getTexGenTStates(i));
|
||||
collection.add(GLStateManager.textures.getTexGenRStates(i));
|
||||
collection.add(GLStateManager.textures.getTexGenQStates(i));
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
attribToFeatures.put(GL11.GL_COLOR_BUFFER_BIT, ImmutableSet.of(
|
||||
GLStateManager.alphaTest // GL_ALPHA_TEST enable bit
|
||||
@@ -51,10 +65,10 @@ public class Feature {
|
||||
, GLStateManager.blendState // Blending source and destination functions
|
||||
// Constant blend color
|
||||
// Blending equation
|
||||
// GL_DITHER enable bit
|
||||
// GL_DRAW_BUFFER setting
|
||||
// GL_COLOR_LOGIC_OP enable bit
|
||||
// GL_INDEX_LOGIC_OP enable bit
|
||||
, GLStateManager.colorLogicOpState // GL_COLOR_LOGIC_OP enable bit
|
||||
, GLStateManager.ditherState // GL_DITHER enable bit
|
||||
, GLStateManager.drawBuffer // GL_DRAW_BUFFER setting
|
||||
, GLStateManager.indexLogicOpState // GL_INDEX_LOGIC_OP enable bit
|
||||
// Logic op function
|
||||
, GLStateManager.colorMask // Color-mode and index-mode writemasks
|
||||
, GLStateManager.clearColor // Color-mode and index-mode clear values
|
||||
@@ -80,14 +94,15 @@ public class Feature {
|
||||
|
||||
final HashSet<IStateStack<?>> enableBits = new HashSet<>(ImmutableSet.of(
|
||||
GLStateManager.alphaTest // GL_ALPHA_TEST flag
|
||||
// GL_AUTO_NORMAL flag
|
||||
, GLStateManager.autoNormalState // GL_AUTO_NORMAL flag
|
||||
, GLStateManager.blendMode // GL_BLEND flag
|
||||
// Enable bits for the user-definable clipping planes
|
||||
, GLStateManager.colorLogicOpState // GL_COLOR_LOGIC_OP flag
|
||||
, GLStateManager.colorMaterial // GL_COLOR_MATERIAL
|
||||
, GLStateManager.cullState // GL_CULL_FACE flag
|
||||
, GLStateManager.depthTest // GL_DEPTH_TEST flag
|
||||
// GL_DITHER flag
|
||||
, GLStateManager.ditherState // GL_DITHER flag
|
||||
, GLStateManager.fogMode // GL_FOG flag
|
||||
, GLStateManager.indexLogicOpState // GL_INDEX_LOGIC_OP flag
|
||||
, GLStateManager.lightStates[0] // GL_LIGHT0
|
||||
, GLStateManager.lightStates[1] // GL_LIGHT1
|
||||
, GLStateManager.lightStates[2] // GL_LIGHT2
|
||||
@@ -97,36 +112,57 @@ public class Feature {
|
||||
, GLStateManager.lightStates[6] // GL_LIGHT6
|
||||
, GLStateManager.lightStates[7] // GL_LIGHT7
|
||||
, GLStateManager.lightingState // GL_LIGHTING flag
|
||||
// GL_LINE_SMOOTH flag
|
||||
// GL_LINE_STIPPLE flag
|
||||
// GL_INDEX_LOGIC_OP flag
|
||||
// GL_COLOR_LOGIC_OP flag
|
||||
// GL_MAP1_x where x is a map type
|
||||
// GL_MAP2_x where x is a map type
|
||||
// GL_MULTISAMPLE flag
|
||||
// GL_NORMALIZE flag
|
||||
// GL_POINT_SMOOTH flag
|
||||
// GL_POLYGON_OFFSET_LINE flag
|
||||
// GL_POLYGON_OFFSET_FILL flag
|
||||
// GL_POLYGON_OFFSET_POINT flag
|
||||
// GL_POLYGON_SMOOTH flag
|
||||
// GL_POLYGON_STIPPLE flag
|
||||
// GL_SAMPLE_ALPHA_TO_COVERAGE flag
|
||||
// GL_SAMPLE_ALPHA_TO_ONE flag
|
||||
// GL_SAMPLE_COVERAGE flag
|
||||
, GLStateManager.lineSmoothState // GL_LINE_SMOOTH flag
|
||||
, GLStateManager.lineStippleState // GL_LINE_STIPPLE flag
|
||||
, GLStateManager.map1Color4State // GL_MAP1_COLOR_4
|
||||
, GLStateManager.map1IndexState // GL_MAP1_INDEX
|
||||
, GLStateManager.map1NormalState // GL_MAP1_NORMAL
|
||||
, GLStateManager.map1TextureCoord1State // GL_MAP1_TEXTURE_COORD_1
|
||||
, GLStateManager.map1TextureCoord2State // GL_MAP1_TEXTURE_COORD_2
|
||||
, GLStateManager.map1TextureCoord3State // GL_MAP1_TEXTURE_COORD_3
|
||||
, GLStateManager.map1TextureCoord4State // GL_MAP1_TEXTURE_COORD_4
|
||||
, GLStateManager.map1Vertex3State // GL_MAP1_VERTEX_3
|
||||
, GLStateManager.map1Vertex4State // GL_MAP1_VERTEX_4
|
||||
, GLStateManager.map2Color4State // GL_MAP2_COLOR_4
|
||||
, GLStateManager.map2IndexState // GL_MAP2_INDEX
|
||||
, GLStateManager.map2NormalState // GL_MAP2_NORMAL
|
||||
, GLStateManager.map2TextureCoord1State // GL_MAP2_TEXTURE_COORD_1
|
||||
, GLStateManager.map2TextureCoord2State // GL_MAP2_TEXTURE_COORD_2
|
||||
, GLStateManager.map2TextureCoord3State // GL_MAP2_TEXTURE_COORD_3
|
||||
, GLStateManager.map2TextureCoord4State // GL_MAP2_TEXTURE_COORD_4
|
||||
, GLStateManager.map2Vertex3State // GL_MAP2_VERTEX_3
|
||||
, GLStateManager.map2Vertex4State // GL_MAP2_VERTEX_4
|
||||
, GLStateManager.multisampleState // GL_MULTISAMPLE flag
|
||||
, GLStateManager.normalizeState // GL_NORMALIZE flag
|
||||
, GLStateManager.pointSmoothState // GL_POINT_SMOOTH flag
|
||||
, GLStateManager.polygonOffsetPointState // GL_POLYGON_OFFSET_POINT flag
|
||||
, GLStateManager.polygonOffsetLineState // GL_POLYGON_OFFSET_LINE flag
|
||||
, GLStateManager.polygonOffsetFillState // GL_POLYGON_OFFSET_FILL flag
|
||||
, GLStateManager.polygonSmoothState // GL_POLYGON_SMOOTH flag
|
||||
, GLStateManager.polygonStippleState // GL_POLYGON_STIPPLE flag
|
||||
, GLStateManager.rescaleNormalState // GL_RESCALE_NORMAL flag
|
||||
, GLStateManager.sampleAlphaToCoverageState // GL_SAMPLE_ALPHA_TO_COVERAGE flag
|
||||
, GLStateManager.sampleAlphaToOneState // GL_SAMPLE_ALPHA_TO_ONE flag
|
||||
, GLStateManager.sampleCoverageState // GL_SAMPLE_COVERAGE flag
|
||||
, GLStateManager.scissorTest // GL_SCISSOR_TEST flag
|
||||
// GL_STENCIL_TEST flag
|
||||
// GL_TEXTURE_1D flag
|
||||
// GL_TEXTURE_2D flag - Below
|
||||
// GL_TEXTURE_3D flag
|
||||
// Flags GL_TEXTURE_GEN_x where x is S, T, R, or Q
|
||||
, GLStateManager.stencilTest // GL_STENCIL_TEST flag
|
||||
));
|
||||
|
||||
// GL_TEXTURE_2D flag
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
enableBits.add(GLStateManager.textures.getTextureUnitStates(i));
|
||||
// Enable bits for the user-definable clipping planes
|
||||
for(int i = 0; i < GLStateManager.clipPlaneStates.length; i++) {
|
||||
enableBits.add(GLStateManager.clipPlaneStates[i]);
|
||||
}
|
||||
|
||||
// GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D flags
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
enableBits.add(GLStateManager.textures.getTexture1DStates(i));
|
||||
enableBits.add(GLStateManager.textures.getTextureUnitStates(i));
|
||||
enableBits.add(GLStateManager.textures.getTexture3DStates(i));
|
||||
}
|
||||
|
||||
// Flags GL_TEXTURE_GEN_x where x is S, T, R, or Q
|
||||
addTextureGenStates(enableBits);
|
||||
|
||||
attribToFeatures.put(GL11.GL_ENABLE_BIT, enableBits);
|
||||
attribToFeatures.put(GL11.GL_EVAL_BIT, ImmutableSet.of(
|
||||
// GL_MAP1_x enable bits, where x is a map type
|
||||
@@ -268,13 +304,16 @@ public class Feature {
|
||||
// textureAttribs.add(GLStateManager.textures.getInfo(i))
|
||||
}
|
||||
|
||||
// Enable bits GL_TEXTURE_GEN_x where x is S, T, R, or Q
|
||||
addTextureGenStates(textureAttribs);
|
||||
|
||||
attribToFeatures.put(GL11.GL_TEXTURE_BIT, textureAttribs);
|
||||
|
||||
attribToFeatures.put(GL11.GL_TRANSFORM_BIT, ImmutableSet.of(
|
||||
// Coefficients of the six clipping planes
|
||||
// Enable bits for the user-definable clipping planes
|
||||
GLStateManager.matrixMode
|
||||
// GL_NORMALIZE flag
|
||||
, GLStateManager.normalizeState // GL_NORMALIZE flag
|
||||
, GLStateManager.rescaleNormalState // GL_RESCALE_NORMAL flag
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_VIEWPORT_BIT, ImmutableSet.of(
|
||||
|
||||
@@ -81,8 +81,23 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.AMD;
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.INTEL;
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.MESA;
|
||||
import static com.gtnewhorizons.angelica.glsm.Vendor.NVIDIA;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
/**
|
||||
* OpenGL State Manager - Provides cached state tracking and management for OpenGL operations.
|
||||
*
|
||||
* <p><b>IMPORTANT INITIALIZATION ORDER:</b></p>
|
||||
* <ul>
|
||||
* <li>This class performs GL queries in static initializers (MAX_CLIP_PLANES, MAX_TEXTURE_UNITS, etc.)</li>
|
||||
* <li>The class MUST NOT be loaded until after the GL context has been created and made current</li>
|
||||
* <li>Violating this requirement will cause crashes with "No current context" or return invalid values</li>
|
||||
* <li>Call {@link #preInit()} after GL context creation to initialize runtime state</li>
|
||||
* </ul>
|
||||
*/
|
||||
@SuppressWarnings("unused") // Used in ASM
|
||||
public class GLStateManager {
|
||||
public static ContextCapabilities capabilities;
|
||||
@@ -94,13 +109,14 @@ public class GLStateManager {
|
||||
public static final int MAX_PROJECTION_STACK_DEPTH = GL11.glGetInteger(GL11.GL_MAX_PROJECTION_STACK_DEPTH);
|
||||
public static final int MAX_TEXTURE_STACK_DEPTH = GL11.glGetInteger(GL11.GL_MAX_TEXTURE_STACK_DEPTH);
|
||||
public static final int MAX_TEXTURE_UNITS = GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS);
|
||||
public static final int MAX_CLIP_PLANES = GL11.glGetInteger(GL11.GL_MAX_CLIP_PLANES);
|
||||
|
||||
public static final GLFeatureSet HAS_MULTIPLE_SET = new GLFeatureSet();
|
||||
|
||||
@Getter protected static boolean NVIDIA;
|
||||
@Getter protected static boolean AMD;
|
||||
@Getter protected static boolean INTEL;
|
||||
@Getter protected static boolean MESA;
|
||||
@Getter private static Vendor VENDOR;
|
||||
|
||||
// This setting varies depending on driver, so it gets queried at runtime
|
||||
public static final int DEFAULT_DRAW_BUFFER = GL11.glGetInteger(GL11.GL_DRAW_BUFFER);
|
||||
|
||||
// GLStateManager State Trackers
|
||||
private static final IntStack attribs = new IntArrayList(MAX_ATTRIB_STACK_DEPTH);
|
||||
@@ -119,12 +135,58 @@ public class GLStateManager {
|
||||
@Getter protected static final Color4Stack color = new Color4Stack();
|
||||
@Getter protected static final Color4Stack clearColor = new Color4Stack(new Color4(0.0F, 0.0F, 0.0F, 0.0F));
|
||||
@Getter protected static final ColorMaskStack colorMask = new ColorMaskStack();
|
||||
@Getter protected static final IntegerStateStack drawBuffer = new IntegerStateStack(DEFAULT_DRAW_BUFFER);
|
||||
@Getter protected static final BooleanStateStack cullState = new BooleanStateStack(GL11.GL_CULL_FACE);
|
||||
@Getter protected static final AlphaStateStack alphaState = new AlphaStateStack();
|
||||
@Getter protected static final BooleanStateStack alphaTest = new BooleanStateStack(GL11.GL_ALPHA_TEST);
|
||||
|
||||
@Getter protected static final BooleanStateStack lightingState = new BooleanStateStack(GL11.GL_LIGHTING);
|
||||
@Getter protected static final BooleanStateStack rescaleNormalState = new BooleanStateStack(GL12.GL_RESCALE_NORMAL);
|
||||
@Getter protected static final BooleanStateStack normalizeState = new BooleanStateStack(GL11.GL_NORMALIZE);
|
||||
|
||||
// Additional enable bit states tracked by GL_ENABLE_BIT
|
||||
@Getter protected static final BooleanStateStack ditherState = new BooleanStateStack(GL11.GL_DITHER, true); // Defaults to true per OpenGL spec
|
||||
@Getter protected static final BooleanStateStack stencilTest = new BooleanStateStack(GL11.GL_STENCIL_TEST);
|
||||
@Getter protected static final BooleanStateStack lineSmoothState = new BooleanStateStack(GL11.GL_LINE_SMOOTH);
|
||||
@Getter protected static final BooleanStateStack lineStippleState = new BooleanStateStack(GL11.GL_LINE_STIPPLE);
|
||||
@Getter protected static final BooleanStateStack pointSmoothState = new BooleanStateStack(GL11.GL_POINT_SMOOTH);
|
||||
@Getter protected static final BooleanStateStack polygonSmoothState = new BooleanStateStack(GL11.GL_POLYGON_SMOOTH);
|
||||
@Getter protected static final BooleanStateStack polygonStippleState = new BooleanStateStack(GL11.GL_POLYGON_STIPPLE);
|
||||
@Getter protected static final BooleanStateStack multisampleState = new BooleanStateStack(GL13.GL_MULTISAMPLE, true); // Defaults to true per OpenGL spec
|
||||
@Getter protected static final BooleanStateStack sampleAlphaToCoverageState = new BooleanStateStack(GL13.GL_SAMPLE_ALPHA_TO_COVERAGE);
|
||||
@Getter protected static final BooleanStateStack sampleAlphaToOneState = new BooleanStateStack(GL13.GL_SAMPLE_ALPHA_TO_ONE);
|
||||
@Getter protected static final BooleanStateStack sampleCoverageState = new BooleanStateStack(GL13.GL_SAMPLE_COVERAGE);
|
||||
@Getter protected static final BooleanStateStack colorLogicOpState = new BooleanStateStack(GL11.GL_COLOR_LOGIC_OP);
|
||||
@Getter protected static final BooleanStateStack indexLogicOpState = new BooleanStateStack(GL11.GL_INDEX_LOGIC_OP);
|
||||
|
||||
// Polygon offset states
|
||||
@Getter protected static final BooleanStateStack polygonOffsetPointState = new BooleanStateStack(GL11.GL_POLYGON_OFFSET_POINT);
|
||||
@Getter protected static final BooleanStateStack polygonOffsetLineState = new BooleanStateStack(GL11.GL_POLYGON_OFFSET_LINE);
|
||||
@Getter protected static final BooleanStateStack polygonOffsetFillState = new BooleanStateStack(GL11.GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
// Evaluator states
|
||||
@Getter protected static final BooleanStateStack autoNormalState = new BooleanStateStack(GL11.GL_AUTO_NORMAL);
|
||||
@Getter protected static final BooleanStateStack map1Color4State = new BooleanStateStack(GL11.GL_MAP1_COLOR_4);
|
||||
@Getter protected static final BooleanStateStack map1IndexState = new BooleanStateStack(GL11.GL_MAP1_INDEX);
|
||||
@Getter protected static final BooleanStateStack map1NormalState = new BooleanStateStack(GL11.GL_MAP1_NORMAL);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord1State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_1);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord2State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_2);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord3State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_3);
|
||||
@Getter protected static final BooleanStateStack map1TextureCoord4State = new BooleanStateStack(GL11.GL_MAP1_TEXTURE_COORD_4);
|
||||
@Getter protected static final BooleanStateStack map1Vertex3State = new BooleanStateStack(GL11.GL_MAP1_VERTEX_3);
|
||||
@Getter protected static final BooleanStateStack map1Vertex4State = new BooleanStateStack(GL11.GL_MAP1_VERTEX_4);
|
||||
@Getter protected static final BooleanStateStack map2Color4State = new BooleanStateStack(GL11.GL_MAP2_COLOR_4);
|
||||
@Getter protected static final BooleanStateStack map2IndexState = new BooleanStateStack(GL11.GL_MAP2_INDEX);
|
||||
@Getter protected static final BooleanStateStack map2NormalState = new BooleanStateStack(GL11.GL_MAP2_NORMAL);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord1State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_1);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord2State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_2);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord3State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_3);
|
||||
@Getter protected static final BooleanStateStack map2TextureCoord4State = new BooleanStateStack(GL11.GL_MAP2_TEXTURE_COORD_4);
|
||||
@Getter protected static final BooleanStateStack map2Vertex3State = new BooleanStateStack(GL11.GL_MAP2_VERTEX_3);
|
||||
@Getter protected static final BooleanStateStack map2Vertex4State = new BooleanStateStack(GL11.GL_MAP2_VERTEX_4);
|
||||
|
||||
// Clip plane states
|
||||
@Getter protected static final BooleanStateStack[] clipPlaneStates = new BooleanStateStack[MAX_CLIP_PLANES];
|
||||
|
||||
@Getter protected static final MatrixModeStack matrixMode = new MatrixModeStack();
|
||||
@Getter protected static final Matrix4fStack modelViewMatrix = new Matrix4fStack(MAX_MODELVIEW_STACK_DEPTH);
|
||||
@@ -148,8 +210,12 @@ public class GLStateManager {
|
||||
lightDataStates[i] = new LightStateStack(GL11.GL_LIGHT0 + i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_CLIP_PLANES; i++) {
|
||||
clipPlaneStates[i] = new BooleanStateStack(GL11.GL_CLIP_PLANE0 + i);
|
||||
}
|
||||
|
||||
try {
|
||||
Field curr = ReflectionHelper.findField(Matrix4fStack.class, "curr");
|
||||
final Field curr = ReflectionHelper.findField(Matrix4fStack.class, "curr");
|
||||
curr.setAccessible(true);
|
||||
MAT4_STACK_CURR_DEPTH = MethodHandles.lookup().unreflectGetter(curr);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -167,11 +233,11 @@ public class GLStateManager {
|
||||
attribs.popInt();
|
||||
}
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS);
|
||||
int size = stacks.size();
|
||||
final List<IStateStack<?>> stacks = Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS);
|
||||
final int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
IStateStack<?> stack = stacks.get(i);
|
||||
final IStateStack<?> stack = stacks.get(i);
|
||||
|
||||
while(!stack.isEmpty()) {
|
||||
stack.pop();
|
||||
@@ -245,16 +311,12 @@ public class GLStateManager {
|
||||
.addFeature(GL11.GL_VIEWPORT);
|
||||
|
||||
String glVendor = GL11.glGetString(GL11.GL_VENDOR);
|
||||
NVIDIA = glVendor.toLowerCase().contains("nvidia");
|
||||
AMD = glVendor.toLowerCase().contains("ati") || glVendor.toLowerCase().contains("amd");
|
||||
INTEL = glVendor.toLowerCase().contains("intel");
|
||||
MESA = glVendor.toLowerCase().contains("mesa");
|
||||
VENDOR = Vendor.getVendor(glVendor.toLowerCase());
|
||||
|
||||
if(AMD) {
|
||||
if (vendorIsAMD()) {
|
||||
// AMD Drivers seem to default to 0 for the matrix mode, so we need to set it to the default
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
@@ -300,12 +362,23 @@ public class GLStateManager {
|
||||
|
||||
// LWJGL Overrides
|
||||
public static void glEnable(int cap) {
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (cap >= GL11.GL_CLIP_PLANE0 && cap < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
clipPlaneStates[cap - GL11.GL_CLIP_PLANE0].enable();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cap) {
|
||||
case GL11.GL_ALPHA_TEST -> enableAlphaTest();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.enable();
|
||||
case GL11.GL_BLEND -> enableBlend();
|
||||
case GL11.GL_COLOR_MATERIAL -> enableColorMaterial();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.enable();
|
||||
case GL11.GL_CULL_FACE -> enableCull();
|
||||
case GL11.GL_DEPTH_TEST -> enableDepthTest();
|
||||
case GL11.GL_DITHER -> ditherState.enable();
|
||||
case GL11.GL_FOG -> enableFog();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.enable();
|
||||
case GL11.GL_LIGHTING -> enableLighting();
|
||||
case GL11.GL_LIGHT0 -> enableLight(0);
|
||||
case GL11.GL_LIGHT1 -> enableLight(1);
|
||||
@@ -315,21 +388,69 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> enableLight(5);
|
||||
case GL11.GL_LIGHT6 -> enableLight(6);
|
||||
case GL11.GL_LIGHT7 -> enableLight(7);
|
||||
case GL11.GL_COLOR_MATERIAL -> enableColorMaterial();
|
||||
case GL11.GL_SCISSOR_TEST -> enableScissorTest();
|
||||
case GL11.GL_TEXTURE_2D -> enableTexture();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.enable();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.enable();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.enable();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.enable();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.enable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.enable();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.enable();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.enable();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.enable();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.enable();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.enable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.enable();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.enable();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.enable();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.enable();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.enable();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.enable();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.enable();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.enable();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.enable();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.enable();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.enable();
|
||||
case GL12.GL_RESCALE_NORMAL -> enableRescaleNormal();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.enable();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.enable();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.enable();
|
||||
case GL11.GL_SCISSOR_TEST -> enableScissorTest();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.enable();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_2D -> enableTexture();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).enable();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).enable();
|
||||
default -> GL11.glEnable(cap);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glDisable(int cap) {
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (cap >= GL11.GL_CLIP_PLANE0 && cap < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
clipPlaneStates[cap - GL11.GL_CLIP_PLANE0].disable();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (cap) {
|
||||
case GL11.GL_ALPHA_TEST -> disableAlphaTest();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.disable();
|
||||
case GL11.GL_BLEND -> disableBlend();
|
||||
case GL11.GL_COLOR_MATERIAL -> disableColorMaterial();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.disable();
|
||||
case GL11.GL_CULL_FACE -> disableCull();
|
||||
case GL11.GL_DEPTH_TEST -> disableDepthTest();
|
||||
case GL11.GL_DITHER -> ditherState.disable();
|
||||
case GL11.GL_FOG -> disableFog();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.disable();
|
||||
case GL11.GL_LIGHTING -> disableLighting();
|
||||
case GL11.GL_LIGHT0 -> disableLight(0);
|
||||
case GL11.GL_LIGHT1 -> disableLight(1);
|
||||
@@ -339,10 +460,47 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> disableLight(5);
|
||||
case GL11.GL_LIGHT6 -> disableLight(6);
|
||||
case GL11.GL_LIGHT7 -> disableLight(7);
|
||||
case GL11.GL_COLOR_MATERIAL -> disableColorMaterial();
|
||||
case GL11.GL_SCISSOR_TEST -> disableScissorTest();
|
||||
case GL11.GL_TEXTURE_2D -> disableTexture();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.disable();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.disable();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.disable();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.disable();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.disable();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.disable();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.disable();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.disable();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.disable();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.disable();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.disable();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.disable();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.disable();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.disable();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.disable();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.disable();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.disable();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.disable();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.disable();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.disable();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.disable();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.disable();
|
||||
case GL12.GL_RESCALE_NORMAL -> disableRescaleNormal();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.disable();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.disable();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.disable();
|
||||
case GL11.GL_SCISSOR_TEST -> disableScissorTest();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.disable();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_2D -> disableTexture();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).disable();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).disable();
|
||||
default -> GL11.glDisable(cap);
|
||||
}
|
||||
}
|
||||
@@ -351,12 +509,22 @@ public class GLStateManager {
|
||||
if(shouldBypassCache()) {
|
||||
return GL11.glIsEnabled(cap);
|
||||
}
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (cap >= GL11.GL_CLIP_PLANE0 && cap < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
return clipPlaneStates[cap - GL11.GL_CLIP_PLANE0].isEnabled();
|
||||
}
|
||||
|
||||
return switch (cap) {
|
||||
case GL11.GL_ALPHA_TEST -> alphaTest.isEnabled();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.isEnabled();
|
||||
case GL11.GL_BLEND -> blendMode.isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.isEnabled();
|
||||
case GL11.GL_CULL_FACE -> cullState.isEnabled();
|
||||
case GL11.GL_DEPTH_TEST -> depthTest.isEnabled();
|
||||
case GL11.GL_DITHER -> ditherState.isEnabled();
|
||||
case GL11.GL_FOG -> fogMode.isEnabled();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.isEnabled();
|
||||
case GL11.GL_LIGHTING -> lightingState.isEnabled();
|
||||
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
|
||||
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
|
||||
@@ -366,10 +534,47 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
|
||||
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
|
||||
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.isEnabled();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.isEnabled();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.isEnabled();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.isEnabled();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.isEnabled();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.isEnabled();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.isEnabled();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.isEnabled();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.isEnabled();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.isEnabled();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.isEnabled();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.isEnabled();
|
||||
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.isEnabled();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).isEnabled();
|
||||
default -> GL11.glIsEnabled(cap);
|
||||
};
|
||||
}
|
||||
@@ -378,13 +583,23 @@ public class GLStateManager {
|
||||
if(shouldBypassCache()) {
|
||||
return GL11.glGetBoolean(pname);
|
||||
}
|
||||
// Handle clip planes dynamically (supports up to MAX_CLIP_PLANES)
|
||||
if (pname >= GL11.GL_CLIP_PLANE0 && pname < GL11.GL_CLIP_PLANE0 + MAX_CLIP_PLANES) {
|
||||
return clipPlaneStates[pname - GL11.GL_CLIP_PLANE0].isEnabled();
|
||||
}
|
||||
|
||||
return switch (pname) {
|
||||
case GL11.GL_ALPHA_TEST -> alphaTest.isEnabled();
|
||||
case GL11.GL_AUTO_NORMAL -> autoNormalState.isEnabled();
|
||||
case GL11.GL_BLEND -> blendMode.isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_COLOR_LOGIC_OP -> colorLogicOpState.isEnabled();
|
||||
case GL11.GL_CULL_FACE -> cullState.isEnabled();
|
||||
case GL11.GL_DEPTH_TEST -> depthTest.isEnabled();
|
||||
case GL11.GL_DEPTH_WRITEMASK -> depthState.isEnabled();
|
||||
case GL11.GL_DITHER -> ditherState.isEnabled();
|
||||
case GL11.GL_FOG -> fogMode.isEnabled();
|
||||
case GL11.GL_INDEX_LOGIC_OP -> indexLogicOpState.isEnabled();
|
||||
case GL11.GL_LIGHTING -> lightingState.isEnabled();
|
||||
case GL11.GL_LIGHT0 -> lightStates[0].isEnabled();
|
||||
case GL11.GL_LIGHT1 -> lightStates[1].isEnabled();
|
||||
@@ -394,10 +609,47 @@ public class GLStateManager {
|
||||
case GL11.GL_LIGHT5 -> lightStates[5].isEnabled();
|
||||
case GL11.GL_LIGHT6 -> lightStates[6].isEnabled();
|
||||
case GL11.GL_LIGHT7 -> lightStates[7].isEnabled();
|
||||
case GL11.GL_COLOR_MATERIAL -> colorMaterial.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_LINE_SMOOTH -> lineSmoothState.isEnabled();
|
||||
case GL11.GL_LINE_STIPPLE -> lineStippleState.isEnabled();
|
||||
case GL11.GL_MAP1_COLOR_4 -> map1Color4State.isEnabled();
|
||||
case GL11.GL_MAP1_INDEX -> map1IndexState.isEnabled();
|
||||
case GL11.GL_MAP1_NORMAL -> map1NormalState.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_1 -> map1TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_2 -> map1TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_3 -> map1TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP1_TEXTURE_COORD_4 -> map1TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_3 -> map1Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP1_VERTEX_4 -> map1Vertex4State.isEnabled();
|
||||
case GL11.GL_MAP2_COLOR_4 -> map2Color4State.isEnabled();
|
||||
case GL11.GL_MAP2_INDEX -> map2IndexState.isEnabled();
|
||||
case GL11.GL_MAP2_NORMAL -> map2NormalState.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_1 -> map2TextureCoord1State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_2 -> map2TextureCoord2State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_3 -> map2TextureCoord3State.isEnabled();
|
||||
case GL11.GL_MAP2_TEXTURE_COORD_4 -> map2TextureCoord4State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_3 -> map2Vertex3State.isEnabled();
|
||||
case GL11.GL_MAP2_VERTEX_4 -> map2Vertex4State.isEnabled();
|
||||
case GL13.GL_MULTISAMPLE -> multisampleState.isEnabled();
|
||||
case GL11.GL_NORMALIZE -> normalizeState.isEnabled();
|
||||
case GL11.GL_POINT_SMOOTH -> pointSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_POINT -> polygonOffsetPointState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_LINE -> polygonOffsetLineState.isEnabled();
|
||||
case GL11.GL_POLYGON_OFFSET_FILL -> polygonOffsetFillState.isEnabled();
|
||||
case GL11.GL_POLYGON_SMOOTH -> polygonSmoothState.isEnabled();
|
||||
case GL11.GL_POLYGON_STIPPLE -> polygonStippleState.isEnabled();
|
||||
case GL12.GL_RESCALE_NORMAL -> rescaleNormalState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_COVERAGE -> sampleAlphaToCoverageState.isEnabled();
|
||||
case GL13.GL_SAMPLE_ALPHA_TO_ONE -> sampleAlphaToOneState.isEnabled();
|
||||
case GL13.GL_SAMPLE_COVERAGE -> sampleCoverageState.isEnabled();
|
||||
case GL11.GL_SCISSOR_TEST -> scissorTest.isEnabled();
|
||||
case GL11.GL_STENCIL_TEST -> stencilTest.isEnabled();
|
||||
case GL11.GL_TEXTURE_1D -> textures.getTexture1DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_2D -> textures.getTextureUnitStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL12.GL_TEXTURE_3D -> textures.getTexture3DStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_S -> textures.getTexGenSStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_T -> textures.getTexGenTStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_R -> textures.getTexGenRStates(activeTextureUnit.getValue()).isEnabled();
|
||||
case GL11.GL_TEXTURE_GEN_Q -> textures.getTexGenQStates(activeTextureUnit.getValue()).isEnabled();
|
||||
default -> GL11.glGetBoolean(pname);
|
||||
};
|
||||
}
|
||||
@@ -997,7 +1249,7 @@ public class GLStateManager {
|
||||
i = mipmap ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_LINEAR;
|
||||
j = GL11.GL_LINEAR;
|
||||
} else {
|
||||
i = mipmap ? GL11.GL_NEAREST_MIPMAP_LINEAR : GL11.GL_NEAREST;
|
||||
i = mipmap ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_NEAREST;
|
||||
j = GL11.GL_NEAREST;
|
||||
}
|
||||
glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, i);
|
||||
@@ -1885,6 +2137,20 @@ public class GLStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean vendorIsAMD() {
|
||||
return VENDOR == AMD;
|
||||
}
|
||||
|
||||
public static boolean vendorIsIntel() {
|
||||
return VENDOR == INTEL;
|
||||
}
|
||||
|
||||
public static boolean vendorIsMesa() {
|
||||
return VENDOR == MESA;
|
||||
}
|
||||
|
||||
public static boolean vendorIsNVIDIA() {
|
||||
return VENDOR == NVIDIA;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
/// Matches
|
||||
public enum Vendor {
|
||||
AMD("amd"),
|
||||
INTEL("intel"),
|
||||
MESA("mesa"),
|
||||
NVIDIA("nvidia"),
|
||||
UNKNOWN("");
|
||||
|
||||
final String[] names;
|
||||
|
||||
Vendor(String... names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
public static Vendor getVendor(String vendorString) {
|
||||
for (var v : values()) {
|
||||
for (var name : v.names) {
|
||||
if (vendorString.contains(name)) return v;
|
||||
}
|
||||
}
|
||||
|
||||
// Shouldn't be needed as "" matches everything, but sanity checks good.
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,20 @@ public class BooleanStateStack extends BooleanState implements IStateStack<Boole
|
||||
protected int pointer;
|
||||
|
||||
public BooleanStateStack(int glCap) {
|
||||
// Most booleans default to false
|
||||
this(glCap, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a BooleanStateStack with a custom initial state.
|
||||
* Useful for GL states that default to true (e.g., GL_DITHER, GL_MULTISAMPLE).
|
||||
*
|
||||
* @param glCap GL capability constant
|
||||
* @param initialState initial enabled state
|
||||
*/
|
||||
public BooleanStateStack(int glCap, boolean initialState) {
|
||||
super(glCap);
|
||||
this.enabled = initialState;
|
||||
stack = new BooleanState[GLStateManager.MAX_ATTRIB_STACK_DEPTH];
|
||||
for (int i = 0; i < GLStateManager.MAX_ATTRIB_STACK_DEPTH; i++) {
|
||||
stack[i] = new BooleanState(glCap);
|
||||
@@ -34,7 +47,7 @@ public class BooleanStateStack extends BooleanState implements IStateStack<Boole
|
||||
}
|
||||
|
||||
set(stack[--pointer]);
|
||||
if (GLStateManager.isAMD() && glCap == GL11.GL_BLEND) {
|
||||
if (GLStateManager.vendorIsAMD() && glCap == GL11.GL_BLEND) {
|
||||
setEnabled(enabled);
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BooleanState implements ISettableState<BooleanState> {
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (GLStateManager.shouldBypassCache() || enabled != this.enabled || (this.glCap == GL11.GL_BLEND && GLStateManager.isAMD() && GLStateManager.isPoppingAttributes())) {
|
||||
if (GLStateManager.shouldBypassCache() || enabled != this.enabled || (this.glCap == GL11.GL_BLEND && GLStateManager.vendorIsAMD() && GLStateManager.isPoppingAttributes())) {
|
||||
this.enabled = enabled;
|
||||
if (enabled) {
|
||||
GL11.glEnable(this.glCap);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class MaterialState implements ISettableState<MaterialState> {
|
||||
// glMaterial specifically for GL_COLOR_INDEXES. Other drivers do not do this.
|
||||
// This probably breaks things but who knows, GLSM is setup to track to what the
|
||||
// driver is doing for it right now.
|
||||
if (GLStateManager.isNVIDIA()) {
|
||||
if (GLStateManager.vendorIsNVIDIA()) {
|
||||
vector3f.set(newBuffer.get(0), newBuffer.get(2), newBuffer.get(1));
|
||||
} else {
|
||||
vector3f.set(newBuffer);
|
||||
|
||||
@@ -6,21 +6,40 @@ import com.gtnewhorizons.angelica.glsm.stacks.TextureBindingStack;
|
||||
import lombok.Getter;
|
||||
import org.joml.Matrix4fStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class TextureUnitArray {
|
||||
private final TextureBindingStack[] bindings;
|
||||
private final BooleanStateStack[] states;
|
||||
private final BooleanStateStack[] texture1DStates;
|
||||
private final BooleanStateStack[] texture3DStates;
|
||||
private final BooleanStateStack[] texGenSStates;
|
||||
private final BooleanStateStack[] texGenTStates;
|
||||
private final BooleanStateStack[] texGenRStates;
|
||||
private final BooleanStateStack[] texGenQStates;
|
||||
@Getter
|
||||
public final Matrix4fStack[] textureMatricies;
|
||||
|
||||
public TextureUnitArray() {
|
||||
bindings = new TextureBindingStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
states = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texture1DStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texture3DStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenSStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenTStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenRStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
texGenQStates = new BooleanStateStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
textureMatricies = new Matrix4fStack[GLStateManager.MAX_TEXTURE_UNITS];
|
||||
|
||||
for (int i = 0; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
bindings[i] = new TextureBindingStack();
|
||||
states[i] = new BooleanStateStack(GL11.GL_TEXTURE_2D);
|
||||
texture1DStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_1D);
|
||||
texture3DStates[i] = new BooleanStateStack(GL12.GL_TEXTURE_3D);
|
||||
texGenSStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_S);
|
||||
texGenTStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_T);
|
||||
texGenRStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_R);
|
||||
texGenQStates[i] = new BooleanStateStack(GL11.GL_TEXTURE_GEN_Q);
|
||||
textureMatricies[i] = new Matrix4fStack(GLStateManager.MAX_TEXTURE_STACK_DEPTH);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +52,30 @@ public class TextureUnitArray {
|
||||
return states[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexture1DStates(int index) {
|
||||
return texture1DStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexture3DStates(int index) {
|
||||
return texture3DStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenSStates(int index) {
|
||||
return texGenSStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenTStates(int index) {
|
||||
return texGenTStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenRStates(int index) {
|
||||
return texGenRStates[index];
|
||||
}
|
||||
|
||||
public BooleanStateStack getTexGenQStates(int index) {
|
||||
return texGenQStates[index];
|
||||
}
|
||||
|
||||
public Matrix4fStack getTextureUnitMatrix(int index) {
|
||||
return textureMatricies[index];
|
||||
}
|
||||
@@ -44,6 +87,12 @@ public class TextureUnitArray {
|
||||
for (int i = 0; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
if (!bindings[i].sameAs(textureUnitArray.bindings[i])) return false;
|
||||
if (!states[i].sameAs(textureUnitArray.states[i])) return false;
|
||||
if (!texture1DStates[i].sameAs(textureUnitArray.texture1DStates[i])) return false;
|
||||
if (!texture3DStates[i].sameAs(textureUnitArray.texture3DStates[i])) return false;
|
||||
if (!texGenSStates[i].sameAs(textureUnitArray.texGenSStates[i])) return false;
|
||||
if (!texGenTStates[i].sameAs(textureUnitArray.texGenTStates[i])) return false;
|
||||
if (!texGenRStates[i].sameAs(textureUnitArray.texGenRStates[i])) return false;
|
||||
if (!texGenQStates[i].sameAs(textureUnitArray.texGenQStates[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ public class TextureInfo {
|
||||
protected int width = -1;
|
||||
protected int height = -1;
|
||||
|
||||
@Getter @Setter protected int minFilter = GL11.GL_NEAREST_MIPMAP_LINEAR;
|
||||
@Getter @Setter protected int minFilter = GL11.GL_LINEAR_MIPMAP_LINEAR;
|
||||
@Getter @Setter protected int magFilter = GL11.GL_LINEAR;
|
||||
@Getter @Setter protected int wrapS = GL11.GL_REPEAT;
|
||||
@Getter @Setter protected int wrapT = GL11.GL_REPEAT;
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package com.gtnewhorizons.angelica.loading;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.asm.ASMUtil;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigException;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.ITransformers;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.Mixins;
|
||||
import com.gtnewhorizons.angelica.mixins.TargetedMod;
|
||||
import com.gtnewhorizons.angelica.transform.compat.GenericCompatTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.handlers.CompatHandler;
|
||||
import com.gtnewhorizons.angelica.transform.compat.handlers.CompatHandlers;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.CompatHandlers;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import jss.notfine.asm.AsmTransformers;
|
||||
import jss.notfine.asm.mappings.Namer;
|
||||
import jss.notfine.config.MCPatcherForgeConfig;
|
||||
import jss.notfine.config.NotFineConfig;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -25,7 +27,7 @@ import org.spongepowered.asm.launch.GlobalProperties;
|
||||
import org.spongepowered.asm.service.mojang.MixinServiceLaunchWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -41,21 +43,22 @@ import java.util.Set;
|
||||
//@IFMLLoadingPlugin.SortingIndex(Integer.MAX_VALUE - 5)
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
@IFMLLoadingPlugin.TransformerExclusions({
|
||||
"com.gtnewhorizons.angelica.transform.RedirectorTransformer",
|
||||
"com.gtnewhorizons.angelica.glsm.GLStateManager"})
|
||||
"jss.notfine.asm",
|
||||
"com.gtnewhorizons.angelica.loading",
|
||||
"com.gtnewhorizons.angelica.glsm.GLStateManager"})
|
||||
public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
private static final boolean DUMP_CLASSES = Boolean.parseBoolean(System.getProperty("angelica.dumpClass", "false"));
|
||||
private static boolean OBF_ENV;
|
||||
private static Boolean OBF_ENV;
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
private String[] transformerClasses;
|
||||
|
||||
static {
|
||||
public AngelicaTweaker() {
|
||||
try {
|
||||
// Angelica Config
|
||||
ConfigurationManager.registerConfig(AngelicaConfig.class);
|
||||
ConfigurationManager.registerConfig(CompatConfig.class);
|
||||
ConfigurationManager.registerConfig(FontConfig.class);
|
||||
MCPatcherForgeConfig.registerConfig();
|
||||
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
final Configuration config = ctx.getConfiguration();
|
||||
@@ -66,39 +69,29 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
ctx.updateLoggers();
|
||||
|
||||
// Debug features
|
||||
AngelicaConfig.enableTestBlocks = Boolean.parseBoolean(System.getProperty("angelica.enableTestBlocks", "false"));
|
||||
AngelicaConfig.enableTestBlocks = Boolean.getBoolean("angelica.enableTestBlocks");
|
||||
|
||||
} catch (ConfigException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
verifyDependencies();
|
||||
}
|
||||
|
||||
private static void verifyDependencies() {
|
||||
if (AngelicaTweaker.class.getResource("/it/unimi/dsi/fastutil/ints/Int2ObjectMap.class") == null) {
|
||||
throw new RuntimeException("Missing dependency: Angelica requires GTNHLib 0.2.1 or newer! Download: https://modrinth.com/mod/gtnhlib");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getASMTransformerClass() {
|
||||
// Directly add this to the MixinServiceLaunchWrapper tweaker's list of Tweak Classes
|
||||
final List<String> mixinTweakClasses = GlobalProperties.get(MixinServiceLaunchWrapper.BLACKBOARD_KEY_TWEAKCLASSES);
|
||||
if (mixinTweakClasses != null) {
|
||||
mixinTweakClasses.add(MixinCompatHackTweaker.class.getName());
|
||||
}
|
||||
if (transformerClasses == null) {
|
||||
final List<String> transformers = new ArrayList<>();
|
||||
|
||||
// Regsiter compat handlers, and add extra specific transformers, then build and register the generic transformer
|
||||
for (CompatHandler handler : CompatHandlers.getHandlers()) {
|
||||
GenericCompatTransformer.register(handler);
|
||||
if (handler.extraTransformers() != null) {
|
||||
transformers.addAll(handler.extraTransformers());
|
||||
}
|
||||
}
|
||||
|
||||
GenericCompatTransformer.build();
|
||||
transformers.add(GenericCompatTransformer.class.getName());
|
||||
|
||||
transformers.addAll(CompatHandlers.getTransformers());
|
||||
// Add NotFine transformers
|
||||
final List<String> notFineTransformers = AsmTransformers.getTransformers();
|
||||
final List<String> notFineTransformers = Arrays.asList(ITransformers.getTransformers(AsmTransformers.class));
|
||||
if (!notFineTransformers.isEmpty()) Namer.initNames();
|
||||
transformers.addAll(notFineTransformers);
|
||||
|
||||
transformerClasses = transformers.toArray(new String[0]);
|
||||
}
|
||||
return transformerClasses;
|
||||
@@ -116,7 +109,28 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
OBF_ENV = (boolean) data.get("runtimeDeobfuscationEnabled");
|
||||
OBF_ENV = (Boolean) data.get("runtimeDeobfuscationEnabled");
|
||||
// Directly add this to the MixinServiceLaunchWrapper tweaker's list of Tweak Classes
|
||||
final List<String> tweaks = GlobalProperties.get(MixinServiceLaunchWrapper.BLACKBOARD_KEY_TWEAKCLASSES);
|
||||
if (tweaks != null) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.IncompatibleModsDisablerTweaker");
|
||||
if (AngelicaConfig.enableHudCaching) {
|
||||
tweaks.add("com.gtnewhorizons.angelica.loading.fml.tweakers.XaerosTransformerDisablerTweaker");
|
||||
}
|
||||
if (FMLLaunchHandler.side().isClient()) {
|
||||
// We register ITweakers that will run last in order to register
|
||||
// specific IClassTransformers that will run last in the transformer chain.
|
||||
// If we were to register them normally in getASMTransformerClass(),
|
||||
// they would be sorted at index 0 which we do not want.
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,26 +145,34 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||
return Mixins.getEarlyMixins(loadedCoreMods);
|
||||
}
|
||||
|
||||
public static boolean DUMP_CLASSES() {
|
||||
return DUMP_CLASSES || !OBF_ENV;
|
||||
NotFineConfig.loadSettings();
|
||||
//This may be possible to handle differently or fix.
|
||||
if (loadedCoreMods.contains("cofh.asm.LoadingPlugin")) {
|
||||
MCPatcherForgeConfig.ExtendedHD.hdFont = false;
|
||||
}
|
||||
return IMixins.getEarlyMixins(Mixins.class, loadedCoreMods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if we are in an obfuscated environment, returns false in dev environment.
|
||||
*/
|
||||
public static boolean isObfEnv() {
|
||||
if (OBF_ENV == null) {
|
||||
throw new IllegalStateException("Obfuscation state has been accessed too early!");
|
||||
}
|
||||
return OBF_ENV;
|
||||
}
|
||||
|
||||
public static void dumpClass(String className, byte[] originalBytes, byte[] transformedBytes, Object transformer) {
|
||||
if (AngelicaTweaker.DUMP_CLASSES()) {
|
||||
ASMUtil.saveAsRawClassFile(originalBytes, className + "_PRE", transformer);
|
||||
ASMUtil.saveAsRawClassFile(transformedBytes, className + "_POST", transformer);
|
||||
/**
|
||||
* Returns the appropriate name according to current environment's obfuscation
|
||||
*/
|
||||
public static String obf(String deobf, String obf) {
|
||||
if (OBF_ENV == null) {
|
||||
throw new IllegalStateException("Obfuscation state has been accessed too early!");
|
||||
}
|
||||
if (OBF_ENV) {
|
||||
return obf;
|
||||
}
|
||||
return deobf;
|
||||
}
|
||||
|
||||
public static final Set<TargetedMod> coreMods = new HashSet<>();
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.handlers.ExtraUtilsCompatHandler;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.handlers.ImmersiveEngineeringCompatHandler;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.handlers.StacksOnStacksCompatHandler;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.handlers.ThaumcraftCompatHandler;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.handlers.ThaumicHorizonsCompatHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum CompatHandlers {
|
||||
|
||||
STACKS_ON_STACKS(() -> CompatConfig.fixStacksOnStacks, new StacksOnStacksCompatHandler()),
|
||||
EXTRA_UTILS(() -> CompatConfig.fixExtraUtils, new ExtraUtilsCompatHandler()),
|
||||
IMMERSIVE_ENGINEERING(() -> CompatConfig.fixImmersiveEngineering, new ImmersiveEngineeringCompatHandler()),
|
||||
THAUMCRAFT(() -> CompatConfig.fixThaumcraft, new ThaumcraftCompatHandler()),
|
||||
THAUMIC_HORIZONS(() -> CompatConfig.fixThaumicHorizons, new ThaumicHorizonsCompatHandler());
|
||||
|
||||
private final Supplier<Boolean> applyIf;
|
||||
private final ICompatHandler handler;
|
||||
|
||||
CompatHandlers(Supplier<Boolean> applyIf, ICompatHandler handler) {
|
||||
this.applyIf = applyIf;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
private static List<ICompatHandler> compatHandlers = null;
|
||||
|
||||
public static List<ICompatHandler> getHandlers() {
|
||||
if (compatHandlers != null) {
|
||||
return compatHandlers;
|
||||
}
|
||||
compatHandlers = new ArrayList<>();
|
||||
for (CompatHandlers value : values()) {
|
||||
if (value.applyIf.get()) {
|
||||
compatHandlers.add(value.handler);
|
||||
}
|
||||
}
|
||||
return compatHandlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns extra transformers as well as the main transformer.
|
||||
* Returns an empty list if no handlers registered.
|
||||
*/
|
||||
public static List<String> getTransformers() {
|
||||
final List<ICompatHandler> handlers = getHandlers();
|
||||
if (handlers.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> transformers = new ArrayList<>();
|
||||
for (ICompatHandler handler : handlers) {
|
||||
if (handler.extraTransformers() != null) {
|
||||
transformers.addAll(handler.extraTransformers());
|
||||
}
|
||||
}
|
||||
transformers.add("com.gtnewhorizons.angelica.loading.fml.transformers.GenericCompatTransformer");
|
||||
return transformers;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CompatHandler {
|
||||
public interface ICompatHandler {
|
||||
|
||||
default Map<String, List<String>> getFieldLevelTessellator() {
|
||||
return null;
|
||||
+3
-2
@@ -1,10 +1,11 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.ICompatHandler;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ExtraUtilsCompatHandler implements CompatHandler {
|
||||
public class ExtraUtilsCompatHandler implements ICompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getThreadSafeISBRHAnnotations() {
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.specific.ImmersiveEngineeringTransformer;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.ICompatHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImmersiveEngineeringCompatHandler implements CompatHandler {
|
||||
public class ImmersiveEngineeringCompatHandler implements ICompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getTileEntityNullGuard() {
|
||||
@@ -38,7 +38,7 @@ public class ImmersiveEngineeringCompatHandler implements CompatHandler {
|
||||
|
||||
@Override
|
||||
public List<String> extraTransformers() {
|
||||
return ImmutableList.of(ImmersiveEngineeringTransformer.class.getName());
|
||||
return ImmutableList.of("com.gtnewhorizons.angelica.loading.fml.compat.transformers.specific.ImmersiveEngineeringTransformer");
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -1,13 +1,13 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.specific.StacksOnStacksTransformer;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.ICompatHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StacksOnStacksCompatHandler implements CompatHandler {
|
||||
public class StacksOnStacksCompatHandler implements ICompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getFieldLevelTessellator() {
|
||||
@@ -28,6 +28,6 @@ public class StacksOnStacksCompatHandler implements CompatHandler {
|
||||
|
||||
@Override
|
||||
public List<String> extraTransformers() {
|
||||
return ImmutableList.of(StacksOnStacksTransformer.class.getName());
|
||||
return ImmutableList.of("com.gtnewhorizons.angelica.loading.fml.compat.transformers.specific.StacksOnStacksTransformer");
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,12 +1,13 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.ICompatHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ThaumcraftCompatHandler implements CompatHandler {
|
||||
public class ThaumcraftCompatHandler implements ICompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHUDCachingEarlyReturn() {
|
||||
+3
-2
@@ -1,12 +1,13 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.ICompatHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ThaumicHorizonsCompatHandler implements CompatHandler {
|
||||
public class ThaumicHorizonsCompatHandler implements ICompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHUDCachingEarlyReturn() {
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic;
|
||||
|
||||
import com.gtnewhorizons.angelica.transform.AsmUtil;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
@@ -62,7 +62,7 @@ public class FieldLevelTessellatorTransformer {
|
||||
new FieldInsnNode(
|
||||
Opcodes.GETSTATIC,
|
||||
"net/minecraft/client/renderer/Tessellator",
|
||||
AsmUtil.obf("instance", "field_78398_a"),
|
||||
AngelicaTweaker.obf("instance", "field_78398_a"),
|
||||
"Lnet/minecraft/client/renderer/Tessellator;"));
|
||||
list.add(new VarInsnNode(Opcodes.ASTORE, localIndex));
|
||||
mn.instructions.insert(list);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
+2
-3
@@ -1,7 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.transform.AsmUtil;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
@@ -60,7 +59,7 @@ public class TileEntityNullGuardTransformer {
|
||||
AbstractInsnNode in = mn.instructions.get(i);
|
||||
if (in instanceof MethodInsnNode min) {
|
||||
if (min.getOpcode() == Opcodes.INVOKEINTERFACE
|
||||
&& min.name.equals(AsmUtil.obf("getTileEntity", "func_147438_o"))
|
||||
&& min.name.equals(AngelicaTweaker.obf("getTileEntity", "func_147438_o"))
|
||||
&& min.owner.equals("net/minecraft/world/IBlockAccess")) {
|
||||
AbstractInsnNode castNodeAbstract = min.getNext();
|
||||
if (castNodeAbstract instanceof TypeInsnNode castNodeType) {
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.specific;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.transformers.specific;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
@@ -60,7 +61,7 @@ public class ImmersiveEngineeringTransformer implements IClassTransformer {
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.LOGGER.info("[AngelicaCompat]Extra Transformers: Applied ImmersiveEngineeringTransformer");
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.specific;
|
||||
package com.gtnewhorizons.angelica.loading.fml.compat.transformers.specific;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.ClassWriter;
|
||||
@@ -47,7 +48,7 @@ public class StacksOnStacksTransformer implements IClassTransformer {
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.LOGGER.info("[AngelicaCompat]Extra Transformers: Applied StacksOnStacksTransformer");
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.transformers;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.AngelicaRedirector;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
/** IClassTransformer wrapper for {@link AngelicaRedirector} */
|
||||
public class AngelicaRedirectorTransformer implements IClassTransformer {
|
||||
|
||||
private final AngelicaRedirector inner;
|
||||
private final String[] exclusions;
|
||||
|
||||
public AngelicaRedirectorTransformer() {
|
||||
inner = new AngelicaRedirector(AngelicaTweaker.isObfEnv());
|
||||
exclusions = inner.getTransformerExclusions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(final String className, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
// Ignore classes that are excluded from transformation - Doesn't fully work without the
|
||||
// TransformerExclusions due to some nested classes
|
||||
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);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
return basicClass;
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.transformers;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.ICompatHandler;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.CompatHandlers;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic.FieldLevelTessellatorTransformer;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic.HUDCachingEarlyReturnTransformer;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic.ThreadSafeISBRHAnnotationTransformer;
|
||||
import com.gtnewhorizons.angelica.loading.fml.compat.transformers.generic.TileEntityNullGuardTransformer;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.transformers.MixinClassWriter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class GenericCompatTransformer implements IClassTransformer {
|
||||
|
||||
private final Map<String, List<String>> fieldLevelTessellator = new Object2ObjectOpenHashMap<>();
|
||||
private final Map<String, List<String>> tileEntityNullGuard = new Object2ObjectOpenHashMap<>();
|
||||
private final Map<String, Boolean> threadSafeIBSRH = new Object2BooleanOpenHashMap<>();
|
||||
private final Map<String, List<String>> hudCachingEarlyReturn = new Object2ObjectOpenHashMap<>();
|
||||
private final Set<String> targetedClasses = new ObjectOpenHashSet<>();
|
||||
|
||||
public GenericCompatTransformer() {
|
||||
for (ICompatHandler handler : CompatHandlers.getHandlers()) {
|
||||
registerHandler(handler);
|
||||
}
|
||||
buildTargetClassSet();
|
||||
}
|
||||
|
||||
private void registerHandler(ICompatHandler handler) {
|
||||
if (handler.getFieldLevelTessellator() != null) {
|
||||
fieldLevelTessellator.putAll(handler.getFieldLevelTessellator());
|
||||
}
|
||||
if (handler.getTileEntityNullGuard() != null) {
|
||||
tileEntityNullGuard.putAll(handler.getTileEntityNullGuard());
|
||||
}
|
||||
if (handler.getThreadSafeISBRHAnnotations() != null) {
|
||||
threadSafeIBSRH.putAll(handler.getThreadSafeISBRHAnnotations());
|
||||
}
|
||||
if (handler.getHUDCachingEarlyReturn() != null) {
|
||||
hudCachingEarlyReturn.putAll(handler.getHUDCachingEarlyReturn());
|
||||
}
|
||||
}
|
||||
|
||||
private void buildTargetClassSet() {
|
||||
targetedClasses.addAll(fieldLevelTessellator.keySet());
|
||||
targetedClasses.addAll(tileEntityNullGuard.keySet());
|
||||
targetedClasses.addAll(threadSafeIBSRH.keySet());
|
||||
targetedClasses.addAll(hudCachingEarlyReturn.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (!targetedClasses.contains(transformedName)) return basicClass;
|
||||
|
||||
ClassReader cr = new ClassReader(basicClass);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
if (fieldLevelTessellator.containsKey(transformedName)) {
|
||||
FieldLevelTessellatorTransformer.transform(cn, fieldLevelTessellator.get(transformedName));
|
||||
}
|
||||
|
||||
if (tileEntityNullGuard.containsKey(transformedName)) {
|
||||
TileEntityNullGuardTransformer.transform(cn, tileEntityNullGuard.get(transformedName));
|
||||
}
|
||||
|
||||
if (threadSafeIBSRH.containsKey(transformedName)) {
|
||||
ThreadSafeISBRHAnnotationTransformer.transform(cn, threadSafeIBSRH.get(transformedName));
|
||||
}
|
||||
|
||||
if (hudCachingEarlyReturn.containsKey(transformedName)) {
|
||||
HUDCachingEarlyReturnTransformer.transform(cn, hudCachingEarlyReturn.get(transformedName));
|
||||
}
|
||||
|
||||
MixinClassWriter cw = new MixinClassWriter(MixinClassWriter.COMPUTE_MAXS | MixinClassWriter.COMPUTE_FRAMES);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -1,7 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.transform;
|
||||
package com.gtnewhorizons.angelica.loading.fml.transformers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.AngelicaRedirector;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -10,10 +11,9 @@ import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockTransformer implements IClassTransformer {
|
||||
public class SodiumBlockTransformer implements IClassTransformer {
|
||||
|
||||
private static final String BlockClassFriendly = "net.minecraft.block.Block";
|
||||
public static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
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"),
|
||||
@@ -23,12 +23,13 @@ public class BlockTransformer implements IClassTransformer {
|
||||
);
|
||||
|
||||
/**
|
||||
* Delete the global vanilla bounding box fields off the Block object. {@link RedirectorTransformer}
|
||||
* Delete the global vanilla bounding box fields off the Block object. {@link AngelicaRedirector}
|
||||
* replaces these with a thread-safe alternative.
|
||||
*/
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass != null && BlockClassFriendly.equals(transformedName)) {
|
||||
if (basicClass == null) return null;
|
||||
if ("net.minecraft.block.Block".equals(transformedName)) {
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
@@ -36,7 +37,7 @@ public class BlockTransformer implements IClassTransformer {
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
return basicClass;
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.tweakers;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class AngelicaLateTweaker implements ITweaker {
|
||||
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLaunchArguments() {
|
||||
// Run after Mixins, but before LWJGl3ify
|
||||
String transformer = "com.gtnewhorizons.angelica.loading.fml.transformers.AngelicaRedirectorTransformer";
|
||||
FMLRelaunchLog.finer("Registering transformer %s", transformer);
|
||||
Launch.classLoader.registerTransformer(transformer);
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
+30
-77
@@ -1,11 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.loading;
|
||||
package com.gtnewhorizons.angelica.loading.fml.tweakers;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.transform.BlockTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.RedirectorTransformer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.CoreModManager;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
@@ -23,61 +19,44 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
public class IncompatibleModsDisablerTweaker implements ITweaker {
|
||||
|
||||
private static final boolean DISABLE_OPTIFINE_FASTCRAFT_BETTERFPS = true;
|
||||
|
||||
public class MixinCompatHackTweaker implements ITweaker {
|
||||
public static final boolean DISABLE_OPTIFINE_FASTCRAFT_BETTERFPS = true;
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
verifyDependencies();
|
||||
// no-op
|
||||
}
|
||||
|
||||
if(DISABLE_OPTIFINE_FASTCRAFT_BETTERFPS) {
|
||||
LOGGER.info("Disabling Optifine, Fastcraft, BetterFPS, and other incompatible mods (if present)");
|
||||
disableIncompatibleMods();
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableHudCaching){
|
||||
disableXaerosMinimapWaypointTransformer();
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
if (DISABLE_OPTIFINE_FASTCRAFT_BETTERFPS) {
|
||||
FMLRelaunchLog.info("[Angelica/IncompatibleModsDisablerTweaker] Disabling Optifine, Fastcraft, BetterFPS, and other incompatible mods (if present)");
|
||||
disableIncompatibleMods(classLoader);
|
||||
}
|
||||
}
|
||||
|
||||
private void verifyDependencies() {
|
||||
if(MixinCompatHackTweaker.class.getResource("/it/unimi/dsi/fastutil/ints/Int2ObjectMap.class") == null) {
|
||||
throw new RuntimeException("Missing dependency: Angelica requires GTNHLib 0.2.1 or newer! Download: https://modrinth.com/mod/gtnhlib");
|
||||
}
|
||||
@Override
|
||||
public String getLaunchTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void disableXaerosMinimapWaypointTransformer(){
|
||||
try {
|
||||
final LaunchClassLoader lcl = Launch.classLoader;
|
||||
final Field xformersField = lcl.getClass().getDeclaredField("transformers");
|
||||
xformersField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IClassTransformer> xformers = (List<IClassTransformer>) xformersField.get(lcl);
|
||||
for (int idx = xformers.size() - 1; idx >= 0; idx--) {
|
||||
final String name = xformers.get(idx).getClass().getName();
|
||||
if (name.startsWith("xaero.common.core.transformer.GuiIngameForgeTransformer")) {
|
||||
LOGGER.info("Removing transformer " + name);
|
||||
xformers.remove(idx);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@Override
|
||||
public String[] getLaunchArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void disableIncompatibleMods() {
|
||||
private void disableIncompatibleMods(LaunchClassLoader lcl) {
|
||||
// Remove transformers, Mod Containers, and mixins for Optifine, Fastcraft, BetterFPS and other incompatible mods
|
||||
try {
|
||||
final LaunchClassLoader lcl = Launch.classLoader;
|
||||
final Field xformersField = lcl.getClass().getDeclaredField("transformers");
|
||||
xformersField.setAccessible(true);
|
||||
final List<IClassTransformer> xformers = (List<IClassTransformer>) xformersField.get(lcl);
|
||||
for (int idx = xformers.size() - 1; idx >= 0; idx--) {
|
||||
final String name = xformers.get(idx).getClass().getName();
|
||||
if (name.startsWith("optifine") || name.startsWith("fastcraft") || name.startsWith("me.guichaguri.betterfps")) {
|
||||
LOGGER.info("Removing transformer " + name);
|
||||
FMLRelaunchLog.info("[Angelica/IncompatibleModsDisablerTweaker] Removing transformer " + name);
|
||||
xformers.remove(idx);
|
||||
}
|
||||
}
|
||||
@@ -85,13 +64,14 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
final Field injectedContainersField = Loader.class.getDeclaredField("injectedContainers");
|
||||
final Class<?> loaderClass = Class.forName("cpw.mods.fml.common.Loader", true, lcl);
|
||||
final Field injectedContainersField = loaderClass.getDeclaredField("injectedContainers");
|
||||
injectedContainersField.setAccessible(true);
|
||||
final List<String> containers = (List<String> ) injectedContainersField.get(Loader.class);
|
||||
final List<String> containers = (List<String>) injectedContainersField.get(loaderClass);
|
||||
for (int idx = containers.size() - 1; idx >= 0; idx--) {
|
||||
final String name = containers.get(idx);
|
||||
final String name = containers.get(idx);
|
||||
if (name.startsWith("optifine") || name.startsWith("fastcraft")) {
|
||||
LOGGER.info("Removing mod container " + name);
|
||||
FMLRelaunchLog.info("[Angelica/IncompatibleModsDisablerTweaker] Removing mod container " + name);
|
||||
containers.remove(idx);
|
||||
}
|
||||
}
|
||||
@@ -105,7 +85,7 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
for (int idx = reparsedCoremods.size() - 1; idx >= 0; idx--) {
|
||||
final String coreMod = reparsedCoremods.get(idx);
|
||||
if (coreMod.startsWith("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing reparsed coremod " + coreMod);
|
||||
FMLRelaunchLog.info("[Angelica/IncompatibleModsDisablerTweaker] Removing reparsed coremod " + coreMod);
|
||||
// Fool the CoreModManager into not checking for a mod container again later
|
||||
loadedCoremods.add(reparsedCoremods.remove(idx));
|
||||
|
||||
@@ -120,7 +100,7 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
for (int idx = mixinConfigsDefault.size() - 1; idx >= 0; idx--) {
|
||||
final String name = mixinConfigsDefault.get(idx);
|
||||
if (name != null && name.contains("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing mixin config " + name);
|
||||
FMLRelaunchLog.info("[Angelica/IncompatibleModsDisablerTweaker] Removing mixin config " + name);
|
||||
mixinConfigsDefault.remove(idx);
|
||||
}
|
||||
}
|
||||
@@ -131,7 +111,7 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
for (Config config : mixinConfigs) {
|
||||
final String name = config.getName();
|
||||
if (name != null && name.contains("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing queued mixin config " + config.getName());
|
||||
FMLRelaunchLog.info("[Angelica/IncompatibleModsDisablerTweaker] Removing queued mixin config " + config.getName());
|
||||
toRemove.add(config);
|
||||
}
|
||||
}
|
||||
@@ -144,8 +124,8 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
final Map<IContainerHandle, MixinContainer> containers = (Map<IContainerHandle, MixinContainer>) containersField.get(platformManager);
|
||||
for (Map.Entry<IContainerHandle, MixinContainer> entry : containers.entrySet()) {
|
||||
final String attribute = entry.getKey().getAttribute("MixinConfigs");
|
||||
if(attribute != null && attribute.contains("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing mixin container " + entry.getKey().toString());
|
||||
if (attribute != null && attribute.contains("optimizationsandtweaks")) {
|
||||
FMLRelaunchLog.info("[Angelica/IncompatibleModsDisablerTweaker] Removing mixin container " + entry.getKey().toString());
|
||||
containers.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
@@ -155,31 +135,4 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLaunchArguments() {
|
||||
if (FMLLaunchHandler.side().isClient()) {
|
||||
final boolean rfbLoaded = Launch.blackboard.getOrDefault("angelica.rfbPluginLoaded", Boolean.FALSE) == Boolean.TRUE;
|
||||
|
||||
if (!rfbLoaded) {
|
||||
// Run after Mixins, but before LWJGl3ify
|
||||
Launch.classLoader.registerTransformer(RedirectorTransformer.class.getName());
|
||||
}
|
||||
if(AngelicaConfig.enableSodium) {
|
||||
Launch.classLoader.registerTransformer(BlockTransformer.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.tweakers;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public class SodiumLateTweaker implements ITweaker {
|
||||
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLaunchArguments() {
|
||||
String transformer = "com.gtnewhorizons.angelica.loading.fml.transformers.SodiumBlockTransformer";
|
||||
FMLRelaunchLog.finer("Registering transformer %s", transformer);
|
||||
Launch.classLoader.registerTransformer(transformer);
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.gtnewhorizons.angelica.loading.fml.tweakers;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLRelaunchLog;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
public class XaerosTransformerDisablerTweaker implements ITweaker {
|
||||
|
||||
@Override
|
||||
public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
|
||||
try {
|
||||
final Field xformersField = classLoader.getClass().getDeclaredField("transformers");
|
||||
xformersField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IClassTransformer> transformers = (List<IClassTransformer>) xformersField.get(classLoader);
|
||||
for (int idx = transformers.size() - 1; idx >= 0; idx--) {
|
||||
final String name = transformers.get(idx).getClass().getName();
|
||||
if (name.startsWith("xaero.common.core.transformer.GuiIngameForgeTransformer")) {
|
||||
transformers.remove(idx);
|
||||
FMLRelaunchLog.info("[Angelica/XaerosTransformerDisablerTweaker] Removed transformer " + name);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLaunchTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getLaunchArguments() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* ITweaker needs to be in a standalone package
|
||||
* because FML adds the whole package to the class
|
||||
* loader exclusions and that causes really hard to
|
||||
* find bugs. ITweakers also get class loaded
|
||||
* by the parent class loader and not LaunchClassLoader,
|
||||
* as a result the ITweakers should not reference any
|
||||
* class otherwise it will load them (maybe a second time)
|
||||
* on the parent class loader.
|
||||
*/
|
||||
package com.gtnewhorizons.angelica.loading.fml.tweakers;
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.loading.rfb;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.rfb.transformers.RFBAngelicaRedirector;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.PluginContext;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RetroFuturaBootstrap;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformer;
|
||||
@@ -21,8 +22,10 @@ public class AngelicaRfbPlugin implements RfbPlugin {
|
||||
if (isServer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final boolean isObf = RetroFuturaBootstrap.API.launchClassLoader().findClassMetadata("net.minecraft.world.World") == null;
|
||||
return new RfbClassTransformer[] {
|
||||
new RedirectorTransformerWrapper()
|
||||
new RFBAngelicaRedirector(isObf)
|
||||
};
|
||||
}
|
||||
}
|
||||
+13
-7
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.loading.rfb;
|
||||
package com.gtnewhorizons.angelica.loading.rfb.transformers;
|
||||
|
||||
import com.gtnewhorizons.angelica.transform.RedirectorTransformer;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import com.gtnewhorizons.angelica.loading.shared.transformers.AngelicaRedirector;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.ClassNodeHandle;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.ExtensibleClassLoader;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.RfbClassTransformer;
|
||||
@@ -10,10 +11,14 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
/** RFB wrapper for {@link com.gtnewhorizons.angelica.transform.RedirectorTransformer} */
|
||||
public class RedirectorTransformerWrapper implements RfbClassTransformer {
|
||||
/** RfbClassTransformer wrapper for {@link AngelicaRedirector} */
|
||||
public class RFBAngelicaRedirector implements RfbClassTransformer {
|
||||
|
||||
public final RedirectorTransformer inner = new RedirectorTransformer();
|
||||
private final AngelicaRedirector inner;
|
||||
|
||||
public RFBAngelicaRedirector(boolean isObf) {
|
||||
inner = new AngelicaRedirector(isObf);
|
||||
}
|
||||
|
||||
@Pattern("[a-z0-9-]+")
|
||||
@Override
|
||||
@@ -33,7 +38,7 @@ public class RedirectorTransformerWrapper implements RfbClassTransformer {
|
||||
|
||||
@Override
|
||||
public @NotNull String @Nullable [] additionalExclusions() {
|
||||
return RedirectorTransformer.getTransformerExclusions().toArray(new String[0]);
|
||||
return inner.getTransformerExclusions();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +52,7 @@ public class RedirectorTransformerWrapper implements RfbClassTransformer {
|
||||
// If a class is already a transformed ClassNode, conservatively continue processing.
|
||||
return true;
|
||||
}
|
||||
return inner.shouldRfbTransform(classNode.getOriginalBytes());
|
||||
return inner.shouldTransform(classNode.getOriginalBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,6 +61,7 @@ public class RedirectorTransformerWrapper implements RfbClassTransformer {
|
||||
final boolean changed = inner.transformClassNode(className, classNode.getNode());
|
||||
if (changed) {
|
||||
classNode.computeMaxs();
|
||||
AngelicaClassDump.dumpRFBClass(className, classNode, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.gtnewhorizons.angelica.loading.shared;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.asm.ASMUtil;
|
||||
import com.gtnewhorizons.retrofuturabootstrap.api.ClassNodeHandle;
|
||||
|
||||
public class AngelicaClassDump {
|
||||
|
||||
private static final boolean DUMP_CLASS = Boolean.getBoolean("angelica.dumpClass");
|
||||
|
||||
public static void dumpClass(String className, byte[] originalBytes, byte[] transformedBytes, Object transformer) {
|
||||
if (DUMP_CLASS) {
|
||||
ASMUtil.saveAsRawClassFile(originalBytes, className + "_PRE", transformer);
|
||||
ASMUtil.saveAsRawClassFile(transformedBytes, className + "_POST", transformer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void dumpRFBClass(String className, ClassNodeHandle classNode, Object transformer) {
|
||||
if (DUMP_CLASS) {
|
||||
final byte[] originalBytes = classNode.getOriginalBytes();
|
||||
final byte[] transformedBytes = classNode.computeBytes();
|
||||
ASMUtil.saveAsRawClassFile(originalBytes, className + "_PRE", transformer);
|
||||
ASMUtil.saveAsRawClassFile(transformedBytes, className + "_POST", transformer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Package that contains classes that may be loaded both by RFB and FML classloaders, the code contained in this package
|
||||
* should not reference any code from outside of this package to avoid causing hard to debug classloading issues unless
|
||||
* the code is known to be safe with different classloaders.
|
||||
*/
|
||||
package com.gtnewhorizons.angelica.loading.shared;
|
||||
+65
-80
@@ -1,14 +1,12 @@
|
||||
package com.gtnewhorizons.angelica.transform;
|
||||
package com.gtnewhorizons.angelica.loading.shared.transformers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizon.gtnhlib.asm.ClassConstantPoolParser;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.IrisLogging;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
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;
|
||||
@@ -22,7 +20,6 @@ import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -33,10 +30,25 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This transformer redirects many GL calls to our custom GLStateManager
|
||||
* <p>
|
||||
* THIS CLASS MIGHT BE LOADED ON A DIFFERENT CLASS LOADER,
|
||||
* IT SHOULD NOT CALL ANY CODE FROM THE MAIN MOD
|
||||
*/
|
||||
public class RedirectorTransformer implements IClassTransformer {
|
||||
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)
|
||||
|
||||
private static final boolean ASSERT_MAIN_THREAD = Boolean.parseBoolean(System.getProperty("angelica.assertMainThread", "false"));
|
||||
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");
|
||||
private static final Logger LOGGER = LogManager.getLogger("AngelicaRedirector");
|
||||
private static final String Drawable = "org/lwjgl/opengl/Drawable";
|
||||
private static final String GLStateManager = "com/gtnewhorizons/angelica/glsm/GLStateManager";
|
||||
private static final String GL11 = "org/lwjgl/opengl/GL11";
|
||||
@@ -58,24 +70,26 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
"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 List<String> VanillaBlockExclusions = Arrays.asList(
|
||||
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, OpenGlHelper, EXTBlendFunc, ARBMultiTexture, BlockPackage, 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 List<String> TransformerExclusions = Arrays.asList(
|
||||
"org.lwjgl",
|
||||
"com.gtnewhorizons.angelica.glsm.",
|
||||
"com.gtnewhorizons.angelica.transform",
|
||||
"me.eigenraven.lwjgl3ify"
|
||||
);
|
||||
|
||||
private static final Set<String> moddedBlockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
@@ -209,8 +223,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
|
||||
try {
|
||||
final Class<?> angelicaConfig = Class.forName("com.gtnewhorizons.angelica.config.AngelicaConfig", true, Launch.classLoader);
|
||||
final MethodHandle sodiumGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableSodium", boolean.class);
|
||||
angelicaConfigSodiumEnabledGetter = sodiumGetter;
|
||||
angelicaConfigSodiumEnabledGetter = MethodHandles.lookup().findStaticGetter(angelicaConfig, "enableSodium", boolean.class);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -240,45 +253,23 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
return isVanillaBlockSubclass(className) || moddedBlockSubclasses.contains(className);
|
||||
}
|
||||
|
||||
public static List<String> getTransformerExclusions() {
|
||||
return Collections.unmodifiableList(TransformerExclusions);
|
||||
private String getFieldName(Pair<String, String> fieldPair) {
|
||||
return IS_OBF ? fieldPair.getRight() : fieldPair.getLeft();
|
||||
}
|
||||
|
||||
public boolean shouldRfbTransform(byte[] basicClass) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(final String className, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
// Ignore classes that are excluded from transformation - Doesn't fully work without the
|
||||
// TransformerExclusions due to some nested classes
|
||||
for (String exclusion : TransformerExclusions) {
|
||||
if (className.startsWith(exclusion)) {
|
||||
return basicClass;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cstPoolParser.find(basicClass, true)) {
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
// Keep in sync with com.gtnewhorizons.angelica.loading.rfb.RedirectorTransformerWrapper
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
final boolean changed = transformClassNode(transformedName, cn);
|
||||
if (changed) {
|
||||
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
/** @return Was the class changed? */
|
||||
public boolean transformClassNode(String transformedName, ClassNode cn) {
|
||||
if (cn == null) {
|
||||
@@ -292,19 +283,19 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
|
||||
// Check if this class shadows any fields of the parent class
|
||||
if(moddedBlockSubclasses.contains(cn.name)) {
|
||||
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)) {
|
||||
if (blockOwnerExclusions.contains(cn.superName)) {
|
||||
doWeShadow = true;
|
||||
} else {
|
||||
// Check if we declare any known field names
|
||||
Set<String> fieldsDeclaredByClass = cn.fields.stream().map(f -> f.name).collect(Collectors.toSet());
|
||||
doWeShadow = BlockTransformer.BlockBoundsFields.stream().anyMatch(pair -> fieldsDeclaredByClass.contains(pair.getLeft()) || fieldsDeclaredByClass.contains(pair.getRight()));
|
||||
doWeShadow = BlockBoundsFields.stream().anyMatch(pair ->
|
||||
cn.fields.stream().anyMatch(field -> field.name.equals(getFieldName(pair))));
|
||||
}
|
||||
if (doWeShadow) {
|
||||
AngelicaTweaker.LOGGER.info("Class '{}' shadows one or more block bounds fields, these accesses won't be redirected!", cn.name);
|
||||
LOGGER.info("Class '{}' shadows one or more block bounds fields, these accesses won't be redirected!", cn.name);
|
||||
blockOwnerExclusions.add(cn.name);
|
||||
}
|
||||
}
|
||||
@@ -332,11 +323,11 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
name = "disable" + name;
|
||||
}
|
||||
}
|
||||
if (IrisLogging.ENABLE_SPAM) {
|
||||
if (LOG_SPAM) {
|
||||
if (name == null) {
|
||||
AngelicaTweaker.LOGGER.info("Redirecting call in {} from GL11.{}(I)V to GLStateManager.{}(I)V", transformedName, mNode.name, mNode.name);
|
||||
LOGGER.info("Redirecting call in {} from GL11.{}(I)V to GLStateManager.{}(I)V", transformedName, mNode.name, mNode.name);
|
||||
} else {
|
||||
AngelicaTweaker.LOGGER.info("Redirecting call in {} from GL11.{}(I)V to GLStateManager.{}()V", transformedName, mNode.name, name);
|
||||
LOGGER.info("Redirecting call in {} from GL11.{}(I)V to GLStateManager.{}()V", transformedName, mNode.name, name);
|
||||
}
|
||||
}
|
||||
mNode.owner = GLStateManager;
|
||||
@@ -353,15 +344,15 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
mNode.desc = "(L" + Drawable + ";)V";
|
||||
mNode.itf = false;
|
||||
changed = true;
|
||||
if (IrisLogging.ENABLE_SPAM) {
|
||||
AngelicaTweaker.LOGGER.info("Redirecting call in {} to GLStateManager.makeCurrent()", transformedName);
|
||||
if (LOG_SPAM) {
|
||||
LOGGER.info("Redirecting call in {} to GLStateManager.makeCurrent()", transformedName);
|
||||
}
|
||||
} else {
|
||||
final Map<String, String> redirects = methodRedirects.get(mNode.owner);
|
||||
if (redirects != null && redirects.containsKey(mNode.name)) {
|
||||
if (IrisLogging.ENABLE_SPAM) {
|
||||
if (LOG_SPAM) {
|
||||
final String shortOwner = mNode.owner.substring(mNode.owner.lastIndexOf("/") + 1);
|
||||
AngelicaTweaker.LOGGER.info("Redirecting call in {} from {}.{}{} to GLStateManager.{}{}", transformedName, shortOwner, mNode.name, mNode.desc, redirects.get(mNode.name), mNode.desc);
|
||||
LOGGER.info("Redirecting call in {} from {}.{}{} to GLStateManager.{}{}", transformedName, shortOwner, mNode.name, mNode.desc, redirects.get(mNode.name), mNode.desc);
|
||||
}
|
||||
mNode.owner = GLStateManager;
|
||||
mNode.name = redirects.get(mNode.name);
|
||||
@@ -369,19 +360,15 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
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 = null;
|
||||
for(Pair<String, String> blockPairs : BlockTransformer.BlockBoundsFields) {
|
||||
if(fNode.name.equals(blockPairs.getLeft()) || fNode.name.equals(blockPairs.getRight())) {
|
||||
fieldToRedirect = blockPairs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} 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 (IrisLogging.ENABLE_SPAM) {
|
||||
AngelicaTweaker.LOGGER.info("Redirecting Block.{} in {} to thread-safe wrapper", fNode.name, transformedName);
|
||||
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
|
||||
@@ -421,8 +408,6 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
|
||||
private static class RedirectMap<K> extends HashMap<K, K> {
|
||||
|
||||
private static final long serialVersionUID = 1712218575345511543L;
|
||||
|
||||
public static RedirectMap<String> newMap() {
|
||||
return new RedirectMap<>();
|
||||
}
|
||||
@@ -1,216 +1,243 @@
|
||||
package com.gtnewhorizons.angelica.mixins;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.builders.IMixins;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.MixinBuilder;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import jss.notfine.config.MCPatcherForgeConfig;
|
||||
import jss.notfine.config.NotFineConfig;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public enum Mixins {
|
||||
ANGELICA_STARTUP(new Builder("Angelica Startup").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.startup.MixinInitGLStateManager"
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum Mixins implements IMixins {
|
||||
|
||||
ANGELICA_STARTUP(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins(
|
||||
"angelica.startup.MixinInitGLStateManager"
|
||||
)
|
||||
),
|
||||
|
||||
ANGELICA(new Builder("Angelica").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.MixinActiveRenderInfo"
|
||||
,"angelica.MixinEntityRenderer"
|
||||
,"angelica.MixinGameSettings"
|
||||
,"angelica.MixinMinecraft"
|
||||
,"angelica.MixinMinecraftServer"
|
||||
,"angelica.optimizations.MixinRendererLivingEntity"
|
||||
,"angelica.MixinFMLClientHandler"
|
||||
,"angelica.bugfixes.MixinRenderGlobal_DestroyBlock"
|
||||
ANGELICA(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins(
|
||||
"angelica.MixinActiveRenderInfo"
|
||||
, "angelica.MixinEntityRenderer"
|
||||
, "angelica.MixinGameSettings"
|
||||
, "angelica.MixinMinecraft"
|
||||
, "angelica.MixinMinecraftServer"
|
||||
, "angelica.optimizations.MixinRendererLivingEntity"
|
||||
, "angelica.MixinFMLClientHandler"
|
||||
, "angelica.bugfixes.MixinRenderGlobal_DestroyBlock"
|
||||
)
|
||||
),
|
||||
ANGELICA_VBO(
|
||||
new Builder("Angelica VBO").addTargetedMod(TargetedMod.VANILLA).setApplyIf(() -> AngelicaConfig.enableVBO).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.vbo.MixinGLAllocation"
|
||||
,"angelica.vbo.MixinModelRenderer"
|
||||
,"angelica.vbo.MixinRenderGlobal"
|
||||
,"angelica.vbo.MixinWavefrontObject"
|
||||
)
|
||||
new MixinBuilder()
|
||||
.setApplyIf(() -> AngelicaConfig.enableVBO)
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins(
|
||||
"angelica.vbo.MixinGLAllocation"
|
||||
, "angelica.vbo.MixinModelRenderer"
|
||||
, "angelica.vbo.MixinRenderGlobal"
|
||||
, "angelica.vbo.MixinWavefrontObject"
|
||||
)
|
||||
),
|
||||
ANGELICA_FONT_RENDERER(new Builder("Angelica Font Renderer").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableFontRenderer).addMixinClasses(
|
||||
"angelica.fontrenderer.MixinGuiIngameForge"
|
||||
,"angelica.fontrenderer.MixinFontRenderer"
|
||||
ANGELICA_FONT_RENDERER(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableFontRenderer)
|
||||
.addClientMixins(
|
||||
"angelica.fontrenderer.MixinGuiIngameForge"
|
||||
, "angelica.fontrenderer.MixinFontRenderer"
|
||||
, "angelica.fontrenderer.MixinMCResourceAccessor"
|
||||
)
|
||||
),
|
||||
|
||||
ANGELICA_ENABLE_DEBUG(new Builder("Angelica Debug").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaMod.lwjglDebug).addMixinClasses(
|
||||
"angelica.debug.MixinProfiler"
|
||||
,"angelica.debug.MixinSplashProgress"
|
||||
,"angelica.debug.MixinTextureManager"
|
||||
ANGELICA_ENABLE_DEBUG(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaMod.lwjglDebug)
|
||||
.addClientMixins(
|
||||
"angelica.debug.MixinProfiler"
|
||||
, "angelica.debug.MixinSplashProgress"
|
||||
, "angelica.debug.MixinTextureManager"
|
||||
)
|
||||
),
|
||||
ANGELICA_DYNAMIC_LIGHTS(new Builder("Angelica Dynamic Lights").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableDynamicLights).addMixinClasses(
|
||||
ANGELICA_DYNAMIC_LIGHTS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableDynamicLights)
|
||||
.addClientMixins(
|
||||
"angelica.dynamiclights.MixinEntityRenderer"
|
||||
,"angelica.dynamiclights.MixinEntity"
|
||||
,"angelica.dynamiclights.MixinWorld"
|
||||
,"angelica.dynamiclights.MixinItemRenderer"
|
||||
, "angelica.dynamiclights.MixinEntity"
|
||||
, "angelica.dynamiclights.MixinWorld"
|
||||
, "angelica.dynamiclights.MixinItemRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
ANGELICA_FIX_FLUID_RENDERER_CHECKING_BLOCK_AGAIN(
|
||||
new Builder("Fix RenderBlockFluid reading the block type from the world access multiple times")
|
||||
.setPhase(Phase.EARLY).addMixinClasses("angelica.bugfixes.MixinRenderBlockFluid").setSide(Side.BOTH)
|
||||
.setApplyIf(() -> AngelicaConfig.fixFluidRendererCheckingBlockAgain)
|
||||
.addTargetedMod(TargetedMod.VANILLA)),
|
||||
new MixinBuilder("Fix RenderBlockFluid reading the block type from the world access multiple times")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.bugfixes.MixinRenderBlockFluid")
|
||||
.setApplyIf(() -> AngelicaConfig.fixFluidRendererCheckingBlockAgain)),
|
||||
|
||||
ANGELICA_LIMIT_DROPPED_ITEM_ENTITIES(new Builder("Dynamically modifies the render distance of dropped items entities to preserve performance")
|
||||
.setPhase(Phase.EARLY).addMixinClasses("angelica.optimizations.MixinRenderGlobal_ItemRenderDist").setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.dynamicItemRenderDistance)
|
||||
.addTargetedMod(TargetedMod.VANILLA)),
|
||||
ANGELICA_LIMIT_DROPPED_ITEM_ENTITIES(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.optimizations.MixinRenderGlobal_ItemRenderDist")
|
||||
.setApplyIf(() -> AngelicaConfig.dynamicItemRenderDistance)),
|
||||
|
||||
ANGELICA_ITEM_DISPLAY_LIST_OPTIMIZATION(new Builder("Optimized item rendering by wrapping them with display lists")
|
||||
.setPhase(Phase.EARLY).addMixinClasses("angelica.itemrenderer.MixinItemRenderer").setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering_WIP)
|
||||
.addTargetedMod(TargetedMod.VANILLA)),
|
||||
ANGELICA_ITEM_RENDERER_OPTIMIZATION(new MixinBuilder("Optimizes in-world item rendering")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.itemrenderer.MixinItemRenderer")
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering)),
|
||||
|
||||
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
|
||||
ARCHAIC_SPLASH(new Builder("ArchaicFix Splash").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.showSplashMemoryBar && !AngelicaMod.lwjglDebug).addMixinClasses(
|
||||
"angelica.archaic.MixinSplashProgress$3"
|
||||
,"angelica.archaic.AccessorSplashProgress"
|
||||
ARCHAIC_SPLASH(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.showSplashMemoryBar && !AngelicaMod.lwjglDebug)
|
||||
.addClientMixins(
|
||||
"angelica.archaic.MixinSplashProgress$3",
|
||||
"angelica.archaic.AccessorSplashProgress"
|
||||
)
|
||||
),
|
||||
|
||||
ARCHAIC_CORE(new Builder("Archaic Core").addTargetedMod(TargetedMod.VANILLA).addExcludedMod(TargetedMod.ARCHAICFIX)
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.archaic.MixinBlockFence"
|
||||
,"angelica.archaic.MixinFMLClientHandler"
|
||||
,"angelica.archaic.MixinGuiIngameForge"
|
||||
,"angelica.archaic.MixinNetHandlerPlayClient"
|
||||
,"angelica.archaic.MixinThreadDownloadImageData"
|
||||
ARCHAIC_CORE(new MixinBuilder()
|
||||
.addExcludedMod(TargetedMod.ARCHAICFIX)
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins(
|
||||
"angelica.archaic.MixinBlockFence"
|
||||
, "angelica.archaic.MixinFMLClientHandler"
|
||||
, "angelica.archaic.MixinGuiIngameForge"
|
||||
, "angelica.archaic.MixinNetHandlerPlayClient"
|
||||
, "angelica.archaic.MixinThreadDownloadImageData"
|
||||
)
|
||||
),
|
||||
|
||||
IRIS_STARTUP(new Builder("Start Iris").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
|
||||
"shaders.startup.MixinGameSettings"
|
||||
,"shaders.startup.MixinMinecraft"
|
||||
,"shaders.startup.MixinInitRenderer"
|
||||
,"shaders.startup.MixinAbstractTexture"
|
||||
,"shaders.startup.MixinTextureAtlasSprite"
|
||||
,"shaders.startup.MixinTextureMap"
|
||||
IRIS_STARTUP(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins(
|
||||
"shaders.startup.MixinGameSettings"
|
||||
, "shaders.startup.MixinMinecraft"
|
||||
, "shaders.startup.MixinInitRenderer"
|
||||
, "shaders.startup.MixinAbstractTexture"
|
||||
, "shaders.startup.MixinTextureAtlasSprite"
|
||||
, "shaders.startup.MixinTextureMap"
|
||||
)
|
||||
),
|
||||
|
||||
SODIUM(new Builder("Sodium").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableSodium).addMixinClasses(
|
||||
"sodium.MixinBlock"
|
||||
,"sodium.MixinBlockFluidBase"
|
||||
,"sodium.AccessorBiomeColorEvent"
|
||||
,"sodium.MixinBiomeGenBase"
|
||||
,"sodium.MixinChunk"
|
||||
,"sodium.MixinChunkProviderServer"
|
||||
,"sodium.MixinClientRegistry"
|
||||
,"sodium.MixinEntity_RenderDist"
|
||||
,"sodium.MixinEntityItem_RenderDist"
|
||||
,"sodium.MixinRenderManager"
|
||||
,"sodium.MixinEntityRenderer"
|
||||
,"sodium.MixinFMLClientHandler"
|
||||
,"sodium.MixinForgeHooksClient"
|
||||
,"sodium.MixinGameSettings"
|
||||
,"sodium.MixinFrustrum"
|
||||
,"sodium.MixinMinecraft"
|
||||
,"sodium.MixinRenderBlocks"
|
||||
,"sodium.MixinRenderGlobal"
|
||||
,"sodium.MixinWorldClient"
|
||||
,"sodium.MixinTileEntity"
|
||||
,"sodium.MixinTileEntityMobSpawner"
|
||||
,"sodium.MixinEffectRenderer"
|
||||
,"sodium.MixinTileEntityRendererDispatcher"
|
||||
,"sodium.MixinLongHashMap"
|
||||
,"sodium.MixinRenderingRegistry"
|
||||
,"sodium.MixinPlayerManager"
|
||||
SODIUM(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableSodium)
|
||||
.addClientMixins(
|
||||
"sodium.MixinBlock"
|
||||
, "sodium.MixinBlockFluidBase"
|
||||
, "sodium.AccessorBiomeColorEvent"
|
||||
, "sodium.MixinBiomeGenBase"
|
||||
, "sodium.MixinChunk"
|
||||
, "sodium.MixinChunkProviderServer"
|
||||
, "sodium.MixinClientRegistry"
|
||||
, "sodium.MixinEntity_RenderDist"
|
||||
, "sodium.MixinEntityItem_RenderDist"
|
||||
, "sodium.MixinRenderManager"
|
||||
, "sodium.MixinEntityRenderer"
|
||||
, "sodium.MixinFMLClientHandler"
|
||||
, "sodium.MixinForgeHooksClient"
|
||||
, "sodium.MixinGameSettings"
|
||||
, "sodium.MixinFrustrum"
|
||||
, "sodium.MixinMinecraft"
|
||||
, "sodium.MixinRenderBlocks"
|
||||
, "sodium.MixinRenderGlobal"
|
||||
, "sodium.MixinWorldClient"
|
||||
, "sodium.MixinTileEntity"
|
||||
, "sodium.MixinTileEntityMobSpawner"
|
||||
, "sodium.MixinEffectRenderer"
|
||||
, "sodium.MixinTileEntityRendererDispatcher"
|
||||
, "sodium.MixinLongHashMap"
|
||||
, "sodium.MixinRenderingRegistry"
|
||||
, "sodium.MixinPlayerManager"
|
||||
)
|
||||
),
|
||||
|
||||
IRIS_RENDERING(new Builder("Iris Shaders").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
|
||||
"shaders.MixinEntityRenderer"
|
||||
,"shaders.MixinGuiIngameForge"
|
||||
,"shaders.MixinFramebuffer"
|
||||
,"shaders.MixinItem"
|
||||
,"shaders.MixinLocale"
|
||||
,"shaders.MixinOpenGlHelper"
|
||||
,"shaders.MixinRender"
|
||||
,"shaders.MixinRendererLivingEntity"
|
||||
,"shaders.MixinRenderGlobal"
|
||||
,"shaders.MixinTileEntityBeaconRenderer"
|
||||
IRIS_SHADERS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins(
|
||||
"shaders.MixinEntityRenderer"
|
||||
, "shaders.MixinGuiIngameForge"
|
||||
, "shaders.MixinFramebuffer"
|
||||
, "shaders.MixinItem"
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinOpenGlHelper"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRendererLivingEntity"
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.MixinTileEntityBeaconRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
IRIS_RENDERING_NOBACKHAND(new Builder("Iris Hand Shaders").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addExcludedMod(TargetedMod.BACKHAND).addMixinClasses(
|
||||
IRIS_RENDERING_NOBACKHAND(new MixinBuilder("Iris Hand Shaders")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addExcludedMod(TargetedMod.BACKHAND)
|
||||
.addClientMixins(
|
||||
"shaders.MixinItemRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
IRIS_RENDERING_BACKHAND(new Builder("Iris Hand Shaders (Backhand)").addTargetedMod(TargetedMod.VANILLA)
|
||||
.addTargetedMod(TargetedMod.BACKHAND).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
|
||||
IRIS_RENDERING_BACKHAND(new MixinBuilder("Iris Hand Shaders (Backhand)")
|
||||
.addRequiredMod(TargetedMod.BACKHAND)
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins(
|
||||
"shaders.MixinItemRendererBackhand"
|
||||
)
|
||||
),
|
||||
|
||||
IRIS_ACCESSORS(new Builder("Iris Accessors").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses("shaders.accessors.MixinEntityRenderer")
|
||||
),
|
||||
|
||||
ANGELICA_TEXTURE(new Builder("Textures").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris || AngelicaConfig.enableSodium).addMixinClasses(
|
||||
"angelica.textures.MixinTextureAtlasSprite"
|
||||
,"angelica.textures.MixinTextureUtil"
|
||||
ANGELICA_TEXTURE(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris || AngelicaConfig.enableSodium)
|
||||
.addClientMixins(
|
||||
"angelica.textures.MixinTextureAtlasSprite"
|
||||
, "angelica.textures.MixinTextureUtil"
|
||||
)),
|
||||
|
||||
ANGELICA_ZOOM(new Builder("Zoom").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableZoom)
|
||||
.addMixinClasses(
|
||||
ANGELICA_ZOOM(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableZoom)
|
||||
.addClientMixins(
|
||||
"angelica.zoom.MixinEntityRenderer_Zoom",
|
||||
"angelica.zoom.MixinMinecraft_Zoom",
|
||||
"angelica.zoom.MixinMouseFilter"
|
||||
)),
|
||||
|
||||
HUD_CACHING(new Builder("Renders the HUD elements 20 times per second maximum to improve performance")
|
||||
.addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableHudCaching).addMixinClasses(
|
||||
"angelica.hudcaching.MixinGuiIngame",
|
||||
"angelica.hudcaching.MixinGuiIngameForge",
|
||||
HUD_CACHING(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableHudCaching)
|
||||
.addClientMixins(
|
||||
"angelica.hudcaching.MixinGuiIngame",
|
||||
"angelica.hudcaching.MixinGuiIngameForge",
|
||||
"angelica.hudcaching.MixinRenderGameOverlayEvent",
|
||||
"angelica.hudcaching.MixinEntityRenderer_HUDCaching",
|
||||
"angelica.hudcaching.MixinFramebuffer_HUDCaching",
|
||||
"angelica.hudcaching.MixinGuiIngame_HUDCaching",
|
||||
"angelica.hudcaching.MixinGuiIngameForge_HUDCaching",
|
||||
"angelica.hudcaching.MixinRenderItem")
|
||||
|
||||
),
|
||||
|
||||
OPTIMIZE_WORLD_UPDATE_LIGHT(new Builder("Optimize world updateLightByType method").setPhase(Phase.EARLY)
|
||||
.setSide(Side.BOTH).addTargetedMod(TargetedMod.VANILLA).addExcludedMod(TargetedMod.ARCHAICFIX).setApplyIf(() -> AngelicaConfig.optimizeWorldUpdateLight)
|
||||
.addMixinClasses("angelica.lighting.MixinWorld_FixLightUpdateLag")),
|
||||
OPTIMIZE_WORLD_UPDATE_LIGHT(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addExcludedMod(TargetedMod.ARCHAICFIX)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeWorldUpdateLight)
|
||||
.addCommonMixins("angelica.lighting.MixinWorld_FixLightUpdateLag")),
|
||||
|
||||
|
||||
SPEEDUP_VANILLA_ANIMATIONS(new Builder("Speedup Vanilla Animations").setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.speedupAnimations).setSide(Side.CLIENT).addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(
|
||||
SPEEDUP_VANILLA_ANIMATIONS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
|
||||
.addClientMixins(
|
||||
"angelica.animation.MixinTextureAtlasSprite",
|
||||
"angelica.animation.MixinTextureMap",
|
||||
"angelica.animation.MixinBlockFire",
|
||||
@@ -221,51 +248,57 @@ public enum Mixins {
|
||||
"angelica.animation.MixinWorldRenderer",
|
||||
"angelica.animation.MixinRenderItem")),
|
||||
|
||||
SCALED_RESOUTION_UNICODE_FIX(new Builder("Removes unicode languages gui scaling being forced to even values").setPhase(Phase.EARLY)
|
||||
.setSide(Side.CLIENT).addTargetedMod(TargetedMod.VANILLA)
|
||||
SCALED_RESOUTION_UNICODE_FIX(new MixinBuilder("Removes unicode languages gui scaling being forced to even values")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.removeUnicodeEvenScaling)
|
||||
.addMixinClasses("angelica.bugfixes.MixinScaledResolution_UnicodeFix")),
|
||||
.addClientMixins("angelica.bugfixes.MixinScaledResolution_UnicodeFix")),
|
||||
|
||||
SECURITYCRAFT_COMPAT(new Builder("Fix reflection in SecurityCraft for compat with Angelica").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.SECURITYCRAFT).setSide(Side.CLIENT)
|
||||
SECURITYCRAFT_COMPAT(new MixinBuilder("Fix reflection in SecurityCraft for compat with Angelica")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.SECURITYCRAFT)
|
||||
.setApplyIf(() -> CompatConfig.fixSecurityCraft)
|
||||
.addMixinClasses(
|
||||
.addClientMixins(
|
||||
"client.securitycraft.MixinBlockReinforcedFenceGate",
|
||||
"client.securitycraft.MixinBlockReinforcedIronBars"
|
||||
)),
|
||||
|
||||
EXTRA_UTILITIES_THREAD_SAFETY(new Builder("Enable thread safety fixes in Extra Utilities").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.EXTRAUTILS).setSide(Side.CLIENT)
|
||||
EXTRA_UTILITIES_THREAD_SAFETY(new MixinBuilder("Enable thread safety fixes in Extra Utilities")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.EXTRAUTILS)
|
||||
.setApplyIf(() -> CompatConfig.fixExtraUtils)
|
||||
.addMixinClasses(
|
||||
.addClientMixins(
|
||||
"client.extrautils.MixinRenderBlockConnectedTextures",
|
||||
"client.extrautils.MixinRenderBlockConnectedTexturesEthereal",
|
||||
"client.extrautils.MixinIconConnectedTexture")),
|
||||
|
||||
MFR_THREAD_SAFETY(new Builder("Enable thread safety fixes for MineFactory Reloaded").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.MINEFACTORY_RELOADED).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> CompatConfig.fixMinefactoryReloaded)
|
||||
.addMixinClasses("client.minefactoryreloaded.MixinRedNetCableRenderer")),
|
||||
MFR_THREAD_SAFETY(new MixinBuilder("Enable thread safety fixes for MineFactory Reloaded")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.MINEFACTORY_RELOADED)
|
||||
.setApplyIf(() -> CompatConfig.fixMinefactoryReloaded)
|
||||
.addClientMixins("client.minefactoryreloaded.MixinRedNetCableRenderer")),
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new Builder("Add animation speedup support to Campfire Backport").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.CAMPFIRE_BACKPORT).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
|
||||
.addMixinClasses("client.campfirebackport.MixinRenderBlockCampfire")),
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new MixinBuilder("Add animation speedup support to Campfire Backport")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.CAMPFIRE_BACKPORT)
|
||||
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
|
||||
.addClientMixins("client.campfirebackport.MixinRenderBlockCampfire")),
|
||||
|
||||
IC2_FLUID_RENDER_FIX(new Builder("IC2 Fluid Render Fix").setPhase(Phase.EARLY).setSide(Side.CLIENT)
|
||||
.addTargetedMod(TargetedMod.IC2).setApplyIf(() -> AngelicaConfig.speedupAnimations)
|
||||
.addMixinClasses("angelica.textures.ic2.MixinRenderLiquidCell")),
|
||||
IC2_FLUID_RENDER_FIX(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addRequiredMod(TargetedMod.IC2)
|
||||
.setApplyIf(() -> AngelicaConfig.speedupAnimations)
|
||||
.addClientMixins("angelica.textures.ic2.MixinRenderLiquidCell")),
|
||||
|
||||
OPTIMIZE_TEXTURE_LOADING(new Builder("Optimize Texture Loading").setPhase(Phase.EARLY)
|
||||
.addMixinClasses("angelica.textures.MixinTextureUtil_OptimizeMipmap").addTargetedMod(TargetedMod.VANILLA)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeTextureLoading).setSide(Side.CLIENT)),
|
||||
OPTIMIZE_TEXTURE_LOADING(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.textures.MixinTextureUtil_OptimizeMipmap")
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeTextureLoading)),
|
||||
|
||||
//From NotFine
|
||||
NOTFINE_BASE_MOD(new Builder("NotFine")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
NOTFINE_BASE_MOD(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("notfine.",
|
||||
.addClientMixins(addPrefix("notfine.",
|
||||
"clouds.MixinEntityRenderer",
|
||||
"clouds.MixinGameSettings",
|
||||
//"clouds.MixinRenderGlobal",
|
||||
@@ -297,11 +330,10 @@ public enum Mixins {
|
||||
"interpolatedtexturemap.MixinTextureMap"
|
||||
))
|
||||
),
|
||||
BETTER_FACE_CULLING(new Builder("Better face culling")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
BETTER_FACE_CULLING(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> NotFineConfig.betterBlockFaceCulling)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("notfine.faceculling.",
|
||||
.addClientMixins(addPrefix("notfine.faceculling.",
|
||||
"MixinBlock",
|
||||
"MixinBlockCactus",
|
||||
"MixinBlockCarpet",
|
||||
@@ -313,103 +345,94 @@ public enum Mixins {
|
||||
"MixinRenderBlocks"
|
||||
))
|
||||
),
|
||||
NOTFINE_NO_DYNAMIC_SURROUNDINGS(new Builder("NotFine no Dynamic Surroundings")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> true)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
NOTFINE_NO_DYNAMIC_SURROUNDINGS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.addExcludedMod(TargetedMod.DYNAMIC_SURROUNDINGS_MIST)
|
||||
.addExcludedMod(TargetedMod.DYNAMIC_SURROUNDINGS_ORIGINAL)
|
||||
.addMixinClasses("notfine.toggle.MixinEntityRenderer$RenderRainSnow")
|
||||
.addClientMixins("notfine.toggle.MixinEntityRenderer$RenderRainSnow")
|
||||
),
|
||||
NOTFINE_NO_CUSTOM_ITEM_TEXTURES(new Builder("NotFine no Custom Item Textures")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
NOTFINE_NO_CUSTOM_ITEM_TEXTURES(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> !AngelicaConfig.enableMCPatcherForgeFeatures || !MCPatcherForgeConfig.CustomItemTextures.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("notfine.glint.",
|
||||
.addClientMixins(addPrefix("notfine.glint.",
|
||||
"MixinItemRenderer",
|
||||
"MixinRenderItem"
|
||||
))
|
||||
),
|
||||
NOTFINE_NATURA(new Builder("NotFine Natura compat")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.LATE)
|
||||
NOTFINE_NATURA_COMPAT(new MixinBuilder()
|
||||
.setPhase(Phase.LATE)
|
||||
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
|
||||
.addTargetedMod(TargetedMod.NATURA)
|
||||
.addMixinClasses(addPrefix("notfine.leaves.natura.",
|
||||
.addRequiredMod(TargetedMod.NATURA)
|
||||
.addClientMixins(addPrefix("notfine.leaves.natura.",
|
||||
"MixinBerryBush",
|
||||
"MixinNetherBerryBush"
|
||||
))
|
||||
),
|
||||
NOTFINE_THAUMCRAFT(new Builder("NotFine Thaumcraft compat")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.LATE)
|
||||
NOTFINE_THAUMCRAFT_COMPAT(new MixinBuilder()
|
||||
.setPhase(Phase.LATE)
|
||||
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
|
||||
.addTargetedMod(TargetedMod.THAUMCRAFT)
|
||||
.addMixinClasses("notfine.leaves.thaumcraft.MixinBlockMagicalLeaves")
|
||||
.addRequiredMod(TargetedMod.THAUMCRAFT)
|
||||
.addClientMixins("notfine.leaves.thaumcraft.MixinBlockMagicalLeaves")
|
||||
),
|
||||
THAUMCRAFT_BETTER_FACE_CULLING(new Builder("Better face culling Thaumcraft compat")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.LATE)
|
||||
THAUMCRAFT_BETTER_FACE_CULLING(new MixinBuilder()
|
||||
.setPhase(Phase.LATE)
|
||||
.setApplyIf(() -> NotFineConfig.betterBlockFaceCulling)
|
||||
.addTargetedMod(TargetedMod.THAUMCRAFT)
|
||||
.addMixinClasses(addPrefix("notfine.faceculling.thaumcraft.",
|
||||
.addRequiredMod(TargetedMod.THAUMCRAFT)
|
||||
.addClientMixins(addPrefix("notfine.faceculling.thaumcraft.",
|
||||
"MixinBlockWoodenDevice",
|
||||
"MixinBlockStoneDevice",
|
||||
"MixinBlockTable"
|
||||
))
|
||||
),
|
||||
NOTFINE_TINKERS_CONSTRUCT(new Builder("NotFine Tinker's Construct compat")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.LATE)
|
||||
NOTFINE_TINKERS_CONSTRUCT_COMPAT(new MixinBuilder()
|
||||
.setPhase(Phase.LATE)
|
||||
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
|
||||
.addTargetedMod(TargetedMod.TINKERS_CONSTRUCT)
|
||||
.addMixinClasses("notfine.leaves.tconstruct.MixinOreberryBush")
|
||||
.addRequiredMod(TargetedMod.TINKERS_CONSTRUCT)
|
||||
.addClientMixins("notfine.leaves.tconstruct.MixinOreberryBush")
|
||||
),
|
||||
NOTFINE_WITCHERY(new Builder("NotFine Witchery compat")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.LATE)
|
||||
NOTFINE_WITCHERY_COMPAT(new MixinBuilder()
|
||||
.setPhase(Phase.LATE)
|
||||
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
|
||||
.addTargetedMod(TargetedMod.WITCHERY)
|
||||
.addMixinClasses("notfine.leaves.witchery.MixinBlockWitchLeaves")
|
||||
.addRequiredMod(TargetedMod.WITCHERY)
|
||||
.addClientMixins("notfine.leaves.witchery.MixinBlockWitchLeaves")
|
||||
),
|
||||
NOTFINE_TWILIGHT_FOREST(new Builder("NotFine Twilight Forest compat")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.LATE)
|
||||
NOTFINE_TWILIGHT_FOREST_COMPAT(new MixinBuilder()
|
||||
.setPhase(Phase.LATE)
|
||||
.setApplyIf(() -> AngelicaConfig.enableNotFineFeatures)
|
||||
.addTargetedMod(TargetedMod.TWILIGHT_FOREST)
|
||||
.addMixinClasses(addPrefix("notfine.leaves.twilightforest.",
|
||||
.addRequiredMod(TargetedMod.TWILIGHT_FOREST)
|
||||
.addClientMixins(addPrefix("notfine.leaves.twilightforest.",
|
||||
"MixinBlockTFLeaves",
|
||||
"MixinBlockTFLeaves3",
|
||||
// TODO: Verify 2.3.8.18 or later to support non NH builds?
|
||||
"MixinBlockTFMagicLeaves"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE(new Builder("MCPatcher Forge")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("mcpatcherforge.",
|
||||
.addClientMixins(addPrefix("mcpatcherforge.",
|
||||
"base.MixinBlockGrass",
|
||||
"base.MixinBlockMycelium",
|
||||
|
||||
"base.MixinAbstractTexture",
|
||||
"base.MixinTextureAtlasSprite",
|
||||
|
||||
"base.MixinSimpleReloadableResourceManager",
|
||||
|
||||
"base.MixinMinecraft"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE_RENDERPASS(new Builder("MCPatcher Forge Renderpass")
|
||||
MCPATCHER_FORGE_RENDERPASS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> NotFineConfig.renderPass)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("mcpatcherforge.",
|
||||
.addClientMixins(addPrefix("mcpatcherforge.",
|
||||
"renderpass.MixinEntityRenderer",
|
||||
"renderpass.MixinRenderBlocks",
|
||||
"renderpass.MixinRenderGlobal",
|
||||
"renderpass.MixinWorldRenderer"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE_CUSTOM_COLORS(new Builder("MCP:F Custom Colors")
|
||||
.setSide(Mixins.Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_CUSTOM_COLORS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("mcpatcherforge.cc.",
|
||||
.addClientMixins(addPrefix("mcpatcherforge.cc.",
|
||||
"block.material.MixinMapColor",
|
||||
|
||||
"block.MixinBlock",
|
||||
@@ -461,11 +484,10 @@ public enum Mixins {
|
||||
"world.MixinWorldProviderHell"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE_CUSTOM_ITEM_TEXTURES(new Builder("MCP:F Custom Item Textures")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_CUSTOM_ITEM_TEXTURES(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.CustomItemTextures.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("mcpatcherforge.cit.",
|
||||
.addClientMixins(addPrefix("mcpatcherforge.cit.",
|
||||
"client.renderer.entity.MixinRenderBiped",
|
||||
"client.renderer.entity.MixinRenderEntityLiving",
|
||||
"client.renderer.entity.MixinRenderItem",
|
||||
@@ -480,34 +502,30 @@ public enum Mixins {
|
||||
"world.MixinWorld"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE_CONNECTED_TEXTURES(new Builder("MCP:F Connected Textures")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_CONNECTED_TEXTURES(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.ConnectedTextures.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses("mcpatcherforge.ctm.MixinRenderBlocks")
|
||||
.addClientMixins("mcpatcherforge.ctm.MixinRenderBlocks")
|
||||
),
|
||||
MCPATCHER_FORGE_EXTENDED_HD(new Builder("MCP:F Extended hd")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_EXTENDED_HD(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.ExtendedHD.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("mcpatcherforge.hd.",
|
||||
.addClientMixins(addPrefix("mcpatcherforge.hd.",
|
||||
"MixinTextureClock",
|
||||
"MixinTextureCompass",
|
||||
"MixinTextureManager"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE_EXTENDED_HD_FONT(new Builder("MCP:F Extended HD Font")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_EXTENDED_HD_FONT(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> (AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.ExtendedHD.enabled && MCPatcherForgeConfig.ExtendedHD.hdFont))
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addExcludedMod(TargetedMod.COFHCORE)
|
||||
.addMixinClasses("mcpatcherforge.hd.MixinFontRenderer")
|
||||
.addClientMixins("mcpatcherforge.hd.MixinFontRenderer")
|
||||
),
|
||||
MCPATCHER_FORGE_RANDOM_MOBS(new Builder("MCP:F Random Mobs")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_RANDOM_MOBS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.RandomMobs.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("mcpatcherforge.mob.",
|
||||
.addClientMixins(addPrefix("mcpatcherforge.mob.",
|
||||
"MixinRender",
|
||||
"MixinRenderEnderman",
|
||||
"MixinRenderFish",
|
||||
@@ -520,220 +538,59 @@ public enum Mixins {
|
||||
"MixinEntityLivingBase"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE_SKY(new Builder("MCP:F Sky")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_SKY(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.BetterSkies.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(addPrefix("mcpatcherforge.sky.",
|
||||
.addClientMixins(addPrefix("mcpatcherforge.sky.",
|
||||
"MixinEffectRenderer",
|
||||
"MixinRenderGlobal"
|
||||
))
|
||||
),
|
||||
MCPATCHER_FORGE_CC_NO_CTM(new Builder("MCP:F Custom Colors, no Connected Textures")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_CC_NO_CTM(new MixinBuilder("MCP:F Custom Colors, no Connected Textures")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures
|
||||
&& !MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
&& MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses("mcpatcherforge.ctm_cc.MixinRenderBlocksNoCTM")
|
||||
&& !MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
&& MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addClientMixins("mcpatcherforge.ctm_cc.MixinRenderBlocksNoCTM")
|
||||
),
|
||||
MCPATCHER_FORGE_CTM_NO_CC(new Builder("MCP:F Connected Textures, no Custom Colours")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_CTM_NO_CC(new MixinBuilder("MCP:F Connected Textures, no Custom Colours")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures
|
||||
&& MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
&& !MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses("mcpatcherforge.ctm_cc.MixinRenderBlocksNoCC")
|
||||
&& MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
&& !MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addClientMixins("mcpatcherforge.ctm_cc.MixinRenderBlocksNoCC")
|
||||
),
|
||||
MCPATCHER_FORGE_CTM_AND_CC(new Builder("MCP:F Connected Textures and Custom Colors")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_CTM_AND_CC(new MixinBuilder("MCP:F Connected Textures and Custom Colors")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures
|
||||
&& MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
&& MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses("mcpatcherforge.ctm_cc.MixinRenderBlocks")
|
||||
&& MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
&& MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addClientMixins("mcpatcherforge.ctm_cc.MixinRenderBlocks")
|
||||
),
|
||||
MCPATCHER_FORGE_CTM_OR_CC(new Builder("MCP:F Connected Textures or Custom Colors")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
MCPATCHER_FORGE_CTM_OR_CC(new MixinBuilder("MCP:F Connected Textures or Custom Colors")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures
|
||||
&& MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
|| MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses("mcpatcherforge.ctm_cc.MixinTextureMap")
|
||||
&& MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
|| MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addClientMixins("mcpatcherforge.ctm_cc.MixinTextureMap")
|
||||
),
|
||||
//End from NotFine
|
||||
|
||||
QPR(new Builder("Adds a QuadProvider field to blocks without populating it")
|
||||
.setSide(Side.CLIENT)
|
||||
QPR(new MixinBuilder("Adds a QuadProvider field to blocks without populating it")
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> true)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses(
|
||||
.addClientMixins(
|
||||
"angelica.models.MixinBlock",
|
||||
"angelica.models.MixinBlockOldLeaf")),
|
||||
|
||||
;
|
||||
|
||||
private final List<String> mixinClasses;
|
||||
private final Supplier<Boolean> applyIf;
|
||||
private final Phase phase;
|
||||
private final Side side;
|
||||
private final List<TargetedMod> targetedMods;
|
||||
private final List<TargetedMod> excludedMods;
|
||||
private final MixinBuilder builder;
|
||||
|
||||
Mixins(Builder builder) {
|
||||
this.mixinClasses = builder.mixinClasses;
|
||||
this.applyIf = builder.applyIf;
|
||||
this.side = builder.side;
|
||||
this.targetedMods = builder.targetedMods;
|
||||
this.excludedMods = builder.excludedMods;
|
||||
this.phase = builder.phase;
|
||||
if (this.targetedMods.isEmpty()) {
|
||||
throw new RuntimeException("No targeted mods specified for " + this.name());
|
||||
}
|
||||
if (this.applyIf == null) {
|
||||
throw new RuntimeException("No ApplyIf function specified for " + this.name());
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getEarlyMixins(Set<String> loadedCoreMods) {
|
||||
NotFineConfig.loadSettings();
|
||||
//This may be possible to handle differently or fix.
|
||||
if(loadedCoreMods.contains("cofh.asm.LoadingPlugin")) {
|
||||
MCPatcherForgeConfig.ExtendedHD.hdFont = false;
|
||||
}
|
||||
final List<String> mixins = new ArrayList<>();
|
||||
final List<String> notLoading = new ArrayList<>();
|
||||
for (Mixins mixin : Mixins.values()) {
|
||||
if (mixin.phase == Mixins.Phase.EARLY) {
|
||||
if (mixin.shouldLoad(loadedCoreMods, Collections.emptySet())) {
|
||||
mixins.addAll(mixin.mixinClasses);
|
||||
} else {
|
||||
notLoading.addAll(mixin.mixinClasses);
|
||||
}
|
||||
}
|
||||
}
|
||||
AngelicaTweaker.LOGGER.info("Not loading the following EARLY mixins: {}", notLoading);
|
||||
return mixins;
|
||||
}
|
||||
|
||||
public static List<String> getLateMixins(Set<String> loadedMods) {
|
||||
final List<String> mixins = new ArrayList<>();
|
||||
final List<String> notLoading = new ArrayList<>();
|
||||
for (Mixins mixin : Mixins.values()) {
|
||||
if (mixin.phase == Mixins.Phase.LATE) {
|
||||
if (mixin.shouldLoad(Collections.emptySet(), loadedMods)) {
|
||||
mixins.addAll(mixin.mixinClasses);
|
||||
} else {
|
||||
notLoading.addAll(mixin.mixinClasses);
|
||||
}
|
||||
}
|
||||
}
|
||||
AngelicaTweaker.LOGGER.info("Not loading the following LATE mixins: {}", notLoading.toString());
|
||||
return mixins;
|
||||
}
|
||||
|
||||
private boolean shouldLoadSide() {
|
||||
return side == Side.BOTH || (side == Side.SERVER && FMLLaunchHandler.side().isServer())
|
||||
|| (side == Side.CLIENT && FMLLaunchHandler.side().isClient());
|
||||
}
|
||||
|
||||
private boolean allModsLoaded(List<TargetedMod> targetedMods, Set<String> loadedCoreMods, Set<String> loadedMods) {
|
||||
if (targetedMods.isEmpty()) return false;
|
||||
|
||||
for (TargetedMod target : targetedMods) {
|
||||
if (target == TargetedMod.VANILLA) continue;
|
||||
|
||||
// Check coremod first
|
||||
if (!loadedCoreMods.isEmpty() && target.coreModClass != null
|
||||
&& !loadedCoreMods.contains(target.coreModClass))
|
||||
return false;
|
||||
else if (!loadedMods.isEmpty() && target.modId != null && !loadedMods.contains(target.modId)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean noModsLoaded(List<TargetedMod> targetedMods, Set<String> loadedCoreMods, Set<String> loadedMods) {
|
||||
if (targetedMods.isEmpty()) return true;
|
||||
|
||||
for (TargetedMod target : targetedMods) {
|
||||
if (target == TargetedMod.VANILLA) continue;
|
||||
|
||||
// Check coremod first
|
||||
if (!loadedCoreMods.isEmpty() && target.coreModClass != null
|
||||
&& loadedCoreMods.contains(target.coreModClass))
|
||||
return false;
|
||||
else if (!loadedMods.isEmpty() && target.modId != null && loadedMods.contains(target.modId)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean shouldLoad(Set<String> loadedCoreMods, Set<String> loadedMods) {
|
||||
return (shouldLoadSide() && applyIf.get()
|
||||
&& allModsLoaded(targetedMods, loadedCoreMods, loadedMods)
|
||||
&& noModsLoaded(excludedMods, loadedCoreMods, loadedMods));
|
||||
}
|
||||
|
||||
private static class Builder {
|
||||
|
||||
private final List<String> mixinClasses = new ArrayList<>();
|
||||
private Supplier<Boolean> applyIf = () -> true;
|
||||
private Side side = Side.BOTH;
|
||||
private Phase phase = Phase.LATE;
|
||||
private final List<TargetedMod> targetedMods = new ArrayList<>();
|
||||
private final List<TargetedMod> excludedMods = new ArrayList<>();
|
||||
|
||||
public Builder(@SuppressWarnings("unused") String description) {}
|
||||
|
||||
public Builder addMixinClasses(String... mixinClasses) {
|
||||
this.mixinClasses.addAll(Arrays.asList(mixinClasses));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPhase(Phase phase) {
|
||||
this.phase = phase;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSide(Side side) {
|
||||
this.side = side;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setApplyIf(Supplier<Boolean> applyIf) {
|
||||
this.applyIf = applyIf;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addTargetedMod(TargetedMod mod) {
|
||||
this.targetedMods.add(mod);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder addExcludedMod(TargetedMod mod) {
|
||||
this.excludedMods.add(mod);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("SimplifyStreamApiCallChains")
|
||||
private static String[] addPrefix(String prefix, String... values) {
|
||||
return Arrays.stream(values)
|
||||
.map(s -> prefix + s)
|
||||
.collect(Collectors.toList())
|
||||
.toArray(new String[values.length]);
|
||||
}
|
||||
|
||||
private enum Side {
|
||||
BOTH,
|
||||
CLIENT,
|
||||
SERVER
|
||||
}
|
||||
|
||||
private enum Phase {
|
||||
EARLY,
|
||||
LATE,
|
||||
List<String> list = new ArrayList<>(values.length);
|
||||
for (String s : values) {
|
||||
list.add(prefix + s);
|
||||
}
|
||||
return list.toArray(new String[values.length]);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,31 @@
|
||||
package com.gtnewhorizons.angelica.mixins;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.builders.ITargetMod;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.TargetModBuilder;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum TargetedMod {
|
||||
@Getter
|
||||
public enum TargetedMod implements ITargetMod {
|
||||
|
||||
VANILLA("Minecraft", null)
|
||||
, FASTCRAFT("FastCraft", "fastcraft.Tweaker")
|
||||
, OPTIFINE("Optifine", "optifine.OptiFineForgeTweaker", "Optifine")
|
||||
, ARCHAICFIX("ArchaicFix", "org.embeddedt.archaicfix.ArchaicCore", "archaicfix")
|
||||
, BACKHAND("Backhand","xonin.backhand.coremod.BackhandLoadingPlugin", "backhand")
|
||||
, BOTANIA("Botania", null, "Botania")
|
||||
, CAMPFIRE_BACKPORT("CampfireBackport", null, "campfirebackport")
|
||||
, CHICKENCHUNKS("ChickenChunks", null, "ChickenChunks")
|
||||
, COFHCORE("CoFHCore", "cofh.asm.LoadingPlugin", "CoFHCore")
|
||||
, DYNAMIC_SURROUNDINGS_MIST("Dynamic Surroundings", "org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround")
|
||||
, DYNAMIC_SURROUNDINGS_ORIGINAL("Dynamic Surroundings", "org.blockartistry.mod.DynSurround.asm.TransformLoader", "dsurround")
|
||||
, EXTRAUTILS("ExtraUtilities", null, "ExtraUtilities")
|
||||
, MINEFACTORY_RELOADED("MineFactory Reloaded", null, "MineFactoryReloaded")
|
||||
, GTNHLIB("GTNHLib", "com.gtnewhorizon.gtnhlib.core.GTNHLibCore", "gtnhlib")
|
||||
, IC2("IC2", "ic2.core.coremod.IC2core", "IC2")
|
||||
, JABBA("JABBA", null, "JABBA")
|
||||
, JOURNEYMAP("JourneyMap", null, "journeymap")
|
||||
, LWJGL3IFY("lwjgl3ify", "me.eigenraven.lwjgl3ify.core.Lwjgl3ifyCoremod", "lwjgl3ify")
|
||||
, MRTJPCORE("MrTJPCore", null, "MrTJPCoreMod")
|
||||
, NATURA("Natura", null, "Natura")
|
||||
, PROJECTRED_ILLUMINATION("ProjectRed Illumination", null, "ProjRed|Illumination")
|
||||
, SECURITYCRAFT("SecurityCraft", null, "securitycraft")
|
||||
, SMART_RENDER("Smart Render", null, "SmartRender")
|
||||
, THAUMCRAFT("Thaumcraft", null, "Thaumcraft")
|
||||
, TINKERS_CONSTRUCT("Tinker's Construct", null, "TConstruct")
|
||||
, TWILIGHT_FOREST("TwilightForest", null, "TwilightForest")
|
||||
, WITCHERY("Witchery", null, "witchery")
|
||||
;
|
||||
ARCHAICFIX("org.embeddedt.archaicfix.ArchaicCore", "archaicfix"),
|
||||
BACKHAND("xonin.backhand.coremod.BackhandLoadingPlugin", "backhand"),
|
||||
CAMPFIRE_BACKPORT(null, "campfirebackport"),
|
||||
COFHCORE( "cofh.asm.LoadingPlugin", "CoFHCore"),
|
||||
DYNAMIC_SURROUNDINGS_MIST("org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround"),
|
||||
DYNAMIC_SURROUNDINGS_ORIGINAL("org.blockartistry.mod.DynSurround.asm.TransformLoader", "dsurround"),
|
||||
EXTRAUTILS(null, "ExtraUtilities"),
|
||||
MINEFACTORY_RELOADED(null, "MineFactoryReloaded"),
|
||||
IC2("ic2.core.coremod.IC2core", "IC2"),
|
||||
NATURA(null, "Natura"),
|
||||
SECURITYCRAFT(null, "securitycraft"),
|
||||
THAUMCRAFT(null, "Thaumcraft"),
|
||||
TINKERS_CONSTRUCT(null, "TConstruct"),
|
||||
TWILIGHT_FOREST(null, "TwilightForest"),
|
||||
WITCHERY(null, "witchery");
|
||||
|
||||
private final TargetModBuilder builder;
|
||||
|
||||
/** The "name" in the @Mod annotation */
|
||||
@Getter
|
||||
public final String modName;
|
||||
/** Class that implements the IFMLLoadingPlugin interface */
|
||||
@Getter
|
||||
public final String coreModClass;
|
||||
/** The "modid" in the @Mod annotation */
|
||||
@Getter
|
||||
public final String modId;
|
||||
|
||||
TargetedMod(String modName, String coreModClass) {
|
||||
this(modName, coreModClass, null);
|
||||
}
|
||||
|
||||
TargetedMod(String modName, String coreModClass, String modId) {
|
||||
this.modName = modName;
|
||||
this.coreModClass = coreModClass;
|
||||
this.modId = modId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TargetedMod{modName='" + modName + "', coreModClass='" + coreModClass + "', modId='" + modId + "'}";
|
||||
TargetedMod(String coreModClass, String modId) {
|
||||
this.builder = new TargetModBuilder().setCoreModClass(coreModClass).setModId(modId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ResourceAccessor {
|
||||
List angelica$getDefaultResourcePacks();
|
||||
}
|
||||
@@ -308,9 +308,14 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onGuiOpen(GuiOpenEvent event) {
|
||||
if (!event.isCanceled() && event.gui instanceof GuiMainMenu && gameStartTime == -1) {
|
||||
gameStartTime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
LOGGER.info("The game loaded in {} seconds.", gameStartTime);
|
||||
if (!event.isCanceled()) {
|
||||
if (event.gui instanceof GuiMainMenu && gameStartTime == -1 ) {
|
||||
gameStartTime = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
LOGGER.info("The game loaded in {} seconds.", gameStartTime);
|
||||
}
|
||||
|
||||
// force reset zoom when a GUI is opened
|
||||
if (AngelicaConfig.enableZoom && event.gui != null) Zoom.resetZoom();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,8 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
GraphicsQualityOff cloudGraphicsQuality = (GraphicsQualityOff)Settings.MODE_CLOUDS.option.getStore();
|
||||
final int cloudQualitySetting = cloudGraphicsQuality == GraphicsQualityOff.FANCY
|
||||
|| cloudGraphicsQuality == GraphicsQualityOff.DEFAULT && mc.gameSettings.fancyGraphics ? 2 : 1;
|
||||
final boolean newEnabled = mc.gameSettings.shouldRenderClouds()
|
||||
final boolean newEnabled = cloudGraphicsQuality != GraphicsQualityOff.OFF
|
||||
&& mc.gameSettings.shouldRenderClouds()
|
||||
&& mc.theWorld != null
|
||||
&& mc.theWorld.provider.isSurfaceWorld();
|
||||
final int targetDistance = Math.max(mc.gameSettings.renderDistanceChunks, (int)Settings.RENDER_DISTANCE_CLOUDS.option.getStore());
|
||||
|
||||
@@ -25,87 +25,161 @@
|
||||
|
||||
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 lombok.AccessLevel;
|
||||
import it.unimi.dsi.fastutil.HashCommon;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.val;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ItemRenderListManager implements IResourceManagerReloadListener {
|
||||
public static final ItemRenderListManager INSTANCE = new ItemRenderListManager();
|
||||
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);
|
||||
|
||||
private final Map<ItemProp, Integer> theMap = new HashMap<>();
|
||||
private final List<ItemProp> propList = new ArrayList<>();
|
||||
private final ItemProp prop = new ItemProp();
|
||||
private int list = 0;
|
||||
// Formula: (widthSubdivisions * 2 + heightSubdivisions * 2 + 2) * 4 * vertexSize
|
||||
// Using 256 as both variables due to enchants, to prevent later re-allocations.
|
||||
private static ByteBuffer quadBuffer = BufferUtils.createByteBuffer(
|
||||
(1026 * DefaultVertexFormat.POSITION_TEXTURE_NORMAL.getVertexSize()) << 2
|
||||
);
|
||||
|
||||
public boolean pre(float a, float b, float c, float d, int e, int f, float g) {
|
||||
prop.set(a, b, c, d, e, f, g);
|
||||
if (theMap.containsKey(prop)) {
|
||||
val list = theMap.get(prop);
|
||||
propList.add(propList.remove(propList.indexOf(prop)));
|
||||
GL11.glCallList(list);
|
||||
return true;
|
||||
} else {
|
||||
if (propList.size() >= AngelicaConfig.itemRendererDisplayListCacheSize) {
|
||||
val oldProp = propList.remove(0);
|
||||
GLAllocation.deleteDisplayLists(theMap.remove(oldProp));
|
||||
// 1 minute
|
||||
private static final int EXPIRY_TICKS = 1_200;
|
||||
private static int smallestExpiry;
|
||||
|
||||
private static final ItemProp prop = new ItemProp();
|
||||
|
||||
public static VertexBuffer pre(float minU, float minV, float maxU, float maxV, int widthSubdivisions, int heightSubdivisions, float thickness) {
|
||||
prop.set(minU, minV, maxU, maxV, widthSubdivisions, heightSubdivisions, thickness);
|
||||
|
||||
if (!vboCache.isEmpty()) {
|
||||
|
||||
final CachedVBO vbo = vboCache.getAndMoveToLast(prop);
|
||||
|
||||
if (vbo != null) {
|
||||
final int time = getElapsedTicks();
|
||||
vbo.render(time);
|
||||
|
||||
// Prevent constant map lookups by only storing the expiry of the least recently used entry
|
||||
if (time > smallestExpiry && time > (smallestExpiry = (vboCache.get(vboCache.firstKey()).expiry + 20))) {
|
||||
vboCache.removeFirst().delete();
|
||||
if (!vboCache.isEmpty()) {
|
||||
smallestExpiry = vboCache.get(vboCache.firstKey()).expiry + 20;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
list = GLAllocation.generateDisplayLists(1);
|
||||
val newProp = new ItemProp(prop);
|
||||
theMap.put(newProp, list);
|
||||
propList.add(newProp);
|
||||
GL11.glNewList(list, GL11.GL_COMPILE);
|
||||
return false;
|
||||
}
|
||||
|
||||
final CachedVBO vbo;
|
||||
if (vboCache.size() >= AngelicaConfig.itemRendererCacheSize) {
|
||||
final ItemProp oldestProp = vboCache.firstKey();
|
||||
vbo = vboCache.removeFirst();
|
||||
oldestProp.set(prop);
|
||||
vboCache.put(oldestProp, vbo);
|
||||
} else {
|
||||
vbo = new CachedVBO();
|
||||
vboCache.put(new ItemProp(prop), vbo);
|
||||
}
|
||||
|
||||
vbo.expiry = getElapsedTicks() + EXPIRY_TICKS;
|
||||
|
||||
TessellatorManager.startCapturing();
|
||||
|
||||
return vbo.vertexBuffer;
|
||||
}
|
||||
|
||||
public void post() {
|
||||
GL11.glEndList();
|
||||
GL11.glCallList(list);
|
||||
public static void post(CapturingTessellator tessellator, VertexBuffer vbo) {
|
||||
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
final int size = quads.size();
|
||||
|
||||
final int needed = (DefaultVertexFormat.POSITION_TEXTURE_NORMAL.getVertexSize() * size) << 2;
|
||||
if (quadBuffer.capacity() < needed) {
|
||||
quadBuffer = BufferUtils.createByteBuffer(HashCommon.nextPowerOfTwo(needed));
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
DefaultVertexFormat.POSITION_TEXTURE_NORMAL.writeQuad(quads.get(i), quadBuffer);
|
||||
}
|
||||
|
||||
quadBuffer.flip();
|
||||
vbo.upload(quadBuffer);
|
||||
quadBuffer.clear();
|
||||
|
||||
tessellator.clearQuads();
|
||||
vbo.render();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager p_110549_1_) {
|
||||
propList.clear();
|
||||
theMap.forEach((key, value) -> GLAllocation.deleteDisplayLists(value));
|
||||
theMap.clear();
|
||||
private static int getElapsedTicks() {
|
||||
return Minecraft.getMinecraft().thePlayer.ticksExisted;
|
||||
}
|
||||
|
||||
private static final class CachedVBO {
|
||||
private VertexBuffer vertexBuffer;
|
||||
private int expiry;
|
||||
|
||||
public CachedVBO() {
|
||||
this.vertexBuffer = new VertexBuffer(DefaultVertexFormat.POSITION_TEXTURE_NORMAL, GL11.GL_QUADS);
|
||||
}
|
||||
|
||||
private void render(int elapsedTicks) {
|
||||
vertexBuffer.render();
|
||||
expiry = elapsedTicks + EXPIRY_TICKS;
|
||||
}
|
||||
|
||||
private void delete() {
|
||||
vertexBuffer.close();
|
||||
vertexBuffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ItemProp {
|
||||
private float a;
|
||||
private float b;
|
||||
private float c;
|
||||
private float d;
|
||||
private int e;
|
||||
private int f;
|
||||
private float g;
|
||||
private static final class ItemProp {
|
||||
private float minU;
|
||||
private float minV;
|
||||
private float maxU;
|
||||
private float maxV;
|
||||
private int widthSubdivisions;
|
||||
private int heightSubdivisions;
|
||||
private float thickness;
|
||||
|
||||
public ItemProp(ItemProp old) {
|
||||
set(old.a, old.b, old.c, old.d, old.e, old.f, old.g);
|
||||
set(
|
||||
old.minU, old.minV,
|
||||
old.maxU, old.maxV,
|
||||
old.widthSubdivisions, old.heightSubdivisions,
|
||||
old.thickness
|
||||
);
|
||||
}
|
||||
|
||||
public void set(float a, float b, float c, float d, int e, int f, float g) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.e = e;
|
||||
this.f = f;
|
||||
this.g = g;
|
||||
public void set(ItemProp other) {
|
||||
set(
|
||||
other.minU, other.minV,
|
||||
other.maxU, other.maxV,
|
||||
other.widthSubdivisions, other.heightSubdivisions,
|
||||
other.thickness
|
||||
);
|
||||
}
|
||||
|
||||
public void set(float minU, float minV, float maxU, float maxV, int widthSubdivisions, int heightSubdivisions, float thickness) {
|
||||
this.minU = minU;
|
||||
this.minV = minV;
|
||||
this.maxU = maxU;
|
||||
this.maxV = maxV;
|
||||
this.widthSubdivisions = widthSubdivisions;
|
||||
this.heightSubdivisions = heightSubdivisions;
|
||||
this.thickness = thickness;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.transform;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
|
||||
public class AsmUtil {
|
||||
|
||||
public static String obf(String deobf, String obf) {
|
||||
if (AngelicaTweaker.isObfEnv()) {
|
||||
return obf;
|
||||
}
|
||||
return deobf;
|
||||
}
|
||||
}
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.transform.compat.handlers.CompatHandler;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.FieldLevelTessellatorTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.HUDCachingEarlyReturnTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.ThreadSafeISBRHAnnotationTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.TileEntityNullGuardTransformer;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.transformers.MixinClassWriter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class GenericCompatTransformer implements IClassTransformer {
|
||||
|
||||
private static final Map<String, List<String>> fieldLevelTessellator = new Object2ObjectOpenHashMap<>();
|
||||
private static final Map<String, List<String>> tileEntityNullGuard = new Object2ObjectOpenHashMap<>();
|
||||
private static final Map<String, Boolean> threadSafeIBSRH = new Object2BooleanOpenHashMap<>();
|
||||
private static final Map<String, List<String>> hudCachingEarlyReturn = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Set<String> transformedClasses = new ObjectOpenHashSet<>();
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (!transformedClasses.contains(transformedName)) return basicClass;
|
||||
|
||||
ClassReader cr = new ClassReader(basicClass);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
if (fieldLevelTessellator.containsKey(transformedName)) {
|
||||
FieldLevelTessellatorTransformer.transform(cn, fieldLevelTessellator.get(transformedName));
|
||||
}
|
||||
|
||||
if (tileEntityNullGuard.containsKey(transformedName)) {
|
||||
TileEntityNullGuardTransformer.transform(cn, tileEntityNullGuard.get(transformedName));
|
||||
}
|
||||
|
||||
if (threadSafeIBSRH.containsKey(transformedName)) {
|
||||
ThreadSafeISBRHAnnotationTransformer.transform(cn, threadSafeIBSRH.get(transformedName));
|
||||
}
|
||||
|
||||
if (hudCachingEarlyReturn.containsKey(transformedName)) {
|
||||
HUDCachingEarlyReturnTransformer.transform(cn, hudCachingEarlyReturn.get(transformedName));
|
||||
}
|
||||
|
||||
MixinClassWriter cw = new MixinClassWriter(MixinClassWriter.COMPUTE_MAXS | MixinClassWriter.COMPUTE_FRAMES);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static void register(CompatHandler handler) {
|
||||
if (handler.getFieldLevelTessellator() != null)
|
||||
fieldLevelTessellator.putAll(handler.getFieldLevelTessellator());
|
||||
if (handler.getTileEntityNullGuard() != null)
|
||||
tileEntityNullGuard.putAll(handler.getTileEntityNullGuard());
|
||||
if (handler.getThreadSafeISBRHAnnotations() != null)
|
||||
threadSafeIBSRH.putAll(handler.getThreadSafeISBRHAnnotations());
|
||||
if (handler.getHUDCachingEarlyReturn() != null)
|
||||
hudCachingEarlyReturn.putAll(handler.getHUDCachingEarlyReturn());
|
||||
}
|
||||
|
||||
public static void build() {
|
||||
transformedClasses.addAll(fieldLevelTessellator.keySet());
|
||||
transformedClasses.addAll(tileEntityNullGuard.keySet());
|
||||
transformedClasses.addAll(threadSafeIBSRH.keySet());
|
||||
transformedClasses.addAll(hudCachingEarlyReturn.keySet());
|
||||
}
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum CompatHandlers {
|
||||
|
||||
STACKS_ON_STACKS(() -> CompatConfig.fixStacksOnStacks, new StacksOnStacksCompatHandler()),
|
||||
EXTRA_UTILS(() -> CompatConfig.fixExtraUtils, new ExtraUtilsCompatHandler()),
|
||||
IMMERSIVE_ENGINEERING(() -> CompatConfig.fixImmersiveEngineering, new ImmersiveEngineeringCompatHandler()),
|
||||
THAUMCRAFT(() -> CompatConfig.fixThaumcraft, new ThaumcraftCompatHandler()),
|
||||
THAUMIC_HORIZONS(() -> CompatConfig.fixThaumicHorizons, new ThaumicHorizonsCompatHandler());
|
||||
|
||||
private final Supplier<Boolean> applyIf;
|
||||
private final CompatHandler handler;
|
||||
|
||||
CompatHandlers(Supplier<Boolean> applyIf, CompatHandler handler) {
|
||||
this.applyIf = applyIf;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
private static List<CompatHandler> compatHandlers = null;
|
||||
|
||||
public static List<CompatHandler> getHandlers() {
|
||||
if (compatHandlers != null) {
|
||||
return compatHandlers;
|
||||
}
|
||||
compatHandlers = new ArrayList<>();
|
||||
for (CompatHandlers value : values()) {
|
||||
if (value.applyIf.get()) {
|
||||
compatHandlers.add(value.handler);
|
||||
}
|
||||
}
|
||||
return compatHandlers;
|
||||
}
|
||||
}
|
||||
@@ -8,46 +8,75 @@ import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
public class Zoom {
|
||||
|
||||
@Getter
|
||||
private static float zoom = 4.0F;
|
||||
@Getter
|
||||
private static final KeyBinding zoomKey = new KeyBinding("Zoom", 0, "key.categories.misc");
|
||||
|
||||
public static final float ZOOM_MIN = 1.0F;
|
||||
public static final float ZOOM_MAX = 64.0F;
|
||||
public static final float ZOOM_STEP = 1.2F;
|
||||
public static final float ZOOM_DEFAULT = 4.0F;
|
||||
|
||||
private static boolean lastSmoothCameraState = false;
|
||||
@Getter
|
||||
private static float zoom = ZOOM_DEFAULT;
|
||||
@Getter
|
||||
private static final KeyBinding zoomKey = new KeyBinding("Zoom", 0, "key.categories.misc");
|
||||
|
||||
private static boolean zoomEnabled = false;
|
||||
|
||||
public static void init() {
|
||||
ClientRegistry.registerKeyBinding(zoomKey);
|
||||
FMLCommonHandler.instance().bus().register(new Zoom());
|
||||
}
|
||||
|
||||
public static boolean isZoomedIn() {
|
||||
return zoomEnabled;
|
||||
}
|
||||
|
||||
public static void modifyZoom(int eventDWheel) {
|
||||
if (eventDWheel == 0) return;
|
||||
zoom = MathHelper.clamp_float((float) (zoom * Math.pow(ZOOM_STEP, Integer.signum(eventDWheel))), ZOOM_MIN, ZOOM_MAX);
|
||||
}
|
||||
|
||||
private static void resetMouseFilters(Minecraft mc) {
|
||||
if (mc.entityRenderer != null) {
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterXAxis).angelica$reset();
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterYAxis).angelica$reset();
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetZoom() {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
zoomEnabled = false;
|
||||
zoom = ZOOM_DEFAULT;
|
||||
resetMouseFilters(mc);
|
||||
}
|
||||
|
||||
private void handleKeyEvent() {
|
||||
if (zoomKey.getKeyCode() == 0) return;
|
||||
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.currentScreen != null) return;
|
||||
|
||||
if (zoomKey.getIsKeyPressed()) {
|
||||
zoomEnabled = true;
|
||||
} else if (zoomEnabled) {
|
||||
resetZoom();
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyPress(InputEvent.KeyInputEvent e) {
|
||||
final int keyCode = zoomKey.getKeyCode();
|
||||
if (keyCode == 0 || Keyboard.getEventKey() != keyCode || Keyboard.isRepeatEvent()) return;
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
lastSmoothCameraState = mc.gameSettings.smoothCamera;
|
||||
mc.gameSettings.smoothCamera = true;
|
||||
} else {
|
||||
zoom = 4.0F;
|
||||
if (mc.gameSettings.smoothCamera != lastSmoothCameraState) {
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterXAxis).angelica$reset();
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterYAxis).angelica$reset();
|
||||
}
|
||||
mc.gameSettings.smoothCamera = lastSmoothCameraState;
|
||||
handleKeyEvent();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onMouseKeyPress(InputEvent.MouseInputEvent e) {
|
||||
// MouseInputEvent is also fired on mouse movement, which we don't care about, only mouse button presses, so
|
||||
// ensure that before any further key processing.
|
||||
if (Mouse.getEventButton() >= 0) {
|
||||
handleKeyEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.EntityRendererAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.potion.Potion;
|
||||
@@ -83,9 +84,8 @@ public final class Lightmap {
|
||||
}
|
||||
|
||||
private float getNightVisionStrength(EntityRenderer renderer, float n) {
|
||||
|
||||
if (Minecraft.getMinecraft().thePlayer.isPotionActive(Potion.nightVision)) {
|
||||
return renderer.getNightVisionBrightness(Minecraft.getMinecraft().thePlayer, n);
|
||||
return ((EntityRendererAccessor) renderer).invokeGetNightVisionBrightness(Minecraft.getMinecraft().thePlayer, n);
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@@ -117,12 +117,13 @@ final class Enchantment extends OverrideBase {
|
||||
return;
|
||||
}
|
||||
begin(intensity);
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
Tessellator.instance.addVertexWithUV(x0, y0, z, 0.0f, 0.0f);
|
||||
Tessellator.instance.addVertexWithUV(x0, y1, z, 0.0f, 1.0f);
|
||||
Tessellator.instance.addVertexWithUV(x1, y1, z, 1.0f, 1.0f);
|
||||
Tessellator.instance.addVertexWithUV(x1, y0, z, 1.0f, 0.0f);
|
||||
Tessellator.instance.draw();
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
tess.addVertexWithUV(x0, y0, z, 0.0f, 0.0f);
|
||||
tess.addVertexWithUV(x0, y1, z, 0.0f, 1.0f);
|
||||
tess.addVertexWithUV(x1, y1, z, 1.0f, 1.0f);
|
||||
tess.addVertexWithUV(x1, y0, z, 1.0f, 0.0f);
|
||||
tess.draw();
|
||||
end();
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class MipmapHelper {
|
||||
int mipmaps = useMipmapsForTexture(textureName) ? getMipmapLevels(width, height, 1) : 0;
|
||||
logger.finer("setupTexture(%s) %dx%d %d mipmaps", textureName, width, height, mipmaps);
|
||||
int magFilter = blur ? GL11.GL_LINEAR : GL11.GL_NEAREST;
|
||||
int minFilter = mipmaps > 0 ? GL11.GL_NEAREST_MIPMAP_LINEAR : magFilter;
|
||||
int minFilter = mipmaps > 0 ? GL11.GL_LINEAR_MIPMAP_LINEAR : magFilter;
|
||||
int wrap = clamp ? GL11.GL_CLAMP : GL11.GL_REPEAT;
|
||||
if (mipmaps > 0) {
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, mipmaps);
|
||||
|
||||
@@ -311,20 +311,18 @@ public class TexturePackAPI {
|
||||
public static void flushUnusedTextures() {
|
||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
if (textureManager != null) {
|
||||
Set<ResourceLocation> texturesToUnload = new HashSet<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Map.Entry<ResourceLocation, ITextureObject>> entrySet = textureManager.mapTextureObjects.entrySet();
|
||||
for (Map.Entry<ResourceLocation, ITextureObject> entry : entrySet) {
|
||||
ResourceLocation resource = entry.getKey();
|
||||
Map.Entry<ResourceLocation, ITextureObject>[] arr = (Map.Entry<ResourceLocation, ITextureObject>[])
|
||||
textureManager.mapTextureObjects.entrySet().toArray(new Map.Entry[0]);
|
||||
for (Map.Entry<ResourceLocation, ITextureObject> entry : arr) {
|
||||
ITextureObject texture = entry.getValue();
|
||||
if (texture instanceof SimpleTexture && !(texture instanceof ThreadDownloadImageData)
|
||||
&& !TexturePackAPI.hasResource(resource)) {
|
||||
texturesToUnload.add(resource);
|
||||
if (texture instanceof SimpleTexture && !(texture instanceof ThreadDownloadImageData)) {
|
||||
ResourceLocation resource = entry.getKey();
|
||||
if (!TexturePackAPI.hasResource(resource)) {
|
||||
unloadTexture(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ResourceLocation resource : texturesToUnload) {
|
||||
unloadTexture(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -427,13 +427,13 @@ public class SkyRenderer {
|
||||
private static void drawTile(int tile) {
|
||||
double tileX = (tile % 3) / 3.0;
|
||||
double tileY = (tile / 3) / 2.0;
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
Tessellator.instance.addVertexWithUV(-SKY_DISTANCE, -SKY_DISTANCE, -SKY_DISTANCE, tileX, tileY);
|
||||
Tessellator.instance.addVertexWithUV(-SKY_DISTANCE, -SKY_DISTANCE, SKY_DISTANCE, tileX, tileY + 0.5);
|
||||
Tessellator.instance
|
||||
.addVertexWithUV(SKY_DISTANCE, -SKY_DISTANCE, SKY_DISTANCE, tileX + 1.0 / 3.0, tileY + 0.5);
|
||||
Tessellator.instance.addVertexWithUV(SKY_DISTANCE, -SKY_DISTANCE, -SKY_DISTANCE, tileX + 1.0 / 3.0, tileY);
|
||||
Tessellator.instance.draw();
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
tess.addVertexWithUV(-SKY_DISTANCE, -SKY_DISTANCE, -SKY_DISTANCE, tileX, tileY);
|
||||
tess.addVertexWithUV(-SKY_DISTANCE, -SKY_DISTANCE, SKY_DISTANCE, tileX, tileY + 0.5);
|
||||
tess.addVertexWithUV(SKY_DISTANCE, -SKY_DISTANCE, SKY_DISTANCE, tileX + 1.0 / 3.0, tileY + 0.5);
|
||||
tess.addVertexWithUV(SKY_DISTANCE, -SKY_DISTANCE, -SKY_DISTANCE, tileX + 1.0 / 3.0, tileY);
|
||||
tess.draw();
|
||||
}
|
||||
|
||||
void setBlendingMethod(float brightness) {
|
||||
|
||||
@@ -1,66 +1,33 @@
|
||||
package jss.notfine.asm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.builders.ITransformers;
|
||||
import com.gtnewhorizon.gtnhmixins.builders.TransformerBuilder;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import jss.notfine.config.MCPatcherForgeConfig;
|
||||
import jss.notfine.config.NotFineConfig;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Adapted from Hodgepodge
|
||||
*/
|
||||
public enum AsmTransformers {
|
||||
import java.util.function.Supplier;
|
||||
|
||||
RENDERBLOCKS("RenderBlocks transformer", () -> AngelicaConfig.enableMCPatcherForgeFeatures
|
||||
&& MCPatcherForgeConfig.CustomColors.enabled,
|
||||
Side.CLIENT, "jss.notfine.asm.RenderBlocksTransformer"),
|
||||
WORLDRENDERER("WorldRenderer transformer", () -> NotFineConfig.renderPass, Side.CLIENT,
|
||||
"jss.notfine.asm.WorldRendererTransformer");
|
||||
public enum AsmTransformers implements ITransformers {
|
||||
|
||||
private final Supplier<Boolean> applyIf;
|
||||
private final Side side;
|
||||
private final String[] transformerClasses;
|
||||
RENDERBLOCKS(
|
||||
() -> AngelicaConfig.enableMCPatcherForgeFeatures && MCPatcherForgeConfig.CustomColors.enabled,
|
||||
"jss.notfine.asm.RenderBlocksTransformer"),
|
||||
WORLDRENDERER(
|
||||
() -> NotFineConfig.renderPass,
|
||||
"jss.notfine.asm.WorldRendererTransformer");
|
||||
|
||||
AsmTransformers(@SuppressWarnings("unused") String description, Supplier<Boolean> applyIf, Side side,
|
||||
String... transformers) {
|
||||
this.applyIf = applyIf;
|
||||
this.side = side;
|
||||
this.transformerClasses = transformers;
|
||||
private final TransformerBuilder builder;
|
||||
|
||||
AsmTransformers(Supplier<Boolean> applyIf, String transformer) {
|
||||
this.builder = new TransformerBuilder().setApplyIf(applyIf).addClientTransformers(transformer);
|
||||
}
|
||||
|
||||
private boolean shouldBeLoaded() {
|
||||
return applyIf.get() && shouldLoadSide();
|
||||
@NotNull
|
||||
@Override
|
||||
public TransformerBuilder getBuilder() {
|
||||
return builder;
|
||||
}
|
||||
|
||||
private boolean shouldLoadSide() {
|
||||
return side == Side.BOTH || (side == Side.SERVER && FMLLaunchHandler.side()
|
||||
.isServer())
|
||||
|| (side == Side.CLIENT && FMLLaunchHandler.side()
|
||||
.isClient());
|
||||
}
|
||||
|
||||
public static List<String> getTransformers() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (AsmTransformers transformer : values()) {
|
||||
if (transformer.shouldBeLoaded()) {
|
||||
AngelicaTweaker.LOGGER.info("Loading transformer {}", (Object[]) transformer.transformerClasses);
|
||||
list.addAll(Arrays.asList(transformer.transformerClasses));
|
||||
} else {
|
||||
AngelicaTweaker.LOGGER.info("Not loading transformer {}", (Object[]) transformer.transformerClasses);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private enum Side {
|
||||
BOTH,
|
||||
CLIENT,
|
||||
SERVER
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package jss.notfine.asm;
|
||||
|
||||
import static jss.notfine.asm.ASMUtils.matchesNodeSequence;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -34,7 +34,7 @@ public class RenderBlocksTransformer implements IClassTransformer {
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if ("net.minecraft.client.renderer.RenderBlocks".equals(transformedName)) {
|
||||
final byte[] bytes = patchRenderBlocks(basicClass);
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
return basicClass;
|
||||
|
||||
@@ -2,7 +2,7 @@ package jss.notfine.asm;
|
||||
|
||||
import static jss.notfine.asm.ASMUtils.matchesNodeSequence;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.loading.shared.AngelicaClassDump;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -28,7 +28,7 @@ public class WorldRendererTransformer implements IClassTransformer {
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if ("net.minecraft.client.renderer.WorldRenderer".equals(transformedName)) {
|
||||
final byte[] bytes = patchWorldRenderer(basicClass);
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
AngelicaClassDump.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
return basicClass;
|
||||
|
||||
+16
-5
@@ -1,5 +1,6 @@
|
||||
package me.flashyreese.mods.reeses_sodium_options.client.gui;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.gui.FontConfigScreen;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Element;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import jss.notfine.gui.GuiCustomMenu;
|
||||
@@ -96,25 +97,35 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
this.applyButton = new FlatButtonWidget(applyButtonDim, "Apply", this::applyChanges);
|
||||
this.closeButton = new FlatButtonWidget(closeButtonDim, "Close", this::onClose);
|
||||
|
||||
Dim2i searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth(), 20);
|
||||
|
||||
|
||||
|
||||
basicFrameBuilder = this.parentBasicFrameBuilder(basicFrameDim, tabFrameDim);
|
||||
|
||||
if(AngelicaConfig.enableIris) {
|
||||
int cumulativeXShift = 0;
|
||||
|
||||
if (AngelicaConfig.enableIris) {
|
||||
//int size = this.client.textRenderer.getWidth(new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()));
|
||||
final String irisText = I18n.format(IrisApi.getInstance().getMainScreenLanguageKey());
|
||||
final int size = this.mc.fontRenderer.getStringWidth(irisText);
|
||||
final Dim2i shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 10, tabFrameDim.getOriginY() - 26, 10 + size, 20);
|
||||
cumulativeXShift += size + 12;
|
||||
|
||||
searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth() - (tabFrameDim.getLimitX() - shaderPackButtonDim.getOriginX()) - 2, 20);
|
||||
|
||||
//FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()), () -> this.client.setScreen((Screen) IrisApi.getInstance().openMainIrisScreenObj(this)));
|
||||
final FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, irisText, () -> mc.displayGuiScreen(new ShaderPackScreen(this)));
|
||||
basicFrameBuilder.addChild(dim -> shaderPackButton);
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableFontRenderer) {
|
||||
final String fontConfigText = I18n.format("options.angelica.fontconfig");
|
||||
final int size = this.mc.fontRenderer.getStringWidth(fontConfigText);
|
||||
final Dim2i fontConfigButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 12 - cumulativeXShift, tabFrameDim.getOriginY() - 26, 12 + size, 20);
|
||||
cumulativeXShift += size + 14;
|
||||
|
||||
final FlatButtonWidget fontConfigButton = new FlatButtonWidget(fontConfigButtonDim, fontConfigText, () -> mc.displayGuiScreen(new FontConfigScreen(this)));
|
||||
basicFrameBuilder.addChild(dim -> fontConfigButton);
|
||||
}
|
||||
|
||||
Dim2i searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth() - cumulativeXShift, 20);
|
||||
this.searchTextField = new SearchTextFieldComponent(searchTextFieldDim, this.pages, tabFrameSelectedTab,
|
||||
tabFrameScrollBarOffset, optionPageScrollBarOffset, tabFrameDim.getHeight(), this, lastSearch, lastSearchIndex);
|
||||
|
||||
|
||||
+2
-1
@@ -47,7 +47,8 @@ public class TabFrame extends AbstractFrame {
|
||||
this.tabSectionSelectedTab = tabSectionSelectedTab;
|
||||
|
||||
if (this.tabSectionSelectedTab.get() != null) {
|
||||
this.selectedTab = this.tabs.stream().filter(tab -> tab.getTitle().equals(this.tabSectionSelectedTab.get())).findAny().get();
|
||||
Optional<Tab<?>> possibleLastTab = this.tabs.stream().filter(tab -> tab.getTitle().equals(this.tabSectionSelectedTab.get())).findAny();
|
||||
possibleLastTab.ifPresent(tab -> this.selectedTab = tab);
|
||||
}
|
||||
|
||||
this.buildFrame();
|
||||
|
||||
@@ -397,9 +397,9 @@ public class SodiumGameOptionPages {
|
||||
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.itemdisplaylistcount"))
|
||||
.setTooltip(I18n.format("options.angelica.itemdisplaylistcount.tooltip"))
|
||||
.setControl(o -> new SliderControl(o, 0, 1024, 1, ControlValueFormatter.number()))
|
||||
.setControl(o -> new SliderControl(o, 256, 1024, 16, ControlValueFormatter.number()))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> AngelicaConfig.itemRendererDisplayListCacheSize = value, options -> AngelicaConfig.itemRendererDisplayListCacheSize)
|
||||
.setBinding((opts, value) -> AngelicaConfig.itemRendererCacheSize = value, options -> AngelicaConfig.itemRendererCacheSize)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
|
||||
@@ -259,6 +259,7 @@ public class SodiumWorldRenderer {
|
||||
if(AngelicaConfig.enableIris) {
|
||||
if (ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
|
||||
ShadowRenderer.visibleTileEntities.addAll(this.chunkRenderManager.getVisibleTileEntities());
|
||||
ShadowRenderer.globalTileEntities.addAll(this.globalTileEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,7 +377,7 @@ public class SodiumWorldRenderer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void renderTileEntities(EntityLivingBase entity, ICamera camera, float partialTicks) {
|
||||
final int pass = MinecraftForgeClient.getRenderPass();
|
||||
for (TileEntity tileEntity : this.chunkRenderManager.getVisibleTileEntities()) {
|
||||
@@ -390,7 +391,7 @@ public class SodiumWorldRenderer {
|
||||
|
||||
public void onChunkRenderUpdated(int x, int y, int z, ChunkRenderData meshBefore, ChunkRenderData meshAfter) {
|
||||
ListUtil.updateList(this.globalTileEntities, meshBefore.getGlobalTileEntities(), meshAfter.getGlobalTileEntities());
|
||||
|
||||
|
||||
this.chunkRenderManager.onChunkRenderUpdates(x, y, z, meshAfter);
|
||||
}
|
||||
|
||||
|
||||
@@ -352,12 +352,9 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
|
||||
private void addEntitiesToRenderLists(ChunkRenderContainer<T> render) {
|
||||
Collection<TileEntity> tileEntities = render.getData().getTileEntities();
|
||||
|
||||
if (!tileEntities.isEmpty()) {
|
||||
this.visibleTileEntities.addAll(tileEntities);
|
||||
}
|
||||
this.visibleTileEntities.addAll(tileEntities);
|
||||
}
|
||||
|
||||
|
||||
public ChunkRenderContainer<T> getRender(int x, int y, int z) {
|
||||
ChunkRenderColumn<T> column = this.columns.get(ChunkPos.toLong(x, z));
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
@@ -39,6 +38,7 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
@@ -603,18 +603,18 @@ public class Iris {
|
||||
}
|
||||
|
||||
public static String getFormattedVersion() {
|
||||
final ChatFormatting color;
|
||||
final EnumChatFormatting color;
|
||||
String version = getVersion();
|
||||
|
||||
if (version.endsWith("-development-environment")) {
|
||||
color = ChatFormatting.GOLD;
|
||||
color = EnumChatFormatting.GOLD;
|
||||
version = version.replace("-development-environment", " (Development Environment)");
|
||||
} else if (version.endsWith("-dirty") || version.contains("unknown") || version.endsWith("-nogit")) {
|
||||
color = ChatFormatting.RED;
|
||||
color = EnumChatFormatting.RED;
|
||||
} else if (version.contains("+rev.")) {
|
||||
color = ChatFormatting.LIGHT_PURPLE;
|
||||
color = EnumChatFormatting.LIGHT_PURPLE;
|
||||
} else {
|
||||
color = ChatFormatting.GREEN;
|
||||
color = EnumChatFormatting.GREEN;
|
||||
}
|
||||
|
||||
return color + version;
|
||||
|
||||
@@ -35,6 +35,24 @@ public class StandardMacros {
|
||||
defines.add(new StringPair(key, value));
|
||||
}
|
||||
|
||||
private static String makeAngelicaVersion()
|
||||
{
|
||||
String[] parts = Tags.VERSION.split("[.-]");
|
||||
int major = Integer.parseInt(parts[0]);
|
||||
int minor = Integer.parseInt(parts[1]);
|
||||
int patch = Integer.parseInt(parts[2]);
|
||||
int sub = 0;
|
||||
|
||||
// Handle optional prerelease (like beta62)
|
||||
if (parts.length > 3) {
|
||||
String pre = parts[3];
|
||||
String num = pre.replaceAll("\\D+", ""); // remove all non-digits
|
||||
if (!num.isEmpty())
|
||||
sub = Integer.parseInt(num);
|
||||
}
|
||||
return String.format("%d%02d%02d%03d", major, minor, patch, sub);
|
||||
}
|
||||
|
||||
public static Iterable<StringPair> createStandardEnvironmentDefines() {
|
||||
ArrayList<StringPair> standardDefines = new ArrayList<>();
|
||||
|
||||
@@ -54,7 +72,7 @@ public class StandardMacros {
|
||||
define(standardDefines, "MC_RENDER_QUALITY", "1.0");
|
||||
define(standardDefines, "MC_SHADOW_QUALITY", "1.0");
|
||||
define(standardDefines, "IS_ANGELICA");
|
||||
define(standardDefines, "ANGELICA_VERSION", Tags.VERSION);
|
||||
define(standardDefines, "ANGELICA_VERSION", makeAngelicaVersion());
|
||||
define(standardDefines, "MC_HAND_DEPTH", Float.toString(HandRenderer.DEPTH));
|
||||
|
||||
TextureFormat textureFormat = TextureFormatLoader.getFormat();
|
||||
|
||||
@@ -175,7 +175,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
final Framebuffer main = Minecraft.getMinecraft().getFramebuffer();
|
||||
|
||||
final int depthTextureId = ((IRenderTargetExt)main).getIris$depthTextureId();
|
||||
final int depthTextureId = ((IRenderTargetExt)main).iris$getDepthTextureId();
|
||||
final int internalFormat = TextureInfoCache.INSTANCE.getInfo(depthTextureId).getInternalFormat();
|
||||
final DepthBufferFormat depthBufferFormat = DepthBufferFormat.fromGlEnumOrDefault(internalFormat);
|
||||
|
||||
@@ -911,7 +911,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
final Framebuffer main = Minecraft.getMinecraft().getFramebuffer();
|
||||
|
||||
final int depthTextureId = ((IRenderTargetExt)main).getIris$depthTextureId();
|
||||
final int depthTextureId = ((IRenderTargetExt)main).iris$getDepthTextureId();
|
||||
final int internalFormat = TextureInfoCache.INSTANCE.getInfo(depthTextureId).getInternalFormat();
|
||||
final DepthBufferFormat depthBufferFormat = DepthBufferFormat.fromGlEnumOrDefault(internalFormat);
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ public class ShadowRenderer {
|
||||
public static final FloatBuffer MODELVIEW_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
public static final Matrix4f PROJECTION = new Matrix4f();
|
||||
public static List<TileEntity> visibleTileEntities;
|
||||
public static List<TileEntity> globalTileEntities;
|
||||
public static boolean ACTIVE = false;
|
||||
private final float halfPlaneLength;
|
||||
private final float renderDistanceMultiplier;
|
||||
@@ -460,6 +461,7 @@ public class ShadowRenderer {
|
||||
MODELVIEW_BUFFER.clear().rewind();
|
||||
modelView.peek().getModel().get(MODELVIEW_BUFFER);
|
||||
GL11.glLoadMatrix(MODELVIEW_BUFFER);
|
||||
|
||||
for (TileEntity tileEntity : visibleTileEntities) {
|
||||
if (hasEntityFrustum && (culler.isCulled(tileEntity.xCoord - 1, tileEntity.yCoord - 1, tileEntity.zCoord - 1, tileEntity.xCoord + 1, tileEntity.yCoord + 1, tileEntity.zCoord + 1))) {
|
||||
continue;
|
||||
@@ -468,6 +470,15 @@ public class ShadowRenderer {
|
||||
|
||||
shadowTileEntities++;
|
||||
}
|
||||
for (TileEntity tileEntity : globalTileEntities) {
|
||||
if (hasEntityFrustum && (culler.isCulled(tileEntity.xCoord - 1, tileEntity.yCoord - 1, tileEntity.zCoord - 1, tileEntity.xCoord + 1, tileEntity.yCoord + 1, tileEntity.zCoord + 1))) {
|
||||
continue;
|
||||
}
|
||||
renderTileEntity(tileEntity, cameraX, cameraY, cameraZ, partialTicks);
|
||||
|
||||
shadowTileEntities++;
|
||||
}
|
||||
|
||||
GLStateManager.glPopMatrix();
|
||||
|
||||
renderedShadowTileEntities = shadowTileEntities;
|
||||
@@ -492,6 +503,7 @@ public class ShadowRenderer {
|
||||
// levelRenderer.setRenderBuffers(buffers);
|
||||
|
||||
visibleTileEntities = new ArrayList<>();
|
||||
globalTileEntities = new ArrayList<>();
|
||||
|
||||
// Create our camera
|
||||
final MatrixStack modelView = createShadowModelView(this.sunPathRotation, this.intervalSize);
|
||||
|
||||
@@ -222,6 +222,10 @@ public class ShaderTransformer {
|
||||
for (var entry : types.entrySet()) {
|
||||
String formattedShader = getFormattedShader(entry.getValue(), prepatched.get(entry.getKey()));
|
||||
|
||||
// Restore identifiers that were temporarily renamed to dodge GLSL reserved keywords.
|
||||
formattedShader = formattedShader.replace("iris_renamed_texture", "texture");
|
||||
formattedShader = formattedShader.replace("iris_renamed_sample", "sample");
|
||||
|
||||
// Please don't mind the entire rest of this loop basically, we're doing awful fragile regex on the transformed
|
||||
// shader output to do things that I can't figure out with AST because I'm bad at it
|
||||
|
||||
|
||||
@@ -13,6 +13,13 @@ public class BufferFlipper {
|
||||
}
|
||||
|
||||
public void flip(int target) {
|
||||
// colortex6 carries material/mask data that the gbuffer populates every frame.
|
||||
// If we allow it to flip, the alternate texture remains empty and later copy-back
|
||||
// wipes the fresh mask, breaking TAA mask lookups (notably on foliage/transparents).
|
||||
if (target == 6) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!flippedBuffers.remove(target)) {
|
||||
// If the target wasn't in the set, add it to the set.
|
||||
flippedBuffers.add(target);
|
||||
|
||||
@@ -49,6 +49,7 @@ public class FinalPassRenderer {
|
||||
@Nullable
|
||||
private final Pass finalPass;
|
||||
private final ImmutableList<SwapPass> swapPasses;
|
||||
private final ImmutableSet<Integer> flippedBuffers;
|
||||
private final GlFramebuffer baseline;
|
||||
private final GlFramebuffer colorHolder;
|
||||
private int lastColorTextureId;
|
||||
@@ -72,6 +73,7 @@ public class FinalPassRenderer {
|
||||
|
||||
this.noiseTexture = noiseTexture;
|
||||
this.renderTargets = renderTargets;
|
||||
this.flippedBuffers = flippedBuffers;
|
||||
this.customUniforms = customUniforms;
|
||||
this.finalPass = pack.getCompositeFinal().map(source -> {
|
||||
Pass pass = new Pass();
|
||||
@@ -101,23 +103,37 @@ public class FinalPassRenderer {
|
||||
// TODO: We don't actually fully swap the content, we merely copy it from alt to main
|
||||
// This works for the most part, but it's not perfect. A better approach would be creating secondary
|
||||
// framebuffers for every other frame, but that would be a lot more complex...
|
||||
ImmutableList.Builder<SwapPass> swapPasses = ImmutableList.builder();
|
||||
final ImmutableList.Builder<SwapPass> swapPasses = ImmutableList.builder();
|
||||
|
||||
flippedBuffers.forEach(i -> {
|
||||
int target = i;
|
||||
// BUG FIX: Swap passes are only needed for NON-flipped buffers that might flip in the future.
|
||||
// Flipped buffers use ping-pong mechanism - no swap needed.
|
||||
// Original code created swaps for ALL flippedAtLeastOnce buffers and copied ALT→MAIN,
|
||||
// which destroyed fresh data in MAIN for currently-flipped buffers (breaking TAA).
|
||||
// Fixed: Only create swaps for buffers that are in flippedAtLeastOnce but NOT currently flipped.
|
||||
flippedAtLeastOnce.forEach(i -> {
|
||||
final int target = i;
|
||||
|
||||
// Skip buffer 6 (material mask) - gbuffers always write to MAIN, never flipped
|
||||
if (target == 6) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip buffers that are currently flipped - they use ping-pong, no swap needed
|
||||
if (flippedBuffers.contains(target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffersToBeCleared.contains(target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
SwapPass swap = new SwapPass();
|
||||
RenderTarget target1 = renderTargets.get(target);
|
||||
final SwapPass swap = new SwapPass();
|
||||
final RenderTarget target1 = renderTargets.get(target);
|
||||
swap.target = target;
|
||||
swap.width = target1.getWidth();
|
||||
swap.height = target1.getHeight();
|
||||
// Non-flipped buffers write to ALT, copy ALT→MAIN to preserve data
|
||||
swap.from = renderTargets.createColorFramebuffer(ImmutableSet.of(), new int[] {target});
|
||||
// NB: This is handled in RenderTargets now.
|
||||
//swap.from.readBuffer(target);
|
||||
swap.targetTexture = renderTargets.get(target).getMainTexture();
|
||||
|
||||
swapPasses.add(swap);
|
||||
@@ -264,8 +280,10 @@ public class FinalPassRenderer {
|
||||
|
||||
public void recalculateSwapPassSize() {
|
||||
for (SwapPass swapPass : swapPasses) {
|
||||
RenderTarget target = renderTargets.get(swapPass.target);
|
||||
final RenderTarget target = renderTargets.get(swapPass.target);
|
||||
renderTargets.destroyFramebuffer(swapPass.from);
|
||||
// Match constructor logic - swap passes are only for non-flipped buffers
|
||||
// Copy ALT→MAIN to preserve data written to ALT
|
||||
swapPass.from = renderTargets.createColorFramebuffer(ImmutableSet.of(), new int[] {swapPass.target});
|
||||
swapPass.width = target.getWidth();
|
||||
swapPass.height = target.getHeight();
|
||||
@@ -274,7 +292,7 @@ public class FinalPassRenderer {
|
||||
}
|
||||
|
||||
private static void setupMipmapping(RenderTarget target, boolean readFromAlt) {
|
||||
int texture = readFromAlt ? target.getAltTexture() : target.getMainTexture();
|
||||
final int texture = readFromAlt ? target.getAltTexture() : target.getMainTexture();
|
||||
|
||||
// TODO: Only generate the mipmap if a valid mipmap hasn't been generated or if we've written to the buffer
|
||||
// (since the last mipmap was generated)
|
||||
@@ -319,13 +337,13 @@ public class FinalPassRenderer {
|
||||
source.getVertexSource().orElseThrow(NullPointerException::new),
|
||||
source.getGeometrySource().orElse(null),
|
||||
source.getFragmentSource().orElseThrow(NullPointerException::new));
|
||||
String vertex = transformed.get(PatchShaderType.VERTEX);
|
||||
String geometry = transformed.get(PatchShaderType.GEOMETRY);
|
||||
String fragment = transformed.get(PatchShaderType.FRAGMENT);
|
||||
final String vertex = transformed.get(PatchShaderType.VERTEX);
|
||||
final String geometry = transformed.get(PatchShaderType.GEOMETRY);
|
||||
final String fragment = transformed.get(PatchShaderType.FRAGMENT);
|
||||
PatchedShaderPrinter.debugPatchedShaders(source.getName(), vertex, geometry, fragment);
|
||||
|
||||
Objects.requireNonNull(flipped);
|
||||
ProgramBuilder builder;
|
||||
final ProgramBuilder builder;
|
||||
|
||||
try {
|
||||
builder = ProgramBuilder.begin(source.getName(), vertex, geometry, fragment,
|
||||
@@ -337,7 +355,7 @@ public class FinalPassRenderer {
|
||||
|
||||
this.customUniforms.assignTo(builder);
|
||||
|
||||
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
|
||||
final ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
|
||||
|
||||
CommonUniforms.addDynamicUniforms(builder);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
|
||||
@@ -361,15 +379,15 @@ public class FinalPassRenderer {
|
||||
}
|
||||
|
||||
private ComputeProgram[] createComputes(ComputeSource[] compute, ImmutableSet<Integer> flipped, ImmutableSet<Integer> flippedAtLeastOnceSnapshot, Supplier<ShadowRenderTargets> shadowTargetsSupplier) {
|
||||
ComputeProgram[] programs = new ComputeProgram[compute.length];
|
||||
final ComputeProgram[] programs = new ComputeProgram[compute.length];
|
||||
for (int i = 0; i < programs.length; i++) {
|
||||
ComputeSource source = compute[i];
|
||||
final ComputeSource source = compute[i];
|
||||
if (source == null || !source.getSource().isPresent()) {
|
||||
continue;
|
||||
} else {
|
||||
// TODO: Properly handle empty shaders
|
||||
Objects.requireNonNull(flipped);
|
||||
ProgramBuilder builder;
|
||||
final ProgramBuilder builder;
|
||||
|
||||
try {
|
||||
builder = ProgramBuilder.beginCompute(source.getName(), source.getSource().orElse(null), IrisSamplers.COMPOSITE_RESERVED_TEXTURE_UNITS);
|
||||
|
||||
@@ -5,6 +5,5 @@ public interface IRenderTargetExt {
|
||||
|
||||
int iris$getColorBufferVersion();
|
||||
|
||||
public boolean getIris$useDepth();
|
||||
public int getIris$depthTextureId();
|
||||
int iris$getDepthTextureId();
|
||||
}
|
||||
@@ -4,6 +4,9 @@ import net.minecraft.util.ResourceLocation;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
||||
public enum PBRType {
|
||||
NORMAL("_n", 0x7F7FFFFF),
|
||||
SPECULAR("_s", 0x00000000);
|
||||
@@ -26,17 +29,37 @@ public enum PBRType {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public ResourceLocation appendToFileLocation(ResourceLocation location) {
|
||||
String path = location.getResourcePath();
|
||||
String newPath;
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(path);
|
||||
if (extensionIndex != -1) {
|
||||
newPath = path.substring(0, extensionIndex) + suffix + path.substring(extensionIndex);
|
||||
} else {
|
||||
newPath = path + suffix;
|
||||
}
|
||||
return new ResourceLocation(location.getResourceDomain(), newPath);
|
||||
}
|
||||
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();
|
||||
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(cleanPath);
|
||||
if (extensionIndex != -1) {
|
||||
newPath = cleanPath.substring(0, extensionIndex) + suffix + cleanPath.substring(extensionIndex);
|
||||
} else {
|
||||
newPath = cleanPath + suffix;
|
||||
}
|
||||
|
||||
URI newUri = new URI(null, null, newPath, null);
|
||||
newPath = newUri.getPath();
|
||||
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
return new ResourceLocation(domain, newPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PBR type corresponding to the suffix of the given file location.
|
||||
|
||||
@@ -103,7 +103,11 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
NativeImage nativeImage = NativeImage.read(resource.getInputStream());
|
||||
AnimationMetadataSection animationMetadata = (AnimationMetadataSection) resource.getMetadata("animation");
|
||||
if (animationMetadata == null) {
|
||||
animationMetadata = new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1);
|
||||
final IResource resourceOriginal = resourceManager.getResource(imageLocation);
|
||||
animationMetadata = (AnimationMetadataSection) resourceOriginal.getMetadata("animation");
|
||||
if (animationMetadata == null) {
|
||||
animationMetadata = new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
final Pair<Integer, Integer> frameSize = this.getFrameSize(nativeImage.getWidth(), nativeImage.getHeight(), animationMetadata);
|
||||
|
||||
@@ -16,4 +16,3 @@ public net.minecraft.potion.PotionHelper field_77925_n # field_77925_n PotionCol
|
||||
public net.minecraft.client.renderer.texture.TextureAtlasSprite <init>(Ljava.lang.String;)V # constuctor
|
||||
public net.minecraft.entity.projectile.EntityPotion field_70197_d # potionDamage
|
||||
public net.minecraft.client.resources.SimpleResource field_110533_b # srResourceLocation
|
||||
public net.minecraft.client.renderer.EntityRenderer func_82830_a(Lnet/minecraft/entity/player/EntityPlayer;F)F # getNightVisionBrightness
|
||||
@@ -2,7 +2,7 @@ name=Angelica
|
||||
version=${version}
|
||||
additionalVersions=
|
||||
className=com.gtnewhorizons.angelica.loading.rfb.AngelicaRfbPlugin
|
||||
transformerExclusions=com.gtnewhorizons.angelica.transform.RedirectorTransformer
|
||||
transformerExclusions=com.gtnewhorizons.angelica.loading.shared
|
||||
versionConstraints=
|
||||
loadBefore=
|
||||
loadAfter=mixin; lwjgl3ify
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
options.button.shader=Shader...
|
||||
|
||||
options.chunks=%s Chunks
|
||||
options.entityShadows=Entitätschatten
|
||||
options.droppedItems=%s Items
|
||||
options.droppedItems.max=Alle
|
||||
sodium.option_impact.low=Niedrig
|
||||
sodium.option_impact.medium=Mittel
|
||||
sodium.option_impact.high=Hoch
|
||||
sodium.option_impact.extreme=Extrem
|
||||
sodium.option_impact.varies=Variiert
|
||||
sodium.options.pages.quality=Qualität
|
||||
sodium.options.pages.performance=Performance
|
||||
sodium.options.pages.advanced=Erweiterte Optionen
|
||||
sodium.options.view_distance.tooltip=Die Sichtweite bestimmt, wie weit das Terrain gerendert wird. Kürzere Distanzen reduzieren die Menge des gerendeten Terrains und verbessern die Bildrate.
|
||||
sodium.options.simulation_distance.tooltip=Der Simulationsabstand bestimmt, wie weit Terrain und Entitäten geladen und aktualisiert werden. Kürzere Distanzen senken die Rechenlast des internen Servers und können die Bildrate verbessern.
|
||||
sodium.options.brightness.tooltip=Steuert die Spielhelligkeit (Gamma).
|
||||
sodium.options.clouds.name=Wolken
|
||||
sodium.options.clouds.tooltip=Steuert, ob Wolken angezeigt werden.
|
||||
sodium.options.gui_scale.tooltip=Setzt den maximalen Skalierungsfaktor für das Nutzerinterface. Bei 'auto' wird immer der größte Faktor ausgewählt.
|
||||
sodium.options.fullscreen.tooltip=Zeigt das Spiel in Vollbild an (wenn unterstützt).
|
||||
sodium.options.v_sync.tooltip=Synchronisiert die Bildrate des Spiels mit der Bildwiederholrate des Monitors. Dies sorgt für ein flüssigeres Spielerlebnis, erhöht jedoch die Eingabeverzögerung. Kann die Performance beeinträchtigen, wenn das System langsam ist.
|
||||
sodium.options.fps_limit.tooltip=Begrenzt die Bildrate. Dies kann die Batterielaufzeit und Rechenlast verbessern. Mit angeschaltetem V-Sync wird diese Option ignoriert, außer sie ist niedriger als deine Monitor-Bildwiederholfrequenz.
|
||||
sodium.options.view_bobbing.tooltip=Aktiviert den Wippeffekt beim Laufen. Spieler, denen schnell übel wird, sollten das deaktivieren.
|
||||
sodium.options.attack_indicator.tooltip=Steuert, ob der Angriffsindikator angezeigt wird.
|
||||
sodium.options.autosave_indicator.tooltip=Legt fest, ob der Autospeicher-Indikator angezeigt wird.
|
||||
sodium.options.graphics_quality.tooltip=Die Grafikqualität-Auswahl ist für einige alte Optionen und für Modkompatibilität notwendig. Wenn die Optionen unten auf den Standardeinstellungen gelassen werden, werden sie diese Option verwenden.
|
||||
sodium.options.clouds_quality.tooltip=Steuert die Wolkenqualität.
|
||||
sodium.options.weather_quality.tooltip=Steuert die Qualität von Regen- und Schneeffekten.
|
||||
sodium.options.leaves_quality.name=Laubqualität
|
||||
sodium.options.leaves_quality.tooltip=Steuert die Qualität von Laubblöcken.
|
||||
sodium.options.grass_quality.name=Grasqualität
|
||||
sodium.options.grass_quality.tooltip=Steuert die Qualität von den Seiten von Grasblöcken.
|
||||
sodium.options.sodium_smooth_lighting.name=Weiche Beleuchtung von Sodium
|
||||
sodium.options.sodium_smooth_lighting.tooltip=Aktiviert die Lichtverarbeitung von Sodium für weiche Beleuchtung. Funktioniert nur, wenn "Weiche Beleuchtung" aktiviert ist.
|
||||
sodium.options.particle_quality.name=Partikelqualität
|
||||
sodium.options.particle_quality.tooltip=Steuert die maximale Anzahl von angezeigten Partikeln.
|
||||
sodium.options.smooth_lighting.tooltip=Legt fest, ob Blöcke weich beleuchtet und schattiert werden. Das erhöht die Chunkerstellungzeit leicht, aber ändert nichts an der Bildrate.
|
||||
sodium.options.biome_blend.value=%s Block/Blöcke
|
||||
sodium.options.biome_blend.tooltip=Bestimmt den Bereich, in dem Biome für Blockverfärbung berücksichtigt werden. Höhere Werte erhöhen die Chunk-Erstellungszeit erheblich, während die Qualitätsverbesserung immer geringer ausfällt.
|
||||
sodium.options.entity_distance.tooltip=Steuert, wie weit Entitäten vom Spieler entfernt gerendert werden. Höhere Werte erhöhen die Renderdistanz auf Kosten der Bildrate.
|
||||
sodium.options.entity_shadows.tooltip=Einfache Schatten unter Entitäten werden angezeigt wenn das hier angeschaltet ist.
|
||||
sodium.options.vignette.name=Vignette
|
||||
sodium.options.vignette.tooltip=Aktiviert einen Vignetteneffekt in der Spieleransicht. Beeinflusst die Bildrate nur selten, es sei denn, die Leistung ist durch die Fillrate begrenzt.
|
||||
sodium.options.mipmap_levels.tooltip=Steuert die Anzahl an Mipmaps, die für Blockmodelle verwendet werden. Höhere Werte sorgen für bessere Anzeigequalität in der Ferne, aber kann für animierte Texturen die Performance verschlechtern.
|
||||
sodium.options.use_chunk_multidraw.name=Chunk-Multidraw
|
||||
sodium.options.use_chunk_multidraw.tooltip=Multidraw ermöglicht das Rendern mehrerer Chunks mit weniger Zeichenbefehlen, wodurch die Rechenlast beim Rendern der Welt erheblich reduziert und die Ressourcennutzung effizienter wird. Diese Optimierung verursacht manchmal Probleme mit Grafiktreibern, und wenn du Grafikfehler bemerkt, könnte sie auszuschalten helfen.
|
||||
sodium.options.use_vertex_objects.name=Vertex-Array-Objekte
|
||||
sodium.options.use_vertex_objects.tooltip=Erhöht die Performance, indem Scheitelpunktinformation in den Treiber übertragen werden, um bessere Optimierung bei wiederholtem Rendern derselben Entitäten zu erlauben. Es gibt eigentlich keinen Grund, diese Option auszuschalten, außer du benutzt Mods, die damit nicht funktionieren.
|
||||
sodium.options.use_block_face_culling.name=Blockflächen-Culling
|
||||
sodium.options.use_block_face_culling.tooltip=Aktiviert das Rendern nur der Blockflächen, die im Sichtfeld des Spielers liegen. Dies reduziert die Anzahl der gerenderte Blockflächen erheblich, spart Grafikspeicher und Rechenzeit. Manche Ressourcenpakete können Probleme damit haben; Deaktiviere die Option, falls Löcher in Blöcken auftreten.
|
||||
sodium.options.use_compact_vertex_format.name=Kompaktes Scheitelpunktformat
|
||||
sodium.options.use_compact_vertex_format.tooltip=Verwendet ein kompakteres Format für Vertex-Daten beim Chunk-Rendern. Dies kann den Grafikspeicherbedarf und die Bandbreitenbelastung deutlich reduzieren, besonders bei integrierten Grafikkarten, kann aber bei manchen Ressourcenpaketen Z-Fighting verursachen.
|
||||
sodium.options.use_fog_occlusion.name=Nebel-Culling
|
||||
sodium.options.use_fog_occlusion.tooltip=Chunks, die vollständig durch Nebel verdeckt sind, werden nicht gerendert. Das kann bei starken Nebellagen (wie Unterwasser) die Performance stark erhöhen, kann aber am Himmel manchmal Artefakte auslösen.
|
||||
sodium.options.use_entity_culling.name=Entitäts-Culling
|
||||
sodium.options.use_entity_culling.tooltip=Entitäten außerhalb sichtbarer Chunks werden beim Rendern übersprungen. Dies kann die Performance erhöhen, weil sie hinter Wänden oder unter Tage übersprungen werden können.
|
||||
sodium.options.use_particle_culling.name=Partikel-Culling
|
||||
sodium.options.use_particle_culling.tooltip=Zeigt nur Partikel innerhalb des Spielersichtfeldes an. Dies kann die Performance bemerkbar verbessern, wenn viele Partikel in der Nähe sind.
|
||||
sodium.options.animate_only_visible_textures.name=Nur sichtbare Texturen animieren
|
||||
sodium.options.animate_only_visible_textures.tooltip=Animiert nur Texturen, die auch im Sichtfeld des Spielers sind. Dies kann die Framerate mancher Hardware stark verbessern, besonders bei "schwereren" Ressourcenpaketen. Wenn du Probleme damit hast, dass Texturen nicht animiert werden, versuch, ob das hier auszuschalten hilft.
|
||||
sodium.options.translucency_sorting.name=Durchsichtigkeits-Sortierung
|
||||
sodium.options.translucency_sorting.tooltip=Aktiviert die korrekte Sortierung durchsichtiger Blöcke von hinten nach vorne für bessered Rendern,insbesondere bei überlappenden durchsichtigen Blöcken. Dies kann die Rechenlast erhöhen.
|
||||
sodium.options.cpu_render_ahead_limit.name=CPU-Vorausrendern begrenzen
|
||||
sodium.options.cpu_render_ahead_limit.tooltip=Die maximale Anzahl an Frames, die der CPU auf das Rendern des GPU warten darf. Sehr niedrige oder hohe Werte können die Bildrate destabilisieren.
|
||||
sodium.options.cpu_render_ahead_limit.value=%s Frame(s)
|
||||
sodium.options.allow_direct_memory_access.name=Direkten Speicherzugriff erlauben
|
||||
sodium.options.allow_direct_memory_access.tooltip=Ermöglichst bestimmten Prozessen den direkten Speicherzugriff zur Leistungssteigerung. Dies kann die Rechenlast deutlich reduzieren, erschwert jedoch die Diagnose von Fehlern und Abstürzen. Deaktiviere dies nur aus, wenn du dazu aufgefordert wirst oder du genau weißt, was du tust.
|
||||
sodium.options.ignore_driver_blacklist.name=Treiber-Blacklist ignorieren
|
||||
sodium.options.ignore_driver_blacklist.tooltip=Ignoriert bekannte Inkompatibilitäten mit deiner Hardware/deinen Treibern, um Optionen zu erlauben, die Probleme mit dem Spiel verursachen können. Benutz diese Option nur, wenn du genau weißt, was du tust. Wenn du diese Option veränderst musst du einmal die Einstellung speichern, schließen und neu öffnen.
|
||||
sodium.options.enable_memory_tracing.name=Memory Tracing erlauben
|
||||
sodium.options.enable_memory_tracing.tooltip=Debug-Feature. Wenn angeschaltet, werden Stack Traces mit Speicherzuweisungen gesammelt, um bessere Diagnostik zu erlauben, gerade bei Speicherlecks.
|
||||
sodium.options.performance_impact_string=Performanceeinfluss: %s
|
||||
sodium.options.use_persistent_mapping.name=Persistente Speicherzuordnung
|
||||
sodium.options.use_persistent_mapping.tooltip=Erlaubt, einen kleinen Speicherbereich persistent zuordnen zu lassen, um Chunkupdates und Entitätsrendering zu beschleunigen.\n\Erfordert OpenGL 4.4 oder ARB_buffer_storage.
|
||||
sodium.options.chunk_memory_allocator.name=Chunk-Memory-Allocator
|
||||
sodium.options.chunk_memory_allocator.tooltip=Wählt den Memory Allocator, der für das Rendern von Chunks verwendet wird.\n- ASYNC: Schnellste Wahl, funktioniert gut mit den meisten modernen Grafiktreibern.\n- SWAP: Ausweichoption für ältere Grafiktreiber. Kann merklich mehr Arbeitsspeicher erfordern..
|
||||
sodium.options.chunk_memory_allocator.async=Async
|
||||
sodium.options.chunk_memory_allocator.swap=Swap
|
||||
sodium.options.chunk_update_threads.name=Chunk Update-Threads
|
||||
sodium.options.chunk_update_threads.tooltip=Bestimmt die Anzahl an Threads für den Chunk-Aufbau. Mehr Threads können schnelleres Laden und Updaten erlauben, aber die Bildrate reduzieren.
|
||||
sodium.options.always_defer_chunk_updates.name=Chunk Updates immer herauszögern
|
||||
sodium.options.always_defer_chunk_updates.tooltip=Wenn angeschaltet, wartet das Rendering nie, bis Chunkupdates vollzogen wurden, selbst wenn sie wichtig sind. Das kann in manchen Szenarios die Bildrate stark verbessern, aber signfikanten Grafiklag in der Welt erzeugen.
|
||||
sodium.options.use_no_error_context.name=Kein Fehlerkontext
|
||||
sodium.options.use_no_error_context.tooltip=Aktiviert den OpenGL-Kontext ohne Fehlerüberprüfung. Das kann die Performance leicht verbessern, erhöht aber auch das Crashrisiko bei OpenGL-Fehlern. Schalt es aus, wenn du unerwartete Crashes erlebst.
|
||||
sodium.options.use_gl_state_cache.name=GL-Zustandscache
|
||||
sodium.options.use_gl_state_cache.tooltip=Wenn angeschaltet, wird der OpenGL-Zustandscache verwendet um die Anzahl an redundanten Operationen zu senken. Das kann die Performance erhöhen, aber auch Probleme mit einigen Mods auslösen. Diese Option bleibt nicht über Spielstarts hinweg erhalten.
|
||||
sodium.options.threads.value=%s Thread(s)
|
||||
sodium.options.default=Standard
|
||||
sodium.options.buttons.undo=Rückgängig
|
||||
sodium.options.buttons.apply=Übernehmen
|
||||
sodium.options.buttons.donate=Spendiere JellySquid einen Kaffee!
|
||||
options.dynamic_fov=Dynamisches Sichtfeld
|
||||
options.dynamic_fov.tooltip=Wenn angeschaltet, ändert sich das Spielersichtfeld mit der Spielergeschwindigkeit
|
||||
options.framerate=%s FPS
|
||||
iris.shaders.toggled=Shader auf %s gestellt!
|
||||
iris.shaders.disabled=Shader ausgeschaltet!
|
||||
options.iris.apply=Übernehmen
|
||||
options.iris.refresh=Aktualisieren
|
||||
options.iris.openShaderPackFolder=Shaderpaket-Ordner öffnen...
|
||||
options.iris.shaderPackSettings=Shaderpaket-Einstellungen...
|
||||
options.iris.shaderPackList=Shaderpakete-Liste...
|
||||
options.iris.refreshShaderPacks=Shaderpakete aktualisieren
|
||||
options.iris.shaderPackSelection=Shaderpakete...
|
||||
options.iris.shaderPackSelection.title=Shaderpakete
|
||||
options.iris.shaderPackSelection.addedPack=Shaderpaket "%s" hinzugefügt
|
||||
options.iris.shaderPackSelection.addedPacks=%s Shaderpakete hinzugefügt
|
||||
options.iris.shaderPackSelection.failedAdd=Dateien sind kein zulässiges Shaderpaket
|
||||
options.iris.shaderPackSelection.failedAddSingle="%s" ist kein zulässiges Shaderpaket
|
||||
options.iris.shaderPackSelection.copyError=Konnte Shaderpaket "%s" nicht hinzufügen
|
||||
options.iris.shaderPackSelection.copyErrorAlreadyExists="%s" ist bereits in deinem Shaderpaket-Ordner!
|
||||
options.iris.shaderPackOptions.tooManyFiles=Du kannst nicht mehrere Shadereinstellungsdateien einfügen!
|
||||
options.iris.shaderPackOptions.failedImport=Konnte Shader-Einstellungsdatei "%s" nicht importieren
|
||||
options.iris.shaderPackOptions.importedSettings=Shadereinstellungen von "%s" importiert
|
||||
options.iris.shaders.disabled=Shader: Aus
|
||||
options.iris.shaders.enabled=Shader: An
|
||||
options.iris.shaders.nonePresent=Shader: Keine Pakete
|
||||
options.iris.back=Zurück
|
||||
options.iris.reset=Zurücksetzen
|
||||
options.iris.reset.tooltip=ALLE Optionen zurücksetzen?
|
||||
options.iris.reset.tooltip.holdShift=Halte SHIFT und klicke, um zurückzusetzen
|
||||
options.iris.importSettings.tooltip=Einstellungen importieren
|
||||
options.iris.exportSettings.tooltip=Einstellungen exportieren
|
||||
options.iris.mustDisableFullscreen=Bitte den Vollbildmodus deaktivieren!
|
||||
options.iris.setToDefault=Option auf Standardeinstellung zurücksetzen?
|
||||
options.iris.profile=Profil
|
||||
options.iris.profile.custom=Benutzerdefiniert
|
||||
options.iris.shadowDistance=Maximaler Schattenabstand
|
||||
options.iris.shadowDistance.sodium_tooltip=Maximaler Schattenabstand
|
||||
options.iris.shadowDistance.enabled=Verändert den maximalen Abstand für Schatten. Terrain und Entitäten weiter als diese Distanz werfen keine Schatten. Die Schattendistanz zu senken kann die Performance signifikant erhöhen.
|
||||
options.iris.shadowDistance.disabled=Dein aktuelles Shaderpaket legt bereits eine Schattendistanz fest. Du kannst sie hier nicht verändern.
|
||||
options.iris.gui.hide=GUI ausblenden
|
||||
options.iris.gui.show=GUI einblenden
|
||||
options.dynamic_lights=Dynamische Beleuchtung
|
||||
options.dynamic_lights.tooltip=Aktiviert dynamische Beleuchtung. Modi: OFF - aus, FASTEST - 500ms Verzögerung, FAST - 250ms Verzögerung, FANCY - 50ms Verzögerung, REALTIME - keine Verzögerung.
|
||||
options.dynamic_lights_shader_force=Dynamische Beleutung trotz Shader erzwingen
|
||||
options.dynamic_lights_shader_force.tooltip=Aktiviert - Dynamische Beleuchtung wird auch trotz Shader angezeigt, Deaktiviert - Dynamische Beleuchtung ist aus, wenn ein Shader aktiviert ist.
|
||||
options.angelica.droppedItemLimit=Dropped Item Render Limit
|
||||
options.angelica.droppedItemLimit=Renderlimit für liegende Items
|
||||
options.angelica.droppedItemLimit.tooltip=Die maximale Anzahl an herumliegenden Items, die gerendert wird. Niedrigere Werte verbessern die Performance.
|
||||
options.angelica.mobSpawnerRenderDistance=Monsterspawner-Renderdistanz
|
||||
options.angelica.mobSpawnerRenderDistance.tooltip=Renderabstand für das rotierende Monster in einem Monsterspawner
|
||||
options.angelica.itemdisplaylistcount=Item Renderer Display List Cache Size
|
||||
options.angelica.itemdisplaylistcount=Item-Renderer-Anzeigecache-Größe
|
||||
options.angelica.itemdisplaylistcount.tooltip=Größte Anzahl an Anzeigelisten, die im Itemrenderer gecacht werden. Höhere Werte erhöhen Performance zukosten von VRAM.
|
||||
options.angelica.sleepbeforeswap=Alternate FPS Limiter
|
||||
options.angelica.sleepbeforeswap=Alternativer FPS-Begrenzer
|
||||
options.angelica.sleepbeforeswap.tooltip=Aktiviert einen alternativen FPS-Begrenzer für stabilere Framezeiten, was zu geringfügig höherer Latenz führen kann. Wird nie mehr als einen Frame Latenz erzeugen, und hat bei hoher Framerate weniger Wirkung.
|
||||
pack.iris.select.title=Auswählen
|
||||
pack.iris.configure.title=Konfigurieren
|
||||
label.iris.true=An
|
||||
label.iris.false=Aus
|
||||
@@ -135,12 +135,37 @@ options.dynamic_lights=Dynamic Lights
|
||||
options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - 50ms delay, REALTIME - no delay.
|
||||
options.dynamic_lights_shader_force=Dynamic Lights - Forced With Shaders
|
||||
options.dynamic_lights_shader_force.tooltip=Enabled - Dynamic Lights are shown even when a shader is active, Disabled - Dynamic Lights are disabled when a shader is active.
|
||||
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.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.glyph_scale=Glyph Scale: %s
|
||||
options.angelica.fontconfig.glyph_aspect=Glyph Aspect: %s
|
||||
options.angelica.fontconfig.whitespace_scale=Whitespace Size: %s
|
||||
options.angelica.fontconfig.glyph_spacing=Glyph Spacing: %s
|
||||
options.angelica.fontconfig.font_aa_strength=Font AA Strength: %s
|
||||
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.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.
|
||||
options.angelica.fontconfig.glyph_spacing.tooltip=The spacing between each individual glyph.
|
||||
options.angelica.fontconfig.font_aa_strength.tooltip=The spacing of samples used in font antialiasing. High values may cause fonts to look blurry, low values may cause aliasing. See what works best with your settings.
|
||||
options.angelica.fontconfig.aamode.tooltip=The font antialiasing mode. Can significantly improve the appearance and readability of text that's being scaled or viewed at oblique angles, at the expense of some performance.
|
||||
options.angelica.droppedItemLimit=Dropped Item Render Limit
|
||||
options.angelica.droppedItemLimit.tooltip=The maximum number of dropped items that will be rendered. Lower values can improve performance.
|
||||
options.angelica.mobSpawnerRenderDistance=Mob spawner render distance
|
||||
options.angelica.mobSpawnerRenderDistance.tooltip=Render distance for the spinning mob inside mod spawners
|
||||
options.angelica.itemdisplaylistcount=Item Renderer Display List Cache Size
|
||||
options.angelica.itemdisplaylistcount.tooltip=The maximum number of display lists to cache in the optimized item renderer. Higher values will increase performance but increase VRAM usage.
|
||||
options.angelica.itemdisplaylistcount=Item Renderer Cache Limit
|
||||
options.angelica.itemdisplaylistcount.tooltip=The upper limit of VBO's to cache in the optimized item renderer. Higher values will significantly increase performance, but may result in increased VRAM usage.
|
||||
options.angelica.sleepbeforeswap=Alternate FPS Limiter
|
||||
options.angelica.sleepbeforeswap.tooltip=Switches to an alternate FPS limiter that gives more stable frametimes, in exchange for slightly more latency. Will never introduce more than one frame of latency, and has a lower impact at higher framerates.
|
||||
pack.iris.select.title=Select
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D sampler;
|
||||
uniform int aaMode;
|
||||
uniform float strength;
|
||||
|
||||
varying vec4 color;
|
||||
varying vec4 tB;
|
||||
|
||||
/*
|
||||
Hacky MSAA and anisotropic filtering. Cursed beyond belief. There _may_ have been simpler means of
|
||||
achieving the produced effects, but this appears to work without noticeable performance losses.
|
||||
*/
|
||||
|
||||
float totalWt;
|
||||
|
||||
float txSample(vec2 uv, float du, float dv, float factorU, float factorV) {
|
||||
float distSquared = sqrt(du * du + dv * dv);
|
||||
float weight = exp(-distSquared / 6);
|
||||
totalWt += weight;
|
||||
float finalU = uv.x + factorU * du;
|
||||
float finalV = uv.y + factorV * dv;
|
||||
if (finalU < tB.x || finalU > tB.y || finalV < tB.z || finalV > tB.w) {
|
||||
return 0.0f;
|
||||
}
|
||||
return weight * texture2D(sampler, vec2(finalU, finalV)).a;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 texCoords = gl_TexCoord[0].st;
|
||||
vec2 texScaled = texCoords * strength;
|
||||
vec4 col = color;
|
||||
float original_alpha = col.a;
|
||||
if (texCoords.s != 0 || texCoords.t != 0) {
|
||||
float res = 0;
|
||||
float fu = abs(dFdx(texScaled.x)) + abs(dFdy(texScaled.x));
|
||||
float fv = abs(dFdx(texScaled.y)) + abs(dFdy(texScaled.y));
|
||||
totalWt = 0;
|
||||
if (aaMode == 1) {
|
||||
res += txSample(texCoords, 2, 6, fu, fv);
|
||||
res += txSample(texCoords, 6, -2, fu, fv);
|
||||
res += txSample(texCoords, -2, -6, fu, fv);
|
||||
res += txSample(texCoords, -6, 2, fu, fv);
|
||||
} else {
|
||||
res += txSample(texCoords, 1, 1, fu, fv);
|
||||
res += txSample(texCoords, -1, -3, fu, fv);
|
||||
res += txSample(texCoords, -3, 2, fu, fv);
|
||||
res += txSample(texCoords, 4, -1, fu, fv);
|
||||
res += txSample(texCoords, -5, -2, fu, fv);
|
||||
res += txSample(texCoords, 2, 5, fu, fv);
|
||||
res += txSample(texCoords, 5, 3, fu, fv);
|
||||
res += txSample(texCoords, 3, -5, fu, fv);
|
||||
res += txSample(texCoords, -2, 6, fu, fv);
|
||||
res += txSample(texCoords, 0, -7, fu, fv);
|
||||
res += txSample(texCoords, -4, -6, fu, fv);
|
||||
res += txSample(texCoords, -6, 4, fu, fv);
|
||||
res += txSample(texCoords, -8, 0, fu, fv);
|
||||
res += txSample(texCoords, 7, -4, fu, fv);
|
||||
res += txSample(texCoords, 6, 7, fu, fv);
|
||||
res += txSample(texCoords, -7, -8, fu, fv);
|
||||
}
|
||||
res /= totalWt;
|
||||
col.a = original_alpha * res;
|
||||
}
|
||||
|
||||
gl_FragColor = col;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#version 120
|
||||
|
||||
attribute vec4 texBounds;
|
||||
varying vec4 tB;
|
||||
varying vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = ftransform();
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
color = gl_Color;
|
||||
tB = texBounds;
|
||||
}
|
||||
@@ -2,11 +2,19 @@ options.button.detail=Details...
|
||||
options.button.other=Sonstige...
|
||||
options.button.particle=Partikel...
|
||||
options.button.sky=Atmosphäre...
|
||||
options.chunks=%s Chunks
|
||||
options.graphics.shelledfancy=Schön [Hybrid]
|
||||
options.graphics.shelledfast=Schnell [Hybrid]
|
||||
options.graphics.smart=Smart
|
||||
options.graphics.ultra=Ultra
|
||||
options.off=Aus
|
||||
options.on=An
|
||||
options.cloud_height=Wolkenhöhe
|
||||
options.cloud_height.tooltip=Wolkenhöhe
|
||||
options.cloud_scale=Wolkengröße
|
||||
options.cloud_scale.tooltip=Wolkengröße
|
||||
options.gui_background=Hintergrund
|
||||
options.gui_background.tooltip=Hintergrund
|
||||
options.gui_background.-1=Standard
|
||||
options.gui_background.0=Sand
|
||||
options.gui_background.1=Myzel
|
||||
@@ -14,40 +22,73 @@ options.gui_background.2=Steinziegel
|
||||
options.gui_background.3=Bemooste Steinziegel
|
||||
options.gui_background.4=Eichenholzbretter
|
||||
options.gui_background.5=Birkenholzbretter
|
||||
options.downfall_distance=Wettereffekte
|
||||
options.downfall_distance.tooltip=Wettereffekte
|
||||
options.dynamic_fov=Dynamisches Sichtfeld
|
||||
options.dynamic_fov.tooltip=Wenn angeschaltet, ändert sich das Spielersichtfeld mit der Spielergeschwindigkeit
|
||||
options.fog_disable=Terrainnebel ausschalten
|
||||
options.fog_disable.tooltip=Terrainnebel ausschalten
|
||||
options.fog_near_distance=Nebelabstand
|
||||
options.fog_near_distance.tooltip=Nebelabstand
|
||||
options.mode_cloud_translucency=Wolkendurchlässigkeit
|
||||
options.mode_cloud_translucency.tooltip=Wolkendurchlässigkeit
|
||||
options.mode_cloud_translucency.-1=Standard
|
||||
options.mode_cloud_translucency.0=Immer
|
||||
options.mode_cloud_translucency.1=Niemals
|
||||
options.mode_clouds=Wolken
|
||||
options.mode_clouds.tooltip=Wolken
|
||||
options.mode_clouds.-1=Standard
|
||||
options.mode_clouds.0=Schön
|
||||
options.mode_clouds.1=Schnell
|
||||
options.mode_clouds.2=Aus
|
||||
options.mode_dropped_items=Herumliegende Items
|
||||
options.mode_dropped_items.tooltip=Grafikqualität von herumliegenden Items
|
||||
options.mode_glint_inv=Inventar-Verzauberungseffekt
|
||||
options.mode_glint_inv.tooltip=Inventar-Verzauberungseffekt
|
||||
options.mode_glint_world=Welt-Verzauberungseffekt
|
||||
options.mode_glint_world.tooltip=Welt-Verzauberungseffekt
|
||||
options.mode_gui_background=Menühintergründe
|
||||
options.mode_gui_background.tooltip=Menühintergründe
|
||||
options.mode_leaves=Laub
|
||||
options.mode_leaves.tooltip=Laub
|
||||
options.mode_leaves.-1=Standard
|
||||
options.mode_leaves.0=Schön
|
||||
options.mode_leaves.1=Schnell
|
||||
options.mode_leaves.2=Schlau
|
||||
options.mode_leaves.3=Schön [Hybrid]
|
||||
options.mode_leaves.4=Schnell [Hybrid]
|
||||
options.mode_light_flicker=Lichtflackern
|
||||
options.mode_light_flicker.tooltip=Lichtflackern
|
||||
options.mode_shadows=Objektschatten
|
||||
options.mode_shadows.tooltip=Objektschatten
|
||||
options.mode_shadows.-1=Standard
|
||||
options.mode_shadows.0=An
|
||||
options.mode_shadows.1=Aus
|
||||
options.mode_sky=Himmel
|
||||
options.mode_sky.tooltip=Himmel anzeigen
|
||||
options.mode_sun_moon=Sonne & Mond
|
||||
options.mode_sun_moon.tooltip=Sonne & Mond anzeigen
|
||||
options.mode_stars=Sterne
|
||||
options.mode_stars.tooltip=Sterne anzeigen
|
||||
options.mode_water=Wasser
|
||||
options.mode_water.tooltip=Wasser
|
||||
options.mode_vignette=Vignette
|
||||
options.mode_vignette.tooltip=Vignette
|
||||
options.mode_vignette.-1=Standard
|
||||
options.mode_vignette.0=An
|
||||
options.mode_vignette.1=Aus
|
||||
options.particles_enc_table=Verzauberungspartikel
|
||||
options.particles_enc_table.tooltip=Verzauberungspartikel
|
||||
options.particles_void=Leerenpartikel
|
||||
options.particles_void.tooltip=Leerenpartikel
|
||||
options.render_distance_clouds=Wolken-Renderdistanz
|
||||
options.render_distance_clouds.tooltip=Minimale Wolken-Renderdistanz
|
||||
options.title.detail=Detaileinstellungen
|
||||
options.title.other=Sonstige Einstellungen
|
||||
options.title.particle=Partikeleinstellungen
|
||||
options.title.sky=Atmosphäreneinstellungen
|
||||
options.title.video=Grafikeinstellungen
|
||||
options.total_stars=Sternendichte
|
||||
options.total_stars.tooltip=Sternendichte
|
||||
options.void_fog=Leerennebel
|
||||
options.void_fog.tooltip=Leerennebel
|
||||
+8
-1
@@ -1,17 +1,24 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.EntityRendererAccessor;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public abstract class MixinEntityRenderer {
|
||||
public abstract class MixinEntityRenderer implements EntityRendererAccessor {
|
||||
|
||||
@Invoker
|
||||
public abstract float invokeGetNightVisionBrightness(EntityPlayer entityPlayer, float partialTicks);
|
||||
|
||||
@Inject(method = "setupCameraTransform", at = @At(value = "TAIL"))
|
||||
private void angelica$captureCameraMatrix(float partialTicks, int startTime, CallbackInfo ci) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
+44
-2
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.fontrenderer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.util.font.IFontParameters;
|
||||
import com.gtnewhorizons.angelica.client.font.BatchingFontRenderer;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
@@ -16,6 +17,8 @@ import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -24,7 +27,7 @@ import java.util.Random;
|
||||
* @author eigenraven
|
||||
*/
|
||||
@Mixin(FontRenderer.class)
|
||||
public abstract class MixinFontRenderer implements FontRendererAccessor {
|
||||
public abstract class MixinFontRenderer implements FontRendererAccessor, IFontParameters {
|
||||
|
||||
@Shadow
|
||||
private boolean randomStyle;
|
||||
@@ -117,7 +120,7 @@ public abstract class MixinFontRenderer implements FontRendererAccessor {
|
||||
@Inject(method = "<init>", at = @At("TAIL"))
|
||||
private void angelica$injectBatcher(GameSettings settings, ResourceLocation fontLocation, TextureManager texManager,
|
||||
boolean unicodeMode, CallbackInfo ci) {
|
||||
angelica$batcher = new BatchingFontRenderer((FontRenderer) (Object) this, unicodePageLocations, this.charWidth, this.glyphWidth, this.colorCode, this.locationFontTexture);
|
||||
angelica$batcher = new BatchingFontRenderer((FontRenderer) (Object) this, this.charWidth, this.glyphWidth, this.colorCode, this.locationFontTexture);
|
||||
}
|
||||
|
||||
@Unique
|
||||
@@ -185,4 +188,43 @@ public abstract class MixinFontRenderer implements FontRendererAccessor {
|
||||
@Override
|
||||
public void angelica$bindTexture(ResourceLocation location) { this.bindTexture(location); }
|
||||
|
||||
@ModifyConstant(method = "getCharWidth", constant = @Constant(intValue = 7))
|
||||
private int angelica$maxCharWidth(int original) {
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Inject(method = "getCharWidth", at = @At("HEAD"), cancellable = true)
|
||||
public void getCharWidth(char c, CallbackInfoReturnable<Integer> cir) {
|
||||
cir.setReturnValue((int) angelica$getBatcher().getCharWidthFine(c));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphScaleX() {
|
||||
return angelica$getBatcher().getGlyphScaleX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphScaleY() {
|
||||
return angelica$getBatcher().getGlyphScaleY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getGlyphSpacing() {
|
||||
return angelica$getBatcher().getGlyphSpacing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWhitespaceScale() {
|
||||
return angelica$getBatcher().getWhitespaceScale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getShadowOffset() {
|
||||
return angelica$getBatcher().getShadowOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getCharWidthFine(char chr) {
|
||||
return angelica$getBatcher().getCharWidthFine(chr);
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.fontrenderer;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ResourceAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MixinMCResourceAccessor implements ResourceAccessor {
|
||||
@Shadow
|
||||
private List defaultResourcePacks;
|
||||
|
||||
@Override
|
||||
public List angelica$getDefaultResourcePacks() {
|
||||
return defaultResourcePacks;
|
||||
}
|
||||
}
|
||||
+13
-18
@@ -25,36 +25,31 @@
|
||||
|
||||
package com.gtnewhorizons.angelica.mixins.early.angelica.itemrenderer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.rendering.ItemRenderListManager;
|
||||
import lombok.SneakyThrows;
|
||||
import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.Slice;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
@Mixin(ItemRenderer.class)
|
||||
public abstract class MixinItemRenderer {
|
||||
@SneakyThrows
|
||||
@Inject(method = "renderItemIn2D",
|
||||
at = @At("HEAD"),
|
||||
cancellable = true,
|
||||
require = 1)
|
||||
private static void leFunnyRenderListStart(Tessellator tess, float a, float b, float c, float d, int e, int f, float g, CallbackInfo ci) {
|
||||
if (ItemRenderListManager.INSTANCE.pre(a, b, c, d, e, f, g)) {
|
||||
ci.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "renderItemIn2D",
|
||||
at = @At("RETURN"),
|
||||
require = 1)
|
||||
private static void leFunnyRenderListEnd(Tessellator tess, float a, float b, float c, float d, int e, int f, float g, CallbackInfo ci) {
|
||||
ItemRenderListManager.INSTANCE.post();
|
||||
@WrapMethod(method = "renderItemIn2D")
|
||||
private static void angelica$cacheItem(Tessellator tessellator, float minU, float minV, float maxU, float maxV, int widthSubdivisions, int heightSubdivisions, float thickness, Operation<Void> original) {
|
||||
final VertexBuffer vbo = ItemRenderListManager.pre(minU, minV, maxU, maxV, widthSubdivisions, heightSubdivisions, thickness);
|
||||
if (vbo != null) {
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
original.call(tess, minU, minV, maxU, maxV, widthSubdivisions, heightSubdivisions, thickness);
|
||||
ItemRenderListManager.post(tess, vbo);
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "renderItemIn2D",
|
||||
|
||||
+13
@@ -3,10 +3,13 @@ package com.gtnewhorizons.angelica.mixins.early.angelica.zoom;
|
||||
import com.gtnewhorizons.angelica.zoom.Zoom;
|
||||
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(EntityRenderer.class)
|
||||
public class MixinEntityRenderer_Zoom {
|
||||
@@ -27,4 +30,14 @@ public class MixinEntityRenderer_Zoom {
|
||||
return original;
|
||||
}
|
||||
|
||||
@Redirect(
|
||||
method = { "updateRenderer", "updateCameraAndRender" },
|
||||
at = @At(
|
||||
opcode = Opcodes.GETFIELD,
|
||||
target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z",
|
||||
value = "FIELD"))
|
||||
private boolean angelica$checkZoomEnablement(GameSettings settings) {
|
||||
return settings.smoothCamera || Zoom.isZoomedIn();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
|
||||
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
|
||||
import com.llamalad7.mixinextras.sugar.Share;
|
||||
@@ -21,7 +22,6 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -55,6 +55,7 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
|
||||
pipeline.get().finalizeLevelRendering();
|
||||
pipeline.set(null);
|
||||
Program.unbind();
|
||||
GLStateManager.glDepthMask(true);
|
||||
}
|
||||
|
||||
@WrapOperation(method = "renderHand", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/ItemRenderer;renderItemInFirstPerson(F)V"))
|
||||
@@ -100,7 +101,7 @@ public abstract class MixinEntityRenderer implements IResourceManagerReloadListe
|
||||
private void iris$beginWeatherAndwriteRainAndSnowToDepthBuffer(float partialTicks, long startTime, CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
pipeline.get().setPhase(WorldRenderingPhase.RAIN_SNOW);
|
||||
if (pipeline.get().shouldWriteRainAndSnowToDepthBuffer()) {
|
||||
GL11.glDepthMask(true);
|
||||
GLStateManager.glDepthMask(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+24
-28
@@ -1,7 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.rendertarget.IRenderTargetExt;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
@@ -11,20 +10,22 @@ import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
@Mixin(Framebuffer.class)
|
||||
public abstract class MixinFramebuffer implements IRenderTargetExt {
|
||||
private int iris$depthBufferVersion;
|
||||
public class MixinFramebuffer implements IRenderTargetExt {
|
||||
|
||||
private int iris$colorBufferVersion;
|
||||
@Unique private int iris$depthBufferVersion;
|
||||
|
||||
@Getter public boolean iris$useDepth;
|
||||
@Getter public int iris$depthTextureId = -1;
|
||||
@Unique private int iris$colorBufferVersion;
|
||||
|
||||
@Unique public int iris$depthTextureId = -1;
|
||||
|
||||
@Shadow public boolean useDepth;
|
||||
|
||||
@@ -45,16 +46,12 @@ public abstract class MixinFramebuffer implements IRenderTargetExt {
|
||||
return iris$colorBufferVersion;
|
||||
}
|
||||
|
||||
// Use a depth texture instead of a depth drawScreen buffer
|
||||
@Inject(method="Lnet/minecraft/client/shader/Framebuffer;createBindFramebuffer(II)V", at=@At(value="HEAD"))
|
||||
private void iris$useDepthTexture(int width, int height, CallbackInfo ci) {
|
||||
if(this.useDepth) {
|
||||
this.useDepth = false;
|
||||
this.iris$useDepth = true;
|
||||
}
|
||||
@Override
|
||||
public int iris$getDepthTextureId() {
|
||||
return iris$depthTextureId;
|
||||
}
|
||||
|
||||
@Inject(method="deleteFramebuffer()V", at=@At(value="FIELD", target="Lnet/minecraft/client/shader/Framebuffer;depthBuffer:I", shift = At.Shift.BEFORE, ordinal = 0))
|
||||
@Inject(method="deleteFramebuffer()V", at=@At(value="FIELD", target="Lnet/minecraft/client/shader/Framebuffer;depthBuffer:I", shift = At.Shift.BEFORE, ordinal = 0), require = 1)
|
||||
private void iris$deleteDepthBuffer(CallbackInfo ci) {
|
||||
if(this.iris$depthTextureId > -1 ) {
|
||||
GLStateManager.glDeleteTextures(this.iris$depthTextureId);
|
||||
@@ -62,19 +59,17 @@ public abstract class MixinFramebuffer implements IRenderTargetExt {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method="createFramebuffer(II)V", at=@At(value="FIELD", target="Lnet/minecraft/client/shader/Framebuffer;useDepth:Z", shift=At.Shift.BEFORE, ordinal = 0))
|
||||
private void iris$createDepthTextureID(int width, int height, CallbackInfo ci) {
|
||||
if (this.iris$useDepth) {
|
||||
this.iris$depthTextureId = GL11.glGenTextures();
|
||||
}
|
||||
// Prevent the creation of a depth buffer, it will get replaced by a depth texture.
|
||||
@Redirect(method = "createFramebuffer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/shader/Framebuffer;useDepth:Z"))
|
||||
private boolean iris$noopDepthBuffer(Framebuffer instance) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Inject(method="createFramebuffer(II)V", at=@At(value="FIELD", target="Lnet/minecraft/client/shader/Framebuffer;useDepth:Z", shift=At.Shift.BEFORE, ordinal = 1))
|
||||
// Uses a depth texture instead of a depth buffer
|
||||
@Inject(method = "createFramebuffer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/shader/Framebuffer;framebufferClear()V", shift = At.Shift.BEFORE, ordinal = 1), require = 1)
|
||||
private void iris$createDepthTexture(int width, int height, CallbackInfo ci) {
|
||||
if(this.iris$useDepth) {
|
||||
if(this.iris$depthTextureId == -1) {
|
||||
this.iris$depthTextureId = GL11.glGenTextures();
|
||||
}
|
||||
if(this.useDepth) {
|
||||
this.iris$depthTextureId = GL11.glGenTextures();
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, this.iris$depthTextureId);
|
||||
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
|
||||
@@ -82,14 +77,15 @@ public abstract class MixinFramebuffer implements IRenderTargetExt {
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_COMPARE_MODE, 0);
|
||||
if (MinecraftForgeClient.getStencilBits() != 0) {
|
||||
final boolean stencil = MinecraftForgeClient.getStencilBits() != 0;
|
||||
if (stencil) {
|
||||
GLStateManager.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL30.GL_DEPTH24_STENCIL8, width, height, 0, GL30.GL_DEPTH_STENCIL, GL30.GL_UNSIGNED_INT_24_8, (IntBuffer) null);
|
||||
} else {
|
||||
GLStateManager.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, width, height, 0, GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (IntBuffer) null);
|
||||
}
|
||||
OpenGlHelper.func_153188_a/*glFramebufferTexture2D*/(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, this.iris$depthTextureId, 0);
|
||||
if (MinecraftForgeClient.getStencilBits() != 0) {
|
||||
OpenGlHelper.func_153188_a/*glFramebufferTexture2D*/(GL30.GL_FRAMEBUFFER, GL30.GL_STENCIL_ATTACHMENT, GL11.GL_TEXTURE_2D, this.iris$depthTextureId, 0);
|
||||
OpenGlHelper.func_153188_a(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, this.iris$depthTextureId, 0);
|
||||
if (stencil) {
|
||||
OpenGlHelper.func_153188_a(GL30.GL_FRAMEBUFFER, GL30.GL_STENCIL_ATTACHMENT, GL11.GL_TEXTURE_2D, this.iris$depthTextureId, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 106 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user