mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-20 12:29:40 +00:00
Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31abbcce32 | ||
|
|
063b2242e8 | ||
|
|
577f905dc5 | ||
|
|
071d2d4a39 | ||
|
|
891715b113 | ||
|
|
30a35ef25e | ||
|
|
33453b3b8c | ||
|
|
62e699f6d0 | ||
|
|
f107d173b7 | ||
|
|
d0948b36f3 | ||
|
|
ae1211f280 | ||
|
|
3d76cb3073 | ||
|
|
45fb120223 | ||
|
|
d7a196eb5c | ||
|
|
4d53e2af9b | ||
|
|
cb6336a365 | ||
|
|
5095021e0e | ||
|
|
f88ecbf68d | ||
|
|
7da9b9eb1c | ||
|
|
02c394108f | ||
|
|
720aaca1b7 | ||
|
|
1e71b1c4d8 | ||
|
|
df4c423e93 | ||
|
|
78e0074e5a | ||
|
|
0350ea2cb6 | ||
|
|
bed724ba59 | ||
|
|
6fa973dbc8 | ||
|
|
c4ad460f34 |
No files matched your search
@@ -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.6
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.6.20
|
||||
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
@@ -29,13 +29,14 @@
|
||||
* 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)
|
||||
|
||||
# Permanent Incompatibilities
|
||||
* OptiFine [Disabled, won't fix]
|
||||
* FastCraft [Disabled, won't fix]
|
||||
* BetterFPS [Disabled, won't fix]
|
||||
* OptimizationsAndTweaks [Disabled, won't fix]
|
||||
* [Amazing Trophies 1.2.1 and below](https://github.com/GTNewHorizons/Amazing-Trophies/releases) - use 1.2.2+
|
||||
* [Amazing Trophies 1.2.1 and below](https://github.com/GTNewHorizons/Amazing-Trophies/releases) - Use 1.2.2+
|
||||
* [LWJGL3ify 1.5.4 and below](https://github.com/GTNewHorizons/lwjgl3ify/releases/) - Use the latest version available, 1.5.7+
|
||||
* [ArchaicFix 0.6.2 and below](https://www.curseforge.com/minecraft/mc-mods/archaicfix/files/all?page=1&pageSize=20) - Use 0.7.0 or above
|
||||
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 0.4.5 or above
|
||||
@@ -64,7 +65,7 @@
|
||||
* Makamys for [Neodymium](https://github.com/makamys/Neodymium) - Various Tessellator -> Quad functionality taken under the LGPL 3
|
||||
* MCPatcherForge
|
||||
* Original [MCPatcher](https://bitbucket.org/prupe/mcpatcher/src/master/): Paul Rupe
|
||||
* [Forge version](https://bitbucket.org/prupe/mcpatcher/src/master/): Mist475 under LGPL 3.0 with default ctm textures for glass and bookshelves by DarkBum under CC-BY-SA
|
||||
* [Forge version](https://github.com/mist475/MCPatcherForge): Mist475 under LGPL 3.0 with default ctm textures for glass and bookshelves by DarkBum under CC-BY-SA
|
||||
* HUDCaching
|
||||
* Created by [Moulberry](https://github.com/Moulberry/MCHUDCaching), backported from [Patcher](https://github.com/Sk1erLLC/Patcher) mod by Alexdoru under the CC-BY-SA-NC 4.0 license
|
||||
* Angelica
|
||||
|
||||
+15
-15
@@ -49,7 +49,7 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.27")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.91")
|
||||
|
||||
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.0: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.11:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.37: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,21 +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.64-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.3:dev')
|
||||
|
||||
// Notfine Deps
|
||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.5:dev") { transitive = false }
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles-Expanded:2.1.9-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.8:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.9-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.2:dev")
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.40-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.8:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.1:dev")
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.5:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.2:dev") { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:Backhand:1.6.11') { 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 }
|
||||
@@ -94,13 +93,12 @@ 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"))
|
||||
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:HoloInventory:2.5.0-GTNH:dev")
|
||||
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
|
||||
|
||||
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
|
||||
|
||||
@@ -115,4 +113,6 @@ dependencies {
|
||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||
testImplementation("org.mockito:mockito-core:3.+")
|
||||
testImplementation("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
|
||||
|
||||
compileOnly("mega:fluidlogged-mc1.7.10:0.1.2")
|
||||
}
|
||||
+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.
|
||||
|
||||
Vendored
BIN
Binary file not shown.
@@ -205,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
@@ -8,6 +8,13 @@ repositories {
|
||||
includeGroup 'com.falsepattern'
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = 'mega'
|
||||
url = 'https://mvn.falsepattern.com/gtmega_releases/'
|
||||
content {
|
||||
includeGroup 'mega'
|
||||
}
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
ivy {
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.36'
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,8 +15,13 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
modid = "angelica",
|
||||
name = "Angelica",
|
||||
version = Tags.VERSION,
|
||||
dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);"
|
||||
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.6.6,);",
|
||||
dependencies = """
|
||||
required-after:gtnhlib@[0.6.6,);\
|
||||
before:lwjgl3ify@[1.5.3,);\
|
||||
after:hodgepodge@[2.4.4,);\
|
||||
after:CodeChickenCore@[1.2.0,);\
|
||||
after:archaicfix@[0.7.0,);\
|
||||
""",
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
|
||||
|
||||
@@ -7,8 +7,9 @@ import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import jss.util.RandomXoshiro256StarStar;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -150,7 +151,7 @@ public class BatchingFontRenderer {
|
||||
return idx;
|
||||
}
|
||||
|
||||
private void pushDrawCmd(int startIdx, int idxCount, ResourceLocation texture) {
|
||||
private void pushDrawCmd(int startIdx, int idxCount, ResourceLocation texture, boolean isUnicode) {
|
||||
if (!batchCommands.isEmpty()) {
|
||||
final FontDrawCmd lastCmd = batchCommands.get(batchCommands.size() - 1);
|
||||
final int prevEndVtx = lastCmd.startVtx + lastCmd.idxCount;
|
||||
@@ -166,7 +167,7 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
}
|
||||
final FontDrawCmd cmd = batchCommandPool.pop();
|
||||
cmd.reset(startIdx, idxCount, texture);
|
||||
cmd.reset(startIdx, idxCount, texture, isUnicode);
|
||||
batchCommands.add(cmd);
|
||||
}
|
||||
|
||||
@@ -174,12 +175,14 @@ public class BatchingFontRenderer {
|
||||
|
||||
public int startVtx;
|
||||
public int idxCount;
|
||||
public boolean isUnicode;
|
||||
public ResourceLocation texture;
|
||||
|
||||
public void reset(int startVtx, int vtxCount, ResourceLocation texture) {
|
||||
public void reset(int startVtx, int vtxCount, ResourceLocation texture, boolean isUnicode) {
|
||||
this.startVtx = startVtx;
|
||||
this.idxCount = vtxCount;
|
||||
this.texture = texture;
|
||||
this.isUnicode = isUnicode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -280,7 +283,21 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
@@ -367,7 +384,7 @@ public class BatchingFontRenderer {
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
underlineStartX = underlineEndX;
|
||||
}
|
||||
if (curStrikethrough && strikethroughStartX != strikethroughEndX) {
|
||||
@@ -378,7 +395,7 @@ public class BatchingFontRenderer {
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
strikethroughStartX = strikethroughEndX;
|
||||
}
|
||||
|
||||
@@ -462,13 +479,13 @@ public class BatchingFontRenderer {
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
uStart = ((float) (chr % 16 * 16) + startColumnF) / 256.0f;
|
||||
vStart = ((float) ((chr & 255) / 16 * 16)) / 256.0f;
|
||||
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 / 256.0f;
|
||||
vSz = 15.98f / 256.0f;
|
||||
uSz = (chrWidth - 0.42f) / 256.0f;
|
||||
vSz = (16.0f - 0.42f) / 256.0f;
|
||||
|
||||
} else {
|
||||
// Draw "ASCII" char
|
||||
@@ -556,7 +573,7 @@ public class BatchingFontRenderer {
|
||||
vtxCount += 4;
|
||||
}
|
||||
|
||||
pushDrawCmd(idxId, vtxCount / 2 * 3, texture);
|
||||
pushDrawCmd(idxId, vtxCount / 2 * 3, texture, chr > 255);
|
||||
curX += xAdvance + (curBold ? shadowOffset : 0.0f);
|
||||
underlineEndX = curX;
|
||||
strikethroughEndX = curX;
|
||||
@@ -565,7 +582,7 @@ public class BatchingFontRenderer {
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
}
|
||||
if (curStrikethrough && strikethroughStartX != strikethroughEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
@@ -575,7 +592,7 @@ public class BatchingFontRenderer {
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
pushDrawCmd(ulIdx, 6, null, false);
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.backhand.BackhandReflectionCompat;
|
||||
import com.gtnewhorizons.angelica.helpers.LoadControllerHelper;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import mods.battlegear2.Battlegear;
|
||||
import net.dries007.holoInventory.HoloInventory;
|
||||
import xonin.backhand.Backhand;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ModStatus {
|
||||
public static final Logger LOGGER = LogManager.getLogger("ModCompat");
|
||||
|
||||
public static BackhandReflectionCompat backhandCompat;
|
||||
/**
|
||||
* Mixin Version
|
||||
*/
|
||||
@@ -16,7 +20,6 @@ public class ModStatus {
|
||||
* ASM Version
|
||||
*/
|
||||
public static boolean isOldNEIDLoaded;
|
||||
|
||||
public static boolean isBetterCrashesLoaded;
|
||||
public static boolean isNEIDMetadataExtended;
|
||||
public static boolean isLotrLoaded;
|
||||
@@ -29,8 +32,14 @@ public class ModStatus {
|
||||
public static boolean isThaumcraftLoaded;
|
||||
public static boolean isThaumicHorizonsLoaded;
|
||||
public static boolean isBaublesLoaded;
|
||||
public static boolean isFluidLoggedLoaded;
|
||||
|
||||
public static void preInit(){
|
||||
isBackhandLoaded = Loader.isModLoaded("backhand");
|
||||
if(isBackhandLoaded) {
|
||||
isBackhandLoaded = BackhandReflectionCompat.isBackhandLoaded();
|
||||
}
|
||||
|
||||
isBetterCrashesLoaded = Loader.isModLoaded("bettercrashes");
|
||||
isNEIDLoaded = Loader.isModLoaded("neid");
|
||||
isOldNEIDLoaded = Loader.isModLoaded("notenoughIDs");
|
||||
@@ -40,17 +49,12 @@ public class ModStatus {
|
||||
isXaerosMinimapLoaded = Loader.isModLoaded("XaeroMinimap");
|
||||
isHoloInventoryLoaded = Loader.isModLoaded("holoinventory");
|
||||
isBattlegearLoaded = Loader.isModLoaded("battlegear2");
|
||||
isBackhandLoaded = Loader.isModLoaded("backhand");
|
||||
isThaumcraftLoaded = Loader.isModLoaded("Thaumcraft");
|
||||
isThaumicHorizonsLoaded = Loader.isModLoaded("ThaumicHorizons");
|
||||
isBaublesLoaded = Loader.isModLoaded("Baubles");
|
||||
isFluidLoggedLoaded = Loader.isModLoaded("fluidlogged");
|
||||
|
||||
if (isHoloInventoryLoaded){
|
||||
isHoloInventoryLoaded = new DefaultArtifactVersion("2.4.4-GTNH")
|
||||
.compareTo(
|
||||
LoadControllerHelper.getOwningMod(HoloInventory.class).getProcessedVersion()
|
||||
) <= 0;
|
||||
}
|
||||
isHoloInventoryLoaded = Loader.isModLoaded("holoinventory");
|
||||
|
||||
// remove compat with original release of BG2
|
||||
if (isBattlegearLoaded){
|
||||
@@ -60,17 +64,9 @@ public class ModStatus {
|
||||
) <= 0;
|
||||
}
|
||||
|
||||
if (isBackhandLoaded){
|
||||
isBackhandLoaded = new DefaultArtifactVersion("1.6.9")
|
||||
.compareTo(
|
||||
LoadControllerHelper.getOwningMod(Backhand.class).getProcessedVersion()
|
||||
) <= 0;
|
||||
}
|
||||
|
||||
|
||||
isNEIDMetadataExtended = false;
|
||||
if (isNEIDLoaded) {
|
||||
int majorVersion = Integer.parseInt(Loader.instance().getIndexedModList().get("neid").getVersion().split("\\.")[0]);
|
||||
final int majorVersion = Integer.parseInt(Loader.instance().getIndexedModList().get("neid").getVersion().split("\\.")[0]);
|
||||
if (majorVersion >= 2) {
|
||||
isNEIDMetadataExtended = true;
|
||||
}
|
||||
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
package com.gtnewhorizons.angelica.compat.backhand;
|
||||
|
||||
import com.gtnewhorizons.angelica.helpers.LoadControllerHelper;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
|
||||
import static com.gtnewhorizons.angelica.compat.ModStatus.LOGGER;
|
||||
|
||||
public class BackhandReflectionCompat {
|
||||
private static final String BACKHAND_CLASS = "xonin.backhand.Backhand";
|
||||
private static final String ITEM_RENDERER_HOOKS_CLASS = "xonin.backhand.client.hooks.ItemRendererHooks";
|
||||
private static final String BACKHAND_UTILS_CLASS = "xonin.backhand.api.core.BackhandUtils";
|
||||
|
||||
private static boolean isLoaded;
|
||||
private static final MethodHandle renderOffhandReturn;
|
||||
private static final MethodHandle getOffhandItem;
|
||||
|
||||
static {
|
||||
MethodHandle renderOffhandReturnTemp = null;
|
||||
MethodHandle getOffhandItemTemp = null;
|
||||
|
||||
try {
|
||||
final Class<?> backhandClass = ReflectionHelper.getClass(BackhandReflectionCompat.class.getClassLoader(), BACKHAND_CLASS);
|
||||
final boolean versionCheck = new DefaultArtifactVersion("1.6.9").compareTo(LoadControllerHelper.getOwningMod(backhandClass).getProcessedVersion()) <= 0;
|
||||
|
||||
if (versionCheck) {
|
||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
final Class<?> itemRendererHooksClass = ReflectionHelper.getClass(BackhandReflectionCompat.class.getClassLoader(), ITEM_RENDERER_HOOKS_CLASS);
|
||||
final Class<?> backhandUtilsClass = ReflectionHelper.getClass(BackhandReflectionCompat.class.getClassLoader(), BACKHAND_UTILS_CLASS);
|
||||
|
||||
renderOffhandReturnTemp = lookup.findStatic(itemRendererHooksClass, "renderOffhandReturn", MethodType.methodType(void.class, float.class));
|
||||
getOffhandItemTemp = lookup.findStatic(backhandUtilsClass, "getOffhandItem", MethodType.methodType(ItemStack.class, EntityPlayer.class));
|
||||
isLoaded = true;
|
||||
LOGGER.info("Backhand compat loaded");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Failed to load Backhand compat", e);
|
||||
isLoaded = false;
|
||||
}
|
||||
|
||||
renderOffhandReturn = renderOffhandReturnTemp;
|
||||
getOffhandItem = getOffhandItemTemp;
|
||||
}
|
||||
|
||||
public static boolean isBackhandLoaded() {
|
||||
return isLoaded;
|
||||
}
|
||||
|
||||
public static void renderOffhand(float partialTicks) {
|
||||
if (isLoaded && renderOffhandReturn != null) {
|
||||
try {
|
||||
renderOffhandReturn.invokeExact(partialTicks);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to invoke Backhand renderOffhandReturn", e);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getOffhandItem(EntityPlayer player) {
|
||||
if (isLoaded && getOffhandItem != null) {
|
||||
try {
|
||||
return (ItemStack) getOffhandItem.invokeExact(player);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to invoke Backhand getOffhandItem", e);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.gtnewhorizons.angelica.compat.battlegear2;
|
||||
|
||||
import mods.battlegear2.api.core.IInventoryPlayerBattle;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
/**
|
||||
* This class exists to isolate classes that exist in Battlegear 2 but not
|
||||
* in Battlegear 2 for Backhand in order to avoid class loading exceptions.
|
||||
*/
|
||||
public class Battlegear2Compat {
|
||||
public static ItemStack getBattlegear2Offhand(EntityPlayer player) {
|
||||
return ((IInventoryPlayerBattle) player.inventory).battlegear2$getCurrentOffhandWeapon();
|
||||
}
|
||||
}
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
package com.gtnewhorizons.angelica.compat.holoinventory;
|
||||
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import static com.gtnewhorizons.angelica.compat.ModStatus.LOGGER;
|
||||
|
||||
public class HoloInventoryReflectionCompat {
|
||||
private static final String RENDERER_CLASS = "net.dries007.holoInventory.client.Renderer";
|
||||
|
||||
private static boolean isLoaded;
|
||||
private static final MethodHandle renderEventPostMethod;
|
||||
private static final MethodHandle renderEventMethod;
|
||||
private static final MethodHandle angelicaOverrideSetter;
|
||||
|
||||
static {
|
||||
MethodHandle renderEventPostMethodTemp = null;
|
||||
MethodHandle renderEventMethodTemp = null;
|
||||
MethodHandle angelicaOverrideSetterTemp = null;
|
||||
final Object rendererInstance;
|
||||
final Class<?> rendererClass;
|
||||
|
||||
try {
|
||||
rendererClass = Class.forName(RENDERER_CLASS);
|
||||
|
||||
// Get and cache the Renderer.INSTANCE
|
||||
final Field instanceField = rendererClass.getDeclaredField("INSTANCE");
|
||||
instanceField.setAccessible(true);
|
||||
rendererInstance = instanceField.get(null);
|
||||
|
||||
final MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||
try {
|
||||
renderEventPostMethodTemp = lookup.findVirtual(rendererClass, "renderEvent", MethodType.methodType(void.class, RenderGameOverlayEvent.Post.class));
|
||||
} catch (NoSuchMethodException e) {
|
||||
// Fallback for 2.5.0-GTNH and earlier
|
||||
renderEventMethodTemp = lookup.findVirtual(rendererClass, "renderEvent", MethodType.methodType(void.class, RenderGameOverlayEvent.class));
|
||||
}
|
||||
|
||||
final Field angelicaOverrideField = rendererClass.getDeclaredField("angelicaOverride");
|
||||
angelicaOverrideField.setAccessible(true);
|
||||
angelicaOverrideSetterTemp = lookup.unreflectSetter(angelicaOverrideField);
|
||||
|
||||
// Bind the method handles to the instance
|
||||
if (rendererInstance != null) {
|
||||
if (renderEventPostMethodTemp != null) {
|
||||
renderEventPostMethodTemp = renderEventPostMethodTemp.bindTo(rendererInstance);
|
||||
}
|
||||
if (renderEventMethodTemp != null) {
|
||||
renderEventMethodTemp = renderEventMethodTemp.bindTo(rendererInstance);
|
||||
}
|
||||
angelicaOverrideSetterTemp = angelicaOverrideSetterTemp.bindTo(rendererInstance);
|
||||
}
|
||||
|
||||
isLoaded = true;
|
||||
LOGGER.info("Successfully initialized HoloInventory compatibility layer");
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Failed to initialize HoloInventory compatibility layer", e);
|
||||
isLoaded = false;
|
||||
}
|
||||
|
||||
renderEventPostMethod = renderEventPostMethodTemp;
|
||||
renderEventMethod = renderEventMethodTemp;
|
||||
angelicaOverrideSetter = angelicaOverrideSetterTemp;
|
||||
}
|
||||
|
||||
public static void renderEvent(RenderGameOverlayEvent event) {
|
||||
if (!isLoaded) return;
|
||||
try {
|
||||
if (event instanceof RenderGameOverlayEvent.Post && renderEventPostMethod != null) {
|
||||
renderEventPostMethod.invokeExact((RenderGameOverlayEvent.Post) event);
|
||||
} else {
|
||||
renderEventMethod.invokeExact(event);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to invoke HoloInventory renderEvent", e);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setAngelicaOverride(boolean value) {
|
||||
if (!isLoaded) return;
|
||||
try {
|
||||
angelicaOverrideSetter.invokeExact(value);
|
||||
} catch (Throwable e) {
|
||||
LOGGER.error("Failed to set HoloInventory angelicaOverride", e);
|
||||
isLoaded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ package com.gtnewhorizons.angelica.compat.mojang;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import xonin.backhand.api.core.BackhandUtils;
|
||||
|
||||
public enum InteractionHand {
|
||||
MAIN_HAND,
|
||||
@@ -15,7 +14,7 @@ public enum InteractionHand {
|
||||
|
||||
public ItemStack getItemInHand(EntityPlayer player){
|
||||
if (ModStatus.isBackhandLoaded && this == InteractionHand.OFF_HAND){ // off hand (requires backhand)
|
||||
return BackhandUtils.getOffhandItem(player);
|
||||
return ModStatus.backhandCompat.getOffhandItem(player);
|
||||
}
|
||||
else { // main hand
|
||||
return player.getHeldItem();
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AngelicaConfig {
|
||||
public static boolean enableIris;
|
||||
|
||||
@Config.Comment("Enable MCPatcherForge features, still in Alpha. Individual features are toggled in mcpatcher.json")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableMCPatcherForgeFeatures;
|
||||
|
||||
|
||||
@@ -39,4 +39,9 @@ public class CompatConfig {
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixImmersiveEngineering;
|
||||
|
||||
@Config.Comment("Apply fixes to Security Craft")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixSecurityCraft;
|
||||
}
|
||||
@@ -6,12 +6,12 @@ import com.gtnewhorizon.gtnhlib.blockpos.IBlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
|
||||
import com.gtnewhorizons.angelica.api.IDynamicLightProducer;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.battlegear2.Battlegear2Compat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import mods.battlegear2.api.core.IBattlePlayer;
|
||||
import mods.battlegear2.api.core.IInventoryPlayerBattle;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xonin.backhand.api.core.BackhandUtils;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
@@ -377,13 +376,13 @@ public class DynamicLights {
|
||||
player instanceof IBattlePlayer battlePlayer &&
|
||||
battlePlayer.battlegear2$isBattlemode()
|
||||
) {
|
||||
ItemStack offhand = ((IInventoryPlayerBattle) player.inventory).battlegear2$getCurrentOffhandWeapon();
|
||||
ItemStack offhand = Battlegear2Compat.getBattlegear2Offhand(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
|
||||
}
|
||||
}
|
||||
else if (ModStatus.isBackhandLoaded && living instanceof EntityPlayer player){
|
||||
ItemStack offhand = BackhandUtils.getOffhandItem(player);
|
||||
ItemStack offhand = ModStatus.backhandCompat.getOffhandItem(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
|
||||
}
|
||||
|
||||
@@ -863,6 +863,16 @@ public class GLStateManager {
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
}
|
||||
|
||||
public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, FloatBuffer pixels) {
|
||||
TextureInfoCache.INSTANCE.onTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
}
|
||||
|
||||
public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, DoubleBuffer pixels) {
|
||||
TextureInfoCache.INSTANCE.onTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
}
|
||||
|
||||
public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer pixels) {
|
||||
TextureInfoCache.INSTANCE.onTexImage2D(target, level, internalformat, width, height, border, format, type, pixels != null ? pixels.asIntBuffer() : (IntBuffer) null);
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
|
||||
@@ -97,6 +97,8 @@ public class RenderSystem {
|
||||
GL20.glUniform3f(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
public static void uniform3i(int location, int v0, int v1, int v2) { GL20.glUniform3i(location, v0, v1, v2); }
|
||||
|
||||
public static void uniform4f(int location, float v0, float v1, float v2, float v3) {
|
||||
GL20.glUniform4f(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.Buffer;
|
||||
|
||||
public class TextureInfoCache {
|
||||
/**
|
||||
@@ -25,7 +25,7 @@ public class TextureInfoCache {
|
||||
return cache.computeIfAbsent(id, TextureInfo::new);
|
||||
}
|
||||
|
||||
public void onTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable IntBuffer pixels) {
|
||||
public void onTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable Buffer pixels) {
|
||||
if (target == GL11.GL_TEXTURE_2D && level == 0) {
|
||||
final TextureInfo info = getInfo(GLStateManager.getBoundTexture());
|
||||
if(info == null) return;
|
||||
|
||||
@@ -2,13 +2,13 @@ package com.gtnewhorizons.angelica.hudcaching;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.holoinventory.HoloInventoryReflectionCompat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.GuiIngameAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.GuiIngameForgeAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.RenderGameOverlayEventAccessor;
|
||||
import com.kentington.thaumichorizons.common.ThaumicHorizons;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import net.dries007.holoInventory.client.Renderer;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -60,7 +60,6 @@ public class HUDCaching {
|
||||
|
||||
public static final HUDCaching INSTANCE = new HUDCaching();
|
||||
|
||||
|
||||
private HUDCaching() {}
|
||||
|
||||
// highest so it runs before the GLSM load event
|
||||
@@ -99,7 +98,7 @@ public class HUDCaching {
|
||||
renderingCacheOverride = false;
|
||||
mc.getFramebuffer().bindFramebuffer(false);
|
||||
} else {
|
||||
renderer.setupOverlayRendering();
|
||||
renderer.setupOverlayRendering();
|
||||
}
|
||||
|
||||
ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
@@ -112,52 +111,50 @@ public class HUDCaching {
|
||||
|
||||
// render bits that were captured when rendering into cache
|
||||
GuiIngameAccessor gui = (GuiIngameAccessor) ingame;
|
||||
if (renderVignetteCaptured)
|
||||
{
|
||||
if (renderVignetteCaptured) {
|
||||
gui.callRenderVignette(mc.thePlayer.getBrightness(partialTicks), width, height);
|
||||
} else {
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
}
|
||||
|
||||
if (ingame instanceof GuiIngameForge) {
|
||||
GuiIngameForgeAccessor guiForge = ((GuiIngameForgeAccessor) ingame);
|
||||
if (renderHelmetCaptured) {
|
||||
guiForge.callRenderHelmet(resolution, partialTicks, hasScreen, mouseX, mouseY);
|
||||
GuiIngameForgeAccessor guiForge = ((GuiIngameForgeAccessor) ingame);
|
||||
if (renderHelmetCaptured) {
|
||||
guiForge.callRenderHelmet(resolution, partialTicks, hasScreen, mouseX, mouseY);
|
||||
if (ModStatus.isHoloInventoryLoaded) {
|
||||
Renderer.INSTANCE.angelicaOverride = false;
|
||||
HoloInventoryReflectionCompat.setAngelicaOverride(false);
|
||||
// only settings the partial ticks as mouseX and mouseY are not used in renderEvent
|
||||
((RenderGameOverlayEventAccessor) fakePostEvent).setPartialTicks(partialTicks);
|
||||
Renderer.INSTANCE.renderEvent(fakePostEvent);
|
||||
HoloInventoryReflectionCompat.renderEvent(fakePostEvent);
|
||||
}
|
||||
}
|
||||
if (renderPortalCapturedTicks > 0) {
|
||||
guiForge.callRenderPortal(width, height, partialTicks);
|
||||
}
|
||||
if (renderCrosshairsCaptured) {
|
||||
if (ModStatus.isXaerosMinimapLoaded){
|
||||
}
|
||||
if (renderPortalCapturedTicks > 0) {
|
||||
guiForge.callRenderPortal(width, height, partialTicks);
|
||||
}
|
||||
if (renderCrosshairsCaptured) {
|
||||
if (ModStatus.isXaerosMinimapLoaded) {
|
||||
// this fixes the crosshair going invisible when no lines are being drawn under the minimap
|
||||
GLStateManager.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
guiForge.callRenderCrosshairs(width, height);
|
||||
}
|
||||
if (ModStatus.isThaumcraftLoaded || ModStatus.isThaumicHorizonsLoaded){
|
||||
guiForge.callRenderCrosshairs(width, height);
|
||||
}
|
||||
if (ModStatus.isThaumcraftLoaded || ModStatus.isThaumicHorizonsLoaded) {
|
||||
((RenderGameOverlayEventAccessor) fakeTextEvent).setPartialTicks(partialTicks);
|
||||
((RenderGameOverlayEventAccessor) fakeTextEvent).setResolution(resolution);
|
||||
((RenderGameOverlayEventAccessor) fakeTextEvent).setMouseX(mouseX);
|
||||
((RenderGameOverlayEventAccessor) fakeTextEvent).setMouseY(mouseY);
|
||||
if (ModStatus.isThaumcraftLoaded){
|
||||
if (ModStatus.isThaumcraftLoaded) {
|
||||
Thaumcraft.instance.renderEventHandler.renderOverlay(fakeTextEvent);
|
||||
}
|
||||
if (ModStatus.isThaumicHorizonsLoaded){
|
||||
if (ModStatus.isThaumicHorizonsLoaded) {
|
||||
ThaumicHorizons.instance.renderEventHandler.renderOverlay(fakeTextEvent);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (renderHelmetCaptured)
|
||||
{
|
||||
if (renderHelmetCaptured) {
|
||||
gui.callRenderPumpkinBlur(width, height);
|
||||
}
|
||||
if (renderPortalCapturedTicks > 0)
|
||||
{
|
||||
if (renderPortalCapturedTicks > 0) {
|
||||
gui.callRenderPortal(renderPortalCapturedTicks, width, height);
|
||||
}
|
||||
}
|
||||
@@ -180,19 +177,19 @@ public class HUDCaching {
|
||||
* the state before we start rendering
|
||||
*/
|
||||
public static void fixGLStateBeforeRenderingCache() {
|
||||
GLStateManager.glDepthMask(true);
|
||||
GLStateManager.enableDepthTest();
|
||||
GLStateManager.enableAlphaTest();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.glDepthMask(true);
|
||||
GLStateManager.enableDepthTest();
|
||||
GLStateManager.enableAlphaTest();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
GLStateManager.disableBlend();
|
||||
}
|
||||
|
||||
private static void resetFramebuffer(int width, int height) {
|
||||
if (framebuffer.framebufferWidth != width || framebuffer.framebufferHeight != height) {
|
||||
framebuffer.createBindFramebuffer(width, height);
|
||||
framebuffer.createBindFramebuffer(width, height);
|
||||
framebuffer.setFramebufferFilter(GL11.GL_NEAREST);
|
||||
} else {
|
||||
framebuffer.framebufferClear();
|
||||
framebuffer.framebufferClear();
|
||||
}
|
||||
// copy depth buffer from MC
|
||||
OpenGlHelper.func_153171_g(GL30.GL_READ_FRAMEBUFFER, mc.getFramebuffer().framebufferObject);
|
||||
@@ -214,10 +211,9 @@ public class HUDCaching {
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
|
||||
}
|
||||
|
||||
// moved to here due to the method being called from a mixin
|
||||
public static void disableHoloInventory() {
|
||||
if (ModStatus.isHoloInventoryLoaded) {
|
||||
Renderer.INSTANCE.angelicaOverride = true;
|
||||
HoloInventoryReflectionCompat.setAngelicaOverride(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@ 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.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;
|
||||
@@ -15,6 +16,7 @@ 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 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;
|
||||
@@ -95,7 +97,7 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
transformers.add(GenericCompatTransformer.class.getName());
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -131,7 +133,12 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedCoreMods) {
|
||||
return Mixins.getEarlyMixins(loadedCoreMods);
|
||||
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);
|
||||
}
|
||||
|
||||
public static boolean DUMP_CLASSES() {
|
||||
@@ -151,6 +158,4 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
ASMUtil.saveAsRawClassFile(transformedBytes, className + "_POST", transformer);
|
||||
}
|
||||
}
|
||||
|
||||
public static final Set<TargetedMod> coreMods = new HashSet<>();
|
||||
}
|
||||
@@ -1,216 +1,248 @@
|
||||
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_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_DISPLAY_LIST_OPTIMIZATION(new MixinBuilder("Optimized item rendering by wrapping them with display lists")
|
||||
.setPhase(Phase.EARLY)
|
||||
.addClientMixins("angelica.itemrenderer.MixinItemRenderer")
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering_WIP)),
|
||||
|
||||
// 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"
|
||||
,"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.MixinGuiMainMenu"
|
||||
,"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")
|
||||
IRIS_ACCESSORS(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins("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,43 +253,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")),
|
||||
|
||||
EXTRA_UTILITIES_THREAD_SAFETY(new Builder("Enable thread safety fixes in Extra Utilities").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.EXTRAUTILS).setSide(Side.CLIENT)
|
||||
SECURITYCRAFT_COMPAT(new MixinBuilder("Fix reflection in SecurityCraft for compat with Angelica")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.SECURITYCRAFT)
|
||||
.setApplyIf(() -> CompatConfig.fixSecurityCraft)
|
||||
.addClientMixins(
|
||||
"client.securitycraft.MixinBlockReinforcedFenceGate",
|
||||
"client.securitycraft.MixinBlockReinforcedIronBars"
|
||||
)),
|
||||
|
||||
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",
|
||||
@@ -289,11 +335,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",
|
||||
@@ -305,103 +350,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",
|
||||
@@ -453,11 +489,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",
|
||||
@@ -472,34 +507,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",
|
||||
@@ -512,220 +543,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,60 +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")
|
||||
, 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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ public class MCPatcherForgeConfig {
|
||||
@Config(modid = "mcpatcherforge", category = "custom_colors")
|
||||
public static class CustomColors {
|
||||
@Config.Comment("Enable the custom colors module")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enabled;
|
||||
|
||||
@@ -32,31 +32,31 @@ public class MCPatcherForgeConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static int fogBlendRadius;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean swampColors;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean water;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean tree;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean redstone;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean stem;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean otherBlocks;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean smoothBiomes;
|
||||
|
||||
@@ -64,43 +64,43 @@ public class MCPatcherForgeConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean testColorSmoothing;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean potion;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean particle;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fog;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean clouds;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean map;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean dye;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean text;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean xporb;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean egg;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean lightmaps;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class MCPatcherForgeConfig {
|
||||
@Config(modid = "mcpatcherforge", category = "custom_item_textures")
|
||||
public static class CustomItemTextures {
|
||||
@Config.Comment("Enable the custom item textures module")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enabled;
|
||||
|
||||
@@ -117,15 +117,15 @@ public class MCPatcherForgeConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static LogLevel logging;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean items;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enchantments;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean armor;
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public class MCPatcherForgeConfig {
|
||||
@Config(modid = "mcpatcherforge", category = "extended_hd")
|
||||
public static class ExtendedHD {
|
||||
@Config.Comment("Enable the extended hd module")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enabled;
|
||||
|
||||
@@ -186,27 +186,27 @@ public class MCPatcherForgeConfig {
|
||||
@Config.Name("lod bias")
|
||||
public static int lodBias;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean animations;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fancyCompass;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fancyClock;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean useGL13;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean useScratchTexture;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
@Config.Name("HDFont")
|
||||
public static boolean hdFont;
|
||||
@@ -223,7 +223,7 @@ public class MCPatcherForgeConfig {
|
||||
@Config(modid = "mcpatcherforge", category = "random_mobs")
|
||||
public static class RandomMobs {
|
||||
@Config.Comment("Enable the random mobs module")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enabled;
|
||||
|
||||
@@ -232,7 +232,7 @@ public class MCPatcherForgeConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static LogLevel logging;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean leashLine;
|
||||
}
|
||||
@@ -240,7 +240,7 @@ public class MCPatcherForgeConfig {
|
||||
@Config(modid = "mcpatcherforge", category = "better_skies")
|
||||
public static class BetterSkies {
|
||||
@Config.Comment("Enable the better skies module")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enabled;
|
||||
|
||||
@@ -253,15 +253,15 @@ public class MCPatcherForgeConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static int horizon;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean brightenFireworks;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean skybox;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean unloadTextures;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class VideoSettings {
|
||||
private final File optionsFile;
|
||||
@@ -19,11 +21,12 @@ public class VideoSettings {
|
||||
|
||||
public void loadSettings() {
|
||||
try {
|
||||
if (!optionsFile.exists()) {
|
||||
if (!optionsFile.exists() && !optionsFile.createNewFile()) {
|
||||
return;
|
||||
}
|
||||
BufferedReader bufferedreader = new BufferedReader(new FileReader(optionsFile));
|
||||
String settingString;
|
||||
Set<Settings> loadedSettings = EnumSet.noneOf(Settings.class);
|
||||
|
||||
while((settingString = bufferedreader.readLine()) != null) {
|
||||
try {
|
||||
@@ -31,12 +34,19 @@ public class VideoSettings {
|
||||
Settings setting = Settings.valueOf(fragments[0]);
|
||||
setting.option.deserialize(fragments[1]);
|
||||
setting.applyChanges();
|
||||
loadedSettings.add(setting);
|
||||
} catch (Exception exception) {
|
||||
NotFine.logger.warn("Skipping bad option: " + settingString);
|
||||
}
|
||||
|
||||
}
|
||||
bufferedreader.close();
|
||||
|
||||
for (Settings setting : Settings.values()) {
|
||||
if (!loadedSettings.contains(setting)) {
|
||||
setting.applyChanges();
|
||||
}
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
NotFine.logger.error("Failed to load options", exception);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package kroppeb.stareval;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Util {
|
||||
public static <T> T make(T item, Consumer<T> init) {
|
||||
init.accept(item);
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
package kroppeb.stareval.element.tree;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import kroppeb.stareval.element.AccessibleExpressionElement;
|
||||
|
||||
public class AccessExpressionElement implements AccessibleExpressionElement {
|
||||
private final AccessibleExpressionElement base;
|
||||
private final String index;
|
||||
@Desugar
|
||||
public record AccessExpressionElement(AccessibleExpressionElement base,
|
||||
String index) implements AccessibleExpressionElement {
|
||||
|
||||
public AccessExpressionElement(AccessibleExpressionElement base, String index) {
|
||||
this.base = base;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public AccessibleExpressionElement getBase() {
|
||||
return this.base;
|
||||
}
|
||||
|
||||
public String getIndex() {
|
||||
return this.index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
package kroppeb.stareval.element.tree;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import kroppeb.stareval.element.ExpressionElement;
|
||||
import kroppeb.stareval.parser.BinaryOp;
|
||||
|
||||
public class BinaryExpressionElement implements ExpressionElement {
|
||||
private final BinaryOp op;
|
||||
private final ExpressionElement left;
|
||||
private final ExpressionElement right;
|
||||
@Desugar
|
||||
public record BinaryExpressionElement(BinaryOp op, ExpressionElement left,
|
||||
ExpressionElement right) implements ExpressionElement {
|
||||
|
||||
public BinaryExpressionElement(BinaryOp op, ExpressionElement left, ExpressionElement right) {
|
||||
this.op = op;
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public BinaryOp getOp() {
|
||||
return this.op;
|
||||
}
|
||||
|
||||
public ExpressionElement getLeft() {
|
||||
return this.left;
|
||||
}
|
||||
|
||||
public ExpressionElement getRight() {
|
||||
return this.right;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -1,25 +1,13 @@
|
||||
package kroppeb.stareval.element.tree;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import kroppeb.stareval.element.ExpressionElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FunctionCall implements ExpressionElement {
|
||||
private final String id;
|
||||
private final List<? extends ExpressionElement> args;
|
||||
@Desugar
|
||||
public record FunctionCall(String id, List<? extends ExpressionElement> args) implements ExpressionElement {
|
||||
|
||||
public FunctionCall(String id, List<? extends ExpressionElement> args) {
|
||||
this.id = id;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<? extends ExpressionElement> getArgs() {
|
||||
return this.args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -1,24 +1,12 @@
|
||||
package kroppeb.stareval.element.tree;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import kroppeb.stareval.element.ExpressionElement;
|
||||
import kroppeb.stareval.parser.UnaryOp;
|
||||
|
||||
public class UnaryExpressionElement implements ExpressionElement {
|
||||
private final UnaryOp op;
|
||||
private final ExpressionElement inner;
|
||||
@Desugar
|
||||
public record UnaryExpressionElement(UnaryOp op, ExpressionElement inner) implements ExpressionElement {
|
||||
|
||||
public UnaryExpressionElement(UnaryOp op, ExpressionElement inner) {
|
||||
this.op = op;
|
||||
this.inner = inner;
|
||||
}
|
||||
|
||||
public UnaryOp getOp() {
|
||||
return op;
|
||||
}
|
||||
|
||||
public ExpressionElement getInner() {
|
||||
return inner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PartialBinaryExpression extends PartialExpression implements Priori
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return this.op.getPriority();
|
||||
return this.op.priority();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class MissingTokenException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = -2096321911994168858L;
|
||||
|
||||
public MissingTokenException(String message, int index) {
|
||||
public MissingTokenException(String message, int index) {
|
||||
super(message + " at index " + index);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public abstract class ParseException extends Exception{
|
||||
|
||||
private static final long serialVersionUID = -5014053641238717471L;
|
||||
|
||||
public ParseException() {
|
||||
public abstract class ParseException extends Exception {
|
||||
public ParseException() {
|
||||
}
|
||||
|
||||
public ParseException(String message) {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class UnexpectedCharacterException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = -3886198952263126846L;
|
||||
|
||||
public UnexpectedCharacterException(char expected, char actual, int index) {
|
||||
public UnexpectedCharacterException(char expected, char actual, int index) {
|
||||
this("Expected to read '" + expected + "' but got '" + actual + "' at index " + index);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class UnexpectedEndingException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = -3704913315979481520L;
|
||||
|
||||
public UnexpectedEndingException() {
|
||||
public UnexpectedEndingException() {
|
||||
this("Expected to read more text, but the string has ended");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class UnexpectedTokenException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = 689385399380177588L;
|
||||
|
||||
public UnexpectedTokenException(String message, int index) {
|
||||
public UnexpectedTokenException(String message, int index) {
|
||||
super(message + " at index " + index);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package kroppeb.stareval.expression;
|
||||
|
||||
import kroppeb.stareval.function.FunctionContext;
|
||||
import kroppeb.stareval.function.FunctionReturn;
|
||||
import kroppeb.stareval.function.Type;
|
||||
|
||||
public class BasicVariableExpression implements VariableExpression {
|
||||
final private String name;
|
||||
final private Type type;
|
||||
|
||||
public BasicVariableExpression(String name, Type type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext c, FunctionReturn r) {
|
||||
c.getVariable(name).evaluateTo(c, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression partialEval(FunctionContext context, FunctionReturn functionReturn) {
|
||||
if (context.hasVariable(this.name)) {
|
||||
context.getVariable(this.name).evaluateTo(context, functionReturn);
|
||||
return type.createConstant(functionReturn);
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package kroppeb.stareval.expression;
|
||||
|
||||
import kroppeb.stareval.function.FunctionContext;
|
||||
import kroppeb.stareval.function.FunctionReturn;
|
||||
import kroppeb.stareval.function.TypedFunction;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class CallExpression implements Expression {
|
||||
private final TypedFunction function;
|
||||
private final Expression[] arguments;
|
||||
|
||||
public CallExpression(TypedFunction function, Expression[] arguments) {
|
||||
this.function = function;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
this.function.evaluateTo(this.arguments, context, functionReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listVariables(Collection<? super VariableExpression> variables) {
|
||||
for (Expression argument : this.arguments) {
|
||||
argument.listVariables(variables);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isConstant() {
|
||||
for (Expression i : arguments) {
|
||||
if (!(i instanceof ConstantExpression)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression partialEval(FunctionContext context, FunctionReturn functionReturn) {
|
||||
// the dirty way would be this
|
||||
/*
|
||||
try{
|
||||
this.evaluateTo(context, functionReturn);
|
||||
return this.function.getReturnType().createConstant(functionReturn);
|
||||
}catch(Exception e){
|
||||
return this;
|
||||
}
|
||||
*/
|
||||
|
||||
if (this.function.isPure() && isConstant()) {
|
||||
this.evaluateTo(context, functionReturn);
|
||||
return function.getReturnType().createConstant(functionReturn);
|
||||
}
|
||||
|
||||
Expression[] partialEvaluatedParams = new Expression[this.arguments.length];
|
||||
boolean allFullySimplified = true;
|
||||
boolean noneSimplified = true;
|
||||
for (int i = 0; i < this.arguments.length; i++) {
|
||||
Expression simplified = this.arguments[i].partialEval(context, functionReturn);
|
||||
if (simplified instanceof ConstantExpression) {
|
||||
noneSimplified = false;
|
||||
} else {
|
||||
allFullySimplified = false;
|
||||
if (simplified != this.arguments[i]) {
|
||||
noneSimplified = false;
|
||||
}
|
||||
}
|
||||
partialEvaluatedParams[i] = simplified;
|
||||
}
|
||||
|
||||
if (this.function.isPure() && allFullySimplified) {
|
||||
this.function.evaluateTo(partialEvaluatedParams, context, functionReturn);
|
||||
return this.function.getReturnType().createConstant(functionReturn);
|
||||
}
|
||||
|
||||
if (noneSimplified) {
|
||||
return this;
|
||||
}
|
||||
|
||||
return new CallExpression(this.function, partialEvaluatedParams);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package kroppeb.stareval.expression;
|
||||
|
||||
import kroppeb.stareval.function.Type;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class ConstantExpression implements Expression {
|
||||
private final Type type;
|
||||
|
||||
protected ConstantExpression(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listVariables(Collection<? super VariableExpression> variables) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package kroppeb.stareval.expression;
|
||||
|
||||
import kroppeb.stareval.function.FunctionContext;
|
||||
import kroppeb.stareval.function.FunctionReturn;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface Expression {
|
||||
void evaluateTo(FunctionContext context, FunctionReturn functionReturn);
|
||||
|
||||
default Expression partialEval(FunctionContext context, FunctionReturn functionReturn) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void listVariables(Collection<? super VariableExpression> variables);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package kroppeb.stareval.expression;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public interface VariableExpression extends Expression {
|
||||
@Override
|
||||
default void listVariables(Collection<? super VariableExpression> variables) {
|
||||
variables.add(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class AbstractTypedFunction implements TypedFunction {
|
||||
private final Type returnType;
|
||||
private final Parameter[] parameters;
|
||||
private final int priority;
|
||||
private final boolean isPure;
|
||||
|
||||
public AbstractTypedFunction(Type returnType, Parameter[] parameters, int priority, boolean isPure) {
|
||||
this.returnType = returnType;
|
||||
this.parameters = parameters;
|
||||
this.priority = priority;
|
||||
this.isPure = isPure;
|
||||
}
|
||||
|
||||
public AbstractTypedFunction(Type returnType, Type[] parameterType) {
|
||||
this.returnType = returnType;
|
||||
this.parameters = Arrays.stream(parameterType).map(Parameter::new).toArray(Parameter[]::new);
|
||||
this.priority = 0;
|
||||
this.isPure = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getReturnType() {
|
||||
return this.returnType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parameter[] getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPure() {
|
||||
return this.isPure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int priority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof AbstractTypedFunction func) {
|
||||
return Objects.equals(returnType, func.returnType) &&
|
||||
Arrays.equals(parameters, func.parameters) &&
|
||||
priority == func.priority &&
|
||||
isPure == func.isPure;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(returnType, Arrays.hashCode(parameters), priority, isPure);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return TypedFunction.format(this, "unknown");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface B2BFunction extends TypedFunction {
|
||||
boolean eval(boolean a);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
boolean a = functionReturn.booleanReturn;
|
||||
|
||||
functionReturn.booleanReturn = this.eval(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.BooleanParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BB2BFunction extends TypedFunction {
|
||||
boolean eval(boolean a, boolean b);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
boolean a = functionReturn.booleanReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
boolean b = functionReturn.booleanReturn;
|
||||
|
||||
functionReturn.booleanReturn = this.eval(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.BooleanParameter, Type.BooleanParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
import kroppeb.stareval.expression.VariableExpression;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class BasicFunctionContext implements FunctionContext {
|
||||
final private Map<String, Expression> variables = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
public void setVariable(String name, Expression value) {
|
||||
variables.put(name, value);
|
||||
}
|
||||
|
||||
public void setIntVariable(String name, int value) {
|
||||
setVariable(name, (VariableExpression) (c, r) -> r.intReturn = value);
|
||||
}
|
||||
|
||||
public void setFloatVariable(String name, float value) {
|
||||
setVariable(name, (VariableExpression) (c, r) -> r.floatReturn = value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression getVariable(String name) {
|
||||
Expression expression = variables.get(name);
|
||||
if (expression == null)
|
||||
throw new RuntimeException("Variable hasn't been set: " + name);
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariable(String name) {
|
||||
return variables.containsKey(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface F2FFunction extends TypedFunction {
|
||||
float eval(float a);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
functionReturn.floatReturn = this.eval(functionReturn.floatReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Float;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.FloatParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface F2IFunction extends TypedFunction {
|
||||
int eval(float a);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
functionReturn.intReturn = this.eval(functionReturn.floatReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Int;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.FloatParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FF2BFunction extends TypedFunction {
|
||||
boolean eval(float a, float b);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
float a = functionReturn.floatReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
float b = functionReturn.floatReturn;
|
||||
|
||||
functionReturn.booleanReturn = this.eval(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.FloatParameter, Type.FloatParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FF2FFunction extends TypedFunction {
|
||||
float eval(float a, float b);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
float a = functionReturn.floatReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
float b = functionReturn.floatReturn;
|
||||
|
||||
functionReturn.floatReturn = this.eval(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Float;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.FloatParameter, Type.FloatParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FFF2BFunction extends TypedFunction {
|
||||
boolean eval(float a, float b, float c);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
float a = functionReturn.floatReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
float b = functionReturn.floatReturn;
|
||||
|
||||
params[2].evaluateTo(context, functionReturn);
|
||||
float c = functionReturn.floatReturn;
|
||||
|
||||
functionReturn.booleanReturn = this.eval(a, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.FloatParameter, Type.FloatParameter, Type.FloatParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FFF2FFunction extends TypedFunction {
|
||||
float eval(float a, float b, float c);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
float a = functionReturn.floatReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
float b = functionReturn.floatReturn;
|
||||
|
||||
params[2].evaluateTo(context, functionReturn);
|
||||
float c = functionReturn.floatReturn;
|
||||
|
||||
functionReturn.floatReturn = this.eval(a, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Float;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.FloatParameter, Type.FloatParameter, Type.FloatParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
public interface FunctionContext {
|
||||
Expression getVariable(String name);
|
||||
|
||||
boolean hasVariable(String name);
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class FunctionResolver {
|
||||
private final Map<String, Map<Type, List<TypedFunction>>> functions;
|
||||
// TODO: instead of a suplier we could use an int->function to make varargs
|
||||
private final Map<String, Map<Type, List<Supplier<? extends TypedFunction>>>> dynamicFunctions;
|
||||
|
||||
public FunctionResolver(
|
||||
Map<String, Map<Type, List<TypedFunction>>> functions,
|
||||
Map<String, Map<Type, List<Supplier<? extends TypedFunction>>>> dynamicFunctions) {
|
||||
this.functions = functions;
|
||||
this.dynamicFunctions = dynamicFunctions;
|
||||
}
|
||||
|
||||
public List<? extends TypedFunction> resolve(String name, Type returnType) {
|
||||
Map<Type, List<TypedFunction>> normal = this.functions.get(name);
|
||||
Map<Type, List<Supplier<? extends TypedFunction>>> dynamic = this.dynamicFunctions.get(name);
|
||||
List<? extends TypedFunction> u = null;
|
||||
|
||||
if (normal == null && dynamic == null)
|
||||
throw new RuntimeException("No such function: " + name);
|
||||
if (normal != null)
|
||||
u = normal.get(returnType);
|
||||
if (dynamic != null) {
|
||||
List<Supplier<? extends TypedFunction>> p = dynamic.get(returnType);
|
||||
if (p != null) {
|
||||
List<? extends TypedFunction> uDynamic = p.stream().map(Supplier::get).collect(Collectors.toList());
|
||||
if (u == null) {
|
||||
u = uDynamic;
|
||||
} else {
|
||||
List<TypedFunction> newU = new ArrayList<>(u.size() + uDynamic.size());
|
||||
newU.addAll(u);
|
||||
newU.addAll(uDynamic);
|
||||
u = newU;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (u == null)
|
||||
return Collections.emptyList();
|
||||
return u;
|
||||
}
|
||||
|
||||
public void logAllFunctions() {
|
||||
final Set<String> names = new LinkedHashSet<>();
|
||||
names.addAll(this.functions.keySet());
|
||||
names.addAll(this.dynamicFunctions.keySet());
|
||||
for (final String name : names) {
|
||||
final Map<Type, List<TypedFunction>> overloads = new Object2ObjectLinkedOpenHashMap<>();
|
||||
Map<Type, List<TypedFunction>> normal = this.functions.get(name);
|
||||
if (normal != null)
|
||||
overloads.putAll(normal);
|
||||
|
||||
Map<Type, List<Supplier<? extends TypedFunction>>> dynamic = this.dynamicFunctions.get(name);
|
||||
if (dynamic != null)
|
||||
overloads.putAll(
|
||||
dynamic
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
entry -> entry.getValue()
|
||||
.stream()
|
||||
.map(Supplier::get)
|
||||
.collect(Collectors.toList())
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
for (Map.Entry<Type, List<TypedFunction>> returnTypeOverloads : overloads.entrySet()) {
|
||||
for (TypedFunction typedFunction : returnTypeOverloads.getValue()) {
|
||||
System.out.println(TypedFunction.format(typedFunction, name));
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final Map<String, List<TypedFunction>> functions = new Object2ObjectLinkedOpenHashMap<>();
|
||||
private final Map<String, Map<Type, List<Supplier<? extends TypedFunction>>>> dynamicFunctions = new Object2ObjectLinkedOpenHashMap<>();
|
||||
|
||||
public <T extends TypedFunction> void add(String name, T function) {
|
||||
this.addFunction(name, function);
|
||||
}
|
||||
|
||||
public <T extends TypedFunction> void addDynamic(String name, Type returnType, Supplier<T> function) {
|
||||
this.addDynamicFunction(name, returnType, function);
|
||||
}
|
||||
|
||||
public void addDynamicFunction(String name, Type returnType, Supplier<? extends TypedFunction> function) {
|
||||
this.dynamicFunctions
|
||||
.computeIfAbsent(name, (n) -> new Object2ObjectLinkedOpenHashMap<>())
|
||||
.computeIfAbsent(returnType, (n) -> new ObjectArrayList<>())
|
||||
.add(function);
|
||||
}
|
||||
|
||||
public void addFunction(String name, TypedFunction function) {
|
||||
this.functions.computeIfAbsent(name, (n) -> new ObjectArrayList<>()).add(function);
|
||||
}
|
||||
|
||||
public FunctionResolver build() {
|
||||
Map<String, Map<Type, List<TypedFunction>>> functions = new Object2ObjectLinkedOpenHashMap<>();
|
||||
for (Map.Entry<String, List<TypedFunction>> entry : this.functions.entrySet()) {
|
||||
Map<Type, List<TypedFunction>> typeMap = new Object2ObjectLinkedOpenHashMap<>();
|
||||
for (TypedFunction function : entry.getValue()) {
|
||||
typeMap.computeIfAbsent(function.getReturnType(), i -> new ObjectArrayList<>())
|
||||
.add(function);
|
||||
}
|
||||
functions.put(entry.getKey(), typeMap);
|
||||
}
|
||||
|
||||
return new FunctionResolver(functions, this.dynamicFunctions);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
public class FunctionReturn {
|
||||
public boolean booleanReturn;
|
||||
public byte byteReturn;
|
||||
public short shortReturn;
|
||||
public int intReturn;
|
||||
public long longReturn;
|
||||
public float floatReturn;
|
||||
public double doubleReturn;
|
||||
public Object objectReturn;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface I2FFunction extends TypedFunction {
|
||||
float eval(int a);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
functionReturn.floatReturn = this.eval(functionReturn.intReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Float;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.IntParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface I2IFunction extends TypedFunction {
|
||||
int eval(int a);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
functionReturn.intReturn = this.eval(functionReturn.intReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Int;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.IntParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface II2BFunction extends TypedFunction {
|
||||
boolean eval(int a, int b);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
int a = functionReturn.intReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
int b = functionReturn.intReturn;
|
||||
|
||||
functionReturn.booleanReturn = this.eval(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.IntParameter, Type.IntParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface II2IFunction extends TypedFunction {
|
||||
int eval(int a, int b);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
int a = functionReturn.intReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
int b = functionReturn.intReturn;
|
||||
|
||||
functionReturn.intReturn = this.eval(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Int;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.IntParameter, Type.IntParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface III2BFunction extends TypedFunction {
|
||||
boolean eval(int a, int b, int c);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
int a = functionReturn.intReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
int b = functionReturn.intReturn;
|
||||
|
||||
params[2].evaluateTo(context, functionReturn);
|
||||
int c = functionReturn.intReturn;
|
||||
|
||||
functionReturn.booleanReturn = this.eval(a, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.IntParameter, Type.IntParameter, Type.IntParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface III2IFunction extends TypedFunction {
|
||||
int eval(int a, int b, int c);
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
params[0].evaluateTo(context, functionReturn);
|
||||
int a = functionReturn.intReturn;
|
||||
|
||||
params[1].evaluateTo(context, functionReturn);
|
||||
int b = functionReturn.intReturn;
|
||||
|
||||
params[2].evaluateTo(context, functionReturn);
|
||||
int c = functionReturn.intReturn;
|
||||
|
||||
functionReturn.intReturn = this.eval(a, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Int;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{Type.IntParameter, Type.IntParameter, Type.IntParameter};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.ConstantExpression;
|
||||
import kroppeb.stareval.function.TypedFunction.Parameter;
|
||||
import net.coderbot.iris.gl.uniform.UniformType;
|
||||
import net.coderbot.iris.parsing.MatrixType;
|
||||
import net.coderbot.iris.parsing.VectorType;
|
||||
|
||||
public abstract class Type {
|
||||
public static final Boolean Boolean = new Boolean();
|
||||
public static final Int Int = new Int();
|
||||
public static final Float Float = new Float();
|
||||
public static final Parameter BooleanParameter = new Parameter(Boolean);
|
||||
public static final Parameter IntParameter = new Parameter(Int);
|
||||
public static final Parameter FloatParameter = new Parameter(Float);
|
||||
public static final Primitive[] AllPrimitives = {Type.Boolean, Type.Int, Type.Float};
|
||||
|
||||
public static UniformType convert(Type type) {
|
||||
if (type == Type.Int || type == Type.Boolean) return UniformType.INT;
|
||||
else if (type == Type.Float) return UniformType.FLOAT;
|
||||
else if (type == VectorType.VEC2) return UniformType.VEC2;
|
||||
else if (type == VectorType.VEC3) return UniformType.VEC3;
|
||||
else if (type == VectorType.VEC4) return UniformType.VEC4;
|
||||
else if (type == VectorType.I_VEC2) return UniformType.VEC2I;
|
||||
else if (type == VectorType.I_VEC3) return UniformType.VEC3I;
|
||||
else if (type == MatrixType.MAT4) return UniformType.MAT4;
|
||||
else throw new IllegalArgumentException("Unsupported custom uniform type: " + type);
|
||||
}
|
||||
|
||||
public abstract ConstantExpression createConstant(FunctionReturn functionReturn);
|
||||
|
||||
public abstract Object createArray(int length);
|
||||
|
||||
public abstract void setValueFromReturn(Object array, int index, FunctionReturn value);
|
||||
|
||||
public abstract void getValueFromArray(Object array, int index, FunctionReturn value);
|
||||
|
||||
public abstract String toString();
|
||||
|
||||
public abstract static class Primitive extends Type {
|
||||
}
|
||||
|
||||
public static class ObjectType extends Type {
|
||||
@Override
|
||||
public ConstantExpression createConstant(FunctionReturn functionReturn) {
|
||||
Object object = functionReturn.objectReturn;
|
||||
return new ConstantExpression(this) {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.objectReturn = object;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createArray(int length) {
|
||||
return new Object[length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromReturn(Object array, int index, FunctionReturn value) {
|
||||
Object[] arr = (Object[]) array;
|
||||
arr[index] = value.objectReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getValueFromArray(Object array, int index, FunctionReturn value) {
|
||||
Object[] arr = (Object[]) array;
|
||||
value.objectReturn = arr[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Object";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Boolean extends Primitive {
|
||||
@Override
|
||||
public ConstantExpression createConstant(FunctionReturn functionReturn) {
|
||||
boolean value = functionReturn.booleanReturn;
|
||||
return new ConstantExpression(this) {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.booleanReturn = value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createArray(int length) {
|
||||
return new boolean[length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromReturn(Object array, int index, FunctionReturn value) {
|
||||
boolean[] arr = (boolean[]) array;
|
||||
arr[index] = value.booleanReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getValueFromArray(Object array, int index, FunctionReturn value) {
|
||||
boolean[] arr = (boolean[]) array;
|
||||
value.booleanReturn = arr[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "bool";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Int extends Primitive {
|
||||
@Override
|
||||
public ConstantExpression createConstant(FunctionReturn functionReturn) {
|
||||
int value = functionReturn.intReturn;
|
||||
return new ConstantExpression(this) {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.intReturn = value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createArray(int length) {
|
||||
return new int[length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromReturn(Object array, int index, FunctionReturn value) {
|
||||
int[] arr = (int[]) array;
|
||||
arr[index] = value.intReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getValueFromArray(Object array, int index, FunctionReturn value) {
|
||||
int[] arr = (int[]) array;
|
||||
value.intReturn = arr[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "int";
|
||||
}
|
||||
}
|
||||
|
||||
public static class Float extends Primitive {
|
||||
@Override
|
||||
public ConstantExpression createConstant(FunctionReturn functionReturn) {
|
||||
float value = functionReturn.floatReturn;
|
||||
return new ConstantExpression(this) {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.floatReturn = value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createArray(int length) {
|
||||
return new float[length];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValueFromReturn(Object array, int index, FunctionReturn value) {
|
||||
float[] arr = (float[]) array;
|
||||
arr[index] = value.floatReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getValueFromArray(Object array, int index, FunctionReturn value) {
|
||||
float[] arr = (float[]) array;
|
||||
value.floatReturn = arr[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "float";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface TypedFunction {
|
||||
|
||||
static String format(TypedFunction function, String name) {
|
||||
return String.format("%s %s(%s) (priority: %d, pure:%s)",
|
||||
function.getReturnType().toString(),
|
||||
name,
|
||||
Arrays.stream(function.getParameters())
|
||||
.map(param -> param.constant() ? "const " + param.type() : param.type().toString())
|
||||
.collect(Collectors.joining(", ")),
|
||||
function.priority(),
|
||||
function.isPure() ? "yes" : "no"
|
||||
);
|
||||
}
|
||||
|
||||
Type getReturnType();
|
||||
|
||||
Parameter[] getParameters();
|
||||
|
||||
void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn);
|
||||
|
||||
default boolean isPure() {
|
||||
return true;
|
||||
}
|
||||
|
||||
default int priority() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
class Parameter {
|
||||
private final Type type;
|
||||
private final boolean isConstant;
|
||||
|
||||
public Parameter(Type type, boolean isConstant) {
|
||||
this.type = type;
|
||||
this.isConstant = isConstant;
|
||||
}
|
||||
|
||||
public Parameter(Type type) {
|
||||
this(type, false);
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean constant() {
|
||||
return this.isConstant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof Parameter p) {
|
||||
return Objects.equals(type, p.type) && Objects.equals(isConstant, p.isConstant);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(type) + 3192 + Objects.hashCode(isConstant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface V2FFunction extends TypedFunction {
|
||||
float eval();
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.floatReturn = this.eval();
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Float;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package kroppeb.stareval.function;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface V2IFunction extends TypedFunction {
|
||||
int eval();
|
||||
|
||||
@Override
|
||||
default void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.intReturn = this.eval();
|
||||
}
|
||||
|
||||
@Override
|
||||
default Type getReturnType() {
|
||||
return Type.Int;
|
||||
}
|
||||
|
||||
@Override
|
||||
default Parameter[] getParameters() {
|
||||
return new Parameter[]{};
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,15 @@
|
||||
package kroppeb.stareval.parser;
|
||||
|
||||
public class BinaryOp {
|
||||
private final String name;
|
||||
private final int priority;
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
|
||||
@Desugar
|
||||
public record BinaryOp(String name, int priority) {
|
||||
|
||||
public BinaryOp(String name, int priority) {
|
||||
this.name = name;
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + "{" + this.priority + "}";
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* OpResolver maps the trailing characters identifying an operator to an actual operator.
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
abstract class OpResolver<T> {
|
||||
@@ -27,7 +28,7 @@ abstract class OpResolver<T> {
|
||||
* Adds a new multi-character operator. Calling this with an empty string is equivalent to calling singleChar.
|
||||
*
|
||||
* @param trailing every character after the first character of the operator.
|
||||
* @param op the operator
|
||||
* @param op the operator
|
||||
*/
|
||||
public void multiChar(String trailing, T op) {
|
||||
T previous = map.put(trailing, op);
|
||||
@@ -40,14 +41,14 @@ abstract class OpResolver<T> {
|
||||
public OpResolver<T> build() {
|
||||
if (map.size() > 2) {
|
||||
throw new RuntimeException("unimplemented: Cannot currently build an optimized operator resolver " +
|
||||
"tree when more than two operators start with the same character");
|
||||
"tree when more than two operators start with the same character");
|
||||
}
|
||||
|
||||
T singleChar = map.get("");
|
||||
|
||||
if (singleChar != null) {
|
||||
if (map.size() == 1) {
|
||||
return new SingleChar<>(singleChar);
|
||||
return new OpResolver.SingleChar<>(singleChar);
|
||||
} else {
|
||||
for (Map.Entry<String, T> subEntry : map.entrySet()) {
|
||||
if ("".equals(subEntry.getKey())) {
|
||||
@@ -57,33 +58,33 @@ abstract class OpResolver<T> {
|
||||
|
||||
if (subEntry.getKey().length() != 1) {
|
||||
throw new RuntimeException("unimplemented: Optimized operator resolver trees can " +
|
||||
"currently only be built of operators that contain one or two characters.");
|
||||
"currently only be built of operators that contain one or two characters.");
|
||||
}
|
||||
|
||||
// We can assume that this is the only other entry in the map due to the size check above
|
||||
return new SingleDualChar<>(
|
||||
singleChar,
|
||||
subEntry.getValue(),
|
||||
subEntry.getKey().charAt(0)
|
||||
return new OpResolver.SingleDualChar<>(
|
||||
singleChar,
|
||||
subEntry.getValue(),
|
||||
subEntry.getKey().charAt(0)
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (map.size() > 1) {
|
||||
throw new RuntimeException("unimplemented: Optimized operator resolver trees can currently only " +
|
||||
"handle two operators starting with the same character if one operator is a single character");
|
||||
"handle two operators starting with the same character if one operator is a single character");
|
||||
}
|
||||
|
||||
for (Map.Entry<String, T> subEntry : map.entrySet()) {
|
||||
if (subEntry.getKey().length() != 1) {
|
||||
throw new RuntimeException("unimplemented: Optimized operator resolver trees can " +
|
||||
"currently only be built of operators that contain one or two characters.");
|
||||
"currently only be built of operators that contain one or two characters.");
|
||||
}
|
||||
|
||||
// We can assume that this is the only entry in the map due to the size check above.
|
||||
return new DualChar<>(
|
||||
subEntry.getValue(),
|
||||
subEntry.getKey().charAt(0)
|
||||
return new OpResolver.DualChar<>(
|
||||
subEntry.getValue(),
|
||||
subEntry.getKey().charAt(0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,13 @@ public class Parser {
|
||||
Parser() {
|
||||
}
|
||||
|
||||
public static ExpressionElement parse(String input, ParserOptions options) throws ParseException {
|
||||
return Tokenizer.parse(input, options);
|
||||
}
|
||||
|
||||
private Element peek() {
|
||||
if (!this.stack.isEmpty()) {
|
||||
return this.stack.get(this.stack.size() - 1);
|
||||
return this.stack.get(this.stack.size() - 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -115,6 +119,8 @@ public class Parser {
|
||||
return token;
|
||||
}
|
||||
|
||||
// visitor methods
|
||||
|
||||
/**
|
||||
* Executes following reduce step:
|
||||
* <ul>
|
||||
@@ -134,8 +140,8 @@ public class Parser {
|
||||
|
||||
if (args == null) {
|
||||
throw new MissingTokenException(
|
||||
"Expected an opening bracket '(' before seeing a comma ',' or closing bracket ')'",
|
||||
index
|
||||
"Expected an opening bracket '(' before seeing a comma ',' or closing bracket ')'",
|
||||
index
|
||||
);
|
||||
}
|
||||
|
||||
@@ -143,13 +149,11 @@ public class Parser {
|
||||
((UnfinishedArgsExpression) args).tokens.add(expr);
|
||||
} else {
|
||||
throw new UnexpectedTokenException(
|
||||
"Expected to see an opening bracket '(' or a comma ',' right before an expression followed by a " +
|
||||
"closing bracket ')' or a comma ','", index);
|
||||
"Expected to see an opening bracket '(' or a comma ',' right before an expression followed by a " +
|
||||
"closing bracket ')' or a comma ','", index);
|
||||
}
|
||||
}
|
||||
|
||||
// visitor methods
|
||||
|
||||
void visitId(String id) {
|
||||
this.push(new IdToken(id));
|
||||
}
|
||||
@@ -213,8 +217,8 @@ public class Parser {
|
||||
|
||||
if (!(pop instanceof UnfinishedArgsExpression)) {
|
||||
throw new UnexpectedTokenException(
|
||||
"Expected to see an opening bracket '(' or a comma ',' right before an expression followed by a " +
|
||||
"closing bracket ')' or a comma ','", index);
|
||||
"Expected to see an opening bracket '(' or a comma ',' right before an expression followed by a " +
|
||||
"closing bracket ')' or a comma ','", index);
|
||||
}
|
||||
args = (UnfinishedArgsExpression) pop;
|
||||
}
|
||||
@@ -256,7 +260,7 @@ public class Parser {
|
||||
*/
|
||||
void visitBinaryOperator(BinaryOp binaryOp) {
|
||||
// reduce the expressions to the needed priority level
|
||||
ExpressionElement left = this.expressionReducePop(binaryOp.getPriority());
|
||||
ExpressionElement left = this.expressionReducePop(binaryOp.priority());
|
||||
// stack[ {'a', '*'}, 'b'], token = '+' -> stack[], left = {'a', '*', 'b'}
|
||||
// -> stack[{{'a', '*', 'b'}, '+'}]
|
||||
// stack[ {'a', '+'}, 'b'], token = '+' -> stack[], left = {'a', '+', 'b'}
|
||||
@@ -287,8 +291,8 @@ public class Parser {
|
||||
throw new MissingTokenException("Expected a closing bracket", endIndex);
|
||||
} else {
|
||||
throw new UnexpectedTokenException(
|
||||
"The stack of tokens isn't empty at the end of the expression: " + this.stack +
|
||||
" top: " + result, endIndex);
|
||||
"The stack of tokens isn't empty at the end of the expression: " + this.stack +
|
||||
" top: " + result, endIndex);
|
||||
}
|
||||
} else {
|
||||
Element top = this.peek();
|
||||
@@ -296,20 +300,16 @@ public class Parser {
|
||||
throw new MissingTokenException("Expected a closing bracket", endIndex);
|
||||
} else if (top instanceof PriorityOperatorElement) {
|
||||
throw new MissingTokenException(
|
||||
"Expected a identifier, constant or subexpression on the right side of the operator",
|
||||
endIndex);
|
||||
"Expected a identifier, constant or subexpression on the right side of the operator",
|
||||
endIndex);
|
||||
} else {
|
||||
throw new UnexpectedTokenException(
|
||||
"The stack of tokens contains an unexpected token at the top: " + this.stack,
|
||||
endIndex);
|
||||
"The stack of tokens contains an unexpected token at the top: " + this.stack,
|
||||
endIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new MissingTokenException("The input seems to be empty", endIndex);
|
||||
}
|
||||
}
|
||||
|
||||
public static ExpressionElement parse(String input, ParserOptions options) throws ParseException {
|
||||
return Tokenizer.parse(input, options);
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@ public final class ParserOptions {
|
||||
private final TokenRules tokenRules;
|
||||
|
||||
private ParserOptions(
|
||||
Char2ObjectMap<? extends OpResolver<? extends UnaryOp>> unaryOpResolvers,
|
||||
Char2ObjectMap<? extends OpResolver<? extends BinaryOp>> binaryOpResolvers,
|
||||
TokenRules tokenRules) {
|
||||
Char2ObjectMap<? extends OpResolver<? extends UnaryOp>> unaryOpResolvers,
|
||||
Char2ObjectMap<? extends OpResolver<? extends BinaryOp>> binaryOpResolvers,
|
||||
TokenRules tokenRules) {
|
||||
this.unaryOpResolvers = unaryOpResolvers;
|
||||
this.binaryOpResolvers = binaryOpResolvers;
|
||||
this.tokenRules = tokenRules;
|
||||
@@ -29,52 +29,12 @@ public final class ParserOptions {
|
||||
return this.binaryOpResolvers.get(c);
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final Char2ObjectMap<OpResolver.Builder<UnaryOp>> unaryOpResolvers = new Char2ObjectOpenHashMap<>();
|
||||
private final Char2ObjectMap<OpResolver.Builder<BinaryOp>> binaryOpResolvers = new Char2ObjectOpenHashMap<>();
|
||||
private TokenRules tokenRules = TokenRules.DEFAULT;
|
||||
|
||||
public void addUnaryOp(String s, UnaryOp op) {
|
||||
char first = s.charAt(0);
|
||||
String trailing = s.substring(1);
|
||||
|
||||
this.unaryOpResolvers.computeIfAbsent(first, (c) -> new OpResolver.Builder<>()).multiChar(trailing, op);
|
||||
}
|
||||
|
||||
public void addBinaryOp(String s, BinaryOp op) {
|
||||
char first = s.charAt(0);
|
||||
String trailing = s.substring(1);
|
||||
|
||||
this.binaryOpResolvers.computeIfAbsent(first, (c) -> new OpResolver.Builder<>()).multiChar(trailing, op);
|
||||
}
|
||||
|
||||
public void setTokenRules(TokenRules tokenRules) {
|
||||
this.tokenRules = tokenRules;
|
||||
}
|
||||
|
||||
private static <T> Char2ObjectMap<? extends OpResolver<? extends T>> buildOpResolvers(
|
||||
Char2ObjectMap<OpResolver.Builder<T>> ops) {
|
||||
Char2ObjectMap<OpResolver<T>> result = new Char2ObjectOpenHashMap<>();
|
||||
|
||||
ops.char2ObjectEntrySet().forEach(
|
||||
entry -> result.put(entry.getCharKey(), entry.getValue().build()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ParserOptions build() {
|
||||
return new ParserOptions(
|
||||
buildOpResolvers(this.unaryOpResolvers),
|
||||
buildOpResolvers(this.binaryOpResolvers),
|
||||
this.tokenRules);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a set of rules that allows the tokenizer to identify tokens within a string.
|
||||
*/
|
||||
public interface TokenRules {
|
||||
TokenRules DEFAULT = new TokenRules() {};
|
||||
TokenRules DEFAULT = new TokenRules() {
|
||||
};
|
||||
|
||||
static boolean isNumber(final char c) {
|
||||
return c >= '0' && c <= '9';
|
||||
@@ -116,4 +76,45 @@ public final class ParserOptions {
|
||||
return this.isAccessStart(c);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private final Char2ObjectMap<OpResolver.Builder<UnaryOp>> unaryOpResolvers = new Char2ObjectOpenHashMap<>();
|
||||
private final Char2ObjectMap<OpResolver.Builder<BinaryOp>> binaryOpResolvers = new Char2ObjectOpenHashMap<>();
|
||||
private TokenRules tokenRules = TokenRules.DEFAULT;
|
||||
|
||||
private static <T> Char2ObjectMap<? extends OpResolver<? extends T>> buildOpResolvers(
|
||||
Char2ObjectMap<OpResolver.Builder<T>> ops) {
|
||||
Char2ObjectMap<OpResolver<T>> result = new Char2ObjectOpenHashMap<>();
|
||||
|
||||
ops.char2ObjectEntrySet().forEach(
|
||||
entry -> result.put(entry.getCharKey(), entry.getValue().build()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addUnaryOp(String s, UnaryOp op) {
|
||||
char first = s.charAt(0);
|
||||
String trailing = s.substring(1);
|
||||
|
||||
this.unaryOpResolvers.computeIfAbsent(first, (c) -> new OpResolver.Builder<>()).multiChar(trailing, op);
|
||||
}
|
||||
|
||||
public void addBinaryOp(String s, BinaryOp op) {
|
||||
char first = s.charAt(0);
|
||||
String trailing = s.substring(1);
|
||||
|
||||
this.binaryOpResolvers.computeIfAbsent(first, (c) -> new OpResolver.Builder<>()).multiChar(trailing, op);
|
||||
}
|
||||
|
||||
public void setTokenRules(TokenRules tokenRules) {
|
||||
this.tokenRules = tokenRules;
|
||||
}
|
||||
|
||||
public ParserOptions build() {
|
||||
return new ParserOptions(
|
||||
buildOpResolvers(this.unaryOpResolvers),
|
||||
buildOpResolvers(this.binaryOpResolvers),
|
||||
this.tokenRules);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package kroppeb.stareval.parser;
|
||||
|
||||
public class UnaryOp {
|
||||
private final String name;
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
|
||||
@Desugar
|
||||
public record UnaryOp(String name) {
|
||||
|
||||
public UnaryOp(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
package kroppeb.stareval.resolver;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import kroppeb.stareval.element.ExpressionElement;
|
||||
import kroppeb.stareval.element.token.IdToken;
|
||||
import kroppeb.stareval.element.token.NumberToken;
|
||||
import kroppeb.stareval.element.tree.AccessExpressionElement;
|
||||
import kroppeb.stareval.element.tree.BinaryExpressionElement;
|
||||
import kroppeb.stareval.element.tree.FunctionCall;
|
||||
import kroppeb.stareval.element.tree.UnaryExpressionElement;
|
||||
import kroppeb.stareval.expression.CallExpression;
|
||||
import kroppeb.stareval.expression.ConstantExpression;
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
import kroppeb.stareval.expression.VariableExpression;
|
||||
import kroppeb.stareval.function.FunctionContext;
|
||||
import kroppeb.stareval.function.FunctionResolver;
|
||||
import kroppeb.stareval.function.FunctionReturn;
|
||||
import kroppeb.stareval.function.Type;
|
||||
import kroppeb.stareval.function.TypedFunction;
|
||||
import kroppeb.stareval.function.TypedFunction.Parameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ExpressionResolver {
|
||||
private final FunctionResolver functionResolver;
|
||||
private final Function<String, Type> variableTypeMap;
|
||||
private final boolean enableDebugging;
|
||||
private final Map<String, ConstantExpression> numbers = new Object2ObjectOpenHashMap<>();
|
||||
private List<String> logs;
|
||||
|
||||
public ExpressionResolver(FunctionResolver functionResolver, Function<String, Type> variableTypeMap) {
|
||||
this(functionResolver, variableTypeMap, false);
|
||||
}
|
||||
|
||||
|
||||
public ExpressionResolver(FunctionResolver functionResolver, Function<String, Type> variableTypeMap, boolean enableDebugging) {
|
||||
this.functionResolver = functionResolver;
|
||||
this.variableTypeMap = variableTypeMap;
|
||||
this.enableDebugging = enableDebugging;
|
||||
}
|
||||
|
||||
public Expression resolveExpression(Type targetType, ExpressionElement expression) {
|
||||
this.clearLogs();
|
||||
Expression result = this.resolveExpressionInternal(targetType, expression, true, true);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
throw new RuntimeException("Couldn't resolve: \n" + String.join("\n", this.extractLogs()));
|
||||
}
|
||||
|
||||
Expression resolveCallExpressionInternal(
|
||||
Type targetType,
|
||||
String name,
|
||||
List<? extends ExpressionElement> inner,
|
||||
boolean implicit
|
||||
) {
|
||||
int innerLength = inner.size();
|
||||
Expression result = null;
|
||||
TypedFunction resultFunction = null;
|
||||
functions:
|
||||
for (TypedFunction f : this.functionResolver.resolve(name, targetType)) {
|
||||
Parameter[] paramTypes = f.getParameters();
|
||||
if (paramTypes.length != innerLength)
|
||||
continue;
|
||||
|
||||
Expression[] params = new Expression[innerLength];
|
||||
for (int i = 0; i < innerLength; i++) {
|
||||
ExpressionElement paramExpression = inner.get(i);
|
||||
Parameter param = paramTypes[i];
|
||||
if (param.constant() && !(paramExpression instanceof NumberToken)) {
|
||||
// not a constant
|
||||
continue functions;
|
||||
}
|
||||
|
||||
Expression expression = this.resolveExpressionInternal(param.type(), paramExpression,
|
||||
!implicit || innerLength > 1, implicit);
|
||||
if (expression == null)
|
||||
continue functions;
|
||||
params[i] = expression;
|
||||
}
|
||||
// FIXME
|
||||
if (result != null && f.priority() == resultFunction.priority()) {
|
||||
throw new RuntimeException("Ambiguity, \n\told: " + TypedFunction.format(resultFunction, "") + "\n\tnew: " + TypedFunction.format(f, ""));
|
||||
} else if (resultFunction == null || f.priority() >= resultFunction.priority()) {
|
||||
result = new CallExpression(f, params);
|
||||
resultFunction = f;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private Expression resolveCallExpression(
|
||||
Type targetType,
|
||||
String name,
|
||||
List<? extends ExpressionElement> inner,
|
||||
boolean allowNonImplicit,
|
||||
boolean allowImplicit) {
|
||||
|
||||
this.log("[DEBUG] resolving function %s with args %s to type %s",
|
||||
name, inner, targetType);
|
||||
|
||||
Expression result = null;
|
||||
|
||||
if (allowNonImplicit) {
|
||||
result = this.resolveCallExpressionInternal(targetType, name, inner, false);
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
this.log("[DEBUG] resolved function %s with args %s to type %s directly",
|
||||
name, inner, targetType);
|
||||
return result;
|
||||
} else if (!allowImplicit) {
|
||||
this.log("[DEBUG] Failed to resolve function %s with args %s to type %s directly",
|
||||
name, inner, targetType);
|
||||
return null;
|
||||
}
|
||||
|
||||
List<? extends TypedFunction> casts = this.functionResolver.resolve("<cast>", targetType);
|
||||
|
||||
for (TypedFunction f : casts) {
|
||||
Expression u = this.resolveCallExpression(f.getParameters()[0].type(), name, inner, true, true);
|
||||
if (u == null)
|
||||
continue;
|
||||
if (result != null)
|
||||
throw new RuntimeException("Ambiguity");
|
||||
result = new CallExpression(f, new Expression[]{u});
|
||||
}
|
||||
if (result != null) {
|
||||
this.log("[DEBUG] resolved function %s with args %s to type %s using only final cast",
|
||||
name, inner, targetType);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = this.resolveCallExpressionInternal(targetType, name, inner, true);
|
||||
if (result != null) {
|
||||
this.log("[DEBUG] resolved function %s with args %s to type %s using implicit inner casts",
|
||||
name, inner, targetType);
|
||||
} else {
|
||||
this.log("[DEBUG] failed to resolve function %s with args %s to type %s",
|
||||
name, inner, targetType);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> extractLogs() {
|
||||
List<String> old = this.logs;
|
||||
this.clearLogs();
|
||||
return old;
|
||||
}
|
||||
|
||||
public void clearLogs() {
|
||||
this.logs = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void log(String str) {
|
||||
if (this.enableDebugging)
|
||||
this.logs.add(str);
|
||||
}
|
||||
|
||||
private void log(String str, Object... args) {
|
||||
if (this.enableDebugging)
|
||||
this.logs.add(String.format(str, args));
|
||||
}
|
||||
|
||||
private void log(Supplier<String> str) {
|
||||
if (this.enableDebugging)
|
||||
this.log(str.get());
|
||||
}
|
||||
|
||||
private Expression resolveExpressionInternal(
|
||||
Type targetType,
|
||||
ExpressionElement expression,
|
||||
boolean allowNonImplicit,
|
||||
boolean allowImplicit) {
|
||||
Expression castable;
|
||||
Type innerType;
|
||||
|
||||
this.log("[DEBUG] resolving %s to type %s (%d%d)",
|
||||
expression, targetType, allowNonImplicit ? 1 : 0, allowImplicit ? 1 : 0);
|
||||
|
||||
if (expression instanceof UnaryExpressionElement token) {
|
||||
return this.resolveCallExpression(targetType, token.op().name(), Collections.singletonList(token.inner()),
|
||||
allowNonImplicit, allowImplicit);
|
||||
} else if (expression instanceof BinaryExpressionElement token) {
|
||||
return this.resolveCallExpression(targetType, token.op().name(), Arrays.asList(token.left(), token.right()),
|
||||
allowNonImplicit, allowImplicit);
|
||||
} else if (expression instanceof FunctionCall token) {
|
||||
return this.resolveCallExpression(targetType, token.id(), token.args(),
|
||||
allowNonImplicit, allowImplicit);
|
||||
} else if (expression instanceof AccessExpressionElement token) {
|
||||
return this.resolveCallExpression(targetType, "<access$" + token.index() + ">",
|
||||
Collections.singletonList(token.base()),
|
||||
allowNonImplicit, allowImplicit);
|
||||
} else if (expression instanceof NumberToken token) {
|
||||
ConstantExpression exp = this.resolveNumber(token.getNumber());
|
||||
if (exp.getType().equals(targetType)) {
|
||||
this.log("[DEBUG] resolved constant %s to type %s", token.getNumber(), targetType);
|
||||
return exp;
|
||||
}
|
||||
// TODO: implicit casting is split up too much
|
||||
if (!allowImplicit) {
|
||||
this.log("[DEBUG] failed to resolve constant %s (of type %s) to type %s without implicit casts",
|
||||
token.getNumber(), exp.getType(), targetType);
|
||||
return null;
|
||||
}
|
||||
this.log("[DEBUG] trying implicit casts to resolve constant %s (of type %s) to type %s",
|
||||
token.getNumber(), exp.getType(), targetType);
|
||||
castable = exp;
|
||||
innerType = exp.getType();
|
||||
} else if (expression instanceof IdToken token) {
|
||||
final String name = token.getId();
|
||||
Type type = this.variableTypeMap.apply(name);
|
||||
if (type == null)
|
||||
throw new RuntimeException("Unknown variable: " + name);
|
||||
if (type.equals(targetType)) {
|
||||
log("[DEBUG] resolved variable %s to type %s", name, targetType);
|
||||
// TODO: We should add a variable provider (and have this as default)
|
||||
// doing so would remove the need for a FunctionContext.
|
||||
return new VariableExpression() {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext c, FunctionReturn r) {
|
||||
c.getVariable(name).evaluateTo(c, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression partialEval(FunctionContext context, FunctionReturn functionReturn) {
|
||||
return context.hasVariable(name) ? context.getVariable(name) : this;
|
||||
}
|
||||
};
|
||||
}
|
||||
if (!allowImplicit) {
|
||||
log("[DEBUG] failed to resolve variable %s (of type %s) to type %s without implicit casts",
|
||||
name, type, targetType);
|
||||
return null;
|
||||
}
|
||||
// TODO duplicate of above
|
||||
castable = new VariableExpression() {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext c, FunctionReturn r) {
|
||||
c.getVariable(name).evaluateTo(c, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Expression partialEval(FunctionContext context, FunctionReturn functionReturn) {
|
||||
return context.hasVariable(name) ? context.getVariable(name) : this;
|
||||
}
|
||||
};
|
||||
innerType = type;
|
||||
} else {
|
||||
throw new RuntimeException("unexpected token: " + expression.toString());
|
||||
}
|
||||
|
||||
List<? extends TypedFunction> casts = this.functionResolver.resolve("<cast>", targetType);
|
||||
|
||||
for (TypedFunction f : casts) {
|
||||
if (f.getParameters()[0].type().equals(innerType)) {
|
||||
this.log("[DEBUG] resolved %s to type %s using implicit casts",
|
||||
expression, targetType);
|
||||
return new CallExpression(f, new Expression[]{castable});
|
||||
}
|
||||
}
|
||||
this.log("[DEBUG] failed to resolved %s to type %s, even using implicit casts", expression, targetType);
|
||||
return null;
|
||||
}
|
||||
|
||||
private ConstantExpression resolveNumber(String s) {
|
||||
return this.numbers.computeIfAbsent(s, str -> {
|
||||
NumberFormatException p;
|
||||
try {
|
||||
final int val;
|
||||
if (str.length() >= 2 && str.charAt(0) == '0') {
|
||||
switch (str.charAt(1)) {
|
||||
case 'b': {
|
||||
val = Integer.parseInt(str.substring(2), 2);
|
||||
break;
|
||||
}
|
||||
case 'x': {
|
||||
val = Integer.parseInt(str.substring(2), 16);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
val = Integer.parseInt(str.substring(1), 8);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
val = Integer.parseInt(str);
|
||||
|
||||
return new ConstantExpression(Type.Int) {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.intReturn = val;
|
||||
}
|
||||
};
|
||||
} catch (NumberFormatException ex) {
|
||||
p = ex;
|
||||
}
|
||||
|
||||
try {
|
||||
final float res = Float.parseFloat(str);
|
||||
return new ConstantExpression(Type.Float) {
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
functionReturn.floatReturn = res;
|
||||
}
|
||||
};
|
||||
} catch (NumberFormatException ex) {
|
||||
RuntimeException exception = new RuntimeException("Illegal number: " + str, ex);
|
||||
exception.addSuppressed(p);
|
||||
throw exception;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,7 +17,7 @@ public class ChunkModelVertexTransformer extends AbstractVertexTransformer<Model
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
this.delegate.writeQuad(x + this.offset.x, y + this.offset.y, z + this.offset.z, color, u, v, light);
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
this.delegate.writeQuad(x + this.offset.x, y + this.offset.y, z + this.offset.z, color, u, v, light, shaderBlockId);
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -12,6 +12,7 @@ public interface ModelVertexSink extends VertexSink {
|
||||
* @param u The u-texture of the vertex
|
||||
* @param v The y-texture of the vertex
|
||||
* @param light The packed light-map coordinates of the vertex
|
||||
* @param shaderBlockId The blockId to be passed to the shader
|
||||
*/
|
||||
void writeQuad(float x, float y, float z, int color, float u, float v, int light);
|
||||
void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId);
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class HFPModelVertexBufferWriterNio extends VertexBufferWriterNio impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
this.writeQuadInternal(
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(x),
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(y),
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class HFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
this.writeQuadInternal(
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(x),
|
||||
ModelVertexUtil.denormalizeVertexPositionFloatAsShort(y),
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public class SFPModelVertexBufferWriterNio extends VertexBufferWriterNio impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
int i = this.writeOffset;
|
||||
|
||||
ByteBuffer buffer = this.byteBuffer;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ public class SFPModelVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light) {
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int shaderBlockId) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
|
||||
+18
-2
@@ -2,6 +2,7 @@ package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionDataBuilder;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -36,6 +37,7 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -155,6 +157,11 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
for (int relZ = 0; relZ < 16; relZ++) {
|
||||
for (int relX = 0; relX < 16; relX++) {
|
||||
Fluid fluid = null;
|
||||
if (ModStatus.isFluidLoggedLoaded) {
|
||||
fluid = slice.getFluidRelative(relX + 16, relY + 16, relZ + 16);
|
||||
}
|
||||
|
||||
final Block block = slice.getBlockRelative(relX + 16, relY + 16, relZ + 16);
|
||||
|
||||
// If the block is vanilla air, assume it renders nothing. Don't use isAir because mods
|
||||
@@ -172,10 +179,18 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
if (rendersOffThread(block)) {
|
||||
// Do regular block rendering
|
||||
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
|
||||
if (ModStatus.isFluidLoggedLoaded) {
|
||||
if (fluid != null && canRenderInPass(fluid.getBlock(), pass)) {
|
||||
ChunkRenderManager.setWorldRenderPass(pass);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(fluid.getBlock(), ExtendedDataHelper.FLUID_RENDER_TYPE);
|
||||
|
||||
cache.getBlockRenderer().renderFluidLogged(fluid, renderBlocks, pos, buffers.get(pass), seed);
|
||||
}
|
||||
}
|
||||
if (canRenderInPass(block, pass) && !shouldUseSodiumFluidRendering(block)) {
|
||||
ChunkRenderManager.setWorldRenderPass(pass);
|
||||
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
|
||||
|
||||
if (cache.getBlockRenderer().renderModel(cache.getWorldSlice(), renderBlocks, block, meta, pos, buffers.get(pass), true, seed)) {
|
||||
@@ -183,6 +198,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
mainThreadBlocks.enqueue(pos.asLong());
|
||||
hasMainThreadBlocks = true;
|
||||
@@ -339,6 +355,6 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
}
|
||||
|
||||
private static boolean shouldUseSodiumFluidRendering(Block block) {
|
||||
return AngelicaConfig.enableSodiumFluidRendering && WorldUtil.isFluidBlock(block);
|
||||
return AngelicaConfig.enableSodiumFluidRendering && WorldUtil.isFluidBlock(block) && !ModStatus.isFluidLoggedLoaded;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
@@ -62,13 +63,54 @@ public class BlockRenderer {
|
||||
this.occlusionCache = new BlockOcclusionCache();
|
||||
}
|
||||
|
||||
public boolean renderFluidLogged(Fluid fluid, RenderBlocks renderBlocks, BlockPos pos, ChunkModelBuffers buffers, long seed) {
|
||||
if (fluid == null) {
|
||||
return false;
|
||||
}
|
||||
Block block = fluid.getBlock();
|
||||
if (block == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean rendered = false;
|
||||
|
||||
try {
|
||||
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
|
||||
final LightPipeline lighter = this.lighters.getLighter(mode);
|
||||
|
||||
TessellatorManager.startCapturing();
|
||||
final CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get();
|
||||
tess.startDrawingQuads();
|
||||
// Use setTranslation rather than setOffset so that the float data written to the internal buffer
|
||||
// is done in subchunk-relative coordinates
|
||||
tess.setOffset(POS_ZERO);
|
||||
tess.setTranslation(-pos.x, -pos.y, -pos.z);
|
||||
renderBlocks.renderBlockByRenderType(block, pos.x, pos.y, pos.z);
|
||||
final List<QuadView> quads = TessellatorManager.stopCapturingToPooledQuads();
|
||||
tess.resetOffset();
|
||||
|
||||
for (ModelQuadFacing facing : ModelQuadFacing.VALUES) {
|
||||
this.random.setSeed(seed);
|
||||
this.renderQuadList(pos, lighter, buffers, quads, facing, (this.useAmbientOcclusion && this.useSodiumAO));
|
||||
}
|
||||
|
||||
if (!quads.isEmpty()) rendered = true;
|
||||
} finally {
|
||||
TessellatorManager.cleanup();
|
||||
}
|
||||
|
||||
return rendered;
|
||||
|
||||
}
|
||||
|
||||
public boolean renderModel(IBlockAccess world, RenderBlocks renderBlocks, Block block, int meta, BlockPos pos, ChunkModelBuffers buffers, boolean cull, long seed) {
|
||||
final LightMode mode = LightMode.SMOOTH; // TODO: this.getLightingMode(block); is what was previously used. The flat pipeline is busted and was only an optimization for very few blocks.
|
||||
final LightPipeline lighter = this.lighters.getLighter(mode);
|
||||
|
||||
boolean rendered = false;
|
||||
|
||||
this.useSeparateAo = AngelicaConfig.enableIris && BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
|
||||
|
||||
boolean rendered = false;
|
||||
final QuadProvider model = ((ModeledBlock) block).getModel();
|
||||
|
||||
if (model != null) {
|
||||
@@ -150,6 +192,7 @@ public class BlockRenderer {
|
||||
|
||||
final ModelQuadOrientation order = (useSodiumLight || this.useSeparateAo) ? ModelQuadOrientation.orient(light.br) : ModelQuadOrientation.NORMAL;
|
||||
|
||||
int shaderBlockId = quad.getShaderBlockId();
|
||||
for (int dstIndex = 0; dstIndex < 4; dstIndex++) {
|
||||
final int srcIndex = order.getVertexIndex(dstIndex);
|
||||
|
||||
@@ -173,7 +216,7 @@ public class BlockRenderer {
|
||||
final int lm = (useSeparateAo) ? ModelQuadUtil.mergeBakedLight(quad.getLight(srcIndex), light.lm[srcIndex]) :
|
||||
(useSodiumLight) ? light.lm[srcIndex] : quad.getLight(srcIndex);
|
||||
|
||||
sink.writeQuad(x, y, z, color, u, v, lm);
|
||||
sink.writeQuad(x, y, z, color, u, v, lm, shaderBlockId);
|
||||
}
|
||||
|
||||
final TextureAtlasSprite sprite = quad.rubidium$getSprite();
|
||||
|
||||
@@ -405,7 +405,7 @@ public class FluidRenderer {
|
||||
|
||||
int light = this.quadLightData.lm[vertexIdx];
|
||||
|
||||
sink.writeQuad(x, y, z, color, u, v, light);
|
||||
sink.writeQuad(x, y, z, color, u, v, light, -1);
|
||||
|
||||
vertexIdx += lightOrder;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,16 @@ package me.jellysquid.mods.sodium.client.world;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.gtnewhorizons.angelica.api.IBlockAccessExtended;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSection;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ClonedChunkSectionCache;
|
||||
import mega.fluidlogged.api.FLBlockAccess;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -24,6 +27,8 @@ import net.minecraft.world.chunk.NibbleArray;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraft.world.gen.structure.StructureBoundingBox;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Takes a slice of world state (block states, biome and light data arrays) and copies the data for use in off-thread
|
||||
@@ -35,7 +40,8 @@ import net.minecraftforge.common.util.ForgeDirection;
|
||||
*
|
||||
* Object pooling should be used to avoid huge allocations as this class contains many large arrays.
|
||||
*/
|
||||
public class WorldSlice implements IBlockAccessExtended {
|
||||
@Optional.Interface(iface = "mega.fluidlogged.api.FLBlockAccess", modid = "fluidlogged")
|
||||
public class WorldSlice implements IBlockAccessExtended, FLBlockAccess {
|
||||
private static final EnumSkyBlock[] LIGHT_TYPES = EnumSkyBlock.values();
|
||||
|
||||
// The number of blocks on each axis in a section.
|
||||
@@ -68,6 +74,7 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
|
||||
// Local Section->BlockState table.
|
||||
private final Block[][] blockArrays;
|
||||
private final Fluid[][] fluidArrays;
|
||||
private final int[][] metadataArrays;
|
||||
|
||||
// Local Section->Light table
|
||||
@@ -145,6 +152,12 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
this.biomeData = new BiomeGenBase[SECTION_TABLE_ARRAY_SIZE][];
|
||||
this.lightArrays = new NibbleArray[SECTION_TABLE_ARRAY_SIZE][LIGHT_TYPES.length];
|
||||
|
||||
if (ModStatus.isFluidLoggedLoaded) {
|
||||
this.fluidArrays = new Fluid[SECTION_TABLE_ARRAY_SIZE][];
|
||||
} else {
|
||||
this.fluidArrays = null;
|
||||
}
|
||||
|
||||
for (int x = 0; x < SECTION_LENGTH; x++) {
|
||||
for (int y = 0; y < SECTION_LENGTH; y++) {
|
||||
for (int z = 0; z < SECTION_LENGTH; z++) {
|
||||
@@ -152,6 +165,10 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
this.blockArrays[i] = new Block[SECTION_BLOCK_COUNT];
|
||||
Arrays.fill(this.blockArrays[i], Blocks.air);
|
||||
this.metadataArrays[i] = new int[SECTION_BLOCK_COUNT];
|
||||
|
||||
if (ModStatus.isFluidLoggedLoaded && this.fluidArrays != null) {
|
||||
this.fluidArrays[i] = new Fluid[SECTION_BLOCK_COUNT];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,6 +192,11 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
final ClonedChunkSection section = this.sections[idx];
|
||||
|
||||
this.unpackBlockData(this.blockArrays[idx], this.metadataArrays[idx], section, context.getVolume());
|
||||
|
||||
if (ModStatus.isFluidLoggedLoaded) {
|
||||
this.unpackFluidLoggedData(this.fluidArrays[idx], section, context.getVolume());
|
||||
}
|
||||
|
||||
this.biomeData[idx] = section.getBiomeData();
|
||||
|
||||
this.lightArrays[idx][EnumSkyBlock.Block.ordinal()] = section.getLightArray(EnumSkyBlock.Block);
|
||||
@@ -191,8 +213,8 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
return (15 << 20) | (min << 4);
|
||||
}
|
||||
|
||||
final int skyBrightness = this.getSkyBlockTypeBrightness(net.minecraft.world.EnumSkyBlock.Sky, x, y, z);
|
||||
int blockBrightness = this.getSkyBlockTypeBrightness(net.minecraft.world.EnumSkyBlock.Block, x, y, z);
|
||||
final int skyBrightness = this.getSkyBlockTypeBrightness(EnumSkyBlock.Sky, x, y, z);
|
||||
int blockBrightness = this.getSkyBlockTypeBrightness(EnumSkyBlock.Block, x, y, z);
|
||||
|
||||
if (blockBrightness < min) {
|
||||
blockBrightness = min;
|
||||
@@ -265,6 +287,14 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
return getBlock(x, y, z).isSideSolid(this, x, y, z, side);
|
||||
}
|
||||
|
||||
private void unpackFluidLoggedData(Fluid[] fluids, ClonedChunkSection section, StructureBoundingBox box) {
|
||||
if (this.origin.equals(section.getPosition())) {
|
||||
this.unpackFluidLoggedDataZ(fluids, section);
|
||||
} else {
|
||||
this.unpackFluidLoggedDataR(fluids, section, box);
|
||||
}
|
||||
}
|
||||
|
||||
private void unpackBlockData(Block[] blocks, int[] metas, ClonedChunkSection section, StructureBoundingBox box) {
|
||||
if (this.origin.equals(section.getPosition())) {
|
||||
this.unpackBlockDataZ(blocks, metas, section);
|
||||
@@ -273,6 +303,48 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
}
|
||||
}
|
||||
|
||||
private void unpackFluidLoggedDataR(Fluid[] fluids, ClonedChunkSection section, StructureBoundingBox box) {
|
||||
final ChunkSectionPos pos = section.getPosition();
|
||||
|
||||
final int minBlockX = Math.max(box.minX, pos.getMinX());
|
||||
final int maxBlockX = Math.min(box.maxX, pos.getMaxX());
|
||||
|
||||
final int minBlockY = Math.max(box.minY, pos.getMinY());
|
||||
final int maxBlockY = Math.min(box.maxY, pos.getMaxY());
|
||||
|
||||
final int minBlockZ = Math.max(box.minZ, pos.getMinZ());
|
||||
final int maxBlockZ = Math.min(box.maxZ, pos.getMaxZ());
|
||||
|
||||
copyFluids(fluids, section, minBlockY, maxBlockY, minBlockZ, maxBlockZ, minBlockX, maxBlockX);
|
||||
}
|
||||
|
||||
private void unpackFluidLoggedDataZ(Fluid[] fluids, ClonedChunkSection section) {
|
||||
// TODO: Look into a faster copy for this?
|
||||
final ChunkSectionPos pos = section.getPosition();
|
||||
|
||||
final int minBlockX = pos.getMinX();
|
||||
final int maxBlockX = pos.getMaxX();
|
||||
|
||||
final int minBlockY = pos.getMinY();
|
||||
final int maxBlockY = pos.getMaxY();
|
||||
|
||||
final int minBlockZ = pos.getMinZ();
|
||||
final int maxBlockZ = pos.getMaxZ();
|
||||
|
||||
// TODO: Can this be optimized?
|
||||
copyFluids(fluids, section, minBlockY, maxBlockY, minBlockZ, maxBlockZ, minBlockX, maxBlockX);
|
||||
}
|
||||
|
||||
private static void copyFluids(Fluid[] fluids, ClonedChunkSection section, int minBlockY, int maxBlockY, int minBlockZ, int maxBlockZ, int minBlockX, int maxBlockX) {
|
||||
for (int y = minBlockY; y <= maxBlockY; y++) {
|
||||
for (int z = minBlockZ; z <= maxBlockZ; z++) {
|
||||
for (int x = minBlockX; x <= maxBlockX; x++) {
|
||||
final int blockIdx = getLocalBlockIndex(x & 15, y & 15, z & 15);
|
||||
fluids[blockIdx] = section.getFluid(x & 15, y & 15, z & 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copyBlocks(Block[] blocks, int[] metas, ClonedChunkSection section, int minBlockY, int maxBlockY, int minBlockZ, int maxBlockZ, int minBlockX, int maxBlockX) {
|
||||
for (int y = minBlockY; y <= maxBlockY; y++) {
|
||||
@@ -419,4 +491,23 @@ public class WorldSlice implements IBlockAccessExtended {
|
||||
z >= box.minZ &&
|
||||
z <= box.maxZ;
|
||||
}
|
||||
|
||||
public @Nullable Fluid fl$getFluid(int x, int y, int z) {
|
||||
if (!blockBoxContains(this.volume, x, y, z)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final int relX = x - this.baseX;
|
||||
final int relY = y - this.baseY;
|
||||
final int relZ = z - this.baseZ;
|
||||
return this.fluidArrays[getLocalSectionIndex(relX >> 4, relY >> 4, relZ >> 4)][getLocalBlockIndex(relX & 15, relY & 15, relZ & 15)];
|
||||
}
|
||||
|
||||
public Fluid getFluidRelative(int x, int y, int z) {
|
||||
return this.fluidArrays[getLocalSectionIndex(x >> 4, y >> 4, z >> 4)][getLocalBlockIndex(x & 15, y & 15, z & 15)];
|
||||
}
|
||||
|
||||
public void fl$setFluid(int x, int y, int z, @Nullable Fluid fluid) {
|
||||
throw new UnsupportedOperationException("Cannot set fluids in a world slice. WorldSlice is read-only");
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import mega.fluidlogged.internal.mixin.hook.FLSubChunk;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
@@ -15,6 +16,7 @@ import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -102,6 +104,14 @@ public class ClonedChunkSection {
|
||||
return data.getBlockByExtId(x, y, z);
|
||||
}
|
||||
|
||||
public Fluid getFluid(int x, int y, int z) {
|
||||
if (ModStatus.isFluidLoggedLoaded) {
|
||||
return ((FLSubChunk) data).fl$getFluid(x, y, z);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getBlockMetadata(int x, int y, int z) {
|
||||
return data.getExtBlockMetadata(x, y, z);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package net.coderbot.iris;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator;
|
||||
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;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.config.IrisConfig;
|
||||
import net.coderbot.iris.gl.shader.StandardMacros;
|
||||
import net.coderbot.iris.gui.screen.ShaderPackScreen;
|
||||
@@ -24,7 +29,9 @@ import net.coderbot.iris.shaderpack.option.OptionSet;
|
||||
import net.coderbot.iris.shaderpack.option.Profile;
|
||||
import net.coderbot.iris.shaderpack.option.values.MutableOptionValues;
|
||||
import net.coderbot.iris.shaderpack.option.values.OptionValues;
|
||||
import net.coderbot.iris.sodium.block_context.BlockContextHolder;
|
||||
import net.coderbot.iris.texture.pbr.PBRTextureManager;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
@@ -639,4 +646,36 @@ public class Iris {
|
||||
ClientRegistry.registerKeyBinding(toggleShadersKeybind);
|
||||
ClientRegistry.registerKeyBinding(shaderpackScreenKeybind);
|
||||
}
|
||||
|
||||
static BlockContextHolder contextHolder;
|
||||
|
||||
private static int getShaderMaterialOverrideId(Block block, int meta) {
|
||||
if (contextHolder == null) {
|
||||
final Object2IntMap<Block> blockMatches = BlockRenderingSettings.INSTANCE.getBlockMatches();
|
||||
if (blockMatches == null) {
|
||||
return -1;
|
||||
}
|
||||
contextHolder = new BlockContextHolder(blockMatches);
|
||||
|
||||
}
|
||||
contextHolder.set(block, (short) block.getRenderType());
|
||||
return contextHolder.blockId;
|
||||
}
|
||||
|
||||
public static void setShaderMaterialOverride(Block block, int meta) {
|
||||
if (!AngelicaConfig.enableIris)
|
||||
return;
|
||||
|
||||
int blockId = getShaderMaterialOverrideId(block, meta);
|
||||
|
||||
if (TessellatorManager.get() instanceof CapturingTessellator tess)
|
||||
tess.setShaderBlockId(blockId);
|
||||
}
|
||||
|
||||
public static void resetShaderMaterialOverride() {
|
||||
if (!AngelicaConfig.enableIris)
|
||||
return;
|
||||
if (TessellatorManager.get() instanceof CapturingTessellator tess)
|
||||
tess.setShaderBlockId(-1);
|
||||
}
|
||||
}
|
||||
@@ -57,12 +57,15 @@ public final class ComputeProgram extends GlResource {
|
||||
return cachedWorkGroups;
|
||||
}
|
||||
|
||||
public void dispatch(float width, float height) {
|
||||
GL20.glUseProgram(getGlId());
|
||||
uniforms.update();
|
||||
samplers.update();
|
||||
images.update();
|
||||
public void use() {
|
||||
GL20.glUseProgram(getGlId());
|
||||
|
||||
uniforms.update();
|
||||
samplers.update();
|
||||
images.update();
|
||||
}
|
||||
|
||||
public void dispatch(float width, float height) {
|
||||
if (!Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::allowConcurrentCompute).orElse(false)) {
|
||||
RenderSystem.memoryBarrier(40);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import net.coderbot.iris.gl.uniform.DynamicLocationalUniformHolder;
|
||||
@@ -20,6 +22,7 @@ import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
|
||||
import net.coderbot.iris.uniforms.SystemTimeUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import org.joml.Vector3i;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.ARBShaderImageLoadStore;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -172,8 +175,7 @@ public class ProgramUniforms {
|
||||
return OptionalInt.empty();
|
||||
}
|
||||
|
||||
// TODO: Temporary hack until custom uniforms are merged.
|
||||
if ((!locations.containsKey(id) && !uniformNames.containsKey(name)) || name.equals("framemod8")) {
|
||||
if ((!locations.containsKey(id) && !uniformNames.containsKey(name))) {
|
||||
locations.put(id, name);
|
||||
uniformNames.put(name, type);
|
||||
} else {
|
||||
@@ -240,12 +242,6 @@ public class ProgramUniforms {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO: This is an absolutely horrific hack, but is needed until custom uniforms work.
|
||||
if ("framemod8".equals(name) && expected == UniformType.FLOAT && provided == UniformType.INT) {
|
||||
SystemTimeUniforms.addFloatFrameMod8Uniform(this);
|
||||
provided = UniformType.FLOAT;
|
||||
}
|
||||
|
||||
if (provided != null && provided != expected) {
|
||||
String expectedName;
|
||||
|
||||
@@ -283,7 +279,7 @@ public class ProgramUniforms {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public UniformHolder externallyManagedUniform(String name, UniformType type) {
|
||||
externalUniformNames.put(name, type);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.coderbot.iris.gl.uniform;
|
||||
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector3i;
|
||||
import org.joml.Vector4f;
|
||||
import org.joml.Vector4i;
|
||||
|
||||
@@ -42,12 +43,23 @@ public interface DynamicLocationalUniformHolder extends LocationalUniformHolder,
|
||||
return this;
|
||||
}
|
||||
|
||||
default DynamicUniformHolder uniform3i(String name, Supplier<Vector3i> value, ValueUpdateNotifier notifier) {
|
||||
location(name, UniformType.VEC3I).ifPresent(id -> addDynamicUniform(new Vector3IntegerJomlUniform(id, value, notifier), notifier));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
default DynamicUniformHolder uniform4f(String name, Supplier<Vector4f> value, ValueUpdateNotifier notifier) {
|
||||
location(name, UniformType.VEC4).ifPresent(id -> addDynamicUniform(new Vector4Uniform(id, value, notifier), notifier));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
default DynamicUniformHolder uniform4fArray(String name, Supplier<float[]> value, ValueUpdateNotifier notifier) {
|
||||
location(name, UniformType.VEC4).ifPresent(id -> addDynamicUniform(new Vector4ArrayUniform(id, value, notifier), notifier));
|
||||
return this;
|
||||
}
|
||||
|
||||
default DynamicUniformHolder uniform4i(String name, Supplier<Vector4i> value, ValueUpdateNotifier notifier) {
|
||||
location(name, UniformType.VEC4I).ifPresent(id -> addDynamicUniform(new Vector4IntegerJomlUniform(id, value, notifier), notifier));
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.coderbot.iris.gl.uniform;
|
||||
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector3i;
|
||||
import org.joml.Vector4f;
|
||||
import org.joml.Vector4i;
|
||||
|
||||
@@ -15,6 +16,8 @@ public interface DynamicUniformHolder extends UniformHolder {
|
||||
DynamicUniformHolder uniform1f(String name, DoubleSupplier value, ValueUpdateNotifier notifier);
|
||||
DynamicUniformHolder uniform1i(String name, IntSupplier value, ValueUpdateNotifier notifier);
|
||||
DynamicUniformHolder uniform2i(String name, Supplier<Vector2i> value, ValueUpdateNotifier notifier);
|
||||
DynamicUniformHolder uniform3i(String name, Supplier<Vector3i> value, ValueUpdateNotifier notifier);
|
||||
DynamicUniformHolder uniform4f(String name, Supplier<Vector4f> value, ValueUpdateNotifier notifier);
|
||||
DynamicUniformHolder uniform4fArray(String name, Supplier<float[]> value, ValueUpdateNotifier notifier);
|
||||
DynamicUniformHolder uniform4i(String name, Supplier<Vector4i> value, ValueUpdateNotifier notifier);
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import org.joml.Vector2f;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.util.OptionalInt;
|
||||
@@ -75,6 +76,13 @@ public interface LocationalUniformHolder extends UniformHolder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
default LocationalUniformHolder uniform3i(UniformUpdateFrequency updateFrequency, String name, Supplier<Vector3i> value) {
|
||||
location(name, UniformType.VEC3I).ifPresent(id -> addUniform(updateFrequency, new Vector3IntegerJomlUniform(id, value)));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
default LocationalUniformHolder uniformVanilla3f(UniformUpdateFrequency updateFrequency, String name, Supplier<Vec3> value) {
|
||||
location(name, UniformType.VEC3).ifPresent(id -> addUniform(updateFrequency, new VanillaVector3Uniform(id, value)));
|
||||
@@ -103,6 +111,13 @@ public interface LocationalUniformHolder extends UniformHolder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
default LocationalUniformHolder uniform4fArray(UniformUpdateFrequency updateFrequency, String name, Supplier<float[]> value) {
|
||||
location(name, UniformType.VEC4).ifPresent(id -> addUniform(updateFrequency, new Vector4ArrayUniform(id, value)));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
default LocationalUniformHolder uniformMatrix(UniformUpdateFrequency updateFrequency, String name, Supplier<Matrix4f> value) {
|
||||
location(name, UniformType.MAT4).ifPresent(id -> addUniform(updateFrequency, new MatrixUniform(id, value)));
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.joml.Vector2f;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3i;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
@@ -30,6 +31,8 @@ public interface UniformHolder {
|
||||
|
||||
UniformHolder uniform3f(UniformUpdateFrequency updateFrequency, String name, Supplier<Vector3f> value);
|
||||
|
||||
UniformHolder uniform3i(UniformUpdateFrequency updateFrequency, String name, Supplier<Vector3i> value);
|
||||
|
||||
UniformHolder uniformVanilla3f(UniformUpdateFrequency updateFrequency, String name, Supplier<Vec3> value);
|
||||
|
||||
UniformHolder uniformTruncated3f(UniformUpdateFrequency updateFrequency, String name, Supplier<Vector4f> value);
|
||||
@@ -38,6 +41,8 @@ public interface UniformHolder {
|
||||
|
||||
UniformHolder uniform4f(UniformUpdateFrequency updateFrequency, String name, Supplier<Vector4f> value);
|
||||
|
||||
UniformHolder uniform4fArray(UniformUpdateFrequency updateFrequency, String name, Supplier<float[]> value);
|
||||
|
||||
UniformHolder uniformMatrix(UniformUpdateFrequency updateFrequency, String name, Supplier<Matrix4f> value);
|
||||
|
||||
UniformHolder uniformMatrixFromArray(UniformUpdateFrequency updateFrequency, String name, Supplier<float[]> value);
|
||||
|
||||
@@ -7,6 +7,7 @@ public enum UniformType {
|
||||
VEC2,
|
||||
VEC2I,
|
||||
VEC3,
|
||||
VEC3I,
|
||||
VEC4,
|
||||
VEC4I
|
||||
}
|
||||
@@ -3,5 +3,6 @@ package net.coderbot.iris.gl.uniform;
|
||||
public enum UniformUpdateFrequency {
|
||||
ONCE,
|
||||
PER_TICK,
|
||||
PER_FRAME
|
||||
PER_FRAME,
|
||||
CUSTOM
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.coderbot.iris.gl.uniform;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Vector3IntegerJomlUniform extends Uniform {
|
||||
private Vector3i cachedValue;
|
||||
private final Supplier<Vector3i> value;
|
||||
|
||||
Vector3IntegerJomlUniform(int location, Supplier<Vector3i> value) {
|
||||
this(location, value, null);
|
||||
}
|
||||
|
||||
Vector3IntegerJomlUniform(int location, Supplier<Vector3i> value, ValueUpdateNotifier notifier) {
|
||||
super(location, notifier);
|
||||
|
||||
this.cachedValue = null;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
updateValue();
|
||||
|
||||
if (notifier != null) {
|
||||
notifier.setListener(this::updateValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateValue() {
|
||||
Vector3i newValue = value.get();
|
||||
|
||||
if (cachedValue == null || !newValue.equals(cachedValue)) {
|
||||
cachedValue = newValue;
|
||||
RenderSystem.uniform3i(this.location, newValue.x, newValue.y, newValue.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.coderbot.iris.gl.uniform;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Vector4ArrayUniform extends Uniform {
|
||||
private final Supplier<float[]> value;
|
||||
private float[] cachedValue;
|
||||
|
||||
Vector4ArrayUniform(int location, Supplier<float[]> value) {
|
||||
this(location, value, null);
|
||||
}
|
||||
|
||||
Vector4ArrayUniform(int location, Supplier<float[]> value, ValueUpdateNotifier notifier) {
|
||||
super(location, notifier);
|
||||
|
||||
this.cachedValue = new float[4];
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
updateValue();
|
||||
|
||||
if (notifier != null) {
|
||||
notifier.setListener(this::updateValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateValue() {
|
||||
float[] newValue = value.get();
|
||||
|
||||
if (!Arrays.equals(newValue, cachedValue)) {
|
||||
cachedValue = newValue;
|
||||
RenderSystem.uniform4f(location, cachedValue[0], cachedValue[1], cachedValue[2], cachedValue[3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.coderbot.iris.gui.screen;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gui.GuiUtil;
|
||||
@@ -21,6 +22,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@@ -90,6 +92,8 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
}
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
GLStateManager.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if(dirty) {
|
||||
dirty = false;
|
||||
this.initGui();
|
||||
@@ -167,6 +171,8 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
} else {
|
||||
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 10, 0xFFFFFF);
|
||||
}
|
||||
|
||||
GLStateManager.glPopAttrib();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.coderbot.iris.parsing;
|
||||
|
||||
public enum BiomeCategories {
|
||||
NONE,
|
||||
TAIGA,
|
||||
EXTREME_HILLS,
|
||||
JUNGLE,
|
||||
MESA,
|
||||
PLAINS,
|
||||
SAVANNA,
|
||||
ICY,
|
||||
THE_END,
|
||||
BEACH,
|
||||
FOREST,
|
||||
OCEAN,
|
||||
DESERT,
|
||||
RIVER,
|
||||
SWAMP,
|
||||
MUSHROOM,
|
||||
NETHER,
|
||||
|
||||
// TODO: This is in Optifine, but undocumented...
|
||||
MOUNTAIN,
|
||||
UNDERGROUND
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package net.coderbot.iris.parsing;
|
||||
|
||||
import kroppeb.stareval.expression.Expression;
|
||||
import kroppeb.stareval.expression.VariableExpression;
|
||||
import kroppeb.stareval.function.FunctionContext;
|
||||
import kroppeb.stareval.function.FunctionReturn;
|
||||
import kroppeb.stareval.function.Type;
|
||||
import kroppeb.stareval.function.TypedFunction;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class BooleanVectorizedFunction implements TypedFunction {
|
||||
final TypedFunction inner;
|
||||
final int size;
|
||||
final Parameter[] parameters;
|
||||
|
||||
private final ElementAccessExpression[] vectorAccessors;
|
||||
private int index;
|
||||
|
||||
public BooleanVectorizedFunction(TypedFunction inner, int size) {
|
||||
this.inner = inner;
|
||||
this.size = size;
|
||||
|
||||
Parameter[] innerTypes = inner.getParameters();
|
||||
this.parameters = new Parameter[innerTypes.length];
|
||||
this.vectorAccessors = new ElementAccessExpression[innerTypes.length];
|
||||
|
||||
for (int i = 0; i < innerTypes.length; i++) {
|
||||
this.parameters[i] = new Parameter(VectorType.of((Type.Primitive) innerTypes[i].type(), size));
|
||||
this.vectorAccessors[i] = new ElementAccessExpression(innerTypes[i].type());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getReturnType() {
|
||||
return Type.Boolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parameter[] getParameters() {
|
||||
return this.parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluateTo(Expression[] params, FunctionContext context, FunctionReturn functionReturn) {
|
||||
for (int p = 0; p < params.length; p++) {
|
||||
final Expression param = params[p];
|
||||
param.evaluateTo(context, functionReturn);
|
||||
this.vectorAccessors[p].vector = functionReturn.objectReturn;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.size; i++) {
|
||||
this.index = i;
|
||||
this.inner.evaluateTo(this.vectorAccessors, context, functionReturn);
|
||||
if (!functionReturn.booleanReturn)
|
||||
return; // if false -> return false
|
||||
}
|
||||
|
||||
// if all true (and thus the last one was true) -> return true
|
||||
}
|
||||
|
||||
class ElementAccessExpression implements Expression {
|
||||
final Type parameterType;
|
||||
Object vector;
|
||||
|
||||
|
||||
ElementAccessExpression(Type parameterType) {
|
||||
this.parameterType = parameterType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluateTo(FunctionContext context, FunctionReturn functionReturn) {
|
||||
parameterType.getValueFromArray(vector, index, functionReturn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void listVariables(Collection<? super VariableExpression> variables) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,53 @@
|
||||
package net.coderbot.iris.parsing;
|
||||
|
||||
import kroppeb.stareval.parser.BinaryOp;
|
||||
import kroppeb.stareval.parser.ParserOptions;
|
||||
import kroppeb.stareval.parser.UnaryOp;
|
||||
|
||||
public class IrisOptions {
|
||||
public static final ParserOptions options;
|
||||
static final BinaryOp Multiply = new BinaryOp("multiply", 0);
|
||||
static final BinaryOp Divide = new BinaryOp("divide", 0);
|
||||
static final BinaryOp Remainder = new BinaryOp("remainder", 0);
|
||||
static final BinaryOp Add = new BinaryOp("add", 1);
|
||||
static final BinaryOp Subtract = new BinaryOp("subtract", 1);
|
||||
static final BinaryOp Equals = new BinaryOp("equals", 2);
|
||||
static final BinaryOp NotEquals = new BinaryOp("notEquals", 2);
|
||||
static final BinaryOp LessThan = new BinaryOp("lessThan", 2);
|
||||
static final BinaryOp MoreThan = new BinaryOp("moreThan", 2);
|
||||
static final BinaryOp LessThanOrEquals = new BinaryOp("lessThanOrEquals", 2);
|
||||
static final BinaryOp MoreThanOrEquals = new BinaryOp("moreThanOrEquals", 2);
|
||||
static final BinaryOp And = new BinaryOp("and", 3);
|
||||
static final BinaryOp Or = new BinaryOp("or", 3);
|
||||
static final UnaryOp Not = new UnaryOp("not");
|
||||
static final UnaryOp Negate = new UnaryOp("negate");
|
||||
|
||||
static {
|
||||
final ParserOptions.Builder builder = new ParserOptions.Builder();
|
||||
builder.addBinaryOp("*", Multiply);
|
||||
builder.addBinaryOp("/", Divide);
|
||||
builder.addBinaryOp("%", Remainder);
|
||||
|
||||
builder.addBinaryOp("+", Add);
|
||||
builder.addBinaryOp("-", Subtract);
|
||||
|
||||
builder.addBinaryOp("==", Equals);
|
||||
builder.addBinaryOp("!=", NotEquals);
|
||||
builder.addBinaryOp("<", LessThan);
|
||||
builder.addBinaryOp(">", MoreThan);
|
||||
builder.addBinaryOp("<=", LessThanOrEquals);
|
||||
builder.addBinaryOp(">=", MoreThanOrEquals);
|
||||
|
||||
builder.addBinaryOp("≠", NotEquals);
|
||||
builder.addBinaryOp("≤", LessThanOrEquals);
|
||||
builder.addBinaryOp("≥", MoreThanOrEquals);
|
||||
|
||||
builder.addBinaryOp("&&", And);
|
||||
builder.addBinaryOp("||", Or);
|
||||
|
||||
builder.addUnaryOp("!", Not);
|
||||
builder.addUnaryOp("-", Negate);
|
||||
|
||||
options = builder.build();
|
||||
}
|
||||
}
|
||||
Loaded 100 of 147 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user