-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInventoryTree.java
More file actions
47 lines (38 loc) · 1.01 KB
/
Copy pathInventoryTree.java
File metadata and controls
47 lines (38 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.custommods.ai;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
public class InventoryTree {
private ItemStack item;
private int stackSize;
private List childs;
private int numberOfChilds = 0;
public InventoryTree(ItemStack item , int stack) {
this.item = new ItemStack(item.getItem());
this.stackSize = stack;
}
public InventoryTree AddChild (ItemStack item , int stack){
if (numberOfChilds == 0){
childs = new ArrayList<InventoryTree>();
}
childs.add(new InventoryTree(item, stack));
numberOfChilds++;
return (InventoryTree)childs.get(numberOfChilds -1);
}
public int GetNumberOfChilds(){
return numberOfChilds;
}
public InventoryTree GetChild(int index){
if (index <= numberOfChilds){
return (InventoryTree) childs.get(index);
}
return null;
}
public boolean removeChild(int index){
if (index <= numberOfChilds){
childs.remove(index);
return true;
}
return false;
}
}