Prevent the linking to a drawer controller when using the multiple mode in the linking tool, closes #8

This commit is contained in:
Buuz135 2022-01-07 20:11:50 +01:00
parent d68f5d2fd5
commit 31466f0294

View File

@ -1,16 +1,12 @@
package com.buuz135.functionalstorage.block.tile; package com.buuz135.functionalstorage.block.tile;
import com.buuz135.functionalstorage.FunctionalStorage; import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.block.DrawerControllerBlock;
import com.buuz135.functionalstorage.block.config.FunctionalStorageConfig; import com.buuz135.functionalstorage.block.config.FunctionalStorageConfig;
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
import com.buuz135.functionalstorage.inventory.ControllerInventoryHandler; import com.buuz135.functionalstorage.inventory.ControllerInventoryHandler;
import com.buuz135.functionalstorage.item.ConfigurationToolItem; import com.buuz135.functionalstorage.item.ConfigurationToolItem;
import com.buuz135.functionalstorage.item.LinkingToolItem; import com.buuz135.functionalstorage.item.LinkingToolItem;
import com.buuz135.functionalstorage.item.UpgradeItem;
import com.hrznstudio.titanium.annotation.Save; import com.hrznstudio.titanium.annotation.Save;
import com.hrznstudio.titanium.block.BasicTileBlock; import com.hrznstudio.titanium.block.BasicTileBlock;
import com.hrznstudio.titanium.component.inventory.InventoryComponent;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction; import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
@ -75,7 +71,8 @@ public class DrawerControllerTile extends ControllableDrawerTile<DrawerControlle
public InteractionResult onSlotActivated(Player playerIn, InteractionHand hand, Direction facing, double hitX, double hitY, double hitZ) { public InteractionResult onSlotActivated(Player playerIn, InteractionHand hand, Direction facing, double hitX, double hitY, double hitZ) {
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())) return InteractionResult.PASS; if (stack.getItem().equals(FunctionalStorage.CONFIGURATION_TOOL.get()) || stack.getItem().equals(FunctionalStorage.LINKING_TOOL.get()))
return InteractionResult.PASS;
if (isServer()) { if (isServer()) {
for (int slot = 0; slot < getStorage().getSlots(); slot++) { for (int slot = 0; slot < getStorage().getSlots(); slot++) {
if (!stack.isEmpty() && getStorage().insertItem(slot, stack, true).getCount() != stack.getCount()) { if (!stack.isEmpty() && getStorage().insertItem(slot, stack, true).getCount() != stack.getCount()) {
@ -152,9 +149,11 @@ public class DrawerControllerTile extends ControllableDrawerTile<DrawerControlle
public void addConnectedDrawers(LinkingToolItem.ActionMode action, BlockPos... positions) { public void addConnectedDrawers(LinkingToolItem.ActionMode action, BlockPos... positions) {
for (BlockPos position : positions) { for (BlockPos position : positions) {
if (level.getBlockState(position).is(FunctionalStorage.DRAWER_CONTROLLER.get())) continue;
if (this.getBlockPos().closerThan(position, FunctionalStorageConfig.DRAWER_CONTROLLER_LINKING_RANGE)) { if (this.getBlockPos().closerThan(position, FunctionalStorageConfig.DRAWER_CONTROLLER_LINKING_RANGE)) {
if (action == LinkingToolItem.ActionMode.ADD) { if (action == LinkingToolItem.ActionMode.ADD) {
if (!connectedDrawers.getConnectedDrawers().contains(position.asLong())) this.connectedDrawers.getConnectedDrawers().add(position.asLong()); if (!connectedDrawers.getConnectedDrawers().contains(position.asLong()))
this.connectedDrawers.getConnectedDrawers().add(position.asLong());
} }
} }
if (action == LinkingToolItem.ActionMode.REMOVE) { if (action == LinkingToolItem.ActionMode.REMOVE) {