Make sure robots can't be used for recursive item storage.
This commit is contained in:
@@ -14,7 +14,6 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public final class RobotInventoryContainer extends AbstractRobotContainer {
|
||||
@@ -77,7 +76,7 @@ public final class RobotInventoryContainer extends AbstractRobotContainer {
|
||||
for (int slot = 0; slot < inventory.getSlots(); slot++) {
|
||||
final int x = 116 + (slot % 3) * SLOT_SIZE;
|
||||
final int y = 24 + (slot / 3) * SLOT_SIZE;
|
||||
addSlot(new SlotItemHandler(inventory, slot, x, y));
|
||||
addSlot(new RobotSlot(inventory, slot, x, y));
|
||||
}
|
||||
|
||||
createPlayerInventoryAndHotbarSlots(player.getInventory(), 8, 115);
|
||||
|
||||
16
src/main/java/li/cil/oc2/common/container/RobotSlot.java
Normal file
16
src/main/java/li/cil/oc2/common/container/RobotSlot.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package li.cil.oc2.common.container;
|
||||
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
|
||||
public final class RobotSlot extends SlotItemHandler {
|
||||
public RobotSlot(final IItemHandler itemHandler, final int index, final int xPosition, final int yPosition) {
|
||||
super(itemHandler, index, xPosition, yPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mayPlace(final ItemStack stack) {
|
||||
return super.mayPlace(stack) && stack.getItem().canFitInsideContainerItems();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
public final class RobotTerminalContainer extends AbstractRobotContainer {
|
||||
@@ -54,7 +53,7 @@ public final class RobotTerminalContainer extends AbstractRobotContainer {
|
||||
final ItemStackHandler inventory = robot.getInventory();
|
||||
for (int slot = 0; slot < inventory.getSlots(); slot++) {
|
||||
final int x = (terminalScreenWidth - inventory.getSlots() * SLOT_SIZE) / 2 + 1 + slot * SLOT_SIZE;
|
||||
addSlot(new SlotItemHandler(inventory, slot, x, terminalScreenHeight + 4));
|
||||
addSlot(new RobotSlot(inventory, slot, x, terminalScreenHeight + 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,11 @@ public final class RobotItem extends ModItem {
|
||||
return InteractionResult.sidedSuccess(level.isClientSide());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFitInsideContainerItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user