mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-15 01:34:48 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
701f55b5a5 | ||
|
|
6563c7c0ce | ||
|
|
52dae51121 | ||
|
|
b42eb9a6b2 | ||
|
|
5925c28d29 | ||
|
|
fedabd0fb6 |
No files matched your search
@@ -36,3 +36,5 @@ addon.local.gradle
|
||||
addon.local.gradle.kts
|
||||
addon.late.local.gradle
|
||||
addon.late.local.gradle.kts
|
||||
/*.csv
|
||||
!gl_functions.csv
|
||||
@@ -8,19 +8,19 @@
|
||||
* It's the angel that pulls you out of OptiFine's hell -Roadhog360
|
||||
|
||||
## **Beta Quality - Here there be Dragons**
|
||||
* Shaders - Beta
|
||||
* Shaders sneak preview - Please don't report issues yet, but please do submit fixes
|
||||
* Complementary & BSL mostly function, but have some bugs
|
||||
* Sildurs, Seus, and any other shader probably doesn't work
|
||||
|
||||
|
||||
# Required Dependencies
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.19
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.6.6
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.14
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.4.2
|
||||
* NOTE: Some mods are not required, but a specific version is required if present - see: `Permanent Incompatibilities` below.
|
||||
|
||||
# Known (temporary) Incompatibilities
|
||||
* Forge Relocation - Currently non Thread Safe; safe if not in use
|
||||
* ProjectRed Frames - Currently non Thread Safe; safe if not in use
|
||||
* ProjectRed Frames - Currently non Thread Safe; safe if not in use'
|
||||
|
||||
# Potential Incompatibilities
|
||||
* EndlessIDs - Compat commits have been made, might work, might not - not fully tested
|
||||
|
||||
+21
-17
@@ -49,19 +49,19 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.6.30")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.78")
|
||||
|
||||
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:1.0.7") { transitive = false }
|
||||
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:0.4.0") { transitive = false }
|
||||
|
||||
compileOnly("org.projectlombok:lombok:1.18.34") { transitive = false }
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.34")
|
||||
compileOnly("org.projectlombok:lombok:1.18.22") { transitive = false }
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.22")
|
||||
|
||||
// Use modern models+textures to inject QuadProviders
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.8.2:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.7.2:dev')
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.6.13:dev")
|
||||
compileOnly('org.jetbrains:annotations:24.0.1')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.5.20: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.29-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.4.1:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.6.45-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.3.10:dev')
|
||||
|
||||
// Notfine Deps
|
||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.7.5:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.6.35:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.13.10-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.8.2:dev")
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.14-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.7.5:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.7.1:dev")
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.6.4:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.2:dev") { transitive = false }
|
||||
compileOnly('com.github.GTNewHorizons:Backhand:1.6.11') { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.1:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { 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.1-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:HoloInventory:2.4.13-GTNH:dev")
|
||||
|
||||
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
|
||||
|
||||
@@ -111,8 +111,12 @@ dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:BetterCrashes:1.4.0-GTNH:dev")
|
||||
|
||||
// Tests
|
||||
testImplementation(platform('org.junit:junit-bom:5.11.4'))
|
||||
testImplementation(platform('org.junit:junit-bom:5.9.2'))
|
||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||
testImplementation("org.mockito:mockito-core:3.+")
|
||||
testImplementation("org.lwjgl.lwjgl:lwjgl:2.9.4-nightly-20150209")
|
||||
|
||||
devOnlyNonPublishable("com.github.javaparser:javaparser-symbol-solver-core:3.26.2") {
|
||||
exclude module: "guava"
|
||||
}
|
||||
}
|
||||
+2084
File diff suppressed because it is too large.
Load diff
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.13-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -86,7 +86,8 @@ 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\n' "$PWD" ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -205,7 +206,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_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.37'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.29'
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import com.github.javaparser.StaticJavaParser;
|
||||
import com.github.javaparser.ast.CompilationUnit;
|
||||
import com.github.javaparser.ast.Node;
|
||||
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
||||
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||
import com.github.javaparser.ast.body.Parameter;
|
||||
import com.github.javaparser.ast.visitor.VoidVisitorWithDefaults;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Used to generate gl_functions.csv. Which contains a mapping of OpenGL functions provided by LWJGL
|
||||
* corresponding to the earliest GL version they appear in.
|
||||
*/
|
||||
public class GLFunctionParser {
|
||||
final static String glPath = "util/gl"; // Path to LWJGL OpenGL bindings source code
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
HashMap<String, Set<String>> byFunction = new HashMap<>();
|
||||
File dir = new File(glPath);
|
||||
for (File file : dir.listFiles()) {
|
||||
final String filename = file.getName();
|
||||
if (filename.endsWith(".java") && filename.startsWith("GL") && Character.isDigit(filename.charAt(2))) {
|
||||
Path p = Paths.get(filename);
|
||||
|
||||
String parsedFile = removeFileExtension(p.getFileName().toString());
|
||||
|
||||
CompilationUnit cu = StaticJavaParser.parse(file);
|
||||
cu.accept(new VoidVisitorWithDefaults<>() {
|
||||
|
||||
@Override
|
||||
public void defaultAction(Node n, Object arg) {
|
||||
for( Node child : n.getChildNodes()) {
|
||||
if(child instanceof ClassOrInterfaceDeclaration cd) {
|
||||
for (MethodDeclaration md : cd.getMethods()) {
|
||||
String methodName = md.getNameAsString() + "(";
|
||||
for (Parameter p : md.getParameters()) {
|
||||
methodName = methodName + p.getTypeAsString();
|
||||
}
|
||||
methodName = methodName + ")";
|
||||
if(methodName.startsWith("n")) continue;
|
||||
|
||||
Set<String> functionSet = byFunction.computeIfAbsent(methodName, k -> new HashSet<>());
|
||||
functionSet.add(parsedFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> functionVersionMap = new HashMap<>();
|
||||
|
||||
for(String function : byFunction.keySet()) {
|
||||
|
||||
Set<String> versionsForFunction = byFunction.get(function);
|
||||
int lowestInt = 46;
|
||||
String lowestString = "GL46";
|
||||
for(String version : versionsForFunction) {
|
||||
int i = Integer.parseInt(version.substring(2, 4));
|
||||
if (i < lowestInt) {
|
||||
lowestInt = i;
|
||||
lowestString = version;
|
||||
}
|
||||
}
|
||||
functionVersionMap.put(function, lowestString);
|
||||
}
|
||||
|
||||
List<String[]> outputLines = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : functionVersionMap.entrySet()) {
|
||||
outputLines.add(new String[] {entry.getKey(), entry.getValue()});
|
||||
}
|
||||
|
||||
File output = new File("output.csv");
|
||||
try (PrintWriter writer = new PrintWriter(output)) {
|
||||
outputLines.stream().map(GLSMFunctionComparison::convertToCSV).forEach(writer::println);
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertToCSV(String[] data) {
|
||||
return Stream.of(data).map(GLSMFunctionComparison::escapeSpecialCharacters).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public static String escapeSpecialCharacters(String data) {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Input data cannot be null");
|
||||
}
|
||||
String escapedData = data.replaceAll("\\R", " ");
|
||||
if (data.contains(",") || data.contains("\"") || data.contains("'")) {
|
||||
data = data.replace("\"", "\"\"");
|
||||
escapedData = "\"" + data + "\"";
|
||||
}
|
||||
return escapedData;
|
||||
}
|
||||
|
||||
public static String removeFileExtension(String filename) {
|
||||
if (filename == null || filename.isEmpty()) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
String extPattern = "(?<!^)[.]" + "[^.]*$";
|
||||
return filename.replaceAll(extPattern, "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import com.github.javaparser.ParserConfiguration;
|
||||
import com.github.javaparser.StaticJavaParser;
|
||||
import com.github.javaparser.ast.CompilationUnit;
|
||||
import com.github.javaparser.ast.Node;
|
||||
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
|
||||
import com.github.javaparser.ast.body.MethodDeclaration;
|
||||
import com.github.javaparser.ast.body.Parameter;
|
||||
import com.github.javaparser.ast.visitor.VoidVisitorWithDefaults;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Used to compare OpenGL functions from gl_functions.csv to current GLStateManager
|
||||
* source code to determine what functions have an implementation in GLSM, and what ones don't.
|
||||
* Only considers functions which appear in GL 2.1 and lower
|
||||
*/
|
||||
public class GLSMFunctionComparison {
|
||||
|
||||
/**
|
||||
* If set to true, then the outputted CSV will show functions which do have an implementation in GLSM
|
||||
*/
|
||||
final static boolean INCLUDE_TRUE = false;
|
||||
|
||||
final static String glFunctionsCsvPath = "gl_functions.csv";
|
||||
final static String glsmPath = "src/main/java/com/gtnewhorizons/angelica/glsm/GLStateManager.java";
|
||||
|
||||
public static Map<String, String> parseGLFunctions() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(glFunctionsCsvPath))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] values = line.split(",");
|
||||
if (values.length == 2) {
|
||||
String key = values[0].trim();
|
||||
String value = values[1].trim();
|
||||
int versionInt = Integer.parseInt(value.substring(2, 4));
|
||||
if (versionInt < 30) map.put(key, value);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws FileNotFoundException {
|
||||
//GLSM will fail to parse without increasing language level
|
||||
StaticJavaParser.getParserConfiguration().setLanguageLevel(ParserConfiguration.LanguageLevel.JAVA_17);
|
||||
|
||||
Map<String, String> functionMap = parseGLFunctions();
|
||||
Set<String> glsmFunctions = new HashSet<>();
|
||||
|
||||
File glsmFile = new File(glsmPath);
|
||||
CompilationUnit cu = StaticJavaParser.parse(glsmFile);
|
||||
cu.accept(new VoidVisitorWithDefaults<>() {
|
||||
|
||||
@Override
|
||||
public void defaultAction(Node n, Object arg) {
|
||||
for (Node child : n.getChildNodes()) {
|
||||
if (child instanceof ClassOrInterfaceDeclaration cd) {
|
||||
for (MethodDeclaration md : cd.getMethods()) {
|
||||
String methodName = md.getNameAsString() + "(";
|
||||
for (Parameter p : md.getParameters()) {
|
||||
methodName = methodName + p.getTypeAsString();
|
||||
}
|
||||
methodName = methodName + ")";
|
||||
glsmFunctions.add(methodName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
|
||||
Map<String, String> functionGLSMMap = new HashMap<>();
|
||||
|
||||
for(String function : functionMap.keySet()) {
|
||||
if (!glsmFunctions.contains(function)) {
|
||||
functionGLSMMap.put(function, "false");
|
||||
} else if (INCLUDE_TRUE) {
|
||||
functionGLSMMap.put(function, "true");
|
||||
}
|
||||
}
|
||||
|
||||
List<String[]> outputLines = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : functionGLSMMap.entrySet()) {
|
||||
outputLines.add(new String[] {entry.getKey(), functionMap.get(entry.getKey()), entry.getValue()});
|
||||
}
|
||||
|
||||
File output = new File("glsm_function_comparison.csv");
|
||||
try (PrintWriter writer = new PrintWriter(output)) {
|
||||
outputLines.stream().map(GLSMFunctionComparison::convertToCSV).forEach(writer::println);
|
||||
}
|
||||
}
|
||||
|
||||
public static String convertToCSV(String[] data) {
|
||||
return Stream.of(data).map(GLSMFunctionComparison::escapeSpecialCharacters).collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
public static String escapeSpecialCharacters(String data) {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Input data cannot be null");
|
||||
}
|
||||
String escapedData = data.replaceAll("\\R", " ");
|
||||
if (data.contains(",") || data.contains("\"") || data.contains("'")) {
|
||||
data = data.replace("\"", "\"\"");
|
||||
escapedData = "\"" + data + "\"";
|
||||
}
|
||||
return escapedData;
|
||||
}
|
||||
|
||||
public static String removeFileExtension(String filename) {
|
||||
if (filename == null || filename.isEmpty()) {
|
||||
return filename;
|
||||
}
|
||||
|
||||
String extPattern = "(?<!^)[.]" + "[^.]*$";
|
||||
return filename.replaceAll(extPattern, "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
name = "Angelica",
|
||||
version = Tags.VERSION,
|
||||
dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);"
|
||||
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.6.6,);",
|
||||
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.4.2,);",
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IBlockAccessExtended extends IBlockAccess {
|
||||
World getWorld();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IPatchedTextureAtlasSprite;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
/**
|
||||
* Exposes a method to the API that allow mods to add texture update compat
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class TextureServices {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void updateBlockTextureAnimation(IIcon icon, RenderBlocks renderBlocks) {
|
||||
if (renderBlocks instanceof ITexturesCache texturesCache) {
|
||||
texturesCache.getRenderedTextures().add(icon);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static void updateTextureAnimation(IIcon icon) {
|
||||
if(icon instanceof IPatchedTextureAtlasSprite patchedSprite) {
|
||||
patchedSprite.markNeedsAnimationUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
import it.unimi.dsi.fastutil.chars.Char2ShortOpenHashMap;
|
||||
@@ -11,6 +10,7 @@ import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -42,6 +42,8 @@ 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 */
|
||||
@@ -72,13 +74,14 @@ public class BatchingFontRenderer {
|
||||
}
|
||||
|
||||
public BatchingFontRenderer(FontRenderer underlying, ResourceLocation[] unicodePageLocations, int[] charWidth,
|
||||
byte[] glyphWidth, int[] colorCode, ResourceLocation locationFontTexture) {
|
||||
byte[] glyphWidth, int[] colorCode, ResourceLocation locationFontTexture, TextureManager renderEngine) {
|
||||
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());
|
||||
@@ -94,10 +97,10 @@ public class BatchingFontRenderer {
|
||||
private static final int INITIAL_BATCH_SIZE = 256;
|
||||
private static final ResourceLocation DUMMY_RESOURCE_LOCATION = new ResourceLocation("angelica$dummy",
|
||||
"this is invalid!");
|
||||
private FloatBuffer batchVtxPositions = memAllocFloat(INITIAL_BATCH_SIZE * 2);
|
||||
private ByteBuffer batchVtxColors = memAlloc(INITIAL_BATCH_SIZE * 4);
|
||||
private FloatBuffer batchVtxTexCoords = memAllocFloat(INITIAL_BATCH_SIZE * 2);
|
||||
private IntBuffer batchIndices = memAllocInt(INITIAL_BATCH_SIZE / 2 * 3);
|
||||
private FloatBuffer batchVtxPositions = BufferUtils.createFloatBuffer(INITIAL_BATCH_SIZE * 2);
|
||||
private ByteBuffer batchVtxColors = BufferUtils.createByteBuffer(INITIAL_BATCH_SIZE * 4);
|
||||
private FloatBuffer batchVtxTexCoords = BufferUtils.createFloatBuffer(INITIAL_BATCH_SIZE * 2);
|
||||
private IntBuffer batchIndices = BufferUtils.createIntBuffer(INITIAL_BATCH_SIZE / 2 * 3);
|
||||
private final ObjectArrayList<FontDrawCmd> batchCommands = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
|
||||
private final ObjectArrayList<FontDrawCmd> batchCommandPool = ObjectArrayList.wrap(new FontDrawCmd[64], 0);
|
||||
|
||||
@@ -106,12 +109,12 @@ public class BatchingFontRenderer {
|
||||
final int oldCap = batchVtxPositions.capacity() / 2;
|
||||
if (vtxWriterIndex >= oldCap) {
|
||||
final int newCap = oldCap * 2;
|
||||
batchVtxPositions = memRealloc(batchVtxPositions, newCap * 2);
|
||||
batchVtxColors = memRealloc(batchVtxColors, newCap * 4);
|
||||
batchVtxTexCoords = memRealloc(batchVtxTexCoords, newCap * 2);
|
||||
batchVtxPositions = CompatMemoryUtil.memReallocDirect(batchVtxPositions, newCap * 2);
|
||||
batchVtxColors = CompatMemoryUtil.memReallocDirect(batchVtxColors, newCap * 4);
|
||||
batchVtxTexCoords = CompatMemoryUtil.memReallocDirect(batchVtxTexCoords, newCap * 2);
|
||||
final int oldIdxCap = batchIndices.capacity();
|
||||
final int newIdxCap = oldIdxCap * 2;
|
||||
batchIndices = memRealloc(batchIndices, newIdxCap);
|
||||
batchIndices = CompatMemoryUtil.memReallocDirect(batchIndices, newIdxCap);
|
||||
}
|
||||
final int idx = vtxWriterIndex;
|
||||
final int idx2 = idx * 2;
|
||||
@@ -434,6 +437,8 @@ public class BatchingFontRenderer {
|
||||
chr = MCFONT_CHARS.charAt(lutIndex);
|
||||
}
|
||||
|
||||
final float shadowOffset = unicodeFlag ? 0.5F : 1.0F;
|
||||
|
||||
// Check ASCII space, NBSP, NNBSP
|
||||
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
|
||||
curX += 4;
|
||||
@@ -447,7 +452,6 @@ public class BatchingFontRenderer {
|
||||
final float uSz;
|
||||
final float vSz;
|
||||
final float itOff = curItalic ? 1.0F : 0.0F; // italic offset
|
||||
final float shadowOffset;
|
||||
final ResourceLocation texture;
|
||||
|
||||
if (lutIndex == -1 || unicodeFlag) {
|
||||
@@ -455,7 +459,6 @@ public class BatchingFontRenderer {
|
||||
continue;
|
||||
}
|
||||
// Draw unicode char
|
||||
shadowOffset = 0.5F;
|
||||
final int uniPage = chr / 256;
|
||||
texture = getUnicodePageLocation(uniPage);
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
@@ -472,7 +475,6 @@ public class BatchingFontRenderer {
|
||||
|
||||
} else {
|
||||
// Draw "ASCII" char
|
||||
shadowOffset = 1.0F;
|
||||
uStart = ((lutIndex % 16) * 8) / 128.0F;
|
||||
vStart = (float) ((lutIndex / 16) * 8) / 128.0F;
|
||||
xAdvance = this.charWidth[lutIndex];
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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;
|
||||
@@ -17,7 +19,7 @@ public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
}
|
||||
|
||||
public ExtendedBlockStorageExt(Chunk chunk, ExtendedBlockStorage storage) {
|
||||
super(storage.yBase, storage.getSkylightArray() != null);
|
||||
super(((ExtendedBlockStorageAccessor) storage).getYBase(), storage.getSkylightArray() != null);
|
||||
|
||||
if (ModStatus.isChunkAPILoaded) {
|
||||
if (storage.getSkylightArray() != null) {
|
||||
@@ -31,7 +33,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(storage.getBlockMSBArray(), this.getBlockMSBArray());
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = block16BArray.length;
|
||||
if (ModStatus.isNEIDMetadataExtended) {
|
||||
@@ -50,31 +52,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(storage.getBlockMSBArray(), this.getBlockMSBArray());
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
|
||||
|
||||
if (!ModStatus.isNEIDMetadataExtended) copyNibbleArray(storage.getMetadataArray(), this.getMetadataArray());
|
||||
copyNibbleArray(storage.getBlocklightArray(), this.getBlocklightArray());
|
||||
if (!ModStatus.isNEIDMetadataExtended) copyNibbleArray((ExtendedNibbleArray) storage.getMetadataArray(), (ExtendedNibbleArray)this.getMetadataArray());
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlocklightArray(), (ExtendedNibbleArray)this.getBlocklightArray());
|
||||
if(storage.getSkylightArray() != null) {
|
||||
hasSky = true;
|
||||
if(this.getSkylightArray() == null) {
|
||||
this.setSkylightArray(new NibbleArray(arrayLen, 4));
|
||||
}
|
||||
copyNibbleArray(storage.getSkylightArray(), this.getSkylightArray());
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getSkylightArray(), (ExtendedNibbleArray) this.getSkylightArray());
|
||||
}
|
||||
}
|
||||
this.blockRefCount = storage.blockRefCount;
|
||||
((ExtendedBlockStorageAccessor) this).setBlockRefCount(((ExtendedBlockStorageAccessor) storage).getBlockRefCount());
|
||||
}
|
||||
|
||||
|
||||
private static void copyNibbleArray(NibbleArray srcArray, NibbleArray dstArray) {
|
||||
private static void copyNibbleArray(ExtendedNibbleArray srcArray, ExtendedNibbleArray dstArray) {
|
||||
if (srcArray == null || dstArray == null) {
|
||||
throw new RuntimeException("NibbleArray is null src: " + (srcArray == null) + " dst: " + (dstArray == null));
|
||||
}
|
||||
final byte[] data = srcArray.data;
|
||||
System.arraycopy(data, 0, dstArray.data, 0, data.length);
|
||||
final byte[] data = srcArray.getData();
|
||||
System.arraycopy(data, 0, dstArray.getData(), 0, data.length);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ 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;
|
||||
@@ -61,7 +62,7 @@ public class ModStatus {
|
||||
}
|
||||
|
||||
if (isBackhandLoaded){
|
||||
isBackhandLoaded = new DefaultArtifactVersion("1.6.9")
|
||||
isBackhandLoaded = new DefaultArtifactVersion("1.4.1")
|
||||
.compareTo(
|
||||
LoadControllerHelper.getOwningMod(Backhand.class).getProcessedVersion()
|
||||
) <= 0;
|
||||
|
||||
@@ -0,0 +1,327 @@
|
||||
package com.gtnewhorizons.angelica.compat.lwjgl;
|
||||
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.Pointer.BITS64;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.LongPredicate;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
/**
|
||||
* Backported from LWJGL3 under the BSD 3-Clause "New" or "Revised" License license
|
||||
*
|
||||
* <p>This class provides functionality for managing native memory.
|
||||
*
|
||||
* <p>All methods in this class will make use of {@link sun.misc.Unsafe} if it's available, for performance. If Unsafe is not available, the fallback
|
||||
* implementations make use of reflection and, in the worst-case, JNI.</p>
|
||||
*
|
||||
* <p>Method names in this class are prefixed with {@code mem} to avoid ambiguities when used with static imports.</p>
|
||||
*/
|
||||
public class CompatMemoryUtil {
|
||||
public static final long NULL = 0;
|
||||
|
||||
static final sun.misc.Unsafe UNSAFE;
|
||||
|
||||
private static final Class<? extends ByteBuffer> BUFFER_BYTE;
|
||||
private static final Class<? extends IntBuffer> BUFFER_INT;
|
||||
private static final Class<? extends FloatBuffer> BUFFER_FLOAT;
|
||||
|
||||
private static final long MARK;
|
||||
private static final long POSITION;
|
||||
private static final long LIMIT;
|
||||
private static final long CAPACITY;
|
||||
|
||||
private static final long ADDRESS;
|
||||
|
||||
static {
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(0).order(ByteOrder.nativeOrder());
|
||||
BUFFER_BYTE = bb.getClass();
|
||||
BUFFER_INT = bb.asIntBuffer().getClass();
|
||||
BUFFER_FLOAT = bb.asFloatBuffer().getClass();
|
||||
|
||||
UNSAFE = getUnsafeInstance();
|
||||
|
||||
MARK = getMarkOffset();
|
||||
POSITION = getPositionOffset();
|
||||
LIMIT = getLimitOffset();
|
||||
CAPACITY = getCapacityOffset();
|
||||
|
||||
ADDRESS = getAddressOffset();
|
||||
}
|
||||
|
||||
public static ByteBuffer memReallocDirect(ByteBuffer old, int capacity) {
|
||||
ByteBuffer newBuf = BufferUtils.createByteBuffer(capacity);
|
||||
int oldPos = old.position();
|
||||
old.rewind();
|
||||
newBuf.put(old);
|
||||
newBuf.position(Math.min(capacity, oldPos));
|
||||
return newBuf;
|
||||
}
|
||||
|
||||
public static IntBuffer memReallocDirect(IntBuffer old, int capacity) {
|
||||
IntBuffer newBuf = BufferUtils.createIntBuffer(capacity);
|
||||
int oldPos = old.position();
|
||||
old.rewind();
|
||||
newBuf.put(old);
|
||||
newBuf.position(Math.min(capacity, oldPos));
|
||||
return newBuf;
|
||||
}
|
||||
|
||||
public static FloatBuffer memReallocDirect(FloatBuffer old, int capacity) {
|
||||
FloatBuffer newBuf = BufferUtils.createFloatBuffer(capacity);
|
||||
int oldPos = old.position();
|
||||
old.rewind();
|
||||
newBuf.put(old);
|
||||
newBuf.position(Math.min(capacity, oldPos));
|
||||
return newBuf;
|
||||
}
|
||||
|
||||
/* -------------------------------------
|
||||
-------------------------------------
|
||||
UNSAFE MEMORY ACCESS API
|
||||
-------------------------------------
|
||||
------------------------------------- */
|
||||
|
||||
private static final int FILL_PATTERN_32 = Integer.divideUnsigned(-1, 255);
|
||||
private static final long FILL_PATTERN_64 = Long.divideUnsigned(-1L, 255L);
|
||||
|
||||
/**
|
||||
* Sets all bytes in a specified block of memory to a fixed value (usually zero).
|
||||
*
|
||||
* @param ptr the starting memory address
|
||||
* @param value the value to set (memSet will convert it to unsigned byte)
|
||||
* @param bytes the number of bytes to set
|
||||
*/
|
||||
public static void memSet(long ptr, int value, long bytes) {
|
||||
if (/*DEBUG*/ false && (ptr == NULL || bytes < 0)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
/*
|
||||
- Unsafe.setMemory is very slow.
|
||||
- A custom Java loop is fastest at small sizes, approximately up to 256 bytes.
|
||||
- The native memset becomes fastest at bigger sizes, when the JNI overhead becomes negligible.
|
||||
TODO: verify this
|
||||
*/
|
||||
|
||||
//UNSAFE.setMemory(ptr, bytes, (byte)(value & 0xFF));
|
||||
//if (bytes < 256L) {
|
||||
int p = (int)ptr;
|
||||
if (BITS64) {
|
||||
if ((p & 7) == 0) {
|
||||
memSet64(ptr, value, (int)bytes & 0xFF);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ((p & 3) == 0) {
|
||||
memSet32(p, value, (int)bytes & 0xFF);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//}
|
||||
//nmemset(ptr, value, bytes);
|
||||
}
|
||||
private static void memSet64(long ptr, int value, int bytes) {
|
||||
int aligned = bytes & ~7;
|
||||
|
||||
// Aligned body
|
||||
long valuel = (value & 0xFF) * FILL_PATTERN_64;
|
||||
for (int i = 0; i < aligned; i += 8) {
|
||||
UNSAFE.putLong(null, ptr + i, valuel);
|
||||
}
|
||||
|
||||
// Unaligned tail
|
||||
byte valueb = (byte)(value & 0xFF);
|
||||
for (int i = aligned; i < bytes; i++) {
|
||||
UNSAFE.putByte(null, ptr + i, valueb);
|
||||
}
|
||||
}
|
||||
private static void memSet32(int ptr, int value, int bytes) {
|
||||
int aligned = bytes & ~3;
|
||||
|
||||
// Aligned body
|
||||
int vi = (value & 0xFF) * FILL_PATTERN_32;
|
||||
for (int i = 0; i < aligned; i += 4) {
|
||||
UNSAFE.putInt(null, (ptr + i) & 0xFFFF_FFFFL, vi);
|
||||
}
|
||||
|
||||
// Unaligned tail
|
||||
byte vb = (byte)(value & 0xFF);
|
||||
for (int i = aligned; i < bytes; i++) {
|
||||
UNSAFE.putByte(null, (ptr + i) & 0xFFFF_FFFFL, vb);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean memGetBoolean(long ptr) { return UNSAFE.getByte(null, ptr) != 0; }
|
||||
public static byte memGetByte(long ptr) { return UNSAFE.getByte(null, ptr); }
|
||||
public static short memGetShort(long ptr) { return UNSAFE.getShort(null, ptr); }
|
||||
public static int memGetInt(long ptr) { return UNSAFE.getInt(null, ptr); }
|
||||
public static long memGetLong(long ptr) { return UNSAFE.getLong(null, ptr); }
|
||||
public static float memGetFloat(long ptr) { return UNSAFE.getFloat(null, ptr); }
|
||||
public static double memGetDouble(long ptr) { return UNSAFE.getDouble(null, ptr); }
|
||||
|
||||
public static void memPutByte(long ptr, byte value) { UNSAFE.putByte(null, ptr, value); }
|
||||
public static void memPutShort(long ptr, short value) { UNSAFE.putShort(null, ptr, value); }
|
||||
public static void memPutInt(long ptr, int value) { UNSAFE.putInt(null, ptr, value); }
|
||||
public static void memPutLong(long ptr, long value) { UNSAFE.putLong(null, ptr, value); }
|
||||
public static void memPutFloat(long ptr, float value) { UNSAFE.putFloat(null, ptr, value); }
|
||||
public static void memPutDouble(long ptr, double value) { UNSAFE.putDouble(null, ptr, value); }
|
||||
|
||||
// -------------------------------------------------
|
||||
// -------------------------------------------------
|
||||
// -------------------------------------------------
|
||||
|
||||
private static sun.misc.Unsafe getUnsafeInstance() {
|
||||
java.lang.reflect.Field[] fields = sun.misc.Unsafe.class.getDeclaredFields();
|
||||
|
||||
/*
|
||||
Different runtimes use different names for the Unsafe singleton,
|
||||
so we cannot use .getDeclaredField and we scan instead. For example:
|
||||
|
||||
Oracle: theUnsafe
|
||||
PERC : m_unsafe_instance
|
||||
Android: THE_ONE
|
||||
*/
|
||||
for (java.lang.reflect.Field field : fields) {
|
||||
if (!field.getType().equals(sun.misc.Unsafe.class)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int modifiers = field.getModifiers();
|
||||
if (!(java.lang.reflect.Modifier.isStatic(modifiers) && java.lang.reflect.Modifier.isFinal(modifiers))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
field.setAccessible(true);
|
||||
return (sun.misc.Unsafe)field.get(null);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
throw new UnsupportedOperationException("LWJGL requires sun.misc.Unsafe to be available.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively searches an object and its superclasses for a field with the same name and type. If the field isn't
|
||||
* public, it may not be stable across library/JVM versions, and these calls are likely not portable. You have been
|
||||
* warned!
|
||||
*/
|
||||
private static long getFieldOffset(Class<?> containerType, Class<?> fieldType, String name) {
|
||||
Class<?> c = containerType;
|
||||
while (c != Object.class) {
|
||||
Field[] fields = c.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (!field.getType().isAssignableFrom(fieldType) || Modifier.isStatic(field.getModifiers()) || field.isSynthetic()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long offset = UNSAFE.objectFieldOffset(field);
|
||||
if (field.getName().equals(name)) {
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
c = c.getSuperclass();
|
||||
}
|
||||
throw new UnsupportedOperationException("Failed to find field offset in class.");
|
||||
}
|
||||
|
||||
private static long getFieldOffset(Class<?> containerType, Class<?> fieldType, LongPredicate predicate) {
|
||||
Class<?> c = containerType;
|
||||
while (c != Object.class) {
|
||||
Field[] fields = c.getDeclaredFields();
|
||||
for (Field field : fields) {
|
||||
if (!field.getType().isAssignableFrom(fieldType) || Modifier.isStatic(field.getModifiers()) || field.isSynthetic()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
long offset = UNSAFE.objectFieldOffset(field);
|
||||
if (predicate.test(offset)) {
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
c = c.getSuperclass();
|
||||
}
|
||||
throw new UnsupportedOperationException("Failed to find field offset in class.");
|
||||
}
|
||||
|
||||
private static long getFieldOffsetInt(Object container, int value) {
|
||||
return getFieldOffset(container.getClass(), int.class, offset -> UNSAFE.getInt(container, offset) == value);
|
||||
}
|
||||
|
||||
private static long getAddressOffset() {
|
||||
final ByteBuffer bb = ByteBuffer.allocateDirect(0);
|
||||
return getFieldOffset(bb.getClass(), long.class, "address");
|
||||
|
||||
// TODO: do this portably
|
||||
// long MAGIC_ADDRESS = 0xDEADBEEF8BADF00DL & (BITS32 ? 0xFFFF_FFFFL : 0xFFFF_FFFF_FFFF_FFFFL);
|
||||
// ByteBuffer bb = Objects.requireNonNull(NewDirectByteBuffer(MAGIC_ADDRESS, 0));
|
||||
//return getFieldOffset(bb.getClass(), long.class, offset -> UNSAFE.getLong(bb, offset) == MAGIC_ADDRESS);
|
||||
}
|
||||
|
||||
private static final int MAGIC_CAPACITY = 0x0D15EA5E;
|
||||
private static final int MAGIC_POSITION = 0x00FACADE;
|
||||
|
||||
private static long getMarkOffset() {
|
||||
// TODO: is this actually reliable without NewDirectByteBuffer?
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(0);
|
||||
return getFieldOffsetInt(bb, -1);
|
||||
// ByteBuffer bb = Objects.requireNonNull(NewDirectByteBuffer(1L, 0));
|
||||
// return getFieldOffsetInt(bb, -1);
|
||||
}
|
||||
|
||||
private static long getPositionOffset() {
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(MAGIC_CAPACITY);
|
||||
bb.position(MAGIC_POSITION);
|
||||
return getFieldOffsetInt(bb, MAGIC_POSITION);
|
||||
}
|
||||
|
||||
private static long getLimitOffset() {
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(MAGIC_CAPACITY);
|
||||
bb.limit(MAGIC_POSITION);
|
||||
return getFieldOffsetInt(bb, MAGIC_POSITION);
|
||||
}
|
||||
|
||||
private static long getCapacityOffset() {
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(MAGIC_CAPACITY);
|
||||
bb.limit(0);
|
||||
return getFieldOffsetInt(bb, MAGIC_CAPACITY);
|
||||
}
|
||||
|
||||
static IntBuffer wrapBufferInt(long address, int capacity) {
|
||||
IntBuffer buffer;
|
||||
try {
|
||||
buffer = (IntBuffer)UNSAFE.allocateInstance(BUFFER_INT);
|
||||
} catch (InstantiationException e) {
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
|
||||
UNSAFE.putLong(buffer, ADDRESS, address);
|
||||
UNSAFE.putInt(buffer, MARK, -1);
|
||||
UNSAFE.putInt(buffer, LIMIT, capacity);
|
||||
UNSAFE.putInt(buffer, CAPACITY, capacity);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static FloatBuffer wrapBufferFloat(long address, int capacity) {
|
||||
FloatBuffer buffer;
|
||||
try {
|
||||
buffer = (FloatBuffer)UNSAFE.allocateInstance(BUFFER_FLOAT);
|
||||
} catch (InstantiationException e) {
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
|
||||
UNSAFE.putLong(buffer, ADDRESS, address);
|
||||
UNSAFE.putInt(buffer, MARK, -1);
|
||||
UNSAFE.putInt(buffer, LIMIT, capacity);
|
||||
UNSAFE.putInt(buffer, CAPACITY, capacity);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
/*
|
||||
* This class is backported from LWJGL3 under the BSD 3-clause "New" or "Revised" License
|
||||
*/
|
||||
|
||||
package com.gtnewhorizons.angelica.compat.lwjgl;
|
||||
|
||||
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutDouble;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutFloat;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutInt;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutLong;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memPutShort;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.memSet;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.wrapBufferFloat;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.wrapBufferInt;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.MemoryUtil;
|
||||
|
||||
/**
|
||||
* An off-heap memory stack.
|
||||
*
|
||||
* <p>This class should be used in a thread-local manner for stack allocations.</p>
|
||||
*
|
||||
* @ see Configuration#STACK_SIZE
|
||||
* @ see Configuration#DEBUG_STACK
|
||||
*/
|
||||
@SuppressWarnings("LombokGetterMayBeUsed")
|
||||
public class MemoryStack extends Pointer.Default implements AutoCloseable {
|
||||
|
||||
private static final int DEFAULT_STACK_SIZE = /*Configuration.STACK_SIZE.get(64)*/ 64 * 1024;
|
||||
private static final int DEFAULT_STACK_FRAMES = 8;
|
||||
|
||||
private static final ThreadLocal<MemoryStack> TLS = ThreadLocal.withInitial(MemoryStack::create);
|
||||
|
||||
static {
|
||||
if (DEFAULT_STACK_SIZE < 0) {
|
||||
throw new IllegalStateException("Invalid stack size.");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({"FieldCanBeLocal", "unused"})
|
||||
private final @Nullable ByteBuffer container;
|
||||
|
||||
private final int size;
|
||||
|
||||
private int pointer;
|
||||
|
||||
private int[] frames;
|
||||
protected int frameIndex;
|
||||
|
||||
/**
|
||||
* Creates a new {@code MemoryStack} backed by the specified memory region.
|
||||
*
|
||||
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
|
||||
*
|
||||
* @param container the backing memory buffer, may be null
|
||||
* @param address the backing memory address
|
||||
* @param size the backing memory size
|
||||
*/
|
||||
protected MemoryStack(@Nullable ByteBuffer container, long address, int size) {
|
||||
super(address);
|
||||
this.container = container;
|
||||
|
||||
this.size = size;
|
||||
this.pointer = size;
|
||||
|
||||
this.frames = new int[DEFAULT_STACK_FRAMES];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code MemoryStack} with the default size.
|
||||
*
|
||||
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
|
||||
*/
|
||||
public static MemoryStack create() {
|
||||
return create(DEFAULT_STACK_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code MemoryStack} with the specified size.
|
||||
*
|
||||
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
|
||||
*
|
||||
* @param capacity the maximum number of bytes that may be allocated on the stack
|
||||
*/
|
||||
public static MemoryStack create(int capacity) {
|
||||
return create(BufferUtils.createByteBuffer(capacity));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code MemoryStack} backed by the specified memory buffer.
|
||||
*
|
||||
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
|
||||
*
|
||||
* @param buffer the backing memory buffer
|
||||
*/
|
||||
public static MemoryStack create(ByteBuffer buffer) {
|
||||
long address = MemoryUtil.getAddress(buffer);
|
||||
int size = buffer.remaining();
|
||||
return new MemoryStack(buffer, address, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@code MemoryStack} backed by the specified memory region.
|
||||
*
|
||||
* <p>In the initial state, there is no active stack frame. The {@link #push} method must be used before any allocations.</p>
|
||||
*
|
||||
* @param address the backing memory address
|
||||
* @param size the backing memory size
|
||||
*/
|
||||
public static MemoryStack ncreate(long address, int size) {
|
||||
return new MemoryStack(null, address, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the current stack pointer and pushes a new frame to the stack.
|
||||
*
|
||||
* <p>This method should be called when entering a method, before doing any stack allocations. When exiting a method, call the {@link #pop} method to
|
||||
* restore the previous stack frame.</p>
|
||||
*
|
||||
* <p>Pairs of push/pop calls may be nested. Care must be taken to:</p>
|
||||
* <ul>
|
||||
* <li>match every push with a pop</li>
|
||||
* <li>not call pop before push has been called at least once</li>
|
||||
* <li>not nest push calls to more than the maximum supported depth</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return this stack
|
||||
*/
|
||||
public MemoryStack push() {
|
||||
if (frameIndex == frames.length) {
|
||||
frameOverflow();
|
||||
}
|
||||
|
||||
frames[frameIndex++] = pointer;
|
||||
return this;
|
||||
}
|
||||
|
||||
private void frameOverflow() {
|
||||
if (/*DEBUG*/ false) {
|
||||
AngelicaTweaker.LOGGER.warn("[WARNING] Out of frame stack space (" + frames.length + ") in thread: " + Thread.currentThread());
|
||||
}
|
||||
frames = Arrays.copyOf(frames, frames.length * 3 / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops the current stack frame and moves the stack pointer to the end of the previous stack frame.
|
||||
*
|
||||
* @return this stack
|
||||
*/
|
||||
public MemoryStack pop() {
|
||||
pointer = frames[--frameIndex];
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #pop} on this {@code MemoryStack}.
|
||||
*
|
||||
* <p>This method should not be used directly. It is called automatically when the {@code MemoryStack} is used as a resource in a try-with-resources
|
||||
* statement.</p>
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
//noinspection resource
|
||||
pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the backing off-heap memory.
|
||||
*
|
||||
* <p>The stack grows "downwards", so the bottom of the stack is at {@code address + size}, while the top is at {@code address}.</p>
|
||||
*/
|
||||
public long getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the backing off-heap memory.
|
||||
*
|
||||
* <p>This is the maximum number of bytes that may be allocated on the stack.</p>
|
||||
*/
|
||||
public int getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current frame index.
|
||||
*
|
||||
* <p>This is the current number of nested {@link #push} calls.</p>
|
||||
*/
|
||||
public int getFrameIndex() {
|
||||
return frameIndex;
|
||||
}
|
||||
|
||||
/** Returns the memory address at the current stack pointer. */
|
||||
public long getPointerAddress() {
|
||||
return address + (pointer & 0xFFFF_FFFFL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current stack pointer.
|
||||
*
|
||||
* <p>The stack grows "downwards", so when the stack is empty {@code pointer} is equal to {@code size}. On every allocation {@code pointer} is reduced by
|
||||
* the allocated size (after alignment) and {@code address + pointer} points to the first byte of the last allocation.</p>
|
||||
*
|
||||
* <p>Effectively, this methods returns how many more bytes may be allocated on the stack.</p>
|
||||
*/
|
||||
public int getPointer() {
|
||||
return pointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current stack pointer.
|
||||
*
|
||||
* <p>This method directly manipulates the stack pointer. Using it irresponsibly may break the internal state of the stack. It should only be used in rare
|
||||
* cases or in auto-generated code.</p>
|
||||
*/
|
||||
public void setPointer(int pointer) {
|
||||
if (/*CHECKS*/ false) {
|
||||
checkPointer(pointer);
|
||||
}
|
||||
|
||||
this.pointer = pointer;
|
||||
}
|
||||
|
||||
private void checkPointer(int pointer) {
|
||||
if (pointer < 0 || size < pointer) {
|
||||
throw new IndexOutOfBoundsException("Invalid stack pointer");
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkAlignment(int alignment) {
|
||||
if (Integer.bitCount(alignment) != 1) {
|
||||
throw new IllegalArgumentException("Alignment must be a power-of-two value.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #nmalloc(int, int)} with {@code alignment} equal to {@link Pointer#POINTER_SIZE POINTER_SIZE}.
|
||||
*
|
||||
* @param size the allocation size
|
||||
*
|
||||
* @return the memory address on the stack for the requested allocation
|
||||
*/
|
||||
public long nmalloc(int size) {
|
||||
return nmalloc(POINTER_SIZE, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a block of {@code size} bytes of memory on the stack. The content of the newly allocated block of memory is not initialized, remaining with
|
||||
* indeterminate values.
|
||||
*
|
||||
* @param alignment the required alignment
|
||||
* @param size the allocation size
|
||||
*
|
||||
* @return the memory address on the stack for the requested allocation
|
||||
*/
|
||||
public long nmalloc(int alignment, int size) {
|
||||
// Align address to the specified alignment
|
||||
long address = (this.address + pointer - size) & ~Integer.toUnsignedLong(alignment - 1);
|
||||
|
||||
pointer = (int)(address - this.address);
|
||||
if (/*CHECKS*/ false && pointer < 0) {
|
||||
throw new OutOfMemoryError("Out of stack space.");
|
||||
}
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a block of memory on the stack for an array of {@code num} elements, each of them {@code size} bytes long, and initializes all its bits to
|
||||
* zero.
|
||||
*
|
||||
* @param alignment the required element alignment
|
||||
* @param num num the number of elements to allocate
|
||||
* @param size the size of each element
|
||||
*
|
||||
* @return the memory address on the stack for the requested allocation
|
||||
*/
|
||||
public long ncalloc(int alignment, int num, int size) {
|
||||
int bytes = num * size;
|
||||
long address = nmalloc(alignment, bytes);
|
||||
memSet(address, 0, bytes);
|
||||
return address;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
/** Unsafe version of {@link #shorts(short)}. */
|
||||
public long nshort(short value) {
|
||||
long a = nmalloc(2, 2);
|
||||
memPutShort(a, value);
|
||||
return a;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
/** Int version of {@link #malloc(int)}. */
|
||||
public IntBuffer mallocInt(int size) { return wrapBufferInt(nmalloc(4, size << 2), size); }
|
||||
|
||||
/** Unsafe version of {@link #ints(int)}. */
|
||||
public long nint(int value) {
|
||||
long a = nmalloc(4, 4);
|
||||
memPutInt(a, value);
|
||||
return a;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
/** Unsafe version of {@link #longs(long)}. */
|
||||
public long nlong(long value) {
|
||||
long a = nmalloc(8, 8);
|
||||
memPutLong(a, value);
|
||||
return a;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
/** Float version of {@link #malloc(int)}. */
|
||||
public FloatBuffer mallocFloat(int size) { return wrapBufferFloat(nmalloc(4, size << 2), size); }
|
||||
|
||||
/** Unsafe version of {@link #floats(float)}. */
|
||||
public long nfloat(float value) {
|
||||
long a = nmalloc(4, 4);
|
||||
memPutFloat(a, value);
|
||||
return a;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
/** Unsafe version of {@link #doubles(double)}. */
|
||||
public long ndouble(double value) {
|
||||
long a = nmalloc(8, 8);
|
||||
memPutDouble(a, value);
|
||||
return a;
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
// -------------------------------------------------
|
||||
// -------------------------------------------------
|
||||
|
||||
|
||||
/** Returns the stack of the current thread. */
|
||||
public static MemoryStack stackGet() {
|
||||
return TLS.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #push} on the stack of the current thread.
|
||||
*
|
||||
* @return the stack of the current thread.
|
||||
*/
|
||||
public static MemoryStack stackPush() {
|
||||
return stackGet().push();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link #pop} on the stack of the current thread.
|
||||
*
|
||||
* @return the stack of the current thread.
|
||||
*/
|
||||
public static MemoryStack stackPop() {
|
||||
return stackGet().pop();
|
||||
}
|
||||
|
||||
/** Thread-local version of {@link #nmalloc(int)}. */
|
||||
public static long nstackMalloc(int size) { return stackGet().nmalloc(size); }
|
||||
/** Thread-local version of {@link #nmalloc(int, int)}. */
|
||||
public static long nstackMalloc(int alignment, int size) { return stackGet().nmalloc(alignment, size); }
|
||||
/** Thread-local version of {@link #ncalloc}. */
|
||||
public static long nstackCalloc(int alignment, int num, int size) { return stackGet().ncalloc(alignment, num, size); }
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* This class is backported from LWJGL3 under the BSD 3-clause "New" or "Revised" License
|
||||
*/
|
||||
package com.gtnewhorizons.angelica.compat.lwjgl;
|
||||
|
||||
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.NULL;
|
||||
import static com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil.UNSAFE;
|
||||
import static org.lwjgl.LWJGLUtil.CHECKS;
|
||||
|
||||
import net.minecraft.util.Util;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Pointer interface.
|
||||
*
|
||||
* <p>LWJGL can run on both 32bit and 64bit architectures. Since LWJGL applications deal with native memory directly, this interface provides necessary
|
||||
* information about the underlying architecture of the running JVM process.</p>
|
||||
*
|
||||
* <p>When interacting with native functions, pointer values are mapped to Java {@code long}. LWJGL automatically converts long values to the correct pointer
|
||||
* addresses when used in native code. Native functions sometimes require arrays of pointer values; the {@link PointerBuffer} class may be used for that
|
||||
* purpose. It has an API similar to a {@link java.nio.LongBuffer} but handles pointer casts automatically.</p>
|
||||
*/
|
||||
public interface Pointer {
|
||||
|
||||
/** The pointer size in bytes. Will be 4 on a 32bit JVM and 8 on a 64bit one. */
|
||||
int POINTER_SIZE = UNSAFE.addressSize();
|
||||
|
||||
/** The pointer size power-of-two. Will be 2 on a 32bit JVM and 3 on a 64bit one. */
|
||||
int POINTER_SHIFT = POINTER_SIZE == 8 ? 3 : 2;
|
||||
|
||||
/** The value of {@code sizeof(long)} for the current platform. */
|
||||
int CLONG_SIZE = POINTER_SIZE == 8 && Util.getOSType() == Util.EnumOS.WINDOWS ? 4 : POINTER_SIZE;
|
||||
|
||||
/** The value of {@code sizeof(long)} as a power-of-two. */
|
||||
int CLONG_SHIFT = CLONG_SIZE == 8 ? 3 : 2;
|
||||
|
||||
/** Will be true on a 32bit JVM. */
|
||||
boolean BITS32 = POINTER_SIZE * 8 == 32;
|
||||
|
||||
/** Will be true on a 64bit JVM. */
|
||||
boolean BITS64 = POINTER_SIZE * 8 == 64;
|
||||
|
||||
/**
|
||||
* Returns the raw pointer address as a {@code long} value.
|
||||
*
|
||||
* @return the pointer address
|
||||
*/
|
||||
long address();
|
||||
|
||||
/** Default {@link Pointer} implementation. */
|
||||
abstract class Default implements Pointer {
|
||||
|
||||
// Removed final due to JDK-8139758. TODO: Restore if the fix is backported to JDK 8.
|
||||
protected long address;
|
||||
|
||||
protected Default(long address) {
|
||||
if (CHECKS && address == NULL) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long address() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public boolean equals(@Nullable Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Pointer)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Pointer that = (Pointer)o;
|
||||
|
||||
return address == that.address();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return (int)(address ^ (address >>> 32));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s pointer [0x%X]", getClass().getSimpleName(), address);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-1
@@ -15,7 +15,6 @@ public class ByteBufferBackedInputStream extends InputStream {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (!buf.hasRemaining()) {
|
||||
return -1;
|
||||
|
||||
@@ -40,7 +40,6 @@ public class ChunkPos {
|
||||
return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int i = 1664525 * this.x + 1013904223;
|
||||
@@ -48,7 +47,6 @@ public class ChunkPos {
|
||||
return i ^ j;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
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,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -7,8 +8,6 @@ import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -59,20 +58,15 @@ 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);
|
||||
|
||||
final IntBuffer buffer = MemoryUtilities.memAllocInt(size);
|
||||
|
||||
try {
|
||||
try (final MemoryStack stack = MemoryStack.stackPush()) {
|
||||
final IntBuffer buffer = stack.mallocInt(size);
|
||||
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);
|
||||
@@ -110,15 +104,18 @@ public class NativeImage extends BufferedImage {
|
||||
|
||||
|
||||
public enum Format {
|
||||
RGBA(4, GL11.GL_RGBA),
|
||||
RGB(3, GL11.GL_RGB);
|
||||
RGBA(4, GL11.GL_RGBA, BufferedImage.TYPE_INT_ARGB),
|
||||
RGB(3, GL11.GL_RGB, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
private final int components;
|
||||
private final int glFormat;
|
||||
private final int imageType;
|
||||
|
||||
Format(int components, int glFormat) {
|
||||
|
||||
Format(int components, int glFormat, int imageType) {
|
||||
this.components = components;
|
||||
this.glFormat = glFormat;
|
||||
this.imageType = imageType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ 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, () -> {
|
||||
@@ -83,6 +84,7 @@ 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});
|
||||
}
|
||||
|
||||
@@ -95,23 +97,20 @@ 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> {
|
||||
@@ -169,7 +168,6 @@ 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;
|
||||
@@ -181,12 +179,10 @@ 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 + ']';
|
||||
}
|
||||
@@ -297,7 +293,6 @@ public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ 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 {
|
||||
@@ -97,7 +98,6 @@ public abstract class RenderPhase {
|
||||
this.endAction.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
@@ -109,12 +109,10 @@ public abstract class RenderPhase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -133,37 +133,19 @@ 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
|
||||
public static boolean enableZoom;
|
||||
|
||||
@Config.Comment("Optimizes in-world item rendering [Experimental]")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.Comment("Optimizes in-world item rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeInWorldItemRendering_WIP;
|
||||
public static boolean optimizeInWorldItemRendering;
|
||||
|
||||
@Config.Comment("Max amount of display lists to cache for optimized item rendering. Higher number will use more VRAM")
|
||||
@Config.DefaultInt(256)
|
||||
@Config.RangeInt(min = 64, max = 1024)
|
||||
public static int itemRendererDisplayListCacheSize;
|
||||
|
||||
@Config.Comment("Render distance for the spinning mob inside mod spawners")
|
||||
@Config.DefaultDouble(16D)
|
||||
@Config.RangeDouble(min = 16D, max = 64D)
|
||||
public static double mobSpawnerRenderDistance;
|
||||
|
||||
@Config.Comment("Switches to an alternate FPS limiter that gives more stable frametimes, in exchange for slightly " +
|
||||
"more latency. Will never introduce more than one frame of latency, and has a lower impact at higher framerates.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean sleepBeforeSwap;
|
||||
|
||||
@Config.Comment("Allows unicode languages to use an odd gui scale")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean removeUnicodeEvenScaling;
|
||||
}
|
||||
@@ -28,10 +28,9 @@ import static org.lwjgl.opengl.GL20.glUniform1;
|
||||
import static org.lwjgl.opengl.GL20.glUniform1f;
|
||||
import static org.lwjgl.opengl.GL20.glUniform1i;
|
||||
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack.*;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.shader.ShaderProgram;
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
|
||||
import java.nio.FloatBuffer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
@@ -132,7 +131,7 @@ public abstract class F3Graph {
|
||||
// Load vertex buffer
|
||||
vertBuf = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertBuf);
|
||||
try (final MemoryStack stack = stackPush()) {
|
||||
try (final MemoryStack stack = MemoryStack.stackPush()) {
|
||||
final FloatBuffer vertices = stack.mallocFloat(VERT_COUNT * VERT_FLOATS);
|
||||
// Since we use a triangle strip, we only need 4 vertices. The quad extends to the top of the screen so spikes
|
||||
// don't get truncated. The max height is replaced in the vert shader, no need to be precise.
|
||||
|
||||
@@ -18,6 +18,7 @@ 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,11 +7,9 @@ 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;
|
||||
|
||||
@@ -21,25 +19,21 @@ 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<List<IStateStack<?>>> maskToFeaturesMap = new Int2ObjectOpenHashMap<>();
|
||||
static final Int2ObjectMap<Set<IStateStack<?>>> maskToFeaturesMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static List<IStateStack<?>> maskToFeatures(int mask) {
|
||||
static Set<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));
|
||||
}
|
||||
}
|
||||
|
||||
final List<IStateStack<?>> asList = new ArrayList<>(features);
|
||||
|
||||
maskToFeaturesMap.put(mask, asList);
|
||||
return asList;
|
||||
maskToFeaturesMap.put(mask, features);
|
||||
return features;
|
||||
}
|
||||
|
||||
private static final Map<Integer, Set<IStateStack<?>>> attribToFeatures = new HashMap<>();
|
||||
|
||||
@@ -26,7 +26,6 @@ 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;
|
||||
@@ -36,7 +35,6 @@ 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;
|
||||
@@ -67,16 +65,11 @@ 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;
|
||||
@@ -140,21 +133,11 @@ 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();
|
||||
@@ -166,18 +149,11 @@ public class GLStateManager {
|
||||
while(!attribs.isEmpty()) {
|
||||
attribs.popInt();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS)) {
|
||||
while(!stack.isEmpty()) {
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
modelViewMatrix.clear();
|
||||
projectionMatrix.clear();
|
||||
}
|
||||
@@ -204,9 +180,6 @@ 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;
|
||||
@@ -425,11 +398,6 @@ 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);
|
||||
@@ -449,8 +417,6 @@ 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);
|
||||
};
|
||||
@@ -994,50 +960,30 @@ public class GLStateManager {
|
||||
glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, j);
|
||||
}
|
||||
|
||||
public static void trySyncProgram() {
|
||||
if (AngelicaConfig.enableIris) {
|
||||
public static void glDrawArrays(int mode, int first, int count) {
|
||||
// Iris -- TODO: This doesn't seem to work and is related to matchPass()
|
||||
if(AngelicaConfig.enableIris) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::syncProgram);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glBegin(int mode) {
|
||||
trySyncProgram();
|
||||
GL11.glBegin(mode);
|
||||
}
|
||||
|
||||
public static void glDrawElements(int mode, ByteBuffer indices) {
|
||||
trySyncProgram();
|
||||
GL11.glDrawElements(mode, indices);
|
||||
}
|
||||
|
||||
public static void glDrawElements(int mode, IntBuffer indices) {
|
||||
trySyncProgram();
|
||||
GL11.glDrawElements(mode, indices);
|
||||
}
|
||||
|
||||
public static void glDrawElements(int mode, ShortBuffer indices) {
|
||||
trySyncProgram();
|
||||
GL11.glDrawElements(mode, indices);
|
||||
}
|
||||
|
||||
public static void glDrawElements(int mode, int indices_count, int type, long indices_buffer_offset) {
|
||||
trySyncProgram();
|
||||
GL11.glDrawElements(mode, indices_count, type, indices_buffer_offset);
|
||||
}
|
||||
|
||||
public static void glDrawElements(int mode, int count, int type, ByteBuffer indices) {
|
||||
trySyncProgram();
|
||||
GL11.glDrawElements(mode, count, type, indices);
|
||||
GL11.glDrawArrays(mode, first, count);
|
||||
}
|
||||
|
||||
public static void glDrawBuffer(int mode) {
|
||||
trySyncProgram();
|
||||
GL11.glDrawBuffer(mode);
|
||||
}
|
||||
|
||||
public static void glDrawArrays(int mode, int first, int count) {
|
||||
trySyncProgram();
|
||||
GL11.glDrawArrays(mode, first, count);
|
||||
public static void glDrawElements(int mode, IntBuffer indices) {
|
||||
if(AngelicaConfig.enableIris) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::syncProgram);
|
||||
}
|
||||
GL11.glDrawElements(mode, indices);
|
||||
}
|
||||
|
||||
public static void glBegin(int mode) {
|
||||
if (AngelicaConfig.enableIris) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::syncProgram);
|
||||
}
|
||||
GL11.glBegin(mode);
|
||||
}
|
||||
|
||||
public static void glLogicOp(int opcode) {
|
||||
@@ -1245,21 +1191,13 @@ public class GLStateManager {
|
||||
glListNesting += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
glListId = list;
|
||||
glListMode = mode;
|
||||
GL11.glNewList(list, mode);
|
||||
|
||||
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);
|
||||
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(GL11.GL_ALL_ATTRIB_BITS)) {
|
||||
// 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);
|
||||
}
|
||||
@@ -1302,7 +1240,6 @@ public class GLStateManager {
|
||||
if(list < 0) {
|
||||
VBOManager.get(list).render();
|
||||
} else {
|
||||
trySyncProgram();
|
||||
GL11.glCallList(list);
|
||||
if(glListChanges.containsKey(list)) {
|
||||
for(Map.Entry<IStateStack<?>, ISettableState<?>> entry : glListChanges.get(list)) {
|
||||
@@ -1315,23 +1252,15 @@ public class GLStateManager {
|
||||
|
||||
public static void pushState(int mask) {
|
||||
attribs.push(mask);
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(mask);
|
||||
int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
stacks.get(i).push();
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(mask)) {
|
||||
stack.push();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static void popState() {
|
||||
final int mask = attribs.popInt();
|
||||
|
||||
List<IStateStack<?>> stacks = Feature.maskToFeatures(mask);
|
||||
int size = stacks.size();
|
||||
|
||||
for(int i = 0; i < size; i++) {
|
||||
stacks.get(i).pop();
|
||||
for(IStateStack<?> stack : Feature.maskToFeatures(mask)) {
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ 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() {}
|
||||
@@ -40,6 +41,7 @@ public class RenderSystem {
|
||||
dsaState = new DSACore();
|
||||
LOGGER.info("OpenGL 4.5 detected, enabling DSA.");
|
||||
}
|
||||
hasMultibind = GLStateManager.capabilities.OpenGL45;
|
||||
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
try {
|
||||
@@ -53,6 +55,10 @@ 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ 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,6 +18,7 @@ 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;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
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;
|
||||
@@ -31,7 +34,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 {
|
||||
|
||||
@@ -56,7 +59,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.Post fakePostEvent = new RenderGameOverlayEvent.Post(new RenderGameOverlayEvent(0, null, 0, 0), RenderGameOverlayEvent.ElementType.HELMET);
|
||||
private final static RenderGameOverlayEvent fakePreEvent = new RenderGameOverlayEvent.Pre(new RenderGameOverlayEvent(0, null, 0, 0), RenderGameOverlayEvent.ElementType.HELMET);
|
||||
|
||||
public static final HUDCaching INSTANCE = new HUDCaching();
|
||||
|
||||
@@ -122,21 +125,17 @@ 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) fakePostEvent).setPartialTicks(partialTicks);
|
||||
Renderer.INSTANCE.renderEvent(fakePostEvent);
|
||||
((RenderGameOverlayEventAccessor) fakePreEvent).setPartialTicks(partialTicks);
|
||||
Renderer.INSTANCE.renderEvent(fakePreEvent);
|
||||
}
|
||||
}
|
||||
if (renderPortalCapturedTicks > 0) {
|
||||
guiForge.callRenderPortal(width, height, partialTicks);
|
||||
}
|
||||
if (renderCrosshairsCaptured) {
|
||||
if (ModStatus.isXaerosMinimapLoaded){
|
||||
// this fixes the crosshair going invisible when no lines are being drawn under the minimap
|
||||
GLStateManager.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
guiForge.callRenderCrosshairs(width, height);
|
||||
}
|
||||
if (ModStatus.isThaumcraftLoaded || ModStatus.isThaumicHorizonsLoaded){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -152,5 +153,18 @@ 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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public enum Mixins {
|
||||
|
||||
ANGELICA_ITEM_DISPLAY_LIST_OPTIMIZATION(new Builder("Optimized item rendering by wrapping them with display lists")
|
||||
.setPhase(Phase.EARLY).addMixinClasses("angelica.itemrenderer.MixinItemRenderer").setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering_WIP)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering)
|
||||
.addTargetedMod(TargetedMod.VANILLA)),
|
||||
|
||||
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
|
||||
@@ -91,8 +91,8 @@ public enum Mixins {
|
||||
)
|
||||
),
|
||||
|
||||
ARCHAIC_CORE(new Builder("Archaic Core").addTargetedMod(TargetedMod.VANILLA).addExcludedMod(TargetedMod.ARCHAICFIX)
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY).addMixinClasses(
|
||||
ARCHAIC_CORE(new Builder("Archaic Core").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.archaic.MixinBlockFence"
|
||||
,"angelica.archaic.MixinFMLClientHandler"
|
||||
,"angelica.archaic.MixinGuiIngameForge"
|
||||
@@ -124,17 +124,19 @@ 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"
|
||||
,"sodium.MixinTileEntity"
|
||||
,"sodium.MixinTileEntityMobSpawner"
|
||||
,"sodium.MixinEffectRenderer"
|
||||
,"sodium.MixinTileEntityRendererDispatcher"
|
||||
,"sodium.MixinLongHashMap"
|
||||
@@ -149,6 +151,7 @@ public enum Mixins {
|
||||
,"shaders.MixinGuiIngameForge"
|
||||
,"shaders.MixinFramebuffer"
|
||||
,"shaders.MixinItem"
|
||||
,"shaders.MixinItemRenderer"
|
||||
,"shaders.MixinLocale"
|
||||
,"shaders.MixinOpenGlHelper"
|
||||
,"shaders.MixinRender"
|
||||
@@ -158,21 +161,15 @@ public enum Mixins {
|
||||
)
|
||||
),
|
||||
|
||||
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")
|
||||
.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"
|
||||
)
|
||||
),
|
||||
|
||||
ANGELICA_TEXTURE(new Builder("Textures").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
@@ -221,11 +218,6 @@ public enum Mixins {
|
||||
"angelica.animation.MixinWorldRenderer",
|
||||
"angelica.animation.MixinRenderItem")),
|
||||
|
||||
SCALED_RESOUTION_UNICODE_FIX(new Builder("Removes unicode languages gui scaling being forced to even values").setPhase(Phase.EARLY)
|
||||
.setSide(Side.CLIENT).addTargetedMod(TargetedMod.VANILLA)
|
||||
.setApplyIf(() -> AngelicaConfig.removeUnicodeEvenScaling)
|
||||
.addMixinClasses("angelica.bugfixes.MixinScaledResolution_UnicodeFix")),
|
||||
|
||||
EXTRA_UTILITIES_THREAD_SAFETY(new Builder("Enable thread safety fixes in Extra Utilities").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.EXTRAUTILS).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> CompatConfig.fixExtraUtils)
|
||||
@@ -527,7 +519,7 @@ public enum Mixins {
|
||||
&& !MCPatcherForgeConfig.ConnectedTextures.enabled
|
||||
&& MCPatcherForgeConfig.CustomColors.enabled)
|
||||
.addTargetedMod(TargetedMod.VANILLA)
|
||||
.addMixinClasses("mcpatcherforge.ctm_cc.MixinRenderBlocksNoCTM")
|
||||
.addMixinClasses("mcpatcherforge.cc_ctm.MixinRenderBlocksNoCTM")
|
||||
),
|
||||
MCPATCHER_FORGE_CTM_NO_CC(new Builder("MCP:F Connected Textures, no Custom Colours")
|
||||
.setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
|
||||
@@ -8,7 +8,6 @@ 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
@@ -0,0 +1,14 @@
|
||||
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
@@ -0,0 +1,9 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
public interface ExtendedBlockStorageAccessor {
|
||||
int getYBase();
|
||||
int getBlockRefCount();
|
||||
void setBlockRefCount(int blockRefCount);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
public interface ExtendedNibbleArray {
|
||||
public byte[] getData();
|
||||
public int getDepthBits();
|
||||
public int getDepthBitsPlusFour();
|
||||
}
|
||||
@@ -8,5 +8,4 @@ public interface ITexturesCache {
|
||||
|
||||
Set<IIcon> getRenderedTextures();
|
||||
void enableTextureTracking();
|
||||
void track(IPatchedTextureAtlasSprite sprite);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.util.Timer;
|
||||
|
||||
public interface MinecraftAccessor {
|
||||
Timer getTimer();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface SimpleTextureAccessor {
|
||||
ResourceLocation getLocation();
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
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,5 +1,6 @@
|
||||
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,7 +47,6 @@ 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;
|
||||
@@ -153,7 +152,7 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeypress(TickEvent.ClientTickEvent event) {
|
||||
final boolean isPressed = glsmKeyBinding.getKeyCode() != 0 && GameSettings.isKeyDown(glsmKeyBinding);
|
||||
final boolean isPressed = glsmKeyBinding.getKeyCode() != 0 && Keyboard.isKeyDown(glsmKeyBinding.getKeyCode());
|
||||
if (isPressed && !wasGLSMKeyPressed) {
|
||||
OpenGLDebugging.checkGLSM();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
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,6 +76,7 @@ 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
|
||||
@@ -347,6 +348,7 @@ 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;
|
||||
@@ -367,6 +369,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
mNode.name = redirects.get(mNode.name);
|
||||
changed = true;
|
||||
redirectInMethod = true;
|
||||
remaps++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -420,9 +423,6 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
|
||||
private static class RedirectMap<K> extends HashMap<K, K> {
|
||||
|
||||
private static final long serialVersionUID = 1712218575345511543L;
|
||||
|
||||
public static RedirectMap<String> newMap() {
|
||||
return new RedirectMap<>();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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,7 +1,5 @@
|
||||
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;
|
||||
@@ -30,26 +28,4 @@ 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,8 +172,6 @@ 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(0);
|
||||
boolean hasEffect = itemStack.hasEffect();
|
||||
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(0);
|
||||
boolean hasEffect = itemStack.hasEffect();
|
||||
List<Enchantment> list = enchantments.get(item);
|
||||
if (list == null) {
|
||||
list = allItemEnchantments;
|
||||
|
||||
@@ -32,6 +32,8 @@ 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;
|
||||
@@ -39,6 +41,7 @@ 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;
|
||||
@@ -47,6 +50,7 @@ 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) {
|
||||
@@ -129,6 +133,11 @@ 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,7 +170,6 @@ 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,6 +32,7 @@ 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,6 +10,8 @@ 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;
|
||||
@@ -19,7 +21,6 @@ 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,7 +61,6 @@ public class BlockStateMatcher {
|
||||
threadLocal.set(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String toString() {
|
||||
return fullString;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ 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,7 +110,6 @@ 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,7 +51,6 @@ 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) {
|
||||
@@ -67,7 +66,6 @@ public class TexturePackAPI {
|
||||
return resourcePacks;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Set<String> getNamespaces() {
|
||||
Set<String> namespaces = new HashSet<>();
|
||||
namespaces.add(DEFAULT_NAMESPACE);
|
||||
@@ -312,7 +310,6 @@ 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,7 +13,6 @@ 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,7 +60,6 @@ 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
|
||||
@@ -133,9 +132,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<Option<?>> settings = optionGroup.getOptions().stream().iterator();
|
||||
Iterator settings = optionGroup.getOptions().stream().iterator();
|
||||
while(settings.hasNext()) {
|
||||
Option<?> optionOne = settings.next();
|
||||
Option<?> optionTwo = settings.hasNext() ? settings.next() : null;
|
||||
Option optionOne = (Option)settings.next();
|
||||
Option optionTwo = settings.hasNext() ? (Option)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,7 +213,6 @@ 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,7 +22,6 @@ 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<T> cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
return new CyclingControlElement<>(option, dim, allowedValues, names);
|
||||
public <T extends Enum<T>> ControlElement cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
return new CyclingControlElement(option, dim, allowedValues, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControlElement<Integer> sliderControlElement(Option<Integer> option, Dim2i dim, int min, int max, int interval, ControlValueFormatter formatter) {
|
||||
public ControlElement 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<Boolean> tickBoxElement(Option<Boolean> option, Dim2i dim) {
|
||||
public ControlElement tickBoxElement(Option<Boolean> option, Dim2i dim) {
|
||||
return new TickBoxControlElement(option, dim);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ 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,7 +10,6 @@ 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,23 +1,19 @@
|
||||
package jss.notfine.proxy;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import jss.notfine.config.NotFineConfig;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
if(!NotFineConfig.allowAdvancedOpenGL) {
|
||||
Minecraft.getMinecraft().gameSettings.advancedOpengl = false;
|
||||
}
|
||||
@@ -33,13 +29,12 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) { }
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
SettingsManager.settingsFile.loadSettings();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void worldLoad(WorldEvent.Load event) {
|
||||
SettingsManager.graphicsUpdated();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package jss.notfine.util.itembreakparticles;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public interface IWorldSpawnItemBreakParticle {
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class MissingTokenException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = -2096321911994168858L;
|
||||
|
||||
public MissingTokenException(String message, int index) {
|
||||
public MissingTokenException(String message, int index) {
|
||||
super(message + " at index " + index);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public abstract class ParseException extends Exception{
|
||||
|
||||
private static final long serialVersionUID = -5014053641238717471L;
|
||||
|
||||
public ParseException() {
|
||||
public ParseException() {
|
||||
}
|
||||
|
||||
public ParseException(String message) {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class UnexpectedCharacterException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = -3886198952263126846L;
|
||||
|
||||
public UnexpectedCharacterException(char expected, char actual, int index) {
|
||||
public UnexpectedCharacterException(char expected, char actual, int index) {
|
||||
this("Expected to read '" + expected + "' but got '" + actual + "' at index " + index);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class UnexpectedEndingException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = -3704913315979481520L;
|
||||
|
||||
public UnexpectedEndingException() {
|
||||
public UnexpectedEndingException() {
|
||||
this("Expected to read more text, but the string has ended");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package kroppeb.stareval.exception;
|
||||
|
||||
public class UnexpectedTokenException extends ParseException {
|
||||
|
||||
private static final long serialVersionUID = 689385399380177588L;
|
||||
|
||||
public UnexpectedTokenException(String message, int index) {
|
||||
public UnexpectedTokenException(String message, int index) {
|
||||
super(message + " at index " + index);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
|
||||
import me.jellysquid.mods.sodium.proxy.CommonProxy;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gl.util;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
|
||||
@@ -18,8 +17,8 @@ public class GlMultiDrawBatch {
|
||||
private boolean isBuilding;
|
||||
|
||||
public GlMultiDrawBatch(int capacity) {
|
||||
this.bufIndices = memAllocInt(capacity);
|
||||
this.bufLen = memAllocInt(capacity);
|
||||
this.bufIndices = BufferUtils.createIntBuffer(capacity);
|
||||
this.bufLen = BufferUtils.createIntBuffer(capacity);
|
||||
}
|
||||
|
||||
public IntBuffer getIndicesBuffer() {
|
||||
@@ -60,8 +59,8 @@ public class GlMultiDrawBatch {
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
memFree(this.bufIndices);
|
||||
memFree(this.bufLen);
|
||||
this.bufIndices.clear();
|
||||
this.bufLen.clear();
|
||||
|
||||
this.bufIndices = null;
|
||||
this.bufLen = null;
|
||||
|
||||
@@ -89,7 +89,6 @@ public class SodiumGameOptionPages {
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.add(Settings.VOID_FOG.option);
|
||||
groups.add(firstGroupBuilder.build());
|
||||
@@ -128,15 +127,6 @@ public class SodiumGameOptionPages {
|
||||
}
|
||||
}, (opts) -> opts.fullScreen)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.sleepbeforeswap"))
|
||||
.setTooltip(I18n.format("options.angelica.sleepbeforeswap.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> {
|
||||
AngelicaConfig.sleepBeforeSwap = value;
|
||||
}, opts -> AngelicaConfig.sleepBeforeSwap)
|
||||
.setImpact(OptionImpact.VARIES)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, vanillaOpts)
|
||||
.setName(I18n.format("options.vsync"))
|
||||
.setTooltip(I18n.format("sodium.options.v_sync.tooltip"))
|
||||
@@ -174,15 +164,6 @@ public class SodiumGameOptionPages {
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
)
|
||||
.add(
|
||||
OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.mobSpawnerRenderDistance"))
|
||||
.setTooltip(I18n.format("options.angelica.mobSpawnerRenderDistance.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 16, 64, 1, ControlValueFormatter.number()))
|
||||
.setBinding((options, value) -> AngelicaConfig.mobSpawnerRenderDistance = value, options -> (int) AngelicaConfig.mobSpawnerRenderDistance)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("stat.generalButton"), ImmutableList.copyOf(groups));
|
||||
@@ -197,10 +178,8 @@ public class SodiumGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.graphics_quality.tooltip"))
|
||||
.setControl(option -> new CyclingControl<>(option, GraphicsMode.class))
|
||||
.setBinding(
|
||||
(opts, value) -> {
|
||||
opts.fancyGraphics = value.isFancy();
|
||||
SettingsManager.graphicsUpdated();
|
||||
},
|
||||
(opts, value) -> { opts.fancyGraphics = value.isFancy();
|
||||
SettingsManager.graphicsUpdated(); },
|
||||
opts -> GraphicsMode.fromBoolean(opts.fancyGraphics))
|
||||
.setImpact(OptionImpact.HIGH)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
|
||||
+3
-3
@@ -7,10 +7,10 @@ import me.jellysquid.mods.sodium.client.util.Dim2i;
|
||||
|
||||
public interface ControlElementFactory {
|
||||
|
||||
<T extends Enum<T>> ControlElement<T> cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names);
|
||||
<T extends Enum<T>> ControlElement cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names);
|
||||
|
||||
ControlElement<Integer> sliderControlElement(Option<Integer> option, Dim2i dim, int min, int max, int interval, ControlValueFormatter formatter);
|
||||
ControlElement sliderControlElement(Option<Integer> option, Dim2i dim, int min, int max, int interval, ControlValueFormatter formatter);
|
||||
|
||||
ControlElement<Boolean> tickBoxElement(Option<Boolean> option, Dim2i dim);
|
||||
ControlElement tickBoxElement(Option<Boolean> option, Dim2i dim);
|
||||
|
||||
}
|
||||
+4
-4
@@ -10,17 +10,17 @@ import net.minecraft.util.MathHelper;
|
||||
|
||||
public class SodiumControlElementFactory implements ControlElementFactory {
|
||||
@Override
|
||||
public <T extends Enum<T>> ControlElement<T> cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
return new CyclingControlElement<>(option, dim, allowedValues, names);
|
||||
public <T extends Enum<T>> ControlElement cyclingControlElement(Option<T> option, Dim2i dim, T[] allowedValues, String[] names) {
|
||||
return new CyclingControlElement(option, dim, allowedValues, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ControlElement<Integer> sliderControlElement(Option<Integer> option, Dim2i dim, int min, int max, int interval, ControlValueFormatter formatter) {
|
||||
public ControlElement 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<Boolean> tickBoxElement(Option<Boolean> option, Dim2i dim) {
|
||||
public ControlElement tickBoxElement(Option<Boolean> option, Dim2i dim) {
|
||||
return new TickBoxControlElement(option, dim);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.buffer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.gl.attribute.BufferVertexFormat;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -16,7 +16,7 @@ public class VertexBufferBuilder implements VertexBufferView {
|
||||
public VertexBufferBuilder(BufferVertexFormat vertexFormat, int initialCapacity) {
|
||||
this.vertexFormat = vertexFormat;
|
||||
|
||||
this.buffer = memAlloc(initialCapacity);
|
||||
this.buffer = BufferUtils.createByteBuffer(initialCapacity);
|
||||
this.capacity = initialCapacity;
|
||||
this.writerOffset = 0;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ public class VertexBufferBuilder implements VertexBufferView {
|
||||
// The new capacity will at least as large as the write it needs to service
|
||||
final int cap = Math.max(this.capacity * 2, this.capacity + len);
|
||||
|
||||
this.buffer = memRealloc(this.buffer, cap);
|
||||
this.buffer = CompatMemoryUtil.memReallocDirect(this.buffer, cap);
|
||||
this.capacity = cap;
|
||||
}
|
||||
|
||||
|
||||
+8
-9
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.glyph.writer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
@@ -16,13 +15,13 @@ public class GlyphVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe impl
|
||||
public void writeGlyph(float x, float y, float z, int color, float u, float v, int light) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
memPutFloat(i + 16, u);
|
||||
memPutFloat(i + 20, v);
|
||||
memPutInt(i + 24, light);
|
||||
CompatMemoryUtil.memPutFloat(i, x);
|
||||
CompatMemoryUtil.memPutFloat(i + 4, y);
|
||||
CompatMemoryUtil.memPutFloat(i + 8, z);
|
||||
CompatMemoryUtil.memPutInt(i + 12, color);
|
||||
CompatMemoryUtil.memPutFloat(i + 16, u);
|
||||
CompatMemoryUtil.memPutFloat(i + 20, v);
|
||||
CompatMemoryUtil.memPutInt(i + 24, light);
|
||||
|
||||
this.advance();
|
||||
|
||||
|
||||
+5
-6
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.line.writer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
@@ -16,10 +15,10 @@ public class LineVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imple
|
||||
public void vertexLine(float x, float y, float z, int color) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
CompatMemoryUtil.memPutFloat(i, x);
|
||||
CompatMemoryUtil.memPutFloat(i + 4, y);
|
||||
CompatMemoryUtil.memPutFloat(i + 8, z);
|
||||
CompatMemoryUtil.memPutInt(i + 12, color);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
+8
-9
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.particle.writer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
@@ -16,13 +15,13 @@ public class ParticleVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe i
|
||||
public void writeParticle(float x, float y, float z, float u, float v, int color, int light) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutFloat(i + 12, u);
|
||||
memPutFloat(i + 16, v);
|
||||
memPutInt(i + 20, color);
|
||||
memPutInt(i + 24, light);
|
||||
CompatMemoryUtil.memPutFloat(i, x);
|
||||
CompatMemoryUtil.memPutFloat(i + 4, y);
|
||||
CompatMemoryUtil.memPutFloat(i + 8, z);
|
||||
CompatMemoryUtil.memPutFloat(i + 12, u);
|
||||
CompatMemoryUtil.memPutFloat(i + 16, v);
|
||||
CompatMemoryUtil.memPutInt(i + 20, color);
|
||||
CompatMemoryUtil.memPutInt(i + 24, light);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
+10
-11
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.quad.writer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
@@ -16,15 +15,15 @@ public class QuadVertexBufferWriterUnsafe extends VertexBufferWriterUnsafe imple
|
||||
public void writeQuad(float x, float y, float z, int color, float u, float v, int light, int overlay, int normal) {
|
||||
final long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
memPutFloat(i + 16, u);
|
||||
memPutFloat(i + 20, v);
|
||||
memPutInt(i + 24, overlay);
|
||||
memPutInt(i + 28, light);
|
||||
memPutInt(i + 32, normal);
|
||||
CompatMemoryUtil.memPutFloat(i, x);
|
||||
CompatMemoryUtil.memPutFloat(i + 4, y);
|
||||
CompatMemoryUtil.memPutFloat(i + 8, z);
|
||||
CompatMemoryUtil.memPutInt(i + 12, color);
|
||||
CompatMemoryUtil.memPutFloat(i + 16, u);
|
||||
CompatMemoryUtil.memPutFloat(i + 20, v);
|
||||
CompatMemoryUtil.memPutInt(i + 24, overlay);
|
||||
CompatMemoryUtil.memPutInt(i + 28, light);
|
||||
CompatMemoryUtil.memPutInt(i + 32, normal);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
+5
-6
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.model.vertex.formats.screen_quad.writer;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.VanillaVertexTypes;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferView;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.buffer.VertexBufferWriterUnsafe;
|
||||
@@ -16,10 +15,10 @@ public class BasicScreenQuadVertexBufferWriterUnsafe extends VertexBufferWriterU
|
||||
public void writeQuad(float x, float y, float z, int color) {
|
||||
long i = this.writePointer;
|
||||
|
||||
memPutFloat(i, x);
|
||||
memPutFloat(i + 4, y);
|
||||
memPutFloat(i + 8, z);
|
||||
memPutInt(i + 12, color);
|
||||
CompatMemoryUtil.memPutFloat(i, x);
|
||||
CompatMemoryUtil.memPutFloat(i + 4, y);
|
||||
CompatMemoryUtil.memPutFloat(i + 8, z);
|
||||
CompatMemoryUtil.memPutInt(i + 12, color);
|
||||
|
||||
this.advance();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.MemoryStack;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package me.jellysquid.mods.sodium.client.render;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkPos;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
import lombok.Getter;
|
||||
@@ -26,6 +29,7 @@ import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTrackerHolder;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheShared;
|
||||
import me.jellysquid.mods.sodium.client.util.math.FrustumExtended;
|
||||
import me.jellysquid.mods.sodium.client.world.ChunkStatusListener;
|
||||
import me.jellysquid.mods.sodium.common.util.ListUtil;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
@@ -72,6 +76,7 @@ public class SodiumWorldRenderer {
|
||||
|
||||
private boolean useEntityCulling;
|
||||
|
||||
private final LongSet loadedChunkPositions = new LongOpenHashSet();
|
||||
private final Set<TileEntity> globalTileEntities = new ObjectOpenHashSet<>();
|
||||
|
||||
|
||||
@@ -343,11 +348,7 @@ public class SodiumWorldRenderer {
|
||||
}
|
||||
|
||||
private boolean checkBEVisibility(TileEntity entity) {
|
||||
var aabb = entity.getRenderBoundingBox();
|
||||
if (aabb == TileEntity.INFINITE_EXTENT_AABB) {
|
||||
return true;
|
||||
}
|
||||
return frustum.isBoundingBoxInFrustum(aabb);
|
||||
return frustum.isBoundingBoxInFrustum(entity.getRenderBoundingBox());
|
||||
}
|
||||
|
||||
private void renderTE(TileEntity tileEntity, int pass, float partialTicks) {
|
||||
|
||||
@@ -48,7 +48,6 @@ public class ChunkRenderContainer<T extends ChunkGraphicsState> {
|
||||
|
||||
private boolean rebuildableForTranslucents;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ChunkRenderContainer(ChunkRenderBackend<T> backend, SodiumWorldRenderer worldRenderer, int chunkX, int chunkY, int chunkZ, ChunkRenderColumn<T> column) {
|
||||
this.worldRenderer = worldRenderer;
|
||||
|
||||
|
||||
+19
-36
@@ -35,7 +35,6 @@ import me.jellysquid.mods.sodium.client.world.ChunkStatusListener;
|
||||
import me.jellysquid.mods.sodium.common.util.IdTable;
|
||||
import me.jellysquid.mods.sodium.common.util.collections.FutureDequeDrain;
|
||||
import net.coderbot.iris.shadows.ShadowRenderingState;
|
||||
import net.coderbot.iris.sodium.shadow_map.SwappableChunkRenderManager;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -48,7 +47,7 @@ import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkStatusListener, SwappableChunkRenderManager {
|
||||
public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkStatusListener {
|
||||
/**
|
||||
* The maximum distance a chunk can be from the player's camera in order to be eligible for blocking updates.
|
||||
*/
|
||||
@@ -123,6 +122,8 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
|
||||
private boolean dirtySwap;
|
||||
|
||||
private static final ObjectArrayFIFOQueue<?> EMPTY_QUEUE = new ObjectArrayFIFOQueue<>();
|
||||
|
||||
private static final ThreadLocal<BlockRenderPass> threadLocalRenderPass = ThreadLocal.withInitial(() -> BlockRenderPass.CUTOUT_MIPPED);
|
||||
public static int getWorldRenderPass() {
|
||||
return threadLocalRenderPass.get().ordinal();
|
||||
@@ -131,7 +132,6 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
threadLocalRenderPass.set(pass);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ChunkRenderManager(SodiumWorldRenderer renderer, ChunkRenderBackend<T> backend, WorldClient world, int renderDistance) {
|
||||
this.backend = backend;
|
||||
this.renderer = renderer;
|
||||
@@ -211,7 +211,6 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
for(Object o : this.renders.getElements()) {
|
||||
if(o == null)
|
||||
continue;
|
||||
@SuppressWarnings("unchecked")
|
||||
ChunkRenderContainer<T> render = (ChunkRenderContainer<T>)o;
|
||||
if(render.getData().isEmpty())
|
||||
continue;
|
||||
@@ -250,11 +249,7 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
}
|
||||
|
||||
private void addChunk(ChunkRenderContainer<T> render) {
|
||||
boolean canRebuild = render.canRebuild();
|
||||
|
||||
if (AngelicaConfig.enableIris && ShadowRenderingState.areShadowsCurrentlyBeingRendered()) {
|
||||
canRebuild = false;
|
||||
}
|
||||
final boolean canRebuild = AngelicaConfig.enableIris ? !ShadowRenderingState.areShadowsCurrentlyBeingRendered() : render.canRebuild();
|
||||
|
||||
if (render.needsRebuild() && canRebuild) {
|
||||
if (!this.alwaysDeferChunkUpdates && render.needsImportantRebuild()) {
|
||||
@@ -371,7 +366,9 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
private void reset() {
|
||||
if(!AngelicaConfig.enableIris || !ShadowRenderingState.areShadowsCurrentlyBeingRendered()) this.rebuildQueue.clear();
|
||||
if(!AngelicaConfig.enableIris || !ShadowRenderingState.areShadowsCurrentlyBeingRendered()) this.importantRebuildQueue.clear();
|
||||
if(!AngelicaConfig.enableIris || !ShadowRenderingState.areShadowsCurrentlyBeingRendered()) this.sortQueue.clear();
|
||||
|
||||
|
||||
this.sortQueue.clear();
|
||||
|
||||
this.visibleTileEntities.clear();
|
||||
|
||||
@@ -552,39 +549,25 @@ public class ChunkRenderManager<T extends ChunkGraphicsState> implements ChunkSt
|
||||
continue;
|
||||
}
|
||||
|
||||
CompletableFuture<ChunkBuildResult<T>> futureTask = this.builder.scheduleRebuildTaskAsync(render);
|
||||
|
||||
if (futureTask != null) {
|
||||
this.dirty = true;
|
||||
|
||||
// Do not allow distant chunks to block rendering
|
||||
if (this.alwaysDeferChunkUpdates || !this.isChunkPrioritized(render)) {
|
||||
this.builder.handleCompletion(futureTask);
|
||||
} else {
|
||||
futures.add(futureTask);
|
||||
}
|
||||
|
||||
submitted++;
|
||||
// Limit quantity of updates submitted if we are deferring all important builds
|
||||
if (this.alwaysDeferChunkUpdates && submitted >= budget)
|
||||
break;
|
||||
// Do not allow distant chunks to block rendering
|
||||
if (this.alwaysDeferChunkUpdates || !this.isChunkPrioritized(render)) {
|
||||
this.builder.deferRebuild(render);
|
||||
} else {
|
||||
// Immediately submit empty data to the queue and do not count this against the budget
|
||||
this.builder.enqueueUpload(new ChunkBuildResult<>(render, ChunkRenderData.EMPTY));
|
||||
futures.add(this.builder.scheduleRebuildTaskAsync(render));
|
||||
}
|
||||
|
||||
this.dirty = true;
|
||||
submitted++;
|
||||
// Limit quantity of updates submitted if we are deferring all important builds
|
||||
if (this.alwaysDeferChunkUpdates && submitted >= budget)
|
||||
break;
|
||||
}
|
||||
|
||||
while (submitted < budget && !this.rebuildQueue.isEmpty()) {
|
||||
ChunkRenderContainer<T> render = this.rebuildQueue.dequeue();
|
||||
|
||||
CompletableFuture<ChunkBuildResult<T>> futureTask = this.builder.scheduleRebuildTaskAsync(render);
|
||||
if(futureTask != null) {
|
||||
this.builder.handleCompletion(futureTask);
|
||||
submitted++;
|
||||
} else {
|
||||
// Immediately submit empty data to the queue and do not count this against the budget
|
||||
this.builder.enqueueUpload(new ChunkBuildResult<>(render, ChunkRenderData.EMPTY));
|
||||
}
|
||||
this.builder.deferRebuild(render);
|
||||
submitted++;
|
||||
}
|
||||
|
||||
// always do at least one sort
|
||||
|
||||
+5
-6
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import org.lwjgl.MemoryUtil;
|
||||
@@ -84,10 +83,10 @@ public abstract class ChunkDrawCallBatcher extends StructBuffer {
|
||||
throw new BufferUnderflowException();
|
||||
}
|
||||
|
||||
memPutInt(this.writePointer , count); // Vertex Count
|
||||
memPutInt(this.writePointer + 4, instanceCount); // Instance Count
|
||||
memPutInt(this.writePointer + 8, first); // Vertex Start
|
||||
memPutInt(this.writePointer + 12, baseInstance); // Base Instance
|
||||
CompatMemoryUtil.memPutInt(this.writePointer , count); // Vertex Count
|
||||
CompatMemoryUtil.memPutInt(this.writePointer + 4, instanceCount); // Instance Count
|
||||
CompatMemoryUtil.memPutInt(this.writePointer + 8, first); // Vertex Start
|
||||
CompatMemoryUtil.memPutInt(this.writePointer + 12, baseInstance); // Base Instance
|
||||
|
||||
this.writePointer += this.stride;
|
||||
}
|
||||
|
||||
+6
-7
@@ -1,7 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import org.lwjgl.MemoryUtil;
|
||||
|
||||
@@ -33,7 +32,7 @@ public abstract class ChunkDrawParamsVector extends StructBuffer {
|
||||
|
||||
protected void growBuffer() {
|
||||
this.capacity = this.capacity * 2;
|
||||
this.buffer = memRealloc(this.buffer, this.capacity * this.stride);
|
||||
this.buffer = CompatMemoryUtil.memReallocDirect(this.buffer, this.capacity * this.stride);
|
||||
}
|
||||
|
||||
public static class UnsafeChunkDrawCallVector extends ChunkDrawParamsVector {
|
||||
@@ -52,9 +51,9 @@ public abstract class ChunkDrawParamsVector extends StructBuffer {
|
||||
this.growBuffer();
|
||||
}
|
||||
|
||||
memPutFloat(this.writePointer , x);
|
||||
memPutFloat(this.writePointer + 4, y);
|
||||
memPutFloat(this.writePointer + 8, z);
|
||||
CompatMemoryUtil.memPutFloat(this.writePointer , x);
|
||||
CompatMemoryUtil.memPutFloat(this.writePointer + 4, y);
|
||||
CompatMemoryUtil.memPutFloat(this.writePointer + 8, z);
|
||||
|
||||
this.writePointer += this.stride;
|
||||
}
|
||||
@@ -65,7 +64,7 @@ public abstract class ChunkDrawParamsVector extends StructBuffer {
|
||||
|
||||
long offset = this.writePointer - this.basePointer;
|
||||
|
||||
this.basePointer = memAddress(this.buffer);
|
||||
this.basePointer = MemoryUtil.getAddress(this.buffer);
|
||||
this.writePointer = this.basePointer + offset;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
import com.gtnewhorizons.angelica.compat.lwjgl.CompatMemoryUtil;
|
||||
|
||||
public class IndirectCommandBufferVector extends StructBuffer {
|
||||
protected IndirectCommandBufferVector(int capacity) {
|
||||
@@ -32,6 +32,6 @@ public class IndirectCommandBufferVector extends StructBuffer {
|
||||
}
|
||||
|
||||
protected void growBuffer(int n) {
|
||||
this.buffer = memRealloc(this.buffer, Math.max(this.buffer.capacity() * 2, this.buffer.capacity() + n));
|
||||
this.buffer = CompatMemoryUtil.memReallocDirect(this.buffer, Math.max(this.buffer.capacity() * 2, this.buffer.capacity() + n));
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,6 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.MemoryUtil;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@@ -10,7 +11,7 @@ public abstract class StructBuffer {
|
||||
protected final int stride;
|
||||
|
||||
protected StructBuffer(int bytes, int stride) {
|
||||
this.buffer = memAlloc(bytes * stride);
|
||||
this.buffer = BufferUtils.createByteBuffer(bytes * stride);
|
||||
this.stride = stride;
|
||||
}
|
||||
|
||||
@@ -19,7 +20,7 @@ public abstract class StructBuffer {
|
||||
}
|
||||
|
||||
public long getBufferAddress() {
|
||||
return memAddress(this.buffer);
|
||||
return MemoryUtil.getAddress(this.buffer);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
||||
-1
@@ -72,7 +72,6 @@ public class ChunkOneshotGraphicsState extends ChunkGraphicsState {
|
||||
|
||||
commandList.uploadData(this.vertexBuffer, vertexData);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
GlVertexFormat<ChunkMeshAttribute> vertexFormat = (GlVertexFormat<ChunkMeshAttribute>) vertexData.format;
|
||||
|
||||
this.tessellation = commandList.createTessellation(GlPrimitiveType.QUADS, new TessellationBinding[] {
|
||||
|
||||
+13
-2
@@ -5,7 +5,6 @@ import it.unimi.dsi.fastutil.ints.IntArrays;
|
||||
import me.jellysquid.mods.sodium.client.model.vertex.type.ChunkVertexType;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.hfp.HFPModelVertexType;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.sfp.SFPModelVertexType;
|
||||
import net.coderbot.iris.sodium.vertex_format.terrain_xhfp.XHFPModelVertexType;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -15,10 +14,22 @@ import java.util.BitSet;
|
||||
|
||||
public class ChunkBufferSorter {
|
||||
|
||||
private static final Class<?> OCULUS_VERTEX_TYPE;
|
||||
|
||||
static {
|
||||
Class<?> clz;
|
||||
try {
|
||||
clz = Class.forName("net.coderbot.iris.compat.sodium.impl.vertex_format.terrain_xhfp.XHFPModelVertexType");
|
||||
} catch(Throwable e) {
|
||||
clz = null;
|
||||
}
|
||||
OCULUS_VERTEX_TYPE = clz;
|
||||
}
|
||||
|
||||
public static void sortStandardFormat(ChunkVertexType vertexType, ByteBuffer buffer, int bufferLen, float x, float y, float z) {
|
||||
boolean isCompact;
|
||||
|
||||
if(vertexType.getClass() == HFPModelVertexType.class || vertexType.getClass() == XHFPModelVertexType.class) {
|
||||
if(vertexType.getClass() == HFPModelVertexType.class || vertexType.getClass() == OCULUS_VERTEX_TYPE) {
|
||||
isCompact = true;
|
||||
} else if(vertexType.getClass() == SFPModelVertexType.class) {
|
||||
isCompact = false;
|
||||
|
||||
-2
@@ -142,8 +142,6 @@ public class ChunkBuildBuffers implements ChunkBuildBuffersExt {
|
||||
|
||||
if (sortTranslucent && pass.isTranslucent()) {
|
||||
ChunkBufferSorter.sortStandardFormat(vertexType, buffer, bufferLen, x, y, z);
|
||||
meshData.clearSlices();
|
||||
meshData.setModelSlice(ModelQuadFacing.UNASSIGNED, new BufferSlice(0, bufferLen));
|
||||
}
|
||||
|
||||
meshData.setVertexData(new VertexData(buffer, this.vertexType.getCustomVertexFormat()));
|
||||
|
||||
Loaded 100 of 226 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user