Skip to content

Commit

Permalink
way to much to explain
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion committed Jun 11, 2024
1 parent 3e5e0a3 commit 2f949d2
Show file tree
Hide file tree
Showing 60 changed files with 1,219 additions and 1,366 deletions.
433 changes: 401 additions & 32 deletions .editorconfig

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
**/.gradle/
**/run/
!run/mods/
**/build/
**/build/
.kotlin
**/generated
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
kotlin("jvm") version "1.9.24"
kotlin("plugin.serialization") version "1.9.24"
kotlin("jvm") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"

id("me.modmuss50.mod-publish-plugin") version "0.5.+"

Expand Down
3 changes: 1 addition & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
kotlin.code.style=official
org.gradle.jvmargs=-Xmx2048m -Xms2048m -XX:ThreadStackSize=4096 -XX:CompilerThreadStackSize=4096
org.gradle.jvmargs=-Xmx1G
13 changes: 10 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ pluginManagement {
gradlePluginPortal()
maven("https://maven.fabricmc.net/")
maven("https://server.bbkr.space/artifactory/libs-release/")
maven("https://maven.quiltmc.org/repository/release/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://maven.kikugie.dev/releases")
maven("https://maven.kikugie.dev/snapshots")
}
}

plugins {
id("dev.kikugie.stonecutter") version "0.3.5"
id("dev.kikugie.stonecutter") version "0.3.9"
}

buildscript {
repositories { mavenCentral() }
dependencies {
classpath("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.0-RC")
}
}

