diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d716e279..4401143e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -38,8 +38,8 @@ jobs: uses: actions/upload-artifact@v4 if: success() with: - name: mod-jars - path: build/libs/*.jar + name: mobends-ci-build + path: build/libs/*-all.jar retention-days: 30 - name: Comment PR with artifact URLs diff --git a/.gitignore b/.gitignore index 8d8de3e2..bb33f9c0 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ !/gradle !/gradlew !/gradlew.bat +!/README.md +!/LICENSE diff --git a/build.gradle b/build.gradle index 3afa0632..e0f0471b 100644 --- a/build.gradle +++ b/build.gradle @@ -3,16 +3,21 @@ buildscript { maven { url = 'https://files.minecraftforge.net/maven' } jcenter() mavenCentral() + gradlePluginPortal() } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:3.+' + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72' + classpath 'com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:4.0.4' } } apply plugin: 'net.minecraftforge.gradle' // Only edit below this line, the above code adds and enables the necessary things for Forge to be setup. apply plugin: 'eclipse' +apply plugin: 'kotlin' apply plugin: 'maven-publish' +apply plugin: 'com.github.johnrengelman.shadow' version = "${mod_version}-${getDate()}" group = "goblinbob.mobends" // http://maven.apache.org/guides/mini/guide-naming-conventions.html @@ -21,6 +26,18 @@ archivesBaseName = "MoBends_${minecraft_version}" // Need this here so eclipse task generates correctly. sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' +// Kotlin configuration +compileKotlin { + kotlinOptions { + jvmTarget = "1.8" + } +} +compileTestKotlin { + kotlinOptions { + jvmTarget = "1.8" + } +} + minecraft { // The mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD Snapshot are built nightly. @@ -81,6 +98,12 @@ dependencies { // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html + // Kotlin support + implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.72' + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72' + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.72' + implementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.72' + testCompile "junit:junit:4.11" } @@ -102,13 +125,19 @@ jar { // Temporary fix for resources not being available during testing // Comment this out upon publishing -sourceSets {main { output.resourcesDir = output.classesDir }} +// sourceSets {main { output.resourcesDir = output.classesDir }} // Example configuration to allow publishing using the maven-publish task // This is the preferred method to reobfuscate your jar file -jar.finalizedBy('reobfJar') +// Configure reobf to work on shadowJar instead of regular jar +reobf { + shadowJar { + // This will create a reobfuscated shadow jar + } +} +shadowJar.finalizedBy('reobfShadowJar') // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing -//publish.dependsOn('reobfJar') +//publish.dependsOn('reobfShadowJar') processResources { // this will ensure that this task is redone when the versions change. @@ -129,10 +158,19 @@ processResources { } } +// Bundling the Kotlin standard library along with the mod +shadowJar { + dependencies { + include(dependency('org.jetbrains.kotlin:kotlin-stdlib')) + include(dependency('org.jetbrains.kotlin:kotlin-stdlib-jdk8')) + } + relocate 'kotlin', 'goblinbob.mobends.kotlin' +} + publishing { publications { mavenJava(MavenPublication) { - artifact jar + artifact shadowJar } } repositories { diff --git a/src/main/java/goblinbob/mobends/standard/animation/bit/biped/JumpAnimationBit.java b/src/main/java/goblinbob/mobends/standard/animation/bit/biped/JumpAnimationBit.java deleted file mode 100644 index d9ea316f..00000000 --- a/src/main/java/goblinbob/mobends/standard/animation/bit/biped/JumpAnimationBit.java +++ /dev/null @@ -1,88 +0,0 @@ -package goblinbob.mobends.standard.animation.bit.biped; - -import goblinbob.mobends.core.animation.bit.AnimationBit; -import goblinbob.mobends.standard.data.BipedEntityData; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.math.MathHelper; - -public class JumpAnimationBit> extends AnimationBit -{ - private static final String[] ACTIONS = new String[] { "jump" }; - - @Override - public String[] getActions(T entityData) - { - return ACTIONS; - } - - @Override - public void onPlay(T data) - { - data.renderRotation.identity(); - data.centerRotation.identity(); - data.body.rotation.orientInstantX(20F); - data.rightLeg.rotation.orientInstantX(0F); - data.leftLeg.rotation.orientInstantX(0F); - data.rightForeLeg.rotation.orientInstantX(0F); - data.leftForeLeg.rotation.orientInstantX(0F); - data.rightArm.rotation.orientInstantZ(2F); - data.leftArm.rotation.orientInstantZ(-2F); - data.rightForeArm.rotation.orientInstantX(-20F); - data.leftForeArm.rotation.orientInstantX(-20F); - } - - @Override - public void perform(T data) - { - if (data.getPrevMotionY() < 0 && data.getMotionY() > 0) - { - /* - * Restarting the animation if the player is going back up again after falling - * down. - */ - this.onPlay(data); - } - - EntityLivingBase biped = data.getEntity(); - - data.globalOffset.slideToZero(0.3F); - data.renderRotation.setSmoothness(.3F).orientZero(); - data.centerRotation.setSmoothness(.7F).orientZero(); - data.renderRightItemRotation.setSmoothness(.3F).orientZero(); - data.renderLeftItemRotation.setSmoothness(.3F).orientZero(); - - float bodyRotationX = Math.max(1.0F - data.getTicksInAir() * 0.1F, 0.0F); - data.body.rotation.setSmoothness(0.2F).orientX(bodyRotationX); - data.rightArm.rotation.setSmoothness(0.05F).orientZ(45F); - data.leftArm.rotation.setSmoothness(0.05F).orientZ(-45F); - data.rightForeArm.rotation.setSmoothness(0.3F).orientX(0); - data.leftForeArm.rotation.setSmoothness(0.3F).orientX(0); - - data.head.rotation.orientX(data.headPitch.get() - bodyRotationX) - .rotateY(data.headYaw.get()); - - if (!data.isStillHorizontally()) - { - final float PI = (float) Math.PI; - float limbSwing = data.limbSwing.get() * 0.6662F; - float limbSwingAmount = 0.7F * data.limbSwingAmount.get() / PI * 180F; - data.rightLeg.rotation.setSmoothness(1.0F).orientX(-5F + MathHelper.cos(limbSwing) * limbSwingAmount); - data.leftLeg.rotation.setSmoothness(1.0F).orientX(-5F + MathHelper.cos(limbSwing + PI) * limbSwingAmount); - - float var = (limbSwing / PI) % 2; - data.leftForeLeg.rotation.setSmoothness(0.3F).orientX((var > 1 ? 45 : 0)); - data.rightForeLeg.rotation.setSmoothness(0.3F).orientX((var > 1 ? 0 : 45)); - data.leftForeArm.rotation.setSmoothness(0.3F).orientX((MathHelper.cos(limbSwing + PI/2) / 2F + 0.5F) * -20F); - data.rightForeArm.rotation.setSmoothness(0.3F).orientX((MathHelper.cos(limbSwing) / 2F + 0.5F) * -20F); - } - else - { - data.rightLeg.rotation.setSmoothness(0.1F).orientZ(10); - data.rightLeg.rotation.setSmoothness(0.3F).rotateX(-45); - data.leftLeg.rotation.setSmoothness(0.1F).orientZ(-10); - data.leftLeg.rotation.setSmoothness(0.3F).rotateX(-17); - data.rightForeLeg.rotation.setSmoothness(0.3F).orientX(70); - data.leftForeLeg.rotation.setSmoothness(0.3F).orientX(17); - } - } -} diff --git a/src/main/kotlin/goblinbob/mobends/standard/animation/bit/biped/JumpAnimationBit.kt b/src/main/kotlin/goblinbob/mobends/standard/animation/bit/biped/JumpAnimationBit.kt new file mode 100644 index 00000000..7ef944c1 --- /dev/null +++ b/src/main/kotlin/goblinbob/mobends/standard/animation/bit/biped/JumpAnimationBit.kt @@ -0,0 +1,89 @@ +package goblinbob.mobends.standard.animation.bit.biped + +import goblinbob.mobends.core.animation.bit.AnimationBit +import goblinbob.mobends.standard.data.BipedEntityData +import net.minecraft.entity.EntityLivingBase +import net.minecraft.util.math.MathHelper +import kotlin.math.PI +import kotlin.math.cos +import kotlin.math.max + +/** + * Represents a jump animation bit for biped entities. + */ +class JumpAnimationBit> : AnimationBit() { + /** + * All constants that are shared across all bits of this type. + */ + companion object { + /* + * Holds the actions that the bits of this type perform. + * TODO: Used by bends-packs, but not sure for purpose exactly. + */ + private val ACTIONS = arrayOf("jump") + } + + override fun getActions(entityData: T): Array = ACTIONS + + override fun onPlay(data: T) { + data.renderRotation.identity() + data.centerRotation.identity() + data.body.rotation.orientInstantX(20f) + data.rightLeg.rotation.orientInstantX(0f) + data.leftLeg.rotation.orientInstantX(0f) + data.rightForeLeg.rotation.orientInstantX(0f) + data.leftForeLeg.rotation.orientInstantX(0f) + data.rightArm.rotation.orientInstantZ(2f) + data.leftArm.rotation.orientInstantZ(-2f) + data.rightForeArm.rotation.orientInstantX(-20f) + data.leftForeArm.rotation.orientInstantX(-20f) + } + + override fun perform(data: T) { + if (data.prevMotionY < 0 && data.motionY > 0) { + /* + * Restarting the animation if the player is going back up again after falling + * down. + */ + onPlay(data) + } + + data.globalOffset.slideToZero(0.3f) + data.renderRotation.setSmoothness(0.3f).orientZero() + data.centerRotation.setSmoothness(0.7f).orientZero() + data.renderRightItemRotation.setSmoothness(0.3f).orientZero() + data.renderLeftItemRotation.setSmoothness(0.3f).orientZero() + + val bodyRotationX = max(1.0f - data.ticksInAir * 0.1f, 0.0f) + data.body.rotation.setSmoothness(0.2f).orientX(bodyRotationX) + data.rightArm.rotation.setSmoothness(0.05f).orientZ(45f) + data.leftArm.rotation.setSmoothness(0.05f).orientZ(-45f) + data.rightForeArm.rotation.setSmoothness(0.3f).orientX(0f) + data.leftForeArm.rotation.setSmoothness(0.3f).orientX(0f) + + data.head.rotation.orientX(data.headPitch.get() - bodyRotationX).rotateY(data.headYaw.get()) + + if (!data.isStillHorizontally()) { + val limbSwing = data.limbSwing.get() * 0.6662f + val limbSwingAmount = 0.7f * data.limbSwingAmount.get() / PI.toFloat() * 180f + + data.rightLeg.rotation.setSmoothness(1.0f).orientX(-5f + MathHelper.cos(limbSwing) * limbSwingAmount) + data.leftLeg.rotation.setSmoothness(1.0f) + .orientX(-5f + MathHelper.cos(limbSwing + PI.toFloat()) * limbSwingAmount) + + val limbSwingVar = (limbSwing / PI.toFloat()) % 2 + data.leftForeLeg.rotation.setSmoothness(0.3f).orientX(if (limbSwingVar > 1) 45f else 0f) + data.rightForeLeg.rotation.setSmoothness(0.3f).orientX(if (limbSwingVar > 1) 0f else 45f) + data.leftForeArm.rotation.setSmoothness(0.3f) + .orientX((MathHelper.cos(limbSwing + PI.toFloat() / 2) / 2f + 0.5f) * -20f) + data.rightForeArm.rotation.setSmoothness(0.3f).orientX((MathHelper.cos(limbSwing) / 2f + 0.5f) * -20f) + } else { + data.rightLeg.rotation.setSmoothness(0.1f).orientZ(10f) + data.rightLeg.rotation.setSmoothness(0.3f).rotateX(-45f) + data.leftLeg.rotation.setSmoothness(0.1f).orientZ(-10f) + data.leftLeg.rotation.setSmoothness(0.3f).rotateX(-17f) + data.rightForeLeg.rotation.setSmoothness(0.3f).orientX(70f) + data.leftForeLeg.rotation.setSmoothness(0.3f).orientX(17f) + } + } +}