TileEntityFlowerPot .java

net.minecraft.tileentity.TileEntityFlowerPot (class, 77 lines): members: getFlowerPotData, getFlowerPotItem, setFlowerPotData, flowerPotData, readFromNBT.

net.minecraft.tileentityclass77 linescommonextends TileEntity2.2 KB

API Surface (6)

void writeToNBT(NBTTagCompound compound)
void readFromNBT(NBTTagCompound compound)
Packet getDescriptionPacket()
void setFlowerPotData(Item potItem, int potData)
Item getFlowerPotItem()
int getFlowerPotData()

Fields & Constants (2)

flowerPotItem
flowerPotData

String literals (1)

"Item"

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

TileEntityFlowerPot.java77 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.tileentity;
2
3
import net.minecraft.item.Item;
4
import net.minecraft.nbt.NBTTagCompound;
5
import net.minecraft.network.Packet;
6
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
7
import net.minecraft.util.ResourceLocation;
8
9
public class TileEntityFlowerPot extends TileEntity
10
{
11
    private Item flowerPotItem;
12
    private int flowerPotData;
13
14
    public TileEntityFlowerPot()
15
    {
16
    }
17
18
    public TileEntityFlowerPot(Item potItem, int potData)
19
    {
20
        this.flowerPotItem = potItem;
21
        this.flowerPotData = potData;
22
    }
23
24
    public void writeToNBT(NBTTagCompound compound)
25
    {
26
        super.writeToNBT(compound);
27
        ResourceLocation resourcelocation = (ResourceLocation)Item.itemRegistry.getNameForObject(this.flowerPotItem);
28
        compound.setString("Item", resourcelocation == null ? "" : resourcelocation.toString());
29
        compound.setInteger("Data", this.flowerPotData);
30
    }
31
32
    public void readFromNBT(NBTTagCompound compound)
33
    {
34
        super.readFromNBT(compound);
35
36
        if (compound.hasKey("Item", 8))
37
        {
38
            this.flowerPotItem = Item.getByNameOrId(compound.getString("Item"));
39
        }
40
        else
41
        {
42
            this.flowerPotItem = Item.getItemById(compound.getInteger("Item"));
43
        }
44
45
        this.flowerPotData = compound.getInteger("Data");
46
    }
47
48
    /**
49
     * Allows for a specialized description packet to be created. This is often used to sync tile entity data from the
50
     * server to the client easily. For example this is used by signs to synchronise the text to be displayed.
51
     */
52
    public Packet getDescriptionPacket()
53
    {
54
        NBTTagCompound nbttagcompound = new NBTTagCompound();
55
        this.writeToNBT(nbttagcompound);
56
        nbttagcompound.removeTag("Item");
57
        nbttagcompound.setInteger("Item", Item.getIdFromItem(this.flowerPotItem));
58
        return new S35PacketUpdateTileEntity(this.pos, 5, nbttagcompound);
59
    }
60
61
    public void setFlowerPotData(Item potItem, int potData)
62
    {
63
        this.flowerPotItem = potItem;
64
        this.flowerPotData = potData;
65
    }
66
67
    public Item getFlowerPotItem()
68
    {
69
        return this.flowerPotItem;
70
    }
71
72
    public int getFlowerPotData()
73
    {
74
        return this.flowerPotData;
75
    }
76
}
77

Deobfuscated MCP 1.8.9 source of TileEntityFlowerPot from Marcelektro/MavenMCP-1.8.9 (net/minecraft/tileentity/TileEntityFlowerPot.java), stored verbatim.