SPIGOT-1980: Register new brewing slot

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2016-03-20 10:22:24 +11:00
parent 75c3223fb3
commit 95133063a1

View file

@ -14,6 +14,7 @@ import net.minecraft.server.PacketPlayOutOpenWindow;
import net.minecraft.server.Slot; import net.minecraft.server.Slot;
public class CraftContainer extends Container { public class CraftContainer extends Container {
private final InventoryView view; private final InventoryView view;
private InventoryType cachedType; private InventoryType cachedType;
private String cachedTitle; private String cachedTitle;
@ -23,8 +24,8 @@ public class CraftContainer extends Container {
this.view = view; this.view = view;
this.windowId = id; this.windowId = id;
// TODO: Do we need to check that it really is a CraftInventory? // TODO: Do we need to check that it really is a CraftInventory?
IInventory top = ((CraftInventory)view.getTopInventory()).getInventory(); IInventory top = ((CraftInventory) view.getTopInventory()).getInventory();
IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory(); IInventory bottom = ((CraftInventory) view.getBottomInventory()).getInventory();
cachedType = view.getType(); cachedType = view.getType();
cachedTitle = view.getTitle(); cachedTitle = view.getTitle();
cachedSize = getSize(); cachedSize = getSize();
@ -78,8 +79,8 @@ public class CraftContainer extends Container {
if (view.getPlayer() instanceof CraftPlayer) { if (view.getPlayer() instanceof CraftPlayer) {
CraftPlayer player = (CraftPlayer) view.getPlayer(); CraftPlayer player = (CraftPlayer) view.getPlayer();
String type = getNotchInventoryType(cachedType); String type = getNotchInventoryType(cachedType);
IInventory top = ((CraftInventory)view.getTopInventory()).getInventory(); IInventory top = ((CraftInventory) view.getTopInventory()).getInventory();
IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory(); IInventory bottom = ((CraftInventory) view.getBottomInventory()).getInventory();
this.b.clear(); this.b.clear();
this.c.clear(); this.c.clear();
if (typeChanged) { if (typeChanged) {
@ -93,55 +94,55 @@ public class CraftContainer extends Container {
} }
public static String getNotchInventoryType(InventoryType type) { public static String getNotchInventoryType(InventoryType type) {
switch(type) { switch (type) {
case WORKBENCH: case WORKBENCH:
return "minecraft:crafting_table"; return "minecraft:crafting_table";
case FURNACE: case FURNACE:
return "minecraft:furnace"; return "minecraft:furnace";
case DISPENSER: case DISPENSER:
return "minecraft:dispenser"; return "minecraft:dispenser";
case ENCHANTING: case ENCHANTING:
return "minecraft:enchanting_table"; return "minecraft:enchanting_table";
case BREWING: case BREWING:
return "minecraft:brewing_stand"; return "minecraft:brewing_stand";
case BEACON: case BEACON:
return "minecraft:beacon"; return "minecraft:beacon";
case ANVIL: case ANVIL:
return "minecraft:anvil"; return "minecraft:anvil";
case HOPPER: case HOPPER:
return "minecraft:hopper"; return "minecraft:hopper";
default: default:
return "minecraft:chest"; return "minecraft:chest";
} }
} }
private void setupSlots(IInventory top, IInventory bottom) { private void setupSlots(IInventory top, IInventory bottom) {
switch(cachedType) { switch (cachedType) {
case CREATIVE: case CREATIVE:
break; // TODO: This should be an error? break; // TODO: This should be an error?
case PLAYER: case PLAYER:
case CHEST: case CHEST:
setupChest(top, bottom); setupChest(top, bottom);
break; break;
case DISPENSER: case DISPENSER:
setupDispenser(top, bottom); setupDispenser(top, bottom);
break; break;
case FURNACE: case FURNACE:
setupFurnace(top, bottom); setupFurnace(top, bottom);
break; break;
case CRAFTING: // TODO: This should be an error? case CRAFTING: // TODO: This should be an error?
case WORKBENCH: case WORKBENCH:
setupWorkbench(top, bottom); setupWorkbench(top, bottom);
break; break;
case ENCHANTING: case ENCHANTING:
setupEnchanting(top, bottom); setupEnchanting(top, bottom);
break; break;
case BREWING: case BREWING:
setupBrewing(top, bottom); setupBrewing(top, bottom);
break; break;
case HOPPER: case HOPPER:
setupHopper(top, bottom); setupHopper(top, bottom);
break; break;
} }
} }
@ -262,9 +263,9 @@ public class CraftContainer extends Container {
this.a(new Slot(top, 1, 79, 53)); this.a(new Slot(top, 1, 79, 53));
this.a(new Slot(top, 2, 102, 46)); this.a(new Slot(top, 2, 102, 46));
this.a(new Slot(top, 3, 79, 17)); this.a(new Slot(top, 3, 79, 17));
this.a(new Slot(top, 4, 17, 17));
int i; int i;
for (i = 0; i < 3; ++i) { for (i = 0; i < 3; ++i) {
for (int j = 0; j < 9; ++j) { for (int j = 0; j < 9; ++j) {
this.a(new Slot(bottom, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); this.a(new Slot(bottom, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));