Moved to RebornCore
This commit is contained in:
parent
50a830a101
commit
8abf6e5282
313 changed files with 3987 additions and 16508 deletions
|
@ -5,9 +5,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileAesu;
|
||||
|
||||
public class ContainerAesu extends TechRebornContainer {
|
||||
public class ContainerAesu extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
@ -29,7 +30,7 @@ public class ContainerAesu extends TechRebornContainer {
|
|||
|
||||
// input
|
||||
//this.addSlotToContainer(new Slot(tileaesu.inventory, 0, 116, 23));
|
||||
// this.addSlotToContainer(new Slot(tileaesu.inventory, 1, 116, 59));
|
||||
// this.addSlotToContainer(new Slot(tileaesu.inventory, 1, 116, 59));
|
||||
|
||||
int i;
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ 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 reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileAlloyFurnace;
|
||||
|
||||
public class ContainerAlloyFurnace extends TechRebornContainer {
|
||||
public class ContainerAlloyFurnace extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
@ -69,7 +70,7 @@ public class ContainerAlloyFurnace extends TechRebornContainer {
|
|||
if (this.burnTime != tile.burnTime) {
|
||||
crafting.sendProgressBarUpdate(this, 1, tile.burnTime);
|
||||
}
|
||||
if (this.cookTime != tile.cookTime) {
|
||||
if (this.cookTime != tile.cookTime) {
|
||||
crafting.sendProgressBarUpdate(this, 2, tile.cookTime);
|
||||
}
|
||||
}
|
||||
|
@ -79,11 +80,11 @@ public class ContainerAlloyFurnace extends TechRebornContainer {
|
|||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
super.updateProgressBar(id, value);
|
||||
if(id == 0){
|
||||
if (id == 0) {
|
||||
this.currentItemBurnTime = value;
|
||||
} else if(id ==1){
|
||||
} else if (id == 1) {
|
||||
this.burnTime = value;
|
||||
} else if(id == 2){
|
||||
} else if (id == 2) {
|
||||
this.cookTime = value;
|
||||
}
|
||||
this.tile.currentItemBurnTime = this.currentItemBurnTime;
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileAlloySmelter;
|
||||
|
||||
public class ContainerAlloySmelter extends ContainerCrafting {
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileAssemblingMachine;
|
||||
|
||||
public class ContainerAssemblingMachine extends ContainerCrafting {
|
||||
|
|
|
@ -3,7 +3,7 @@ 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 reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileBlastFurnace;
|
||||
|
||||
public class ContainerBlastFurnace extends ContainerCrafting {
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileCentrifuge;
|
||||
|
||||
public class ContainerCentrifuge extends ContainerCrafting {
|
||||
|
@ -19,8 +19,8 @@ public class ContainerCentrifuge extends ContainerCrafting {
|
|||
}
|
||||
|
||||
public ContainerCentrifuge(TileCentrifuge tileCentrifuge, EntityPlayer player) {
|
||||
super(tileCentrifuge.crafter);
|
||||
tile = tileCentrifuge;
|
||||
super(tileCentrifuge.crafter);
|
||||
tile = tileCentrifuge;
|
||||
this.player = player;
|
||||
|
||||
// input
|
||||
|
|
|
@ -2,9 +2,10 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileChargeBench;
|
||||
|
||||
public class ContainerChargeBench extends TechRebornContainer {
|
||||
public class ContainerChargeBench extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileChemicalReactor;
|
||||
|
||||
public class ContainerChemicalReactor extends ContainerCrafting {
|
||||
|
|
|
@ -2,9 +2,10 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileChunkLoader;
|
||||
|
||||
public class ContainerChunkloader extends TechRebornContainer {
|
||||
public class ContainerChunkloader extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@ package techreborn.client.container;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.api.recipe.RecipeCrafter;
|
||||
|
||||
public abstract class ContainerCrafting extends TechRebornContainer {
|
||||
public abstract class ContainerCrafting extends RebornContainer {
|
||||
|
||||
RecipeCrafter crafter;
|
||||
|
||||
|
|
|
@ -3,11 +3,12 @@ package techreborn.client.container;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.client.SlotFilteredVoid;
|
||||
import reborncore.client.gui.SlotFilteredVoid;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.util.Inventory;
|
||||
|
||||
public class ContainerDestructoPack extends TechRebornContainer {
|
||||
public class ContainerDestructoPack extends RebornContainer {
|
||||
|
||||
private EntityPlayer player;
|
||||
private Inventory inv;
|
||||
|
|
|
@ -5,11 +5,12 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileDieselGenerator;
|
||||
|
||||
public class ContainerDieselGenerator extends TechRebornContainer {
|
||||
public class ContainerDieselGenerator extends RebornContainer {
|
||||
public TileDieselGenerator tiledieselGenerator;
|
||||
public EntityPlayer player;
|
||||
public int energy;
|
||||
|
@ -74,8 +75,7 @@ public class ContainerDieselGenerator extends TechRebornContainer {
|
|||
public void updateProgressBar(int id, int value) {
|
||||
if (id == 0) {
|
||||
this.energy = value;
|
||||
}else
|
||||
if (id == 1) {
|
||||
} else if (id == 1) {
|
||||
this.fluid = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileDigitalChest;
|
||||
|
||||
public class ContainerDigitalChest extends TechRebornContainer {
|
||||
public class ContainerDigitalChest extends RebornContainer {
|
||||
public TileDigitalChest tileDigitalChest;
|
||||
public EntityPlayer player;
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileGasTurbine;
|
||||
|
||||
public class ContainerGasTurbine extends TechRebornContainer {
|
||||
public class ContainerGasTurbine extends RebornContainer {
|
||||
public TileGasTurbine tileGasTurbine;
|
||||
public EntityPlayer player;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileGrinder;
|
||||
|
||||
public class ContainerGrinder extends ContainerCrafting {
|
||||
|
|
|
@ -5,10 +5,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
|
||||
|
||||
public class ContainerIDSU extends TechRebornContainer {
|
||||
public class ContainerIDSU extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileImplosionCompressor;
|
||||
|
||||
public class ContainerImplosionCompressor extends ContainerCrafting {
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileIndustrialElectrolyzer;
|
||||
|
||||
public class ContainerIndustrialElectrolyzer extends ContainerCrafting {
|
||||
|
|
|
@ -2,7 +2,7 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import techreborn.tiles.TileIndustrialSawmill;
|
||||
|
||||
public class ContainerIndustrialSawmill extends ContainerCrafting {
|
||||
|
|
|
@ -5,10 +5,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
|
||||
public class ContainerLesu extends TechRebornContainer {
|
||||
public class ContainerLesu extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
|
|
@ -5,10 +5,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileMatterFabricator;
|
||||
|
||||
public class ContainerMatterFabricator extends TechRebornContainer {
|
||||
public class ContainerMatterFabricator extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
|
||||
public class ContainerPda extends TechRebornContainer {
|
||||
public class ContainerPda extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileQuantumChest;
|
||||
|
||||
public class ContainerQuantumChest extends TechRebornContainer {
|
||||
public class ContainerQuantumChest extends RebornContainer {
|
||||
public TileQuantumChest tileQuantumChest;
|
||||
public EntityPlayer player;
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotFluid;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotFluid;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileQuantumTank;
|
||||
|
||||
public class ContainerQuantumTank extends TechRebornContainer {
|
||||
public class ContainerQuantumTank extends RebornContainer {
|
||||
public TileQuantumTank tileQuantumTank;
|
||||
public EntityPlayer player;
|
||||
|
||||
|
|
|
@ -5,12 +5,13 @@ import net.minecraft.inventory.ICrafting;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.api.RollingMachineRecipe;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
import techreborn.tiles.TileRollingMachine;
|
||||
|
||||
public class ContainerRollingMachine extends TechRebornContainer {
|
||||
public class ContainerRollingMachine extends RebornContainer {
|
||||
|
||||
EntityPlayer player;
|
||||
TileRollingMachine tile;
|
||||
|
@ -85,7 +86,7 @@ public class ContainerRollingMachine extends TechRebornContainer {
|
|||
if (this.burnTime != tile.tickTime) {
|
||||
crafting.sendProgressBarUpdate(this, 1, tile.tickTime);
|
||||
}
|
||||
if (this.energy != (int) tile.getEnergy()) {
|
||||
if (this.energy != (int) tile.getEnergy()) {
|
||||
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
}
|
||||
|
@ -95,11 +96,11 @@ public class ContainerRollingMachine extends TechRebornContainer {
|
|||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
super.updateProgressBar(id, value);
|
||||
if(id == 0){
|
||||
if (id == 0) {
|
||||
this.currentItemBurnTime = value;
|
||||
} else if(id ==1){
|
||||
} else if (id == 1) {
|
||||
this.burnTime = value;
|
||||
} else if(id == 2){
|
||||
} else if (id == 2) {
|
||||
this.energy = value;
|
||||
}
|
||||
this.tile.runTime = this.currentItemBurnTime;
|
||||
|
@ -107,9 +108,8 @@ public class ContainerRollingMachine extends TechRebornContainer {
|
|||
this.tile.setEnergy(this.energy);
|
||||
}
|
||||
|
||||
public int getBurnTimeRemainingScaled(int scale)
|
||||
{
|
||||
if(burnTime == 0 || this.currentItemBurnTime == 0){
|
||||
public int getBurnTimeRemainingScaled(int scale) {
|
||||
if (burnTime == 0 || this.currentItemBurnTime == 0) {
|
||||
return 0;
|
||||
}
|
||||
return this.burnTime * scale / this.currentItemBurnTime;
|
||||
|
|
|
@ -2,11 +2,12 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileSemifluidGenerator;
|
||||
|
||||
public class ContainerSemifluidGenerator extends TechRebornContainer {
|
||||
public class ContainerSemifluidGenerator extends RebornContainer {
|
||||
public TileSemifluidGenerator tileSemifluidGenerator;
|
||||
public EntityPlayer player;
|
||||
|
||||
|
|
|
@ -2,12 +2,13 @@ package techreborn.client.container;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.client.SlotFake;
|
||||
import techreborn.client.SlotFluid;
|
||||
import techreborn.client.SlotOutput;
|
||||
import reborncore.client.gui.SlotFake;
|
||||
import reborncore.client.gui.SlotFluid;
|
||||
import reborncore.client.gui.SlotOutput;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.TileThermalGenerator;
|
||||
|
||||
public class ContainerThermalGenerator extends TechRebornContainer {
|
||||
public class ContainerThermalGenerator extends RebornContainer {
|
||||
public TileThermalGenerator tileThermalGenerator;
|
||||
public EntityPlayer player;
|
||||
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import techreborn.client.SlotFake;
|
||||
|
||||
public abstract class TechRebornContainer extends Container {
|
||||
|
||||
@Override
|
||||
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 && canStacksMerge(stackInSlot, stackToShift)) {
|
||||
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;
|
||||
}
|
||||
|
||||
public static boolean canStacksMerge(ItemStack stack1, ItemStack stack2) {
|
||||
if (stack1 == null || stack2 == null) {
|
||||
return false;
|
||||
}
|
||||
if (!stack1.isItemEqual(stack2)) {
|
||||
return false;
|
||||
}
|
||||
if (!ItemStack.areItemStackTagsEqual(stack1, stack2)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue