Compare commits

..

23 Commits

Author SHA1 Message Date
b40a33f69a feat(swarm): walk farther 2023-08-23 21:35:56 +08:00
22b1450a72 feat: adjust swarm time table 2023-08-23 14:28:06 +08:00
abb5646959 fix: game crash when no container available 2023-08-21 09:10:13 +08:00
1ee1c7215d fix: container focus again 2023-08-18 09:34:07 +08:00
d45f8d2a57 fix: signed 32-bits integer overflowed
Use in the wild: Mojang
2023-08-18 09:28:00 +08:00
cd40ba58da fix: WorkPoiAI not initialized early 2023-08-16 10:22:17 +08:00
d110d688c6 fix: only stroll in near positions 2023-08-11 16:00:14 +08:00
6cc16233fa fix: work poi missing 2023-08-11 15:55:17 +08:00
00ce17cb21 fix: disable despawn for swarm 2023-08-11 15:44:22 +08:00
3a4ad875e2 fix: missing bed memory for swarm 2023-08-11 15:33:25 +08:00
e25f23f40b chore: trigger longjing build 2023-08-11 09:51:19 +08:00
f794f9848b fix: remove debug log 2023-08-10 22:22:40 +08:00
f2b60ca6b0 fix(i18n): json syntax 2023-08-10 22:11:25 +08:00
a68b68a0e3 fix: remove duplicated key 2023-08-10 22:09:21 +08:00
33604db8a0 feat(i18n): add translations 2023-08-10 22:07:56 +08:00
a31321e662 feat: volume scaler 2023-08-10 22:03:32 +08:00
db74d07155 fix: mitigation for container tracker 2023-08-10 11:48:16 +08:00
d578db6fb2 fix: crash 2023-08-10 11:45:21 +08:00
296fe1efc2 fix: crash when trying to interact with destoryed container 2023-08-10 11:41:33 +08:00
2c95dfa660 fix: fix unable to bootstrap registry warning 2023-08-01 17:53:34 +08:00
fa1aefe425 feat: remove 3.0 base factor for music 2023-08-01 17:51:53 +08:00
dca1482526 feat: add quilt support
It is not working at all
2023-08-01 16:56:38 +08:00
9aa248e7f2 build: add fabric support 2023-08-01 15:45:21 +08:00
31 changed files with 464 additions and 34 deletions

2
.gitignore vendored
View File

@@ -1,4 +1,4 @@
build
.gradle
forge/run
*/run
.idea

View File

