Fixed batbox capability invalidation.

This commit is contained in:
Flanks255 2024-10-30 11:09:31 -05:00
parent 9fe3fa1c7c
commit 6596a8e6f9
2 changed files with 4 additions and 2 deletions

View file

@ -61,11 +61,12 @@ public class BlockBatteryBox extends BlockContainerBase {
protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) { protected ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult pHitResult) {
BlockEntity tile = world.getBlockEntity(pos); BlockEntity tile = world.getBlockEntity(pos);
if (tile instanceof TileEntityBatteryBox box) { if (tile instanceof TileEntityBatteryBox box) {
ItemStack stack = player.getItemInHand(hand); ItemStack stack = player.getItemInHand(hand);
if (!stack.isEmpty()) { if (!stack.isEmpty()) {
if (stack.getItem() instanceof ItemBattery && box.inv.getStackInSlot(0).isEmpty()) { if (stack.getItem() instanceof ItemBattery && box.inv.getStackInSlot(0).isEmpty()) {
box.inv.setStackInSlot(0, stack.copy()); box.inv.setStackInSlot(0, stack.copy());
box.invalidateCapabilities();
player.setItemInHand(hand, ItemStack.EMPTY); player.setItemInHand(hand, ItemStack.EMPTY);
return ItemInteractionResult.SUCCESS; return ItemInteractionResult.SUCCESS;
} }
@ -74,6 +75,7 @@ public class BlockBatteryBox extends BlockContainerBase {
if (!inSlot.isEmpty()) { if (!inSlot.isEmpty()) {
player.setItemInHand(hand, inSlot.copy()); player.setItemInHand(hand, inSlot.copy());
box.inv.setStackInSlot(0, ItemStack.EMPTY); box.inv.setStackInSlot(0, ItemStack.EMPTY);
box.invalidateCapabilities();
return ItemInteractionResult.SUCCESS; return ItemInteractionResult.SUCCESS;
} }
} }

View file

@ -135,7 +135,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
for (BlockEntity tile : startTile.tilesAround) { for (BlockEntity tile : startTile.tilesAround) {
if (tile instanceof TileEntityBatteryBox box) { if (tile instanceof TileEntityBatteryBox box) {
if (!pushOffTo.contains(box)) { if (!pushOffTo.contains(box)) {
pushOffTo.add(box); pushOffTo.add(box);
this.energyPushOffLoop(box, pushOffTo); this.energyPushOffLoop(box, pushOffTo);