Skip to content

Commit

Permalink
don't build empty render controllers + added config list for vanilla …
Browse files Browse the repository at this point in the history
…files that should not be hashed
  • Loading branch information
12rcu committed May 6, 2024
1 parent b5d763d commit b716f89
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/main/kotlin/com/lop/devtools/monstera/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ class Config(
var langFileBuilder: AddonLangFileBuilders = AddonLangFileBuilders(behPath, resPath),
var scriptEntryFile: File = File(),
var scriptingVersion: String = "1.8.0",
var hashFileNames: Boolean = false
var hashFileNames: Boolean = false,
/**
* don't hash or modify these file names on build
*/
var vanillaFileNames: List<String> = listOf("player", "humanoid")
) {
init {
behPath.toFile().deleteRecursively()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ open class ResourceEntity(val unsafeParent: Entity) {
renderParts.forEach { it.build() }
}

if (!disableRender) {
if (!disableRender && !unsafeRenderController.isEmpty()) {
unsafeRenderController.build(unsafeParent.name, unsafeParent.addon.config.paths.resRenderControllers)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ fun sanetiseFilename(filename: String, fileSuffix: String): String {
.removeSuffix(".$fileSuffix")
.replace("-", "_")
.replace(" ", "_")
if(Addon.active?.config?.hashFileNames == true) {
val vanillaName = (Addon.active?.config?.vanillaFileNames ?: listOf("player", "humanoid")).contains(sanFile)
if(Addon.active?.config?.hashFileNames == true && !vanillaName) {
sanFile = getUniqueBuildFileName(Addon.active!!.config.namespace, sanFile)
}
return "${sanFile}.$fileSuffix"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class ResRenderControllers : MonsteraBuildableFile, MonsteraRawFile() {
return Result.success(target)
}

fun isEmpty() : Boolean = renderControllers?.isEmpty() ?: true

@SerializedName("format_version")
@Expose
var formatVersion: String = "1.10.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.lop.devtools.monstera.addon.entitiy.wiki

import com.lop.devtools.monstera.addon.buildTestAddon
import com.lop.devtools.monstera.addon.testAddon
import kotlin.test.AfterTest
import kotlin.test.Test

class Boat {
@AfterTest
fun buildTask() {
buildTestAddon()
}

@Test
fun testBoat() = testAddon {
entity("my_boat", "My Boat") {
behaviour {
components {
behRiseToLiquidLevel {
priority = 0
liquidYOffset = 0.5
riseDelta = 0.05
sinkDelta = 0.05
}
underwaterMovement {
value = 5
}
navigationWalk {
canSink = false
}
rideable {
seatCount = 1
familyTypes("player")
interactText("ride", "action.interact.enter_boat")
seat {
position(0, 0, 0)
}
}
inputGroundControlled { }
collisionBox {
width = 1
height = 1
}
physics { }
}
}
}
entity("my_second_boat") {
behaviour {
components {
buoyant {
applyGravity = true
baseBuoyancy = 1
simulateWaves = true
bigWaveProbability = 0.03
bigWaveSpeed = 10
dragDownOnBuoyancyRemoved = 0
liquidBlocks("water")
}
underwaterMovement {
value = 5
}
navigationWalk {
canSink = false
}
rideable {
seatCount = 1
familyTypes("player")
interactText("ride", "action.interact.enter_boat")
seat {
position(0, 0, 0)
}
}
inputGroundControlled { }
collisionBox {
width = 1
height = 1
}
physics { }
movementBasic { }
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.lop.devtools.monstera.addon.entitiy.wiki

import com.lop.devtools.monstera.addon.buildTestAddon
import kotlin.test.AfterTest

class Sleeping {
@AfterTest
fun buildTask() {
buildTestAddon()
}


}

0 comments on commit b716f89

Please sign in to comment.