for(int i = 0; i < 2; ++i) {
for(int j = 0; j < 2; ++j) {
this.addSlot(new Slot(this.craftSlots, j + i * 2, 98 + j * 18, 18 + i * 18));
}
}
for(int k = 0; k < 4; ++k) {
final EquipmentSlot equipmentslot = SLOT_IDS[k];
this.addSlot(new Slot(pPlayerInventory, 39 - k, 8, 8 + k * 18) {
public void setByPlayer(ItemStack p_270969_) {
InventoryMenu.onEquipItem(pOwner, equipmentslot, p_270969_, this.getItem());
super.setByPlayer(p_270969_);
}
/**
* Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1 in
* the case of armor slots)
*/
public int getMaxStackSize() {
return 1;
}
/**
* Check if the stack is allowed to be placed in this slot, used for armor slots as well as furnace fuel.
*/
public boolean mayPlace(ItemStack p_39746_) {
return p_39746_.canEquip(equipmentslot, owner);
}
/**
* Return whether this slot's stack can be taken from this slot.
*/
public boolean mayPickup(Player p_39744_) {
ItemStack itemstack = this.getItem();
return !itemstack.isEmpty() && !p_39744_.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? false : super.mayPickup(p_39744_);
}
[spoiler=该类的字段]public static final int CONTAINER_ID = 0;
public static final int RESULT_SLOT = 0;
public static final int CRAFT_SLOT_START = 1;
public static final int CRAFT_SLOT_END = 5;
public static final int ARMOR_SLOT_START = 5;
public static final int ARMOR_SLOT_END = 9;
public static final int INV_SLOT_START = 9;
public static final int INV_SLOT_END = 36;
public static final int USE_ROW_SLOT_START = 36;
public static final int USE_ROW_SLOT_END = 45;
public static final int SHIELD_SLOT = 45;[/spoiler]