-
Notifications
You must be signed in to change notification settings - Fork 754
/
StencilTableLogic.java
146 lines (129 loc) · 3.54 KB
/
StencilTableLogic.java
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package tconstruct.blocks.logic;
import tconstruct.common.TContent;
import tconstruct.common.TRepo;
import tconstruct.inventory.PatternShaperContainer;
import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
public class StencilTableLogic extends InventoryLogic implements ISidedInventory
{
public StencilTableLogic()
{
super(2);
}
public boolean canUpdate ()
{
return false;
}
@Override
public String getDefaultName ()
{
return "toolstation.PatternShaper";
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return new PatternShaperContainer(inventoryplayer, this);
}
/*@Override
public void markDirty()
{
if (inventory[0] == null)
inventory[1] = null;
super.markDirty();
}*/
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
if (slot == 0 && itemstack != null && itemstack.getItem() == TRepo.blankPattern)//instanceof tconstruct.items.Pattern)
{
if (itemstack.getItemDamage() == 0)
setInventorySlotContents(1, new ItemStack(TRepo.woodPattern, 1, 1));
/*else if (itemstack.getItemDamage() == 1)
setInventorySlotContents(1, new ItemStack(TContent.metalPattern, 1, 0));*/
}
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
if (slot == 1)
{
super.decrStackSize(0, 1);
if (inventory[0] == null)
return super.decrStackSize(slot, quantity);
else
return inventory[1].copy();
}
else
{
ItemStack ret = super.decrStackSize(slot, quantity);
if (inventory[0] == null)
super.decrStackSize(1, 1);
return ret;
}
}
public void altDecrStackSize (int slot, int quantity)
{
if (inventory[slot] != null)
{
if (inventory[slot].stackSize <= quantity)
{
ItemStack stack = inventory[slot];
inventory[slot] = null;
return;
}
ItemStack split = inventory[slot].splitStack(quantity);
if (inventory[slot].stackSize == 0)
{
inventory[slot] = null;
}
return;
}
}
@Override
public boolean canDropInventorySlot (int slot)
{
if (slot == 0)
return true;
else
return false;
}
@Override
public int[] getAccessibleSlotsFromSide (int side)
{
return new int[0];
}
@Override
public boolean canInsertItem (int i, ItemStack itemstack, int j)
{
return false;
}
@Override
public boolean canExtractItem (int i, ItemStack itemstack, int j)
{
return false;
}
@Override
public String getInventoryName ()
{
return StatCollector.translateToLocal("toolstation.PatternShaper");
}
@Override
public boolean hasCustomInventoryName ()
{
return true;
}
@Override
public void closeInventory ()
{
}
@Override
public void openInventory ()
{
}
}