mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Update TileEntityMachineArcFurnaceLarge.java
This commit is contained in:
parent
f0bd84fa47
commit
14f7668a9a
@ -401,7 +401,110 @@ public class TileEntityMachineArcFurnaceLarge extends TileEntityMachineBase impl
|
||||
liquids.add(matStack.copy());
|
||||
}
|
||||
|
||||
//Returns what is unused, or null if used up
|
||||
public ItemStack distributeInput(ItemStack is, boolean modulate) {
|
||||
if(is.stackSize == 0) return null;
|
||||
ItemStack split;
|
||||
|
||||
//Slots 0,1,2
|
||||
if(is.getItem() == ModItems.arc_electrode) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(slots[i] == null) {
|
||||
split = is.splitStack(1);
|
||||
if(modulate) this.setInventorySlotContents(i, split);
|
||||
}
|
||||
if (is.stackSize == 0) return null;
|
||||
}
|
||||
//Don't tell me you're gonna add an arc furnace recipe smelting electrodes
|
||||
return is;
|
||||
}
|
||||
|
||||
//Slots 5-24
|
||||
ArcFurnaceRecipe recipe = ArcFurnaceRecipes.getOutput(is, this.liquidMode);
|
||||
if(recipe != null) {
|
||||
int maxStackSize = this.liquidMode ? 64 : recipe.solidOutput.getMaxStackSize() / recipe.solidOutput.stackSize;
|
||||
maxStackSize = Math.min(maxStackSize, Math.min(is.getMaxStackSize(), getMaxInputSize()));
|
||||
|
||||
//Scan
|
||||
for(int i = 5; i < 25; i++){
|
||||
if(slots[i] == null) {
|
||||
if(is.stackSize > maxStackSize) {
|
||||
split = is.splitStack(maxStackSize);
|
||||
if(modulate) slots[i] = split;
|
||||
} else {
|
||||
if(modulate) slots[i] = is;
|
||||
return null;
|
||||
}
|
||||
} else if(ItemStackUtil.areStacksCompatible(is, slots[i]) && slots[i].stackSize < maxStackSize) {
|
||||
if(is.stackSize > maxStackSize - slots[i].stackSize) {
|
||||
is.splitStack(maxStackSize - slots[i].stackSize);
|
||||
if(modulate) slots[i].stackSize = maxStackSize;
|
||||
} else {
|
||||
if(modulate) slots[i].stackSize += is.stackSize;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
//Returns requested ItemStack
|
||||
public ItemStack collectRequested(ItemStack is, boolean modulate) {
|
||||
int req = is.stackSize;
|
||||
if(req == 0) return null;
|
||||
|
||||
//Slots 0,1,2
|
||||
if(is.getItem() != ModItems.arc_electrode) {
|
||||
for(int i = 0; i < 3; i++) {
|
||||
if(slots[i] == null) continue;
|
||||
if(ItemStackUtil.areStacksCompatible(is, slots[i])) {
|
||||
if(req > slots[i].stackSize) {
|
||||
req -= slots[i].stackSize;
|
||||
if(modulate) slots[i] = null;
|
||||
} else if(req < slots[i].stackSize) {
|
||||
if(modulate) slots[i].stackSize -= req;
|
||||
return is;
|
||||
} else {
|
||||
if(modulate) slots[i] = null;
|
||||
return is;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Slots 5-24
|
||||
if(ArcFurnaceRecipes.getOutput(is, this.liquidMode) == null) {
|
||||
for(int i = 5; i < 25; i++) {
|
||||
if(slots[i] == null) continue;
|
||||
if(ItemStackUtil.areStacksCompatible(is, slots[i])) {
|
||||
if(req > slots[i].stackSize) {
|
||||
req -= slots[i].stackSize;
|
||||
if(modulate) slots[i] = null;
|
||||
} else if(req < slots[i].stackSize) {
|
||||
if(modulate) slots[i].stackSize -= req;
|
||||
return is;
|
||||
} else {
|
||||
if(modulate) slots[i] = null;
|
||||
return is;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
is.stackSize -= req;
|
||||
if(is.stackSize == 0) return null;
|
||||
return is;
|
||||
}
|
||||
|
||||
//Return ItemStack in slot, null if unavailable
|
||||
public ItemStack getAvailableItemFromSlot(int slot) {
|
||||
if(slots[slot] == null) return null;
|
||||
if(slot < 3 && slots[slot].getItem() == ModItems.arc_electrode) return null;
|
||||
else if(slot > 4 && ArcFurnaceRecipes.getOutput(slots[slot], this.liquidMode) != null) return null;
|
||||
else if(slot == 3 || slot == 4) return null;
|
||||
else return slots[slot];
|
||||
}
|
||||
|
||||
public static int getStackAmount(List<MaterialStack> stack) {
|
||||
int amount = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user