mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 17:22:55 +01:00
Add InventoryView#getSlotType
By: md_5 <git@md-5.net>
This commit is contained in:
parent
6631f07cae
commit
d085b4781b
2 changed files with 1 additions and 68 deletions
|
@ -1230,7 +1230,7 @@
|
|||
+ }
|
||||
+
|
||||
+ InventoryView inventory = this.player.activeContainer.getBukkitView();
|
||||
+ SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.c());
|
||||
+ SlotType type = inventory.getSlotType(packetplayinwindowclick.c());
|
||||
|
||||
+ InventoryClickEvent event;
|
||||
+ ClickType click = ClickType.UNKNOWN;
|
||||
|
|
|
@ -72,71 +72,4 @@ public class CraftInventoryView extends InventoryView {
|
|||
public Container getHandle() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public static SlotType getSlotType(InventoryView inventory, int slot) {
|
||||
SlotType type = SlotType.CONTAINER;
|
||||
if (slot >= 0 && slot < inventory.getTopInventory().getSize()) {
|
||||
switch(inventory.getType()) {
|
||||
case FURNACE:
|
||||
if (slot == 2) {
|
||||
type = SlotType.RESULT;
|
||||
} else if(slot == 1) {
|
||||
type = SlotType.FUEL;
|
||||
} else {
|
||||
type = SlotType.CRAFTING;
|
||||
}
|
||||
break;
|
||||
case BREWING:
|
||||
if (slot == 3) {
|
||||
type = SlotType.FUEL;
|
||||
} else {
|
||||
type = SlotType.CRAFTING;
|
||||
}
|
||||
break;
|
||||
case ENCHANTING:
|
||||
type = SlotType.CRAFTING;
|
||||
break;
|
||||
case WORKBENCH:
|
||||
case CRAFTING:
|
||||
if (slot == 0) {
|
||||
type = SlotType.RESULT;
|
||||
} else {
|
||||
type = SlotType.CRAFTING;
|
||||
}
|
||||
break;
|
||||
case MERCHANT:
|
||||
if (slot == 2) {
|
||||
type = SlotType.RESULT;
|
||||
} else {
|
||||
type = SlotType.CRAFTING;
|
||||
}
|
||||
break;
|
||||
case BEACON:
|
||||
type = SlotType.CRAFTING;
|
||||
break;
|
||||
case ANVIL:
|
||||
if (slot == 2) {
|
||||
type = SlotType.RESULT;
|
||||
} else {
|
||||
type = SlotType.CRAFTING;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Nothing to do, it's a CONTAINER slot
|
||||
}
|
||||
} else {
|
||||
if (slot < 0) {
|
||||
type = SlotType.OUTSIDE;
|
||||
} else if (inventory.getType() == InventoryType.CRAFTING) { // Also includes creative inventory
|
||||
if (slot < 9) {
|
||||
type = SlotType.ARMOR;
|
||||
} else if (slot > 35) {
|
||||
type = SlotType.QUICKBAR;
|
||||
}
|
||||
} else if (slot >= (inventory.countSlots() - (9 + 4 + 1))) { // Quickbar, Armor, Offhand
|
||||
type = SlotType.QUICKBAR;
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue