shrink zero-matter dust stack on split (even if it will never go truly empty)

This commit is contained in:
YuRaNnNzZZ 2023-03-11 13:16:46 +03:00
parent 45084e8fe0
commit b80fa51fbc
Signed by: YuRaNnNzZZ
GPG Key ID: 5F71738C85A6006D

View File

@ -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