71 lines
2.4 KiB
Java
71 lines
2.4 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.world.inventory;
|
|
|
|
import net.minecraft.world.Container;
|
|
import net.minecraft.world.SimpleContainer;
|
|
import net.minecraft.world.entity.player.Inventory;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.inventory.AbstractContainerMenu;
|
|
import net.minecraft.world.inventory.MenuType;
|
|
import net.minecraft.world.inventory.ShulkerBoxSlot;
|
|
import net.minecraft.world.inventory.Slot;
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
public class ShulkerBoxMenu
|
|
extends AbstractContainerMenu {
|
|
private static final int CONTAINER_SIZE = 27;
|
|
private final Container container;
|
|
|
|
public ShulkerBoxMenu(int containerId, Inventory inventory) {
|
|
this(containerId, inventory, new SimpleContainer(27));
|
|
}
|
|
|
|
public ShulkerBoxMenu(int containerId, Inventory inventory, Container container) {
|
|
super(MenuType.SHULKER_BOX, containerId);
|
|
ShulkerBoxMenu.checkContainerSize(container, 27);
|
|
this.container = container;
|
|
container.startOpen(inventory.player);
|
|
int rows = 3;
|
|
int columns = 9;
|
|
for (int y = 0; y < 3; ++y) {
|
|
for (int x = 0; x < 9; ++x) {
|
|
this.addSlot(new ShulkerBoxSlot(container, x + y * 9, 8 + x * 18, 18 + y * 18));
|
|
}
|
|
}
|
|
this.addStandardInventorySlots(inventory, 8, 84);
|
|
}
|
|
|
|
@Override
|
|
public boolean stillValid(Player player) {
|
|
return this.container.stillValid(player);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack quickMoveStack(Player player, int slotIndex) {
|
|
ItemStack clicked = ItemStack.EMPTY;
|
|
Slot slot = (Slot)this.slots.get(slotIndex);
|
|
if (slot != null && slot.hasItem()) {
|
|
ItemStack stack = slot.getItem();
|
|
clicked = stack.copy();
|
|
if (slotIndex < this.container.getContainerSize() ? !this.moveItemStackTo(stack, this.container.getContainerSize(), this.slots.size(), true) : !this.moveItemStackTo(stack, 0, this.container.getContainerSize(), false)) {
|
|
return ItemStack.EMPTY;
|
|
}
|
|
if (stack.isEmpty()) {
|
|
slot.setByPlayer(ItemStack.EMPTY);
|
|
} else {
|
|
slot.setChanged();
|
|
}
|
|
}
|
|
return clicked;
|
|
}
|
|
|
|
@Override
|
|
public void removed(Player player) {
|
|
super.removed(player);
|
|
this.container.stopOpen(player);
|
|
}
|
|
}
|
|
|