Skip to content

Commit

Permalink
compat fix with mods that change hotbar size
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed Nov 28, 2018
1 parent 7403f99 commit c731efa
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package org.spongepowered.common.item.inventory.lens.impl.comp;

import net.minecraft.entity.player.InventoryPlayer;
import org.spongepowered.api.item.inventory.Inventory;
import org.spongepowered.common.item.inventory.adapter.InventoryAdapter;
import org.spongepowered.common.item.inventory.adapter.impl.comp.PrimaryPlayerInventoryAdapter;
Expand Down Expand Up @@ -58,10 +59,12 @@ public PrimaryPlayerInventoryLens(int base, Class<? extends Inventory> adapterTy
private void init(SlotProvider slots) {
int base = this.base;

int hotbarSize = InventoryPlayer.getHotbarSize();

if (this.isContainer) {
this.mainGrid = new GridInventoryLensImpl(base, INVENTORY_WIDTH, MAIN_INVENTORY_HEIGHT, slots);
base += INVENTORY_WIDTH * 3;
this.hotbar = new HotbarLensImpl(base, INVENTORY_WIDTH, slots);
this.hotbar = new HotbarLensImpl(base - (hotbarSize - INVENTORY_WIDTH), hotbarSize, slots);
/*
1 |G|G|G|G|G|G|G|G|G|
2 |G|G|G|G|G|G|G|G|G|
Expand All @@ -76,7 +79,7 @@ private void init(SlotProvider slots) {
this.addChild(fullGrid);

} else {
this.hotbar = new HotbarLensImpl(base, INVENTORY_WIDTH, slots);
this.hotbar = new HotbarLensImpl(base, hotbarSize, slots);
base += INVENTORY_WIDTH;
this.mainGrid = new GridInventoryLensImpl(base, INVENTORY_WIDTH, MAIN_INVENTORY_HEIGHT, slots);

Expand Down

0 comments on commit c731efa

Please sign in to comment.