Skip to content

Commit

Permalink
Fix charger voiding items on right-click (#7942)
Browse files Browse the repository at this point in the history
Fixes #7934
  • Loading branch information
shartte committed Jun 18, 2024
1 parent 39cb312 commit 51ef1d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/java/appeng/block/misc/ChargerBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state,
Player player, InteractionHand hand, BlockHitResult hit) {
if (level.getBlockEntity(pos) instanceof ChargerBlockEntity charger) {
var inv = charger.getInternalInventory();
var chargingItem = inv.extractItem(0, Integer.MAX_VALUE, false);
var chargingItem = inv.getStackInSlot(0);
if (chargingItem.isEmpty()) {
if (ChargerRecipes.findRecipe(level, heldItem) != null || Platform.isChargeable(heldItem)) {
var toInsert = heldItem.split(1);
Expand All @@ -94,8 +94,9 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockP
BlockHitResult hitResult) {
if (level.getBlockEntity(pos) instanceof ChargerBlockEntity charger) {
var inv = charger.getInternalInventory();
var chargingItem = inv.extractItem(0, Integer.MAX_VALUE, false);
var chargingItem = inv.getStackInSlot(0);
if (!chargingItem.isEmpty()) {
inv.setItemDirect(0, ItemStack.EMPTY);
Platform.spawnDrops(player.level(), charger.getBlockPos().relative(charger.getFront()),
List.of(chargingItem));
return InteractionResult.sidedSuccess(level.isClientSide);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/appeng/debug/ItemGenBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ItemGenBlock() {
@Override
protected ItemInteractionResult useItemOn(ItemStack heldItem, BlockState state, Level level, BlockPos pos,
Player player, InteractionHand hand, BlockHitResult hit) {
if (level.getBlockEntity(pos) instanceof ItemGenBlockEntity itemGen) {
if (!heldItem.isEmpty() && level.getBlockEntity(pos) instanceof ItemGenBlockEntity itemGen) {
itemGen.setItem(heldItem.getItem());

return ItemInteractionResult.sidedSuccess(level.isClientSide);
Expand Down

0 comments on commit 51ef1d2

Please sign in to comment.