improve container gui
This commit is contained in:
parent
d44352c40e
commit
5421552dde
23 changed files with 133 additions and 190 deletions
|
@ -25,11 +25,11 @@ public abstract class Container
|
|||
private Set<EntityNPC> playerList = Sets.<EntityNPC>newHashSet();
|
||||
|
||||
public int getInventoryOffsetX() {
|
||||
return 8;
|
||||
return 16;
|
||||
}
|
||||
|
||||
public int getInventoryOffsetY() {
|
||||
return 84;
|
||||
return 168;
|
||||
}
|
||||
|
||||
public final int getPlayerInventoryOffset() {
|
||||
|
@ -41,7 +41,7 @@ public abstract class Container
|
|||
int y = this.getInventoryOffsetY();
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
final Equipment type = slot;
|
||||
this.addSlotToContainer(new Slot(player, Equipment.INVENTORY_SLOTS + slot.getIndex(), x + slot.getIndex() * 18, y) {
|
||||
this.addSlotToContainer(new Slot(player, Equipment.INVENTORY_SLOTS + slot.getIndex(), x + slot.getIndex() * 36, y) {
|
||||
public boolean canStackItems() {
|
||||
return false;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public abstract class Container
|
|||
this.offset = this.inventorySlots.size();
|
||||
List<SlotCommon> list = Lists.newArrayList();
|
||||
for(int z = 0; z < Equipment.INVENTORY_SLOTS; ++z) {
|
||||
this.addSlotToContainer(new SlotCommon(list, player, z, x + (z % INVENTORY_WIDTH) * 18, y + 20 + (z / INVENTORY_WIDTH) * 18));
|
||||
this.addSlotToContainer(new SlotCommon(list, player, z, x + (z % INVENTORY_WIDTH) * 36, y + 40 + (z / INVENTORY_WIDTH) * 36));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class ContainerChest extends Container
|
|||
{
|
||||
for (int k = 0; k < this.width; ++k)
|
||||
{
|
||||
this.addSlotToContainer(new SlotCommon(list, chest, k + j * this.width, 8 + k * 18, 18 + j * 18));
|
||||
this.addSlotToContainer(new SlotCommon(list, chest, k + j * this.width, 16 + k * 36, 36 + j * 36));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,11 +36,11 @@ public class ContainerChest extends Container
|
|||
}
|
||||
|
||||
public int getInventoryOffsetX() {
|
||||
return 8 + (this.width < INVENTORY_WIDTH ? 0 : (this.width - INVENTORY_WIDTH) * 18 / 2);
|
||||
return super.getInventoryOffsetX() + (this.width < INVENTORY_WIDTH ? 0 : (this.width - INVENTORY_WIDTH) * 36 / 2);
|
||||
}
|
||||
|
||||
public int getInventoryOffsetY() {
|
||||
return 85 + (this.height - 3) * 18;
|
||||
return 170 + (this.height - 3) * 36;
|
||||
}
|
||||
|
||||
protected boolean canMergeStacks() {
|
||||
|
|
|
@ -2,7 +2,6 @@ package common.inventory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
import common.enchantment.RngEnchantment;
|
||||
|
@ -13,7 +12,6 @@ import common.item.ItemStack;
|
|||
import common.item.material.ItemEnchantedBook;
|
||||
import common.network.IPlayer;
|
||||
import common.rng.Random;
|
||||
import common.util.Equipment;
|
||||
import common.util.LocalPos;
|
||||
import common.util.Pair;
|
||||
import common.world.World;
|
||||
|
@ -49,7 +47,7 @@ public class ContainerEnchantment extends Container
|
|||
this.world = worldIn;
|
||||
this.position = pos;
|
||||
this.seed = playerInv.getEnchSeed();
|
||||
this.addSlotToContainer(new Slot(this.table, 0, 25, 47)
|
||||
this.addSlotToContainer(new Slot(this.table, 0, 50, 94)
|
||||
{
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,6 @@ import common.entity.animal.EntityHorse;
|
|||
import common.entity.npc.EntityNPC;
|
||||
import common.init.Items;
|
||||
import common.item.ItemStack;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class ContainerEntityInventory extends Container
|
||||
{
|
||||
|
@ -21,14 +20,14 @@ public class ContainerEntityInventory extends Container
|
|||
this.entity = entity;
|
||||
if(this.entity instanceof EntityHorse) {
|
||||
final EntityHorse horse = (EntityHorse)this.entity;
|
||||
this.addSlotToContainer(new Slot(entityInv, 0, 8, 18)
|
||||
this.addSlotToContainer(new Slot(entityInv, 0, 16, 36)
|
||||
{
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return super.isItemValid(stack) && stack.getItem() == Items.saddle && !this.getHasStack();
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(entityInv, 1, 8, 36)
|
||||
this.addSlotToContainer(new Slot(entityInv, 1, 16, 72)
|
||||
{
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
|
@ -46,7 +45,7 @@ public class ContainerEntityInventory extends Container
|
|||
{
|
||||
for (int l = 0; l < 5; ++l)
|
||||
{
|
||||
this.addSlotToContainer(new SlotCommon(list, entityInv, 2 + l + k * 5, 80 + l * 18, 18 + k * 18));
|
||||
this.addSlotToContainer(new SlotCommon(list, entityInv, 2 + l + k * 5, 160 + l * 36, 36 + k * 36));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package common.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.ItemStack;
|
||||
import common.network.IPlayer;
|
||||
import common.util.Equipment;
|
||||
import common.village.MerchantRecipe;
|
||||
import common.world.World;
|
||||
|
||||
|
@ -138,17 +134,17 @@ public class ContainerMerchant extends Container
|
|||
this.theMerchant = merchant;
|
||||
this.theWorld = worldIn;
|
||||
this.merchantInventory = new InventoryMerchant(playerInventory, merchant);
|
||||
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53) {
|
||||
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 72, 106) {
|
||||
public boolean canEditItem() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53) {
|
||||
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 124, 106) {
|
||||
public boolean canEditItem() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new SlotMerchantResult(playerInventory, this.merchantInventory, 2, 120, 53));
|
||||
this.addSlotToContainer(new SlotMerchantResult(playerInventory, this.merchantInventory, 2, 240, 106));
|
||||
|
||||
this.addPlayerSlots(playerInventory);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ public class ContainerPlayer extends Container {
|
|||
}
|
||||
|
||||
public int getInventoryOffsetY() {
|
||||
return 16;
|
||||
return 32;
|
||||
}
|
||||
|
||||
public ItemStack getSingleRecipe(ItemStack stack) {
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
package common.inventory;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import common.block.tech.BlockAnvil;
|
||||
import common.collect.Lists;
|
||||
import common.enchantment.Enchantment;
|
||||
import common.enchantment.EnchantmentHelper;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemEnchantedBook;
|
||||
import common.network.IPlayer;
|
||||
import common.util.Equipment;
|
||||
import common.util.LocalPos;
|
||||
import common.vars.Vars;
|
||||
import common.world.State;
|
||||
|
@ -117,17 +114,17 @@ public class ContainerRepair extends Container
|
|||
};
|
||||
this.selfPosition = blockPosIn;
|
||||
this.theWorld = worldIn;
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 0, 27, 47) {
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 0, 54, 94) {
|
||||
public boolean canEditItem() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 1, 76, 47) {
|
||||
this.addSlotToContainer(new Slot(this.inputSlots, 1, 152, 94) {
|
||||
public boolean canEditItem() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47)
|
||||
this.addSlotToContainer(new Slot(this.outputSlot, 2, 268, 94)
|
||||
{
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package common.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.ItemStack;
|
||||
import common.network.IPlayer;
|
||||
import common.tileentity.Device;
|
||||
import common.tileentity.Device.Status;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class ContainerTile extends Container
|
||||
{
|
||||
|
@ -39,7 +35,7 @@ public class ContainerTile extends Container
|
|||
for (int idx = 0; idx < tileInv.getSizeInventory(); ++idx)
|
||||
{
|
||||
final int index = idx;
|
||||
this.addSlotToContainer(new Slot(tileInv, idx, 8 + (this.tile.isInput(index) ? input : 8 - output) * 18, 81) {
|
||||
this.addSlotToContainer(new Slot(tileInv, idx, 16 + (this.tile.isInput(index) ? input : 8 - output) * 36, 162) {
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return ContainerTile.this.tile.isItemValidForSlot(index, stack);
|
||||
|
@ -59,7 +55,7 @@ public class ContainerTile extends Container
|
|||
}
|
||||
|
||||
public int getInventoryOffsetY() {
|
||||
return 112;
|
||||
return 224;
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityNPC playerIn)
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package common.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.block.tech.BlockWorkbench;
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.ItemStack;
|
||||
import common.util.Equipment;
|
||||
import common.util.LocalPos;
|
||||
import common.world.World;
|
||||
|
||||
|
|
|
@ -28,11 +28,11 @@ public class SlotCommon extends Slot {
|
|||
for(SlotCommon slot : this.list) {
|
||||
x1 = Math.min(x1, slot.xDisplayPosition);
|
||||
y1 = Math.min(y1, slot.yDisplayPosition);
|
||||
x2 = Math.max(x2, slot.xDisplayPosition + 18);
|
||||
y2 = Math.max(y2, slot.yDisplayPosition + 18);
|
||||
x2 = Math.max(x2, slot.xDisplayPosition + 36);
|
||||
y2 = Math.max(y2, slot.yDisplayPosition + 36);
|
||||
}
|
||||
this.w = (x2 - x1) / 18;
|
||||
this.h = (y2 - y1) / 18;
|
||||
this.w = (x2 - x1) / 36;
|
||||
this.h = (y2 - y1) / 36;
|
||||
}
|
||||
|
||||
public int getBackgroundWidth() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue