From b269bc940abe5e5c61a084e364e9b7b5476bf30c Mon Sep 17 00:00:00 2001 From: IThundxr Date: Tue, 8 Oct 2024 17:54:13 -0400 Subject: [PATCH] Fix JukeboxPoint - Fixes #5902 --- .../AllArmInteractionPointTypes.java | 37 ++++++------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java index 8740d57402..d6d7c6c0c6 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java +++ b/src/main/java/com/simibubi/create/content/kinetics/mechanicalArm/AllArmInteractionPointTypes.java @@ -646,45 +646,30 @@ public int getSlotCount() { @Override public ItemStack insert(ItemStack stack, boolean simulate) { - Item item = stack.getItem(); - if (!(item instanceof RecordItem)) + if (!(stack.getItem() instanceof RecordItem)) return stack; - if (cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD) - .orElse(true)) + if (cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD).orElse(true)) return stack; - BlockEntity blockEntity = level.getBlockEntity(pos); - if (!(blockEntity instanceof JukeboxBlockEntity jukeboxBE)) + if (!(level.getBlockEntity(pos) instanceof JukeboxBlockEntity jukeboxBE)) return stack; - if (!jukeboxBE.getFirstItem() - .isEmpty()) + if (!jukeboxBE.getFirstItem().isEmpty()) return stack; ItemStack remainder = stack.copy(); ItemStack toInsert = remainder.split(1); - if (!simulate) { - jukeboxBE.setFirstItem(toInsert); - level.setBlock(pos, cachedState.setValue(JukeboxBlock.HAS_RECORD, true), 2); - level.levelEvent(null, 1010, pos, Item.getId(item)); - } + if (!simulate) + jukeboxBE.setItem(0, toInsert); return remainder; } @Override public ItemStack extract(int slot, int amount, boolean simulate) { - if (!cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD) - .orElse(false)) + if (!cachedState.getOptionalValue(JukeboxBlock.HAS_RECORD).orElse(false)) return ItemStack.EMPTY; - BlockEntity blockEntity = level.getBlockEntity(pos); - if (!(blockEntity instanceof JukeboxBlockEntity jukeboxBE)) - return ItemStack.EMPTY; - ItemStack record = jukeboxBE.getFirstItem(); - if (record.isEmpty()) + if (!(level.getBlockEntity(pos) instanceof JukeboxBlockEntity jukeboxBE)) return ItemStack.EMPTY; - if (!simulate) { - level.levelEvent(1010, pos, 0); - jukeboxBE.clearContent(); - level.setBlock(pos, cachedState.setValue(JukeboxBlock.HAS_RECORD, false), 2); - } - return record; + if (!simulate) + return jukeboxBE.removeItem(slot, amount); + return jukeboxBE.getFirstItem(); } }