Rightclicking a storage upgrade into a drawer it will replace upgrades of lower tier if the slots are full, closes #44
This commit is contained in:
parent
70abf74ce6
commit
95063289f0
|
@ -12,7 +12,7 @@ buildscript {
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
|
|
||||||
group = 'com.buuz135'
|
group = 'com.buuz135'
|
||||||
version = '1.18.2-1.0.2'
|
version = '1.18.2-1.0.3'
|
||||||
|
|
||||||
java {
|
java {
|
||||||
archivesBaseName = 'functionalstorage'
|
archivesBaseName = 'functionalstorage'
|
||||||
|
|
|
@ -263,14 +263,32 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
|
||||||
ItemStack stack = playerIn.getItemInHand(hand);
|
ItemStack stack = playerIn.getItemInHand(hand);
|
||||||
if (stack.getItem().equals(FunctionalStorage.CONFIGURATION_TOOL.get()) || stack.getItem().equals(FunctionalStorage.LINKING_TOOL.get()))
|
if (stack.getItem().equals(FunctionalStorage.CONFIGURATION_TOOL.get()) || stack.getItem().equals(FunctionalStorage.LINKING_TOOL.get()))
|
||||||
return InteractionResult.PASS;
|
return InteractionResult.PASS;
|
||||||
if (!stack.isEmpty() && stack.getItem() instanceof UpgradeItem) {
|
if (!stack.isEmpty() && stack.getItem() instanceof UpgradeItem upgradeItem) {
|
||||||
InventoryComponent component = ((UpgradeItem) stack.getItem()).getType() == UpgradeItem.Type.STORAGE ? storageUpgrades : utilityUpgrades;
|
if (upgradeItem instanceof StorageUpgradeItem storageUpgradeItem) {
|
||||||
|
InventoryComponent component = storageUpgrades;
|
||||||
for (int i = 0; i < component.getSlots(); i++) {
|
for (int i = 0; i < component.getSlots(); i++) {
|
||||||
if (component.getStackInSlot(i).isEmpty()) {
|
if (component.getStackInSlot(i).isEmpty()) {
|
||||||
playerIn.setItemInHand(hand, component.insertItem(i, stack, false));
|
playerIn.setItemInHand(hand, component.insertItem(i, stack, false));
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < component.getSlots(); i++) {
|
||||||
|
if (!component.getStackInSlot(i).isEmpty() && component.getStackInSlot(i).getItem() instanceof StorageUpgradeItem instertedUpgrade && instertedUpgrade.getStorageMultiplier() < storageUpgradeItem.getStorageMultiplier()) {
|
||||||
|
ItemHandlerHelper.giveItemToPlayer(playerIn, component.getStackInSlot(i).copy());
|
||||||
|
component.setStackInSlot(i, ItemStack.EMPTY);
|
||||||
|
playerIn.setItemInHand(hand, component.insertItem(i, stack, false));
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
InventoryComponent component = utilityUpgrades;
|
||||||
|
for (int i = 0; i < component.getSlots(); i++) {
|
||||||
|
if (component.getStackInSlot(i).isEmpty()) {
|
||||||
|
playerIn.setItemInHand(hand, component.insertItem(i, stack, false));
|
||||||
|
return InteractionResult.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (super.onActivated(playerIn, hand, facing, hitX, hitY, hitZ) == InteractionResult.SUCCESS) {
|
if (super.onActivated(playerIn, hand, facing, hitX, hitY, hitZ) == InteractionResult.SUCCESS) {
|
||||||
return InteractionResult.SUCCESS;
|
return InteractionResult.SUCCESS;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user