summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/ItemStack.java
blob: 5d30421ce92b75dbbb4454c99a08ba2cbdbb4317 (plain)
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package net.minecraft.server;

public final class ItemStack {

    public int a;
    public int b;
    public int c;
    public int d; // Craftbukkit - make public

    public ItemStack(Block block) {
        this(block, 1);
    }

    public ItemStack(Block block, int k) {
        this(block.bi, k, 0);
    }

    public ItemStack(Block block, int k, int l) {
        this(block.bi, k, l);
    }

    public ItemStack(Item item) {
        this(item.ba, 1, 0);
    }

    public ItemStack(Item item, int k) {
        this(item.ba, k, 0);
    }

    public ItemStack(Item item, int k, int l) {
        this(item.ba, k, l);
    }

    public ItemStack(int k, int l, int i1) {
        a = 0;
        c = k;
        a = l;
        d = i1;
    }

    public ItemStack(NBTTagCompound nbttagcompound) {
        a = 0;
        b(nbttagcompound);
    }

    public ItemStack a(int k) {
        a -= k;
        return new ItemStack(c, k, d);
    }

    public Item a() {
        return Item.c[c];
    }

    public boolean a(EntityPlayer entityplayer, World world, int k, int l, int i1, int j1) {
        return a().a(this, entityplayer, world, k, l, i1, j1);
    }

    public float a(Block block) {
        return a().a(this, block);
    }

    public ItemStack a(World world, EntityPlayer entityplayer) {
        return a().a(this, world, entityplayer);
    }

    public NBTTagCompound a(NBTTagCompound nbttagcompound) {
        nbttagcompound.a("id", (short) c);
        nbttagcompound.a("Count", (byte) a);
        nbttagcompound.a("Damage", (short) d);
        return nbttagcompound;
    }

    public void b(NBTTagCompound nbttagcompound) {
        c = ((int) (nbttagcompound.c("id")));
        a = ((int) (nbttagcompound.b("Count")));
        d = ((int) (nbttagcompound.c("Damage")));
    }

    public int b() {
        return a().b();
    }

    public boolean c() {
        return b() > 1 && (!d() || !f());
    }

    public boolean d() {
        return Item.c[c].d() > 0;
    }

    public boolean e() {
        return Item.c[c].c();
    }

    public boolean f() {
        return d() && d > 0;
    }

    public int g() {
        return d;
    }

    public int h() {
        return d;
    }

    public int i() {
        return Item.c[c].d();
    }

    public void b(int k) {
        if (!d()) {
            return;
        }
        d += k;
        if (d > i()) {
            a--;
            if (a < 0) {
                a = 0;
            }
            d = 0;
        }
    }

    public void a(EntityLiving entityliving) {
        Item.c[c].a(this, entityliving);
    }

    public void a(int k, int l, int i1, int j1) {
        Item.c[c].a(this, k, l, i1, j1);
    }

    public int a(Entity entity) {
        return Item.c[c].a(entity);
    }

    public boolean b(Block block) {
        return Item.c[c].a(block);
    }

    public void a(EntityPlayer entityplayer) {}

    public void b(EntityLiving entityliving) {
        Item.c[c].b(this, entityliving);
    }

    public ItemStack j() {
        return new ItemStack(c, a, d);
    }

    public static boolean a(ItemStack itemstack, ItemStack itemstack1) {
        if (itemstack == null && itemstack1 == null) {
            return true;
        }
        if (itemstack == null || itemstack1 == null) {
            return false;
        } else {
            return itemstack.c(itemstack1);
        }
    }

    private boolean c(ItemStack itemstack) {
        if (a != itemstack.a) {
            return false;
        }
        if (c != itemstack.c) {
            return false;
        }
        return d == itemstack.d;
    }

    public boolean a(ItemStack itemstack) {
        return c == itemstack.c && d == itemstack.d;
    }

    public static ItemStack b(ItemStack itemstack) {
        return itemstack != null ? itemstack.j() : null;
    }

    public String toString() {
        return (new StringBuilder()).append(a).append("x").append(Item.c[c].a()).append("@").append(d).toString();
    }
}