Files
CustomNPC-Plus/src/main/java/noppes/npcs/containers/ContainerNPCBankInterface.java
T

103 lines
3.0 KiB
Java
Raw Normal View History

2018-09-13 12:03:28 -04:00
package noppes.npcs.containers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import noppes.npcs.NpcMiscInventory;
import noppes.npcs.controllers.PlayerDataController;
2023-01-12 21:33:06 -05:00
import noppes.npcs.controllers.data.PlayerBankData;
2018-09-13 12:03:28 -04:00
2025-03-12 20:12:01 -04:00
public class ContainerNPCBankInterface extends ContainerNpcInterface {
2018-09-13 12:03:28 -04:00
public InventoryNPC currencyMatrix;
2025-03-12 20:12:01 -04:00
private final EntityPlayer player;
2018-09-13 12:03:28 -04:00
public SlotNpcBankCurrency currency;
public int slot = 0;
public int bankid;
private PlayerBankData data;
2025-03-12 20:12:01 -04:00
public ContainerNPCBankInterface(EntityPlayer player, int slot, int bankid) {
super(player);
this.bankid = bankid;
this.slot = slot;
this.player = player;
2018-09-13 12:03:28 -04:00
currencyMatrix = new InventoryNPC("currency", 1, this);
2025-03-12 20:12:01 -04:00
if (!isAvailable() || canBeUpgraded()) {
currency = new SlotNpcBankCurrency(this, currencyMatrix, 0, 80, 29);
addSlotToContainer(currency);
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
2018-09-13 12:03:28 -04:00
NpcMiscInventory items = new NpcMiscInventory(54);
2025-03-12 20:12:01 -04:00
if (!player.worldObj.isRemote) {
data = PlayerDataController.Instance.getBankData(player, bankid);
items = data.getBankOrDefault(bankid).itemSlots.get(slot);
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
2018-09-13 12:03:28 -04:00
int xOffset = xOffset();
2025-03-12 20:12:01 -04:00
for (int j = 0; j < getRowNumber(); j++) {
for (int i1 = 0; i1 < 9; i1++) {
int id = i1 + j * 9;
addSlotToContainer(new Slot(items, id, 8 + i1 * 18, 17 + xOffset + j * 18));
2018-09-13 12:03:28 -04:00
}
}
2025-03-12 20:12:01 -04:00
if (isUpgraded())
xOffset += 54;
for (int k = 0; k < 3; k++) {
for (int j1 = 0; j1 < 9; j1++) {
addSlotToContainer(new Slot(player.inventory, j1 + k * 9 + 9, 8 + j1 * 18, 86 + xOffset + k * 18));
2018-09-13 12:03:28 -04:00
}
}
2025-03-12 20:12:01 -04:00
for (int l = 0; l < 9; l++) {
addSlotToContainer(new Slot(player.inventory, l, 8 + l * 18, 144 + xOffset));
2018-09-13 12:03:28 -04:00
}
}
2025-03-12 20:12:01 -04:00
2018-09-13 12:03:28 -04:00
public int getRowNumber() {
2025-03-12 20:12:01 -04:00
return 0;
}
public int xOffset() {
return 0;
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
2018-09-13 12:03:28 -04:00
@Override
2025-03-12 20:12:01 -04:00
public void onCraftMatrixChanged(IInventory inv) {
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public boolean isAvailable() {
return false;
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public boolean isUpgraded() {
return false;
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public boolean canBeUpgraded() {
return false;
2018-09-13 12:03:28 -04:00
}
2025-03-12 20:12:01 -04:00
public synchronized void setCurrency(ItemStack item) {
currency.item = item;
}
2018-09-13 12:03:28 -04:00
@Override
2025-03-12 20:12:01 -04:00
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) {
return null;
}
2018-09-13 12:03:28 -04:00
@Override
2025-03-12 20:12:01 -04:00
public void onContainerClosed(EntityPlayer entityplayer) {
2018-09-13 12:03:28 -04:00
super.onContainerClosed(entityplayer);
2025-03-12 20:12:01 -04:00
if (!entityplayer.worldObj.isRemote) {
2018-09-13 12:03:28 -04:00
ItemStack var3 = this.currencyMatrix.getStackInSlot(0);
currencyMatrix.setInventorySlotContents(0, null);
2025-03-12 20:12:01 -04:00
if (var3 != null) {
entityplayer.dropPlayerItemWithRandomChoice(var3, false);
2018-09-13 12:03:28 -04:00
}
}
}
}