2017-04-10 16:20:39 +02:00
|
|
|
/*
|
|
|
|
* This file is part of Industrial Wires.
|
|
|
|
* Copyright (C) 2016-2017 malte0811
|
|
|
|
*
|
|
|
|
* Industrial Wires is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Industrial Wires is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package malte0811.industrialWires.containers;
|
|
|
|
|
|
|
|
import blusunrize.immersiveengineering.common.gui.ContainerIEBase;
|
2017-04-13 17:14:05 +02:00
|
|
|
import malte0811.industrialWires.controlpanel.*;
|
2017-04-10 16:20:39 +02:00
|
|
|
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
2017-04-12 15:55:37 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2017-04-10 16:20:39 +02:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2017-04-12 15:55:37 +02:00
|
|
|
import net.minecraft.inventory.ClickType;
|
2017-04-10 16:20:39 +02:00
|
|
|
import net.minecraft.inventory.Slot;
|
2017-04-12 15:55:37 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2017-04-10 16:20:39 +02:00
|
|
|
|
|
|
|
//TODO remove dependency on core IE
|
|
|
|
public class ContainerPanelCreator extends ContainerIEBase<TileEntityPanelCreator> {
|
2017-04-12 15:55:37 +02:00
|
|
|
public PanelComponent toPlace = null;
|
2017-04-10 16:20:39 +02:00
|
|
|
public ContainerPanelCreator(InventoryPlayer inventoryPlayer, TileEntityPanelCreator tile) {
|
|
|
|
super(inventoryPlayer, tile);
|
2017-04-12 15:55:37 +02:00
|
|
|
int slotH = 130;
|
2017-04-13 17:14:05 +02:00
|
|
|
slotCount = 1;
|
|
|
|
addSlotToContainer(new Slot(inv, 0, 0, 36));
|
2017-04-10 16:20:39 +02:00
|
|
|
for (int i = 0; i < 3; i++)
|
|
|
|
for (int j = 0; j < 9; j++)
|
2017-04-12 15:55:37 +02:00
|
|
|
addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, slotH+i*18));
|
2017-04-10 16:20:39 +02:00
|
|
|
for (int i = 0; i < 9; i++)
|
2017-04-12 15:55:37 +02:00
|
|
|
addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, slotH+58));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack slotClick(int id, int button, ClickType clickType, EntityPlayer player) {
|
|
|
|
if (id >= 0) {
|
|
|
|
Slot s = getSlot(id);
|
|
|
|
if (s instanceof ComponentFakeSlot) {
|
|
|
|
if (!((ComponentFakeSlot) s).isSelected()) {
|
|
|
|
toPlace = ((ComponentFakeSlot) s).select();
|
|
|
|
for (int i = 0; i < slotCount; i++) {
|
|
|
|
Slot slot = getSlot(i);
|
|
|
|
if (slot != s && slot instanceof ComponentFakeSlot) {
|
|
|
|
((ComponentFakeSlot) slot).unselect();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
toPlace = null;
|
|
|
|
((ComponentFakeSlot) s).unselect();
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.slotClick(id, button, clickType, player);
|
2017-04-10 16:20:39 +02:00
|
|
|
}
|
|
|
|
}
|