mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-28 22:05:01 +01:00
Fix JukeboxPoint (#7040)
This commit is contained in:
parent
d48a504486
commit
d97f01add8
1 changed files with 11 additions and 26 deletions
|
@ -646,45 +646,30 @@ public class AllArmInteractionPointTypes {
|
|||
|
||||
@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))
|
||||
if (!(level.getBlockEntity(pos) instanceof JukeboxBlockEntity jukeboxBE))
|
||||
return ItemStack.EMPTY;
|
||||
ItemStack record = jukeboxBE.getFirstItem();
|
||||
if (record.isEmpty())
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue