mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-22 04:52:25 +00:00
Add comparator support for a large number of blocks (#5474)
* Add comparator support to a lot of various blocks. Closes #5447 * Add comparator support for various generator blocks * Cleanup some old calculations not using the new utils method
This commit is contained in:
1 parent
52796ff18f
commit
c8d2fbbac8
34 files changed
+341
-64
No files matched your search
@@ -16,6 +16,7 @@ import mekanism.common.MekanismFluids;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.Upgrade.IUpgradeInfoHandler;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ITankManager;
|
||||
@@ -51,7 +52,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityElectrolyticSeparator extends TileEntityMachine implements IFluidHandlerWrapper, IComputerIntegration, ISustainedData, IGasHandler,
|
||||
IUpgradeInfoHandler, ITankManager {
|
||||
IUpgradeInfoHandler, ITankManager, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getWater", "getWaterNeeded", "getHydrogen",
|
||||
"getHydrogenNeeded", "getOxygen", "getOxygenNeeded"};
|
||||
@@ -91,6 +92,8 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement
|
||||
*/
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityElectrolyticSeparator() {
|
||||
super("machine.electrolyticseparator", "ElectrolyticSeparator", MachineType.ELECTROLYTIC_SEPARATOR.getStorage(), 0, 4);
|
||||
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
@@ -137,6 +140,12 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement
|
||||
handleTank(leftTank, dumpLeft, MekanismUtils.getLeft(facing), dumpAmount);
|
||||
handleTank(rightTank, dumpRight, MekanismUtils.getRight(facing), dumpAmount);
|
||||
prevEnergy = getEnergy();
|
||||
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,4 +487,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement
|
||||
setEnergy(Math.min(getMaxEnergy(), getEnergy()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(fluidTank.getFluidAmount(), fluidTank.getCapacity());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user