use of org.spongepowered.common.item.inventory.lens.impl.slots.EquipmentSlotLensImpl in project SpongeCommon by SpongePowered.
the class MixinInventoryPlayer method onConstructed.
@Inject(method = "<init>*", at = @At("RETURN"), remap = false)
private void onConstructed(EntityPlayer playerIn, CallbackInfo ci) {
// Find offhand slot
for (NonNullList<ItemStack> inventory : this.allInventories) {
if (inventory == this.offHandInventory) {
break;
}
this.offhandIndex += inventory.size();
}
// Set Carrier if we got a real Player
if (playerIn instanceof EntityPlayerMP) {
this.carrier = (Player) playerIn;
this.inventory = new IInventoryFabric((IInventory) this);
Class clazz = this.getClass();
if (clazz == InventoryPlayer.class) {
// Build Player Lens
// We only care about Server inventories
this.slots = new SlotCollection.Builder().add(this.mainInventory.size()).add(this.offHandInventory.size()).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.BOOTS)).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.LEGGINGS)).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.CHESTPLATE)).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.HEADWEAR)).add(this.armorInventory.size() - 4, EquipmentSlotAdapter.class).add(this.getSizeInventory() - this.mainInventory.size() - this.offHandInventory.size() - this.armorInventory.size()).build();
this.lens = new PlayerInventoryLens(this, this.slots);
} else if (this.getSizeInventory() != 0) {
// Fallback OrderedLens when not 0 sized inventory
this.slots = new SlotCollection.Builder().add(this.getSizeInventory()).build();
this.lens = new OrderedInventoryLensImpl(0, this.getSizeInventory(), 1, slots);
}
}
}
use of org.spongepowered.common.item.inventory.lens.impl.slots.EquipmentSlotLensImpl in project SpongeCommon by SpongePowered.
the class MixinContainerPlayer method slotProvider.
@Override
public SlotProvider<IInventory, ItemStack> slotProvider(Fabric<IInventory> fabric, InventoryAdapter<IInventory, ItemStack> adapter) {
SlotCollection.Builder builder = new SlotCollection.Builder().add(1, CraftingOutputAdapter.class, (i) -> new CraftingOutputSlotLensImpl(i, (t) -> false, (t) -> false)).add(4).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.HEADWEAR)).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.CHESTPLATE)).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.LEGGINGS)).add(EquipmentSlotAdapter.class, index -> new EquipmentSlotLensImpl(index, i -> true, t -> true, e -> e == EquipmentTypes.BOOTS)).add(36).add(1);
// Add additional slots (e.g. from mods)
builder.add(this.inventorySlots.size() - 46);
return builder.build();
}
Aggregations