Format
This commit is contained in:
parent
6e0ec1d861
commit
4ac26ac086
137 changed files with 10339 additions and 7322 deletions
|
@ -1,48 +1,53 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
import techreborn.tiles.TileCentrifuge;
|
||||
|
||||
public class ContainerBlastFurnace extends TechRebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
EntityPlayer player;
|
||||
|
||||
TileBlastFurnace tile;
|
||||
|
||||
TileBlastFurnace tile;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int tickTime;
|
||||
public int tickTime;
|
||||
|
||||
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace, EntityPlayer player) {
|
||||
tile = tileblastfurnace;
|
||||
this.player = player;
|
||||
public ContainerBlastFurnace(TileBlastFurnace tileblastfurnace,
|
||||
EntityPlayer player)
|
||||
{
|
||||
tile = tileblastfurnace;
|
||||
this.player = player;
|
||||
|
||||
//input
|
||||
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25));
|
||||
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43));
|
||||
//outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2, 116, 35));
|
||||
// input
|
||||
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 0, 56, 25));
|
||||
this.addSlotToContainer(new Slot(tileblastfurnace.inventory, 1, 56, 43));
|
||||
// outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileblastfurnace.inventory, 2,
|
||||
116, 35));
|
||||
|
||||
int i;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,61 +8,77 @@ import techreborn.tiles.TileCentrifuge;
|
|||
|
||||
public class ContainerCentrifuge extends TechRebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
EntityPlayer player;
|
||||
|
||||
TileCentrifuge tile;
|
||||
TileCentrifuge tile;
|
||||
|
||||
public int tickTime;
|
||||
public int tickTime;
|
||||
|
||||
public ContainerCentrifuge(TileCentrifuge tileCentrifuge, EntityPlayer player) {
|
||||
tile = tileCentrifuge;
|
||||
this.player = player;
|
||||
public ContainerCentrifuge(TileCentrifuge tileCentrifuge,
|
||||
EntityPlayer player)
|
||||
{
|
||||
tile = tileCentrifuge;
|
||||
this.player = player;
|
||||
|
||||
//input
|
||||
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35));
|
||||
//cells
|
||||
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5));
|
||||
//outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80, 5));
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3, 110, 35));
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80, 65));
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50, 35));
|
||||
// input
|
||||
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 0, 80, 35));
|
||||
// cells
|
||||
this.addSlotToContainer(new Slot(tileCentrifuge.inventory, 1, 50, 5));
|
||||
// outputs
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 2, 80,
|
||||
5));
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 3,
|
||||
110, 35));
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 4, 80,
|
||||
65));
|
||||
this.addSlotToContainer(new SlotOutput(tileCentrifuge.inventory, 5, 50,
|
||||
35));
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, tile.tickTime);
|
||||
}
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting)
|
||||
{
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, tile.tickTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); ++i) {
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.tickTime != this.tile.tickTime) {
|
||||
icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime);
|
||||
}
|
||||
}
|
||||
this.tickTime = this.tile.tickTime;
|
||||
}
|
||||
/**
|
||||
* Looks for changes made in the container, sends them to every listener.
|
||||
*/
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); ++i)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.tickTime != this.tile.tickTime)
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 0, this.tile.tickTime);
|
||||
}
|
||||
}
|
||||
this.tickTime = this.tile.tickTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,34 +7,44 @@ import techreborn.client.SlotOutput;
|
|||
import techreborn.tiles.TileQuantumChest;
|
||||
|
||||
public class ContainerQuantumChest extends TechRebornContainer {
|
||||
public TileQuantumChest tileQuantumChest;
|
||||
public EntityPlayer player;
|
||||
public TileQuantumChest tileQuantumChest;
|
||||
public EntityPlayer player;
|
||||
|
||||
public ContainerQuantumChest(TileQuantumChest tileQuantumChest, EntityPlayer player) {
|
||||
super();
|
||||
this.tileQuantumChest = tileQuantumChest;
|
||||
this.player = player;
|
||||
public ContainerQuantumChest(TileQuantumChest tileQuantumChest,
|
||||
EntityPlayer player)
|
||||
{
|
||||
super();
|
||||
this.tileQuantumChest = tileQuantumChest;
|
||||
this.player = player;
|
||||
|
||||
this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1, 80, 53));
|
||||
this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59, 42, false, false, Integer.MAX_VALUE));
|
||||
this.addSlotToContainer(new Slot(tileQuantumChest.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotOutput(tileQuantumChest.inventory, 1,
|
||||
80, 53));
|
||||
this.addSlotToContainer(new SlotFake(tileQuantumChest.inventory, 2, 59,
|
||||
42, false, false, Integer.MAX_VALUE));
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,33 +7,43 @@ import techreborn.client.SlotOutput;
|
|||
import techreborn.tiles.TileQuantumTank;
|
||||
|
||||
public class ContainerQuantumTank extends TechRebornContainer {
|
||||
public TileQuantumTank tileQuantumTank;
|
||||
public EntityPlayer player;
|
||||
public TileQuantumTank tileQuantumTank;
|
||||
public EntityPlayer player;
|
||||
|
||||
public ContainerQuantumTank(TileQuantumTank tileQuantumTank, EntityPlayer player) {
|
||||
super();
|
||||
this.tileQuantumTank = tileQuantumTank;
|
||||
this.player = player;
|
||||
public ContainerQuantumTank(TileQuantumTank tileQuantumTank,
|
||||
EntityPlayer player)
|
||||
{
|
||||
super();
|
||||
this.tileQuantumTank = tileQuantumTank;
|
||||
this.player = player;
|
||||
|
||||
this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1, 80, 53));
|
||||
this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59, 42, false, false, 1));
|
||||
this.addSlotToContainer(new Slot(tileQuantumTank.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotOutput(tileQuantumTank.inventory, 1,
|
||||
80, 53));
|
||||
this.addSlotToContainer(new SlotFake(tileQuantumTank.inventory, 2, 59,
|
||||
42, false, false, 1));
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,50 +11,63 @@ import techreborn.tiles.TileRollingMachine;
|
|||
|
||||
public class ContainerRollingMachine extends TechRebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
TileRollingMachine tile;
|
||||
EntityPlayer player;
|
||||
TileRollingMachine tile;
|
||||
|
||||
public ContainerRollingMachine(TileRollingMachine tileRollingmachine, EntityPlayer player) {
|
||||
tile = tileRollingmachine;
|
||||
this.player = player;
|
||||
public ContainerRollingMachine(TileRollingMachine tileRollingmachine,
|
||||
EntityPlayer player)
|
||||
{
|
||||
tile = tileRollingmachine;
|
||||
this.player = player;
|
||||
|
||||
for (int l = 0; l < 3; l++)
|
||||
{
|
||||
for (int k1 = 0; k1 < 3; k1++)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(
|
||||
tileRollingmachine.craftMatrix, k1 + l * 3,
|
||||
30 + k1 * 18, 17 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 3; k1++) {
|
||||
this.addSlotToContainer(new Slot(tileRollingmachine.craftMatrix, k1 + l * 3, 30 + k1 * 18, 17 + l * 18));
|
||||
}
|
||||
}
|
||||
// output
|
||||
this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0,
|
||||
124, 35));
|
||||
|
||||
//output
|
||||
this.addSlotToContainer(new SlotOutput(tileRollingmachine.inventory, 0, 124, 35));
|
||||
// fakeOutput
|
||||
this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1,
|
||||
124, 10, false, false, 1));
|
||||
|
||||
//fakeOutput
|
||||
this.addSlotToContainer(new SlotFake(tileRollingmachine.inventory, 1, 124, 10, false, false, 1));
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCraftMatrixChanged(IInventory inv) {
|
||||
ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe(tile.craftMatrix, tile.getWorldObj());
|
||||
tile.inventory.setInventorySlotContents(1, output);
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onCraftMatrixChanged(IInventory inv)
|
||||
{
|
||||
ItemStack output = RollingMachineRecipe.instance.findMatchingRecipe(
|
||||
tile.craftMatrix, tile.getWorldObj());
|
||||
tile.inventory.setInventorySlotContents(1, output);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,33 +7,44 @@ import techreborn.client.SlotOutput;
|
|||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
public class ContainerThermalGenerator extends TechRebornContainer {
|
||||
public TileThermalGenerator tileThermalGenerator;
|
||||
public EntityPlayer player;
|
||||
public TileThermalGenerator tileThermalGenerator;
|
||||
public EntityPlayer player;
|
||||
|
||||
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator, EntityPlayer player) {
|
||||
super();
|
||||
this.tileThermalGenerator = tileThermalGenerator;
|
||||
this.player = player;
|
||||
public ContainerThermalGenerator(TileThermalGenerator tileThermalGenerator,
|
||||
EntityPlayer player)
|
||||
{
|
||||
super();
|
||||
this.tileThermalGenerator = tileThermalGenerator;
|
||||
this.player = player;
|
||||
|
||||
this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory, 1, 80, 53));
|
||||
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2, 59, 42, false, false, 1));
|
||||
this.addSlotToContainer(new Slot(tileThermalGenerator.inventory, 0, 80,
|
||||
17));
|
||||
this.addSlotToContainer(new SlotOutput(tileThermalGenerator.inventory,
|
||||
1, 80, 53));
|
||||
this.addSlotToContainer(new SlotFake(tileThermalGenerator.inventory, 2,
|
||||
59, 42, false, false, 1));
|
||||
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18,
|
||||
142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,88 +7,112 @@ import net.minecraft.item.ItemStack;
|
|||
import techreborn.client.SlotFake;
|
||||
import techreborn.util.ItemUtils;
|
||||
|
||||
|
||||
public abstract class TechRebornContainer extends Container {
|
||||
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
|
||||
ItemStack originalStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
int numSlots = inventorySlots.size();
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
originalStack = stackInSlot.copy();
|
||||
if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots)) {
|
||||
// NOOP
|
||||
} else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9) {
|
||||
if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots))
|
||||
return null;
|
||||
} else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) {
|
||||
if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9))
|
||||
return null;
|
||||
} else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots))
|
||||
return null;
|
||||
slot.onSlotChange(stackInSlot, originalStack);
|
||||
if (stackInSlot.stackSize <= 0)
|
||||
slot.putStack(null);
|
||||
else
|
||||
slot.onSlotChanged();
|
||||
if (stackInSlot.stackSize == originalStack.stackSize)
|
||||
return null;
|
||||
slot.onPickupFromSlot(player, stackInSlot);
|
||||
}
|
||||
return originalStack;
|
||||
}
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
|
||||
{
|
||||
ItemStack originalStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
int numSlots = inventorySlots.size();
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
originalStack = stackInSlot.copy();
|
||||
if (slotIndex >= numSlots - 9 * 4
|
||||
&& tryShiftItem(stackInSlot, numSlots))
|
||||
{
|
||||
// NOOP
|
||||
} else if (slotIndex >= numSlots - 9 * 4
|
||||
&& slotIndex < numSlots - 9)
|
||||
{
|
||||
if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots))
|
||||
return null;
|
||||
} else if (slotIndex >= numSlots - 9 && slotIndex < numSlots)
|
||||
{
|
||||
if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9))
|
||||
return null;
|
||||
} else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots))
|
||||
return null;
|
||||
slot.onSlotChange(stackInSlot, originalStack);
|
||||
if (stackInSlot.stackSize <= 0)
|
||||
slot.putStack(null);
|
||||
else
|
||||
slot.onSlotChanged();
|
||||
if (stackInSlot.stackSize == originalStack.stackSize)
|
||||
return null;
|
||||
slot.onPickupFromSlot(player, stackInSlot);
|
||||
}
|
||||
return originalStack;
|
||||
}
|
||||
|
||||
protected boolean shiftItemStack(ItemStack stackToShift, int start, int end) {
|
||||
boolean changed = false;
|
||||
if (stackToShift.isStackable())
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot != null && ItemUtils.isItemEqual(stackInSlot, stackToShift, true, true)) {
|
||||
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
if (resultingStackSize <= max) {
|
||||
stackToShift.stackSize = 0;
|
||||
stackInSlot.stackSize = resultingStackSize;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
} else if (stackInSlot.stackSize < max) {
|
||||
stackToShift.stackSize -= max - stackInSlot.stackSize;
|
||||
stackInSlot.stackSize = max;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stackToShift.stackSize > 0)
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot == null) {
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
stackInSlot = stackToShift.copy();
|
||||
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
|
||||
stackToShift.stackSize -= stackInSlot.stackSize;
|
||||
slot.putStack(stackInSlot);
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
protected boolean shiftItemStack(ItemStack stackToShift, int start, int end)
|
||||
{
|
||||
boolean changed = false;
|
||||
if (stackToShift.isStackable())
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0
|
||||
&& slotIndex < end; slotIndex++)
|
||||
{
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot != null
|
||||
&& ItemUtils.isItemEqual(stackInSlot, stackToShift,
|
||||
true, true))
|
||||
{
|
||||
int resultingStackSize = stackInSlot.stackSize
|
||||
+ stackToShift.stackSize;
|
||||
int max = Math.min(stackToShift.getMaxStackSize(),
|
||||
slot.getSlotStackLimit());
|
||||
if (resultingStackSize <= max)
|
||||
{
|
||||
stackToShift.stackSize = 0;
|
||||
stackInSlot.stackSize = resultingStackSize;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
} else if (stackInSlot.stackSize < max)
|
||||
{
|
||||
stackToShift.stackSize -= max - stackInSlot.stackSize;
|
||||
stackInSlot.stackSize = max;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stackToShift.stackSize > 0)
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0
|
||||
&& slotIndex < end; slotIndex++)
|
||||
{
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot == null)
|
||||
{
|
||||
int max = Math.min(stackToShift.getMaxStackSize(),
|
||||
slot.getSlotStackLimit());
|
||||
stackInSlot = stackToShift.copy();
|
||||
stackInSlot.stackSize = Math.min(stackToShift.stackSize,
|
||||
max);
|
||||
stackToShift.stackSize -= stackInSlot.stackSize;
|
||||
slot.putStack(stackInSlot);
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
private boolean tryShiftItem(ItemStack stackToShift, int numSlots) {
|
||||
for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(machineIndex);
|
||||
if (slot instanceof SlotFake) {
|
||||
continue;
|
||||
}
|
||||
if (!slot.isItemValid(stackToShift))
|
||||
continue;
|
||||
if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean tryShiftItem(ItemStack stackToShift, int numSlots)
|
||||
{
|
||||
for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++)
|
||||
{
|
||||
Slot slot = (Slot) inventorySlots.get(machineIndex);
|
||||
if (slot instanceof SlotFake)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!slot.isItemValid(stackToShift))
|
||||
continue;
|
||||
if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue