blob: f9bbd711251f5a695bfa1fdbb084783d608f8905 (
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
|
package org.bukkit.craftbukkit.inventory;
import net.minecraft.server.ContainerAnvil;
import net.minecraft.server.IInventory;
import org.bukkit.Location;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack;
public class CraftInventoryAnvil extends CraftInventory implements AnvilInventory {
private final Location location;
private final IInventory resultInventory;
private final ContainerAnvil container;
public CraftInventoryAnvil(Location location, IInventory inventory, IInventory resultInventory, ContainerAnvil container) {
super(inventory);
this.location = location;
this.resultInventory = resultInventory;
this.container = container;
}
public IInventory getResultInventory() {
return resultInventory;
}
public IInventory getIngredientsInventory() {
return inventory;
}
@Override
public ItemStack getItem(int slot) {
if (slot < getIngredientsInventory().getSize()) {
net.minecraft.server.ItemStack item = getIngredientsInventory().getItem(slot);
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
} else {
net.minecraft.server.ItemStack item = getResultInventory().getItem(slot - getIngredientsInventory().getSize());
return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
}
}
@Override
public void setItem(int index, ItemStack item) {
if (index < getIngredientsInventory().getSize()) {
getIngredientsInventory().setItem(index, CraftItemStack.asNMSCopy(item));
} else {
getResultInventory().setItem((index - getIngredientsInventory().getSize()), CraftItemStack.asNMSCopy(item));
}
}
@Override
public int getSize() {
return getResultInventory().getSize() + getIngredientsInventory().getSize();
}
@Override
public Location getLocation() {
return location;
}
@Override
public String getRenameText() {
return container.renameText;
}
@Override
public int getRepairCost() {
return container.levelCost;
}
@Override
public void setRepairCost(int i) {
container.levelCost = i;
}
}
|