mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-18 11:29:08 +00:00
Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
169e584506 | ||
|
|
03eeec9d23 | ||
|
|
4d9bb7b9a5 | ||
|
|
08e411f70b | ||
|
|
d5a005a0ed | ||
|
|
5fddbcecec | ||
|
|
4dfe96639e | ||
|
|
96e7064192 | ||
|
|
1d46d0c32f | ||
|
|
0b66f7a255 | ||
|
|
d63bd7a8a5 | ||
|
|
9f8477c039 | ||
|
|
6526cac45a | ||
|
|
c37b1020e2 | ||
|
|
cc5905dfbc | ||
|
|
88af3a807a | ||
|
|
0b1cd16ed0 | ||
|
|
7614cfc2c4 | ||
|
|
39e7b5b3ea | ||
|
|
df3ff717f0 |
No files matched your search
@@ -1,67 +0,0 @@
|
||||
name: Report Bug
|
||||
description: "Report a bug."
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "A bug/crash report with sufficient information and logs to reproduce and track down."
|
||||
- type: input
|
||||
id: discord
|
||||
attributes:
|
||||
label: Your GTNH Discord Username
|
||||
description: Leave empty if you don't have one, but this will make it harder to contact you if we need additional info.
|
||||
placeholder: "Example: Fake#1234"
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Mod Version
|
||||
description: "What version of the Mod are you using?"
|
||||
placeholder: "Example: 1.0.0-alpha1"
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: java
|
||||
attributes:
|
||||
label: Java Version
|
||||
description: What Java version are you using? It's worth mentioning that if you play on Java9+ you should try update to latest minor release (e.g. prefer Java 17.0.6 over 17.0.2) of that version.
|
||||
options:
|
||||
- Java 8
|
||||
- Java 9
|
||||
- Java 11
|
||||
- Java 17
|
||||
- Java 19
|
||||
- Java 20
|
||||
- Java 21
|
||||
- Other (Please Specify)
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: report
|
||||
attributes:
|
||||
label: Bug Report
|
||||
description: "Relevant information, as well as relevant logs attached such as `logs/fml-client-latest.log."
|
||||
placeholder: "Example: https://mclo.gs/ OR submit the file to github by dragging it to this textbox."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: modlist
|
||||
attributes:
|
||||
label: Mod List or GTNH Pack Version
|
||||
description: "List of mods, ideally a minimal reproducible set (can be retrieved from latest.log). If using GTNH please indicate pack version and any changed mods, not the entire modlist."
|
||||
placeholder: "List of mods or GTNH Pack version goes here"
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: final
|
||||
attributes:
|
||||
label: Final Checklist
|
||||
description: Certify that you read things
|
||||
options:
|
||||
- label: "I have searched the issues and haven't found a similar issue."
|
||||
required: true
|
||||
- label: "I have read the known incompatibilities and this is not related to one of those."
|
||||
required: true
|
||||
- label: "I am running an officially released version. (Or, if I've compiled it myself I plan to fix the issue)"
|
||||
required: true
|
||||
- label: "This issue is not shader related (they aren't ready yet for testing)"
|
||||
required: true
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
@@ -1,60 +1,19 @@
|
||||
# Angelica
|
||||
* The little Angle [sic] that supports shaders while saving your fps from a certain death -boubou
|
||||
* Is it obtuse, or accute? -Caedis
|
||||
* It's a cute angle -mitchej123
|
||||
the little angle that supports shaders while saving your fps from a certain death - boubou
|
||||
|
||||
**Alpha Quality - Here there be Dragons**
|
||||
Not yet in an usable state
|
||||
|
||||
|
||||
# Required Dependencies
|
||||
* [UniMixins](https://github.com/LegacyModdingMC/UniMixins/releases) >= 0.1.14
|
||||
* [GTNHLib](https://github.com/GTNewHorizons/GTNHLib/releases) >= 0.2.1
|
||||
|
||||
# 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
|
||||
* EndlessIDs - Future compat planned
|
||||
* FalseTweaks - Future compat planned
|
||||
* SmoothFont - Future compat planned
|
||||
* RPLE - Future compat planned
|
||||
|
||||
# Permanent Incompatibilities
|
||||
* Optifine [Disabled, won't fix]
|
||||
* Fastcraft [Disable, won't fix]
|
||||
* BetterFPS [Won't fix]
|
||||
* LWJGL3ify 1.5.4 and below - Use the latest version available, 1.5.7+
|
||||
* ArchaicFix 0.6.2 and below - Use 0.7.0 or above
|
||||
* Hodgepodge 2.4.3 and below - [Use 2.4.4 or above](https://github.com/GTNewHorizons/Hodgepodge/releases)
|
||||
* CodeChicken[Core](https://github.com/GTNewHorizons/CodeChickenCore/releases)/[Lib](https://github.com/GTNewHorizons/CodeChickenLib/releases) <1.2.0 - Threading issues, use 1.2.0+
|
||||
* Neodymium - Untested, but unlikely to be compatible. (Chunk Meshing is definitely incompatible, other features might work depending on config)
|
||||
|
||||
# Credits
|
||||
* ShadersMod
|
||||
* Original ShadersMods: karyonix, sonic ether, id_miner, daxnitro
|
||||
* eigenraven, Caedis, glowredman, and mitchej123 for the conversion of ASM to Mixin
|
||||
* eigenraven and vlaetansky for getting the original ShadersMod compiling again
|
||||
* ArchaicFix
|
||||
* Includes graphic enhancements from [ArchaicFix](https://github.com/embeddedt/ArchaicFix/tree/4afb943751883b27a1f0aa7c5ba71698bc897e95) by embeddedt under the [LGPL](https://github.com/embeddedt/ArchaicFix/blob/main/LICENSE.md)
|
||||
* NotFine
|
||||
* Includes modified version of [NotFine](https://github.com/jss2a98aj/NotFine/tree/a2652e24b5654f437fb7138f6d1f5e947a7d7125) by jss2a98aj under the LGPL
|
||||
* Iris Shaders
|
||||
* The [Iris](https://github.com/IrisShaders/Iris) Team: coderbot, IMS212, Justsnoopy30, FoundationGames
|
||||
* Asek3 for the Iris Forge port [Oculus](https://github.com/Asek3/Oculus/tree/839ce8eca8cf0c4f6b7a1322b906e5c99125ca69)
|
||||
* Backported code under the LGPL
|
||||
* Sodium
|
||||
* JellySquid & the CaffeineMC team, for making Sodium in the first place
|
||||
* Embeddedt for [Embeddium](https://github.com/embeddedt/embeddium/tree/dc59ca357c25beefd6288f0d1d40b4cd8e670ab8) under the [LGPL 3.0](https://github.com/embeddedt/embeddium/blob/16.x/forge/LICENSE)
|
||||
* Reese's Sodium Options
|
||||
* FlashyReese for [Reese's Sodium Options](https://github.com/FlashyReese/reeses-sodium-options/tree/aa4ea67047cf53e54976e93c6bb1ab5ba16b142b) under the [MIT license](https://github.com/FlashyReese/reeses-sodium-options/blob/aa4ea67047cf53e54976e93c6bb1ab5ba16b142b/LICENSE.txt)
|
||||
* Neodymium
|
||||
* Makamys for [Neodymium](https://github.com/makamys/Neodymium) - Various Tessellator -> Quad functionality taken under the LGPL 3
|
||||
* MCPatcherForge
|
||||
* Original [MCPatcher](https://bitbucket.org/prupe/mcpatcher/src/master/): Paul Rupe
|
||||
* [Forge version](https://bitbucket.org/prupe/mcpatcher/src/master/): Mist475 under LGPL 3.0 with default ctm textures for glass and bookshelves by DarkBum under CC-BY-SA
|
||||
* HUDCaching
|
||||
* Created by [Moulberry](https://github.com/Moulberry/MCHUDCaching), backported from [Patcher](https://github.com/Sk1erLLC/Patcher) mod by Alexdoru under the CC-BY-SA-NC 4.0 license
|
||||
* Angelica
|
||||
* mitchej123, Omni, Makamys, Embeddedt, NanoLive, Caedis, Cardinalstar, Alexdoru, Eigenraven, mist475, Clepto for helping get Angelica up and running!
|
||||
* IMS, jss2a98aj, || dbp ||, roadhog360 for advice and moral support
|
||||
* Forge 1.12+
|
||||
* Some files have been taken from Minecraft Forge under the LGPL 2.1 license and are marked as such
|
||||
Original build instructions obtained via minecraftforums archeology:
|
||||
```
|
||||
Developing environment
|
||||
- Extract forge src to forge folder. Run "gradlew setupDecompWorkspace setupDevWorkspace" until it succeeded, then "gradlew build", then "gradlew eclipse".
|
||||
- Delete everything in src\main folder inside forge folder.
|
||||
- Extract smc-2.3.18-mc1.7.10-src.7z to src\main folder.
|
||||
- Read patch file shadersmod-mcf.patch
|
||||
- Find %userprofile%\.gradle\caches\minecraft\net\minecraftforge\forge\*\forgeSrc-*-sources.jar and extract it somewhere.
|
||||
-- Select files that need to be patched and copy them to src\main with correct folder structure.
|
||||
- Apply patch shadersmod-mcf.patch
|
||||
- In eclipse, add java_dev folder as another source folder.
|
||||
- In eclipse, exclude InitNames in src folder from build path. Use InitNames in java_dev folder instead.
|
||||
- Find %userprofile%\.gradle\caches\modules-2\files-2.1\net.minecraftforge\forge\*\*\forge-*-userdev.jar and extract conf\*.csv and conf\*.srg in it to forge\conf and rename packaged.srg to joined.srg.
|
||||
```
|
||||
+9
-5
@@ -1,7 +1,11 @@
|
||||
allprojects {
|
||||
gradle.projectsEvaluated {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs << "-Xmaxerrs" << "2000"
|
||||
}
|
||||
|
||||
configurations {
|
||||
compileStubs
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
compileStubsStubs
|
||||
compileStubs {
|
||||
compileClasspath += configurations.compileStubs
|
||||
}
|
||||
}
|
||||
+61
-94
@@ -1,4 +1,4 @@
|
||||
//version: 1705357285
|
||||
//version: 1692122114
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -28,11 +28,27 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
name 'forge'
|
||||
url 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
// GTNH RetroFuturaGradle and ASM Fork
|
||||
name "GTNH Maven"
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
}
|
||||
maven {
|
||||
name 'sonatype'
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
}
|
||||
maven {
|
||||
name 'Scala CI dependencies'
|
||||
url 'https://repo1.maven.org/maven2/'
|
||||
}
|
||||
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
@@ -48,12 +64,12 @@ plugins {
|
||||
id 'org.ajoberstar.grgit' version '4.1.1' // 4.1.1 is the last jvm8 supporting version, unused, available for addon.gradle
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
|
||||
id 'com.palantir.git-version' version '3.0.0' apply false
|
||||
id 'de.undercouch.download' version '5.5.0'
|
||||
id 'de.undercouch.download' version '5.4.0'
|
||||
id 'com.github.gmazzo.buildconfig' version '3.1.0' apply false // Unused, available for addon.gradle
|
||||
id 'com.diffplug.spotless' version '6.13.0' apply false // 6.13.0 is the last jvm8 supporting version
|
||||
id 'com.modrinth.minotaur' version '2.+' apply false
|
||||
id 'com.matthewprenger.cursegradle' version '1.4.0' apply false
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.27'
|
||||
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
|
||||
}
|
||||
|
||||
print("You might want to check out './gradlew :faq' if your build fails.\n")
|
||||
@@ -73,23 +89,6 @@ def out = services.get(StyledTextOutputFactory).create('an-output')
|
||||
def projectJavaVersion = JavaLanguageVersion.of(8)
|
||||
|
||||
boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
|
||||
boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false
|
||||
|
||||
final String CHECKSTYLE_CONFIG = """
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
<module name="TreeWalker">
|
||||
<!-- Use CHECKSTYLE:OFF and CHECKSTYLE:ON comments to suppress checkstyle lints in a block -->
|
||||
<module name="SuppressionCommentFilter"/>
|
||||
<module name="AvoidStarImport">
|
||||
<!-- Allow static wildcard imports for cases like Opcodes and LWJGL classes, these don't get created accidentally by the IDE -->
|
||||
<property name="allowStaticMemberImports" value="true"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
"""
|
||||
|
||||
checkPropertyExists("modName")
|
||||
checkPropertyExists("modId")
|
||||
@@ -117,12 +116,11 @@ propertyDefaultIfUnset("forceEnableMixins", false)
|
||||
propertyDefaultIfUnset("channel", "stable")
|
||||
propertyDefaultIfUnset("mappingsVersion", "12")
|
||||
propertyDefaultIfUnset("usesMavenPublishing", true)
|
||||
propertyDefaultIfUnset("mavenPublishUrl", "https://nexus.gtnewhorizons.com/repository/releases/")
|
||||
propertyDefaultIfUnset("mavenPublishUrl", "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases")
|
||||
propertyDefaultIfUnset("modrinthProjectId", "")
|
||||
propertyDefaultIfUnset("modrinthRelations", "")
|
||||
propertyDefaultIfUnset("curseForgeProjectId", "")
|
||||
propertyDefaultIfUnset("curseForgeRelations", "")
|
||||
propertyDefaultIfUnset("versionPattern", "")
|
||||
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
|
||||
propertyDefaultIfUnset("relocateShadowedDependencies", true)
|
||||
// Deprecated properties (kept for backwards compat)
|
||||
@@ -142,17 +140,6 @@ if (!disableSpotless) {
|
||||
apply from: Blowdryer.file('spotless.gradle')
|
||||
}
|
||||
|
||||
if (!disableCheckstyle) {
|
||||
apply plugin: 'checkstyle'
|
||||
tasks.named("checkstylePatchedMc") { enabled = false }
|
||||
tasks.named("checkstyleMcLauncher") { enabled = false }
|
||||
tasks.named("checkstyleIdeVirtualMain") { enabled = false }
|
||||
tasks.named("checkstyleInjectedTags") { enabled = false }
|
||||
checkstyle {
|
||||
config = resources.text.fromString(CHECKSTYLE_CONFIG)
|
||||
}
|
||||
}
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
String kotlinSourceDir = "src/main/kotlin/"
|
||||
@@ -287,7 +274,7 @@ if (apiPackage) {
|
||||
}
|
||||
|
||||
if (accessTransformersFile) {
|
||||
for (atFile in accessTransformersFile.split(" ")) {
|
||||
for (atFile in accessTransformersFile.split(",")) {
|
||||
String targetFile = "src/main/resources/META-INF/" + atFile.trim()
|
||||
if (!getFile(targetFile).exists()) {
|
||||
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
||||
@@ -371,7 +358,6 @@ catch (Exception ignored) {
|
||||
// Pulls version first from the VERSION env and then git tag
|
||||
String identifiedVersion
|
||||
String versionOverride = System.getenv("VERSION") ?: null
|
||||
boolean checkVersion = false
|
||||
try {
|
||||
// Produce a version based on the tag, or for branches something like 0.2.2-configurable-maven-and-extras.38+43090270b6-dirty
|
||||
if (versionOverride == null) {
|
||||
@@ -390,8 +376,6 @@ try {
|
||||
}
|
||||
} else if (isDirty) {
|
||||
identifiedVersion += "-${branchName}+${gitDetails.gitHash}-dirty"
|
||||
} else {
|
||||
checkVersion = true
|
||||
}
|
||||
} else {
|
||||
identifiedVersion = versionOverride
|
||||
@@ -413,8 +397,6 @@ ext {
|
||||
|
||||
if (identifiedVersion == versionOverride) {
|
||||
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
|
||||
} else if (checkVersion && versionPattern && !(identifiedVersion ==~ versionPattern)) {
|
||||
throw new GradleException("Invalid version: '$identifiedVersion' does not match version pattern '$versionPattern'")
|
||||
}
|
||||
|
||||
group = "com.github.GTNewHorizons"
|
||||
@@ -434,31 +416,18 @@ minecraft {
|
||||
for (f in replaceGradleTokenInFile.split(',')) {
|
||||
tagReplacementFiles.add f
|
||||
}
|
||||
out.style(Style.Info).text('replaceGradleTokenInFile is deprecated! Consider using generateGradleTokenClass.').println()
|
||||
}
|
||||
if (gradleTokenModId) {
|
||||
if (replaceGradleTokenInFile) {
|
||||
injectedTags.put gradleTokenModId, modId
|
||||
} else {
|
||||
out.style(Style.Failure).text('gradleTokenModId is deprecated! The field will no longer be generated.').println()
|
||||
}
|
||||
injectedTags.put gradleTokenModId, modId
|
||||
}
|
||||
if (gradleTokenModName) {
|
||||
if (replaceGradleTokenInFile) {
|
||||
injectedTags.put gradleTokenModName, modName
|
||||
} else {
|
||||
out.style(Style.Failure).text('gradleTokenModName is deprecated! The field will no longer be generated.').println()
|
||||
}
|
||||
injectedTags.put gradleTokenModName, modName
|
||||
}
|
||||
if (gradleTokenVersion) {
|
||||
injectedTags.put gradleTokenVersion, modVersion
|
||||
}
|
||||
if (gradleTokenGroupName) {
|
||||
if (replaceGradleTokenInFile) {
|
||||
injectedTags.put gradleTokenGroupName, modGroup
|
||||
} else {
|
||||
out.style(Style.Failure).text('gradleTokenGroupName is deprecated! The field will no longer be generated.').println()
|
||||
}
|
||||
injectedTags.put gradleTokenGroupName, modGroup
|
||||
}
|
||||
if (enableGenericInjection.toBoolean()) {
|
||||
injectMissingGenerics.set(true)
|
||||
@@ -590,17 +559,15 @@ afterEvaluate {
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
url = "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
// Links for convenience:
|
||||
// Simple HTML browsing: https://nexus.gtnewhorizons.com/service/rest/repository/browse/releases/
|
||||
// Rich web UI browsing: https://nexus.gtnewhorizons.com/#browse/browse:releases
|
||||
}
|
||||
maven {
|
||||
name 'Overmind forge repo mirror'
|
||||
url 'https://gregtech.overminddl1.com/'
|
||||
}
|
||||
maven {
|
||||
name = "GTNH Maven"
|
||||
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
}
|
||||
maven {
|
||||
name 'sonatype'
|
||||
url 'https://oss.sonatype.org/content/repositories/snapshots/'
|
||||
@@ -633,10 +600,15 @@ repositories {
|
||||
}
|
||||
maven {
|
||||
name = "ic2"
|
||||
url = getURL("https://maven2.ic2.player.to/", "https://maven.ic2.player.to/")
|
||||
content {
|
||||
includeGroup "net.industrial-craft"
|
||||
url = "https://maven.ic2.player.to/"
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "ic2-mirror"
|
||||
url = "https://maven2.ic2.player.to/"
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
@@ -651,7 +623,7 @@ repositories {
|
||||
|
||||
def mixinProviderGroup = "io.github.legacymoddingmc"
|
||||
def mixinProviderModule = "unimixins"
|
||||
def mixinProviderVersion = "0.1.13"
|
||||
def mixinProviderVersion = "0.1.7.1"
|
||||
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
|
||||
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
||||
ext.mixinProviderSpec = mixinProviderSpec
|
||||
@@ -692,8 +664,6 @@ configurations.all {
|
||||
substitute module('com.github.GTNewHorizons:SpongePoweredMixin') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('com.github.GTNewHorizons:SpongeMixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Unimixins replaces other mixin mods")
|
||||
substitute module('io.github.legacymoddingmc:unimixins') using module(mixinProviderSpecNoClassifer) withClassifier("dev") because("Our previous unimixins upload was missing the dev classifier")
|
||||
|
||||
substitute module('org.scala-lang:scala-library:2.11.1') using module('org.scala-lang:scala-library:2.11.5') because('To allow mixing with Java 8 targets')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,14 +770,23 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lwjgl3ifyVersion = '1.5.7'
|
||||
def lwjgl3ifyVersion = '1.4.0'
|
||||
def asmVersion = '9.4'
|
||||
if (modId != 'lwjgl3ify') {
|
||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||
}
|
||||
if (modId != 'hodgepodge') {
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.4.4')
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.26')
|
||||
}
|
||||
|
||||
java17PatchDependencies('net.minecraft:launchwrapper:1.17.2') {transitive = false}
|
||||
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
|
||||
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
|
||||
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
|
||||
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
||||
}
|
||||
|
||||
@@ -980,7 +959,8 @@ if (usesShadowedDependencies.toBoolean()) {
|
||||
configurations.runtimeElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||
configurations.apiElements.outgoing.artifact(tasks.named("shadowJar", ShadowJar))
|
||||
tasks.named("jar", Jar) {
|
||||
archiveClassifier.set('dev-preshadow')
|
||||
enabled = false
|
||||
finalizedBy(tasks.shadowJar)
|
||||
}
|
||||
tasks.named("reobfJar", ReobfuscatedJar) {
|
||||
inputJar.set(tasks.named("shadowJar", ShadowJar).flatMap({it.archiveFile}))
|
||||
@@ -989,6 +969,11 @@ if (usesShadowedDependencies.toBoolean()) {
|
||||
javaComponent.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
for (runTask in ["runClient", "runServer", "runClient17", "runServer17"]) {
|
||||
tasks.named(runTask).configure {
|
||||
dependsOn("shadowJar")
|
||||
}
|
||||
}
|
||||
}
|
||||
ext.publishableDevJar = usesShadowedDependencies.toBoolean() ? tasks.shadowJar : tasks.jar
|
||||
ext.publishableObfJar = tasks.reobfJar
|
||||
@@ -1188,11 +1173,12 @@ publishing {
|
||||
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
if (usesMavenPublishing.toBoolean() && System.getenv("MAVEN_USER") != null) {
|
||||
if (usesMavenPublishing.toBoolean()) {
|
||||
maven {
|
||||
url = mavenPublishUrl
|
||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://")
|
||||
allowInsecureProtocol = mavenPublishUrl.startsWith("http://") // Mostly for the GTNH maven
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||
@@ -1311,7 +1297,7 @@ def addCurseForgeRelation(String type, String name) {
|
||||
|
||||
// Updating
|
||||
|
||||
def buildscriptGradleVersion = "8.5"
|
||||
def buildscriptGradleVersion = "8.2.1"
|
||||
|
||||
tasks.named('wrapper', Wrapper).configure {
|
||||
gradleVersion = buildscriptGradleVersion
|
||||
@@ -1590,25 +1576,6 @@ def getSecondaryArtifacts() {
|
||||
return secondaryArtifacts
|
||||
}
|
||||
|
||||
def getURL(String main, String fallback) {
|
||||
return pingURL(main, 10000) ? main : fallback
|
||||
}
|
||||
|
||||
// credit: https://stackoverflow.com/a/3584332
|
||||
def pingURL(String url, int timeout) {
|
||||
url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates.
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
|
||||
connection.setConnectTimeout(timeout)
|
||||
connection.setReadTimeout(timeout)
|
||||
connection.setRequestMethod("HEAD")
|
||||
int responseCode = connection.getResponseCode()
|
||||
return 200 <= responseCode && responseCode <= 399
|
||||
} catch (IOException ignored) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// For easier scripting of things that require variables defined earlier in the buildscript
|
||||
if (file('addon.late.gradle.kts').exists()) {
|
||||
apply from: 'addon.late.gradle.kts'
|
||||
|
||||
+3
-91
@@ -1,95 +1,7 @@
|
||||
/*
|
||||
* Add your dependencies here. Supported configurations:
|
||||
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
|
||||
* Available at runtime and compiletime for mods depending on this mod
|
||||
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
|
||||
* Available at runtime but not compiletime for mods depending on this mod
|
||||
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
|
||||
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
|
||||
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
|
||||
* Available at compiletime but not runtime for mods depending on this mod
|
||||
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
|
||||
* Not available at all for mods depending on this mod, only visible at runtime for this mod
|
||||
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
|
||||
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
|
||||
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
|
||||
* Available at runtime for mods depending on this mod
|
||||
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
|
||||
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
|
||||
*
|
||||
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
|
||||
* Requires you to enable usesShadowedDependencies in gradle.properties
|
||||
*
|
||||
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
|
||||
*
|
||||
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
|
||||
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
|
||||
*
|
||||
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
|
||||
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
|
||||
*
|
||||
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
|
||||
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
|
||||
*
|
||||
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
|
||||
*/
|
||||
configurations {
|
||||
transformedMod // Mods that can be transformed - used for compiling angelica, but not necessary at runtime
|
||||
transformedMod.canBeConsumed = false
|
||||
transformedModCompileOnly
|
||||
transformedModCompileOnly.canBeConsumed = false
|
||||
|
||||
// Add the transformed mod dependencies to the compilation classpaths, but don't publish them in the Maven metadata
|
||||
compileClasspath.extendsFrom(transformedMod, transformedModCompileOnly)
|
||||
testCompileClasspath.extendsFrom(transformedMod, transformedModCompileOnly)
|
||||
|
||||
// Can be enabled for testing if desired
|
||||
// runtimeClasspath.extendsFrom(transformedMod)
|
||||
// testRuntimeClasspath.extendsFrom(transformedMod)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.4.4")
|
||||
compileOnly(sourceSets.compileStubs.output)
|
||||
compileStubs(sourceSets.compileStubsStubs.output)
|
||||
|
||||
compileOnly("org.projectlombok:lombok:1.18.22") {transitive = false }
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.22")
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:24.0.1')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.2.1:dev")
|
||||
shadowImplementation("org.joml:joml:1.10.5") // MIT
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
implementation("io.github.douira:glsl-transformer:1.0.0")
|
||||
shadowImplementation("io.github.douira:glsl-transformer:1.0.0") { // glsl-transformer Noncommercial License 1.0.0
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
}
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Because who doesn't want NEI
|
||||
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.4.9-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:CodeChickenCore:1.2.0:dev')
|
||||
|
||||
// Notfine Deps
|
||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
||||
runtimeOnly("com.github.GTNewHorizons:Baubles:1.0.1.16:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.5.1:dev") {transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
|
||||
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.0:api")
|
||||
compileOnly("com.falsepattern:endlessids-mc1.7.10:1.5-beta0002:dev")
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:extrautils-225561:2264383"))
|
||||
compileOnly(rfg.deobf("curse.maven:dynamiclights-227874:2337326"))
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:1.5.3:dev") // Mixin Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675"))
|
||||
// HMMMMM
|
||||
compileOnly(rfg.deobf("curse.maven:journeymap-32274:2367915"))
|
||||
|
||||
runtimeOnly(deobf("https://github.com/makamys/CoreTweaks/releases/download/0.3.3.2/CoreTweaks-1.7.10-0.3.3.2+nomixin.jar"))
|
||||
|
||||
// Hodgepodge
|
||||
transformedMod("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
||||
runtimeOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.3.55-GTNH:dev")
|
||||
}
|
||||
BIN
Binary file not shown.
+5
-6
@@ -57,17 +57,17 @@ replaceGradleTokenInFile =
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||
apiPackage = api
|
||||
apiPackage =
|
||||
|
||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
||||
# There can be multiple files in a comma-separated list.
|
||||
# Example value: mymodid_at.cfg,nei_at.cfg
|
||||
accessTransformersFile = angelica_at.cfg notfine_at.cfg archaicfix_at.cfg mcpatcherforge_at.cfg
|
||||
accessTransformersFile = angelica_at.cfg
|
||||
|
||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||
usesMixins = true
|
||||
# Adds some debug arguments like verbose output and export
|
||||
usesMixinDebug = false
|
||||
usesMixinDebug = true
|
||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||
mixinPlugin =
|
||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||
@@ -85,7 +85,7 @@ forceEnableMixins = false
|
||||
|
||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated in your jar. It is your
|
||||
# responsibility check the licence and request permission for distribution, if required.
|
||||
usesShadowedDependencies = true
|
||||
usesShadowedDependencies = false
|
||||
# If disabled, won't remove unused classes from shaded dependencies. Some libraries use reflection to access
|
||||
# their own classes, making the minimization unreliable.
|
||||
minimizeShadowedDependencies = true
|
||||
@@ -136,8 +136,7 @@ curseForgeRelations =
|
||||
# Uncomment this to disable spotless checks
|
||||
# This should only be uncommented to keep it easier to sync with upstream/other forks.
|
||||
# That is, if there is no other active fork/upstream, NEVER change this.
|
||||
# Disabling to make easier to sync if some of the additional mods get any changes upstream
|
||||
disableSpotless = true
|
||||
# disableSpotless = true
|
||||
|
||||
# Override the IDEA build type. Valid value is "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
||||
# (force use delegated build).
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-2
@@ -1,7 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -83,8 +83,7 @@ done
|
||||
# This is normally unused
|
||||
# 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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -131,13 +130,10 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -145,7 +141,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -153,7 +149,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -202,11 +198,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# 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.
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
+1
-8
@@ -1,12 +1,5 @@
|
||||
// Add any additional repositories for your dependencies here
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = 'mavenpattern'
|
||||
url = 'https://mvn.falsepattern.com/releases'
|
||||
content {
|
||||
includeGroup "com.falsepattern"
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
|
||||
}
|
||||
+6
-5
@@ -4,9 +4,10 @@ pluginManagement {
|
||||
maven {
|
||||
// RetroFuturaGradle
|
||||
name "GTNH Maven"
|
||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
||||
url "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||
allowInsecureProtocol = true
|
||||
mavenContent {
|
||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
||||
includeGroup("com.gtnewhorizons.retrofuturagradle")
|
||||
}
|
||||
}
|
||||
gradlePluginPortal()
|
||||
@@ -16,12 +17,12 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.diffplug.blowdryerSetup' version '1.7.1'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' // Provides java toolchains
|
||||
id 'com.diffplug.blowdryerSetup' version '1.6.0'
|
||||
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0' // Provides java toolchains
|
||||
}
|
||||
|
||||
blowdryerSetup {
|
||||
repoSubfolder 'gtnhShared'
|
||||
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.2')
|
||||
github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.2.0')
|
||||
//devLocal '.' // Use this when testing config updates locally
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.minecraft.client.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ModelBase {
|
||||
|
||||
public List boxList;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.minecraft.client.renderer;
|
||||
|
||||
import net.minecraft.client.renderer.culling.ICamera;
|
||||
|
||||
public class WorldRenderer {
|
||||
|
||||
public boolean isInFrustum;
|
||||
|
||||
public boolean skipAllRenderPasses() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateInFrustum(ICamera frustrum) {}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.minecraft.client.renderer.culling;
|
||||
|
||||
public class Frustrum implements ICamera {
|
||||
|
||||
public void setPosition(double x, double y, double z) {}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.minecraft.client.renderer.culling;
|
||||
|
||||
public interface ICamera {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.MultiTexID;
|
||||
|
||||
public abstract class AbstractTexture implements ITextureObject {
|
||||
|
||||
public int glTextureId = -1;
|
||||
public MultiTexID multiTex;
|
||||
|
||||
public int getGlTextureId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public MultiTexID getMultiTexID() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
public class DynamicTexture extends AbstractTexture {
|
||||
|
||||
public DynamicTexture(int i, int i1) {
|
||||
super();
|
||||
}
|
||||
|
||||
public int[] getTextureData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateDynamicTexture() {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.MultiTexID;
|
||||
|
||||
public interface ITextureObject {
|
||||
|
||||
MultiTexID getMultiTexID();
|
||||
|
||||
int getGlTextureId();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
public class TextureAtlasSprite {
|
||||
|
||||
public boolean useAnisotropicFiltering;
|
||||
|
||||
public void updateAnimation() {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.minecraft.client.renderer.texture;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TextureMap extends AbstractTexture {
|
||||
|
||||
public static ResourceLocation locationBlocksTexture;
|
||||
public int atlasWidth;
|
||||
public int atlasHeight;
|
||||
|
||||
public int getTextureType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ResourceLocation completeResourceLocation(ResourceLocation resourceLocation, int i) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Stubs for the compile stubs
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
public class MultiTexID {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.minecraft.client.shader;
|
||||
|
||||
public class TesselatorVertexState {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.minecraft.util;
|
||||
|
||||
public class ResourceLocation {
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.gtnewhorizons.angelica;
|
||||
|
||||
import com.gtnewhorizon.gtnhmixins.ILateMixinLoader;
|
||||
import com.gtnewhorizon.gtnhmixins.LateMixin;
|
||||
import com.gtnewhorizons.angelica.mixins.Mixins;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@LateMixin
|
||||
public class AngelicaLateMixins implements ILateMixinLoader {
|
||||
@Override
|
||||
public String getMixinConfig() {
|
||||
return "mixins.angelica.late.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMixins(Set<String> loadedMods) {
|
||||
return Mixins.getLateMixins(loadedMods);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +1,12 @@
|
||||
package com.gtnewhorizons.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.proxy.CommonProxy;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationMode;
|
||||
import com.gtnewhorizons.angelica.utils.ManagedEnum;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
@Mod(
|
||||
modid = "angelica",
|
||||
name = "Angelica",
|
||||
version = Tags.VERSION,
|
||||
dependencies = " before:lwjgl3ify@[1.5.3,);" + " after:hodgepodge@[2.4.4,);" + " after:CodeChickenCore@[1.2.0,);"
|
||||
+ " after:archaicfix@[0.7.0,);" + " required-after:gtnhlib@[0.2.1,);",
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
acceptableRemoteVersions = "*",
|
||||
guiFactory = "com.gtnewhorizons.angelica.config.AngelicaGuiConfigFactory")
|
||||
acceptedMinecraftVersions = "[1.7.10,)",
|
||||
acceptableRemoteVersions = "*")
|
||||
public class AngelicaMod {
|
||||
@SidedProxy(clientSide = "com.gtnewhorizons.angelica.proxy.ClientProxy", serverSide = "com.gtnewhorizons.angelica.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
public static final boolean lwjglDebug = Boolean.parseBoolean(System.getProperty("org.lwjgl.util.Debug", "false"));
|
||||
|
||||
public static final ManagedEnum<AnimationMode> animationsMode = new ManagedEnum<>(AnimationMode.VISIBLE_ONLY);
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
ModStatus.preInit();
|
||||
proxy.preInit(event);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
proxy.init(event);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
proxy.postInit(event);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
- [x] Frustum (Seems related to Frustrum)
|
||||
- [X] NativeImage
|
||||
- [ ] PoseStack
|
||||
- [ ] RenderType
|
||||
- [ ] MultiBufferSource.BufferSource
|
||||
- [ ] VertexBuffer
|
||||
- [ ] VertexConsumer
|
||||
- [ ] VertextFormat
|
||||
- [ ] TextureAtlas (Seems related to TextureManager) - PBR related
|
||||
- [ ] GUI
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
/**
|
||||
* Marks an ISBRH as thread-safe, allowing Angelica to run it off-thread.
|
||||
*
|
||||
* <p>Note: Any tessellator access <i>must</i> be done within the methods of the ISBRH and not cached in the class.</p>
|
||||
*/
|
||||
@Documented
|
||||
@Target({ TYPE })
|
||||
@Retention(RUNTIME)
|
||||
public @interface ThreadSafeISBRH {
|
||||
/**
|
||||
* Specifies whether Angelica should create a thread local instance of the class for each thread.
|
||||
* <ul>
|
||||
* <li>If this is set to <tt>true</tt>, a new instance will be created using the default constructor on each thread.</li>
|
||||
* <ul>
|
||||
* <li>Note: If your renderer requires arguments to the constructor, do <i>not</i> use this annotation;
|
||||
* instead use the {@link ThreadSafeISBRHFactory} interface and implement the {@link ThreadSafeISBRHFactory#newInstance} method. </li>
|
||||
* </ul>
|
||||
* <li>If this is set to <tt>false</tt>, the main thread instance will be used on all threads.
|
||||
* Use this option if your renderer class has no state, and can be safely used from multiple threads as is.</li>
|
||||
* <ul>
|
||||
* <li>No state/non final variables should be stored in the ISBRH as it is not guaranteed to be thread safe.</li>
|
||||
* </ul>
|
||||
* </ul>
|
||||
*/
|
||||
boolean perThread();
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.api;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
|
||||
/**
|
||||
* Marks an ISBRH as thread-safe using a thread local instance, allowing Angelica to run it off-thread.
|
||||
* Use this when your ISBRH uses a non-default constructor.
|
||||
* <p>To avoid a hard dependency on Angelica, you will likely want to mark this as an optional interface using:</p>
|
||||
* <pre>
|
||||
* @Optional.Interface(modid = "angelica", iface = "com.gtnewhorizons.angelica.api.ThreadSafeISBRHFactory")
|
||||
* </pre>
|
||||
*
|
||||
* <p><b>Notes</b></p>
|
||||
* <ul>
|
||||
* <li>Any tessellator access <i>must</i> be done within the methods of the ISBRH and not cached in the class.</li>
|
||||
* <li>If your class uses a default constructor or is thread-safe by default, consider using the simpler {@link ThreadSafeISBRH}
|
||||
* annotation instead.
|
||||
* </ul>
|
||||
*/
|
||||
public interface ThreadSafeISBRHFactory extends ISimpleBlockRenderingHandler {
|
||||
ThreadSafeISBRHFactory newInstance();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
|
||||
public class DefaultTexture extends AbstractTexture {
|
||||
|
||||
public DefaultTexture() {
|
||||
loadTexture(null);
|
||||
}
|
||||
|
||||
public void loadTexture(IResourceManager resourcemanager) {
|
||||
int[] aint = ShadersTex.createAIntImage(1, 0xFFFFFFFF);
|
||||
ShadersTex.setupTexture(this.getMultiTexID(), aint, 1, 1, false, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
|
||||
import org.lwjgl.Sys;
|
||||
|
||||
public class GuiShaders extends GuiScreen {
|
||||
|
||||
/** This GUI's parent GUI. */
|
||||
protected GuiScreen parentGui;
|
||||
|
||||
private int updateTimer = -1;
|
||||
public boolean needReinit;
|
||||
|
||||
/*
|
||||
* private class GuiListShaderpacks { int posX,posY,sizeX,sizeY; int viewPosY; int itemHeight = 20; int selection;
|
||||
* ArrayList<String> listShaderpacks; public void draw() { Tessellator tess = Tessellator.instance; int listSize =
|
||||
* listShaderpacks.size(); int i,j; for (i=viewPosY/itemHeight, j=Math.min((viewPosY+sizeY)/itemHeight,listSize);
|
||||
* i<j; ++i) { int itemY = posY-viewPosY+itemHeight*i; boolean selected = i==selection; tess.startDrawingQuads();
|
||||
* tess.setColorRGBA(0,0,selected?128:0,128); tess.addVertex(posX,itemY,0); tess.addVertex(posX,itemY+itemHeight,0);
|
||||
* tess.addVertex(posX+sizeX,itemY+itemHeight,0); tess.addVertex(posX+sizeX,itemY,0); tess.draw();
|
||||
* field_146289_q.drawString(listShaderpacks.get(i), posX, itemY, 0xFFFFFFFF, true); } } } private
|
||||
* GuiListShaderpacks guiListShaderpacks;
|
||||
*/
|
||||
|
||||
private GuiSlotShaders shaderList;
|
||||
|
||||
/** This GUI's 'Done' button. */
|
||||
// private GuiSmallButton doneButton;
|
||||
|
||||
public GuiShaders(GuiScreen par1GuiScreen, GameSettings par2GameSettings) {
|
||||
this.parentGui = par1GuiScreen;
|
||||
}
|
||||
|
||||
private static String toStringOnOff(boolean value) {
|
||||
return value ? "On" : "Off";
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Adds the buttons (and other controls) to the screen in question.
|
||||
*/
|
||||
public void initGui() {
|
||||
if (Shaders.shadersConfig == null) Shaders.loadConfig();
|
||||
List buttonList = this.buttonList;
|
||||
int width = this.width;
|
||||
int height = this.height;
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
17,
|
||||
width * 3 / 4 - 60,
|
||||
30,
|
||||
160,
|
||||
18,
|
||||
"NormapMap: " + toStringOnOff(Shaders.configNormalMap)));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
18,
|
||||
width * 3 / 4 - 60,
|
||||
50,
|
||||
160,
|
||||
18,
|
||||
"SpecularMap: " + toStringOnOff(Shaders.configSpecularMap)));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
15,
|
||||
width * 3 / 4 - 60,
|
||||
70,
|
||||
160,
|
||||
18,
|
||||
"RenderResMul: " + String.format("%.04f", Shaders.configRenderResMul)));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
16,
|
||||
width * 3 / 4 - 60,
|
||||
90,
|
||||
160,
|
||||
18,
|
||||
"ShadowResMul: " + String.format("%.04f", Shaders.configShadowResMul)));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
10,
|
||||
width * 3 / 4 - 60,
|
||||
110,
|
||||
160,
|
||||
18,
|
||||
"HandDepth: " + String.format("%.04f", Shaders.configHandDepthMul)));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
9,
|
||||
width * 3 / 4 - 60,
|
||||
130,
|
||||
160,
|
||||
18,
|
||||
"CloudShadow: " + toStringOnOff(Shaders.configCloudShadow)));
|
||||
// buttonList.add(new GuiButton(14, width *3 /4 -60, 150, 160, 18, "ShadowClipFrustrum: "
|
||||
// +toStringOnOff(Shaders.configShadowClipFrustrum)));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
4,
|
||||
width * 3 / 4 - 60,
|
||||
170,
|
||||
160,
|
||||
18,
|
||||
"tweakBlockDamage: " + toStringOnOff(Shaders.configTweakBlockDamage)));
|
||||
buttonList.add(
|
||||
new GuiButton(
|
||||
19,
|
||||
width * 3 / 4 - 60,
|
||||
190,
|
||||
160,
|
||||
18,
|
||||
"OldLighting: " + toStringOnOff(Shaders.configOldLighting)));
|
||||
// buttonList.add(new GuiButton(11, width *3 /4 -60, 210, 160, 18, "Tex Min: "
|
||||
// +Shaders.texMinFilDesc[Shaders.configTexMinFilB]));
|
||||
// buttonList.add(new GuiButton(12, width *3 /4 -60, 230, 160, 18, "Tex_n Mag: "
|
||||
// +Shaders.texMagFilDesc[Shaders.configTexMagFilN]));
|
||||
// buttonList.add(new GuiButton(13, width *3 /4 -60, 250, 160, 18, "Tex_s Mag: "
|
||||
// +Shaders.texMagFilDesc[Shaders.configTexMagFilS]));
|
||||
buttonList.add(new GuiButton(6, width * 3 / 4 - 60, height - 25, 160, 20, "Done"));
|
||||
buttonList.add(new GuiButton(5, width / 4 - 80, height - 25, 160, 20, "Open shaderpacks folder"));
|
||||
this.shaderList = new GuiSlotShaders(this);
|
||||
this.shaderList.registerScrollButtons(7, 8); // registerScrollButtons(7, 8);
|
||||
this.needReinit = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* actionPerformed Fired when a control is clicked. This is the equivalent of
|
||||
* ActionListener.actionPerformed(ActionEvent e).
|
||||
*/
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if (par1GuiButton.enabled) // enabled
|
||||
{
|
||||
switch (par1GuiButton.id) // id
|
||||
{
|
||||
case 4: /* New block breaking */
|
||||
Shaders.configTweakBlockDamage = !Shaders.configTweakBlockDamage;
|
||||
// displayString
|
||||
par1GuiButton.displayString = "tweakBlockDamage: " + toStringOnOff(Shaders.configTweakBlockDamage);
|
||||
break;
|
||||
|
||||
case 9: /* Cloud shadow */
|
||||
Shaders.configCloudShadow = !Shaders.configCloudShadow;
|
||||
par1GuiButton.displayString = "CloudShadow: " + toStringOnOff(Shaders.configCloudShadow);
|
||||
break;
|
||||
|
||||
case 10: /* Hand Depth */ {
|
||||
float val = Shaders.configHandDepthMul;
|
||||
float[] choices = { 0.0625f, 0.125f, 0.25f, 0.5f, 1.0f };
|
||||
int i;
|
||||
if (!isShiftKeyDown()) { // isShiftKeyDown
|
||||
for (i = 0; i < choices.length && choices[i] <= val; ++i) {}
|
||||
if (i == choices.length) i = 0;
|
||||
} else {
|
||||
for (i = choices.length - 1; i >= 0 && val <= choices[i]; --i) {}
|
||||
if (i < 0) i = choices.length - 1;
|
||||
}
|
||||
Shaders.configHandDepthMul = choices[i];
|
||||
par1GuiButton.displayString = "HandDepth: " + String.format("%.4f", Shaders.configHandDepthMul);
|
||||
break;
|
||||
}
|
||||
|
||||
case 15: /* Render Resolution Multiplier */ {
|
||||
float val = Shaders.configRenderResMul;
|
||||
float[] choices = { 0.25f, 0.3333333333f, 0.5f, 0.7071067812f, 1.0f, 1.414213562f, 2.0f };
|
||||
int i;
|
||||
if (!isShiftKeyDown()) {
|
||||
for (i = 0; i < choices.length && choices[i] <= val; ++i) {}
|
||||
if (i == choices.length) i = 0;
|
||||
} else {
|
||||
for (i = choices.length - 1; i >= 0 && val <= choices[i]; --i) {}
|
||||
if (i < 0) i = choices.length - 1;
|
||||
}
|
||||
Shaders.configRenderResMul = choices[i];
|
||||
par1GuiButton.displayString = "RenderResMul: " + String.format("%.4f", Shaders.configRenderResMul);
|
||||
Shaders.scheduleResize();
|
||||
break;
|
||||
}
|
||||
|
||||
case 16: /* Shadow Resolution Multiplier */ {
|
||||
float val = Shaders.configShadowResMul;
|
||||
float[] choices = { 0.25f, 0.3333333333f, 0.5f, 0.7071067812f, 1.0f, 1.414213562f, 2.0f, 3.0f,
|
||||
4.0f };
|
||||
int i;
|
||||
if (!isShiftKeyDown()) {
|
||||
for (i = 0; i < choices.length && choices[i] <= val; ++i) {}
|
||||
if (i == choices.length) i = 0;
|
||||
} else {
|
||||
for (i = choices.length - 1; i >= 0 && val <= choices[i]; --i) {}
|
||||
if (i < 0) i = choices.length - 1;
|
||||
}
|
||||
Shaders.configShadowResMul = choices[i];
|
||||
par1GuiButton.displayString = "ShadowResMul: " + String.format("%.4f", Shaders.configShadowResMul);
|
||||
Shaders.scheduleResizeShadow();
|
||||
break;
|
||||
}
|
||||
|
||||
case 17: /* Normal Map */ {
|
||||
Shaders.configNormalMap = !Shaders.configNormalMap;
|
||||
// displayString
|
||||
par1GuiButton.displayString = "NormapMap: " + toStringOnOff(Shaders.configNormalMap);
|
||||
mc.scheduleResourcesRefresh(); // schedule refresh texture
|
||||
break;
|
||||
}
|
||||
|
||||
case 18: /* Normal Map */ {
|
||||
Shaders.configSpecularMap = !Shaders.configSpecularMap;
|
||||
// displayString
|
||||
par1GuiButton.displayString = "SpecularMap: " + toStringOnOff(Shaders.configSpecularMap);
|
||||
mc.scheduleResourcesRefresh(); // schedule refresh texture
|
||||
break;
|
||||
}
|
||||
|
||||
case 19: /* old Lighting */ {
|
||||
Shaders.configOldLighting = !Shaders.configOldLighting;
|
||||
// displayString
|
||||
par1GuiButton.displayString = "OldLighting: " + toStringOnOff(Shaders.configOldLighting);
|
||||
Shaders.updateBlockLightLevel();
|
||||
mc.renderGlobal.loadRenderers();
|
||||
break;
|
||||
}
|
||||
|
||||
case 11: /* texture filter */ {
|
||||
Shaders.configTexMinFilB = (Shaders.configTexMinFilB + 1) % Shaders.texMinFilRange;
|
||||
Shaders.configTexMinFilN = Shaders.configTexMinFilS = Shaders.configTexMinFilB;
|
||||
par1GuiButton.displayString = "Tex Min: " + Shaders.texMinFilDesc[Shaders.configTexMinFilB];
|
||||
ShadersTex.updateTextureMinMagFilter();
|
||||
break;
|
||||
}
|
||||
|
||||
case 12: /* texture filter */ {
|
||||
Shaders.configTexMagFilN = (Shaders.configTexMagFilN + 1) % Shaders.texMagFilRange;
|
||||
par1GuiButton.displayString = "Tex_n Mag: " + Shaders.texMagFilDesc[Shaders.configTexMagFilN];
|
||||
ShadersTex.updateTextureMinMagFilter();
|
||||
break;
|
||||
}
|
||||
|
||||
case 13: /* texture filter */ {
|
||||
Shaders.configTexMagFilS = (Shaders.configTexMagFilS + 1) % Shaders.texMagFilRange;
|
||||
par1GuiButton.displayString = "Tex_s Mag: " + Shaders.texMagFilDesc[Shaders.configTexMagFilS];
|
||||
ShadersTex.updateTextureMinMagFilter();
|
||||
break;
|
||||
}
|
||||
|
||||
case 14: /* shadow frustum clipping */ {
|
||||
Shaders.configShadowClipFrustrum = !Shaders.configShadowClipFrustrum;
|
||||
par1GuiButton.displayString = "ShadowClipFrustrum: "
|
||||
+ toStringOnOff(Shaders.configShadowClipFrustrum);
|
||||
ShadersTex.updateTextureMinMagFilter();
|
||||
break;
|
||||
}
|
||||
|
||||
case 5: /* Open shaderpacks folder */
|
||||
switch (net.minecraft.util.Util.getOSType()) {
|
||||
case OSX: {
|
||||
try {
|
||||
Runtime.getRuntime().exec(
|
||||
new String[] { "/usr/bin/open", Shaders.shaderpacksdir.getAbsolutePath() });
|
||||
return;
|
||||
} catch (IOException var7) {
|
||||
var7.printStackTrace();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WINDOWS: {
|
||||
String var2 = String.format(
|
||||
"cmd.exe /C start \"Open file\" \"%s\"",
|
||||
new Object[] { Shaders.shaderpacksdir.getAbsolutePath() });
|
||||
|
||||
try {
|
||||
Runtime.getRuntime().exec(var2);
|
||||
return;
|
||||
} catch (IOException var6) {
|
||||
var6.printStackTrace();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
boolean var8 = false;
|
||||
|
||||
try {
|
||||
Class var3 = Class.forName("java.awt.Desktop");
|
||||
Object var4 = var3.getMethod("getDesktop", new Class[0]).invoke((Object) null, new Object[0]);
|
||||
var3.getMethod("browse", new Class[] { URI.class }).invoke(
|
||||
var4,
|
||||
new Object[] { (new File(mc.mcDataDir, Shaders.shaderpacksdirname)).toURI() });
|
||||
} catch (Throwable var5) {
|
||||
var5.printStackTrace();
|
||||
var8 = true;
|
||||
}
|
||||
|
||||
if (var8) {
|
||||
System.out.println("Opening via system class!");
|
||||
Sys.openURL("file://" + Shaders.shaderpacksdir.getAbsolutePath());
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: /* Done */
|
||||
File confshader = new File(Shaders.shadersdir, "current.cfg");
|
||||
try {
|
||||
Shaders.storeConfig();
|
||||
} catch (Exception ex) {}
|
||||
if (needReinit) {
|
||||
needReinit = false;
|
||||
Shaders.loadShaderPack();
|
||||
Shaders.uninit();
|
||||
this.mc.renderGlobal.loadRenderers();
|
||||
}
|
||||
this.mc.displayGuiScreen(this.parentGui); // displayGuiScreen
|
||||
break;
|
||||
|
||||
default:
|
||||
this.shaderList.actionPerformed(par1GuiButton); // actionPerformed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Draws the screen and all the components in it.
|
||||
*/
|
||||
public void drawScreen(int par1, int par2, float par3) {
|
||||
drawDefaultBackground(); // background
|
||||
this.shaderList.drawScreen(par1, par2, par3); // drawScreen
|
||||
|
||||
if (this.updateTimer <= 0) {
|
||||
this.shaderList.updateList();
|
||||
this.updateTimer += 20;
|
||||
}
|
||||
|
||||
this.drawCenteredString(this.fontRendererObj, "Shaders ", this.width / 2, 16, 0xffffff);
|
||||
this.drawCenteredString(this.fontRendererObj, " v" + Shaders.versionString, this.width - 40, 10, 0x808080);
|
||||
// this.drawCenteredString(this.fontRenderer, "( Place zipped Shader files here. )", this.width / 4 + 10,
|
||||
// this.height - 26, 0x808080);
|
||||
super.drawScreen(par1, par2, par3);
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Called from the main game loop to update the screen.
|
||||
*/
|
||||
public void updateScreen() {
|
||||
super.updateScreen();
|
||||
--this.updateTimer;
|
||||
}
|
||||
|
||||
public Minecraft getMc() {
|
||||
return this.mc;
|
||||
}
|
||||
|
||||
public void drawCenteredString(String par1, int par2, int par3, int par4) {
|
||||
this.drawCenteredString(this.fontRendererObj, par1, par2, par3, par4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.client.gui.GuiSlot;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
class GuiSlotShaders extends GuiSlot {
|
||||
|
||||
private ArrayList shaderslist;
|
||||
|
||||
final GuiShaders shadersGui;
|
||||
|
||||
public GuiSlotShaders(GuiShaders par1GuiShaders) {
|
||||
// super(par1GuiShaders.getMc(), par1GuiShaders.width / 2 + 20, par1GuiShaders.height, 40, par1GuiShaders.height
|
||||
// - 70, 16);
|
||||
super(
|
||||
par1GuiShaders.getMc(),
|
||||
par1GuiShaders.width / 2 + 20,
|
||||
par1GuiShaders.height,
|
||||
40,
|
||||
par1GuiShaders.height - 70,
|
||||
16);
|
||||
this.shadersGui = par1GuiShaders;
|
||||
this.shaderslist = Shaders.listofShaders();
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
this.shaderslist = Shaders.listofShaders();
|
||||
}
|
||||
|
||||
@Override
|
||||
/** getSize */
|
||||
protected int getSize() {
|
||||
return this.shaderslist.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
/** elementClicked */
|
||||
protected void elementClicked(int par1, boolean par2, int par3, int par4) {
|
||||
Shaders.setShaderPack((String) shaderslist.get(par1));
|
||||
shadersGui.needReinit = false;
|
||||
Shaders.loadShaderPack();
|
||||
Shaders.uninit();
|
||||
}
|
||||
|
||||
@Override
|
||||
/** isSelected */
|
||||
protected boolean isSelected(int par1) {
|
||||
return ((String) this.shaderslist.get(par1)).equals(Shaders.currentshadername);
|
||||
}
|
||||
|
||||
@Override
|
||||
/** getScrollBarX */
|
||||
protected int getScrollBarX() {
|
||||
return this.width - 6;
|
||||
}
|
||||
|
||||
@Override
|
||||
/** getContentHeight */
|
||||
protected int getContentHeight() {
|
||||
return this.getSize() * 18;
|
||||
}
|
||||
|
||||
@Override
|
||||
/** drawBackground */
|
||||
protected void drawBackground() {
|
||||
// this.shadersGui.drawDefaultBackground();
|
||||
}
|
||||
|
||||
@Override
|
||||
/** drawSlot */
|
||||
protected void drawSlot(int par1, int par2, int par3, int par4, Tessellator par5, int par6, int par7) {
|
||||
this.shadersGui.drawCenteredString(
|
||||
(String) this.shaderslist.get(par1),
|
||||
this.shadersGui.width / 4 + 10,
|
||||
par3 + 1,
|
||||
0xffffff);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Nathanael Lane
|
||||
*/
|
||||
public class HFNoiseTexture {
|
||||
|
||||
public int texID;
|
||||
public int textureUnit;
|
||||
|
||||
public HFNoiseTexture(int width, int height) {
|
||||
texID = GL11.glGenTextures();
|
||||
textureUnit = 15;
|
||||
|
||||
byte[] image = genHFNoiseImage(width, height);
|
||||
ByteBuffer data = BufferUtils.createByteBuffer(image.length);
|
||||
data.put(image);
|
||||
data.flip();
|
||||
|
||||
// GL13.glActiveTexture(GL13.GL_TEXTURE0 + this.textureUnit);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
|
||||
GL11.glTexImage2D(
|
||||
GL11.GL_TEXTURE_2D,
|
||||
0,
|
||||
GL11.GL_RGB,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
GL11.GL_RGB,
|
||||
GL11.GL_UNSIGNED_BYTE,
|
||||
data);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
|
||||
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
||||
// GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
|
||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return texID;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
GL11.glDeleteTextures(texID);
|
||||
texID = 0;
|
||||
}
|
||||
|
||||
// from George Marsaglia's paper on XORshift PRNGs
|
||||
private int random(int seed) {
|
||||
seed ^= (seed << 13);
|
||||
seed ^= (seed >> 17);
|
||||
seed ^= (seed << 5);
|
||||
return seed;
|
||||
}
|
||||
|
||||
private byte random(int x, int y, int z) {
|
||||
int seed = (random(x) + random(y * 19)) * random(z * 23) - z;
|
||||
return (byte) (random(seed) % 128);
|
||||
}
|
||||
|
||||
/*
|
||||
* Just a random value for each pixel to get maximum frequency
|
||||
*/
|
||||
private byte[] genHFNoiseImage(int width, int height) {
|
||||
|
||||
byte[] image = new byte[width * height * 3];
|
||||
int index = 0;
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int z = 1; z < 4; z++) {
|
||||
image[index++] = random(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface IShaderPack {
|
||||
|
||||
void close();
|
||||
|
||||
InputStream getResourceAsStream(String resName);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
public class MultiTexID {
|
||||
|
||||
public int base;
|
||||
public int norm;
|
||||
public int spec;
|
||||
|
||||
public MultiTexID(int baseTex, int normTex, int specTex) {
|
||||
base = baseTex;
|
||||
norm = normTex;
|
||||
spec = specTex;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ShaderPackDefault implements IShaderPack {
|
||||
|
||||
public ShaderPackDefault() {}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String resName) {
|
||||
return ShaderPackDefault.class.getResourceAsStream(resName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ShaderPackFolder implements IShaderPack {
|
||||
|
||||
protected File packFile;
|
||||
|
||||
public ShaderPackFolder(String name, File file) {
|
||||
packFile = file;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String resName) {
|
||||
try {
|
||||
File resFile = new File(packFile, resName.substring(1));
|
||||
if (resFile != null) {
|
||||
return new BufferedInputStream(new FileInputStream(resFile));
|
||||
}
|
||||
} catch (Exception excp) {}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ShaderPackNone implements IShaderPack {
|
||||
|
||||
public ShaderPackNone() {}
|
||||
|
||||
@Override
|
||||
public void close() {}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String resName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
public class ShaderPackZip implements IShaderPack {
|
||||
|
||||
protected File packFile;
|
||||
protected ZipFile packZipFile;
|
||||
|
||||
public ShaderPackZip(String name, File file) {
|
||||
packFile = file;
|
||||
packZipFile = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
if (packZipFile != null) {
|
||||
try {
|
||||
packZipFile.close();
|
||||
} catch (Exception excp) {}
|
||||
packZipFile = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String resName) {
|
||||
if (packZipFile == null) {
|
||||
try {
|
||||
packZipFile = new ZipFile(packFile);
|
||||
} catch (Exception excp) {}
|
||||
}
|
||||
if (packZipFile != null) {
|
||||
try {
|
||||
ZipEntry entry = packZipFile.getEntry(resName.substring(1));
|
||||
if (entry != null) {
|
||||
return packZipFile.getInputStream(entry);
|
||||
}
|
||||
} catch (Exception excp) {}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,90 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockIce;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.WorldRenderer;
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.early.accessors.WorldRenderersAccessor;
|
||||
|
||||
public class ShadersRender {
|
||||
|
||||
public static void setFrustrumPosition(Frustrum frustrum, double x, double y, double z) {
|
||||
frustrum.setPosition(x, y, z);
|
||||
}
|
||||
|
||||
public static void clipRenderersByFrustrum(RenderGlobal renderGlobal, Frustrum frustrum, float par2) {
|
||||
Shaders.checkGLError("pre clip");
|
||||
WorldRenderer[] worldRenderers = ((WorldRenderersAccessor) renderGlobal).getWorldRenderers();
|
||||
if (!Shaders.isShadowPass) {
|
||||
for (WorldRenderer worldRenderer : worldRenderers) {
|
||||
if (!worldRenderer.skipAllRenderPasses()) {
|
||||
worldRenderer.updateInFrustum(frustrum);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (WorldRenderer worldRenderer : worldRenderers) {
|
||||
if (!worldRenderer.skipAllRenderPasses()) {
|
||||
worldRenderer.isInFrustum = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderHand0(EntityRenderer er, float par1, int par2) {
|
||||
if (!Shaders.isShadowPass) {
|
||||
Item item = (Shaders.itemToRender != null) ? Shaders.itemToRender.getItem() : null;
|
||||
Block block = (item instanceof ItemBlock) ? ((ItemBlock) item).field_150939_a : null;
|
||||
// ItemCloth is for semitransparent block : stained glass, wool
|
||||
if (!(item instanceof ItemBlock) && !(block instanceof BlockIce)) {
|
||||
Shaders.readCenterDepth();
|
||||
Shaders.beginHand();
|
||||
er.renderHand(par1, par2);
|
||||
Shaders.endHand();
|
||||
Shaders.isHandRendered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderHand1(EntityRenderer er, float par1, int par2) {
|
||||
if (!Shaders.isShadowPass) {
|
||||
if (!Shaders.isHandRendered) {
|
||||
Shaders.readCenterDepth();
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
Shaders.beginHand();
|
||||
er.renderHand(par1, par2);
|
||||
Shaders.endHand();
|
||||
Shaders.isHandRendered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void renderItemFP(ItemRenderer itemRenderer, float par1) {
|
||||
// clear depth buffer locally
|
||||
GL11.glDepthFunc(GL11.GL_GEQUAL);
|
||||
GL11.glPushMatrix();
|
||||
IntBuffer drawBuffers = Shaders.activeDrawBuffers;
|
||||
Shaders.setDrawBuffers(Shaders.drawBuffersNone);
|
||||
itemRenderer.renderItemInFirstPerson(par1);
|
||||
Shaders.setDrawBuffers(drawBuffers);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
||||
// really render item or hand
|
||||
itemRenderer.renderItemInFirstPerson(par1);
|
||||
}
|
||||
|
||||
public static void renderFPOverlay(EntityRenderer er, float par1, int par2) {
|
||||
Shaders.beginFPOverlay();
|
||||
er.renderHand(par1, par2);
|
||||
Shaders.endFPOverlay();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
package com.gtnewhorizons.angelica.client;
|
||||
|
||||
import static org.lwjgl.opengl.ARBVertexShader.glDisableVertexAttribArrayARB;
|
||||
import static org.lwjgl.opengl.ARBVertexShader.glEnableVertexAttribArrayARB;
|
||||
import static org.lwjgl.opengl.ARBVertexShader.glVertexAttribPointerARB;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TessellatorAccessor;
|
||||
import com.gtnewhorizons.angelica.transform.ALog;
|
||||
|
||||
public class ShadersTess {
|
||||
|
||||
public static final int vertexStride = 16;
|
||||
|
||||
public static int draw(Tessellator tess) {
|
||||
final TessellatorAccessor tessa = (TessellatorAccessor) tess;
|
||||
if (!tess.isDrawing) {
|
||||
throw new IllegalStateException("Not tesselating!");
|
||||
} else {
|
||||
tess.isDrawing = false;
|
||||
if (tess.drawMode == GL11.GL_QUADS && tess.vertexCount % 4 != 0) {
|
||||
ALog.warning("%s", "bad vertexCount");
|
||||
}
|
||||
int voffset = 0;
|
||||
int realDrawMode = tess.drawMode;
|
||||
while (voffset < tess.vertexCount) {
|
||||
int vcount;
|
||||
vcount = Math.min(
|
||||
tess.vertexCount - voffset,
|
||||
tessa.getAngelica$byteBuffer().capacity() / (vertexStride * 4));
|
||||
if (realDrawMode == GL11.GL_QUADS) vcount = vcount / 4 * 4;
|
||||
tessa.getAngelica$floatBuffer().clear();
|
||||
tessa.getAngelica$shortBuffer().clear();
|
||||
tessa.getAngelica$intBuffer().clear();
|
||||
tessa.getAngelica$intBuffer().put(tess.rawBuffer, voffset * vertexStride, vcount * vertexStride);
|
||||
tessa.getAngelica$byteBuffer().position(0);
|
||||
tessa.getAngelica$byteBuffer().limit(vcount * (vertexStride * 4));
|
||||
voffset += vcount;
|
||||
|
||||
if (tess.hasTexture) {
|
||||
tessa.getAngelica$floatBuffer().position(3);
|
||||
GL11.glTexCoordPointer(2, (vertexStride * 4), tessa.getAngelica$floatBuffer());
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
if (tess.hasBrightness) {
|
||||
OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
tessa.getAngelica$shortBuffer().position(6 * 2);
|
||||
GL11.glTexCoordPointer(2, (vertexStride * 4), tessa.getAngelica$shortBuffer());
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
}
|
||||
if (tess.hasColor) {
|
||||
tessa.getAngelica$byteBuffer().position(5 * 4);
|
||||
GL11.glColorPointer(4, true, (vertexStride * 4), tessa.getAngelica$byteBuffer());
|
||||
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
|
||||
}
|
||||
if (tess.hasNormals) {
|
||||
tessa.getAngelica$floatBuffer().position(9);
|
||||
GL11.glNormalPointer((vertexStride * 4), tessa.getAngelica$floatBuffer());
|
||||
GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
|
||||
}
|
||||
tessa.getAngelica$floatBuffer().position(0);
|
||||
GL11.glVertexPointer(3, (vertexStride * 4), tessa.getAngelica$floatBuffer());
|
||||
ShadersTess.preDrawArray(tess);
|
||||
|
||||
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
||||
GL11.glDrawArrays(realDrawMode, 0, vcount);
|
||||
}
|
||||
// end loop
|
||||
|
||||
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
|
||||
ShadersTess.postDrawArray(tess);
|
||||
if (tess.hasTexture) {
|
||||
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
if (tess.hasBrightness) {
|
||||
OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
}
|
||||
if (tess.hasColor) {
|
||||
GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
|
||||
}
|
||||
if (tess.hasNormals) {
|
||||
GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY);
|
||||
}
|
||||
|
||||
int n = tess.rawBufferIndex * 4;
|
||||
tess.reset();
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
public static void preDrawArray(Tessellator tess) {
|
||||
final TessellatorAccessor tessa = (TessellatorAccessor) tess;
|
||||
// Shaders.checkGLError("preDrawArray");
|
||||
if (Shaders.useMultiTexCoord3Attrib && tess.hasTexture) {
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE3);
|
||||
GL11.glTexCoordPointer(2, (vertexStride * 4), (FloatBuffer) tessa.getAngelica$floatBuffer().position(12));
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
|
||||
}
|
||||
if (Shaders.useMidTexCoordAttrib && tess.hasTexture) {
|
||||
glVertexAttribPointerARB(
|
||||
Shaders.midTexCoordAttrib,
|
||||
2,
|
||||
false,
|
||||
vertexStride * 4,
|
||||
(FloatBuffer) tessa.getAngelica$floatBuffer().position(12));
|
||||
glEnableVertexAttribArrayARB(Shaders.midTexCoordAttrib);
|
||||
}
|
||||
if (Shaders.useEntityAttrib) {
|
||||
glVertexAttribPointerARB(
|
||||
Shaders.entityAttrib,
|
||||
3,
|
||||
false,
|
||||
false,
|
||||
vertexStride * 4,
|
||||
(ShortBuffer) tessa.getAngelica$shortBuffer().position(7 * 2));
|
||||
glEnableVertexAttribArrayARB(Shaders.entityAttrib);
|
||||
}
|
||||
// Shaders.checkGLError("preDrawArray");
|
||||
}
|
||||
|
||||
public static void preDrawArrayVBO(Tessellator tess) {
|
||||
// Shaders.checkGLError("preDrawArray");
|
||||
if (Shaders.useMultiTexCoord3Attrib && tess.hasTexture) {
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE3);
|
||||
GL11.glTexCoordPointer(2, GL11.GL_FLOAT, (vertexStride * 4), 12 * 4L);
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
|
||||
}
|
||||
if (Shaders.useMidTexCoordAttrib && tess.hasTexture) {
|
||||
glVertexAttribPointerARB(Shaders.midTexCoordAttrib, 2, GL11.GL_FLOAT, false, vertexStride * 4, 12 * 4L);
|
||||
glEnableVertexAttribArrayARB(Shaders.midTexCoordAttrib);
|
||||
}
|
||||
if (Shaders.useEntityAttrib) {
|
||||
glVertexAttribPointerARB(Shaders.entityAttrib, 3, GL11.GL_SHORT, false, vertexStride * 4, 7 * 4L);
|
||||
glEnableVertexAttribArrayARB(Shaders.entityAttrib);
|
||||
}
|
||||
// Shaders.checkGLError("preDrawArray");
|
||||
}
|
||||
|
||||
public static void postDrawArray(Tessellator tess) {
|
||||
// Shaders.checkGLError("postDrawArray");
|
||||
if (Shaders.useEntityAttrib) {
|
||||
glDisableVertexAttribArrayARB(Shaders.entityAttrib);
|
||||
}
|
||||
if (Shaders.useMidTexCoordAttrib && tess.hasTexture) {
|
||||
glDisableVertexAttribArrayARB(Shaders.midTexCoordAttrib);
|
||||
}
|
||||
if (Shaders.useMultiTexCoord3Attrib && tess.hasTexture) {
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE3);
|
||||
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
|
||||
}
|
||||
// Shaders.checkGLError("postDrawArray");
|
||||
}
|
||||
|
||||
public static void addVertex(Tessellator tess, double parx, double pary, double parz) {
|
||||
final TessellatorAccessor tessa = (TessellatorAccessor) (Object) tess;
|
||||
int[] rawBuffer = tess.rawBuffer;
|
||||
int rbi = tess.rawBufferIndex;
|
||||
float fx = (float) (parx + tess.xOffset);
|
||||
float fy = (float) (pary + tess.yOffset);
|
||||
float fz = (float) (parz + tess.zOffset);
|
||||
// Check if buffer is nearly full
|
||||
if (rbi >= tess.bufferSize - vertexStride * 4) {
|
||||
if (tess.bufferSize >= 0x1000000) {
|
||||
// Max size reached. Just draw.
|
||||
if (tess.addedVertices % 4 == 0) {
|
||||
tess.draw();
|
||||
tess.isDrawing = true;
|
||||
}
|
||||
} else if (tess.bufferSize > 0) {
|
||||
// Expand
|
||||
tess.bufferSize *= 2;
|
||||
tess.rawBuffer = rawBuffer = Arrays.copyOf(tess.rawBuffer, tess.bufferSize);
|
||||
System.out.format("Expand tesselator buffer %d\n", tess.bufferSize);
|
||||
} else {
|
||||
// Initialize
|
||||
tess.bufferSize = 0x10000;
|
||||
tess.rawBuffer = rawBuffer = new int[tess.bufferSize];
|
||||
}
|
||||
}
|
||||
|
||||
// shaders mod calculate normal and mid UV
|
||||
if (tess.drawMode == 7) {
|
||||
int i = tess.addedVertices % 4;
|
||||
float[] vertexPos = tessa.getAngelica$vertexPos();
|
||||
vertexPos[i * 4 + 0] = fx;
|
||||
vertexPos[i * 4 + 1] = fy;
|
||||
vertexPos[i * 4 + 2] = fz;
|
||||
if (i == 3) {
|
||||
// calculate normal
|
||||
float x1 = vertexPos[8 + 0] - vertexPos[+0];
|
||||
float y1 = vertexPos[8 + 1] - vertexPos[+1];
|
||||
float z1 = vertexPos[8 + 2] - vertexPos[+2];
|
||||
float x2 = vertexPos[12 + 0] - vertexPos[4 + 0];
|
||||
float y2 = vertexPos[12 + 1] - vertexPos[4 + 1];
|
||||
float z2 = vertexPos[12 + 2] - vertexPos[4 + 2];
|
||||
float vnx = y1 * z2 - y2 * z1;
|
||||
float vny = z1 * x2 - z2 * x1;
|
||||
float vnz = x1 * y2 - x2 * y1;
|
||||
float lensq = vnx * vnx + vny * vny + vnz * vnz;
|
||||
float mult = (lensq != 0.0) ? (float) (1f / Math.sqrt(lensq)) : 1f;
|
||||
float normalX = vnx * mult;
|
||||
float normalY = vny * mult;
|
||||
float normalZ = vnz * mult;
|
||||
tessa.setAngelica$normalX(normalX);
|
||||
tessa.setAngelica$normalY(normalY);
|
||||
tessa.setAngelica$normalZ(normalZ);
|
||||
rawBuffer[rbi + (9 - vertexStride * 3)] = rawBuffer[rbi + (9 - vertexStride * 2)] = rawBuffer[rbi
|
||||
+ (9 - vertexStride * 1)] = Float.floatToRawIntBits(normalX);
|
||||
rawBuffer[rbi + (10 - vertexStride * 3)] = rawBuffer[rbi + (10 - vertexStride * 2)] = rawBuffer[rbi
|
||||
+ (10 - vertexStride * 1)] = Float.floatToRawIntBits(normalY);
|
||||
rawBuffer[rbi + (11 - vertexStride * 3)] = rawBuffer[rbi + (11 - vertexStride * 2)] = rawBuffer[rbi
|
||||
+ (11 - vertexStride * 1)] = Float.floatToRawIntBits(normalZ);
|
||||
tess.hasNormals = true;
|
||||
// mid UV
|
||||
tessa.setAngelica$midTextureU(
|
||||
(Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 3)])
|
||||
+ Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 2)])
|
||||
+ Float.intBitsToFloat(rawBuffer[rbi + (3 - vertexStride * 1)])
|
||||
+ (float) tess.textureU) / 4);
|
||||
tessa.setAngelica$midTextureV(
|
||||
(Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 3)])
|
||||
+ Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 2)])
|
||||
+ Float.intBitsToFloat(rawBuffer[rbi + (4 - vertexStride * 1)])
|
||||
+ (float) tess.textureV) / 4);
|
||||
rawBuffer[rbi + (12 - vertexStride * 3)] = rawBuffer[rbi + (12 - vertexStride * 2)] = rawBuffer[rbi
|
||||
+ (12 - vertexStride * 1)] = Float.floatToRawIntBits(tessa.getAngelica$midTextureU());
|
||||
rawBuffer[rbi + (13 - vertexStride * 3)] = rawBuffer[rbi + (13 - vertexStride * 2)] = rawBuffer[rbi
|
||||
+ (13 - vertexStride * 1)] = Float.floatToRawIntBits(tessa.getAngelica$midTextureV());
|
||||
}
|
||||
}
|
||||
// end normal and mid UV calculation
|
||||
|
||||
++tess.addedVertices;
|
||||
rawBuffer[rbi + 0] = Float.floatToRawIntBits((float) fx);
|
||||
rawBuffer[rbi + 1] = Float.floatToRawIntBits((float) fy);
|
||||
rawBuffer[rbi + 2] = Float.floatToRawIntBits((float) fz);
|
||||
rawBuffer[rbi + 3] = Float.floatToRawIntBits((float) tess.textureU);
|
||||
rawBuffer[rbi + 4] = Float.floatToRawIntBits((float) tess.textureV);
|
||||
rawBuffer[rbi + 5] = tess.color;
|
||||
rawBuffer[rbi + 6] = tess.brightness;
|
||||
rawBuffer[rbi + 7] = Shaders.getEntityData();
|
||||
rawBuffer[rbi + 8] = Shaders.getEntityData2();
|
||||
rawBuffer[rbi + 9] = Float.floatToRawIntBits((float) tessa.getAngelica$normalX());
|
||||
rawBuffer[rbi + 10] = Float.floatToRawIntBits((float) tessa.getAngelica$normalY());
|
||||
rawBuffer[rbi + 11] = Float.floatToRawIntBits((float) tessa.getAngelica$normalZ());
|
||||
rawBuffer[rbi + 12] = Float.floatToRawIntBits((float) tessa.getAngelica$midTextureU());
|
||||
rawBuffer[rbi + 13] = Float.floatToRawIntBits((float) ((TessellatorAccessor) tess).getAngelica$midTextureV());
|
||||
|
||||
tess.rawBufferIndex = rbi += vertexStride;
|
||||
++tess.vertexCount;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,590 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.client.font;
|
||||
|
||||
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;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import jss.util.RandomXoshiro256StarStar;
|
||||
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;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
/**
|
||||
* A batching replacement for {@code FontRenderer}
|
||||
*
|
||||
* @author eigenraven
|
||||
*/
|
||||
public class BatchingFontRenderer {
|
||||
|
||||
/** The underlying FontRenderer object that's being accelerated */
|
||||
protected FontRenderer underlying;
|
||||
/** Cached locations for each unicode page atlas */
|
||||
private final ResourceLocation[] unicodePageLocations;
|
||||
/** Array of width of all the characters in default.png */
|
||||
protected int[] charWidth = new int[256];
|
||||
/** Array of the start/end column (in upper/lower nibble) for every glyph in the /font directory. */
|
||||
protected byte[] glyphWidth;
|
||||
/**
|
||||
* Array of RGB triplets defining the 16 standard chat colors followed by 16 darker version of the same colors for
|
||||
* drop shadows.
|
||||
*/
|
||||
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 */
|
||||
@SuppressWarnings("UnnecessaryUnicodeEscape")
|
||||
private static final String MCFONT_CHARS = "\u00c0\u00c1\u00c2\u00c8\u00ca\u00cb\u00cd\u00d3\u00d4\u00d5\u00da\u00df\u00e3\u00f5\u011f\u0130\u0131\u0152\u0153\u015e\u015f\u0174\u0175\u017e\u0207\u0000\u0000\u0000\u0000\u0000\u0000\u0000 !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\u0000\u00c7\u00fc\u00e9\u00e2\u00e4\u00e0\u00e5\u00e7\u00ea\u00eb\u00e8\u00ef\u00ee\u00ec\u00c4\u00c5\u00c9\u00e6\u00c6\u00f4\u00f6\u00f2\u00fb\u00f9\u00ff\u00d6\u00dc\u00f8\u00a3\u00d8\u00d7\u0192\u00e1\u00ed\u00f3\u00fa\u00f1\u00d1\u00aa\u00ba\u00bf\u00ae\u00ac\u00bd\u00bc\u00a1\u00ab\u00bb\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255d\u255c\u255b\u2510\u2514\u2534\u252c\u251c\u2500\u253c\u255e\u255f\u255a\u2554\u2569\u2566\u2560\u2550\u256c\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256b\u256a\u2518\u250c\u2588\u2584\u258c\u2590\u2580\u03b1\u03b2\u0393\u03c0\u03a3\u03c3\u03bc\u03c4\u03a6\u0398\u03a9\u03b4\u221e\u2205\u2208\u2229\u2261\u00b1\u2265\u2264\u2320\u2321\u00f7\u2248\u00b0\u2219\u00b7\u221a\u207f\u00b2\u25a0\u0000";
|
||||
|
||||
private static final short[] MCFONT_ASCII_LUT = new short[512];
|
||||
private static final Char2ShortOpenHashMap MCFONT_UNI_LUT = new Char2ShortOpenHashMap();
|
||||
|
||||
static {
|
||||
Arrays.fill(MCFONT_ASCII_LUT, (short) -1);
|
||||
for (short i = 0; i < MCFONT_CHARS.length(); i++) {
|
||||
char ch = MCFONT_CHARS.charAt(i);
|
||||
if (ch < MCFONT_ASCII_LUT.length) {
|
||||
MCFONT_ASCII_LUT[ch] = i;
|
||||
} else {
|
||||
MCFONT_UNI_LUT.put(ch, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int lookupMcFontPosition(char ch) {
|
||||
if (ch < MCFONT_ASCII_LUT.length) {
|
||||
return MCFONT_ASCII_LUT[ch];
|
||||
} else {
|
||||
return MCFONT_UNI_LUT.getOrDefault(ch, (short) -1);
|
||||
}
|
||||
}
|
||||
|
||||
public BatchingFontRenderer(FontRenderer underlying, ResourceLocation[] unicodePageLocations, int[] charWidth,
|
||||
byte[] glyphWidth, int[] colorCode, ResourceLocation locationFontTexture, 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());
|
||||
}
|
||||
}
|
||||
|
||||
// === Batched rendering
|
||||
|
||||
private int batchDepth = 0;
|
||||
|
||||
private int vtxWriterIndex = 0;
|
||||
private int idxWriterIndex = 0;
|
||||
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 = 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);
|
||||
|
||||
/** */
|
||||
private void pushVtx(float x, float y, int rgba, float u, float v) {
|
||||
final int oldCap = batchVtxPositions.capacity() / 2;
|
||||
if (vtxWriterIndex >= oldCap) {
|
||||
final int newCap = oldCap * 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 = CompatMemoryUtil.memReallocDirect(batchIndices, newIdxCap);
|
||||
}
|
||||
final int idx = vtxWriterIndex;
|
||||
final int idx2 = idx * 2;
|
||||
final int idx4 = idx * 4;
|
||||
batchVtxPositions.put(idx2, x);
|
||||
batchVtxPositions.put(idx2 + 1, y);
|
||||
// 0xAARRGGBB
|
||||
batchVtxColors.put(idx4, (byte) ((rgba >> 16) & 0xFF));
|
||||
batchVtxColors.put(idx4 + 1, (byte) ((rgba >> 8) & 0xFF));
|
||||
batchVtxColors.put(idx4 + 2, (byte) (rgba & 0xFF));
|
||||
batchVtxColors.put(idx4 + 3, (byte) ((rgba >> 24) & 0xFF));
|
||||
batchVtxTexCoords.put(idx2, u);
|
||||
batchVtxTexCoords.put(idx2 + 1, v);
|
||||
vtxWriterIndex++;
|
||||
}
|
||||
|
||||
private void pushUntexRect(float x, float y, float w, float h, int rgba) {
|
||||
final int vtxId = vtxWriterIndex;
|
||||
pushVtx(x, y, rgba, 0, 0);
|
||||
pushVtx(x, y + h, rgba, 0, 0);
|
||||
pushVtx(x + w, y, rgba, 0, 0);
|
||||
pushVtx(x + w, y + h, rgba, 0, 0);
|
||||
pushQuadIdx(vtxId);
|
||||
}
|
||||
|
||||
private int pushQuadIdx(int startV) {
|
||||
final int idx = idxWriterIndex;
|
||||
batchIndices.put(idx, startV);
|
||||
batchIndices.put(idx + 1, startV + 1);
|
||||
batchIndices.put(idx + 2, startV + 2);
|
||||
//
|
||||
batchIndices.put(idx + 3, startV + 2);
|
||||
batchIndices.put(idx + 4, startV + 1);
|
||||
batchIndices.put(idx + 5, startV + 3);
|
||||
idxWriterIndex += 6;
|
||||
return idx;
|
||||
}
|
||||
|
||||
private void pushDrawCmd(int startIdx, int idxCount, ResourceLocation texture) {
|
||||
if (!batchCommands.isEmpty()) {
|
||||
final FontDrawCmd lastCmd = batchCommands.get(batchCommands.size() - 1);
|
||||
final int prevEndVtx = lastCmd.startVtx + lastCmd.idxCount;
|
||||
if (prevEndVtx == startIdx && lastCmd.texture == texture) {
|
||||
// Coalesce into one
|
||||
lastCmd.idxCount += idxCount;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (batchCommandPool.isEmpty()) {
|
||||
for (int i = 0; i < 64; i++) {
|
||||
batchCommandPool.add(new FontDrawCmd());
|
||||
}
|
||||
}
|
||||
final FontDrawCmd cmd = batchCommandPool.pop();
|
||||
cmd.reset(startIdx, idxCount, texture);
|
||||
batchCommands.add(cmd);
|
||||
}
|
||||
|
||||
private static final class FontDrawCmd {
|
||||
|
||||
public int startVtx;
|
||||
public int idxCount;
|
||||
public ResourceLocation texture;
|
||||
|
||||
public void reset(int startVtx, int vtxCount, ResourceLocation texture) {
|
||||
this.startVtx = startVtx;
|
||||
this.idxCount = vtxCount;
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
||||
var that = (FontDrawCmd) obj;
|
||||
return this.startVtx == that.startVtx && this.idxCount == that.idxCount && Objects.equals(this.texture,
|
||||
that.texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(startVtx, idxCount, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FontDrawCmd["
|
||||
+ "startVtx="
|
||||
+ startVtx
|
||||
+ ", "
|
||||
+ "vtxCount="
|
||||
+ idxCount
|
||||
+ ", "
|
||||
+ "texture="
|
||||
+ texture
|
||||
+ ']';
|
||||
}
|
||||
|
||||
public static final Comparator<FontDrawCmd> DRAW_ORDER_COMPARATOR = Comparator.comparing((FontDrawCmd fdc) -> fdc.texture,
|
||||
Comparator.nullsLast(Comparator.comparing(ResourceLocation::getResourceDomain)
|
||||
.thenComparing(ResourceLocation::getResourcePath))).thenComparing(fdc -> fdc.startVtx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a new batch of font rendering operations. Can be called from within another batch with a matching end, to
|
||||
* allow for easier optimizing of blocks of font rendering code.
|
||||
*/
|
||||
public void beginBatch() {
|
||||
if (batchDepth == Integer.MAX_VALUE) {
|
||||
throw new StackOverflowError("More than Integer.MAX_VALUE nested font rendering batch operations");
|
||||
}
|
||||
batchDepth++;
|
||||
}
|
||||
|
||||
public void endBatch() {
|
||||
if (batchDepth <= 0) {
|
||||
batchDepth = 0;
|
||||
return;
|
||||
}
|
||||
batchDepth--;
|
||||
if (batchDepth == 0) {
|
||||
// We finished any nested batches
|
||||
flushBatch();
|
||||
}
|
||||
}
|
||||
|
||||
private void flushBatch() {
|
||||
// Sort&Draw
|
||||
batchCommands.sort(FontDrawCmd.DRAW_ORDER_COMPARATOR);
|
||||
|
||||
final boolean isTextureEnabledBefore = GLStateManager.glIsEnabled(GL11.GL_TEXTURE_2D);
|
||||
final int boundTextureBefore = GLStateManager.getBoundTexture();
|
||||
boolean textureChanged = false;
|
||||
|
||||
ResourceLocation lastTexture = DUMMY_RESOURCE_LOCATION;
|
||||
GLStateManager.enableTexture();
|
||||
GLStateManager.enableAlphaTest();
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
|
||||
GLStateManager.glShadeModel(GL_FLAT);
|
||||
|
||||
glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
|
||||
glTexCoordPointer(2, 0, batchVtxTexCoords);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, 0, batchVtxColors);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glVertexPointer(2, 0, batchVtxPositions);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
// Use plain for loop to avoid allocations
|
||||
final FontDrawCmd[] cmdsData = batchCommands.elements();
|
||||
final int cmdsSize = batchCommands.size();
|
||||
for (int i = 0; i < cmdsSize; i++) {
|
||||
final FontDrawCmd cmd = cmdsData[i];
|
||||
if (!Objects.equals(lastTexture, cmd.texture)) {
|
||||
if (lastTexture == null) {
|
||||
GLStateManager.enableTexture();
|
||||
} else if (cmd.texture == null) {
|
||||
GLStateManager.disableTexture();
|
||||
}
|
||||
if (cmd.texture != null) {
|
||||
((FontRendererAccessor) underlying).angelica$bindTexture(cmd.texture);
|
||||
textureChanged = true;
|
||||
}
|
||||
lastTexture = cmd.texture;
|
||||
}
|
||||
batchIndices.limit(cmd.startVtx + cmd.idxCount);
|
||||
batchIndices.position(cmd.startVtx);
|
||||
glDrawElements(GL_TRIANGLES, batchIndices);
|
||||
}
|
||||
|
||||
glPopClientAttrib();
|
||||
|
||||
if (isTextureEnabledBefore) {
|
||||
GLStateManager.enableTexture();
|
||||
}
|
||||
if (textureChanged) {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, boundTextureBefore);
|
||||
}
|
||||
|
||||
// Clear for the next batch
|
||||
batchCommandPool.addAll(batchCommands);
|
||||
batchCommands.clear();
|
||||
vtxWriterIndex = 0;
|
||||
idxWriterIndex = 0;
|
||||
batchIndices.limit(batchIndices.capacity());
|
||||
batchIndices.position(0);
|
||||
}
|
||||
|
||||
// === Actual text mesh generation
|
||||
|
||||
public static boolean charInRange(char what, char fromInclusive, char toInclusive) {
|
||||
return (what >= fromInclusive) && (what <= toInclusive);
|
||||
}
|
||||
|
||||
private ResourceLocation getUnicodePageLocation(int page) {
|
||||
final ResourceLocation lookup = unicodePageLocations[page];
|
||||
if (lookup == null) {
|
||||
final ResourceLocation rl = new ResourceLocation(String.format(
|
||||
"textures/font/unicode_page_%02x.png",
|
||||
page));
|
||||
unicodePageLocations[page] = rl;
|
||||
return rl;
|
||||
} else {
|
||||
return lookup;
|
||||
}
|
||||
}
|
||||
|
||||
private static final char FORMATTING_CHAR = 167; // §
|
||||
|
||||
public float drawString(final float anchorX, final float anchorY, final int color, final boolean enableShadow,
|
||||
final boolean unicodeFlag, final CharSequence string, int stringOffset, int stringLength) {
|
||||
// noinspection SizeReplaceableByIsEmpty
|
||||
if (string == null || string.length() == 0) {
|
||||
return anchorX + (enableShadow ? 1.0f : 0.0f);
|
||||
}
|
||||
final int shadowColor = (color & 0xfcfcfc) >> 2 | color & 0xff000000;
|
||||
|
||||
this.beginBatch();
|
||||
float curX = anchorX;
|
||||
try {
|
||||
final int totalStringLength = string.length();
|
||||
stringOffset = MathHelper.clamp_int(stringOffset, 0, totalStringLength);
|
||||
stringLength = MathHelper.clamp_int(stringLength, 0, totalStringLength - stringOffset);
|
||||
if (stringLength <= 0) {
|
||||
return 0;
|
||||
}
|
||||
final int stringEnd = stringOffset + stringLength;
|
||||
|
||||
int curColor = color;
|
||||
int curShadowColor = shadowColor;
|
||||
boolean curItalic = false;
|
||||
boolean curRandom = false;
|
||||
boolean curBold = false;
|
||||
boolean curStrikethrough = false;
|
||||
boolean curUnderline = false;
|
||||
|
||||
final float underlineY = anchorY + underlying.FONT_HEIGHT - 1.0f;
|
||||
float underlineStartX = 0.0f;
|
||||
float underlineEndX = 0.0f;
|
||||
final float strikethroughY = anchorY + (float) (underlying.FONT_HEIGHT / 2);
|
||||
float strikethroughStartX = 0.0f;
|
||||
float strikethroughEndX = 0.0f;
|
||||
|
||||
for (int charIdx = stringOffset; charIdx < stringEnd; charIdx++) {
|
||||
char chr = string.charAt(charIdx);
|
||||
if (chr == FORMATTING_CHAR && (charIdx + 1) < stringEnd) {
|
||||
final char fmtCode = Character.toLowerCase(string.charAt(charIdx + 1));
|
||||
charIdx++;
|
||||
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
underlineStartX = underlineEndX;
|
||||
}
|
||||
if (curStrikethrough && strikethroughStartX != strikethroughEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(
|
||||
strikethroughStartX,
|
||||
strikethroughY,
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
strikethroughStartX = strikethroughEndX;
|
||||
}
|
||||
|
||||
final boolean is09 = charInRange(fmtCode, '0', '9');
|
||||
final boolean isAF = charInRange(fmtCode, 'a', 'f');
|
||||
if (is09 || isAF) {
|
||||
curRandom = false;
|
||||
curBold = false;
|
||||
curStrikethrough = false;
|
||||
curUnderline = false;
|
||||
curItalic = false;
|
||||
|
||||
final int colorIdx = is09 ? (fmtCode - '0') : (fmtCode - 'a' + 10);
|
||||
final int rgb = this.colorCode[colorIdx];
|
||||
curColor = (curColor & 0xFF000000) | (rgb & 0x00FFFFFF);
|
||||
final int shadowRgb = this.colorCode[colorIdx + 16];
|
||||
curShadowColor = (curShadowColor & 0xFF000000) | (shadowRgb & 0x00FFFFFF);
|
||||
} else if (fmtCode == 'k') {
|
||||
curRandom = true;
|
||||
} else if (fmtCode == 'l') {
|
||||
curBold = true;
|
||||
} else if (fmtCode == 'm') {
|
||||
curStrikethrough = true;
|
||||
strikethroughStartX = curX - 1.0f;
|
||||
strikethroughEndX = strikethroughStartX;
|
||||
} else if (fmtCode == 'n') {
|
||||
curUnderline = true;
|
||||
underlineStartX = curX - 1.0f;
|
||||
underlineEndX = underlineStartX;
|
||||
} else if (fmtCode == 'o') {
|
||||
curItalic = true;
|
||||
} else if (fmtCode == 'r') {
|
||||
curRandom = false;
|
||||
curBold = false;
|
||||
curStrikethrough = false;
|
||||
curUnderline = false;
|
||||
curItalic = false;
|
||||
curColor = color;
|
||||
curShadowColor = shadowColor;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
int lutIndex = lookupMcFontPosition(chr);
|
||||
if (curRandom && lutIndex != -1) {
|
||||
int randomReplacementIndex;
|
||||
do {
|
||||
randomReplacementIndex = fontRandom.nextInt(this.charWidth.length);
|
||||
} while (this.charWidth[lutIndex] != this.charWidth[randomReplacementIndex]);
|
||||
|
||||
lutIndex = randomReplacementIndex;
|
||||
chr = MCFONT_CHARS.charAt(lutIndex);
|
||||
}
|
||||
|
||||
final float shadowOffset = unicodeFlag ? 0.5F : 1.0F;
|
||||
|
||||
// Check ASCII space, NBSP, NNBSP
|
||||
if (chr == ' ' || chr == '\u00A0' || chr == '\u202F') {
|
||||
curX += 4;
|
||||
continue;
|
||||
}
|
||||
|
||||
final float uStart;
|
||||
final float vStart;
|
||||
final float xAdvance;
|
||||
final float glyphW;
|
||||
final float uSz;
|
||||
final float vSz;
|
||||
final float itOff = curItalic ? 1.0F : 0.0F; // italic offset
|
||||
final ResourceLocation texture;
|
||||
|
||||
if (lutIndex == -1 || unicodeFlag) {
|
||||
if (glyphWidth[chr] == 0) {
|
||||
continue;
|
||||
}
|
||||
// Draw unicode char
|
||||
final int uniPage = chr / 256;
|
||||
texture = getUnicodePageLocation(uniPage);
|
||||
final int startColumn = this.glyphWidth[chr] >>> 4;
|
||||
final int endColumn = this.glyphWidth[chr] & 15;
|
||||
final float startColumnF = (float) startColumn;
|
||||
final float endColumnF = (float) (endColumn + 1);
|
||||
uStart = ((float) (chr % 16 * 16) + startColumnF) / 256.0f;
|
||||
vStart = ((float) ((chr & 255) / 16 * 16)) / 256.0f;
|
||||
final float chrWidth = endColumnF - startColumnF - 0.02F;
|
||||
glyphW = chrWidth / 2.0f + 1.0f;
|
||||
xAdvance = (endColumnF - startColumnF) / 2.0F + 1.0F;
|
||||
uSz = chrWidth / 256.0f;
|
||||
vSz = 15.98f / 256.0f;
|
||||
|
||||
} else {
|
||||
// Draw "ASCII" char
|
||||
uStart = ((lutIndex % 16) * 8) / 128.0F;
|
||||
vStart = (float) ((lutIndex / 16) * 8) / 128.0F;
|
||||
xAdvance = this.charWidth[lutIndex];
|
||||
if (xAdvance == 0) {
|
||||
continue;
|
||||
}
|
||||
glyphW = xAdvance - 0.01F;
|
||||
uSz = (glyphW - 1.0F) / 128.0F;
|
||||
vSz = 7.99F / 128.0F;
|
||||
texture = locationFontTexture;
|
||||
}
|
||||
|
||||
final int vtxId = vtxWriterIndex;
|
||||
final int idxId = idxWriterIndex;
|
||||
|
||||
int vtxCount = 0;
|
||||
|
||||
if (enableShadow) {
|
||||
pushVtx(curX + itOff + shadowOffset, anchorY + shadowOffset, curShadowColor, uStart, vStart);
|
||||
pushVtx(
|
||||
curX - itOff + shadowOffset,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart,
|
||||
vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff + shadowOffset,
|
||||
anchorY + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
|
||||
if (curBold) {
|
||||
final float shadowOffset2 = 2.0f * shadowOffset;
|
||||
pushVtx(curX + itOff + shadowOffset2, anchorY + shadowOffset, curShadowColor, uStart, vStart);
|
||||
pushVtx(
|
||||
curX - itOff + shadowOffset2,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart,
|
||||
vStart + vSz);
|
||||
pushVtx(
|
||||
curX + glyphW - 1.0F + itOff + shadowOffset2,
|
||||
anchorY + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff + shadowOffset2,
|
||||
anchorY + 7.99F + shadowOffset,
|
||||
curShadowColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
}
|
||||
}
|
||||
|
||||
pushVtx(curX + itOff, anchorY, curColor, uStart, vStart);
|
||||
pushVtx(curX - itOff, anchorY + 7.99F, curColor, uStart, vStart + vSz);
|
||||
pushVtx(curX + glyphW - 1.0F + itOff, anchorY, curColor, uStart + uSz, vStart);
|
||||
pushVtx(curX + glyphW - 1.0F - itOff, anchorY + 7.99F, curColor, uStart + uSz, vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
|
||||
if (curBold) {
|
||||
pushVtx(shadowOffset + curX + itOff, anchorY, curColor, uStart, vStart);
|
||||
pushVtx(shadowOffset + curX - itOff, anchorY + 7.99F, curColor, uStart, vStart + vSz);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F + itOff, anchorY, curColor, uStart + uSz, vStart);
|
||||
pushVtx(shadowOffset + curX + glyphW - 1.0F - itOff,
|
||||
anchorY + 7.99F,
|
||||
curColor,
|
||||
uStart + uSz,
|
||||
vStart + vSz);
|
||||
pushQuadIdx(vtxId + vtxCount);
|
||||
vtxCount += 4;
|
||||
}
|
||||
|
||||
pushDrawCmd(idxId, vtxCount / 2 * 3, texture);
|
||||
curX += xAdvance + (curBold ? shadowOffset : 0.0f);
|
||||
underlineEndX = curX;
|
||||
strikethroughEndX = curX;
|
||||
}
|
||||
|
||||
if (curUnderline && underlineStartX != underlineEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(underlineStartX, underlineY, underlineEndX - underlineStartX, 1.0f, curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
}
|
||||
if (curStrikethrough && strikethroughStartX != strikethroughEndX) {
|
||||
final int ulIdx = idxWriterIndex;
|
||||
pushUntexRect(
|
||||
strikethroughStartX,
|
||||
strikethroughY,
|
||||
strikethroughEndX - strikethroughStartX,
|
||||
1.0f,
|
||||
curColor);
|
||||
pushDrawCmd(ulIdx, 6, null);
|
||||
}
|
||||
|
||||
} finally {
|
||||
this.endBatch();
|
||||
}
|
||||
return curX + (enableShadow ? 1.0f : 0.0f);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Element;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ScrollableGuiScreen extends GuiScreen {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
handleMouseScroll(mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
public abstract List<? extends Element> children();
|
||||
|
||||
protected void handleMouseScroll(int mouseX, int mouseY, float partialTicks) {
|
||||
for (; !this.mc.gameSettings.touchscreen && Mouse.next(); this.mc.currentScreen.handleMouseInput()) {
|
||||
int dWheel = Mouse.getEventDWheel();
|
||||
|
||||
if (dWheel != 0) {
|
||||
for(Element child : children()) {
|
||||
child.mouseScrolled(mouseX, mouseY, dWheel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,249 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.client.renderer;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITessellatorInstance;
|
||||
import com.gtnewhorizons.angelica.utils.ObjectPooler;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import org.joml.Vector3d;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.reflect.Field;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.util.MathHelper.clamp_int;
|
||||
|
||||
/*
|
||||
* To be used in conjunction with the TessellatorManager
|
||||
*
|
||||
* Used to capture the quads generated by the Tessellator across multiple draw calls and make the quad
|
||||
* list available for usage.
|
||||
*
|
||||
* NOTE: This will _not_ (currently) capture, integrate, or stop any GL calls made around the tessellator draw calls.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class CapturingTessellator extends Tessellator implements ITessellatorInstance {
|
||||
|
||||
// Access Transformers don't work on Forge Fields :rage:
|
||||
private static final MethodHandle sRawBufferSize;
|
||||
private static final MethodHandle gRawBufferSize;
|
||||
private final BlockRenderer.Flags FLAGS = new BlockRenderer.Flags(true, true, true, true);
|
||||
private final ObjectPooler<Quad> quadBuf = new ObjectPooler<>(Quad::new);
|
||||
private final List<Quad> collectedQuads = new ObjectArrayList<>();
|
||||
|
||||
// Any offset we need to the Tesselator's offset!
|
||||
private final BlockPos offset = new BlockPos();
|
||||
|
||||
private final Vector3d storedTranslation = new Vector3d();
|
||||
private boolean translationStored = false;
|
||||
|
||||
public void setOffset(BlockPos pos) {
|
||||
this.offset.set(pos);
|
||||
}
|
||||
public void resetOffset() {
|
||||
this.offset.zero();
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
final Field rbs = ReflectionHelper.findField(Tessellator.class, "rawBufferSize");
|
||||
rbs.setAccessible(true);
|
||||
try {
|
||||
sRawBufferSize = MethodHandles.lookup().unreflectSetter(rbs);
|
||||
gRawBufferSize = MethodHandles.lookup().unreflectGetter(rbs);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setRawBufferSize(int size) {
|
||||
try {
|
||||
sRawBufferSize.invokeExact((Tessellator)this, size);
|
||||
} catch (Throwable throwable) {
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
}
|
||||
public int getRawBufferSize() {
|
||||
try {
|
||||
return (int) gRawBufferSize.invokeExact((Tessellator)this);
|
||||
} catch (Throwable throwable) {
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int draw() {
|
||||
// Adapted from Neodymium
|
||||
|
||||
FLAGS.hasBrightness = this.hasBrightness;
|
||||
FLAGS.hasColor = this.hasColor;
|
||||
FLAGS.hasNormals = this.hasNormals;
|
||||
|
||||
final int verticesPerPrimitive = this.drawMode == GL11.GL_QUADS ? 4 : 3;
|
||||
|
||||
|
||||
for(int quadI = 0; quadI < this.vertexCount / verticesPerPrimitive; quadI++) {
|
||||
final Quad quad = quadBuf.getInstance();
|
||||
quad.setState(this.rawBuffer, quadI * (verticesPerPrimitive * 8), FLAGS, this.drawMode, -offset.x, -offset.y, -offset.z);
|
||||
|
||||
if(quad.deleted) {
|
||||
quadBuf.releaseInstance(quad);
|
||||
} else {
|
||||
this.collectedQuads.add(quad);
|
||||
}
|
||||
}
|
||||
|
||||
final int i = this.rawBufferIndex * 4;
|
||||
this.discard();
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void discard() {
|
||||
isDrawing = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
public List<Quad> getQuads() {
|
||||
return collectedQuads;
|
||||
}
|
||||
|
||||
public void clearQuads() {
|
||||
//noinspection ForLoopReplaceableByForEach
|
||||
for(int i = 0; i < this.collectedQuads.size(); i++) {
|
||||
this.quadBuf.releaseInstance(this.collectedQuads.get(i));
|
||||
}
|
||||
this.collectedQuads.clear();
|
||||
}
|
||||
|
||||
public static ByteBuffer quadsToBuffer(List<Quad> quads, VertexFormat format) {
|
||||
if(!format.canWriteQuads()) {
|
||||
throw new IllegalStateException("Vertex format has no quad writer: " + format);
|
||||
}
|
||||
final ByteBuffer byteBuffer = BufferUtils.createByteBuffer(format.getVertexSize() * quads.size() * 4);
|
||||
// noinspection ForLoopReplaceableByForEach
|
||||
for (int i = 0, quadsSize = quads.size(); i < quadsSize; i++) {
|
||||
format.writeQuad(quads.get(i), byteBuffer);
|
||||
}
|
||||
byteBuffer.rewind();
|
||||
return byteBuffer;
|
||||
}
|
||||
|
||||
public void storeTranslation() {
|
||||
if(translationStored) throw new IllegalStateException("Translation already stored!");
|
||||
translationStored = true;
|
||||
this.storedTranslation.set(xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
public void restoreTranslation() {
|
||||
if(!translationStored) throw new IllegalStateException("Translation not stored!");
|
||||
|
||||
xOffset = storedTranslation.x;
|
||||
yOffset = storedTranslation.y;
|
||||
zOffset = storedTranslation.z;
|
||||
storedTranslation.zero();
|
||||
translationStored = false;
|
||||
}
|
||||
|
||||
public static int createBrightness(int sky, int block) {
|
||||
return sky << 20 | block << 4;
|
||||
}
|
||||
|
||||
// API from newer MC
|
||||
public CapturingTessellator pos(double x, double y, double z) {
|
||||
ensureBuffer();
|
||||
|
||||
this.rawBuffer[this.rawBufferIndex + 0] = Float.floatToRawIntBits((float)(x + this.xOffset));
|
||||
this.rawBuffer[this.rawBufferIndex + 1] = Float.floatToRawIntBits((float)(y + this.yOffset));
|
||||
this.rawBuffer[this.rawBufferIndex + 2] = Float.floatToRawIntBits((float)(z + this.zOffset));
|
||||
|
||||
return this;
|
||||
}
|
||||
public CapturingTessellator tex(double u, double v) {
|
||||
this.rawBuffer[this.rawBufferIndex + 3] = Float.floatToRawIntBits((float)u);
|
||||
this.rawBuffer[this.rawBufferIndex + 4] = Float.floatToRawIntBits((float)v);
|
||||
this.hasTexture = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CapturingTessellator color(float red, float green, float blue, float alpha) {
|
||||
return this.color((int)(red * 255.0F), (int)(green * 255.0F), (int)(blue * 255.0F), (int)(alpha * 255.0F));
|
||||
}
|
||||
|
||||
public CapturingTessellator color(int red, int green, int blue, int alpha) {
|
||||
if(this.isColorDisabled) return this;
|
||||
red = clamp_int(red, 0, 255);
|
||||
green = clamp_int(green, 0, 255);
|
||||
blue = clamp_int(blue, 0, 255);
|
||||
alpha = clamp_int(alpha, 0, 255);
|
||||
|
||||
final int color;
|
||||
if (ByteOrder.nativeOrder() == ByteOrder.LITTLE_ENDIAN) {
|
||||
color = alpha << 24 | blue << 16 | green << 8 | red;
|
||||
} else {
|
||||
color = red << 24 | green << 16 | blue << 8 | alpha;
|
||||
}
|
||||
this.rawBuffer[this.rawBufferIndex + 5] = color;
|
||||
this.hasColor = true;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public CapturingTessellator normal(float x, float y, float z) {
|
||||
final byte b0 = (byte)((int)(x * 127.0F));
|
||||
final byte b1 = (byte)((int)(y * 127.0F));
|
||||
final byte b2 = (byte)((int)(z * 127.0F));
|
||||
|
||||
this.rawBuffer[this.rawBufferIndex + 6] = b0 & 255 | (b1 & 255) << 8 | (b2 & 255) << 16;
|
||||
this.hasNormals = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CapturingTessellator lightmap(int skyLight, int blockLight) {
|
||||
return brightness(createBrightness(skyLight, blockLight));
|
||||
}
|
||||
|
||||
public CapturingTessellator brightness(int brightness) {
|
||||
this.rawBuffer[this.rawBufferIndex + 7] = brightness;
|
||||
this.hasBrightness = true;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CapturingTessellator endVertex() {
|
||||
this.rawBufferIndex += 8;
|
||||
++this.vertexCount;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void ensureBuffer() {
|
||||
int rawBufferSize = getRawBufferSize();
|
||||
if (rawBufferIndex >= rawBufferSize - 32) {
|
||||
if (rawBufferSize == 0) {
|
||||
rawBufferSize = 0x10000;
|
||||
setRawBufferSize(rawBufferSize);
|
||||
rawBuffer = new int[rawBufferSize];
|
||||
} else {
|
||||
rawBufferSize *= 2;
|
||||
setRawBufferSize(rawBufferSize);
|
||||
rawBuffer = Arrays.copyOf(rawBuffer, rawBufferSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import com.falsepattern.chunk.api.DataRegistry;
|
||||
import com.gtnewhorizons.angelica.mixins.early.sodium.MixinExtendedBlockStorage;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ExtendedNibbleArray;
|
||||
import com.gtnewhorizons.neid.mixins.interfaces.IExtendedBlockStorageMixin;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.NibbleArray;
|
||||
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
|
||||
import ru.fewizz.idextender.Hooks;
|
||||
|
||||
public class ExtendedBlockStorageExt extends ExtendedBlockStorage {
|
||||
public boolean hasSky;
|
||||
|
||||
public ExtendedBlockStorageExt(int yBase, boolean hasSky) {
|
||||
super(yBase, hasSky);
|
||||
this.hasSky = hasSky;
|
||||
}
|
||||
|
||||
public ExtendedBlockStorageExt(Chunk chunk, ExtendedBlockStorage storage) {
|
||||
super(((MixinExtendedBlockStorage) storage).getYBase(), storage.getSkylightArray() != null);
|
||||
|
||||
if (ModStatus.isChunkAPILoaded) {
|
||||
if (storage.getSkylightArray() != null) {
|
||||
hasSky = true;
|
||||
}
|
||||
DataRegistry.cloneSubChunk(chunk, storage, this);
|
||||
} else {
|
||||
int arrayLen;
|
||||
if (ModStatus.isNEIDLoaded){
|
||||
final short[] block16BArray = ((IExtendedBlockStorageMixin)(Object)this).getBlock16BArray();
|
||||
System.arraycopy(((IExtendedBlockStorageMixin)(Object)storage).getBlock16BArray(), 0, block16BArray, 0, block16BArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(block16BArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = block16BArray.length;
|
||||
}
|
||||
else if (ModStatus.isOldNEIDLoaded){
|
||||
final short[] blockLSBArray = Hooks.get(this);
|
||||
System.arraycopy(Hooks.get(storage), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
// getBlockMSBArray is nuked in asm version
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
else {
|
||||
final byte[] blockLSBArray = this.getBlockLSBArray();
|
||||
System.arraycopy(storage.getBlockLSBArray(), 0, blockLSBArray, 0, blockLSBArray.length);
|
||||
if(storage.getBlockMSBArray() != null) {
|
||||
this.setBlockMSBArray(new NibbleArray(blockLSBArray.length, 4));
|
||||
copyNibbleArray((ExtendedNibbleArray) storage.getBlockMSBArray(), (ExtendedNibbleArray) this.getBlockMSBArray());
|
||||
}
|
||||
arrayLen = blockLSBArray.length;
|
||||
}
|
||||
|
||||
|
||||
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((ExtendedNibbleArray) storage.getSkylightArray(), (ExtendedNibbleArray) this.getSkylightArray());
|
||||
}
|
||||
}
|
||||
((MixinExtendedBlockStorage) this).setBlockRefCount(((MixinExtendedBlockStorage) storage).getBlockRefCount());
|
||||
}
|
||||
|
||||
|
||||
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.getData();
|
||||
System.arraycopy(data, 0, dstArray.getData(), 0, data.length);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class ModStatus {
|
||||
/**
|
||||
* Mixin Version
|
||||
*/
|
||||
public static boolean isNEIDLoaded;
|
||||
/**
|
||||
* ASM Version
|
||||
*/
|
||||
public static boolean isOldNEIDLoaded;
|
||||
public static boolean isLotrLoaded;
|
||||
public static boolean isChunkAPILoaded;
|
||||
public static boolean isEIDBiomeLoaded;
|
||||
|
||||
public static void preInit(){
|
||||
isNEIDLoaded = Loader.isModLoaded("neid");
|
||||
isOldNEIDLoaded = Loader.isModLoaded("notenoughIDs");
|
||||
isLotrLoaded = Loader.isModLoaded("lotr");
|
||||
isChunkAPILoaded = Loader.isModLoaded("chunkapi");
|
||||
isEIDBiomeLoaded = Loader.isModLoaded("endlessids_biome");
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.lwjgl;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
public class CompatMemoryUtil {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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>
|
||||
*/
|
||||
|
||||
static final sun.misc.Unsafe UNSAFE;
|
||||
|
||||
static {
|
||||
UNSAFE = getUnsafeInstance();
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
|
||||
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); }
|
||||
|
||||
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); }
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public abstract class AutoClosableAbstractTexture extends AbstractTexture implements AutoCloseable {
|
||||
@Override
|
||||
public void close() throws Exception {}
|
||||
|
||||
// TODO: Is this needed?
|
||||
public void bind() {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, getGlTextureId());
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
|
||||
public enum Axis {
|
||||
X,
|
||||
Y,
|
||||
Z;
|
||||
|
||||
public static Axis fromDirection(ModelQuadFacing dir) {
|
||||
return switch (dir) {
|
||||
case DOWN, UP -> Y;
|
||||
case NORTH, SOUTH -> Z;
|
||||
case WEST, EAST -> X;
|
||||
default -> null;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import static com.google.common.math.IntMath.log2;
|
||||
|
||||
// Should we keep this?
|
||||
public class BlockPos extends Vector3i {
|
||||
|
||||
private static final int SIZE_BITS_X = 1 + log2(MathHelper.roundUpToPowerOfTwo(30000000), RoundingMode.UNNECESSARY);
|
||||
private static final int SIZE_BITS_Z = SIZE_BITS_X;
|
||||
private static final int SIZE_BITS_Y = 64 - SIZE_BITS_X - SIZE_BITS_Z;
|
||||
private static final long BITS_X = (1L << SIZE_BITS_X) - 1L;
|
||||
private static final long BITS_Y = (1L << SIZE_BITS_Y) - 1L;
|
||||
private static final long BITS_Z = (1L << SIZE_BITS_Z) - 1L;
|
||||
private static final int BIT_SHIFT_Z = SIZE_BITS_Y;
|
||||
private static final int BIT_SHIFT_X = SIZE_BITS_Y + SIZE_BITS_Z;
|
||||
|
||||
public BlockPos() {
|
||||
super();
|
||||
}
|
||||
public BlockPos(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
}
|
||||
|
||||
public BlockPos(ChunkPosition chunkPosition) {
|
||||
super(chunkPosition.chunkPosX, chunkPosition.chunkPosY, chunkPosition.chunkPosZ);
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public BlockPos set(int x, int y, int z) {
|
||||
super.set(x, y, z);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method does NOT mutate the BlockPos
|
||||
*/
|
||||
public BlockPos offset(ForgeDirection d) {
|
||||
return new BlockPos(this.x + d.offsetX, this.y + d.offsetY, this.z + d.offsetZ);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method does NOT mutate the BlockPos
|
||||
*/
|
||||
public BlockPos down() {
|
||||
return offset(ForgeDirection.DOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method does NOT mutate the BlockPos
|
||||
*/
|
||||
public BlockPos up() {
|
||||
return offset(ForgeDirection.UP);
|
||||
}
|
||||
|
||||
public long asLong() {
|
||||
return asLong(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public static long asLong(int x, int y, int z) {
|
||||
long l = 0L;
|
||||
l |= ((long)x & BITS_X) << BIT_SHIFT_X;
|
||||
l |= ((long)y & BITS_Y) << 0;
|
||||
l |= ((long)z & BITS_Z) << BIT_SHIFT_Z;
|
||||
return l;
|
||||
}
|
||||
|
||||
public BlockPos set(long packedPos) {
|
||||
return set(unpackLongX(packedPos), unpackLongY(packedPos), unpackLongZ(packedPos));
|
||||
}
|
||||
|
||||
public static int unpackLongX(long packedPos) {
|
||||
return (int)(packedPos << 64 - BIT_SHIFT_X - SIZE_BITS_X >> 64 - SIZE_BITS_X);
|
||||
}
|
||||
|
||||
public static int unpackLongY(long packedPos) {
|
||||
return (int)(packedPos << 64 - SIZE_BITS_Y >> 64 - SIZE_BITS_Y);
|
||||
}
|
||||
|
||||
public static int unpackLongZ(long packedPos) {
|
||||
return (int)(packedPos << 64 - BIT_SHIFT_Z - SIZE_BITS_Z >> 64 - SIZE_BITS_Z);
|
||||
}
|
||||
|
||||
public static class Mutable extends BlockPos {
|
||||
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class ByteBufferBackedInputStream extends InputStream {
|
||||
|
||||
ByteBuffer buf;
|
||||
|
||||
public ByteBufferBackedInputStream(ByteBuffer buf) {
|
||||
this.buf = buf;
|
||||
}
|
||||
|
||||
public int read() throws IOException {
|
||||
if (!buf.hasRemaining()) {
|
||||
return -1;
|
||||
}
|
||||
return buf.get() & 0xFF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte @NotNull [] bytes, int off, int len) throws IOException {
|
||||
if (!buf.hasRemaining()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
len = Math.min(len, buf.remaining());
|
||||
buf.get(bytes, off, len);
|
||||
return len;
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
@Getter
|
||||
public class Camera {
|
||||
final Vector3d pos = new Vector3d();
|
||||
final BlockPos.Mutable blockPos = new BlockPos.Mutable();
|
||||
float pitch;
|
||||
float yaw;
|
||||
EntityLivingBase entity;
|
||||
boolean thirdPerson;
|
||||
final float partialTicks;
|
||||
|
||||
public Camera(EntityLivingBase entity, float partialTicks) {
|
||||
this.partialTicks = partialTicks;
|
||||
final Vector4f offset = new Vector4f(); // third person offset
|
||||
final Matrix4f inverseModelView = new Matrix4f(RenderingState.INSTANCE.getModelViewMatrix()).invert();
|
||||
inverseModelView.transform(offset);
|
||||
|
||||
final double camX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks + offset.x;
|
||||
final double camY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks + offset.y;
|
||||
final double camZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks + offset.z;
|
||||
this.entity = entity;
|
||||
|
||||
pos.set(camX, camY, camZ);
|
||||
blockPos.set(MathHelper.floor_double(camX), MathHelper.floor_double(camY), MathHelper.floor_double(camZ));
|
||||
pitch = entity.cameraPitch;
|
||||
yaw = entity.rotationYaw;
|
||||
thirdPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView == 1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class ChunkOcclusionData {
|
||||
private static final int DIRECTION_COUNT = ForgeDirection.values().length;
|
||||
private final BitSet visibility;
|
||||
|
||||
public ChunkOcclusionData() {
|
||||
this.visibility = new BitSet(DIRECTION_COUNT * DIRECTION_COUNT);
|
||||
}
|
||||
|
||||
public void addOpenEdgeFaces(Set<ForgeDirection> faces) {
|
||||
for (ForgeDirection dirFrom : faces) {
|
||||
for (ForgeDirection dirTo : faces) {
|
||||
this.setVisibleThrough(dirFrom, dirTo, true);
|
||||
}
|
||||
}
|
||||
|
||||
for (ForgeDirection direction : faces) {
|
||||
this.visibility.set(direction.ordinal() * DIRECTION_COUNT + direction.ordinal());
|
||||
}
|
||||
}
|
||||
public void setVisibleThrough(ForgeDirection from, ForgeDirection to, boolean visible) {
|
||||
this.visibility.set(from.ordinal() + to.ordinal() * DIRECTION_COUNT, visible);
|
||||
this.visibility.set(to.ordinal() + from.ordinal() * DIRECTION_COUNT, visible);
|
||||
}
|
||||
|
||||
public boolean isVisibleThrough(ForgeDirection from, ForgeDirection to) {
|
||||
return this.visibility.get(from.ordinal() + to.ordinal() * DIRECTION_COUNT);
|
||||
}
|
||||
|
||||
public void fill(boolean visible) {
|
||||
this.visibility.set(0, this.visibility.size(), visible);
|
||||
}
|
||||
}
|
||||
-155
@@ -1,155 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayFIFOQueue;
|
||||
import it.unimi.dsi.fastutil.ints.IntPriorityQueue;
|
||||
import me.jellysquid.mods.sodium.common.util.DirectionUtil;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.BitSet;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* WARNING: Minecraft 1.16 code rip!!
|
||||
*/
|
||||
|
||||
public class ChunkOcclusionDataBuilder {
|
||||
private static final int STEP_X = (int)Math.pow(16.0, 0.0);
|
||||
private static final int STEP_Z = (int)Math.pow(16.0, 1.0);
|
||||
private static final int STEP_Y = (int)Math.pow(16.0, 2.0);
|
||||
private static final ForgeDirection[] DIRECTIONS = DirectionUtil.ALL_DIRECTIONS;
|
||||
private final BitSet closed = new BitSet(4096);
|
||||
private static final int[] EDGE_POINTS = new int[1352];
|
||||
|
||||
static {
|
||||
int k = 0;
|
||||
|
||||
for(int l = 0; l < 16; ++l) {
|
||||
for(int m = 0; m < 16; ++m) {
|
||||
for(int n = 0; n < 16; ++n) {
|
||||
if (l == 0 || l == 15 || m == 0 || m == 15 || n == 0 || n == 15) {
|
||||
EDGE_POINTS[k++] = pack(l, m, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private int openCount = 4096;
|
||||
|
||||
public void markClosed(BlockPos pos) {
|
||||
this.closed.set(pack(pos), true);
|
||||
--this.openCount;
|
||||
}
|
||||
|
||||
private static int pack(BlockPos pos) {
|
||||
return pack(pos.getX() & 15, pos.getY() & 15, pos.getZ() & 15);
|
||||
}
|
||||
|
||||
private static int pack(int x, int y, int z) {
|
||||
return x << 0 | y << 8 | z << 4;
|
||||
}
|
||||
|
||||
public ChunkOcclusionData build() {
|
||||
final ChunkOcclusionData lv = new ChunkOcclusionData();
|
||||
if (4096 - this.openCount < 256) {
|
||||
lv.fill(true);
|
||||
} else if (this.openCount == 0) {
|
||||
lv.fill(false);
|
||||
} else {
|
||||
for(int i : EDGE_POINTS) {
|
||||
if (!this.closed.get(i)) {
|
||||
lv.addOpenEdgeFaces(this.getOpenFaces(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lv;
|
||||
}
|
||||
|
||||
private Set<ForgeDirection> getOpenFaces(int pos) {
|
||||
final Set<ForgeDirection> set = EnumSet.noneOf(ForgeDirection.class);
|
||||
final IntPriorityQueue intPriorityQueue = new IntArrayFIFOQueue();
|
||||
intPriorityQueue.enqueue(pos);
|
||||
this.closed.set(pos, true);
|
||||
|
||||
while(!intPriorityQueue.isEmpty()) {
|
||||
final int j = intPriorityQueue.dequeueInt();
|
||||
this.addEdgeFaces(j, set);
|
||||
|
||||
for(ForgeDirection lv : DIRECTIONS) {
|
||||
final int k = this.offset(j, lv);
|
||||
if (k >= 0 && !this.closed.get(k)) {
|
||||
this.closed.set(k, true);
|
||||
intPriorityQueue.enqueue(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
private void addEdgeFaces(int pos, Set<ForgeDirection> openFaces) {
|
||||
final int j = pos >> 0 & 15;
|
||||
if (j == 0) {
|
||||
openFaces.add(ForgeDirection.WEST);
|
||||
} else if (j == 15) {
|
||||
openFaces.add(ForgeDirection.EAST);
|
||||
}
|
||||
|
||||
final int k = pos >> 8 & 15;
|
||||
if (k == 0) {
|
||||
openFaces.add(ForgeDirection.DOWN);
|
||||
} else if (k == 15) {
|
||||
openFaces.add(ForgeDirection.UP);
|
||||
}
|
||||
|
||||
final int l = pos >> 4 & 15;
|
||||
if (l == 0) {
|
||||
openFaces.add(ForgeDirection.NORTH);
|
||||
} else if (l == 15) {
|
||||
openFaces.add(ForgeDirection.SOUTH);
|
||||
}
|
||||
}
|
||||
|
||||
private int offset(int pos, ForgeDirection arg) {
|
||||
return switch (arg) {
|
||||
case DOWN -> {
|
||||
if ((pos >> 8 & 15) == 0) {
|
||||
yield -1;
|
||||
}
|
||||
yield pos - STEP_Y;
|
||||
}
|
||||
case UP -> {
|
||||
if ((pos >> 8 & 15) == 15) {
|
||||
yield -1;
|
||||
}
|
||||
yield pos + STEP_Y;
|
||||
}
|
||||
case NORTH -> {
|
||||
if ((pos >> 4 & 15) == 0) {
|
||||
yield -1;
|
||||
}
|
||||
yield pos - STEP_Z;
|
||||
}
|
||||
case SOUTH -> {
|
||||
if ((pos >> 4 & 15) == 15) {
|
||||
yield -1;
|
||||
}
|
||||
yield pos + STEP_Z;
|
||||
}
|
||||
case WEST -> {
|
||||
if ((pos >> 0 & 15) == 0) {
|
||||
yield -1;
|
||||
}
|
||||
yield pos - STEP_X;
|
||||
}
|
||||
case EAST -> {
|
||||
if ((pos >> 0 & 15) == 15) {
|
||||
yield -1;
|
||||
}
|
||||
yield pos + STEP_X;
|
||||
}
|
||||
default -> -1;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
// See if we can merge/mixin/extend ChunkCoordIntPair?
|
||||
public class ChunkPos {
|
||||
public static long INT_MASK = (1L << Integer.SIZE) - 1;
|
||||
|
||||
public final int x;
|
||||
public final int z;
|
||||
|
||||
public ChunkPos(int x, int z) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public ChunkPos(BlockPos pos) {
|
||||
this.x = pos.getX() >> 4;
|
||||
this.z = pos.getZ() >> 4;
|
||||
}
|
||||
|
||||
public ChunkPos(long pos) {
|
||||
this.x = (int)pos;
|
||||
this.z = (int)(pos >> 32);
|
||||
}
|
||||
|
||||
public static int getPackedX(long pos) {
|
||||
return (int)(pos & INT_MASK);
|
||||
}
|
||||
|
||||
public static int getPackedZ(long pos) {
|
||||
return (int)(pos >>> 32 & INT_MASK);
|
||||
}
|
||||
|
||||
public long toLong() {
|
||||
return toLong(this.x, this.z);
|
||||
}
|
||||
|
||||
public static long toLong(int x, int z) {
|
||||
return (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
final int i = 1664525 * this.x + 1013904223;
|
||||
final int j = 1664525 * (this.z ^ -559038737) + 1013904223;
|
||||
return i ^ j;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object instanceof ChunkPos lv) {
|
||||
return this.x == lv.x && this.z == lv.z;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
|
||||
// See if we can merge/mixin/extend ChunkPosition maybe?
|
||||
public class ChunkSectionPos extends Vector3i {
|
||||
|
||||
public static int getSectionCoord(int coord) {
|
||||
return coord >> 4;
|
||||
}
|
||||
public static int getBlockCoord(int sectionCoord) {
|
||||
return sectionCoord << 4;
|
||||
}
|
||||
|
||||
private ChunkSectionPos(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
}
|
||||
public static ChunkSectionPos from(int x, int y, int z) {
|
||||
return new ChunkSectionPos(x, y, z);
|
||||
}
|
||||
|
||||
public static ChunkSectionPos from(BlockPos pos) {
|
||||
return new ChunkSectionPos(getSectionCoord(pos.getX()), getSectionCoord(pos.getY()), getSectionCoord(pos.getZ()));
|
||||
}
|
||||
|
||||
public static long asLong(int x, int y, int z) {
|
||||
long l = 0L;
|
||||
l |= ((long)x & 4194303L) << 42;
|
||||
l |= ((long)y & 1048575L) << 0;
|
||||
l |= ((long)z & 4194303L) << 20;
|
||||
return l;
|
||||
}
|
||||
|
||||
public static int getLocalCoord(int coord) {
|
||||
return coord & 15;
|
||||
}
|
||||
|
||||
public static short packLocal(BlockPos pos) {
|
||||
int i = getLocalCoord(pos.x);
|
||||
int j = getLocalCoord(pos.y);
|
||||
int k = getLocalCoord(pos.z);
|
||||
return (short)(i << 8 | k << 4 | j << 0);
|
||||
}
|
||||
|
||||
public long asLong() {
|
||||
return asLong(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public int getSectionX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public int getSectionY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public int getSectionZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public int getMinX() {
|
||||
return this.x << 4;
|
||||
}
|
||||
|
||||
public int getMinY() {
|
||||
return this.y << 4;
|
||||
}
|
||||
|
||||
public int getMinZ() {
|
||||
return this.z << 4;
|
||||
}
|
||||
|
||||
public int getMaxX() {
|
||||
return (this.x << 4) + 15;
|
||||
}
|
||||
|
||||
public int getMaxY() {
|
||||
return (this.y << 4) + 15;
|
||||
}
|
||||
|
||||
public int getMaxZ() {
|
||||
return (this.z << 4) + 15;
|
||||
}
|
||||
|
||||
public ChunkPos toChunkPos() {
|
||||
return new ChunkPos(this.getSectionX(), this.getSectionZ());
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
public class CompatMathHelper {
|
||||
public static int smallestEncompassingPowerOfTwo(int value) {
|
||||
int j = value - 1;
|
||||
j |= j >> 1;
|
||||
j |= j >> 2;
|
||||
j |= j >> 4;
|
||||
j |= j >> 8;
|
||||
j |= j >> 16;
|
||||
return j + 1;
|
||||
}
|
||||
public static int roundUpToMultiple(int value, int divisor) {
|
||||
if (divisor == 0) {
|
||||
return 0;
|
||||
} else if (value == 0) {
|
||||
return divisor;
|
||||
} else {
|
||||
if (value < 0) {
|
||||
divisor *= -1;
|
||||
}
|
||||
|
||||
int k = value % divisor;
|
||||
return k == 0 ? value : value + divisor - k;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
public class Constants {
|
||||
public static final float DEGREES_TO_RADIANS = (float)Math.PI / 180.0F;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement.Type;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormatElement.Usage;
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.ItemVBOQuadWriter;
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.PositionColorTextureQuadWriter;
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.PositionQuadWriter;
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.PositionTextureColorQuadWriter;
|
||||
import com.gtnewhorizons.angelica.compat.nd.writers.PositionTextureQuadWriter;
|
||||
|
||||
public class DefaultVertexFormat {
|
||||
|
||||
public static final VertexFormatElement POSITION_ELEMENT = new VertexFormatElement(0, Type.FLOAT, Usage.POSITION, 3);
|
||||
public static final VertexFormatElement COLOR_ELEMENT = new VertexFormatElement(0, Type.UBYTE, Usage.COLOR, 4);
|
||||
public static final VertexFormatElement TEXTURE_ELEMENT = new VertexFormatElement(0, Type.FLOAT, Usage.UV, 2);
|
||||
public static final VertexFormatElement LIGHT_ELEMENT = new VertexFormatElement(1, Type.SHORT, Usage.UV, 2);
|
||||
// TODO: The overlay element index is wrong, need to find a 1.7.10 equivalent
|
||||
public static final VertexFormatElement OVERLAY_ELEMENT = new VertexFormatElement(1, Type.SHORT, Usage.UV, 2);
|
||||
public static final VertexFormatElement NORMAL_ELEMENT = new VertexFormatElement(0, Type.BYTE, Usage.NORMAL, 3);
|
||||
public static final VertexFormatElement PADDING_ELEMENT = new VertexFormatElement(0, Type.BYTE, Usage.PADDING, 1);
|
||||
public static final VertexFormat POSITION_TEXTURE_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build(), new ItemVBOQuadWriter());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(OVERLAY_ELEMENT).add(LIGHT_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR_LIGHT = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(COLOR_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).build(), new PositionQuadWriter());
|
||||
public static final VertexFormat POSITION_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_COLOR_LIGHT = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).build(), new PositionTextureQuadWriter());
|
||||
public static final VertexFormat POSITION_COLOR_TEXTURE = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).build(), new PositionColorTextureQuadWriter());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(COLOR_ELEMENT).build(), new PositionTextureColorQuadWriter());
|
||||
public static final VertexFormat POSITION_COLOR_TEX_LIGHTMAP = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(COLOR_ELEMENT).add(TEXTURE_ELEMENT).add(LIGHT_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_LIGHT_COLOR = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(LIGHT_ELEMENT).add(COLOR_ELEMENT).build());
|
||||
public static final VertexFormat POSITION_TEXTURE_COLOR_NORMAL = new VertexFormat(new ImmutableList.Builder<VertexFormatElement>().add(POSITION_ELEMENT).add(TEXTURE_ELEMENT).add(COLOR_ELEMENT).add(NORMAL_ELEMENT).add(PADDING_ELEMENT).build());
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
public interface Drawable {
|
||||
default void render(int mouseX, int mouseY, float delta) {}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
public interface Element {
|
||||
default boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean mouseDragged(double mouseX, double mouseY, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean mouseScrolled(double mouseX, double mouseY, double amount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean keyTyped(char typedChar, int keyCode) { return false; }
|
||||
|
||||
default boolean isMouseOver(double mouseX, double mouseY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean changeFocus(boolean lookForwards) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
|
||||
public enum InteractionHand {
|
||||
MAIN_HAND,
|
||||
OFF_HAND;
|
||||
|
||||
InteractionHand() {
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
// TBD
|
||||
public class NativeImage extends BufferedImage {
|
||||
@Getter
|
||||
private final Format format;
|
||||
@Getter
|
||||
private final int width;
|
||||
@Getter
|
||||
private final int height;
|
||||
@Getter
|
||||
private final int size;
|
||||
|
||||
public NativeImage(int width, int height, boolean useStb) {
|
||||
this(NativeImage.Format.RGBA, width, height, useStb);
|
||||
}
|
||||
|
||||
public NativeImage(Format format, int width, int height, boolean useStb) {
|
||||
super(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
this.format = format;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.size = width * height * format.components;
|
||||
}
|
||||
public NativeImage(Format format, int width, int height, BufferedImage image) {
|
||||
super(image.getColorModel(), image.getRaster(), image.isAlphaPremultiplied(), null);
|
||||
this.format = format;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.size = width * height * format.components;
|
||||
}
|
||||
|
||||
public static NativeImage read(ByteBuffer buf) throws IOException {
|
||||
return read(new ByteBufferBackedInputStream(buf));
|
||||
}
|
||||
public static NativeImage read(InputStream inputStream) throws IOException {
|
||||
BufferedImage image = ImageIO.read(inputStream);
|
||||
return new NativeImage(Format.RGBA, image.getWidth(), image.getHeight(), image);
|
||||
}
|
||||
|
||||
public void downloadTexture(int level, boolean bl) {
|
||||
// this.checkAllocated();
|
||||
GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, format.components);
|
||||
// GlStateManager._getTexImage(3553, level, format.glFormat, GL11.GL_UNSIGNED_BYTE, this.pixels);
|
||||
|
||||
// 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);
|
||||
IntBuffer buffer = BufferUtils.createIntBuffer(size);
|
||||
int[] data = new int[size];
|
||||
|
||||
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, format.glFormat, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer);
|
||||
buffer.get(data);
|
||||
setRGB(0, 0, width, height, data, 0, width);
|
||||
}
|
||||
public void writeToFile(File file) throws IOException{
|
||||
try {
|
||||
ImageIO.write(this, "png", file);
|
||||
} catch(IOException ioexception) {
|
||||
Iris.logger.info("[TextureDump] Unable to write: ", ioexception);
|
||||
}
|
||||
}
|
||||
public static int combine(int i, int j, int k, int l) {
|
||||
return (i & 255) << 24 | (j & 255) << 16 | (k & 255) << 8 | (l & 255);
|
||||
}
|
||||
|
||||
public static int getA(int i) {
|
||||
return i >> 24 & 255;
|
||||
}
|
||||
|
||||
public static int getR(int i) {
|
||||
return i >> 0 & 255;
|
||||
}
|
||||
|
||||
public static int getG(int i) {
|
||||
return i >> 8 & 255;
|
||||
}
|
||||
|
||||
public static int getB(int i) {
|
||||
return i >> 16 & 255;
|
||||
}
|
||||
|
||||
public int getPixelRGBA(int x, int y) {
|
||||
return getRGB(x, y);
|
||||
}
|
||||
|
||||
public void setPixelRGBA(int x, int y, int rgb) {
|
||||
setRGB(x, y, rgb);
|
||||
}
|
||||
|
||||
|
||||
public enum Format {
|
||||
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, int imageType) {
|
||||
this.components = components;
|
||||
this.glFormat = glFormat;
|
||||
this.imageType = imageType;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface ParentElement extends Element {
|
||||
List<? extends Element> children();
|
||||
|
||||
default Optional<Element> hoveredElement(double mouseX, double mouseY) {
|
||||
for(Element element : this.children()) {
|
||||
if (element.isMouseOver(mouseX, mouseY)) {
|
||||
return Optional.of(element);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
default boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
for(Element element : this.children()) {
|
||||
if (element.mouseClicked(mouseX, mouseY, button)) {
|
||||
this.setFocused(element);
|
||||
if (button == 0) {
|
||||
this.setDragging(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
default boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||
this.setDragging(false);
|
||||
return this.hoveredElement(mouseX, mouseY).filter((element) -> element.mouseReleased(mouseX, mouseY, button)).isPresent();
|
||||
}
|
||||
|
||||
default boolean mouseDragged(double mouseX, double mouseY, int button) {
|
||||
return this.getFocused() != null && this.isDragging() && button == 0 && this.getFocused().mouseDragged(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
boolean isDragging();
|
||||
|
||||
void setDragging(boolean dragging);
|
||||
|
||||
default boolean mouseScrolled(double mouseX, double mouseY, double amount) {
|
||||
return this.hoveredElement(mouseX, mouseY).filter((element) -> element.mouseScrolled(mouseX, mouseY, amount)).isPresent();
|
||||
}
|
||||
|
||||
default boolean keyTyped(char typedChar, int keyCode) {
|
||||
return this.getFocused() != null && this.getFocused().keyTyped(typedChar, keyCode);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
Element getFocused();
|
||||
|
||||
void setFocused(@Nullable Element focused);
|
||||
|
||||
default boolean changeFocus(boolean lookForwards) {
|
||||
final Element element = this.getFocused();
|
||||
if (element != null && element.changeFocus(lookForwards)) {
|
||||
return true;
|
||||
} else {
|
||||
final List<? extends Element> list = this.children();
|
||||
final int i = list.indexOf(element);
|
||||
final int j;
|
||||
if (element != null && i >= 0) {
|
||||
j = i + (lookForwards ? 1 : 0);
|
||||
} else if (lookForwards) {
|
||||
j = 0;
|
||||
} else {
|
||||
j = list.size();
|
||||
}
|
||||
|
||||
|
||||
final ListIterator<? extends Element> listIterator = list.listIterator(j);
|
||||
final BooleanSupplier booleanSupplier = lookForwards ? listIterator::hasNext : listIterator::hasPrevious;
|
||||
final Supplier<? extends Element> supplier = lookForwards ? listIterator::next : listIterator::previous;
|
||||
|
||||
Element element2;
|
||||
do {
|
||||
if (!booleanSupplier.getAsBoolean()) {
|
||||
this.setFocused(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
element2 = supplier.get();
|
||||
} while(!element2.changeFocus(lookForwards));
|
||||
|
||||
this.setFocused(element2);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
|
||||
public class VertexBuffer implements AutoCloseable {
|
||||
private int id;
|
||||
private int vertexCount;
|
||||
private VertexFormat format;
|
||||
private int drawMode;
|
||||
|
||||
public VertexBuffer() {
|
||||
this.id = GL15.glGenBuffers();
|
||||
}
|
||||
|
||||
public VertexBuffer(VertexFormat format, int drawMode) {
|
||||
this();
|
||||
this.format = format;
|
||||
this.drawMode = drawMode;
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.id);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
public void upload(ByteBuffer buffer, int vertexCount) {
|
||||
if (this.id == -1) return;
|
||||
this.vertexCount = vertexCount;
|
||||
this.bind();
|
||||
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
|
||||
this.unbind();
|
||||
}
|
||||
|
||||
public VertexBuffer upload(ByteBuffer buffer) {
|
||||
if(format == null) throw new IllegalStateException("No format specified for VBO upload");
|
||||
upload(buffer, buffer.remaining() / format.getVertexSize());
|
||||
return this;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (this.id >= 0) {
|
||||
GL15.glDeleteBuffers(this.id);
|
||||
this.id = -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(FloatBuffer floatBuffer) {
|
||||
GL11.glPushMatrix();
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMultMatrix(floatBuffer);
|
||||
draw();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
public void draw() {
|
||||
GL11.glDrawArrays(drawMode, 0, this.vertexCount);
|
||||
}
|
||||
|
||||
public void setupState() {
|
||||
if(format == null) throw new IllegalStateException("No format specified for VBO setup");
|
||||
bind();
|
||||
format.setupBufferState(0L);
|
||||
}
|
||||
|
||||
public void cleanupState() {
|
||||
format.clearBufferState();
|
||||
unbind();
|
||||
}
|
||||
public void render() {
|
||||
setupState();
|
||||
draw();
|
||||
cleanupState();
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.vertices.ImmediateState;
|
||||
import net.coderbot.iris.vertices.IrisVertexFormats;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
public class VertexFormat {
|
||||
@Getter
|
||||
protected final ImmutableList<VertexFormatElement> elements;
|
||||
protected final IntList offsets = new IntArrayList();
|
||||
@Getter
|
||||
protected final int vertexSize;
|
||||
|
||||
protected IWriteQuads quadWriter;
|
||||
|
||||
public VertexFormat(ImmutableList<VertexFormatElement> elements) {
|
||||
this(elements, null);
|
||||
}
|
||||
|
||||
public VertexFormat(ImmutableList<VertexFormatElement> elements, IWriteQuads quadWriter) {
|
||||
this.elements = elements;
|
||||
int i = 0;
|
||||
for (VertexFormatElement element : elements) {
|
||||
offsets.add(i);
|
||||
i += element.getByteSize();
|
||||
}
|
||||
vertexSize = i;
|
||||
this.quadWriter = quadWriter;
|
||||
}
|
||||
|
||||
public void setupBufferState(long l) {
|
||||
if (BlockRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat() && ImmediateState.renderWithExtendedVertexFormat) {
|
||||
if (this == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL || this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
IrisVertexFormats.TERRAIN.setupBufferState(l);
|
||||
return;
|
||||
} else if (this == DefaultVertexFormat.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL) {
|
||||
IrisVertexFormats.ENTITY.setupBufferState(l);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final int i = this.getVertexSize();
|
||||
final List<VertexFormatElement> list = this.getElements();
|
||||
final int listSize = list.size();
|
||||
|
||||
for(int j = 0; j < listSize; ++j) {
|
||||
list.get(j).setupBufferState(l + this.offsets.getInt(j), i);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearBufferState() {
|
||||
if (BlockRenderingSettings.INSTANCE.shouldUseExtendedVertexFormat() && ImmediateState.renderWithExtendedVertexFormat) {
|
||||
if (this == DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL || this == DefaultVertexFormat.POSITION_COLOR_TEX_LIGHTMAP) {
|
||||
IrisVertexFormats.TERRAIN.clearBufferState();
|
||||
return;
|
||||
} else if ( this == DefaultVertexFormat.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL) {
|
||||
IrisVertexFormats.ENTITY.clearBufferState();
|
||||
return;
|
||||
}
|
||||
}
|
||||
final List<VertexFormatElement> list = this.getElements();
|
||||
final int listSize = list.size();
|
||||
|
||||
for(int i = 0 ; i < listSize; ++i) {
|
||||
list.get(i).clearBufferState();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canWriteQuads() {
|
||||
return quadWriter != null;
|
||||
}
|
||||
|
||||
public void writeQuad(Quad quad, ByteBuffer byteBuffer) {
|
||||
if(quadWriter == null) {
|
||||
throw new IllegalStateException("No quad writer set");
|
||||
}
|
||||
quadWriter.writeQuad(quad, byteBuffer);
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.mojang;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import java.util.function.IntConsumer;
|
||||
|
||||
|
||||
@Getter
|
||||
public class VertexFormatElement {
|
||||
protected final Type type;
|
||||
protected final Usage usage;
|
||||
protected final int index;
|
||||
protected final int count;
|
||||
protected final int byteSize;
|
||||
|
||||
public VertexFormatElement(int index, Type type, Usage usage, int count) {
|
||||
this.index = index;
|
||||
this.type = type;
|
||||
this.usage = usage;
|
||||
this.count = count;
|
||||
this.byteSize = type.getSize() * count;
|
||||
}
|
||||
|
||||
public void setupBufferState(long l, int i) {
|
||||
this.usage.setupBufferState(this.count, this.type.getGlType(), i, l, this.index);
|
||||
}
|
||||
|
||||
public void clearBufferState() {
|
||||
this.usage.clearBufferState(this.index);
|
||||
}
|
||||
|
||||
public enum Usage {
|
||||
POSITION("Position", (i, j, k, l, m) -> {
|
||||
GL11.glVertexPointer(i, j, k, l);
|
||||
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
|
||||
}, (i) -> GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY)),
|
||||
NORMAL("Normal", (i, j, k, l, m) -> {
|
||||
GL11.glNormalPointer(j, k, l);
|
||||
GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
|
||||
}, (i) -> GL11.glDisableClientState(GL11.GL_NORMAL_ARRAY)),
|
||||
COLOR("Vertex Color", (i, j, k, l, m) -> {
|
||||
GL11.glColorPointer(i, j, k, l);
|
||||
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
|
||||
}, i -> GL11.glDisableClientState(GL11.GL_COLOR_ARRAY)),
|
||||
UV("UV", (i, j, k, l, m) -> {
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + m);
|
||||
GL11.glTexCoordPointer(i, j, k, l);
|
||||
GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
|
||||
}, i -> {
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + i);
|
||||
GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
|
||||
GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
|
||||
}),
|
||||
PADDING("Padding", (i, j, k, l, m) -> {}, i-> {}),
|
||||
GENERIC("Generic", (i, j, k, l, m) -> {
|
||||
GL20.glEnableVertexAttribArray(m);
|
||||
GL20.glVertexAttribPointer(m, i, j, false, k, l);
|
||||
}, GL20::glDisableVertexAttribArray);
|
||||
|
||||
@Getter private final String name;
|
||||
private final SetupState setupState;
|
||||
private final IntConsumer clearState;
|
||||
|
||||
Usage(String name, SetupState setupState, IntConsumer clearState) {
|
||||
this.name = name;
|
||||
this.setupState = setupState;
|
||||
this.clearState = clearState;
|
||||
}
|
||||
|
||||
private void setupBufferState(int i, int j, int k, long l, int m) {
|
||||
this.setupState.setupBufferState(i, j, k, l, m);
|
||||
}
|
||||
|
||||
public void clearBufferState(int i) {
|
||||
this.clearState.accept(i);
|
||||
}
|
||||
|
||||
interface SetupState {
|
||||
void setupBufferState(int i, int j, int k, long l, int m);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public enum Type {
|
||||
FLOAT(4, "Float", GL11.GL_FLOAT),
|
||||
UBYTE(1, "Unsigned Byte", GL11.GL_UNSIGNED_BYTE),
|
||||
BYTE(1, "Byte", GL11.GL_BYTE),
|
||||
USHORT(2, "Unsigned Short", GL11.GL_UNSIGNED_SHORT),
|
||||
SHORT(2, "Short", GL11.GL_SHORT),
|
||||
UINT(4, "Unsigned Int", GL11.GL_UNSIGNED_INT),
|
||||
INT(4, "Int", GL11.GL_INT);
|
||||
|
||||
private final int size;
|
||||
private final String name;
|
||||
private final int glType;
|
||||
|
||||
Type(int size, String name, int glType) {
|
||||
this.size = size;
|
||||
this.name = name;
|
||||
this.glType = glType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
public class BufferWriter {
|
||||
// Adapted from Neodymium
|
||||
|
||||
private final ByteBuffer buf;
|
||||
|
||||
private final FloatBuffer floatBuffer;
|
||||
private final ShortBuffer shortBuffer;
|
||||
private final IntBuffer intBuffer;
|
||||
|
||||
public BufferWriter(ByteBuffer buf) {
|
||||
this.buf = buf;
|
||||
this.floatBuffer = buf.asFloatBuffer();
|
||||
this.shortBuffer = buf.asShortBuffer();
|
||||
this.intBuffer = buf.asIntBuffer();
|
||||
}
|
||||
|
||||
private void incrementPosition(int add) {
|
||||
buf.position(buf.position() + add);
|
||||
floatBuffer.position(buf.position() / 4);
|
||||
shortBuffer.position(buf.position() / 2);
|
||||
intBuffer.position(buf.position() / 4);
|
||||
}
|
||||
|
||||
public void writeFloat(float x) {
|
||||
try {
|
||||
floatBuffer.put(x);
|
||||
|
||||
incrementPosition(4);
|
||||
} catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void writeInt(int x) {
|
||||
intBuffer.put(x);
|
||||
|
||||
incrementPosition(4);
|
||||
}
|
||||
|
||||
public void writeByte(byte x) {
|
||||
buf.put(x); // this increments the buffer position by 1
|
||||
|
||||
incrementPosition(0);
|
||||
}
|
||||
|
||||
public int position() {
|
||||
return buf.position();
|
||||
}
|
||||
|
||||
public void writeShort(short s) {
|
||||
shortBuffer.put(s);
|
||||
|
||||
incrementPosition(2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public interface IWriteQuads {
|
||||
void writeQuad(Quad quad, ByteBuffer buf);
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.model.quad.ModelQuadView;
|
||||
import me.jellysquid.mods.sodium.client.model.quad.properties.ModelQuadFacing;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.BlockRenderer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class Quad implements ModelQuadView {
|
||||
// Adapted from Neodymium
|
||||
|
||||
private final static int DEFAULT_BRIGHTNESS = 15 << 20 | 15 << 4;
|
||||
private final static int DEFAULT_COLOR = 0xFFFFFFFF;
|
||||
|
||||
public float[] xs = new float[4];
|
||||
public float[] ys = new float[4];
|
||||
public float[] zs = new float[4];
|
||||
public float[] us = new float[4];
|
||||
public float[] vs = new float[4];
|
||||
public int[] cs = new int[4];
|
||||
public int[] ns = new int[4];
|
||||
public int[] bs = new int[4];
|
||||
|
||||
public boolean deleted;
|
||||
|
||||
public ModelQuadFacing normal;
|
||||
|
||||
private final Vector3f vectorA = new Vector3f(), vectorB = new Vector3f(), vectorC = new Vector3f();
|
||||
|
||||
private boolean hasColor;
|
||||
private boolean hasShade;
|
||||
private boolean hasNormals;
|
||||
|
||||
public boolean hasColor() {
|
||||
return this.hasColor;
|
||||
}
|
||||
|
||||
public int[] getColors() {
|
||||
return this.cs;
|
||||
}
|
||||
|
||||
public boolean hasShade() {
|
||||
return this.hasShade;
|
||||
}
|
||||
|
||||
public boolean hasNormals() {
|
||||
return this.hasNormals;
|
||||
}
|
||||
|
||||
public ForgeDirection getFace() {
|
||||
// TODO: Sodium/Quad Facing
|
||||
return ForgeDirection.UP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getX(int idx) {
|
||||
return xs[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getY(int idx) {
|
||||
return ys[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZ(int idx) {
|
||||
return zs[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(int idx) {
|
||||
return cs[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexU(int idx) {
|
||||
return us[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexV(int idx) {
|
||||
return vs[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLight(int idx) {
|
||||
return bs[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNormal(int idx) {
|
||||
return ns[idx];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorIndex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite rubidium$getSprite() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void read(int[] rawBuffer, int offset, float offsetX, float offsetY, float offsetZ, int drawMode, BlockRenderer.Flags flags) {
|
||||
final int vertices = drawMode == GL11.GL_TRIANGLES ? 3 : 4;
|
||||
for(int vi = 0; vi < vertices; vi++) {
|
||||
int i = offset + vi * 8;
|
||||
|
||||
xs[vi] = Float.intBitsToFloat(rawBuffer[i + 0]) + offsetX;
|
||||
ys[vi] = Float.intBitsToFloat(rawBuffer[i + 1]) + offsetY;
|
||||
zs[vi] = Float.intBitsToFloat(rawBuffer[i + 2]) + offsetZ;
|
||||
|
||||
us[vi] = Float.intBitsToFloat(rawBuffer[i + 3]);
|
||||
vs[vi] = Float.intBitsToFloat(rawBuffer[i + 4]);
|
||||
|
||||
cs[vi] = flags.hasColor ? rawBuffer[i + 5] : DEFAULT_COLOR;
|
||||
ns[vi] = flags.hasNormals ? rawBuffer[i + 6] : 0;
|
||||
bs[vi] = flags.hasBrightness ? rawBuffer[i + 7] : DEFAULT_BRIGHTNESS;
|
||||
|
||||
this.hasColor = flags.hasColor;
|
||||
this.hasShade = flags.hasBrightness;
|
||||
this.hasNormals = flags.hasNormals;
|
||||
|
||||
|
||||
i += 8;
|
||||
}
|
||||
|
||||
if(vertices == 3) {
|
||||
// Quadrangulate!
|
||||
xs[3] = xs[2];
|
||||
ys[3] = ys[2];
|
||||
zs[3] = zs[2];
|
||||
|
||||
us[3] = us[2];
|
||||
vs[3] = vs[2];
|
||||
|
||||
bs[3] = bs[2];
|
||||
cs[3] = cs[2];
|
||||
ns[3] = ns[2];
|
||||
}
|
||||
}
|
||||
|
||||
public void setState(int[] rawBuffer, int offset, BlockRenderer.Flags flags, int drawMode, float offsetX, float offsetY, float offsetZ) {
|
||||
deleted = false;
|
||||
|
||||
read(rawBuffer, offset, offsetX, offsetY, offsetZ, drawMode, flags);
|
||||
|
||||
if(xs[0] == xs[1] && xs[1] == xs[2] && xs[2] == xs[3] && ys[0] == ys[1] && ys[1] == ys[2] && ys[2] == ys[3]) {
|
||||
// ignore empty quads (e.g. alpha pass of EnderIO item conduits)
|
||||
deleted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
vectorA.set(xs[1] - xs[0], ys[1] - ys[0], zs[1] - zs[0]);
|
||||
vectorB.set(xs[2] - xs[1], ys[2] - ys[1], zs[2] - zs[1]);
|
||||
vectorA.cross(vectorB, vectorC);
|
||||
|
||||
normal = ModelQuadFacing.fromVector(vectorC);
|
||||
}
|
||||
|
||||
public static boolean isValid(Quad q) {
|
||||
return q != null && !q.deleted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format(Locale.ENGLISH, "%s[(%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f), (%.1f, %.1f, %.1f)]", deleted ? "XXX " : "", xs[0], ys[0], zs[0], xs[1], ys[1], zs[1], xs[2], ys[2], zs[2], xs[3], ys[3], zs[3]);
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class ItemVBOQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public ItemVBOQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(Quad quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(Quad quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(Quad quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
|
||||
// Normals + Padding
|
||||
buf.putInt(quad.getNormal(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionColorTextureQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionColorTextureQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(Quad quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(Quad quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(Quad quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Color
|
||||
buf.putInt(quad.getColor(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(Quad quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(Quad quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(Quad quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionTextureColorQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionTextureColorQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(Quad quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(Quad quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(Quad quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
|
||||
// Color
|
||||
buf.putInt(quad.getColor(idx));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.nd.writers;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.nd.IWriteQuads;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
public class PositionTextureQuadWriter implements IWriteQuads {
|
||||
private boolean direct;
|
||||
|
||||
public PositionTextureQuadWriter() {
|
||||
init(false);
|
||||
}
|
||||
|
||||
public void init(boolean direct) {
|
||||
// This would need to be re-initialized if the direct vs indirect changes
|
||||
this.direct = direct;
|
||||
}
|
||||
@Override
|
||||
public void writeQuad(Quad quad, ByteBuffer buf) {
|
||||
if(direct) {
|
||||
writeQuadDirect(quad, buf);
|
||||
} else {
|
||||
writeQuadIndirect(quad, buf);
|
||||
}
|
||||
}
|
||||
|
||||
protected void writeQuadDirect(Quad quad, ByteBuffer buf) {
|
||||
throw new UnsupportedOperationException("Direct mode not supported yet");
|
||||
}
|
||||
|
||||
protected void writeQuadIndirect(Quad quad, ByteBuffer buf) {
|
||||
for(int idx = 0; idx < 4; ++idx) {
|
||||
// Position
|
||||
buf.putFloat(quad.getX(idx));
|
||||
buf.putFloat(quad.getY(idx));
|
||||
buf.putFloat(quad.getZ(idx));
|
||||
|
||||
// Texture
|
||||
buf.putFloat(quad.getTexU(idx));
|
||||
buf.putFloat(quad.getTexV(idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import lombok.Getter;
|
||||
|
||||
@Deprecated
|
||||
public class DrawState {
|
||||
@Getter
|
||||
private final VertexFormat format;
|
||||
@Getter
|
||||
private final int vertexCount;
|
||||
@Getter
|
||||
private final int mode;
|
||||
|
||||
public DrawState(VertexFormat format, int vertexCount, int mode) {
|
||||
this.format = format;
|
||||
this.vertexCount = vertexCount;
|
||||
this.mode = mode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.util.Deque;
|
||||
|
||||
|
||||
public class MatrixStack {
|
||||
private final Deque<Entry> matrixStack;
|
||||
|
||||
public MatrixStack() {
|
||||
this.matrixStack = Queues.newArrayDeque();
|
||||
matrixStack.add(new Entry(new Matrix4f().identity(), new Matrix3f().identity()));
|
||||
}
|
||||
|
||||
public MatrixStack(Matrix4f initial) {
|
||||
this.matrixStack = Queues.newArrayDeque();
|
||||
Matrix3f normal = new Matrix3f();
|
||||
matrixStack.add(new Entry(initial, initial.normal(normal)));
|
||||
}
|
||||
|
||||
public Entry peek() {
|
||||
return (Entry)this.matrixStack.getLast();
|
||||
}
|
||||
|
||||
public void push() {
|
||||
final Entry lv = (Entry)this.matrixStack.getLast();
|
||||
this.matrixStack.addLast(new Entry(new Matrix4f(lv.model), new Matrix3f(lv.normal)));
|
||||
}
|
||||
|
||||
public void pop() {
|
||||
this.matrixStack.removeLast();
|
||||
}
|
||||
public boolean clear() {
|
||||
return this.matrixStack.size() == 1;
|
||||
}
|
||||
|
||||
public void translate(double d, double e, double f) {
|
||||
final Entry lv = (Entry)this.matrixStack.getLast();
|
||||
lv.model.translate((float)d, (float)e, (float)f);
|
||||
}
|
||||
public void rotateX(float f) {
|
||||
final Entry lv = (Entry)this.matrixStack.getLast();
|
||||
lv.model.rotateX(f);
|
||||
lv.normal.rotateX(f);
|
||||
}
|
||||
|
||||
public void rotateY(float f) {
|
||||
final Entry lv = (Entry)this.matrixStack.getLast();
|
||||
lv.model.rotateY(f);
|
||||
lv.normal.rotateY(f);
|
||||
}
|
||||
|
||||
public void rotateZ(float f) {
|
||||
final Entry lv = (Entry)this.matrixStack.getLast();
|
||||
lv.model.rotateZ(f);
|
||||
lv.normal.rotateZ(f);
|
||||
}
|
||||
|
||||
|
||||
public void scale(float f, float g, float h) {
|
||||
final Entry lv = (Entry)this.matrixStack.getLast();
|
||||
lv.model.scale(f, g, h);
|
||||
|
||||
if (f == g && g == h) {
|
||||
if (f > 0.0F) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv.normal.scale(-1.0F);
|
||||
}
|
||||
float i = 1.0F / f;
|
||||
float j = 1.0F / g;
|
||||
float k = 1.0F / h;
|
||||
float l = invSqrt(i * j * k);
|
||||
lv.normal.scale(l * i, l * j, l * k);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static float invSqrt(float x) {
|
||||
float xhalf = 0.5f * x;
|
||||
int i = Float.floatToIntBits(x);
|
||||
i = 0x5f3759df - (i >> 1);
|
||||
x = Float.intBitsToFloat(i);
|
||||
x *= (1.5f - xhalf * x * x);
|
||||
return x;
|
||||
}
|
||||
|
||||
public static final class Entry {
|
||||
private final Matrix4f model;
|
||||
private final Matrix3f normal;
|
||||
|
||||
private Entry(Matrix4f model, Matrix3f normal) {
|
||||
this.model = model;
|
||||
this.normal = normal;
|
||||
}
|
||||
|
||||
public Matrix4f getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public Matrix3f getNormal() {
|
||||
return normal;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
@Deprecated
|
||||
public class OverlayTexture {
|
||||
|
||||
// This is definitely wrong
|
||||
public static final int NO_OVERLAY = 0;
|
||||
}
|
||||
@@ -1,313 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.DefaultVertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import it.unimi.dsi.fastutil.Hash;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public abstract class RenderLayer extends RenderPhase { // Aka: RenderType (Iris)
|
||||
private static final RenderLayer SOLID = of("solid", DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, 7, 2097152, true, false, RenderLayer.MultiPhaseParameters.builder().shadeModel(SMOOTH_SHADE_MODEL).lightmap(ENABLE_LIGHTMAP).texture(MIPMAP_BLOCK_ATLAS_TEXTURE).build(true));
|
||||
private static final RenderLayer CUTOUT = of("cutout", DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, 7, 131072, true, false, RenderLayer.MultiPhaseParameters.builder().shadeModel(SMOOTH_SHADE_MODEL).lightmap(ENABLE_LIGHTMAP).texture(BLOCK_ATLAS_TEXTURE).alpha(HALF_ALPHA).build(true));
|
||||
private static final RenderLayer TRANSLUCENT = of("translucent", DefaultVertexFormat.POSITION_COLOR_TEXTURE_LIGHT_NORMAL, 7, 262144, true, true, createTranslucentPhaseData());
|
||||
|
||||
@Getter
|
||||
private final VertexFormat vertexFormat;
|
||||
@Getter
|
||||
private final int drawMode;
|
||||
@Getter
|
||||
private final int expectedBufferSize;
|
||||
|
||||
public RenderLayer(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize, Runnable startAction, Runnable endAction) {
|
||||
super(name, startAction, endAction);
|
||||
this.vertexFormat = vertexFormat;
|
||||
this.drawMode = drawMode;
|
||||
this.expectedBufferSize = expectedBufferSize;
|
||||
}
|
||||
|
||||
|
||||
public static MultiPhase of(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize, MultiPhaseParameters phaseData) {
|
||||
return of(name, vertexFormat, drawMode, expectedBufferSize, false, false, phaseData);
|
||||
}
|
||||
|
||||
public static MultiPhase of(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent, MultiPhaseParameters phases) {
|
||||
return RenderLayer.MultiPhase.of(name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent, phases);
|
||||
}
|
||||
|
||||
|
||||
public static RenderLayer solid() {
|
||||
return SOLID;
|
||||
}
|
||||
|
||||
public static RenderLayer cutout() {
|
||||
return CUTOUT;
|
||||
}
|
||||
|
||||
private static MultiPhaseParameters createTranslucentPhaseData() {
|
||||
return RenderLayer.MultiPhaseParameters.builder().shadeModel(SMOOTH_SHADE_MODEL).lightmap(ENABLE_LIGHTMAP).texture(MIPMAP_BLOCK_ATLAS_TEXTURE).transparency(TRANSLUCENT_TRANSPARENCY).target(TRANSLUCENT_TARGET).build(true);
|
||||
}
|
||||
|
||||
public static RenderLayer translucent() {
|
||||
return TRANSLUCENT;
|
||||
}
|
||||
|
||||
public static RenderLayer getOutline(ResourceLocation texture, RenderPhase.Cull cull) {
|
||||
return of("outline", DefaultVertexFormat.POSITION_COLOR_TEXTURE, 7, 256, RenderLayer.MultiPhaseParameters.builder().texture(new RenderPhase.Texture(texture, false, false)).cull(cull).depthTest(ALWAYS_DEPTH_TEST).alpha(ONE_TENTH_ALPHA).texturing(OUTLINE_TEXTURING).fog(NO_FOG).target(OUTLINE_TARGET).build(RenderLayer.OutlineMode.IS_OUTLINE));
|
||||
}
|
||||
|
||||
public int mode() {
|
||||
return this.drawMode;
|
||||
}
|
||||
|
||||
static final class MultiPhase extends RenderLayer {
|
||||
private static final ObjectOpenCustomHashSet<MultiPhase> CACHE;
|
||||
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, () -> {
|
||||
phases.phases.forEach(RenderPhase::startDrawing);
|
||||
}, () -> {
|
||||
phases.phases.forEach(RenderPhase::endDrawing);
|
||||
});
|
||||
this.phases = phases;
|
||||
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});
|
||||
}
|
||||
|
||||
public static MultiPhase of(String name, VertexFormat vertexFormat, int drawMode, int expectedBufferSize, boolean hasCrumbling, boolean translucent,
|
||||
MultiPhaseParameters phases) {
|
||||
return (MultiPhase)CACHE.addOrGet(new MultiPhase(name, vertexFormat, drawMode, expectedBufferSize, hasCrumbling, translucent, phases));
|
||||
}
|
||||
|
||||
public Optional<RenderLayer> getAffectedOutline() {
|
||||
return this.affectedOutline;
|
||||
}
|
||||
|
||||
public boolean equals(@Nullable Object object) {
|
||||
return this == object;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.hash;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "RenderType[" + this.phases + ']';
|
||||
}
|
||||
|
||||
static {
|
||||
CACHE = new ObjectOpenCustomHashSet(RenderLayer.MultiPhase.HashStrategy.INSTANCE);
|
||||
}
|
||||
|
||||
static enum HashStrategy implements Hash.Strategy<MultiPhase> {
|
||||
INSTANCE;
|
||||
|
||||
private HashStrategy() {
|
||||
}
|
||||
|
||||
public int hashCode(@Nullable MultiPhase arg) {
|
||||
return arg == null ? 0 : arg.hash;
|
||||
}
|
||||
|
||||
public boolean equals(@Nullable MultiPhase arg, @Nullable MultiPhase arg2) {
|
||||
if (arg == arg2) {
|
||||
return true;
|
||||
} else {
|
||||
return arg != null && arg2 != null ? Objects.equals(arg.phases, arg2.phases) : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final class MultiPhaseParameters {
|
||||
private final RenderPhase.Texture texture;
|
||||
private final RenderPhase.Transparency transparency;
|
||||
private final RenderPhase.DiffuseLighting diffuseLighting;
|
||||
private final RenderPhase.ShadeModel shadeModel;
|
||||
private final RenderPhase.Alpha alpha;
|
||||
private final RenderPhase.DepthTest depthTest;
|
||||
private final RenderPhase.Cull cull;
|
||||
private final RenderPhase.Lightmap lightmap;
|
||||
private final RenderPhase.Overlay overlay;
|
||||
private final RenderPhase.Fog fog;
|
||||
private final RenderPhase.Layering layering;
|
||||
private final RenderPhase.Target target;
|
||||
private final RenderPhase.Texturing texturing;
|
||||
private final RenderPhase.WriteMaskState writeMaskState;
|
||||
private final RenderPhase.LineWidth lineWidth;
|
||||
private final OutlineMode outlineMode;
|
||||
private final ImmutableList<RenderPhase> phases;
|
||||
|
||||
private MultiPhaseParameters(RenderPhase.Texture texture, RenderPhase.Transparency transparency, RenderPhase.DiffuseLighting diffuseLighting, RenderPhase.ShadeModel shadeModel, RenderPhase.Alpha alpha, RenderPhase.DepthTest depthTest, RenderPhase.Cull cull, RenderPhase.Lightmap lightmap, RenderPhase.Overlay overlay, RenderPhase.Fog fog, RenderPhase.Layering layering, RenderPhase.Target target, RenderPhase.Texturing texturing, RenderPhase.WriteMaskState writeMaskState, RenderPhase.LineWidth lineWidth, OutlineMode outlineMode) {
|
||||
this.texture = texture;
|
||||
this.transparency = transparency;
|
||||
this.diffuseLighting = diffuseLighting;
|
||||
this.shadeModel = shadeModel;
|
||||
this.alpha = alpha;
|
||||
this.depthTest = depthTest;
|
||||
this.cull = cull;
|
||||
this.lightmap = lightmap;
|
||||
this.overlay = overlay;
|
||||
this.fog = fog;
|
||||
this.layering = layering;
|
||||
this.target = target;
|
||||
this.texturing = texturing;
|
||||
this.writeMaskState = writeMaskState;
|
||||
this.lineWidth = lineWidth;
|
||||
this.outlineMode = outlineMode;
|
||||
this.phases = ImmutableList.of(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layering, this.target, new RenderPhase[]{this.texturing, this.writeMaskState, this.lineWidth});
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
MultiPhaseParameters rendertype$state = (MultiPhaseParameters)object;
|
||||
return this.outlineMode == rendertype$state.outlineMode && this.phases.equals(rendertype$state.phases);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return Objects.hash(new Object[]{this.phases, this.outlineMode});
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "CompositeState[" + this.phases + ", outlineProperty=" + this.outlineMode + ']';
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
private RenderPhase.Texture texture;
|
||||
private RenderPhase.Transparency transparency;
|
||||
private RenderPhase.DiffuseLighting diffuseLighting;
|
||||
private RenderPhase.ShadeModel shadeModel;
|
||||
private RenderPhase.Alpha alpha;
|
||||
private RenderPhase.DepthTest depthTest;
|
||||
private RenderPhase.Cull cull;
|
||||
private RenderPhase.Lightmap lightmap;
|
||||
private RenderPhase.Overlay overlay;
|
||||
private RenderPhase.Fog fog;
|
||||
private RenderPhase.Layering layering;
|
||||
private RenderPhase.Target target;
|
||||
private RenderPhase.Texturing texturing;
|
||||
private RenderPhase.WriteMaskState writeMaskState;
|
||||
private RenderPhase.LineWidth lineWidth;
|
||||
|
||||
private Builder() {
|
||||
this.texture = RenderPhase.NO_TEXTURE ;
|
||||
this.transparency = RenderPhase.NO_TRANSPARENCY;
|
||||
this.diffuseLighting = RenderPhase.DISABLE_DIFFUSE_LIGHTING;
|
||||
this.shadeModel = RenderPhase.SHADE_MODEL;
|
||||
this.alpha = RenderPhase.ZERO_ALPHA;
|
||||
this.depthTest = RenderPhase.LEQUAL_DEPTH_TEST;
|
||||
this.cull = RenderPhase.ENABLE_CULLING;
|
||||
this.lightmap = RenderPhase.DISABLE_LIGHTMAP;
|
||||
this.overlay = RenderPhase.DISABLE_OVERLAY_COLOR;
|
||||
this.fog = RenderPhase.FOG;
|
||||
this.layering = RenderPhase.NO_LAYERING;
|
||||
this.target = RenderPhase.MAIN_TARGET;
|
||||
this.texturing = RenderPhase.DEFAULT_TEXTURING;
|
||||
this.writeMaskState = RenderPhase.ALL_MASK;
|
||||
this.lineWidth = RenderPhase.FULL_LINE_WIDTH;
|
||||
}
|
||||
|
||||
public Builder texture(RenderPhase.Texture texture) {
|
||||
this.texture = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder transparency(RenderPhase.Transparency transparency) {
|
||||
this.transparency = transparency;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder shadeModel(RenderPhase.ShadeModel shadeModel) {
|
||||
this.shadeModel = shadeModel;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder alpha(RenderPhase.Alpha alpha) {
|
||||
this.alpha = alpha;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder depthTest(RenderPhase.DepthTest depthTest) {
|
||||
this.depthTest = depthTest;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder cull(RenderPhase.Cull cull) {
|
||||
this.cull = cull;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder lightmap(RenderPhase.Lightmap lightmap) {
|
||||
this.lightmap = lightmap;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder overlay(RenderPhase.Overlay overlay) {
|
||||
this.overlay = overlay;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fog(RenderPhase.Fog fog) {
|
||||
this.fog = fog;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder target(RenderPhase.Target target) {
|
||||
this.target = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder texturing(RenderPhase.Texturing texturing) {
|
||||
this.texturing = texturing;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MultiPhaseParameters build(boolean affectsOutline) {
|
||||
return this.build(affectsOutline ? RenderLayer.OutlineMode.AFFECTS_OUTLINE : RenderLayer.OutlineMode.NONE);
|
||||
}
|
||||
|
||||
public MultiPhaseParameters build(OutlineMode outlineMode) {
|
||||
return new MultiPhaseParameters(this.texture, this.transparency, this.diffuseLighting, this.shadeModel, this.alpha, this.depthTest, this.cull, this.lightmap, this.overlay, this.fog, this.layering, this.target, this.texturing, this.writeMaskState, this.lineWidth, outlineMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum OutlineMode {
|
||||
NONE("none"),
|
||||
IS_OUTLINE("is_outline"),
|
||||
AFFECTS_OUTLINE("affects_outline");
|
||||
|
||||
private final String name;
|
||||
|
||||
OutlineMode(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,816 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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 {
|
||||
protected final String name;
|
||||
protected Runnable beginAction;
|
||||
private final Runnable endAction;
|
||||
protected static final Transparency NO_TRANSPARENCY = new Transparency("no_transparency", GLStateManager::disableBlend, () -> {
|
||||
});
|
||||
protected static final Transparency ADDITIVE_TRANSPARENCY = new Transparency("additive_transparency", () -> {
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
|
||||
}, () -> {
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.defaultBlendFunc();
|
||||
});
|
||||
protected static final Transparency LIGHTNING_TRANSPARENCY = new Transparency("lightning_transparency", () -> {
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
}, () -> {
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.defaultBlendFunc();
|
||||
});
|
||||
protected static final Transparency GLINT_TRANSPARENCY = new Transparency("glint_transparency", () -> {
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_COLOR, GL11.GL_ONE, GL11.GL_ZERO, GL11.GL_ONE);
|
||||
}, () -> {
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.defaultBlendFunc();
|
||||
});
|
||||
protected static final Transparency CRUMBLING_TRANSPARENCY = new Transparency("crumbling_transparency", () -> {
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR, GL11.GL_ONE, GL11.GL_ZERO);
|
||||
}, () -> {
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.defaultBlendFunc();
|
||||
});
|
||||
protected static final Transparency TRANSLUCENT_TRANSPARENCY = new Transparency("translucent_transparency", () -> {
|
||||
GLStateManager.enableBlend();
|
||||
GLStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}, () -> {
|
||||
GLStateManager.disableBlend();
|
||||
GLStateManager.defaultBlendFunc();
|
||||
});
|
||||
protected static final Alpha ZERO_ALPHA = new Alpha(0.0F);
|
||||
protected static final Alpha ONE_TENTH_ALPHA = new Alpha(0.003921569F);
|
||||
protected static final Alpha HALF_ALPHA = new Alpha(0.5F);
|
||||
protected static final ShadeModel SHADE_MODEL = new ShadeModel(false);
|
||||
protected static final ShadeModel SMOOTH_SHADE_MODEL = new ShadeModel(true);
|
||||
protected static final Texture MIPMAP_BLOCK_ATLAS_TEXTURE;
|
||||
protected static final Texture BLOCK_ATLAS_TEXTURE;
|
||||
protected static final Texture NO_TEXTURE;
|
||||
protected static final Texturing DEFAULT_TEXTURING;
|
||||
protected static final Texturing OUTLINE_TEXTURING;
|
||||
protected static final Texturing GLINT_TEXTURING;
|
||||
protected static final Texturing ENTITY_GLINT_TEXTURING;
|
||||
protected static final Lightmap ENABLE_LIGHTMAP;
|
||||
protected static final Lightmap DISABLE_LIGHTMAP;
|
||||
protected static final Overlay ENABLE_OVERLAY_COLOR;
|
||||
protected static final Overlay DISABLE_OVERLAY_COLOR;
|
||||
protected static final DiffuseLighting ENABLE_DIFFUSE_LIGHTING;
|
||||
protected static final DiffuseLighting DISABLE_DIFFUSE_LIGHTING;
|
||||
protected static final Cull ENABLE_CULLING;
|
||||
protected static final Cull DISABLE_CULLING;
|
||||
protected static final DepthTest ALWAYS_DEPTH_TEST;
|
||||
protected static final DepthTest EQUAL_DEPTH_TEST;
|
||||
protected static final DepthTest LEQUAL_DEPTH_TEST;
|
||||
protected static final WriteMaskState ALL_MASK;
|
||||
protected static final WriteMaskState COLOR_MASK;
|
||||
protected static final WriteMaskState DEPTH_MASK;
|
||||
protected static final Layering NO_LAYERING;
|
||||
protected static final Layering POLYGON_OFFSET_LAYERING;
|
||||
protected static final Layering VIEW_OFFSET_Z_LAYERING;
|
||||
protected static final Fog NO_FOG;
|
||||
protected static final Fog FOG;
|
||||
protected static final Fog BLACK_FOG;
|
||||
protected static final Target MAIN_TARGET;
|
||||
protected static final Target OUTLINE_TARGET;
|
||||
protected static final Target TRANSLUCENT_TARGET;
|
||||
protected static final Target PARTICLES_TARGET;
|
||||
protected static final Target WEATHER_TARGET;
|
||||
protected static final Target CLOUDS_TARGET;
|
||||
protected static final Target ITEM_TARGET;
|
||||
protected static final LineWidth FULL_LINE_WIDTH;
|
||||
|
||||
public RenderPhase(String name, Runnable beginAction, Runnable endAction) {
|
||||
this.name = name;
|
||||
this.beginAction = beginAction;
|
||||
this.endAction = endAction;
|
||||
}
|
||||
|
||||
public void startDrawing() {
|
||||
this.beginAction.run();
|
||||
}
|
||||
|
||||
public void endDrawing() {
|
||||
this.endAction.run();
|
||||
}
|
||||
|
||||
public boolean equals(@Nullable Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
RenderPhase lv = (RenderPhase)object;
|
||||
return this.name.equals(lv.name);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
private static void setupGlintTexturing(float scale) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.matrixMode(5890);
|
||||
// RenderSystem.pushMatrix();
|
||||
// RenderSystem.loadIdentity();
|
||||
// long l = Util.getMeasuringTimeMs() * 8L;
|
||||
// float g = (float)(l % 110000L) / 110000.0F;
|
||||
// float h = (float)(l % 30000L) / 30000.0F;
|
||||
// RenderSystem.translatef(-g, h, 0.0F);
|
||||
// RenderSystem.rotatef(10.0F, 0.0F, 0.0F, 1.0F);
|
||||
// RenderSystem.scalef(scale, scale, scale);
|
||||
// RenderSystem.matrixMode(5888);
|
||||
}
|
||||
|
||||
private static ResourceLocation ATLAS = TextureMap.locationBlocksTexture;
|
||||
static {
|
||||
// TODO: Sodium - SpriteAtlasTexture
|
||||
MIPMAP_BLOCK_ATLAS_TEXTURE = new Texture(ATLAS, false, true);
|
||||
BLOCK_ATLAS_TEXTURE = new Texture(ATLAS, false, false);
|
||||
NO_TEXTURE = new Texture();
|
||||
DEFAULT_TEXTURING = new Texturing("default_texturing", () -> {
|
||||
}, () -> {
|
||||
});
|
||||
OUTLINE_TEXTURING = new Texturing("outline_texturing", () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.setupOutline();
|
||||
}, () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.teardownOutline();
|
||||
});
|
||||
GLINT_TEXTURING = new Texturing("glint_texturing", () -> {
|
||||
setupGlintTexturing(8.0F);
|
||||
}, () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.matrixMode(5890);
|
||||
// RenderSystem.popMatrix();
|
||||
// RenderSystem.matrixMode(5888);
|
||||
});
|
||||
ENTITY_GLINT_TEXTURING = new Texturing("entity_glint_texturing", () -> {
|
||||
setupGlintTexturing(0.16F);
|
||||
}, () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.matrixMode(5890);
|
||||
// RenderSystem.popMatrix();
|
||||
// RenderSystem.matrixMode(5888);
|
||||
});
|
||||
ENABLE_LIGHTMAP = new Lightmap(true);
|
||||
DISABLE_LIGHTMAP = new Lightmap(false);
|
||||
ENABLE_OVERLAY_COLOR = new Overlay(true);
|
||||
DISABLE_OVERLAY_COLOR = new Overlay(false);
|
||||
ENABLE_DIFFUSE_LIGHTING = new DiffuseLighting(true);
|
||||
DISABLE_DIFFUSE_LIGHTING = new DiffuseLighting(false);
|
||||
ENABLE_CULLING = new Cull(true);
|
||||
DISABLE_CULLING = new Cull(false);
|
||||
ALWAYS_DEPTH_TEST = new DepthTest("always", GL11.GL_ALWAYS);
|
||||
EQUAL_DEPTH_TEST = new DepthTest("==", GL11.GL_EQUAL);
|
||||
LEQUAL_DEPTH_TEST = new DepthTest("<=", GL11.GL_LEQUAL);
|
||||
ALL_MASK = new WriteMaskState(true, true);
|
||||
COLOR_MASK = new WriteMaskState(true, false);
|
||||
DEPTH_MASK = new WriteMaskState(false, true);
|
||||
NO_LAYERING = new Layering("no_layering", () -> {
|
||||
}, () -> {
|
||||
});
|
||||
POLYGON_OFFSET_LAYERING = new Layering("polygon_offset_layering", () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.polygonOffset(-1.0F, -10.0F);
|
||||
// RenderSystem.enablePolygonOffset();
|
||||
}, () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.polygonOffset(0.0F, 0.0F);
|
||||
// RenderSystem.disablePolygonOffset();
|
||||
});
|
||||
VIEW_OFFSET_Z_LAYERING = new Layering("view_offset_z_layering", () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.pushMatrix();
|
||||
// RenderSystem.scalef(0.99975586F, 0.99975586F, 0.99975586F);
|
||||
}, () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem::popMatrix();
|
||||
});
|
||||
NO_FOG = new Fog("no_fog", () -> {
|
||||
}, () -> {
|
||||
});
|
||||
FOG = new Fog("fog", () -> {
|
||||
// Unclear what this should do
|
||||
// BackgroundRenderer.setFogBlack(), also levelFogColor()
|
||||
SodiumClientMod.LOGGER.debug("Fog - Not setting level fog color");
|
||||
GLStateManager.enableFog();
|
||||
}, GLStateManager::disableFog);
|
||||
BLACK_FOG = new Fog("black_fog", () -> {
|
||||
GLStateManager.fogColor(0.0F, 0.0F, 0.0F, 1.0F);
|
||||
GLStateManager.enableFog();
|
||||
}, () -> {
|
||||
// Unclear what this should do
|
||||
// BackgroundRenderer.setFogBlack(), also levelFogColor()
|
||||
SodiumClientMod.LOGGER.debug("Fog - Not setting level fog color");
|
||||
GLStateManager.disableFog();
|
||||
});
|
||||
MAIN_TARGET = new Target("main_target", () -> {
|
||||
}, () -> {
|
||||
});
|
||||
OUTLINE_TARGET = new Target("outline_target", () -> {
|
||||
// TODO: Sodium
|
||||
SodiumClientMod.LOGGER.debug("NOT enabling the entity outline framebuffer");
|
||||
//MinecraftClient.getInstance().worldRenderer.getEntityOutlinesFramebuffer().beginWrite(false);
|
||||
}, () -> {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
});
|
||||
TRANSLUCENT_TARGET = new Target("translucent_target", () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
// TODO: Sodium
|
||||
SodiumClientMod.LOGGER.debug("NOT enabling the translucent framebuffer");
|
||||
// MinecraftClient.getInstance().worldRenderer.getTranslucentFramebuffer().beginWrite(false);
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
}
|
||||
|
||||
});
|
||||
PARTICLES_TARGET = new Target("particles_target", () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().worldRenderer.getParticlesFramebuffer().beginWrite(false);
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
}
|
||||
|
||||
});
|
||||
WEATHER_TARGET = new Target("weather_target", () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().worldRenderer.getWeatherFramebuffer().beginWrite(false);
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
}
|
||||
|
||||
});
|
||||
CLOUDS_TARGET = new Target("clouds_target", () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().worldRenderer.getCloudsFramebuffer().beginWrite(false);
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
}
|
||||
|
||||
});
|
||||
ITEM_TARGET = new Target("item_entity_target", () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().worldRenderer.getEntityFramebuffer().beginWrite(false);
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
}
|
||||
|
||||
});
|
||||
FULL_LINE_WIDTH = new LineWidth(OptionalDouble.of(1.0));
|
||||
}
|
||||
|
||||
|
||||
public static class LineWidth extends RenderPhase {
|
||||
private final OptionalDouble width;
|
||||
|
||||
public LineWidth(OptionalDouble optionalDouble) {
|
||||
super("line_width", () -> {
|
||||
if (!Objects.equals(optionalDouble, OptionalDouble.of(1.0))) {
|
||||
if (optionalDouble.isPresent()) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.lineWidth((float)optionalDouble.getAsDouble());
|
||||
} else {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.lineWidth(Math.max(2.5F, (float)MinecraftClient.getInstance().getWindow().getFramebufferWidth() / 1920.0F * 2.5F));
|
||||
}
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (!Objects.equals(optionalDouble, OptionalDouble.of(1.0))) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.lineWidth(1.0F);
|
||||
}
|
||||
|
||||
});
|
||||
this.width = optionalDouble;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
return !super.equals(object) ? false : Objects.equals(this.width, ((LineWidth)object).width);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), this.width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + '[' + (this.width.isPresent() ? this.width.getAsDouble() : "window_scale") + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Target extends RenderPhase {
|
||||
public Target(String string, Runnable runnable, Runnable runnable2) {
|
||||
super(string, runnable, runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Fog extends RenderPhase {
|
||||
public Fog(String string, Runnable runnable, Runnable runnable2) {
|
||||
super(string, runnable, runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Layering extends RenderPhase {
|
||||
public Layering(String string, Runnable runnable, Runnable runnable2) {
|
||||
super(string, runnable, runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class WriteMaskState extends RenderPhase {
|
||||
private final boolean color;
|
||||
private final boolean depth;
|
||||
|
||||
public WriteMaskState(boolean color, boolean depth) {
|
||||
super("write_mask_state", () -> {
|
||||
if (!depth) {
|
||||
GLStateManager.glDepthMask(depth);
|
||||
}
|
||||
|
||||
if (!color) {
|
||||
GLStateManager.glColorMask(color, color, color, color);
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (!depth) {
|
||||
GLStateManager.glDepthMask(true);
|
||||
}
|
||||
|
||||
if (!color) {
|
||||
GLStateManager.glColorMask(true, true, true, true);
|
||||
}
|
||||
|
||||
});
|
||||
this.color = color;
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
WriteMaskState lv = (WriteMaskState)object;
|
||||
return this.color == lv.color && this.depth == lv.depth;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.color, this.depth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + "[writeColor=" + this.color + ", writeDepth=" + this.depth + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DepthTest extends RenderPhase {
|
||||
private final String depthFunction;
|
||||
private final int func;
|
||||
|
||||
public DepthTest(String string, int i) {
|
||||
super("depth_test", () -> {
|
||||
if (i != GL11.GL_ALWAYS) {
|
||||
GLStateManager.enableDepthTest();
|
||||
GLStateManager.glDepthFunc(i);
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (i != GL11.GL_ALWAYS) {
|
||||
GLStateManager.disableDepthTest();
|
||||
GLStateManager.glDepthFunc(GL11.GL_LEQUAL);
|
||||
}
|
||||
|
||||
});
|
||||
this.depthFunction = string;
|
||||
this.func = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
DepthTest lv = (DepthTest)object;
|
||||
return this.func == lv.func;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Integer.hashCode(this.func);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + '[' + this.depthFunction + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Cull extends Toggleable {
|
||||
public Cull(boolean culling) {
|
||||
super("cull", () -> {
|
||||
if (!culling) {
|
||||
GLStateManager.disableCull();
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (!culling) {
|
||||
GLStateManager.enableCull();
|
||||
}
|
||||
|
||||
}, culling);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class DiffuseLighting extends Toggleable {
|
||||
public DiffuseLighting(boolean guiLighting) {
|
||||
super("diffuse_lighting", () -> {
|
||||
if (guiLighting) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// net.minecraft.client.drawScreen.DiffuseLighting.enable();
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (guiLighting) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// net.minecraft.client.drawScreen.DiffuseLighting.disable();
|
||||
}
|
||||
|
||||
}, guiLighting);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Overlay extends Toggleable {
|
||||
public Overlay(boolean overlayColor) {
|
||||
super("overlay", () -> {
|
||||
if (overlayColor) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().gameRenderer.getOverlayTexture().setupOverlayColor();
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (overlayColor) {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().gameRenderer.getOverlayTexture().teardownOverlayColor();
|
||||
}
|
||||
|
||||
}, overlayColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Lightmap extends Toggleable {
|
||||
public Lightmap(boolean lightmap) {
|
||||
super("lightmap", () -> {
|
||||
if (lightmap) {
|
||||
// TODO: Sodium - LightmapTextureManager
|
||||
SodiumClientMod.LOGGER.debug("Lightmap - enable (not implemented)");
|
||||
// throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().enable();
|
||||
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
if (lightmap) {
|
||||
// TODO: Sodium - LightmapTextureManager
|
||||
SodiumClientMod.LOGGER.debug("Lightmap - disable (not implemented)");
|
||||
// throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().disable();
|
||||
}
|
||||
|
||||
}, lightmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class Toggleable extends RenderPhase {
|
||||
private final boolean enabled;
|
||||
|
||||
public Toggleable(String string, Runnable runnable, Runnable runnable2, boolean bl) {
|
||||
super(string, runnable, runnable2);
|
||||
this.enabled = bl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
Toggleable lv = (Toggleable)object;
|
||||
return this.enabled == lv.enabled;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Boolean.hashCode(this.enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + '[' + this.enabled + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final class PortalTexturing extends Texturing {
|
||||
private final int layer;
|
||||
|
||||
public PortalTexturing(int layer) {
|
||||
super("portal_texturing", () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.matrixMode(5890);
|
||||
// RenderSystem.pushMatrix();
|
||||
// RenderSystem.loadIdentity();
|
||||
// RenderSystem.translatef(0.5F, 0.5F, 0.0F);
|
||||
// RenderSystem.scalef(0.5F, 0.5F, 1.0F);
|
||||
// RenderSystem.translatef(17.0F / (float)layer, (2.0F + (float)layer / 1.5F) * ((float)(Util.getMeasuringTimeMs() % 800000L) / 800000.0F), 0.0F);
|
||||
// RenderSystem.rotatef(((float)(layer * layer) * 4321.0F + (float)layer * 9.0F) * 2.0F, 0.0F, 0.0F, 1.0F);
|
||||
// RenderSystem.scalef(4.5F - (float)layer / 4.0F, 4.5F - (float)layer / 4.0F, 1.0F);
|
||||
// RenderSystem.mulTextureByProjModelView();
|
||||
// RenderSystem.matrixMode(5888);
|
||||
// RenderSystem.setupEndPortalTexGen();
|
||||
}, () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.matrixMode(5890);
|
||||
// RenderSystem.popMatrix();
|
||||
// RenderSystem.matrixMode(5888);
|
||||
// RenderSystem.clearTexGen();
|
||||
});
|
||||
this.layer = layer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
PortalTexturing lv = (PortalTexturing)object;
|
||||
return this.layer == lv.layer;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Integer.hashCode(this.layer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static final class OffsetTexturing extends Texturing {
|
||||
private final float x;
|
||||
private final float y;
|
||||
|
||||
public OffsetTexturing(float x, float y) {
|
||||
super("offset_texturing", () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.matrixMode(5890);
|
||||
// RenderSystem.pushMatrix();
|
||||
// RenderSystem.loadIdentity();
|
||||
// RenderSystem.translatef(x, y, 0.0F);
|
||||
// RenderSystem.matrixMode(5888);
|
||||
}, () -> {
|
||||
throw new RuntimeException("Not Implemented Yet");
|
||||
// RenderSystem.matrixMode(5890);
|
||||
// RenderSystem.popMatrix();
|
||||
// RenderSystem.matrixMode(5888);
|
||||
});
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
OffsetTexturing lv = (OffsetTexturing)object;
|
||||
return Float.compare(lv.x, this.x) == 0 && Float.compare(lv.y, this.y) == 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(this.x, this.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Texturing extends RenderPhase {
|
||||
public Texturing(String string, Runnable runnable, Runnable runnable2) {
|
||||
super(string, runnable, runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Texture extends RenderPhase {
|
||||
private final Optional<ResourceLocation> id;
|
||||
protected boolean bilinear;
|
||||
protected boolean mipmap;
|
||||
|
||||
public Texture(ResourceLocation id, boolean bilinear, boolean mipmap) {
|
||||
super("texture", () -> {
|
||||
GLStateManager.enableTexture();
|
||||
TextureManager lv = Minecraft.getMinecraft().getTextureManager();
|
||||
lv.bindTexture(id);
|
||||
//GLStateManager.setFilter(bilinear, mipmap); // breaks textures. TODO find out why
|
||||
}, () -> {
|
||||
});
|
||||
this.id = Optional.of(id);
|
||||
this.bilinear = bilinear;
|
||||
this.mipmap = mipmap;
|
||||
}
|
||||
|
||||
public Texture() {
|
||||
super("texture", GLStateManager::disableTexture, GLStateManager::enableTexture);
|
||||
this.id = Optional.empty();
|
||||
this.bilinear = false;
|
||||
this.mipmap = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
Texture lv = (Texture)object;
|
||||
return this.id.equals(lv.id) && this.bilinear == lv.bilinear && this.mipmap == lv.mipmap;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.id.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + '[' + this.id + "(blur=" + this.bilinear + ", mipmap=" + this.mipmap + ")]";
|
||||
}
|
||||
|
||||
protected Optional<ResourceLocation> getId() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ShadeModel extends RenderPhase {
|
||||
private final boolean smooth;
|
||||
|
||||
public ShadeModel(boolean smooth) {
|
||||
super("shade_model",
|
||||
() -> GLStateManager.glShadeModel(smooth ? GL11.GL_SMOOTH : GL11.GL_FLAT),
|
||||
() -> GLStateManager.glShadeModel(GL11.GL_FLAT));
|
||||
this.smooth = smooth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
ShadeModel lv = (ShadeModel)object;
|
||||
return this.smooth == lv.smooth;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Boolean.hashCode(this.smooth);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + '[' + (this.smooth ? "smooth" : "flat") + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Alpha extends RenderPhase {
|
||||
private final float alpha;
|
||||
|
||||
public Alpha(float alpha) {
|
||||
super("alpha", () -> {
|
||||
if (alpha > 0.0F) {
|
||||
|
||||
GLStateManager.enableAlphaTest();
|
||||
GLStateManager.glAlphaFunc(GL11.GL_GREATER, alpha);
|
||||
} else {
|
||||
GLStateManager.disableAlphaTest();
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
GLStateManager.disableAlphaTest();
|
||||
GLStateManager.glAlphaFunc(GL11.GL_GREATER, 0.1F);
|
||||
});
|
||||
this.alpha = alpha;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
} else if (object != null && this.getClass() == object.getClass()) {
|
||||
if (!super.equals(object)) {
|
||||
return false;
|
||||
} else {
|
||||
return this.alpha == ((Alpha)object).alpha;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), this.alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.name + '[' + this.alpha + ']';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Transparency extends RenderPhase {
|
||||
public Transparency(String string, Runnable runnable, Runnable runnable2) {
|
||||
super(string, runnable, runnable2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface VertexConsumer {
|
||||
|
||||
VertexConsumer vertex(double d, double e, double f);
|
||||
|
||||
@Nonnull
|
||||
VertexConsumer color(int r, int g, int b, int a);
|
||||
|
||||
@Nonnull
|
||||
VertexConsumer texture(float u, float v);
|
||||
|
||||
@Nonnull
|
||||
VertexConsumer overlay(int u, int v);
|
||||
|
||||
@Nonnull
|
||||
VertexConsumer light(int u, int v);
|
||||
|
||||
@Nonnull
|
||||
VertexConsumer normal(float x, float y, float z);
|
||||
|
||||
void next();
|
||||
|
||||
default VertexConsumer overlay(int overlay) {
|
||||
return this.overlay(overlay & 0xFFFF, overlay >> 16 & 0xFFFF);
|
||||
}
|
||||
|
||||
default VertexConsumer light(int light) {
|
||||
return this.light(light & 0xFFFF, light >> 16 & 0xFFFF);
|
||||
}
|
||||
|
||||
default VertexConsumer color(float red, float green, float blue, float alpha) {
|
||||
return this.color((int)(red * 255.0F), (int)(green * 255.0F), (int)(blue * 255.0F), (int)(alpha * 255.0F));
|
||||
}
|
||||
|
||||
default void vertex(float x, float y, float z, float red, float green, float blue, float alpha, float u, float v, int overlay, int light, float normalX, float normalY, float normalZ) {
|
||||
this.vertex((double)x, (double)y, (double)z);
|
||||
this.color(red, green, blue, alpha);
|
||||
this.texture(u, v);
|
||||
this.overlay(overlay);
|
||||
this.light(light);
|
||||
this.normal(normalX, normalY, normalZ);
|
||||
this.next();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
@Config(modid = "angelica")
|
||||
public class AngelicaConfig {
|
||||
@Config.Comment("Enable Sodium rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableSodium;
|
||||
|
||||
@Config.Comment("Enable Reese's Sodium Options")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean enableReesesSodiumOptions;
|
||||
|
||||
@Config.Comment("Enable Sodium fluid rendering")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableSodiumFluidRendering;
|
||||
|
||||
@Config.Comment("Enable Iris Shaders [Requires Sodium]")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableIris;
|
||||
|
||||
@Config.Comment("Enable MCPatcherForge features, still in Alpha. Individual features are toggled in mcpatcher.json")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableMCPatcherForgeFeatures;
|
||||
|
||||
@Config.Comment("Enable NotFine optimizations")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableNotFineOptimizations;
|
||||
|
||||
@Config.Comment("Replace some vanilla render paths with more optimized versions. Disable if you encounter mixin conflicts.")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableVBO;
|
||||
|
||||
@Config.Comment("Enable NotFine features")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableNotFineFeatures;
|
||||
|
||||
@Config.Comment("Tweak F3 screen to be closer to modern versions. [From ArchaicFix]")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean modernizeF3Screen;
|
||||
|
||||
@Config.Comment("Show block registry name and meta value in F3, similar to 1.8+. [From ArchaicFix]")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean showBlockDebugInfo;
|
||||
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.Comment("Hide downloading terrain screen. [From ArchaicFix]")
|
||||
public static boolean hideDownloadingTerrainScreen;
|
||||
|
||||
@Config.Comment("Show memory usage during game load. [From ArchaicFix]")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean showSplashMemoryBar;
|
||||
|
||||
|
||||
@Config.Comment("Renders the HUD elements once per tick and reuses the pixels to improve performance. [Experimental]")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableHudCaching;
|
||||
|
||||
@Config.Comment("Batch drawScreen fonts [Experimental]")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableFontRenderer;
|
||||
|
||||
@Config.Comment("Optimize world update light. [From Hodgepodge]")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeWorldUpdateLight;
|
||||
|
||||
@Config.Comment("Speedup Animations. [From Hodgepodge]")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean speedupAnimations;
|
||||
|
||||
@Config.Comment("Optimize Texture Loading. [From Hodgepodge]")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeTextureLoading;
|
||||
|
||||
@Config.Comment("Fix thread-safety in lotrs rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixLotrSodiumCompat;
|
||||
|
||||
@Config.Comment("Enable Debug Logging")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableDebugLogging;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class AngelicaGuiConfig extends SimpleGuiConfig {
|
||||
public AngelicaGuiConfig(GuiScreen parent) throws ConfigException {
|
||||
super(parent, AngelicaConfig.class, "angelica", "Angelica");
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
public class AngelicaGuiConfigFactory implements SimpleGuiFactory {
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass() {
|
||||
return AngelicaGuiConfig.class;
|
||||
}
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Config {
|
||||
/**
|
||||
* The mod id that this configuration is associated with.
|
||||
*/
|
||||
String modid();
|
||||
|
||||
/**
|
||||
* Root element category, defaults to "general". You must not specify an empty string.
|
||||
*/
|
||||
String category() default "general";
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface LangKey {
|
||||
String value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Comment {
|
||||
String[] value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Ignore {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultBoolean {
|
||||
boolean value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeInt {
|
||||
int min() default Integer.MIN_VALUE;
|
||||
|
||||
int max() default Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultInt {
|
||||
int value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeFloat {
|
||||
float min() default Float.MIN_VALUE;
|
||||
|
||||
float max() default Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultFloat {
|
||||
float value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultString {
|
||||
String value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Pattern {
|
||||
String value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultEnum {
|
||||
String value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultStringList {
|
||||
String[] value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Name {
|
||||
String value();
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface RequiresMcRestart {
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface RequiresWorldRestart {
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
/**
|
||||
* A really basic wrapper for config to simplify handling them in external code.
|
||||
*/
|
||||
public class ConfigException extends Exception {
|
||||
|
||||
public ConfigException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ConfigException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ConfigMigrator {
|
||||
public static Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
/**
|
||||
* Tries to migrate the equivalent config file from Rubidium to the Angelica name if possible.
|
||||
*/
|
||||
public static Path handleConfigMigration(String fileName) {
|
||||
final Path configDir = Minecraft.getMinecraft().mcDataDir.toPath().resolve("config");
|
||||
final Path mainPath = configDir.resolve(fileName);
|
||||
try {
|
||||
if(Files.notExists(mainPath)) {
|
||||
final String legacyName = fileName.replace("angelica", "rubidium");
|
||||
final Path legacyPath = configDir.resolve(legacyName);
|
||||
if(Files.exists(legacyPath)) {
|
||||
Files.move(legacyPath, mainPath);
|
||||
LOGGER.warn("Migrated {} config file to {}", legacyName, fileName);
|
||||
}
|
||||
}
|
||||
} catch(IOException | RuntimeException e) {
|
||||
LOGGER.error("Exception encountered while attempting config migration", e);
|
||||
}
|
||||
|
||||
return mainPath;
|
||||
}
|
||||
}
|
||||
@@ -1,267 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import cpw.mods.fml.client.config.IConfigElement;
|
||||
import cpw.mods.fml.client.event.ConfigChangedEvent;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.val;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Class for controlling the loading of configuration files.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ConfigurationManager {
|
||||
private static final Logger LOGGER = LogManager.getLogger("ArchaicConfig");
|
||||
private static final Map<String, Configuration> configs = new HashMap<>();
|
||||
|
||||
private static final Map<Configuration, Set<Class<?>>> configToClassMap = new HashMap<>();
|
||||
|
||||
private static final ConfigurationManager instance = new ConfigurationManager();
|
||||
|
||||
private static boolean initialized = false;
|
||||
|
||||
private static Path configDir;
|
||||
|
||||
/**
|
||||
* Registers a configuration class to be loaded. This should be done in preInit.
|
||||
*
|
||||
* @param configClass The class to register.
|
||||
*/
|
||||
public static void registerConfig(Class<?> configClass) throws ConfigException {
|
||||
init();
|
||||
val cfg = Optional.ofNullable(configClass.getAnnotation(Config.class))
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Class " + configClass.getName() + " does not have a @Config annotation!"));
|
||||
val category = Optional.of(cfg.category().trim())
|
||||
.map((cat) -> cat.length() == 0 ? null : cat)
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Config class " + configClass.getName() + " has an empty category!"));
|
||||
val rawConfig = configs.computeIfAbsent(cfg.modid(), (ignored) -> {
|
||||
val c = new Configuration(configDir.resolve(cfg.modid() + ".cfg").toFile());
|
||||
c.load();
|
||||
return c;
|
||||
});
|
||||
configToClassMap.computeIfAbsent(rawConfig, (ignored) -> new HashSet<>()).add(configClass);
|
||||
try {
|
||||
processConfigInternal(configClass, category, rawConfig);
|
||||
rawConfig.save();
|
||||
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException | NoSuchFieldException e) {
|
||||
throw new ConfigException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void processConfigInternal(Class<?> configClass, String category, Configuration rawConfig)
|
||||
throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, NoSuchFieldException,
|
||||
ConfigException {
|
||||
val cat = rawConfig.getCategory(category);
|
||||
for (val field : configClass.getDeclaredFields()) {
|
||||
if (field.getAnnotation(Config.Ignore.class) != null) {
|
||||
continue;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
val comment = Optional.ofNullable(field.getAnnotation(Config.Comment.class))
|
||||
.map(Config.Comment::value)
|
||||
.map((lines) -> String.join("\n", lines))
|
||||
.orElse("");
|
||||
val name = Optional.ofNullable(field.getAnnotation(Config.Name.class))
|
||||
.map(Config.Name::value)
|
||||
.orElse(field.getName());
|
||||
val langKey = Optional.ofNullable(field.getAnnotation(Config.LangKey.class))
|
||||
.map(Config.LangKey::value)
|
||||
.orElse(name);
|
||||
val fieldClass = field.getType();
|
||||
var boxed = false;
|
||||
if ((boxed = fieldClass.equals(Boolean.class)) || fieldClass.equals(boolean.class)) {
|
||||
val defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultBoolean.class))
|
||||
.map(Config.DefaultBoolean::value)
|
||||
.orElse(boxed ? (Boolean) field.get(null) : field.getBoolean(null));
|
||||
field.setBoolean(null, rawConfig.getBoolean(name, category, defaultValue, comment, langKey));
|
||||
} else if ((boxed = fieldClass.equals(Integer.class)) || fieldClass.equals(int.class)) {
|
||||
val range = Optional.ofNullable(field.getAnnotation(Config.RangeInt.class));
|
||||
val min = range.map(Config.RangeInt::min).orElse(Integer.MIN_VALUE);
|
||||
val max = range.map(Config.RangeInt::max).orElse(Integer.MAX_VALUE);
|
||||
val defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultInt.class))
|
||||
.map(Config.DefaultInt::value)
|
||||
.orElse(boxed ? (Integer) field.get(null) : field.getInt(null));
|
||||
field.setInt(null, rawConfig.getInt(name, category, defaultValue, min, max, comment, langKey));
|
||||
} else if ((boxed = fieldClass.equals(Float.class)) || fieldClass.equals(float.class)) {
|
||||
val range = Optional.ofNullable(field.getAnnotation(Config.RangeFloat.class));
|
||||
val min = range.map(Config.RangeFloat::min).orElse(Float.MIN_VALUE);
|
||||
val max = range.map(Config.RangeFloat::max).orElse(Float.MAX_VALUE);
|
||||
val defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultFloat.class))
|
||||
.map(Config.DefaultFloat::value)
|
||||
.orElse(boxed ? (Float) field.get(null) : field.getFloat(null));
|
||||
field.setFloat(null, rawConfig.getFloat(name, category, defaultValue, min, max, comment, langKey));
|
||||
} else if (fieldClass.equals(String.class)) {
|
||||
val defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultString.class))
|
||||
.map(Config.DefaultString::value)
|
||||
.orElse((String) field.get(null));
|
||||
val pattern = Optional.ofNullable(field.getAnnotation(Config.Pattern.class))
|
||||
.map(Config.Pattern::value)
|
||||
.map(Pattern::compile)
|
||||
.orElse(null);
|
||||
field.set(null, rawConfig.getString(name, category, defaultValue, comment, langKey, pattern));
|
||||
} else if (fieldClass.isEnum()) {
|
||||
val enumValues = Arrays.stream((Object[]) fieldClass.getDeclaredMethod("values").invoke(null))
|
||||
.map((obj) -> (Enum<?>) obj)
|
||||
.collect(Collectors.toList());
|
||||
val defaultValue = (Enum<?>) Optional.ofNullable(field.getAnnotation(Config.DefaultEnum.class))
|
||||
.map(Config.DefaultEnum::value)
|
||||
.map((defName) -> extractField(fieldClass, defName))
|
||||
.map(ConfigurationManager::extractValue)
|
||||
.orElse(field.get(null));
|
||||
val possibleValues = enumValues.stream().map(Enum::name).toArray(String[]::new);
|
||||
var value = rawConfig.getString(name,
|
||||
category,
|
||||
defaultValue.name(),
|
||||
comment + "\nPossible values: " + Arrays.toString(possibleValues) +
|
||||
"\n",
|
||||
possibleValues,
|
||||
langKey);
|
||||
|
||||
try {
|
||||
if (!Arrays.asList(possibleValues).contains(value)) {
|
||||
throw new NoSuchFieldException();
|
||||
}
|
||||
val enumField = fieldClass.getDeclaredField(value);
|
||||
if (!enumField.isEnumConstant()) {
|
||||
throw new NoSuchFieldException();
|
||||
}
|
||||
field.set(null, enumField.get(null));
|
||||
} catch (NoSuchFieldException e) {
|
||||
LOGGER
|
||||
.warn("Invalid value " + value + " for enum configuration field " + field.getName() +
|
||||
" of type " + fieldClass.getName() + " in config class " +
|
||||
configClass.getName() + "! Using default value of " + defaultValue + "!");
|
||||
field.set(null, defaultValue);
|
||||
}
|
||||
} else if (fieldClass.isArray() && fieldClass.getComponentType().equals(String.class)) {
|
||||
val defaultValue = Optional.ofNullable(field.getAnnotation(Config.DefaultStringList.class)).map(Config.DefaultStringList::value).orElse((String[])field.get(null));
|
||||
var value = rawConfig.getStringList(name, category, defaultValue, comment, null, langKey);
|
||||
field.set(null, value);
|
||||
} else {
|
||||
throw new ConfigException("Illegal config field: " + field.getName() + " in " + configClass.getName() +
|
||||
": Unsupported type " + fieldClass.getName() +
|
||||
"! Did you forget an @Ignore annotation?");
|
||||
}
|
||||
if (field.isAnnotationPresent(Config.RequiresMcRestart.class)) {
|
||||
cat.setRequiresMcRestart(true);
|
||||
}
|
||||
if (field.isAnnotationPresent(Config.RequiresWorldRestart.class)) {
|
||||
cat.setRequiresWorldRestart(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static Field extractField(Class<?> clazz, String field) {
|
||||
return clazz.getDeclaredField(field);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private static Object extractValue(Field field) {
|
||||
return field.get(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the configuration into a list of config elements usable in config GUI code.
|
||||
*
|
||||
* @param configClass The class to process.
|
||||
*
|
||||
* @return The configuration elements.
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
public static List<IConfigElement> getConfigElements(Class<?> configClass) throws ConfigException {
|
||||
init();
|
||||
val cfg = Optional.ofNullable(configClass.getAnnotation(Config.class))
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Class " + configClass.getName() + " does not have a @Config annotation!"));
|
||||
val rawConfig = Optional.ofNullable(configs.get(cfg.modid()))
|
||||
.map((conf) -> Optional.ofNullable(configToClassMap.get(conf))
|
||||
.map((l) -> l.contains(configClass))
|
||||
.orElse(false) ? conf : null)
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Tried to get config elements for non-registered config class!"));
|
||||
val category = cfg.category();
|
||||
val elements = new ConfigElement<>(rawConfig.getCategory(category)).getChildElements();
|
||||
return elements.stream().map((element) -> new IConfigElementProxy(element, () -> {
|
||||
try {
|
||||
processConfigInternal(configClass, category, rawConfig);
|
||||
rawConfig.save();
|
||||
} catch (IllegalAccessException |
|
||||
NoSuchMethodException |
|
||||
InvocationTargetException |
|
||||
NoSuchFieldException |
|
||||
ConfigException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
})).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static File minecraftHome() {
|
||||
return Launch.minecraftHome != null ? Launch.minecraftHome : new File(".");
|
||||
}
|
||||
|
||||
private static void init() {
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
configDir = minecraftHome().toPath().resolve("config");
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal, do not use.
|
||||
*/
|
||||
public static void registerBus() {
|
||||
FMLCommonHandler.instance().bus().register(instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal, do not use.
|
||||
*
|
||||
* @param event The event.
|
||||
*/
|
||||
@SubscribeEvent
|
||||
public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) {
|
||||
init();
|
||||
val config = configs.get(event.modID);
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
val configClasses = configToClassMap.get(config);
|
||||
configClasses.forEach((configClass) -> {
|
||||
try {
|
||||
val category = Optional.ofNullable(configClass.getAnnotation(Config.class))
|
||||
.map(Config::category)
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Failed to get config category for class " + configClass.getName()));
|
||||
processConfigInternal(configClass, category, config);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,158 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import cpw.mods.fml.client.config.ConfigGuiType;
|
||||
import cpw.mods.fml.client.config.GuiConfigEntries;
|
||||
import cpw.mods.fml.client.config.GuiEditArrayEntries;
|
||||
import cpw.mods.fml.client.config.IConfigElement;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class IConfigElementProxy<T> implements IConfigElement<T> {
|
||||
private final IConfigElement<T> proxied;
|
||||
private final Runnable onUpdate;
|
||||
|
||||
public IConfigElementProxy(IConfigElement<T> proxied, Runnable onUpdate) {
|
||||
this.proxied = proxied;
|
||||
this.onUpdate = onUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProperty() {
|
||||
return proxied.isProperty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Class<? extends GuiConfigEntries.IConfigEntry> getConfigEntryClass() {
|
||||
return proxied.getConfigEntryClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiEditArrayEntries.IArrayEntry> getArrayEntryClass() {
|
||||
return proxied.getArrayEntryClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return proxied.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getQualifiedName() {
|
||||
return proxied.getQualifiedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguageKey() {
|
||||
return proxied.getLanguageKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComment() {
|
||||
return proxied.getComment();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public List<IConfigElement> getChildElements() {
|
||||
return proxied.getChildElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigGuiType getType() {
|
||||
return proxied.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isList() {
|
||||
return proxied.isList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isListLengthFixed() {
|
||||
return proxied.isListLengthFixed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxListLength() {
|
||||
return proxied.getMaxListLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefault() {
|
||||
return proxied.isDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getDefault() {
|
||||
return proxied.getDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getDefaults() {
|
||||
return proxied.getDefaults();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToDefault() {
|
||||
proxied.setToDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresWorldRestart() {
|
||||
return proxied.requiresWorldRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showInGui() {
|
||||
return proxied.showInGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresMcRestart() {
|
||||
return proxied.requiresMcRestart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get() {
|
||||
return proxied.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getList() {
|
||||
return proxied.getList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(T value) {
|
||||
proxied.set(value);
|
||||
onUpdate.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(T[] aVal) {
|
||||
proxied.set(aVal);
|
||||
onUpdate.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getValidValues() {
|
||||
return proxied.getValidValues();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getMinValue() {
|
||||
return proxied.getMinValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getMaxValue() {
|
||||
return proxied.getMaxValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern getValidationPattern() {
|
||||
return proxied.getValidationPattern();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import cpw.mods.fml.client.config.GuiConfig;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class SimpleGuiConfig extends GuiConfig {
|
||||
public SimpleGuiConfig(GuiScreen parent, Class<?> configClass, String modID, String modName) throws ConfigException {
|
||||
super(parent, ConfigurationManager.getConfigElements(configClass), modID, false, false, modName + " Configuration");
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface SimpleGuiFactory extends IModGuiFactory {
|
||||
@Override
|
||||
default void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
default Set<RuntimeOptionCategoryElement> runtimeGuiCategories() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
default RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.glsm.stacks.IStateStack;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class Feature {
|
||||
private static final int[] supportedAttribs = new int[] { GL11.GL_ACCUM_BUFFER_BIT, GL11.GL_COLOR_BUFFER_BIT, GL11.GL_CURRENT_BIT, GL11.GL_DEPTH_BUFFER_BIT,
|
||||
GL11.GL_ENABLE_BIT, GL11.GL_EVAL_BIT, GL11.GL_FOG_BIT, GL11.GL_HINT_BIT, GL11.GL_LIGHTING_BIT, GL11.GL_LINE_BIT, GL11.GL_LIST_BIT,
|
||||
GL13.GL_MULTISAMPLE_BIT, GL11.GL_PIXEL_MODE_BIT, GL11.GL_POINT_BIT, GL11.GL_POLYGON_BIT, GL11.GL_POLYGON_STIPPLE_BIT, GL11.GL_SCISSOR_BIT,
|
||||
GL11.GL_STENCIL_BUFFER_BIT, GL11.GL_TEXTURE_BIT, GL11.GL_TRANSFORM_BIT, GL11.GL_VIEWPORT_BIT };
|
||||
|
||||
static final Int2ObjectMap<Set<IStateStack<?>>> maskToFeaturesMap = new Int2ObjectOpenHashMap<>();
|
||||
|
||||
static 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));
|
||||
}
|
||||
}
|
||||
maskToFeaturesMap.put(mask, features);
|
||||
return features;
|
||||
}
|
||||
|
||||
private static final Map<Integer, Set<IStateStack<?>>> attribToFeatures = new HashMap<>();
|
||||
static {
|
||||
attribToFeatures.put(GL11.GL_COLOR_BUFFER_BIT, ImmutableSet.of(
|
||||
GLStateManager.alphaTest // GL_ALPHA_TEST enable bit
|
||||
, GLStateManager.alphaState // Alpha test function and reference value
|
||||
, GLStateManager.blendMode // GL_BLEND enable bit
|
||||
, GLStateManager.blendState // Blending source and destination functions
|
||||
// Constant blend color
|
||||
// Blending equation
|
||||
// GL_DITHER enable bit
|
||||
// GL_DRAW_BUFFER setting
|
||||
// GL_COLOR_LOGIC_OP enable bit
|
||||
// GL_INDEX_LOGIC_OP enable bit
|
||||
// Logic op function
|
||||
, GLStateManager.colorMask // Color mode and index mode writemasks
|
||||
, GLStateManager.color // Color mode and index mode writemasks
|
||||
, GLStateManager.clearColor // Color mode and index mode clear values
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_CURRENT_BIT, ImmutableSet.of(
|
||||
// Current RGBA color
|
||||
// Current color index
|
||||
// Current normal vector
|
||||
// Current texture coordinates
|
||||
// Current raster position
|
||||
// GL_CURRENT_RASTER_POSITION_VALID flag
|
||||
// RGBA color associated with current raster position
|
||||
// Color index associated with current raster position
|
||||
// Texture coordinates associated with current raster position
|
||||
// GL_EDGE_FLAG flag
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_DEPTH_BUFFER_BIT, ImmutableSet.of(
|
||||
GLStateManager.depthTest // GL_DEPTH_TEST enable bit
|
||||
, GLStateManager.depthState // Depth buffer test function
|
||||
// Depth buffer clear value
|
||||
// GL_DEPTH_WRITEMASK enable bit
|
||||
));
|
||||
|
||||
final HashSet<IStateStack<?>> enableBits = new HashSet<>(ImmutableSet.of(
|
||||
GLStateManager.alphaTest // GL_ALPHA_TEST flag
|
||||
// GL_AUTO_NORMAL flag
|
||||
, GLStateManager.blendMode // GL_BLEND flag
|
||||
// Enable bits for the user-definable clipping planes
|
||||
// GL_COLOR_MATERIAL
|
||||
, GLStateManager.cullState // GL_CULL_FACE flag
|
||||
, GLStateManager.depthTest // GL_DEPTH_TEST flag
|
||||
// GL_DITHER flag
|
||||
, GLStateManager.fogMode // GL_FOG flag
|
||||
// GL_LIGHTi where 0 <= i < GL_MAX_LIGHTS
|
||||
// GL_LIGHTING flag
|
||||
// GL_LINE_SMOOTH flag
|
||||
// GL_LINE_STIPPLE flag
|
||||
// GL_INDEX_LOGIC_OP flag
|
||||
// GL_COLOR_LOGIC_OP flag
|
||||
// GL_MAP1_x where x is a map type
|
||||
// GL_MAP2_x where x is a map type
|
||||
// GL_MULTISAMPLE flag
|
||||
// GL_NORMALIZE flag
|
||||
// GL_POINT_SMOOTH flag
|
||||
// GL_POLYGON_OFFSET_LINE flag
|
||||
// GL_POLYGON_OFFSET_FILL flag
|
||||
// GL_POLYGON_OFFSET_POINT flag
|
||||
// GL_POLYGON_SMOOTH flag
|
||||
// GL_POLYGON_STIPPLE flag
|
||||
// GL_SAMPLE_ALPHA_TO_COVERAGE flag
|
||||
// GL_SAMPLE_ALPHA_TO_ONE flag
|
||||
// GL_SAMPLE_COVERAGE flag
|
||||
// GL_SCISSOR_TEST flag
|
||||
// GL_STENCIL_TEST flag
|
||||
// GL_TEXTURE_1D flag
|
||||
// GL_TEXTURE_2D flag - Below
|
||||
// GL_TEXTURE_3D flag
|
||||
// Flags GL_TEXTURE_GEN_x where x is S, T, R, or Q
|
||||
));
|
||||
|
||||
// GL_TEXTURE_2D flag
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
enableBits.add(GLStateManager.textures.getTextureUnitStates(i));
|
||||
}
|
||||
|
||||
attribToFeatures.put(GL11.GL_ENABLE_BIT, enableBits);
|
||||
attribToFeatures.put(GL11.GL_EVAL_BIT, ImmutableSet.of(
|
||||
// GL_MAP1_x enable bits, where x is a map type
|
||||
// GL_MAP2_x enable bits, where x is a map type
|
||||
// 1D grid endpoints and divisions
|
||||
// 2D grid endpoints and divisions
|
||||
// GL_AUTO_NORMAL enable bit
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_FOG_BIT, ImmutableSet.of(
|
||||
GLStateManager.fogMode // GL_FOG enable bit
|
||||
, GLStateManager.fogState // Fog color
|
||||
// ^^ Fog density
|
||||
// ^^ Linear fog start
|
||||
// ^^ Linear fog end
|
||||
// Fog index
|
||||
// ^^ GL_FOG_MODE value
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_HINT_BIT, ImmutableSet.of(
|
||||
// GL_PERSPECTIVE_CORRECTION_HINT setting
|
||||
// GL_POINT_SMOOTH_HINT setting
|
||||
// GL_LINE_SMOOTH_HINT setting
|
||||
// GL_POLYGON_SMOOTH_HINT setting
|
||||
// GL_FOG_HINT setting
|
||||
// GL_GENERATE_MIPMAP_HINT setting
|
||||
// GL_TEXTURE_COMPRESSION_HINT setting
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_LIGHTING_BIT, ImmutableSet.of(
|
||||
// GL_COLOR_MATERIAL enable bit
|
||||
// GL_COLOR_MATERIAL_FACE value
|
||||
// Color material parameters that are tracking the current color
|
||||
// Ambient scene color
|
||||
// GL_LIGHT_MODEL_LOCAL_VIEWER value
|
||||
// GL_LIGHT_MODEL_TWO_SIDE setting
|
||||
// GL_LIGHTING enable bit
|
||||
// Enable bit for each light
|
||||
// Ambient, diffuse, and specular intensity for each light
|
||||
// Direction, position, exponent, and cutoff angle for each light
|
||||
// Constant, linear, and quadratic attenuation factors for each light
|
||||
// Ambient, diffuse, specular, and emissive color for each material
|
||||
// Ambient, diffuse, and specular color indices for each material
|
||||
// Specular exponent for each material
|
||||
// GL_SHADE_MODEL setting
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_LINE_BIT, ImmutableSet.of(
|
||||
// GL_LINE_SMOOTH flag
|
||||
// GL_LINE_STIPPLE enable bit
|
||||
// Line stipple pattern and repeat counter
|
||||
// Line width
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_LIST_BIT, ImmutableSet.of(
|
||||
// GL_LIST_BASE setting
|
||||
));
|
||||
attribToFeatures.put(GL13.GL_MULTISAMPLE_BIT, ImmutableSet.of(
|
||||
// GL_MULTISAMPLE enable bit
|
||||
// GL_SAMPLE_ALPHA_TO_COVERAGE flag
|
||||
// GL_SAMPLE_ALPHA_TO_ONE flag
|
||||
// GL_SAMPLE_COVERAGE flag
|
||||
// GL_SAMPLE_COVERAGE_VALUE value
|
||||
// GL_SAMPLE_COVERAGE_INVERT value
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_PIXEL_MODE_BIT, ImmutableSet.of(
|
||||
// GL_RED_BIAS and GL_RED_SCALE settings
|
||||
// GL_GREEN_BIAS and GL_GREEN_SCALE values
|
||||
// GL_BLUE_BIAS and GL_BLUE_SCALE
|
||||
// GL_ALPHA_BIAS and GL_ALPHA_SCALE
|
||||
// GL_DEPTH_BIAS and GL_DEPTH_SCALE
|
||||
// GL_INDEX_OFFSET and GL_INDEX_SHIFT values
|
||||
// GL_MAP_COLOR and GL_MAP_STENCIL flags
|
||||
// GL_ZOOM_X and GL_ZOOM_Y factors
|
||||
// GL_READ_BUFFER setting
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_POINT_BIT, ImmutableSet.of(
|
||||
// GL_POINT_SMOOTH flag
|
||||
// Point size
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_POLYGON_BIT, ImmutableSet.of(
|
||||
GLStateManager.cullState // GL_CULL_FACE enable bit
|
||||
// GL_CULL_FACE_MODE value
|
||||
// GL_FRONT_FACE indicator
|
||||
// GL_POLYGON_MODE setting
|
||||
// GL_POLYGON_SMOOTH flag
|
||||
// GL_POLYGON_STIPPLE enable bit
|
||||
// GL_POLYGON_OFFSET_FILL flag
|
||||
// GL_POLYGON_OFFSET_LINE flag
|
||||
// GL_POLYGON_OFFSET_POINT flag
|
||||
// GL_POLYGON_OFFSET_FACTOR
|
||||
// GL_POLYGON_OFFSET_UNITS
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_POLYGON_STIPPLE_BIT, ImmutableSet.of(
|
||||
// Polygon stipple pattern
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_SCISSOR_BIT, ImmutableSet.of(
|
||||
// GL_SCISSOR_TEST enable bit
|
||||
// Scissor box
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_STENCIL_BUFFER_BIT, ImmutableSet.of(
|
||||
// GL_STENCIL_TEST enable bit
|
||||
// Stencil function and reference value
|
||||
// Stencil value mask
|
||||
// Stencil fail, pass, and depth buffer pass actions
|
||||
// Stencil buffer clear value
|
||||
// Stencil buffer writemask
|
||||
));
|
||||
final Set<IStateStack<?>> textureAttribs = new HashSet<>(ImmutableSet.of(
|
||||
// Enable bits for the four texture coordinates
|
||||
// Border color for each texture image
|
||||
// Minification function for each texture image
|
||||
// Magnification function for each texture image
|
||||
// Texture coordinates and wrap mode for each texture image
|
||||
// Color and mode for each texture environment
|
||||
// Enable bits GL_TEXTURE_GEN_x, x is S, T, R, and Q
|
||||
// GL_TEXTURE_GEN_MODE setting for S, T, R, and Q
|
||||
// glTexGen plane equations for S, T, R, and Q
|
||||
// Current texture bindings (for example, GL_TEXTURE_BINDING_2D) - Below
|
||||
));
|
||||
|
||||
// Current Texture Bindings - GL_TEXTURE_BINDING_2D
|
||||
for(int i = 0 ; i < GLStateManager.MAX_TEXTURE_UNITS; i++) {
|
||||
textureAttribs.add(GLStateManager.textures.getTextureUnitBindings(i));
|
||||
}
|
||||
|
||||
attribToFeatures.put(GL11.GL_TEXTURE_BIT, textureAttribs);
|
||||
attribToFeatures.put(GL11.GL_TRANSFORM_BIT, ImmutableSet.of(
|
||||
// Coefficients of the six clipping planes
|
||||
// Enable bits for the user-definable clipping planes
|
||||
GLStateManager.matrixMode
|
||||
// GL_NORMALIZE flag
|
||||
// GL_RESCALE_NORMAL flag
|
||||
));
|
||||
attribToFeatures.put(GL11.GL_VIEWPORT_BIT, ImmutableSet.of(
|
||||
// Depth range (near and far)
|
||||
GLStateManager.viewportState
|
||||
));
|
||||
}
|
||||
|
||||
public static Set<IStateStack<?>> getFeatures(int attrib) {
|
||||
return attribToFeatures.getOrDefault(attrib, Collections.emptySet());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,362 +0,0 @@
|
||||
/*
|
||||
* Copyright LWJGL. All rights reserved. Modified by IMS for use in Iris (net.coderbot.iris.gl).
|
||||
* License terms: https://www.lwjgl.org/license
|
||||
*/
|
||||
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import org.lwjgl.opengl.AMDDebugOutput;
|
||||
import org.lwjgl.opengl.AMDDebugOutputCallback;
|
||||
import org.lwjgl.opengl.ARBDebugOutput;
|
||||
import org.lwjgl.opengl.ARBDebugOutputCallback;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
import org.lwjgl.opengl.KHRDebugCallback;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
import static org.lwjgl.opengl.ARBDebugOutput.glDebugMessageCallbackARB;
|
||||
|
||||
public final class GLDebug {
|
||||
/**
|
||||
* Sets up debug callbacks
|
||||
* @return 0 for failure, 1 for success, 2 for restart required.
|
||||
*/
|
||||
public static int setupDebugMessageCallback() {
|
||||
if (Thread.currentThread() != GLStateManager.getMainThread()) {
|
||||
LOGGER.warn("setupDebugMessageCallback called from non-main thread!");
|
||||
return 0;
|
||||
}
|
||||
return setupDebugMessageCallback(System.err);
|
||||
}
|
||||
|
||||
private static void trace(Consumer<String> output) {
|
||||
/*
|
||||
* We can not just use a fixed stacktrace element offset, because some methods
|
||||
* are intercepted and some are not. So, check the package name.
|
||||
*/
|
||||
StackTraceElement[] elems = filterStackTrace(new Throwable(), 4).getStackTrace();
|
||||
for (StackTraceElement ste : elems) {
|
||||
output.accept(ste.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static Throwable filterStackTrace(Throwable throwable, int offset) {
|
||||
StackTraceElement[] elems = throwable.getStackTrace();
|
||||
StackTraceElement[] filtered = new StackTraceElement[elems.length];
|
||||
int j = 0;
|
||||
for (int i = offset; i < elems.length; i++) {
|
||||
String className = elems[i].getClassName();
|
||||
if (className == null) {
|
||||
className = "";
|
||||
}
|
||||
filtered[j++] = elems[i];
|
||||
}
|
||||
StackTraceElement[] newElems = new StackTraceElement[j];
|
||||
System.arraycopy(filtered, 0, newElems, 0, j);
|
||||
throwable.setStackTrace(newElems);
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public static void printTrace(PrintStream stream) {
|
||||
trace(new Consumer<String>() {
|
||||
boolean first = true;
|
||||
|
||||
public void accept(String str) {
|
||||
if (first) {
|
||||
printDetail(stream, "Stacktrace", str);
|
||||
first = false;
|
||||
} else {
|
||||
printDetailLine(stream, "Stacktrace", str);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up debug callbacks
|
||||
* @return 0 for failure, 1 for success, 2 for restart required.
|
||||
*/
|
||||
public static int setupDebugMessageCallback(PrintStream stream) {
|
||||
if (GLStateManager.capabilities.OpenGL43 || GLStateManager.capabilities.GL_KHR_debug) {
|
||||
LOGGER.info("[GL] Using OpenGL 4.3 for error logging.");
|
||||
KHRDebugCallback proc = new KHRDebugCallback((source, type, id, severity, message) -> {
|
||||
stream.println("[LWJGL] OpenGL debug message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
printDetail(stream, "Source", getDebugSource(source));
|
||||
printDetail(stream, "Type", getDebugType(type));
|
||||
printDetail(stream, "Severity", getDebugSeverity(severity));
|
||||
printDetail(stream, "Message", message);
|
||||
printTrace(stream);
|
||||
});
|
||||
GL43.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_HIGH, null, true);
|
||||
GL43.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_MEDIUM, null, false);
|
||||
GL43.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_LOW, null, false);
|
||||
GL43.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_NOTIFICATION, null, false);
|
||||
GL43.glDebugMessageCallback(proc);
|
||||
|
||||
if ((GL11.glGetInteger(GL30.GL_CONTEXT_FLAGS) & GL43.GL_CONTEXT_FLAG_DEBUG_BIT) == 0) {
|
||||
LOGGER.warn("[GL] Warning: A non-debug context may not produce any debug output.");
|
||||
GL11.glEnable(GL43.GL_DEBUG_OUTPUT);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_ARB_debug_output) {
|
||||
LOGGER.info("[GL] Using ARB_debug_output for error logging.");
|
||||
ARBDebugOutputCallback proc = new ARBDebugOutputCallback((source, type, id, severity, message) -> {
|
||||
stream.println("[LWJGL] ARB_debug_output message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
printDetail(stream, "Source", getSourceARB(source));
|
||||
printDetail(stream, "Type", getTypeARB(type));
|
||||
printDetail(stream, "Severity", getSeverityARB(severity));
|
||||
printDetail(stream, "Message", message);
|
||||
printTrace(stream);
|
||||
});
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_HIGH, null, true);
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_MEDIUM, null, false);
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_LOW, null, false);
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_NOTIFICATION, null, false);
|
||||
ARBDebugOutput.glDebugMessageCallbackARB(proc);
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_AMD_debug_output) {
|
||||
LOGGER.info("[GL] Using AMD_debug_output for error logging.");
|
||||
AMDDebugOutputCallback proc = new AMDDebugOutputCallback((id, category, severity, message) -> {
|
||||
stream.println("[LWJGL] AMD_debug_output message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
printDetail(stream, "Category", getCategoryAMD(category));
|
||||
printDetail(stream, "Severity", getSeverityAMD(severity));
|
||||
printDetail(stream, "Message", message);
|
||||
printTrace(stream);
|
||||
});
|
||||
AMDDebugOutput.glDebugMessageEnableAMD(0, GL43.GL_DEBUG_SEVERITY_HIGH, null, true);
|
||||
AMDDebugOutput.glDebugMessageEnableAMD(0, GL43.GL_DEBUG_SEVERITY_MEDIUM, null, false);
|
||||
AMDDebugOutput.glDebugMessageEnableAMD(0, GL43.GL_DEBUG_SEVERITY_LOW, null, false);
|
||||
AMDDebugOutput.glDebugMessageEnableAMD(0, GL43.GL_DEBUG_SEVERITY_NOTIFICATION, null, false);
|
||||
AMDDebugOutput.glDebugMessageCallbackAMD(proc);
|
||||
return 1;
|
||||
} else {
|
||||
LOGGER.info("[GL] No debug output implementation is available, cannot return debug info.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int disableDebugMessages() {
|
||||
if (GLStateManager.capabilities.OpenGL43) {
|
||||
GL43.glDebugMessageCallback(null);
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_KHR_debug) {
|
||||
KHRDebug.glDebugMessageCallback(null);
|
||||
if (GLStateManager.capabilities.OpenGL30 && (GL11.glGetInteger(GL30.GL_CONTEXT_FLAGS) & 2) == 0) {
|
||||
GL11.glDisable(GL43.GL_DEBUG_OUTPUT);
|
||||
}
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_ARB_debug_output) {
|
||||
glDebugMessageCallbackARB(null);
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_AMD_debug_output) {
|
||||
AMDDebugOutput.glDebugMessageCallbackAMD(null);
|
||||
return 1;
|
||||
} else {
|
||||
LOGGER.info("[GL] No debug output implementation is available, cannot disable debug info.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static void printDetail(PrintStream stream, String type, String message) {
|
||||
stream.printf("\t%s: %s\n", type, message);
|
||||
}
|
||||
|
||||
private static void printDetailLine(PrintStream stream, String type, String message) {
|
||||
stream.append(" ");
|
||||
for (int i = 0; i < type.length(); i++) {
|
||||
stream.append(" ");
|
||||
}
|
||||
stream.append(message).append("\n");
|
||||
}
|
||||
|
||||
private static String getDebugSource(int source) {
|
||||
return switch (source) {
|
||||
case GL43.GL_DEBUG_SOURCE_API -> "API";
|
||||
case GL43.GL_DEBUG_SOURCE_WINDOW_SYSTEM -> "WINDOW SYSTEM";
|
||||
case GL43.GL_DEBUG_SOURCE_SHADER_COMPILER -> "SHADER COMPILER";
|
||||
case GL43.GL_DEBUG_SOURCE_THIRD_PARTY -> "THIRD PARTY";
|
||||
case GL43.GL_DEBUG_SOURCE_APPLICATION -> "APPLICATION";
|
||||
case GL43.GL_DEBUG_SOURCE_OTHER -> "OTHER";
|
||||
default -> String.format("Unknown [0x%X]", source);
|
||||
};
|
||||
}
|
||||
|
||||
private static String getDebugType(int type) {
|
||||
return switch (type) {
|
||||
case GL43.GL_DEBUG_TYPE_ERROR -> "ERROR";
|
||||
case GL43.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR -> "DEPRECATED BEHAVIOR";
|
||||
case GL43.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR -> "UNDEFINED BEHAVIOR";
|
||||
case GL43.GL_DEBUG_TYPE_PORTABILITY -> "PORTABILITY";
|
||||
case GL43.GL_DEBUG_TYPE_PERFORMANCE -> "PERFORMANCE";
|
||||
case GL43.GL_DEBUG_TYPE_OTHER -> "OTHER";
|
||||
case GL43.GL_DEBUG_TYPE_MARKER -> "MARKER";
|
||||
default -> String.format("Unknown [0x%X]", type);
|
||||
};
|
||||
}
|
||||
|
||||
private static String getDebugSeverity(int severity) {
|
||||
return switch (severity) {
|
||||
case GL43.GL_DEBUG_SEVERITY_NOTIFICATION -> "NOTIFICATION";
|
||||
case GL43.GL_DEBUG_SEVERITY_HIGH -> "HIGH";
|
||||
case GL43.GL_DEBUG_SEVERITY_MEDIUM -> "MEDIUM";
|
||||
case GL43.GL_DEBUG_SEVERITY_LOW -> "LOW";
|
||||
default -> String.format("Unknown [0x%X]", severity);
|
||||
};
|
||||
}
|
||||
|
||||
private static String getSourceARB(int source) {
|
||||
return switch (source) {
|
||||
case ARBDebugOutput.GL_DEBUG_SOURCE_API_ARB -> "API";
|
||||
case ARBDebugOutput.GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB -> "WINDOW SYSTEM";
|
||||
case ARBDebugOutput.GL_DEBUG_SOURCE_SHADER_COMPILER_ARB -> "SHADER COMPILER";
|
||||
case ARBDebugOutput.GL_DEBUG_SOURCE_THIRD_PARTY_ARB -> "THIRD PARTY";
|
||||
case ARBDebugOutput.GL_DEBUG_SOURCE_APPLICATION_ARB -> "APPLICATION";
|
||||
case ARBDebugOutput.GL_DEBUG_SOURCE_OTHER_ARB -> "OTHER";
|
||||
default -> String.format("Unknown [0x%X]", source);
|
||||
};
|
||||
}
|
||||
|
||||
private static String getTypeARB(int type) {
|
||||
return switch (type) {
|
||||
case ARBDebugOutput.GL_DEBUG_TYPE_ERROR_ARB -> "ERROR";
|
||||
case ARBDebugOutput.GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB -> "DEPRECATED BEHAVIOR";
|
||||
case ARBDebugOutput.GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB -> "UNDEFINED BEHAVIOR";
|
||||
case ARBDebugOutput.GL_DEBUG_TYPE_PORTABILITY_ARB -> "PORTABILITY";
|
||||
case ARBDebugOutput.GL_DEBUG_TYPE_PERFORMANCE_ARB -> "PERFORMANCE";
|
||||
case ARBDebugOutput.GL_DEBUG_TYPE_OTHER_ARB -> "OTHER";
|
||||
default -> String.format("Unknown [0x%X]", type);
|
||||
};
|
||||
}
|
||||
|
||||
private static String getSeverityARB(int severity) {
|
||||
return switch (severity) {
|
||||
case ARBDebugOutput.GL_DEBUG_SEVERITY_HIGH_ARB -> "HIGH";
|
||||
case ARBDebugOutput.GL_DEBUG_SEVERITY_MEDIUM_ARB -> "MEDIUM";
|
||||
case ARBDebugOutput.GL_DEBUG_SEVERITY_LOW_ARB -> "LOW";
|
||||
default -> String.format("Unknown [0x%X]", severity);
|
||||
};
|
||||
}
|
||||
|
||||
private static String getCategoryAMD(int category) {
|
||||
return switch (category) {
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_API_ERROR_AMD -> "API ERROR";
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD -> "WINDOW SYSTEM";
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_DEPRECATION_AMD -> "DEPRECATION";
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD -> "UNDEFINED BEHAVIOR";
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_PERFORMANCE_AMD -> "PERFORMANCE";
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD -> "SHADER COMPILER";
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_APPLICATION_AMD -> "APPLICATION";
|
||||
case AMDDebugOutput.GL_DEBUG_CATEGORY_OTHER_AMD -> "OTHER";
|
||||
default -> String.format("Unknown [0x%X]", category);
|
||||
};
|
||||
}
|
||||
|
||||
private static String getSeverityAMD(int severity) {
|
||||
return switch (severity) {
|
||||
case AMDDebugOutput.GL_DEBUG_SEVERITY_HIGH_AMD -> "HIGH";
|
||||
case AMDDebugOutput.GL_DEBUG_SEVERITY_MEDIUM_AMD -> "MEDIUM";
|
||||
case AMDDebugOutput.GL_DEBUG_SEVERITY_LOW_AMD -> "LOW";
|
||||
default -> String.format("Unknown [0x%X]", severity);
|
||||
};
|
||||
}
|
||||
|
||||
private static DebugState debugState;
|
||||
|
||||
private interface DebugState {
|
||||
void nameObject(int id, int object, String name);
|
||||
void pushGroup(String name);
|
||||
void popGroup();
|
||||
void debugMessage(String name);
|
||||
}
|
||||
|
||||
private static class KHRDebugState implements DebugState {
|
||||
private static final int ID = 0;
|
||||
private int depth = 0;
|
||||
private static final int maxDepth = GL11.glGetInteger(KHRDebug.GL_MAX_DEBUG_GROUP_STACK_DEPTH);
|
||||
|
||||
@Override
|
||||
public void nameObject(int id, int object, String name) {
|
||||
KHRDebug.glObjectLabel(id, object, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushGroup(String name) {
|
||||
depth++;
|
||||
if (depth > maxDepth) {
|
||||
throw new RuntimeException("Stack overflow");
|
||||
}
|
||||
KHRDebug.glPushDebugGroup(KHRDebug.GL_DEBUG_SOURCE_APPLICATION, ID, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popGroup() {
|
||||
depth--;
|
||||
if (depth < 0) {
|
||||
throw new RuntimeException("Stack underflow");
|
||||
}
|
||||
KHRDebug.glPopDebugGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugMessage(String message) {
|
||||
KHRDebug.glDebugMessageInsert(KHRDebug.GL_DEBUG_SOURCE_APPLICATION, KHRDebug.GL_DEBUG_TYPE_MARKER, ID, KHRDebug.GL_DEBUG_SEVERITY_NOTIFICATION, message);
|
||||
}
|
||||
}
|
||||
|
||||
private static class UnsupportedDebugState implements DebugState {
|
||||
@Override
|
||||
public void nameObject(int id, int object, String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pushGroup(String name) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popGroup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugMessage(String name) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void initDebugState() {
|
||||
if (GLStateManager.capabilities.GL_KHR_debug || GLStateManager.capabilities.OpenGL43) {
|
||||
debugState = new KHRDebugState();
|
||||
} else {
|
||||
debugState = new UnsupportedDebugState();
|
||||
}
|
||||
}
|
||||
|
||||
public static void nameObject(int id, int object, String name) {
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.nameObject(id, object, name);
|
||||
}
|
||||
}
|
||||
public static void pushGroup(String group) {
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.pushGroup(group);
|
||||
}
|
||||
}
|
||||
public static void popGroup() {
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.popGroup();
|
||||
}
|
||||
}
|
||||
public static void debugMessage(String message) {
|
||||
if(debugState != null && Thread.currentThread() == GLStateManager.getMainThread()) {
|
||||
debugState.debugMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,274 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.dsa.DSAARB;
|
||||
import com.gtnewhorizons.angelica.glsm.dsa.DSAAccess;
|
||||
import com.gtnewhorizons.angelica.glsm.dsa.DSACore;
|
||||
import com.gtnewhorizons.angelica.glsm.dsa.DSAUnsupported;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3i;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.EXTShaderImageLoadStore;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
/**
|
||||
* This class is responsible for abstracting calls to OpenGL and asserting that calls are run on the render thread.
|
||||
*/
|
||||
public class RenderSystem {
|
||||
private static DSAAccess dsaState;
|
||||
private static boolean hasMultibind;
|
||||
private static boolean supportsCompute;
|
||||
|
||||
private RenderSystem() {}
|
||||
|
||||
public static void initRenderer() {
|
||||
try {
|
||||
if (GLStateManager.capabilities.OpenGL45) {
|
||||
dsaState = new DSACore();
|
||||
LOGGER.info("OpenGL 4.5 detected, enabling DSA.");
|
||||
}
|
||||
hasMultibind = GLStateManager.capabilities.OpenGL45;
|
||||
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
try {
|
||||
if (dsaState == null && GLStateManager.capabilities.GL_ARB_direct_state_access) {
|
||||
dsaState = new DSAARB();
|
||||
LOGGER.info("ARB_direct_state_access detected, enabling DSA.");
|
||||
}
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
if (dsaState == null) {
|
||||
dsaState = new DSAUnsupported();
|
||||
}
|
||||
|
||||
try {
|
||||
hasMultibind |= GLStateManager.capabilities.GL_ARB_multi_bind;
|
||||
} catch (NoSuchFieldError ignored) {}
|
||||
|
||||
supportsCompute = supportsCompute();
|
||||
}
|
||||
|
||||
public static void generateMipmaps(int texture, int mipmapTarget) {
|
||||
dsaState.generateMipmaps(texture, mipmapTarget);
|
||||
}
|
||||
|
||||
public static void bindAttributeLocation(int program, int index, CharSequence name) {
|
||||
GL20.glBindAttribLocation(program, index, name);
|
||||
}
|
||||
|
||||
public static void texImage2D(int texture, int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable ByteBuffer pixels) {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
GLStateManager.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
}
|
||||
|
||||
public static void uniformMatrix4fv(int location, boolean transpose, FloatBuffer matrix) {
|
||||
GL20.glUniformMatrix4(location, transpose, matrix);
|
||||
}
|
||||
|
||||
public static void copyTexImage2D(int target, int level, int internalFormat, int x, int y, int width, int height, int border) {
|
||||
GL11.glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border);
|
||||
}
|
||||
|
||||
public static void uniform1f(int location, float v0) {
|
||||
GL20.glUniform1f(location, v0);
|
||||
}
|
||||
|
||||
public static void uniform1i(int location, int v0) {
|
||||
GL20.glUniform1i(location, v0);
|
||||
}
|
||||
|
||||
public static void uniform2f(int location, float v0, float v1) {
|
||||
GL20.glUniform2f(location, v0, v1);
|
||||
}
|
||||
|
||||
public static void uniform2i(int location, int v0, int v1) {
|
||||
GL20.glUniform2i(location, v0, v1);
|
||||
}
|
||||
|
||||
public static void uniform3f(int location, float v0, float v1, float v2) {
|
||||
GL20.glUniform3f(location, v0, v1, v2);
|
||||
}
|
||||
|
||||
public static void uniform4f(int location, float v0, float v1, float v2, float v3) {
|
||||
GL20.glUniform4f(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
public static void uniform4i(int location, int v0, int v1, int v2, int v3) {
|
||||
GL20.glUniform4i(location, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
public static int getAttribLocation(int programId, String name) {
|
||||
return GL20.glGetAttribLocation(programId, name);
|
||||
}
|
||||
|
||||
public static int getUniformLocation(int programId, String name) {
|
||||
return GL20.glGetUniformLocation(programId, name);
|
||||
}
|
||||
|
||||
public static void texParameteriv(int texture, int target, int pname, IntBuffer params) {
|
||||
dsaState.texParameteriv(texture, target, pname, params);
|
||||
}
|
||||
|
||||
public static void copyTexSubImage2D(int destTexture, int target, int i, int i1, int i2, int i3, int i4, int width, int height) {
|
||||
dsaState.copyTexSubImage2D(destTexture, target, i, i1, i2, i3, i4, width, height);
|
||||
}
|
||||
|
||||
public static void texParameteri(int texture, int target, int pname, int param) {
|
||||
dsaState.texParameteri(texture, target, pname, param);
|
||||
}
|
||||
|
||||
public static void texParameterf(int texture, int target, int pname, float param) {
|
||||
dsaState.texParameterf(texture, target, pname, param);
|
||||
}
|
||||
|
||||
public static String getProgramInfoLog(int program) {
|
||||
return GL20.glGetProgramInfoLog(program, GL20.glGetProgrami(program, GL20.GL_INFO_LOG_LENGTH));
|
||||
}
|
||||
|
||||
public static String getShaderInfoLog(int shader) {
|
||||
return GL20.glGetShaderInfoLog(shader, GL20.glGetShaderi(shader, GL20.GL_INFO_LOG_LENGTH));
|
||||
}
|
||||
|
||||
public static void drawBuffers(int framebuffer, IntBuffer buffers) {
|
||||
dsaState.drawBuffers(framebuffer, buffers);
|
||||
}
|
||||
|
||||
public static void readBuffer(int framebuffer, int buffer) {
|
||||
dsaState.readBuffer(framebuffer, buffer);
|
||||
}
|
||||
|
||||
public static String getActiveUniform(int program, int index, int maxLength, IntBuffer sizeType) {
|
||||
return GL20.glGetActiveUniform(program, index, maxLength, sizeType);
|
||||
}
|
||||
|
||||
public static void readPixels(int x, int y, int width, int height, int format, int type, FloatBuffer pixels) {
|
||||
GL11.glReadPixels(x, y, width, height, format, type, pixels);
|
||||
}
|
||||
|
||||
public static void bufferData(int target, FloatBuffer data, int usage) {
|
||||
GL15.glBufferData(target, data, usage);
|
||||
}
|
||||
|
||||
public static int bufferStorage(int target, FloatBuffer data, int usage) {
|
||||
return dsaState.bufferStorage(target, data, usage);
|
||||
}
|
||||
|
||||
public static void vertexAttrib4f(int index, float v0, float v1, float v2, float v3) {
|
||||
GL20.glVertexAttrib4f(index, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
public static void detachShader(int program, int shader) {
|
||||
GL20.glDetachShader(program, shader);
|
||||
}
|
||||
|
||||
public static void framebufferTexture2D(int fb, int fbtarget, int attachment, int target, int texture, int levels) {
|
||||
dsaState.framebufferTexture2D(fb, fbtarget, attachment, target, texture, levels);
|
||||
}
|
||||
|
||||
public static int getTexParameteri(int texture, int target, int pname) {
|
||||
return dsaState.getTexParameteri(texture, target, pname);
|
||||
}
|
||||
|
||||
public static void bindImageTexture(int unit, int texture, int level, boolean layered, int layer, int access, int format) {
|
||||
if (GLStateManager.capabilities.OpenGL42) {
|
||||
GL42.glBindImageTexture(unit, texture, level, layered, layer, access, format);
|
||||
} else {
|
||||
EXTShaderImageLoadStore.glBindImageTextureEXT(unit, texture, level, layered, layer, access, format);
|
||||
}
|
||||
}
|
||||
|
||||
public static int getMaxImageUnits() {
|
||||
if (GLStateManager.capabilities.OpenGL42) {
|
||||
return GL11.glGetInteger(GL42.GL_MAX_IMAGE_UNITS);
|
||||
} else if (GLStateManager.capabilities.GL_EXT_shader_image_load_store) {
|
||||
return GL11.glGetInteger(EXTShaderImageLoadStore.GL_MAX_IMAGE_UNITS_EXT);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static void getProgramiv(int program, int value, IntBuffer storage) {
|
||||
GL20.glGetProgram(program, value, storage);
|
||||
}
|
||||
|
||||
public static void dispatchCompute(int workX, int workY, int workZ) {
|
||||
GL43.glDispatchCompute(workX, workY, workZ);
|
||||
}
|
||||
|
||||
public static void dispatchCompute(Vector3i workGroups) {
|
||||
GL43.glDispatchCompute(workGroups.x, workGroups.y, workGroups.z);
|
||||
}
|
||||
|
||||
public static void memoryBarrier(int barriers) {
|
||||
if (supportsCompute) {
|
||||
GL42.glMemoryBarrier(barriers);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean supportsBufferBlending() {
|
||||
return GLStateManager.capabilities.GL_ARB_draw_buffers_blend || GLStateManager.capabilities.OpenGL40;
|
||||
}
|
||||
|
||||
public static void disableBufferBlend(int buffer) {
|
||||
GL30.glDisablei(GL11.GL_BLEND, buffer);
|
||||
}
|
||||
|
||||
public static void enableBufferBlend(int buffer) {
|
||||
GL30.glEnablei(GL11.GL_BLEND, buffer);
|
||||
}
|
||||
|
||||
public static void blendFuncSeparatei(int buffer, int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
|
||||
GL40.glBlendFuncSeparatei(buffer, srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
public static void bindTextureToUnit(int unit, int texture) {
|
||||
dsaState.bindTextureToUnit(unit, texture);
|
||||
}
|
||||
|
||||
public static FloatBuffer PROJECTION_MATRIX_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
public static void setupProjectionMatrix(Matrix4f matrix) {
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glPushMatrix();
|
||||
matrix.get(0, PROJECTION_MATRIX_BUFFER);
|
||||
GL11.glLoadMatrix(PROJECTION_MATRIX_BUFFER);
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
public static void restoreProjectionMatrix() {
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glPopMatrix();
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
public static void blitFramebuffer(int source, int dest, int offsetX, int offsetY, int width, int height, int offsetX2, int offsetY2, int width2, int height2, int bufferChoice, int filter) {
|
||||
dsaState.blitFramebuffer(source, dest, offsetX, offsetY, width, height, offsetX2, offsetY2, width2, height2, bufferChoice, filter);
|
||||
}
|
||||
|
||||
public static int createFramebuffer() {
|
||||
return dsaState.createFramebuffer();
|
||||
}
|
||||
|
||||
public static int createTexture(int target) {
|
||||
return dsaState.createTexture(target);
|
||||
}
|
||||
|
||||
// TODO: Proper notification of compute support
|
||||
public static boolean supportsCompute() {
|
||||
try {
|
||||
return GLStateManager.capabilities.GL_ARB_compute_shader;
|
||||
} catch(Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.glsm;
|
||||
|
||||
import com.gtnewhorizons.angelica.client.renderer.CapturingTessellator;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexBuffer;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.nd.Quad;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class TessellatorManager {
|
||||
private static final ThreadLocal<CapturingTessellator> capturingTessellator = ThreadLocal.withInitial(CapturingTessellator::new);
|
||||
|
||||
private static final ThreadLocal<Boolean> currentlyCapturing = ThreadLocal.withInitial(() -> Boolean.FALSE);
|
||||
private static final Thread mainThread = Thread.currentThread();
|
||||
|
||||
public static Tessellator get() {
|
||||
if(currentlyCapturing.get()) {
|
||||
return capturingTessellator.get();
|
||||
} else if(isOnMainThread()) {
|
||||
return Tessellator.instance;
|
||||
} else {
|
||||
// TODO: Verify this works correctly and nothing unexpected is grabbing a tessellator off the main thread
|
||||
// when not capturing
|
||||
throw new IllegalStateException("Tried to get the Tessellator off the main thread when not capturing!");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isOnMainThread() {
|
||||
return Thread.currentThread() == mainThread;
|
||||
}
|
||||
|
||||
public static boolean isMainInstance(Object instance) {
|
||||
return instance == Tessellator.instance || isOnMainThread();
|
||||
}
|
||||
|
||||
public static void startCapturing() {
|
||||
if(currentlyCapturing.get()) throw new IllegalStateException("Tried to start capturing when already capturing!");
|
||||
final CapturingTessellator tess = capturingTessellator.get();
|
||||
if(tess.getQuads().size() > 0) throw new IllegalStateException("Tried to start capturing with existing collected Quads!");
|
||||
tess.storeTranslation();
|
||||
|
||||
currentlyCapturing.set(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop the CapturingTessellator and return the pooled quads. The quads are valid until clearQuads() is
|
||||
* called on the CapturingTesselator, which must be done before starting capturing again.
|
||||
*/
|
||||
public static List<Quad> stopCapturingToPooledQuads() {
|
||||
if(!currentlyCapturing.get()) throw new IllegalStateException("Tried to stop capturing when not capturing!");
|
||||
currentlyCapturing.set(false);
|
||||
final CapturingTessellator tess = capturingTessellator.get();
|
||||
|
||||
// Be sure we got all the quads
|
||||
if(tess.isDrawing) tess.draw();
|
||||
|
||||
final List<Quad> quads = tess.getQuads();
|
||||
tess.discard();
|
||||
tess.restoreTranslation();
|
||||
|
||||
return quads;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stops the CapturingTessellator, stores the quads in a buffer (based on the VertexFormat provided),
|
||||
* and clears the quads.
|
||||
*/
|
||||
public static ByteBuffer stopCapturingToBuffer(VertexFormat format) {
|
||||
final ByteBuffer buf = CapturingTessellator.quadsToBuffer(stopCapturingToPooledQuads(), format);
|
||||
capturingTessellator.get().clearQuads();
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Stops the CapturingTessellator, stores the quads in a buffer (based on the VertexFormat provided),
|
||||
* uploads the buffer to a new VertexBuffer, and clears the quads.
|
||||
*/
|
||||
public static VertexBuffer stopCapturingToVBO(VertexFormat format) {
|
||||
return new VertexBuffer(format, GL11.GL_QUADS).upload(stopCapturingToBuffer(format));
|
||||
}
|
||||
|
||||
static {
|
||||
System.out.println("[TessellatorManager] Initialized on thread " + mainThread.getName());
|
||||
}
|
||||
|
||||
public static void cleanup() {
|
||||
// Ensure we've cleaned everything up
|
||||
final CapturingTessellator tessellator = capturingTessellator.get();
|
||||
|
||||
currentlyCapturing.set(false);
|
||||
tessellator.discard();
|
||||
tessellator.clearQuads();
|
||||
}
|
||||
}
|
||||
Loaded 100 of 1241 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user