mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1710 from abel1502/abel-strand-caster
Improve strand caster
This commit is contained in:
commit
a4e321f4c9
@ -35,6 +35,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
|||||||
|
|
||||||
public FluidTank water;
|
public FluidTank water;
|
||||||
public FluidTank steam;
|
public FluidTank steam;
|
||||||
|
private long lastCastTick = 0;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "container.machineStrandCaster";
|
return "container.machineStrandCaster";
|
||||||
@ -81,31 +82,41 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
|||||||
ItemMold.Mold mold = this.getInstalledMold();
|
ItemMold.Mold mold = this.getInstalledMold();
|
||||||
|
|
||||||
if(canProcess()) {
|
if(canProcess()) {
|
||||||
|
int minAmount = mold.getCost() * 9;
|
||||||
int itemsCasted = Math.min(amount / mold.getCost(), 9);
|
|
||||||
|
// Makes it flush the buffers after 10 seconds of inactivity
|
||||||
for(int j = 0; j < itemsCasted; j++) {
|
if(worldObj.getWorldTime() >= lastCastTick + 200) {
|
||||||
this.amount -= mold.getCost();
|
minAmount = mold.getCost();
|
||||||
|
|
||||||
ItemStack out = mold.getOutput(type);
|
|
||||||
|
|
||||||
for(int i = 1; i < 7; i++) {
|
|
||||||
if(slots[i] == null) {
|
|
||||||
slots[i] = out.copy();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(slots[i].isItemEqual(out) && slots[i].stackSize + out.stackSize <= out.getMaxStackSize()) {
|
|
||||||
slots[i].stackSize += out.stackSize;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
markChanged();
|
|
||||||
|
|
||||||
water.setFill(water.getFill() - getWaterRequired() * itemsCasted);
|
if(this.amount >= minAmount) {
|
||||||
steam.setFill(steam.getFill() + getWaterRequired() * itemsCasted);
|
int itemsCasted = amount / mold.getCost();
|
||||||
|
|
||||||
|
for(int j = 0; j < itemsCasted; j++) {
|
||||||
|
this.amount -= mold.getCost();
|
||||||
|
|
||||||
|
ItemStack out = mold.getOutput(type);
|
||||||
|
|
||||||
|
for(int i = 1; i < 7; i++) {
|
||||||
|
if(slots[i] == null) {
|
||||||
|
slots[i] = out.copy();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(slots[i].isItemEqual(out) && slots[i].stackSize + out.stackSize <= out.getMaxStackSize()) {
|
||||||
|
slots[i].stackSize += out.stackSize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
markChanged();
|
||||||
|
|
||||||
|
water.setFill(water.getFill() - getWaterRequired() * itemsCasted);
|
||||||
|
steam.setFill(steam.getFill() + getWaterRequired() * itemsCasted);
|
||||||
|
|
||||||
|
lastCastTick = worldObj.getWorldTime();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +131,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
|||||||
|
|
||||||
public boolean canProcess() {
|
public boolean canProcess() {
|
||||||
ItemMold.Mold mold = this.getInstalledMold();
|
ItemMold.Mold mold = this.getInstalledMold();
|
||||||
if(type != null && mold != null && this.amount >= mold.getCost() * 9 && mold.getOutput(type) != null) {
|
if(type != null && mold != null && mold.getOutput(type) != null) {
|
||||||
for(int i = 1; i < 7; i++) {
|
for(int i = 1; i < 7; i++) {
|
||||||
if(slots[i] == null || slots[i].isItemEqual(mold.getOutput(type)) && slots[i].stackSize + mold.getOutput(type).stackSize <= mold.getOutput(type).getMaxStackSize())
|
if(slots[i] == null || slots[i].isItemEqual(mold.getOutput(type)) && slots[i].stackSize + mold.getOutput(type).stackSize <= mold.getOutput(type).getMaxStackSize())
|
||||||
return water.getFill() >= getWaterRequired() && steam.getFill() < steam.getMaxFill();
|
return water.getFill() >= getWaterRequired() && steam.getFill() < steam.getMaxFill();
|
||||||
@ -270,6 +281,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
|||||||
super.writeToNBT(nbt);
|
super.writeToNBT(nbt);
|
||||||
water.writeToNBT(nbt, "w");
|
water.writeToNBT(nbt, "w");
|
||||||
steam.writeToNBT(nbt, "s");
|
steam.writeToNBT(nbt, "s");
|
||||||
|
nbt.setLong("t", lastCastTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -277,6 +289,7 @@ public class TileEntityMachineStrandCaster extends TileEntityFoundryCastingBase
|
|||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
water.readFromNBT(nbt, "w");
|
water.readFromNBT(nbt, "w");
|
||||||
steam.readFromNBT(nbt, "s");
|
steam.readFromNBT(nbt, "s");
|
||||||
|
lastCastTick = nbt.getLong("t");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user