Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
1.21.3 supports.
Browse files Browse the repository at this point in the history
  • Loading branch information
toxicity188 committed Nov 3, 2024
1 parent 9b4e419 commit 7b61c3b
Show file tree
Hide file tree
Showing 28 changed files with 1,748 additions and 62 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ bin/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store

### Minecraft ###
run/
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 64 additions & 46 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
plugins {
`java-library`
kotlin("jvm") version "1.9.23"
id("com.github.johnrengelman.shadow") version("8.1.1")
id("io.papermc.paperweight.userdev") version "1.5.15" apply false
kotlin("jvm") version "2.0.21"
id("io.github.goooler.shadow") version "8.1.8"
id("io.papermc.paperweight.userdev") version "1.7.4" apply false
id("xyz.jpenilla.run-paper") version "2.3.1"
}

val api = project(":api")
val dist = project(":dist")
val scheduler = project(":scheduler")

val minecraftVersion = "1.20.4"
val adventureVersion = "4.16.0"
val platformVersion = "4.3.2"
val minecraftVersion = "1.21.3"
val adventureVersion = "4.17.0"
val platformVersion = "4.3.4"

val nmsVersions = listOf(
"v1_19_R3",
"v1_20_R1",
"v1_20_R2",
"v1_20_R3"
)

val shadedDependencies = listOf(
"com.ticxo.playeranimator:PlayerAnimator:R1.2.8"
)
val targetJavaVersion = 21

