mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-17 19:15:24 +00:00
port to forestry 4.2
This commit is contained in:
1 parent
dbc5c1a564
commit
f969f63b66
3697 files changed
+78372
No files matched your search
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.30
|
||||
//
|
||||
|
||||
package binnie.craftgui.minecraft.control;
|
||||
|
||||
import java.util.Iterator;
|
||||
import binnie.craftgui.minecraft.InventoryType;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import java.util.ArrayList;
|
||||
import binnie.craftgui.core.IWidget;
|
||||
import java.util.List;
|
||||
import binnie.craftgui.controls.core.Control;
|
||||
|
||||
public class ControlSlotArray extends Control implements Iterable<ControlSlot>
|
||||
{
|
||||
private int rows;
|
||||
private int columns;
|
||||
private List<ControlSlot> slots;
|
||||
|
||||
public ControlSlotArray(final IWidget parent, final int x, final int y, final int columns, final int rows) {
|
||||
super(parent, x, y, columns * 18, rows * 18);
|
||||
this.slots = new ArrayList<ControlSlot>();
|
||||
this.rows = rows;
|
||||
this.columns = columns;
|
||||
for (int row = 0; row < rows; ++row) {
|
||||
for (int column = 0; column < columns; ++column) {
|
||||
this.slots.add(this.createSlot(column * 18, row * 18));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ControlSlot createSlot(final int x, final int y) {
|
||||
return new ControlSlot(this, x, y);
|
||||
}
|
||||
|
||||
public void setItemStacks(final ItemStack[] array) {
|
||||
int i = 0;
|
||||
for (final ItemStack item : array) {
|
||||
if (i >= this.slots.size()) {
|
||||
return;
|
||||
}
|
||||
this.slots.get(i).slot.putStack(item);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
public ControlSlot getControlSlot(final int i) {
|
||||
if (i < 0 || i >= this.slots.size()) {
|
||||
return null;
|
||||
}
|
||||
return this.slots.get(i);
|
||||
}
|
||||
|
||||
public ControlSlotArray create(final int[] index) {
|
||||
return this.create(InventoryType.Machine, index);
|
||||
}
|
||||
|
||||
public ControlSlotArray create(final InventoryType type, final int[] index) {
|
||||
int i = 0;
|
||||
for (final ControlSlot slot : this.slots) {
|
||||
slot.assign(type, index[i++]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<ControlSlot> iterator() {
|
||||
return this.slots.iterator();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user