Skip to content

Commit

Permalink
Added set_custom_model_data
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed May 23, 2023
1 parent fd55c7f commit ebce265
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/kotlin/com/willfp/libreforge/effects/Effects.kt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import com.willfp.libreforge.effects.impl.EffectSellMultiplier
import com.willfp.libreforge.effects.impl.EffectSendMessage
import com.willfp.libreforge.effects.impl.EffectSendTitle
import com.willfp.libreforge.effects.impl.EffectSetBlock
import com.willfp.libreforge.effects.impl.EffectSetCustomModelData
import com.willfp.libreforge.effects.impl.EffectSetFreezeTicks
import com.willfp.libreforge.effects.impl.EffectSetGlobalPoints
import com.willfp.libreforge.effects.impl.EffectSetItemPoints
Expand Down Expand Up @@ -455,5 +456,6 @@ object Effects : Registry<Effect<*>>() {
register(EffectMultiplyItemPoints)
register(EffectSetGlobalPoints)
register(EffectSetItemPoints)
register(EffectSetCustomModelData)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.willfp.libreforge.effects.impl

import com.willfp.eco.core.config.interfaces.Config
import com.willfp.libreforge.NoCompileData
import com.willfp.libreforge.arguments
import com.willfp.libreforge.effects.Effect
import com.willfp.libreforge.getIntFromExpression
import com.willfp.libreforge.triggers.TriggerData
import com.willfp.libreforge.triggers.TriggerParameter

object EffectSetCustomModelData : Effect<NoCompileData>("set_custom_model_data") {
override val parameters = setOf(
TriggerParameter.ITEM
)

override val arguments = arguments {
require("model", "You must specify the custom model data ID!")
}

override fun onTrigger(config: Config, data: TriggerData, compileData: NoCompileData): Boolean {
val item = data.item ?: return false
val meta = item.itemMeta ?: return false

meta.setCustomModelData(config.getIntFromExpression("model", data))
item.itemMeta = meta

return true
}
}

0 comments on commit ebce265

Please sign in to comment.