@@ -45,6 +45,10 @@ allprojects {
name = "ParchmentMC"
setUrl("https://maven.parchmentmc.org")
}
maven {
name = "QuiltMC"
setUrl("https://maven.quiltmc.org/repository/release/")
}
}
dependencies {

View File

@@ -1,5 +1,5 @@
architectury {
common("forge")
common("forge", "fabric", "quilt")
}
loom {

View File

@@ -20,6 +20,7 @@ import quaedam.projection.misc.NoiseProjection
import quaedam.projection.misc.SkylightProjection
import quaedam.projection.misc.SoundProjection
import quaedam.projection.music.MusicProjection
import quaedam.projection.swarm.ProjectedPersonEntity
import quaedam.projection.swarm.SwarmProjection
import quaedam.projector.Projector
import quaedam.shell.ProjectionShell
@@ -48,6 +49,8 @@ object Quaedam {
}
}
val lateinit = mutableListOf<() -> Unit>()
fun init() {
QuaedamConfig
Projector
@@ -75,6 +78,9 @@ object Quaedam {
soundEvents.register()
poiTypes.register()
projectionEffects.register()
lateinit.forEach { it() }
lateinit.clear()
}
fun resource(path: String) = ResourceLocation(ID, path)

View File

@@ -39,7 +39,7 @@ data class ProjectionEffectType<T : ProjectionEffect>(val constructor: () -> T)
val registryKey: ResourceKey<Registry<ProjectionEffectType<*>>> =
ResourceKey.createRegistryKey(Quaedam.resource("projection_effect"))
val registry: Registry<ProjectionEffectType<*>> = BuiltInRegistries.registerSimple(registryKey) { null }
val registry: Registry<ProjectionEffectType<*>> = BuiltInRegistries.registerSimple(registryKey) { nopEffect }
val nopEffect: ProjectionEffectType<NopEffect> =
Registry.register(registry, Quaedam.resource("nop"), ProjectionEffectType { NopEffect })

View File

@@ -59,10 +59,11 @@ object NoiseProjection {
if (projections.isNotEmpty()) {
val rate = projections.maxOf { it.rate }
val amount = min(projections.sumOf { it.amount }, 12)
val volume = projections.fold(1.0f) { v, p -> v * p.volume }
if (amount != 0 && random.nextInt(1000 / rate) == 1) {
for (i in 0 until random.nextInt(amount)) {
// play random noise
playRandomNoise(random, game)
playRandomNoise(random, game, volume)
}
}
}
@@ -70,7 +71,7 @@ object NoiseProjection {
}
}
private fun playRandomNoise(random: RandomSource, game: Minecraft) {
private fun playRandomNoise(random: RandomSource, game: Minecraft, volume: Float) {
val volumeFactor = random.nextInt(100)
val sound = SimpleSoundInstance(
soundEvent.get().location,
@@ -80,7 +81,7 @@ object NoiseProjection {
in 10..15 -> random.nextFloat() * 0.5f + 0.5f
in 21..50 -> random.nextFloat() * 0.3f
else -> random.nextFloat() * 0.2f
},
} * volume,
random.nextFloat() + 0.4f,
RandomSource.create(random.nextLong()),
false,
@@ -102,12 +103,14 @@ object NoiseProjectionBlock : EntityProjectionBlock<NoiseProjectionEffect>(creat
}
data class NoiseProjectionEffect(var rate: Int = 250, var amount: Int = 3) : ProjectionEffect(),
data class NoiseProjectionEffect(var rate: Int = 250, var amount: Int = 3, var volume: Float = 1.0f) :
ProjectionEffect(),
ProjectionEffectShell.Provider {
companion object {
const val TAG_RATE = "Rate"
const val TAG_AMOUNT = "Amount"
const val TAG_VOLUME = "Volume"
val maxAmount get() = QuaedamConfig.current.valuesInt["projection.noise.max_amount"] ?: 8
val maxRate get() = QuaedamConfig.current.valuesInt["projection.noise.max_rate"] ?: 300
@@ -119,11 +122,13 @@ data class NoiseProjectionEffect(var rate: Int = 250, var amount: Int = 3) : Pro
override fun toNbt(tag: CompoundTag) {
tag.putInt(TAG_RATE, rate)
tag.putInt(TAG_AMOUNT, amount)
tag.putFloat(TAG_VOLUME, volume)
}
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
rate = tag.getInt(TAG_RATE)
amount = tag.getInt(TAG_AMOUNT)
volume = tag.getFloat(TAG_VOLUME)
if (!trusted) {
amount = min(amount, maxAmount)
rate = min(rate, maxRate)
@@ -133,6 +138,7 @@ data class NoiseProjectionEffect(var rate: Int = 250, var amount: Int = 3) : Pro
override fun createShell() = buildProjectionEffectShell(this) {
intSlider("quaedam.shell.noise.rate", ::rate, 0..maxRate step 5)
intSlider("quaedam.shell.noise.amount", ::amount, 0..maxAmount)
floatSlider("quaedam.shell.noise.volume", ::volume, 0.0f..1.0f, 0.1f)
}
}

View File

@@ -43,10 +43,12 @@ object SoundProjectionBlock : EntityProjectionBlock<SoundProjectionEffect>(creat
}
data class SoundProjectionEffect(var rate: Int = 60) : ProjectionEffect(), ProjectionEffectShell.Provider {
data class SoundProjectionEffect(var rate: Int = 60, var volume: Float = 1.0f) : ProjectionEffect(),
ProjectionEffectShell.Provider {
companion object {
const val TAG_RATE = "Rate"
const val TAG_VOLUME = "Volume"
val maxRate get() = QuaedamConfig.current.valuesInt["projection.sound.max_rate"] ?: 210
}
@@ -56,10 +58,12 @@ data class SoundProjectionEffect(var rate: Int = 60) : ProjectionEffect(), Proje
override fun toNbt(tag: CompoundTag) {
tag.putInt(TAG_RATE, rate)
tag.putFloat(TAG_VOLUME, volume)
}
override fun fromNbt(tag: CompoundTag, trusted: Boolean) {
rate = tag.getInt(TAG_RATE)
volume = tag.getFloat(TAG_VOLUME)
if (!trusted) {
rate = min(rate, maxRate)
}
@@ -67,6 +71,7 @@ data class SoundProjectionEffect(var rate: Int = 60) : ProjectionEffect(), Proje
override fun createShell() = buildProjectionEffectShell(this) {
intSlider("quaedam.shell.sound.rate", ::rate, 0..maxRate)
floatSlider("quaedam.shell.sound.volume", ::volume, 0.0f..1.0f, 0.1f)
}
}

View File

@@ -71,7 +71,7 @@ class MusicPlayer(
// play note
val projections = Projector.findNearbyProjections(level, pos, MusicProjection.effect.get())
.takeIf { it.isNotEmpty() } ?: listOf(MusicProjectionEffect())
val volume = 3.0f * projections.maxOf { it.volumeFactor } * note.volume
val volume = projections.maxOf { it.volumeFactor } * note.volume
val particle = projections.any { it.particle }
val instrument = level.getBlockState(pos).getValue(BlockStateProperties.NOTEBLOCK_INSTRUMENT)
val pitch = if (instrument.isTunable) {

View File

@@ -60,7 +60,7 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
}!!
init {
EntityAttributeRegistry.register(entity, ::createAttributes)
Quaedam.lateinit += { EntityAttributeRegistry.register(entity, ::createAttributes) }
if (Platform.getEnv() == EnvType.CLIENT) ProjectedPersonRenderer
ProjectedPersonShape
ProjectedPersonAI
@@ -177,7 +177,8 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
Projector.findNearbyProjections(level(), blockPosition(), SwarmProjection.effect.get()).isNotEmpty()
override fun checkDespawn() {
super.checkDespawn()
// no despawn
// super.checkDespawn()
if (!checkProjectionEffect() && !CausalityAnchor.checkEffect(level(), blockPosition())) {
dropEquipment()
remove(RemovalReason.KILLED)
@@ -237,24 +238,27 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
}
fun findNearbySoundProjection() =
Projector.findNearbyProjections(level(), blockPosition(), SoundProjection.effect.get()).firstOrNull()
Projector.findNearbyProjections(level(), blockPosition(), SoundProjection.effect.get())
override fun isSilent() =
super.isSilent() && findNearbySoundProjection() != null
super.isSilent() && findNearbySoundProjection().isEmpty()
override fun getAmbientSound(): SoundEvent? {
if (findNearbySoundProjection() != null) {
if (findNearbySoundProjection().isNotEmpty()) {
// sound projection available
return soundNoise.get()
}
return null
}
override fun getSoundVolume() = super.getSoundVolume() * (random.nextFloat() * 1.1f + 0.4f)
override fun getSoundVolume() =
super.getSoundVolume() * (random.nextFloat() * 1.1f + 0.4f) *
findNearbySoundProjection().fold(1.0f) { v, p -> v * p.volume }
override fun getVoicePitch() = super.getVoicePitch() * (random.nextFloat() * 0.55f + 0.7f)
override fun getAmbientSoundInterval() = 80 - random.nextInt((findNearbySoundProjection()?.rate ?: 1) * 5)
override fun getAmbientSoundInterval() =
80 - random.nextInt((findNearbySoundProjection().firstOrNull()?.rate ?: 1) * 5)
override fun isEffectiveAi() = super.isEffectiveAi() && checkProjectionEffect()

View File

@@ -10,6 +10,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider
import net.minecraft.client.renderer.entity.MobRenderer
import net.minecraft.client.renderer.entity.layers.CustomHeadLayer
import net.minecraft.client.renderer.entity.layers.ItemInHandLayer
import quaedam.Quaedam
@Environment(EnvType.CLIENT)
class ProjectedPersonRenderer(context: EntityRendererProvider.Context) :
@@ -21,7 +22,12 @@ class ProjectedPersonRenderer(context: EntityRendererProvider.Context) :
companion object {
init {
EntityRendererRegistry.register(ProjectedPersonEntity.entity, ::ProjectedPersonRenderer)
Quaedam.lateinit += {
EntityRendererRegistry.register(
ProjectedPersonEntity.entity,
::ProjectedPersonRenderer
)
}
}
}

View File

@@ -41,7 +41,9 @@ class ExchangeItem<E> : Behavior<E>(
if (closeAt == null) {
if (owner.brain.getMemory(MemoryModuleType.WALK_TARGET).isEmpty) {
// reached
val chest = level.getBlockEntity(target!!) as BaseContainerBlockEntity
val chest = level.getBlockEntity(target!!) ?: return
if (chest !is BaseContainerBlockEntity)
return
if (chest is ChestBlockEntity) {
ChestBlockEntity.playSound(level, target!!, level.getBlockState(target!!), SoundEvents.CHEST_OPEN)
}
@@ -60,7 +62,7 @@ class ExchangeItem<E> : Behavior<E>(
owner.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE)
if (closeAt != null) {
// opened
val chest = level.getBlockEntity(target!!)!!
val chest = level.getBlockEntity(target!!) ?: return
if (chest is ChestBlockEntity) {
ChestBlockEntity.playSound(level, target!!, level.getBlockState(target!!), SoundEvents.CHEST_CLOSE)
}
@@ -68,7 +70,9 @@ class ExchangeItem<E> : Behavior<E>(
}
private fun exchangeItems(level: ServerLevel, entity: E) {
val container = level.getBlockEntity(target!!) as Container
val container = level.getBlockEntity(target!!) ?: return
if (container !is Container)
return
val inventory = entity.inventory
for (i in 1..10) {
val maxCount = 1 + level.random.nextInt(16)

View File

@@ -10,6 +10,7 @@ import net.minecraft.world.level.block.entity.BaseContainerBlockEntity
import quaedam.Quaedam
import quaedam.utils.getChunksNearby
import java.util.*
import kotlin.random.Random
class NearestVisibleContainer : Sensor<LivingEntity>() {
@@ -33,7 +34,9 @@ class NearestVisibleContainer : Sensor<LivingEntity>() {
if (entity.tickCount and 0b11111 == 0) { // 32gt
val pos = level.getChunksNearby(entity.blockPosition(), 1)
.flatMap { it.blockEntities.filterValues { be -> be is BaseContainerBlockEntity }.keys }
.minByOrNull { it.distManhattan(entity.blockPosition()) }
.sortedBy { it.distManhattan(entity.blockPosition()) / 5 }
.shuffled(Random(System.currentTimeMillis() / 10000))
.firstOrNull()
entity.brain.setMemory(memory.get(), pos)
}
}

View File

@@ -1,7 +1,6 @@
package quaedam.projection.swarm.ai
import com.google.common.collect.ImmutableList
import net.minecraft.core.Holder
import net.minecraft.core.registries.Registries
import net.minecraft.tags.TagKey
import net.minecraft.world.entity.LivingEntity
@@ -11,8 +10,6 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType
import net.minecraft.world.entity.ai.memory.MemoryStatus
import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities
import net.minecraft.world.entity.ai.sensing.SensorType
import net.minecraft.world.entity.ai.village.poi.PoiType
import net.minecraft.world.entity.ai.village.poi.PoiTypes
import net.minecraft.world.entity.monster.Monster
import net.minecraft.world.entity.schedule.Activity
import net.minecraft.world.entity.schedule.Schedule
@@ -32,8 +29,8 @@ object ProjectedPersonAI {
val defaultSchedule = Quaedam.schedules.register("projected_person_default") {
ScheduleBuilder(Schedule()).changeActivityAt(10, Activity.IDLE)
.changeActivityAt(10, Activity.IDLE)
.changeActivityAt(2000, Activity.WORK)
.changeActivityAt(7300, Activity.IDLE)
.changeActivityAt(900, Activity.WORK)
.changeActivityAt(6300, Activity.IDLE)
.changeActivityAt(9000, Activity.WORK)
.changeActivityAt(10700, Activity.IDLE)
.changeActivityAt(11000, Activity.PLAY)
@@ -55,6 +52,7 @@ object ProjectedPersonAI {
init {
BedInChunkSensor
AmusementAI
WorkPoiAI
NearestVisibleContainer
}
@@ -71,6 +69,7 @@ object ProjectedPersonAI {
MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE,
MemoryModuleType.HOME,
MemoryModuleType.LAST_WOKEN,
MemoryModuleType.NEAREST_BED,
NearestVisibleContainer.memory.get(),
)
}
@@ -158,7 +157,15 @@ object ProjectedPersonAI {
brain.addActivity(
Activity.WORK, ImmutableList.of(
5 weight ExchangeItem(),
10 weight createStrollBehavior(),
7 weight WorkPoiAI.createStrollAroundPoi(),
7 weight WorkPoiAI.createStrollToPoi(),
10 weight RunOne(
mapOf(),
listOf(
1 weightR createStrollBehavior(),
1 weightR WorkPoiAI.createAcquirePoi(),
)
),
)
)
}
@@ -182,7 +189,7 @@ object ProjectedPersonAI {
private fun createStrollBehavior() = RunOne(
listOf(
2 weightR RandomStroll.stroll(1.0f),
2 weightR RandomStroll.stroll(1.0f, 42, 12),
2 weightR SetWalkTargetFromLookTarget.create(1.0f, 5),
1 weightR DoNothing(30, 60)
)

View File

@@ -0,0 +1,49 @@
package quaedam.projection.swarm.ai
import net.minecraft.core.GlobalPos
import net.minecraft.world.entity.ai.behavior.AcquirePoi
import net.minecraft.world.entity.ai.behavior.StrollAroundPoi
import net.minecraft.world.entity.ai.behavior.StrollToPoi
import net.minecraft.world.entity.ai.memory.MemoryModuleType
import net.minecraft.world.entity.ai.village.poi.PoiTypes
import quaedam.Quaedam
import java.util.*
object WorkPoiAI {
const val ID = "work"
val poiTypes by lazy {
setOf(
PoiTypes.ARMORER,
PoiTypes.BUTCHER,
PoiTypes.CARTOGRAPHER,
PoiTypes.CLERIC,
PoiTypes.FARMER,
PoiTypes.FISHERMAN,
PoiTypes.FLETCHER,
PoiTypes.LEATHERWORKER,
PoiTypes.LIBRARIAN,
PoiTypes.MASON,
PoiTypes.SHEPHERD,
PoiTypes.TOOLSMITH,
PoiTypes.WEAPONSMITH,
PoiTypes.LODESTONE,
PoiTypes.LIGHTNING_ROD,
)
}
val memory = Quaedam.memoryTypes.register(ID) {
MemoryModuleType(Optional.of(GlobalPos.CODEC))
}!!
fun createAcquirePoi() =
AcquirePoi.create({ it.`is` { key -> key in poiTypes } }, memory.get(), false, Optional.empty())
fun createStrollToPoi() =
StrollToPoi.create(memory.get(), 0.4f, 7, 4)
fun createStrollAroundPoi() =
StrollAroundPoi.create(memory.get(), 0.4f, 5)
}

View File

@@ -75,8 +75,11 @@ class ProjectorBlockEntity(pos: BlockPos, state: BlockState) :
val chunk = ChunkPos(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z))
val minChunk = ChunkPos(chunk.x - radius, chunk.z - radius)
val maxChunk = ChunkPos(chunk.x + radius, chunk.z + radius)
val minBlock = BlockPos(minChunk.minBlockX, Int.MIN_VALUE, minChunk.minBlockZ)
val maxBlock = BlockPos(maxChunk.maxBlockX, Int.MAX_VALUE, maxChunk.maxBlockZ)
// Y is not the limit value of Int because at
// Lnet/minecraft/world/level/entity/EntitySectionStorage;forEachAccessibleNonEmptySection(Lnet/minecraft/world/phys/AABB;Lnet/minecraft/util/AbortableIterationConsumer;)V
// it may get overflow
val minBlock = BlockPos(minChunk.minBlockX, Short.MIN_VALUE.toInt(), minChunk.minBlockZ)
val maxBlock = BlockPos(maxChunk.maxBlockX, Short.MAX_VALUE.toInt(), maxChunk.maxBlockZ)
effectArea = BoundingBox.fromCorners(minBlock, maxBlock)
effectAreaAABB = AABB(minBlock, maxBlock)
}

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@@ -23,8 +23,10 @@
"quaedam.shell.skylight.factor": "Factor",
"quaedam.shell.noise.rate": "Rate",
"quaedam.shell.noise.amount": "Amount",
"quaedam.shell.noise.volume": "Volume",
"quaedam.shell.swarm.max_count": "Max Count",
"quaedam.shell.sound.rate": "Rate",
"quaedam.shell.sound.volume": "Volume",
"quaedam.shell.music.volume_factor": "Volume Factor",
"quaedam.shell.music.particle": "Particle",
"quaedam.shell.music.particle.true": "Display",

View File

@@ -23,8 +23,10 @@
"quaedam.shell.skylight.factor": "因子",
"quaedam.shell.noise.rate": "速率",
"quaedam.shell.noise.amount": "数量",
"quaedam.shell.noise.volume": "响度因子",
"quaedam.shell.swarm.max_count": "最大数量",
"quaedam.shell.sound.rate": "速率",
"quaedam.shell.sound.volume": "响度因子",
"quaedam.shell.music.volume_factor": "响度因子",
"quaedam.shell.music.particle": "粒子效果",
"quaedam.shell.music.particle.true": "显示",

View File

@@ -23,8 +23,10 @@
"quaedam.shell.skylight.factor": "防晒系数",
"quaedam.shell.noise.rate": "急急急等级",
"quaedam.shell.noise.amount": "声卡压榨等级",
"quaedam.shell.noise.volume": "振幅大小",
"quaedam.shell.swarm.max_count": "显卡和处理器迫害等级",
"quaedam.shell.sound.rate": "急急急等级",
"quaedam.shell.sound.volume": "振幅大小",
"quaedam.shell.music.volume_factor": "振幅大小",
"quaedam.shell.music.particle": "会变色的颗粒buff",
"quaedam.shell.music.particle.true": "打开",

82
fabric/build.gradle.kts Normal file
View File

@@ -0,0 +1,82 @@
plugins {
id("com.github.johnrengelman.shadow")
}
architectury {
platformSetupLoomIde()
fabric()
}
loom {
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
}
val common: Configuration by configurations.creating
val shadowCommon: Configuration by configurations.creating
val developmentFabric: Configuration by configurations.getting
configurations {
compileOnly.configure { extendsFrom(common) }
runtimeOnly.configure { extendsFrom(common) }
developmentFabric.extendsFrom(common)
}
dependencies {
modImplementation("net.fabricmc:fabric-loader:${rootProject.property("fabric_loader_version")}")
modApi("net.fabricmc.fabric-api:fabric-api:${rootProject.property("fabric_version")}")
modApi("dev.architectury:architectury-fabric:${rootProject.property("architectury_version")}")
modImplementation("net.fabricmc:fabric-language-kotlin:${rootProject.property("fabric_kotlin_version")}")
common(project(":common", "namedElements")) {
isTransitive = false
}
shadowCommon(project(":common", "transformProductionFabric")){
isTransitive = false
}
}
tasks.processResources {
inputs.property("version", project.version)
filesMatching("fabric.mod.json") {
expand(
mapOf(
"version" to project.version,
"minecraft_version" to rootProject.property("minecraft_version"),
"architectury_version" to rootProject.property("architectury_version"),
"fabric_kotlin_version" to rootProject.property("fabric_kotlin_version")
)
)
}
}
tasks.shadowJar {
exclude("architectury.common.json")
configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}
tasks.remapJar {
injectAccessWidener.set(true)
inputFile.set(tasks.shadowJar.get().archiveFile)
dependsOn(tasks.shadowJar)
archiveClassifier.set(null as String?)
}
tasks.jar {
archiveClassifier.set("dev")
}
tasks.sourcesJar {
val commonSources = project(":common").tasks.getByName<Jar>("sourcesJar")
dependsOn(commonSources)
from(commonSources.archiveFile.map { zipTree(it) })
}
components.getByName("java") {
this as AdhocComponentWithVariants
this.withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) {
skip()
}
}

View File

@@ -0,0 +1,12 @@
package quaedam.fabric
import net.fabricmc.api.ModInitializer
import quaedam.Quaedam
object QuaedamFabric: ModInitializer {
override fun onInitialize() {
Quaedam.init()
}
}

View File

@@ -0,0 +1,34 @@
{
"schemaVersion": 1,
"id": "quaedam",
"version": "${version}",
"name": "Quaedam",
"description": "Hot hot hot!",
"authors": [
"xtex"
],
"contact": {
"homepage": "https://codeberg.org/xtex/quaedam",
"sources": "https://codeberg.org/xtex/quaedam"
},
"license": "Apache-2.0",
"icon": "assets/quaedam/icon.png",
"environment": "*",
"entrypoints": {
"main": [
{
"adapter": "kotlin",
"value": "quaedam.fabric.QuaedamFabric"
}
]
},
"mixins": [
"quaedam-common.mixins.json"
],
"depends": {
"fabric": "*",
"minecraft": ">=${minecraft_version}",
"architectury": ">=${architectury_version}",
"fabric-language-kotlin": ">=${fabric_kotlin_version}"
}
}

View File

@@ -0,0 +1,13 @@
{
"required": true,
"package": "quaedam.fabric.mixin",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}

View File

@@ -11,7 +11,7 @@ authors = "xtex"
description = '''
Hot hot hot!
'''
logoFile = "icon.png"
logoFile = "assets/quaedam/icon.png"
[[dependencies.quaedam]]
modId = "forge"

View File

@@ -1,13 +1,27 @@
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.jvmargs=-Xmx2048M
minecraft_version=1.20.1
parchment_version=2023.07.16
# https://www.curseforge.com/minecraft/mc-mods/architectury-api
parchment_version=2023.07.30
# https://modrinth.com/mod/architectury-api
architectury_version=9.1.12
# https://files.minecraftforge.net/net/minecraftforge/forge/
forge_version=1.20.1-47.1.43
# https://www.curseforge.com/minecraft/mc-mods/kotlin-for-forge/files
# https://modrinth.com/mod/kotlin-for-forge
kotlin_for_forge_version=4.4.0
# https://fabricmc.net/develop/
fabric_loader_version=0.14.21
fabric_version=0.86.1+1.20.1
# https://modrinth.com/mod/fabric-language-kotlin
fabric_kotlin_version=1.10.8+kotlin.1.9.0
# https://github.com/QuiltMC/quilt-loader/tags
quilt_loader_version=0.20.0-beta.5
# https://modrinth.com/mod/qsl
quilt_fabric_version=7.0.3+0.83.1-1.20.1
quilt_standard_library_version=6.0.4+1.20.1
# https://modrinth.com/mod/qkl
quilt_kotlin_libraries_version=2.1.1+kt.1.9.0+flk.1.9.6

86
quilt/build.gradle.kts Normal file
View File

@@ -0,0 +1,86 @@
plugins {
id("com.github.johnrengelman.shadow")
}
architectury {
platformSetupLoomIde()
loader("quilt")
}
loom {
accessWidenerPath.set(project(":common").loom.accessWidenerPath)
}
val common: Configuration by configurations.creating
val shadowCommon: Configuration by configurations.creating
val developmentQuilt: Configuration by configurations.getting
configurations {
compileOnly.configure { extendsFrom(common) }
runtimeOnly.configure { extendsFrom(common) }
developmentQuilt.extendsFrom(common)
}
dependencies {
modImplementation("org.quiltmc:quilt-loader:${rootProject.property("quilt_loader_version")}")
modApi("org.quiltmc.quilted-fabric-api:quilted-fabric-api:${rootProject.property("quilt_fabric_version")}")
modApi("dev.architectury:architectury-fabric:${rootProject.property("architectury_version")}") {
exclude("net.fabricmc")
exclude("net.fabricmc.fabric-api")
}
modApi("org.quiltmc:qsl:${rootProject.property("quilt_standard_library_version")}")
modApi("org.quiltmc.quilt-kotlin-libraries:quilt-kotlin-libraries:${rootProject.property("quilt_kotlin_libraries_version")}")
common(project(":common", "namedElements")) {
isTransitive = false
}
shadowCommon(project(":common", "transformProductionQuilt")) {
isTransitive = false
}
}
tasks.processResources {
inputs.property("version", project.version)
filesMatching("quilt.mod.json") {
expand(
mapOf(
"version" to project.version,
"minecraft_version" to rootProject.property("minecraft_version"),
"architectury_version" to rootProject.property("architectury_version"),
"quilt_kotlin_libraries_version" to rootProject.property("quilt_kotlin_libraries_version"),
)
)
}
}
tasks.shadowJar {
exclude("architectury.common.json")
configurations = listOf(shadowCommon)
archiveClassifier.set("dev-shadow")
}
tasks.remapJar {
injectAccessWidener.set(true)
inputFile.set(tasks.shadowJar.get().archiveFile)
dependsOn(tasks.shadowJar)
archiveClassifier.set(null as String?)
}
tasks.jar {
archiveClassifier.set("dev")
}
tasks.sourcesJar {
val commonSources = project(":common").tasks.getByName<Jar>("sourcesJar")
dependsOn(commonSources)
from(commonSources.archiveFile.map { zipTree(it) })
}
components.getByName("java") {
this as AdhocComponentWithVariants
this.withVariantsFromConfiguration(project.configurations["shadowRuntimeElements"]) {
skip()
}
}

1
quilt/gradle.properties Normal file
View File

@@ -0,0 +1 @@
loom.platform=quilt

View File

@@ -0,0 +1,12 @@
package quaedam.quilt
import net.fabricmc.api.ModInitializer
import quaedam.Quaedam
object QuaedamQuilt: ModInitializer {
override fun onInitialize() {
Quaedam.init()
}
}

View File

@@ -0,0 +1,13 @@
{
"required": true,
"package": "quaedam.fabric.mixin",
"compatibilityLevel": "JAVA_17",
"minVersion": "0.8",
"client": [
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}

View File

@@ -0,0 +1,59 @@
{
"_comment": "https://github.com/QuiltMC/rfcs/blob/main/specification/0002-quilt.mod.json.md",
"schema_version": 1,
"mixin": [
"quaedam-common.mixins.json"
],
"quilt_loader": {
"metadata": {
"name": "Quaedam",
"description": "Hot hot hot!",
"license": "Apache-2.0",
"authors": [
"xtex"
],
"contact": {
"homepage": "https://codeberg.org/xtex/quaedam",
"sources": "https://codeberg.org/xtex/quaedam"
},
"icon": "assets/quaedam/icon.png"
},
"group": "quaedam",
"id": "quaedam",
"version": "${version}",
"intermediate_mappings": "net.fabricmc:intermediary",
"entrypoints": {
"init": [
{
"adapter": "kotlin",
"value": "quaedam.quilt.QuaedamQuilt"
}
]
},
"depends": [
{
"id": "quilt_loader",
"version": "*"
},
{
"id": "quilt_base",
"version": "*"
},
{
"id": "minecraft",
"version": ">=${minecraft_version}"
},
{
"id": "architectury",
"version": ">=${architectury_version}"
},
{
"id": "qkl",
"version": ">=${quilt_kotlin_libraries_version}"
}
]
},
"minecraft": {
"environment": "*"
}
}

View File

@@ -10,5 +10,6 @@ pluginManagement {
include("common")
include("forge")
include("fabric", "quilt")
rootProject.name = "quaedam"