//include("telekinesis-paper")
Expand All @@ -24,7 +31,7 @@ extensions.configure<StonecutterSettings> {
kotlinController = true
centralScript = "build.gradle.kts"
shared {
versions("1.20.1", "1.20.4", "1.20.6")
versions("1.20.1", "1.20.4", "1.20.6", "1.21")
vcsVersion = "1.20.6"
}
create(project(":telekinesis-fabric"))
Expand Down
96 changes: 42 additions & 54 deletions telekinesis-fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
@file:Suppress("SpellCheckingInspection")

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import kotlin.io.path.readText

plugins {
kotlin("jvm") version "1.9.24"
kotlin("plugin.serialization") version "1.9.24"
kotlin("jvm") version "2.0.0"
kotlin("plugin.serialization") version "2.0.0"
id("fabric-loom") version "1.6-SNAPSHOT"

id("me.modmuss50.mod-publish-plugin") version "0.5.+"
Expand All @@ -23,23 +23,28 @@ group = "dev.nyon"
val projectAuthors = listOf("btwonion")
val githubRepo = "btwonion/telekinesis"

base {
archivesName.set(rootProject.name)
}

loom {
if (stonecutter.current.isActive) {
runConfigs.all {
ideConfigGenerated(true)
runDir("../../run")
}

project.tasks.register("runActive") {
group = "mod"

dependsOn(tasks.named("runClient"))
}
}

mixin { useLegacyMixinAp = false }

accessWidenerPath = file("../../src/main/resources/telekinesis.accesswidener")
accessWidenerPath = rootProject.file("telekinesis-fabric/src/main/resources/telekinesis.accesswidener")
}

// Enable data generation for >1.20.6
if (!listOf("1.20.1", "1.20.4", "1.20.6").contains(stonecutter.current.version)) {
fabricApi {
configureDataGeneration()
}
}

repositories {
Expand All @@ -56,35 +61,29 @@ repositories {
maven("https://maven.parchmentmc.org")
maven("https://repo.nyon.dev/releases")
maven("https://maven.isxander.dev/releases")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://maven.isxander.dev/snapshots")
maven("https://jitpack.io")
}

dependencies {
minecraft("com.mojang:minecraft:$mcVersion")
mappings(
loom.layered {
parchment("org.parchmentmc.data:parchment-${property("deps.parchment")}@zip")
officialMojangMappings()
}
)
mappings(loom.layered {
val parchment: String = property("deps.parchment").toString()
if (parchment.isNotEmpty()) parchment("org.parchmentmc.data:parchment-$parchment@zip")
officialMojangMappings()
})

implementation("org.vineflower:vineflower:1.10.1")
modImplementation("net.fabricmc:fabric-loader:0.15.11")
modImplementation("net.fabricmc.fabric-api:fabric-api:${property("deps.fapi")!!}")
modImplementation("net.fabricmc:fabric-language-kotlin:1.10.20+kotlin.1.9.24")
modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0")

modImplementation("dev.isxander:yet-another-config-lib:${property("deps.yacl")!!}")
modImplementation("com.terraformersmc:modmenu:${property("deps.modMenu")!!}")
modCompileOnly("com.terraformersmc:modmenu:${property("deps.modMenu")!!}")

include(implementation(annotationProcessor("com.github.bawnorton.mixinsquared:mixinsquared-fabric:0.1.1")!!)!!)

include(implementation("com.akuleshov7:ktoml-core-jvm:0.5.1")!!)

// Integration
// modCompileOnly("maven.modrinth:abooMhox:c2klaSgQ") // tree-harvester by ricksouth wait for 1.20.5
// modCompileOnly("maven.modrinth:MpzVLzy5:9kJblF2V") // better nether by quickueck wait for 1.20.5
// modCompileOnly("maven.modrinth:EFtixeiF:Gcai736Z") // levelz by Globox1997 wait for 1.20.5
}

val javaVersion = property("javaVer")!!.toString()
Expand All @@ -94,15 +93,14 @@ tasks {
val modName = "telekinesis"
val modDescription = "Adds a telekinesis enchantment to minecraft"

val props =
mapOf(
"id" to modId,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubRepo,
"mc" to mcVersionRange
)
val props = mapOf(
"id" to modId,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubRepo,
"mc" to mcVersionRange
)

props.forEach(inputs::property)

Expand All @@ -123,17 +121,19 @@ tasks {
}

withType<KotlinCompile> {
kotlinOptions.jvmTarget = javaVersion
compilerOptions {
jvmTarget = JvmTarget.fromTarget(javaVersion)
}
}
}

val changelogText =
buildString {
append("# v${project.version}\n")
file("../../../changelog.md").readText().also { append(it) }
}
val changelogText = buildString {
append("# v${project.version}\n")
rootProject.file("changelog.md").readText().also(::append)
}

val supportedMcVersions: List<String> = property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty)
val supportedMcVersions: List<String> =
property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty)

publishMods {
displayName = "v${project.version}"
Expand All @@ -149,7 +149,7 @@ publishMods {

requires { slug = "fabric-api" }
requires { slug = "yacl" }
requires { slug = "fabric-language-kotlin" }
requires { slug = "fabric-language-kotlin" }
optional { slug = "modmenu" }
}

Expand All @@ -158,12 +158,6 @@ publishMods {
accessToken = providers.environmentVariable("GITHUB_TOKEN")
commitish = "master"
}

discord {
webhookUrl = providers.environmentVariable("DISCORD_WEBHOOK")
username = "Release Notifier"
content = "# A new version of Telekinesis released!\n$changelogText"
}
}

publishing {
Expand All @@ -190,18 +184,12 @@ publishing {
java {
withSourcesJar()

javaVersion.toInt()
.let { JavaVersion.values()[it - 1] }
.let {
javaVersion.toInt().let { JavaVersion.values()[it - 1] }.let {
sourceCompatibility = it
targetCompatibility = it
}
}

kotlin {
jvmToolchain(javaVersion.toInt())
}

/*
signing {
val signingKey: String? by project
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package dev.nyon.telekinesis.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.EntityUtils;
import dev.nyon.telekinesis.utils.MixinHelper;
import net.minecraft.world.entity.animal.horse.AbstractChestedHorse;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ItemLike;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -17,10 +18,10 @@ public class AbstractChestedHorseMixin {
target = "Lnet/minecraft/world/entity/animal/horse/AbstractChestedHorse;spawnAtLocation(Lnet/minecraft/world/level/ItemLike;)Lnet/minecraft/world/entity/item/ItemEntity;"
)
)
public boolean redirectEquipmentDrop(
public boolean modifyEquipmentDrop(
AbstractChestedHorse instance,
ItemLike item
) {
return EntityUtils.spawnAtLocationInject(instance, item);
return MixinHelper.entityDropEquipmentSingle(instance, new ItemStack(item));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.nyon.telekinesis.mixins;

import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.EntityUtils;
import dev.nyon.telekinesis.utils.MixinHelper;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -17,10 +17,24 @@ public class AbstractHorseMixin {
target = "Lnet/minecraft/world/entity/animal/horse/AbstractHorse;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;"
)
)
public boolean redirectEquipmentDrop(
public boolean modifyEquipmentDrop(
AbstractHorse instance,
ItemStack stack
) {
return EntityUtils.spawnAtLocationInject(instance, stack);
return MixinHelper.entityDropEquipmentSingle(instance, stack);
}

@WrapWithCondition(
method = "dropEquipment",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/animal/horse/AbstractHorse;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;"
)
)
public boolean modifyEquipmentDrops(
AbstractHorse instance,
ItemStack itemStack
) {
return MixinHelper.entityDropEquipmentSingle(instance, itemStack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import net.minecraft.world.entity.vehicle.AbstractMinecart;
import org.spongepowered.asm.mixin.Mixin;

/*? <=1.20.2 {*/
/*? <=1.20.2 {*//*
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import dev.nyon.telekinesis.utils.EntityUtils;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.injection.At;
/*?}*/
*//*?}*/

@Mixin(AbstractMinecart.class)
public class AbstractMinecartMixin {

/*? <=1.20.2 {*/
/*? <=1.20.2 {*//*
@WrapWithCondition(method = "destroy", at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/vehicle/AbstractMinecart;spawnAtLocation(Lnet/minecraft/world/item/ItemStack;)Lnet/minecraft/world/entity/item/ItemEntity;"
Expand All @@ -28,5 +28,5 @@ private boolean redirectMinecartDrops(
if (!(damageSource.getEntity() instanceof LivingEntity livingEntity)) return true;
return EntityUtils.spawnAtLocationAttacker(livingEntity, itemStack);
}
/*?}*/
*//*?}*/
}
Loading

0 comments on commit 2f949d2

Please sign in to comment.