fix draining items having weird behavior if passed a stack it can drain from
This commit is contained in:
parent
5193a20a0a
commit
a8ec68a846
2 changed files with 4 additions and 3 deletions
|
@ -154,11 +154,13 @@ data class CastingContext(
|
|||
fun withdrawItem(item: ItemStack, count: Int, actuallyRemove: Boolean): Boolean {
|
||||
if (this.caster.isCreative) return true
|
||||
|
||||
val operativeItem = item.copy()
|
||||
|
||||
// TODO: withdraw from ender chest given a specific ender charm?
|
||||
val stacksToExamine = DiscoveryHandlers.collectItemSlots(this)
|
||||
|
||||
fun matches(stack: ItemStack): Boolean =
|
||||
!stack.isEmpty && ItemStack.isSameItemSameTags(item, stack)
|
||||
!stack.isEmpty && ItemStack.isSameItemSameTags(operativeItem, stack)
|
||||
|
||||
val presentCount = stacksToExamine.fold(0) { acc, stack ->
|
||||
acc + if (matches(stack)) stack.count else 0
|
||||
|
|
|
@ -36,8 +36,7 @@ object OpColorize : SpellOperator {
|
|||
private data class Spell(val stack: ItemStack) : RenderedSpell {
|
||||
override fun cast(ctx: CastingContext) {
|
||||
val copy = stack.copy()
|
||||
copy.count = 1
|
||||
if (ctx.withdrawItem(stack, 1, true)) {
|
||||
if (ctx.withdrawItem(copy, 1, true)) {
|
||||
IXplatAbstractions.INSTANCE.setColorizer(
|
||||
ctx.caster,
|
||||
FrozenColorizer(copy, ctx.caster.uuid)
|
||||
|
|
Loading…
Reference in a new issue