mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-17 19:15:06 +00:00
Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0350ea2cb6 | ||
|
|
bed724ba59 | ||
|
|
6fa973dbc8 | ||
|
|
c4ad460f34 | ||
|
|
2a8404c6c2 | ||
|
|
108db9031b | ||
|
|
d6d8a5dad6 | ||
|
|
ad2b73edf9 | ||
|
|
bb5526598e | ||
|
|
611bbf02c8 | ||
|
|
ca16036604 | ||
|
|
f118211257 | ||
|
|
81d03ea552 | ||
|
|
67c8628aeb | ||
|
|
f9b9873637 | ||
|
|
c66bf8658e | ||
|
|
052824017d | ||
|
|
6a5d914a43 |
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.5.20
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.6.6
|
||||
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
|
||||
+8
-8
@@ -49,7 +49,7 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.22")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.30")
|
||||
|
||||
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.2:dev')
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.6:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.13: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,21 @@ dependencies {
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.27-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.7.29-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.1: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.4:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.5:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.8-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.10-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.2:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.1:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.2:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:Backhand:1.6.11') { 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 }
|
||||
@@ -100,7 +100,7 @@ dependencies {
|
||||
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("com.github.GTNewHorizons:HoloInventory:2.5.1-GTNH:dev")
|
||||
|
||||
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
|
||||
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -86,8 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -206,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.
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.31'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.37'
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IBlockAccessExtended extends IBlockAccess {
|
||||
World getWorld();
|
||||
}
|
||||
@@ -42,8 +42,6 @@ public class BatchingFontRenderer {
|
||||
private int[] colorCode;
|
||||
/** Location of the primary font atlas to bind. */
|
||||
protected final ResourceLocation locationFontTexture;
|
||||
/** The RenderEngine used to load and setup glyph textures. */
|
||||
private final TextureManager renderEngine;
|
||||
private final RandomXoshiro256StarStar fontRandom = new RandomXoshiro256StarStar();
|
||||
|
||||
/** The full list of characters present in the default Minecraft font, excluding the Unicode font */
|
||||
@@ -74,14 +72,13 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
|
||||
public BatchingFontRenderer(FontRenderer underlying, ResourceLocation[] unicodePageLocations, int[] charWidth,
|
||||
byte[] glyphWidth, int[] colorCode, ResourceLocation locationFontTexture, TextureManager renderEngine) {
|
||||
byte[] glyphWidth, int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
this.underlying = underlying;
|
||||
this.unicodePageLocations = unicodePageLocations;
|
||||
this.charWidth = charWidth;
|
||||
this.glyphWidth = glyphWidth;
|
||||
this.colorCode = colorCode;
|
||||
this.locationFontTexture = locationFontTexture;
|
||||
this.renderEngine = renderEngine;
|
||||
|
||||
for (int i = 0; i < 64; i++) {
|
||||
batchCommandPool.add(new FontDrawCmd());
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import com.falsepattern.chunk.api.DataRegistry;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ExtendedBlockStorageAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ExtendedNibbleArray;
|
||||
import com.gtnewhorizons.neid.mixins.interfaces.IExtendedBlockStorageMixin;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
@@ -19,7 +17,7 @@ public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
}
|
||||
|
||||
public ExtendedBlockStorageExt(Chunk chunk, ExtendedBlockStorage storage) {
|
||||
super(((ExtendedBlockStorageAccessor) storage).getYBase(), storage.getSkylightArray() != null);
|
||||
super(storage.yBase, storage.getSkylightArray() != null);
|
||||
|
||||
if (ModStatus.isChunkAPILoaded) {
|
||||
if (storage.getSkylightArray() != null) {
|
||||
@@ -33,7 +31,7 @@ public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
System.arraycopy(((IExtendedBlockStorageMixin)(Object)storage).getBlock16BArray(), 0, block16BArray, 0, block16BArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(block16BArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
copyNibbleArray(storage.getBlockMSBArray(), this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = block16BArray.length;
|
||||
if (ModStatus.isNEIDMetadataExtended) {
|
||||
@@ -52,31 +50,31 @@ public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
System.arraycopy(storage.getBlockLSBArray(), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(blockLSBArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
copyNibbleArray(storage.getBlockMSBArray(), this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
|
||||
|
||||
if (!ModStatus.isNEIDMetadataExtended) copyNibbleArray((ExtendedNibbleArray) storage.getMetadataArray(), (ExtendedNibbleArray)this.getMetadataArray());
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlocklightArray(), (ExtendedNibbleArray)this.getBlocklightArray());
|
||||
if (!ModStatus.isNEIDMetadataExtended) copyNibbleArray(storage.getMetadataArray(), this.getMetadataArray());
|
||||
copyNibbleArray(storage.getBlocklightArray(), this.getBlocklightArray());
|
||||
if(storage.getSkylightArray() != null) {
|
||||
hasSky = true;
|
||||
if(this.getSkylightArray() == null) {
|
||||
this.setSkylightArray(new NibbleArray(arrayLen, 4));
|
||||
}
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getSkylightArray(), (ExtendedNibbleArray) this.getSkylightArray());
|
||||
copyNibbleArray(storage.getSkylightArray(), this.getSkylightArray());
|
||||
}
|
||||
}
|
||||
((ExtendedBlockStorageAccessor) this).setBlockRefCount(((ExtendedBlockStorageAccessor) storage).getBlockRefCount());
|
||||
this.blockRefCount = storage.blockRefCount;
|
||||
}
|
||||
|
||||
|
||||
private static void copyNibbleArray(ExtendedNibbleArray srcArray, ExtendedNibbleArray dstArray) {
|
||||
private static void copyNibbleArray(NibbleArray srcArray, NibbleArray dstArray) {
|
||||
if (srcArray == null || dstArray == null) {
|
||||
throw new RuntimeException("NibbleArray is null src: " + (srcArray == null) + " dst: " + (dstArray == null));
|
||||
}
|
||||
final byte[] data = srcArray.getData();
|
||||
System.arraycopy(data, 0, dstArray.getData(), 0, data.length);
|
||||
final byte[] data = srcArray.data;
|
||||
System.arraycopy(data, 0, dstArray.data, 0, data.length);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.helpers.LoadControllerHelper;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import mods.battlegear2.Battlegear;
|
||||
import net.dries007.holoInventory.HoloInventory;
|
||||
@@ -62,7 +61,7 @@ public class ModStatus {
|
||||
}
|
||||
|
||||
if (isBackhandLoaded){
|
||||
isBackhandLoaded = new DefaultArtifactVersion("1.4.1")
|
||||
isBackhandLoaded = new DefaultArtifactVersion("1.6.9")
|
||||
.compareTo(
|
||||
LoadControllerHelper.getOwningMod(Backhand.class).getProcessedVersion()
|
||||
) <= 0;
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ public class ByteBufferBackedInputStream extends InputStream {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (!buf.hasRemaining()) {
|
||||
return -1;
|
||||
|
||||
@@ -40,6 +40,7 @@ public class ChunkPos {
|
||||
return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int i = 1664525 * this.x + 1013904223;
|
||||
@@ -47,6 +48,7 @@ public class ChunkPos {
|
||||
return i ^ j;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
|
||||
@@ -1,10 +1,24 @@
|
||||
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,
|
||||
OFF_HAND;
|
||||
|
||||
InteractionHand() {
|
||||
}
|
||||
|
||||
public ItemStack getItemInHand(EntityPlayer player){
|
||||
if (ModStatus.isBackhandLoaded && this == InteractionHand.OFF_HAND){ // off hand (requires backhand)
|
||||
return BackhandUtils.getOffhandItem(player);
|
||||
}
|
||||
else { // main hand
|
||||
return player.getHeldItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -10,7 +8,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
|
||||
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -61,15 +59,20 @@ public class NativeImage extends BufferedImage {
|
||||
|
||||
// final int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
|
||||
// final int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
|
||||
try (final MemoryStack stack = stackPush()) {
|
||||
final IntBuffer buffer = stack.mallocInt(size);
|
||||
|
||||
final IntBuffer buffer = MemoryUtilities.memAllocInt(size);
|
||||
|
||||
try {
|
||||
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, format.glFormat, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer);
|
||||
|
||||
int[] data = new int[size];
|
||||
buffer.get(data);
|
||||
setRGB(0, 0, width, height, data, 0, width);
|
||||
} finally {
|
||||
MemoryUtilities.memFree(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeToFile(File file) throws IOException{
|
||||
try {
|
||||
ImageIO.write(this, "png", file);
|
||||
@@ -107,18 +110,15 @@ public class NativeImage extends BufferedImage {
|
||||
|
||||
|
||||
public enum Format {
|
||||
RGBA(4, GL11.GL_RGBA, BufferedImage.TYPE_INT_ARGB),
|
||||
RGB(3, GL11.GL_RGB, BufferedImage.TYPE_INT_RGB);
|
||||
RGBA(4, GL11.GL_RGBA),
|
||||
RGB(3, GL11.GL_RGB);
|
||||
|
||||
private final int components;
|
||||
private final int glFormat;
|
||||
private final int imageType;
|
||||
|
||||
|
||||
Format(int components, int glFormat, int imageType) {
|
||||
Format(int components, int glFormat) {
|
||||
this.components = components;
|
||||
this.glFormat = glFormat;
|
||||
this.imageType = imageType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
|
||||
private final MultiPhaseParameters phases;
|
||||
private final int hash;
|
||||
private final Optional<RenderLayer> affectedOutline;
|
||||
private final boolean outline;
|
||||
|
||||
private MultiPhase(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent, MultiPhaseParameters phases) {
|
||||
super(name, vertexFormat, drawMode, expectedBufferSize, () -> {
|
||||
@@ -84,7 +83,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
|
||||
this.affectedOutline = phases.outlineMode == RenderLayer.OutlineMode.AFFECTS_OUTLINE ? phases.texture.getId().map((arg2) -> {
|
||||
return getOutline(arg2, phases.cull);
|
||||
}) : Optional.empty();
|
||||
this.outline = phases.outlineMode == RenderLayer.OutlineMode.IS_OUTLINE;
|
||||
this.hash = Objects.hash(new Object[]{super.hashCode(), phases});
|
||||
}
|
||||
|
||||
@@ -97,20 +95,23 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
|
||||
return this.affectedOutline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object object) {
|
||||
return this == object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RenderType[" + this.phases + ']';
|
||||
}
|
||||
|
||||
static {
|
||||
CACHE = new ObjectOpenCustomHashSet(RenderLayer.MultiPhase.HashStrategy.INSTANCE);
|
||||
CACHE = new ObjectOpenCustomHashSet<>(RenderLayer.MultiPhase.HashStrategy.INSTANCE);
|
||||
}
|
||||
|
||||
static enum HashStrategy implements Hash.Strategy<MultiPhase> {
|
||||
@@ -168,6 +169,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
|
||||
this.phases = ImmutableList.of(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.fog, this.layering, this.target, this.texturing, this.writeMaskState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
@@ -179,10 +181,12 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(new Object[]{this.phases, this.outlineMode});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CompositeState[" + this.phases + ", outlineProperty=" + this.outlineMode + ']';
|
||||
}
|
||||
@@ -293,6 +297,7 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.lwjgl.opengl.GL11;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalDouble;
|
||||
|
||||
|
||||
public abstract class RenderPhase {
|
||||
@@ -98,6 +97,7 @@ public abstract class RenderPhase {
|
||||
this.endAction.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
@@ -109,10 +109,12 @@ public abstract class RenderPhase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableDebugLogging;
|
||||
|
||||
@Config.Comment("Enables PBR atlas dumping")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.Name("Enable PBR Debug")
|
||||
public static boolean enablePBRDebug;
|
||||
|
||||
@Config.Comment("Enable Zoom")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
|
||||
@@ -18,7 +18,6 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.monster.EntityCreeper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
|
||||
@@ -7,9 +7,11 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -19,21 +21,25 @@ public class Feature {
|
||||
GL13.GL_MULTISAMPLE_BIT, GL11.GL_PIXEL_MODE_BIT, GL11.GL_POINT_BIT, GL11.GL_POLYGON_BIT, GL11.GL_POLYGON_STIPPLE_BIT, GL11.GL_SCISSOR_BIT,
|
||||
GL11.GL_STENCIL_BUFFER_BIT, GL11.GL_TEXTURE_BIT, GL11.GL_TRANSFORM_BIT, GL11.GL_VIEWPORT_BIT };
|
||||
|
||||
static final Int2ObjectMap<Set<IStateStack<?>>> maskToFeaturesMap = new Int2ObjectOpenHashMap<>();
|
||||
static final Int2ObjectMap<List<IStateStack<?>>> maskToFeaturesMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static Set<IStateStack<?>> maskToFeatures(int mask) {
|
||||
static List<IStateStack<?>> maskToFeatures(int mask) {
|
||||
if(maskToFeaturesMap.containsKey(mask)) {
|
||||
return maskToFeaturesMap.get(mask);
|
||||
}
|
||||
|
||||
final Set<IStateStack<?>> features = new HashSet<>();
|
||||
|
||||
for(int attrib : Feature.supportedAttribs) {
|
||||
if((mask & attrib) == attrib) {
|
||||
features.addAll(getFeatures(attrib));
|
||||
}
|
||||
}
|
||||
maskToFeaturesMap.put(mask, features);
|
||||
return features;
|
||||
|
||||
final List<IStateStack<?>> asList = new ArrayList<>(features);
|
||||
|
||||
maskToFeaturesMap.put(mask, asList);
|
||||
return asList;
|
||||
}
|
||||
|
||||
private static final Map<Integer, Set<IStateStack<?>>> attribToFeatures = new HashMap<>();
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureTracker;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
@@ -35,6 +36,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArraySet;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.SneakyThrows;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gbuffer_overrides.state.StateTracker;
|
||||
import net.coderbot.iris.gl.blending.AlphaTestStorage;
|
||||
@@ -65,12 +67,16 @@ import org.lwjgl.opengl.GLContext;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
|
||||
import java.lang.Math;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
@@ -134,11 +140,21 @@ public class GLStateManager {
|
||||
@Getter protected static final MaterialStateStack frontMaterial = new MaterialStateStack(GL11.GL_FRONT);
|
||||
@Getter protected static final MaterialStateStack backMaterial = new MaterialStateStack(GL11.GL_BACK);
|
||||
|
||||
private static final MethodHandle MAT4_STACK_CURR_DEPTH;
|
||||
|
||||
static {
|
||||
for (int i = 0; i < lightStates.length; i ++) {
|
||||
lightStates[i] = new BooleanStateStack(GL11.GL_LIGHT0 + i);
|
||||
lightDataStates[i] = new LightStateStack(GL11.GL_LIGHT0 + i);
|
||||
}
|
||||
|
||||
try {
|
||||
Field curr = ReflectionHelper.findField(Matrix4fStack.class, "curr");
|
||||
curr.setAccessible(true);
|
||||
MAT4_STACK_CURR_DEPTH = MethodHandles.lookup().unreflectGetter(curr);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter protected static final ViewPortStateStack viewportState = new ViewPortStateStack();
|
||||
@@ -150,11 +166,18 @@ public class GLStateManager {
|
||||
while(!attribs.isEmpty()) {
|
||||
attribs.popInt();
|
||||
}
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS)) {
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS);
|
||||
int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
IStateStack<?> stack = stacks.get(i);
|
||||
|
||||
while(!stack.isEmpty()) {
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
modelViewMatrix.clear();
|
||||
projectionMatrix.clear();
|
||||
}
|
||||
@@ -181,6 +204,9 @@ public class GLStateManager {
|
||||
|
||||
|
||||
public static class GLFeatureSet extends IntOpenHashSet {
|
||||
|
||||
private static final long serialVersionUID = 8558779940775721010L;
|
||||
|
||||
public GLFeatureSet addFeature(int feature) {
|
||||
super.add(feature);
|
||||
return this;
|
||||
@@ -399,6 +425,11 @@ public class GLStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public static int getMatrixStackDepth(Matrix4fStack stack) {
|
||||
return (int) MAT4_STACK_CURR_DEPTH.invokeExact(stack);
|
||||
}
|
||||
|
||||
public static int glGetInteger(int pname) {
|
||||
if(shouldBypassCache()) {
|
||||
return GL11.glGetInteger(pname);
|
||||
@@ -418,6 +449,8 @@ public class GLStateManager {
|
||||
case GL11.GL_COLOR_MATERIAL_FACE -> colorMaterialFace.getValue();
|
||||
case GL11.GL_COLOR_MATERIAL_PARAMETER -> colorMaterialParameter.getValue();
|
||||
case GL20.GL_CURRENT_PROGRAM -> activeProgram;
|
||||
case GL11.GL_MODELVIEW_STACK_DEPTH -> getMatrixStackDepth(modelViewMatrix);
|
||||
case GL11.GL_PROJECTION_STACK_DEPTH -> getMatrixStackDepth(projectionMatrix);
|
||||
|
||||
default -> GL11.glGetInteger(pname);
|
||||
};
|
||||
@@ -830,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);
|
||||
@@ -1212,13 +1255,21 @@ public class GLStateManager {
|
||||
glListNesting += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
glListId = list;
|
||||
glListMode = mode;
|
||||
GL11.glNewList(list, mode);
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS)) {
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS);
|
||||
int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
IStateStack<?> stack = stacks.get(i);
|
||||
|
||||
// Feature Stack, copy of current feature state
|
||||
glListStates.put(stack, (ISettableState<?>) ((ISettableState<?>)stack).copy());
|
||||
}
|
||||
|
||||
if(glListMode == GL11.GL_COMPILE) {
|
||||
pushState(GL11.GL_ALL_ATTRIB_BITS);
|
||||
}
|
||||
@@ -1274,15 +1325,23 @@ public class GLStateManager {
|
||||
|
||||
public static void pushState(int mask) {
|
||||
attribs.push(mask);
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(mask)) {
|
||||
stack.push();
|
||||
}
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(mask);
|
||||
int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
stacks.get(i).push();
|
||||
}
|
||||
}
|
||||
|
||||
public static void popState() {
|
||||
final int mask = attribs.popInt();
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(mask)) {
|
||||
stack.pop();
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(mask);
|
||||
int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
stacks.get(i).pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ import java.nio.IntBuffer;
|
||||
public class RenderSystem {
|
||||
private static final Logger LOGGER = LogManager.getLogger("RenderSystem");
|
||||
private static DSAAccess dsaState;
|
||||
private static boolean hasMultibind;
|
||||
private static boolean supportsCompute;
|
||||
|
||||
private RenderSystem() {}
|
||||
@@ -41,7 +40,6 @@ public class RenderSystem {
|
||||
dsaState = new DSACore();
|
||||
LOGGER.info("OpenGL 4.5 detected, enabling DSA.");
|
||||
}
|
||||
hasMultibind = GLStateManager.capabilities.OpenGL45;
|
||||
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
try {
|
||||
@@ -55,10 +53,6 @@ public class RenderSystem {
|
||||
LOGGER.info("No DSA support detected, falling back to legacy OpenGL.");
|
||||
}
|
||||
|
||||
try {
|
||||
hasMultibind |= GLStateManager.capabilities.GL_ARB_multi_bind;
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
|
||||
supportsCompute = supportsCompute();
|
||||
}
|
||||
|
||||
@@ -103,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);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.glsm.states;
|
||||
|
||||
public interface ISettableState<T> extends Cloneable {
|
||||
T set(T state);
|
||||
@SuppressWarnings("unchecked")
|
||||
default void set(ISettableState<?> value) {
|
||||
set((T) value);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ public class LightState implements ISettableState<LightState> {
|
||||
private static final Vector4i vector4i = new Vector4i();
|
||||
private static final Vector4f vector4f = new Vector4f();
|
||||
private static final Vector3i vector3i = new Vector3i();
|
||||
private static final Vector3f vector3f = new Vector3f();
|
||||
private static final Matrix3f matrix3f = new Matrix3f();
|
||||
|
||||
public int light;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.hudcaching;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -34,7 +31,7 @@ import xaero.common.core.XaeroMinimapCore;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
// See LICENSE+HUDCaching.md for license information.
|
||||
// See LICENSE-HUDCaching.md for license information.
|
||||
|
||||
public class HUDCaching {
|
||||
|
||||
@@ -59,7 +56,7 @@ public class HUDCaching {
|
||||
public static boolean renderCrosshairsCaptured;
|
||||
|
||||
private final static RenderGameOverlayEvent fakeTextEvent = new RenderGameOverlayEvent.Text(new RenderGameOverlayEvent(0, null, 0, 0), null, null);
|
||||
private final static RenderGameOverlayEvent fakePreEvent = new RenderGameOverlayEvent.Pre(new RenderGameOverlayEvent(0, null, 0, 0), RenderGameOverlayEvent.ElementType.HELMET);
|
||||
private final static RenderGameOverlayEvent.Post fakePostEvent = new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(0, null, 0, 0), RenderGameOverlayEvent.ElementType.HELMET);
|
||||
|
||||
public static final HUDCaching INSTANCE = new HUDCaching();
|
||||
|
||||
@@ -125,11 +122,11 @@ public class HUDCaching {
|
||||
GuiIngameForgeAccessor guiForge = ((GuiIngameForgeAccessor) ingame);
|
||||
if (renderHelmetCaptured) {
|
||||
guiForge.callRenderHelmet(resolution, partialTicks, hasScreen, mouseX, mouseY);
|
||||
if (ModStatus.isHoloInventoryLoaded){
|
||||
if (ModStatus.isHoloInventoryLoaded) {
|
||||
Renderer.INSTANCE.angelicaOverride = false;
|
||||
// only settings the partial ticks as mouseX and mouseY are not used in renderEvent
|
||||
((RenderGameOverlayEventAccessor) fakePreEvent).setPartialTicks(partialTicks);
|
||||
Renderer.INSTANCE.renderEvent(fakePreEvent);
|
||||
((RenderGameOverlayEventAccessor) fakePostEvent).setPartialTicks(partialTicks);
|
||||
Renderer.INSTANCE.renderEvent(fakePostEvent);
|
||||
}
|
||||
}
|
||||
if (renderPortalCapturedTicks > 0) {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.loading;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizon.gtnhlib.asm.ASMUtil;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigException;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
@@ -153,18 +152,5 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ImmutableMap<String, TargetedMod> MODS_BY_CLASS = ImmutableMap.<String, TargetedMod>builder()
|
||||
.put("optifine.OptiFineForgeTweaker", TargetedMod.OPTIFINE)
|
||||
.put("fastcraft.Tweaker", TargetedMod.FASTCRAFT)
|
||||
.put("cofh.asm.LoadingPlugin", TargetedMod.COFHCORE)
|
||||
.build();
|
||||
public static final Set<TargetedMod> coreMods = new HashSet<>();
|
||||
|
||||
private static void detectCoreMods(Set<String> loadedCoreMods) {
|
||||
MODS_BY_CLASS.forEach((key, value) -> {
|
||||
if (loadedCoreMods.contains(key))
|
||||
coreMods.add(value);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -91,8 +91,8 @@ public enum Mixins {
|
||||
)
|
||||
),
|
||||
|
||||
ARCHAIC_CORE(new Builder("Archaic Core").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
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"
|
||||
@@ -124,15 +124,12 @@ public enum Mixins {
|
||||
,"sodium.MixinEntity_RenderDist"
|
||||
,"sodium.MixinEntityItem_RenderDist"
|
||||
,"sodium.MixinRenderManager"
|
||||
,"sodium.MixinExtendedBlockStorage"
|
||||
,"sodium.MixinEntityRenderer"
|
||||
,"sodium.MixinFMLClientHandler"
|
||||
,"sodium.MixinForgeHooksClient"
|
||||
,"sodium.MixinGameSettings"
|
||||
,"sodium.MixinFrustrum"
|
||||
,"sodium.MixinMaterial"
|
||||
,"sodium.MixinMinecraft"
|
||||
,"sodium.MixinNibbleArray"
|
||||
,"sodium.MixinRenderBlocks"
|
||||
,"sodium.MixinRenderGlobal"
|
||||
,"sodium.MixinWorldClient"
|
||||
@@ -152,7 +149,6 @@ public enum Mixins {
|
||||
,"shaders.MixinGuiIngameForge"
|
||||
,"shaders.MixinFramebuffer"
|
||||
,"shaders.MixinItem"
|
||||
,"shaders.MixinItemRenderer"
|
||||
,"shaders.MixinLocale"
|
||||
,"shaders.MixinOpenGlHelper"
|
||||
,"shaders.MixinRender"
|
||||
@@ -162,17 +158,23 @@ public enum Mixins {
|
||||
)
|
||||
),
|
||||
|
||||
IRIS_ACCESSORS(new Builder("Iris Accessors").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
|
||||
"shaders.accessors.MixinMinecraft"
|
||||
,"shaders.accessors.MixinEntityRenderer"
|
||||
,"shaders.accessors.MixinSimpleTexture"
|
||||
,"shaders.accessors.MixinTextureAtlasSprite"
|
||||
,"shaders.accessors.MixinTextureMap"
|
||||
,"shaders.accessors.MixinAnimationMetadataSection"
|
||||
IRIS_RENDERING_NOBACKHAND(new Builder("Iris Hand Shaders").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addExcludedMod(TargetedMod.BACKHAND).addMixinClasses(
|
||||
"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(
|
||||
"shaders.MixinItemRendererBackhand"
|
||||
)
|
||||
),
|
||||
|
||||
IRIS_ACCESSORS(new Builder("Iris Accessors").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses("shaders.accessors.MixinEntityRenderer")
|
||||
),
|
||||
|
||||
ANGELICA_TEXTURE(new Builder("Textures").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris || AngelicaConfig.enableSodium).addMixinClasses(
|
||||
"angelica.textures.MixinTextureAtlasSprite"
|
||||
|
||||
@@ -8,6 +8,7 @@ public enum TargetedMod {
|
||||
, 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")
|
||||
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mutable;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
public interface AnimationMetadataSectionAccessor {
|
||||
int getFrameWidth();
|
||||
|
||||
void setFrameWidth(int frameWidth);
|
||||
|
||||
int getFrameHeight();
|
||||
|
||||
void setFrameHeight(int frameHeight);
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
public interface ExtendedBlockStorageAccessor {
|
||||
int getYBase();
|
||||
int getBlockRefCount();
|
||||
void setBlockRefCount(int blockRefCount);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
public interface ExtendedNibbleArray {
|
||||
public byte[] getData();
|
||||
public int getDepthBits();
|
||||
public int getDepthBitsPlusFour();
|
||||
}
|
||||
@@ -8,4 +8,5 @@ public interface ITexturesCache {
|
||||
|
||||
Set<IIcon> getRenderedTextures();
|
||||
void enableTextureTracking();
|
||||
void track(IPatchedTextureAtlasSprite sprite);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.util.Timer;
|
||||
|
||||
public interface MinecraftAccessor {
|
||||
Timer getTimer();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface SimpleTextureAccessor {
|
||||
ResourceLocation getLocation();
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.client.resources.data.AnimationMetadataSection;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TextureAtlasSpriteAccessor {
|
||||
AnimationMetadataSection getMetadata();
|
||||
|
||||
List<int[][]> getFramesTextureData();
|
||||
|
||||
int getFrame();
|
||||
|
||||
void setFrame(int frame);
|
||||
|
||||
int getSubFrame();
|
||||
|
||||
void setSubFrame(int subFrame);
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface TextureMapAccessor {
|
||||
Map getMapUploadedSprites();
|
||||
|
||||
int getAnisotropicFiltering();
|
||||
|
||||
int getMipmapLevels();
|
||||
|
||||
ResourceLocation getLocationBlocksTexture();
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.models;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.IBlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.ModelLoader;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.Variant;
|
||||
|
||||
@@ -47,6 +47,7 @@ import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.server.integrated.IntegratedServer;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -152,7 +153,7 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeypress(TickEvent.ClientTickEvent event) {
|
||||
final boolean isPressed = glsmKeyBinding.getKeyCode() != 0 && Keyboard.isKeyDown(glsmKeyBinding.getKeyCode());
|
||||
final boolean isPressed = glsmKeyBinding.getKeyCode() != 0 && GameSettings.isKeyDown(glsmKeyBinding);
|
||||
if (isPressed && !wasGLSMKeyPressed) {
|
||||
OpenGLDebugging.checkGLSM();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
"com.gtnewhorizons.angelica.transform",
|
||||
"me.eigenraven.lwjgl3ify"
|
||||
);
|
||||
private static int remaps = 0;
|
||||
|
||||
private static final Set<String> moddedBlockSubclasses = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
// Block owners we *shouldn't* redirect because they shadow one of our fields
|
||||
@@ -348,7 +347,6 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
changed = true;
|
||||
redirectInMethod = true;
|
||||
remaps++;
|
||||
} else if (mNode.owner.startsWith(Drawable) && mNode.name.equals("makeCurrent")) {
|
||||
mNode.setOpcode(Opcodes.INVOKESTATIC);
|
||||
mNode.owner = GLStateManager;
|
||||
@@ -369,7 +367,6 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
mNode.name = redirects.get(mNode.name);
|
||||
changed = true;
|
||||
redirectInMethod = true;
|
||||
remaps++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -423,6 +420,9 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
|
||||
private static class RedirectMap<K> extends HashMap<K, K> {
|
||||
|
||||
private static final long serialVersionUID = 1712218575345511543L;
|
||||
|
||||
public static RedirectMap<String> newMap() {
|
||||
return new RedirectMap<>();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -28,4 +30,26 @@ public class AnimationsRenderUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final static ThreadLocal<ArrayDeque<ITexturesCache>> TEXTURE_CACHE_STACK = ThreadLocal.withInitial(ArrayDeque::new);
|
||||
|
||||
public static void onSpriteUsed(IPatchedTextureAtlasSprite sprite) {
|
||||
ArrayDeque<ITexturesCache> stack = TEXTURE_CACHE_STACK.get();
|
||||
|
||||
if (stack == null || stack.isEmpty()) {
|
||||
// icon was used outside of chunk building, it's probably an item in an inventory or something
|
||||
sprite.markNeedsAnimationUpdate();
|
||||
return;
|
||||
}
|
||||
|
||||
stack.peek().track(sprite);
|
||||
}
|
||||
|
||||
public static void pushCache(ITexturesCache cache) {
|
||||
TEXTURE_CACHE_STACK.get().push(cache);
|
||||
}
|
||||
|
||||
public static void popCache() {
|
||||
TEXTURE_CACHE_STACK.get().pop();
|
||||
}
|
||||
}
|
||||
@@ -172,6 +172,8 @@ public class MCLogger {
|
||||
|
||||
private static class ErrorLevel extends Level {
|
||||
|
||||
private static final long serialVersionUID = 3987750897854233321L;
|
||||
|
||||
protected ErrorLevel() {
|
||||
super("ERROR", (Level.WARNING.intValue() + Level.SEVERE.intValue()) / 2);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class CITUtils {
|
||||
List<T> list = overrides.get(item);
|
||||
if (list != null) {
|
||||
int[] enchantmentLevels = getEnchantmentLevels(item, itemStack.getTagCompound());
|
||||
boolean hasEffect = itemStack.hasEffect();
|
||||
boolean hasEffect = itemStack.hasEffect(0);
|
||||
for (T override : list) {
|
||||
if (override.match(itemStack, enchantmentLevels, hasEffect)) {
|
||||
return override;
|
||||
|
||||
@@ -49,7 +49,7 @@ final class EnchantmentList {
|
||||
Map<Integer, Layer> tmpLayers = new HashMap<>();
|
||||
Item item = itemStack.getItem();
|
||||
int[] enchantmentLevels = CITUtils.getEnchantmentLevels(item, itemStack.getTagCompound());
|
||||
boolean hasEffect = itemStack.hasEffect();
|
||||
boolean hasEffect = itemStack.hasEffect(0);
|
||||
List<Enchantment> list = enchantments.get(item);
|
||||
if (list == null) {
|
||||
list = allItemEnchantments;
|
||||
|
||||
@@ -32,8 +32,6 @@ abstract class TileOverride implements Comparable<TileOverride> {
|
||||
|
||||
private static final MCLogger logger = MCLogger.getLogger(MCLogger.Category.CONNECTED_TEXTURES, "CTM");
|
||||
|
||||
private static final int META_MASK = 0xffff;
|
||||
|
||||
private final PropertiesFile properties;
|
||||
private final String baseFilename;
|
||||
private final TileLoader tileLoader;
|
||||
@@ -41,7 +39,6 @@ abstract class TileOverride implements Comparable<TileOverride> {
|
||||
private final int weight;
|
||||
private final List<BlockStateMatcher> matchBlocks;
|
||||
private final Set<String> matchTiles;
|
||||
private final int defaultMetaMask;
|
||||
private final BlockFaceMatcher faceMatcher;
|
||||
private final int connectType;
|
||||
private final boolean innerSeams;
|
||||
@@ -50,7 +47,6 @@ abstract class TileOverride implements Comparable<TileOverride> {
|
||||
|
||||
private final List<ResourceLocation> tileNames = new ArrayList<>();
|
||||
protected IIcon[] icons;
|
||||
private int matchMetadata = META_MASK;
|
||||
|
||||
static TileOverride create(ResourceLocation propertiesFile, TileLoader tileLoader) {
|
||||
if (propertiesFile == null) {
|
||||
@@ -133,11 +129,6 @@ abstract class TileOverride implements Comparable<TileOverride> {
|
||||
if (matchBlocks.isEmpty() && matchTiles.isEmpty()) {
|
||||
matchTiles.add(baseFilename);
|
||||
}
|
||||
int bits = 0;
|
||||
for (int i : properties.getIntList("metadata", 0, 15, "0-15")) {
|
||||
bits |= 1 << i;
|
||||
}
|
||||
defaultMetaMask = bits;
|
||||
|
||||
faceMatcher = BlockFaceMatcher.create(properties.getString("faces", ""));
|
||||
|
||||
|
||||
@@ -170,6 +170,7 @@ public class FancyDial {
|
||||
static void registerAnimations() {
|
||||
ITextureObject texture = TexturePackAPI.getTextureObject(TexturePackAPI.ITEMS_PNG);
|
||||
if (texture instanceof TextureMap map) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<TextureAtlasSprite> animations = map.listAnimatedSprites;
|
||||
for (FancyDial instance : instances.values()) {
|
||||
instance.registerAnimation(animations);
|
||||
|
||||
@@ -32,7 +32,6 @@ abstract public class ColorMap implements IColorMap {
|
||||
private static final int BIOME_HEIGHT = 2;
|
||||
|
||||
private static final int COLORMAP_WIDTH = 256;
|
||||
private static final int COLORMAP_HEIGHT = 256;
|
||||
|
||||
public static final String BLOCK_COLORMAP_DIR = TexturePackAPI.MCPATCHER_SUBDIR + "colormap/blocks";
|
||||
public static final List<ResourceLocation> unusedPNGs = new ArrayList<>();
|
||||
|
||||
@@ -10,8 +10,6 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.prupe.mcpatcher.MCPatcherUtils;
|
||||
import com.prupe.mcpatcher.mal.resource.PropertiesFile;
|
||||
@@ -21,6 +19,7 @@ import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
public class BlockAPI {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
BlockAPI(FMLControlledNamespacedRegistry<Block> registry) {
|
||||
File outputFile = new File("blocks17.txt");
|
||||
if (outputFile.isFile()) {
|
||||
|
||||
@@ -61,6 +61,7 @@ public class BlockStateMatcher {
|
||||
threadLocal.set(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String toString() {
|
||||
return fullString;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
public class ItemAPI {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ItemAPI() {
|
||||
File outputFile = new File("items17.txt");
|
||||
if (outputFile.isFile()) {
|
||||
|
||||
@@ -120,7 +120,7 @@ final public class PropertiesFile {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<Map.Entry<String, String>> entrySet() {
|
||||
return (Set<Map.Entry<String, String>>) (Set) properties.entrySet();
|
||||
return (Set<Map.Entry<String, String>>) (Set<?>) properties.entrySet();
|
||||
}
|
||||
|
||||
public ResourceLocation getResource() {
|
||||
|
||||
@@ -110,6 +110,7 @@ public class ResourceList {
|
||||
MCPatcherUtils.close(zipFile);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, File> map = resourcePack.field_152781_b; // map
|
||||
if (map != null) {
|
||||
for (Map.Entry<String, File> entry : map.entrySet()) {
|
||||
|
||||
@@ -51,6 +51,7 @@ public class TexturePackAPI {
|
||||
List<IResourcePack> resourcePacks = new ArrayList<>();
|
||||
IResourceManager resourceManager = Minecraft.getMinecraft().getResourceManager();
|
||||
if (resourceManager instanceof SimpleReloadableResourceManager) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Map.Entry<String, FallbackResourceManager>> entrySet = ((SimpleReloadableResourceManager) resourceManager).domainResourceManagers
|
||||
.entrySet();
|
||||
for (Map.Entry<String, FallbackResourceManager> entry : entrySet) {
|
||||
@@ -66,6 +67,7 @@ public class TexturePackAPI {
|
||||
return resourcePacks;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Set<String> getNamespaces() {
|
||||
Set<String> namespaces = new HashSet<>();
|
||||
namespaces.add(DEFAULT_NAMESPACE);
|
||||
@@ -310,6 +312,7 @@ public class TexturePackAPI {
|
||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
if (textureManager != null) {
|
||||
Set<ResourceLocation> texturesToUnload = new HashSet<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
Set<Map.Entry<ResourceLocation, ITextureObject>> entrySet = textureManager.mapTextureObjects.entrySet();
|
||||
for (Map.Entry<ResourceLocation, ITextureObject> entry : entrySet) {
|
||||
ResourceLocation resource = entry.getKey();
|
||||
|
||||
@@ -13,6 +13,7 @@ import jss.notfine.asm.mappings.Names.Meth;
|
||||
|
||||
public class NamerMcp extends NamerSrg {
|
||||
|
||||
@Override
|
||||
public void setNames() {
|
||||
setNamesSrg();
|
||||
final String confPath = System.getProperty("net.minecraftforge.gradle.GradleStart.csvDir", "../conf") + "/";
|
||||
|
||||
@@ -48,7 +48,7 @@ public enum Settings {
|
||||
}
|
||||
},
|
||||
DYNAMIC_FOV(new NotFineOptionTickBox(true, null)),
|
||||
DYNAMIC_LIGHTS(new NotFineOptionCycling(DynamicLightsMode.FANCY, OptionImpact.VARIES)){
|
||||
DYNAMIC_LIGHTS(new NotFineOptionCycling<>(DynamicLightsMode.FANCY, OptionImpact.VARIES)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
DynamicLights.Mode = (DynamicLightsMode) this.option.getStore();
|
||||
@@ -60,6 +60,7 @@ public enum Settings {
|
||||
DynamicLights.ShaderForce = (boolean) this.option.getStore();
|
||||
}
|
||||
},
|
||||
FOG_DISABLE(new NotFineOptionTickBox(false, OptionImpact.LOW)),
|
||||
FOG_NEAR_DISTANCE(new NotFineOptionSliderPercentage(75, 1, 100, 1, OptionImpact.LOW)),
|
||||
GUI_BACKGROUND(new NotFineOptionCycling<>(BackgroundSelect.DEFAULT, null)) {
|
||||
@Override
|
||||
@@ -132,9 +133,9 @@ public enum Settings {
|
||||
},
|
||||
VOID_FOG(new NotFineOptionTickBox(false, OptionImpact.LOW));
|
||||
|
||||
public final NotFineOption option;
|
||||
public final NotFineOption<?> option;
|
||||
|
||||
Settings(NotFineOption option) {
|
||||
Settings(NotFineOption<?> option) {
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,10 +26,10 @@ public class GuiCustomOptionsRowList extends GuiListExtended {
|
||||
field_148163_i = false;
|
||||
|
||||
for(OptionGroup optionGroup : optionPage.getGroups()) {
|
||||
Iterator settings = optionGroup.getOptions().stream().iterator();
|
||||
Iterator<Option<?>> settings = optionGroup.getOptions().stream().iterator();
|
||||
while(settings.hasNext()) {
|
||||
Option optionOne = (Option)settings.next();
|
||||
Option optionTwo = settings.hasNext() ? (Option)settings.next() : null;
|
||||
Option<?> optionOne = settings.next();
|
||||
Option<?> optionTwo = settings.hasNext() ? settings.next() : null;
|
||||
GuiButton buttonOne = (GuiButton)optionOne.getControl().createElement(new Dim2i(width / 2 - 155,0,150,20), factory);
|
||||
GuiButton buttonTwo = optionTwo == null ? null : (GuiButton)optionTwo.getControl().createElement(new Dim2i(width / 2 - 155 + 160,0,150,20), factory);
|
||||
settingsList.add(new GuiCustomOptionsRowList.Row(buttonOne, buttonTwo));
|
||||
|
||||
@@ -213,6 +213,7 @@ public class NotFineGameOptionPages {
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.build());
|
||||
return new OptionPage(I18n.format("options.button.sky"), ImmutableList.copyOf(groups));
|
||||
|
||||
@@ -22,6 +22,7 @@ public class CyclingControlElement<T extends Enum<T>> extends NotFineControlElem
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
Enum<T> value = option.getValue();
|
||||
return super.getLabel() + names[value.ordinal()];
|
||||
|
||||
+4
-4
@@ -9,17 +9,17 @@ import me.jellysquid.mods.sodium.client.util.Dim2i;
|
||||
public class NotFineControlElementFactory implements ControlElementFactory {
|
||||
|
||||
@Override
|
||||
public <T extends Enum<T>> ControlElement cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
return new CyclingControlElement(option, dim, allowedValues, names);
|
||||
public <T extends Enum<T>> ControlElement<T> cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
return new CyclingControlElement<>(option, dim, allowedValues, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControlElement sliderControlElement(Option<Integer> option, Dim2i dim, int min, int max, int interval, ControlValueFormatter formatter) {
|
||||
public ControlElement<Integer> sliderControlElement(Option<Integer> option, Dim2i dim, int min, int max, int interval, ControlValueFormatter formatter) {
|
||||
return new SliderControlElement(option, dim, min, max, interval, formatter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControlElement tickBoxElement(Option<Boolean> option, Dim2i dim) {
|
||||
public ControlElement<Boolean> tickBoxElement(Option<Boolean> option, Dim2i dim) {
|
||||
return new TickBoxControlElement(option, dim);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ public class SliderControlElement extends NotFineControlElement<Integer> {
|
||||
value = MathHelper.clamp_float((value - min) / (max - min), 0f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return super.getLabel() + formatter.format(option.getValue());
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ public class TickBoxControlElement extends NotFineControlElement<Boolean> {
|
||||
super(option, dim);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
return super.getLabel() + I18n.format(option.getValue() ? "options.on" : "options.off");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package jss.notfine.util.itembreakparticles;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public interface IWorldSpawnItemBreakParticle {
|
||||
|
||||
|
||||
@@ -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,6 +1,6 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public abstract class ParseException extends Exception{
|
||||
public abstract class ParseException extends Exception {
|
||||
public ParseException() {
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 260 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user