allprojects {
apply(plugin = "java")
Expand All @@ -38,19 +26,38 @@ allprojects {
}

dependencies {
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4")
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.7")
}

tasks {
compileJava {
options.compilerArgs.addAll(listOf("-source", "17", "-target", "17"))
options.encoding = Charsets.UTF_8.name()
}
javadoc {
options.encoding = Charsets.UTF_8.name()
compileKotlin {
compilerOptions {
freeCompilerArgs.addAll(listOf("-jvm-target", "17"))
}
}
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}

fun Project.legacy() = also { p ->
p.java.toolchain.languageVersion = JavaLanguageVersion.of(17)
}

val api = project("api").legacy()
val dist = project("dist")
val scheduler = project(":scheduler")

val shadedDependencies = listOf(
"com.ticxo.playeranimator:PlayerAnimator:R1.2.8"
)

fun Project.setupDependencies() {
dependencies {
shadedDependencies.forEach { dependency ->
Expand All @@ -59,22 +66,37 @@ fun Project.setupDependencies() {
}
}

nmsVersions.forEach {
val project = project(":nms:$it")
project.apply(plugin = "io.papermc.paperweight.userdev")
project.dependencies {
val legacyNMSVersion = listOf(
"v1_19_R3",
"v1_20_R1",
"v1_20_R2",
"v1_20_R3"
).map {
project("nms:$it").legacy()
}
val currentNMSVersion = listOf(
"v1_20_R4",
"v1_21_R1",
"v1_21_R2"
).map {
project("nms:$it")
}

val allNMSVersion = (legacyNMSVersion + currentNMSVersion).onEach {
it.apply(plugin = "io.papermc.paperweight.userdev")
it.dependencies {
compileOnly(api)
}
project.setupDependencies()
it.setupDependencies()
}

dist.dependencies {
compileOnly(api)
scheduler.subprojects.forEach {
compileOnly(it)
}
nmsVersions.forEach { nms ->
compileOnly(project(":nms:$nms"))
allNMSVersion.forEach { nms ->
compileOnly(nms)
}
}

Expand Down Expand Up @@ -114,16 +136,16 @@ dependencies {
shadedDependencies.forEach { dependency ->
implementation(dependency)
}
nmsVersions.forEach {
implementation(project(":nms:$it", configuration = "reobf"))
allNMSVersion.forEach {
implementation(project("nms:${it.name}", configuration = "reobf"))
}
}

scheduler.project("folia") {
setupDependencies()
dependencies {
compileOnly(api)
compileOnly("dev.folia:folia-api:$minecraftVersion-R0.1-SNAPSHOT")
setupDependencies()
compileOnly("io.papermc.paper:paper-api:$minecraftVersion-R0.1-SNAPSHOT")
}
}

Expand All @@ -134,8 +156,11 @@ tasks {
finalizedBy(shadowJar)
}
shadowJar {
nmsVersions.forEach {
dependsOn(":nms:$it:reobfJar")
allNMSVersion.forEach {
dependsOn(it.tasks.named("reobfJar"))
}
manifest {
attributes["paperweight-mappings-namespace"] = "spigot"
}
archiveClassifier = ""
fun prefix(pattern: String) {
Expand All @@ -152,14 +177,7 @@ tasks {
prefix(it)
}
}
runServer {
version(minecraftVersion)
}
}

val targetJavaVersion = 17

java {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}

kotlin {
jvmToolchain(targetJavaVersion)
}
14 changes: 9 additions & 5 deletions dist/src/main/kotlin/kr/toxicity/animator/ModelAnimatorImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import kr.toxicity.animator.api.scheduler.AnimatorScheduler
import kr.toxicity.animator.api.scheduler.AnimatorTask
import kr.toxicity.animator.scheduler.FoliaScheduler
import kr.toxicity.animator.scheduler.StandardScheduler
import kr.toxicity.animator.util.MinecraftVersion
import kr.toxicity.animator.util.info
import kr.toxicity.animator.util.warn
import org.bukkit.Bukkit
Expand Down Expand Up @@ -53,11 +54,14 @@ class ModelAnimatorImpl: ModelAnimator() {
private var onReload = false

override fun onEnable() {
nms = when (val version = Bukkit.getServer()::class.java.`package`.name.split('.')[3]) {
"v1_19_R3" -> kr.toxicity.animator.nms.v1_19_R3.NMSImpl()
"v1_20_R1" -> kr.toxicity.animator.nms.v1_20_R1.NMSImpl()
"v1_20_R2" -> kr.toxicity.animator.nms.v1_20_R2.NMSImpl()
"v1_20_R3" -> kr.toxicity.animator.nms.v1_20_R3.NMSImpl()
nms = when (val version = MinecraftVersion.current) {
MinecraftVersion.version1_19_4 -> kr.toxicity.animator.nms.v1_19_R3.NMSImpl()
MinecraftVersion.version1_20, MinecraftVersion.version1_20_1 -> kr.toxicity.animator.nms.v1_20_R1.NMSImpl()
MinecraftVersion.version1_20_2 -> kr.toxicity.animator.nms.v1_20_R2.NMSImpl()
MinecraftVersion.version1_20_3, MinecraftVersion.version1_20_4 -> kr.toxicity.animator.nms.v1_20_R3.NMSImpl()
MinecraftVersion.version1_20_5, MinecraftVersion.version1_20_6 -> kr.toxicity.animator.nms.v1_20_R4.NMSImpl()
MinecraftVersion.version1_21, MinecraftVersion.version1_21_1 -> kr.toxicity.animator.nms.v1_21_R1.NMSImpl()
MinecraftVersion.version1_21_2, MinecraftVersion.version1_21_3 -> kr.toxicity.animator.nms.v1_21_R2.NMSImpl()
else -> {
warn("Unsupported version found: $version")
warn("Plugin will automatically disabled.")
Expand Down
48 changes: 48 additions & 0 deletions dist/src/main/kotlin/kr/toxicity/animator/util/MinecraftVersion.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package kr.toxicity.animator.util

import org.bukkit.Bukkit

data class MinecraftVersion(
val first: Int,
val second: Int,
val third: Int
): Comparable<MinecraftVersion> {
companion object {
val current = MinecraftVersion(Bukkit.getBukkitVersion().substringBefore('-'))

val version1_21_3 = MinecraftVersion(1, 21, 3)
val version1_21_2 = MinecraftVersion(1, 21, 2)
val version1_21_1 = MinecraftVersion(1, 21, 1)
val version1_21 = MinecraftVersion(1, 21, 0)
val version1_20_6 = MinecraftVersion(1, 20, 6)
val version1_20_5 = MinecraftVersion(1, 20, 5)
val version1_20_4 = MinecraftVersion(1, 20, 4)
val version1_20_3 = MinecraftVersion(1, 20, 3)
val version1_20_2 = MinecraftVersion(1, 20, 2)
val version1_20_1 = MinecraftVersion(1, 20, 1)
val version1_20 = MinecraftVersion(1, 20, 0)
val version1_19_4 = MinecraftVersion(1, 19, 4)

private val comparator = Comparator.comparing { v: MinecraftVersion ->
v.first
}.thenComparing { v: MinecraftVersion ->
v.second
}.thenComparing { v: MinecraftVersion ->
v.third
}
}

constructor(string: String): this(string.split('.'))
constructor(string: List<String>): this(
if (string.isNotEmpty()) string[0].toInt() else 0,
if (string.size > 1) string[1].toInt() else 0,
if (string.size > 2) string[2].toInt() else 0
)
override fun compareTo(other: MinecraftVersion): Int {
return comparator.compare(this, other)
}

override fun toString(): String {
return if (third == 0) "$first.$second" else "$first.$second.$third"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"uniforms": [
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "IViewRotMat", "type": "matrix3x3", "count": 9, "values": [ 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
{ "name": "ModelOffset", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] },
{ "name": "Light0_Direction", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] },
{ "name": "Light1_Direction", "type": "float", "count": 3, "values": [ 0.0, 0.0, 0.0 ] },
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#version 150

#moj_import <light.glsl>
#moj_import <fog.glsl>

in vec3 Position;
in vec4 Color;
Expand All @@ -16,10 +15,10 @@ uniform sampler2D Sampler2;

uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform mat3 IViewRotMat;

uniform vec3 Light0_Direction;
uniform vec3 Light1_Direction;
uniform vec3 ModelOffset;

uniform int FogShape;

Expand Down Expand Up @@ -95,23 +94,34 @@ vec2(0.0, 48.0)

const int[] faceremap = int[](0, 0, 1, 1, 2, 3, 4, 5);

float fog_distance(vec3 pos, int shape) {
if (shape == 0) {
return length(pos);
} else {
float distXZ = length(pos.xz);
float distY = abs(pos.y);
return max(distXZ, distY);
}
}


void main() {
vertexColor = minecraft_mix_light(Light0_Direction, Light1_Direction, normalize(Normal), Color);
lightMapColor = texelFetch(Sampler2, UV2 / 16, 0);
overlayColor = texelFetch(Sampler1, UV1, 0);
normal = ProjMat * ModelViewMat * vec4(Normal, 0.0);

vec3 wpos = Position + ModelOffset;
ivec2 dim = textureSize(Sampler0, 0);

if (ProjMat[2][3] == 0.0 || dim.x != 64 || dim.y != 64) { // short circuit if cannot be player
part = 0.0;
texCoord0 = UV0;
texCoord1 = vec2(0.0);
vertexDistance = fog_distance(ModelViewMat, IViewRotMat * Position, FogShape);
vertexDistance = fog_distance(Position, FogShape);
gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0);
}
else {
vec3 wpos = IViewRotMat * Position;
vec2 UVout = UV0;
vec2 UVout2 = vec2(0.0);
int partId = -int((wpos.y - MAXRANGE) / SPACING);
Expand Down Expand Up @@ -141,7 +151,7 @@ void main() {
int subuvIndex = faceId;

wpos.y += SPACING * partId;
gl_Position = ProjMat * ModelViewMat * vec4(inverse(IViewRotMat) * wpos, 1.0);
gl_Position = ProjMat * ModelViewMat * vec4(wpos, 1.0);

UVout = origins[2 * (partId - 1) + outerLayer];
UVout2 = origins[2 * (partId - 1)];
Expand Down Expand Up @@ -206,7 +216,7 @@ void main() {
UVout2 /= float(SKINRES);
}

vertexDistance = fog_distance(ModelViewMat, wpos, FogShape);
vertexDistance = fog_distance(wpos, FogShape);
texCoord0 = UVout;
texCoord1 = UVout2;
}
Expand Down
Loading

0 comments on commit 7b61c3b

Please sign in to comment.