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

71 lines
2.3 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.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleFollower;
2025-03-13 17:14:45 -04:00
public class ContainerNPCFollowerSetup extends Container {
private RoleFollower role;
2018-09-13 12:03:28 -04:00
2025-03-13 17:14:45 -04:00
public ContainerNPCFollowerSetup(EntityNPCInterface npc, EntityPlayer player) {
2018-09-13 12:03:28 -04:00
role = (RoleFollower) npc.roleInterface;
2025-03-13 17:14:45 -04:00
for (int i1 = 0; i1 < 3; i1++)
addSlotToContainer(new Slot(role.inventory, i1, 44, 39 + i1 * 25));
for (int i1 = 0; i1 < 3; i1++) {
for (int l1 = 0; l1 < 9; l1++) {
addSlotToContainer(new Slot(player.inventory, l1 + i1 * 9 + 9, 8 + l1 * 18, 113 + i1 * 18));
2018-09-13 12:03:28 -04:00
}
}
2025-03-13 17:14:45 -04:00
for (int j1 = 0; j1 < 9; j1++) {
addSlotToContainer(new Slot(player.inventory, j1, 8 + j1 * 18, 171));
2018-09-13 12:03:28 -04:00
}
}
@Override
2025-03-13 17:14:45 -04:00
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int i) {
2018-09-13 12:03:28 -04:00
ItemStack itemstack = null;
2025-03-13 17:14:45 -04:00
Slot slot = (Slot) inventorySlots.get(i);
if (slot != null && slot.getHasStack()) {
2018-09-13 12:03:28 -04:00
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
2025-03-13 17:14:45 -04:00
if (i >= 0 && i < 3) {
if (!mergeItemStack(itemstack1, 3, 38, true)) {
2018-09-13 12:03:28 -04:00
return null;
}
2025-03-13 17:14:45 -04:00
} else if (i >= 3 && i < 30) {
if (!mergeItemStack(itemstack1, 30, 38, false)) {
2018-09-13 12:03:28 -04:00
return null;
}
2025-03-13 17:14:45 -04:00
} else if (i >= 30 && i < 38) {
if (!mergeItemStack(itemstack1, 3, 29, false)) {
2018-09-13 12:03:28 -04:00
return null;
}
2025-03-13 17:14:45 -04:00
} else if (!mergeItemStack(itemstack1, 3, 38, false)) {
2018-09-13 12:03:28 -04:00
return null;
}
2025-03-13 17:14:45 -04:00
if (itemstack1.stackSize == 0) {
2018-09-13 12:03:28 -04:00
slot.putStack(null);
2025-03-13 17:14:45 -04:00
} else {
2018-09-13 12:03:28 -04:00
slot.onSlotChanged();
}
2025-03-13 17:14:45 -04:00
if (itemstack1.stackSize != itemstack.stackSize) {
2018-09-13 12:03:28 -04:00
slot.onPickupFromSlot(par1EntityPlayer, itemstack1);
2025-03-13 17:14:45 -04:00
} else {
2018-09-13 12:03:28 -04:00
return null;
}
}
return itemstack;
}
2025-03-13 17:14:45 -04:00
@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
return true;
}
2018-09-13 12:03:28 -04:00
}