shrink zero-matter dust stack on split (even if it will never go truly empty)
This commit is contained in:
parent
45084e8fe0
commit
b80fa51fbc
@ -87,15 +87,17 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem {
|
|||||||
return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer)
|
return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer)
|
||||||
|
|
||||||
if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) {
|
if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) {
|
||||||
|
if (!pSlot.hasItem()) {
|
||||||
val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true
|
val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true
|
||||||
|
|
||||||
if (!pSlot.hasItem()) {
|
|
||||||
val halfStack = pStack.copyWithCount(1)
|
val halfStack = pStack.copyWithCount(1)
|
||||||
|
|
||||||
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide()))
|
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide()))
|
||||||
|
|
||||||
pSlot.set(halfStack)
|
pSlot.set(halfStack)
|
||||||
|
|
||||||
|
if (getMatterValue(pStack)?.matter!! <= Decimal.ZERO) {
|
||||||
|
pStack.shrink(1)
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,13 +117,11 @@ class MatterDustItem : Item(Properties().stacksTo(64)), IMatterItem {
|
|||||||
return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer)
|
return super.overrideStackedOnOther(pStack, pSlot, pAction, pPlayer)
|
||||||
|
|
||||||
if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) {
|
if (pAction == ClickAction.SECONDARY && pSlot.allowModification(pPlayer)) {
|
||||||
|
if (pOther.isEmpty) {
|
||||||
val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true
|
val matterHalf = getMatterValue(pStack)?.matter?.div(2) ?: return true
|
||||||
|
|
||||||
if (pOther.isEmpty) {
|
|
||||||
val halfStack = pStack.copyWithCount(1)
|
val halfStack = pStack.copyWithCount(1)
|
||||||
|
|
||||||
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide()))
|
matter(halfStack, -addMatterValue(pStack, -matterHalf, pPlayer.level.isClientSide()))
|
||||||
|
|
||||||
pAccess.set(halfStack)
|
pAccess.set(halfStack)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
Loading…
Reference in New Issue
Block a user