Changed how drawer insertion is done from the drawer controller interaction, closes #34
This commit is contained in:
parent
4f0dae10cc
commit
73d2d29c4a
|
@ -52,6 +52,7 @@ public class CompactingDrawerTile extends ControllableDrawerTile<CompactingDrawe
|
|||
public boolean isLocked() {
|
||||
return CompactingDrawerTile.this.isLocked();
|
||||
}
|
||||
|
||||
};
|
||||
lazyStorage = LazyOptional.of(() -> this.handler);
|
||||
this.hasCheckedRecipes = false;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.buuz135.functionalstorage.block.tile;
|
|||
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||
import com.buuz135.functionalstorage.block.config.FunctionalStorageConfig;
|
||||
import com.buuz135.functionalstorage.inventory.ControllerInventoryHandler;
|
||||
import com.buuz135.functionalstorage.inventory.ILockable;
|
||||
import com.buuz135.functionalstorage.item.ConfigurationToolItem;
|
||||
import com.buuz135.functionalstorage.item.LinkingToolItem;
|
||||
import com.hrznstudio.titanium.annotation.Save;
|
||||
|
@ -76,14 +77,34 @@ public class DrawerControllerTile extends ControllableDrawerTile<DrawerControlle
|
|||
if (stack.getItem().equals(FunctionalStorage.CONFIGURATION_TOOL.get()) || stack.getItem().equals(FunctionalStorage.LINKING_TOOL.get()))
|
||||
return InteractionResult.PASS;
|
||||
if (isServer()) {
|
||||
for (int slot = 0; slot < getStorage().getSlots(); slot++) {
|
||||
if (!stack.isEmpty() && !getStorage().getStackInSlot(slot).isEmpty() && getStorage().insertItem(slot, stack, true).getCount() != stack.getCount()) {
|
||||
playerIn.setItemInHand(hand, getStorage().insertItem(slot, stack, false));
|
||||
for (IItemHandler iItemHandler : this.getConnectedDrawers().handlers) {
|
||||
if (iItemHandler instanceof ILockable && ((ILockable) iItemHandler).isLocked()) {
|
||||
for (int slot = 0; slot < iItemHandler.getSlots(); slot++) {
|
||||
if (!stack.isEmpty() && iItemHandler.insertItem(slot, stack, true).getCount() != stack.getCount()) {
|
||||
playerIn.setItemInHand(hand, iItemHandler.insertItem(slot, stack, false));
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (System.currentTimeMillis() - INTERACTION_LOGGER.getOrDefault(playerIn.getUUID(), System.currentTimeMillis()) < 300) {
|
||||
for (ItemStack itemStack : playerIn.getInventory().items) {
|
||||
if (!itemStack.isEmpty() && !getStorage().getStackInSlot(slot).isEmpty() && getStorage().insertItem(slot, itemStack, true).getCount() != itemStack.getCount()) {
|
||||
itemStack.setCount(getStorage().insertItem(slot, itemStack.copy(), false).getCount());
|
||||
if (!itemStack.isEmpty() && iItemHandler.insertItem(slot, itemStack, true).getCount() != itemStack.getCount()) {
|
||||
itemStack.setCount(iItemHandler.insertItem(slot, itemStack.copy(), false).getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (IItemHandler iItemHandler : this.getConnectedDrawers().handlers) {
|
||||
if (iItemHandler instanceof ILockable && !((ILockable) iItemHandler).isLocked()) {
|
||||
for (int slot = 0; slot < iItemHandler.getSlots(); slot++) {
|
||||
if (!stack.isEmpty() && !iItemHandler.getStackInSlot(slot).isEmpty() && iItemHandler.insertItem(slot, stack, true).getCount() != stack.getCount()) {
|
||||
playerIn.setItemInHand(hand, iItemHandler.insertItem(slot, stack, false));
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (System.currentTimeMillis() - INTERACTION_LOGGER.getOrDefault(playerIn.getUUID(), System.currentTimeMillis()) < 300) {
|
||||
for (ItemStack itemStack : playerIn.getInventory().items) {
|
||||
if (!itemStack.isEmpty() && !iItemHandler.getStackInSlot(slot).isEmpty() && iItemHandler.insertItem(slot, itemStack, true).getCount() != itemStack.getCount()) {
|
||||
itemStack.setCount(iItemHandler.insertItem(slot, itemStack.copy(), false).getCount());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.annotation.Nonnull;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BigInventoryHandler implements IItemHandler, INBTSerializable<CompoundTag> {
|
||||
public abstract class BigInventoryHandler implements IItemHandler, INBTSerializable<CompoundTag>, ILockable {
|
||||
|
||||
public static String BIG_ITEMS = "BigItems";
|
||||
public static String STACK = "Stack";
|
||||
|
|
|
@ -11,7 +11,7 @@ import javax.annotation.Nonnull;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class CompactingInventoryHandler implements IItemHandler, INBTSerializable<CompoundTag> {
|
||||
public abstract class CompactingInventoryHandler implements IItemHandler, INBTSerializable<CompoundTag>, ILockable {
|
||||
|
||||
public static String PARENT = "Parent";
|
||||
public static String BIG_ITEMS = "BigItems";
|
||||
|
@ -179,8 +179,6 @@ public abstract class CompactingInventoryHandler implements IItemHandler, INBTSe
|
|||
|
||||
public abstract boolean isVoid();
|
||||
|
||||
public abstract boolean isLocked();
|
||||
|
||||
public List<CompactingUtil.Result> getResultList() {
|
||||
return resultList;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@ public abstract class ControllerInventoryHandler implements IItemHandler {
|
|||
this.slots = getDrawers().getHandlers().stream().filter(iItemHandler -> !(iItemHandler instanceof ControllerInventoryHandler)).map(IItemHandler::getSlots).mapToInt(Integer::intValue).sum();
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slot) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.buuz135.functionalstorage.FunctionalStorage;
|
|||
import com.buuz135.functionalstorage.world.EnderSavedData;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class EnderInventoryHandler extends BigInventoryHandler{
|
||||
public class EnderInventoryHandler extends BigInventoryHandler implements ILockable {
|
||||
|
||||
public static String NBT_LOCKED = "Locked";
|
||||
public static String NBT_VOID = "Void";
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.buuz135.functionalstorage.inventory;
|
||||
|
||||
public interface ILockable {
|
||||
|
||||
boolean isLocked();
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user