-
Notifications
You must be signed in to change notification settings - Fork 755
/
DryingRackLogic.java
153 lines (131 loc) · 3.67 KB
/
DryingRackLogic.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
147
148
149
150
151
152
153
package tconstruct.blocks.logic;
import mantle.blocks.abstracts.InventoryLogic;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import tconstruct.library.crafting.DryingRackRecipes;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class DryingRackLogic extends InventoryLogic
{
int currentTime;
int maxTime;
public DryingRackLogic()
{
super(1, 1);
}
@Override
public Container getGuiContainer (InventoryPlayer inventoryplayer, World world, int x, int y, int z)
{
return null;
}
@Override
public String getDefaultName ()
{
return "";
}
@Override
public void updateEntity ()
{
if (!worldObj.isRemote && maxTime > 0 && currentTime < maxTime)
{
currentTime++;
if (currentTime >= maxTime)
{
inventory[0] = DryingRackRecipes.getDryingResult(inventory[0]);
updateDryingTime();
}
}
}
@Override
public void setInventorySlotContents (int slot, ItemStack itemstack)
{
super.setInventorySlotContents(slot, itemstack);
updateDryingTime();
}
@Override
public ItemStack decrStackSize (int slot, int quantity)
{
ItemStack stack = super.decrStackSize(slot, quantity);
maxTime = 0;
currentTime = 0;
return stack;
}
public void updateDryingTime ()
{
currentTime = 0;
if (inventory[0] != null)
maxTime = DryingRackRecipes.getDryingTime(inventory[0]);
else
maxTime = 0;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public void readFromNBT (NBTTagCompound tags)
{
currentTime = tags.getInteger("Time");
maxTime = tags.getInteger("MaxTime");
readCustomNBT(tags);
}
@Override
public void writeToNBT (NBTTagCompound tags)
{
tags.setInteger("Time", currentTime);
tags.setInteger("MaxTime", maxTime);
writeCustomNBT(tags);
}
public void readCustomNBT (NBTTagCompound tags)
{
super.readFromNBT(tags);
}
public void writeCustomNBT (NBTTagCompound tags)
{
super.writeToNBT(tags);
}
/* Packets */
@Override
public Packet getDescriptionPacket ()
{
NBTTagCompound tag = new NBTTagCompound();
writeCustomNBT(tag);
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
}
@Override
public void onDataPacket (NetworkManager net, S35PacketUpdateTileEntity packet)
{
readCustomNBT(packet.func_148857_g());
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
}
@SideOnly(Side.CLIENT)
public AxisAlignedBB getRenderBoundingBox ()
{
AxisAlignedBB cbb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord - 1, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
return cbb;
}
@Override
public String getInventoryName ()
{
return null;
}
@Override
public boolean hasCustomInventoryName ()
{
return false;
}
@Override
public void closeInventory ()
{
// TODO Auto-generated method stub
}
@Override
public void openInventory ()
{
// TODO Auto-generated method stub
}
}