Skip to content

Commit

Permalink
added more types to shooter ammunition
Browse files Browse the repository at this point in the history
  • Loading branch information
12rcu committed Jan 22, 2024
1 parent 546bf5a commit db82183
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ class BehItemComponents : MonsteraFile {
fun shooter(settings: BehItemShooter.() -> Unit) {
val behItemShooter = BehItemShooter().apply { settings(this) }
unsafe.general.apply {
put("minecraft:shooter", behItemShooter.getData())
put("minecraft:shooter", behItemShooter.unsafe.getData())
}
}

Expand Down Expand Up @@ -468,7 +468,18 @@ class BehItemComponents : MonsteraFile {
@ExperimentalUnsignedTypes
private fun sampleShooter() {
shooter {
ammunition("arrow")
ammunition {
item = "minecraft:arrow"
useOffhand = true
searchInventory = true
useInCreative = true
}
ammunition {
item = "minecraft:fireworks_rocket"
useOffhand = true
searchInventory = true
useInCreative = true
}
chargeOnDraw(true)
launchPowerScale(1.0f)
maxDrawDuration(2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
package com.lop.devtools.monstera.files.beh.item.comp

class BehItemShooter {
import com.lop.devtools.monstera.addon.api.MonsteraFile
import com.lop.devtools.monstera.addon.api.MonsteraUnsafe
import com.lop.devtools.monstera.addon.api.MonsteraUnsafeMap

class BehItemShooter: MonsteraFile {
override val unsafe = Unsafe()

inner class Unsafe: MonsteraUnsafeMap {
val general = mutableMapOf<String, Any>()

val ammo = mutableListOf<BehItemShooterAmmo>()

override fun getData(): MutableMap<String, Any> {
if(ammo.isNotEmpty())
general["ammunition"] = ammo.map { it.unsafe.getData() }
return general
}
}

@Deprecated("", ReplaceWith("unsafe.general"))
val general = mutableMapOf<String, Any>()

var chargeOnDraw: Boolean = false
set(value) {
unsafe.general["charge_on_draw"] = value
field = value
}



/**
* Ammunition.
*/
fun ammunition(ammunition: String) {
general.apply {
put("ammunition", ammunition)
}
fun ammunition(ammunition: BehItemShooterAmmo.() -> Unit) {
unsafe.ammo.add(BehItemShooterAmmo().apply(ammunition))
}

/**
Expand All @@ -25,39 +50,64 @@ class BehItemShooter {
* Launch power scale. Default is set to 1.0.
*/
fun launchPowerScale(value: Float = 1.0f) {
general.apply {
put("launch_power_scale", value)
}
unsafe.general["launch_power_scale"] = value
}

/**
* Draw Duration. Default is set to 0.
*/
fun maxDrawDuration(value: Int = 0) {
general.apply {
put("max_draw_duration", value)
}
unsafe.general["max_draw_duration"] = value
}

/**
* Launch power. Default is set to 1.0.
*/
fun maxLaunchPower(value: Float = 1.0f) {
general.apply {
put("max_launch_power", value)
}
unsafe.general["max_launch_power"] = value
}

/**
* Scale power by draw duration? Default is set to false.
*/
fun scalePowerByDrawDuration(value: Boolean = false) {
general.apply {
put("scale_power_by_draw_duration", value)
}
unsafe.general["scale_power_by_draw_duration"] = value
}

fun getData(): MutableMap<String, Any> {
return general
@Deprecated("", ReplaceWith("unsafe.getData()"))
fun getData(): MutableMap<String, Any> = unsafe.getData()
}

class BehItemShooterAmmo: MonsteraFile {
override val unsafe = Unsafe()

inner class Unsafe: MonsteraUnsafeMap {
val general = mutableMapOf<String, Any>()

override fun getData() = general
}

var item: String = ""
set(value) {
unsafe.general["item"] = value
field = value
}

var useOffhand: Boolean = false
set(value) {
unsafe.general["use_offhand"] = value
field = value
}

var searchInventory: Boolean = false
set(value) {
unsafe.general["search_inventory"] = value
field = value
}

var useInCreative: Boolean = false
set(value) {
unsafe.general["use_in_creative"] = value
field = value
}
}

0 comments on commit db82183

Please sign in to comment.