mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +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
@@ -9,6 +9,7 @@ import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.ILogisticalTransporter;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
@@ -34,7 +35,6 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
@@ -42,7 +42,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IConfigurable, ITierUpgradeable {
|
||||
public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IConfigurable, ITierUpgradeable, IComparatorSupport {
|
||||
|
||||
private static final int[] UPSLOTS = {1};
|
||||
private static final int[] DOWNSLOTS = {0};
|
||||
@@ -487,9 +487,9 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
double fractionFull = (float) getItemCount() / (float) getMaxStoredCount();
|
||||
return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
return MekanismUtils.redstoneLevelFromContents(getItemCount(), getMaxStoredCount());
|
||||
}
|
||||
|
||||
public int getMaxStoredCount() {
|
||||
|
||||
@@ -4,12 +4,14 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.content.boiler.BoilerSteamTank;
|
||||
import mekanism.common.content.boiler.BoilerTank;
|
||||
import mekanism.common.content.boiler.BoilerWaterTank;
|
||||
import mekanism.common.integration.computer.IComputerIntegration;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -19,11 +21,12 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFluidHandlerWrapper, IComputerIntegration {
|
||||
public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFluidHandlerWrapper, IComputerIntegration, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"isFormed", "getSteam", "getWater", "getBoilRate", "getMaxBoilRate", "getTemp"};
|
||||
public BoilerTank waterTank;
|
||||
public BoilerTank steamTank;
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityBoilerValve() {
|
||||
super("BoilerValve");
|
||||
@@ -51,6 +54,11 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl
|
||||
}
|
||||
}
|
||||
}
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -163,4 +171,9 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(waterTank.getFluidAmount(), waterTank.getCapacity());
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.MekanismFluids;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
@@ -27,6 +28,7 @@ import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.StatUtils;
|
||||
import mekanism.common.util.TileUtils;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -35,7 +37,7 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityChemicalDissolutionChamber extends TileEntityMachine implements IGasHandler, ISustainedData, ITankManager {
|
||||
public class TileEntityChemicalDissolutionChamber extends TileEntityMachine implements IGasHandler, ISustainedData, ITankManager, IComparatorSupport {
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
public static final int BASE_INJECT_USAGE = 1;
|
||||
@@ -308,4 +310,9 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl
|
||||
public Object[] getTanks() {
|
||||
return new Object[]{injectTank, outputTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return Container.calcRedstoneFromInventory(this);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import mekanism.api.gas.IGasItem;
|
||||
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;
|
||||
@@ -46,7 +47,8 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityChemicalWasher extends TileEntityMachine implements IGasHandler, IFluidHandlerWrapper, ISustainedData, IUpgradeInfoHandler, ITankManager {
|
||||
public class TileEntityChemicalWasher extends TileEntityMachine implements IGasHandler, IFluidHandlerWrapper, ISustainedData, IUpgradeInfoHandler, ITankManager,
|
||||
IComparatorSupport {
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
public static final int MAX_FLUID = 10000;
|
||||
@@ -58,6 +60,7 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH
|
||||
|
||||
public WasherRecipe cachedRecipe;
|
||||
|
||||
private int currentRedstoneLevel;
|
||||
public double clientEnergyUsed;
|
||||
|
||||
public TileEntityChemicalWasher() {
|
||||
@@ -84,6 +87,11 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH
|
||||
}
|
||||
TileUtils.emitGas(this, outputTank, gasOutput, MekanismUtils.getRight(facing));
|
||||
prevEnergy = getEnergy();
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,4 +352,9 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH
|
||||
public Object[] getTanks() {
|
||||
return new Object[]{fluidTank, inputTank, outputTank};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(inputTank.getStored(), inputTank.getMaxGas());
|
||||
}
|
||||
}
|
||||
@@ -74,9 +74,7 @@ public class TileEntityDynamicTank extends TileEntityMultiblock<SynchronizedTank
|
||||
}
|
||||
valveViewing.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
} else {
|
||||
if (structure != null) {
|
||||
if (structure.fluidStored != null && structure.fluidStored.amount <= 0) {
|
||||
structure.fluidStored = null;
|
||||
|
||||
@@ -3,11 +3,13 @@ package mekanism.common.tile;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.content.tank.DynamicFluidTank;
|
||||
import mekanism.common.util.FluidContainerUtils;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.LangUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -17,15 +19,28 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFluidHandlerWrapper {
|
||||
public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFluidHandlerWrapper, IComparatorSupport {
|
||||
|
||||
public DynamicFluidTank fluidTank;
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityDynamicValve() {
|
||||
super("Dynamic Valve");
|
||||
fluidTank = new DynamicFluidTank(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
super.onUpdate();
|
||||
if (!world.isRemote) {
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
return ((!world.isRemote && structure != null) || (world.isRemote && clientHasStructure)) ? new FluidTankInfo[]{fluidTank.getInfo()} : PipeUtils.EMPTY;
|
||||
@@ -114,4 +129,9 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl
|
||||
//can be filled/emptied
|
||||
return slot == 0 && FluidContainerUtils.isFluidContainer(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(fluidTank.getFluidAmount(), fluidTank.getCapacity());
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismFluids;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedTank;
|
||||
@@ -58,7 +59,7 @@ import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandlerWrapper, ISustainedTank, IConfigurable, IRedstoneControl, IUpgradeTile,
|
||||
ITankManager, IComputerIntegration, ISecurityTile {
|
||||
ITankManager, IComputerIntegration, ISecurityTile, IComparatorSupport {
|
||||
|
||||
private static final int[] UPSLOTS = {0};
|
||||
private static final int[] DOWNSLOTS = {1};
|
||||
@@ -99,6 +100,8 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityElectricPump() {
|
||||
super("ElectricPump", MachineType.ELECTRIC_PUMP.getStorage());
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
@@ -114,9 +117,6 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
FluidContainerUtils.handleContainerItemFill(this, fluidTank, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) {
|
||||
if (suckedLastOperation) {
|
||||
setEnergy(getEnergy() - energyPerTick);
|
||||
@@ -143,12 +143,19 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if (!world.isRemote && fluidTank.getFluid() != null) {
|
||||
TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.UP).getTileEntity(world);
|
||||
if (CapabilityUtils.hasCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
|
||||
IFluidHandler handler = CapabilityUtils.getCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN);
|
||||
FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(256 * (upgradeComponent.getUpgrades(Upgrade.SPEED) + 1), fluidTank.getFluidAmount()));
|
||||
fluidTank.drain(handler.fill(toDrain, true), true);
|
||||
if (!world.isRemote) {
|
||||
if (fluidTank.getFluid() != null) {
|
||||
TileEntity tileEntity = Coord4D.get(this).offset(EnumFacing.UP).getTileEntity(world);
|
||||
if (CapabilityUtils.hasCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN)) {
|
||||
IFluidHandler handler = CapabilityUtils.getCapability(tileEntity, CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, EnumFacing.DOWN);
|
||||
FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(256 * (upgradeComponent.getUpgrades(Upgrade.SPEED) + 1), fluidTank.getFluidAmount()));
|
||||
fluidTank.drain(handler.fill(toDrain, true), true);
|
||||
}
|
||||
}
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -482,4 +489,9 @@ public class TileEntityElectricPump extends TileEntityElectricBlock implements I
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(fluidTank.getFluidAmount(), fluidTank.getCapacity());
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import mekanism.api.TileNetworkList;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
@@ -32,12 +33,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl, ISideConfiguration, ISecurityTile, ITierUpgradeable,
|
||||
IConfigCardAccess {
|
||||
IConfigCardAccess, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded"};
|
||||
/**
|
||||
@@ -241,9 +241,9 @@ public class TileEntityEnergyCube extends TileEntityElectricBlock implements ICo
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
double fractionFull = getEnergy() / getMaxEnergy();
|
||||
return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
return MekanismUtils.redstoneLevelFromContents(getEnergy(), getMaxEnergy());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@ import mekanism.common.MekanismItems;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFactory.MachineFuelType;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
@@ -61,6 +62,7 @@ import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import mekanism.common.util.StatUtils;
|
||||
import mekanism.common.util.TileUtils;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -69,7 +71,8 @@ import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityFactory extends TileEntityMachine implements IComputerIntegration, ISideConfiguration, IGasHandler, ISpecialConfigData, ITierUpgradeable, ISustainedData {
|
||||
public class TileEntityFactory extends TileEntityMachine implements IComputerIntegration, ISideConfiguration, IGasHandler, ISpecialConfigData, ITierUpgradeable,
|
||||
ISustainedData, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
|
||||
private final MachineRecipe[] cachedRecipe;
|
||||
@@ -985,4 +988,9 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
infuseStored.readSustainedData(itemStack);
|
||||
GasUtils.readSustainedData(gasTank, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return Container.calcRedstoneFromInventory(this);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidContainerManager;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.ISustainedTank;
|
||||
@@ -41,7 +42,6 @@ import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.SoundCategory;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
@@ -52,7 +52,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityFluidTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, IFluidHandlerWrapper, ISustainedTank, IFluidContainerManager,
|
||||
ITankManager, ISecurityTile, ITierUpgradeable, ITieredTile {
|
||||
ITankManager, ISecurityTile, ITierUpgradeable, ITieredTile, IComparatorSupport {
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
@@ -287,9 +287,9 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
double fractionFull = (float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity();
|
||||
return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
return MekanismUtils.redstoneLevelFromContents(fluidTank.getFluidAmount(), fluidTank.getCapacity());
|
||||
}
|
||||
|
||||
public int getCurrentNeeded() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedTank;
|
||||
@@ -52,7 +53,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, IFluidHandlerWrapper, ISustainedTank,
|
||||
IUpgradeTile, IRedstoneControl, ISecurityTile {
|
||||
IUpgradeTile, IRedstoneControl, ISecurityTile, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"reset"};
|
||||
private static EnumSet<EnumFacing> dirs = EnumSet.complementOf(EnumSet.of(EnumFacing.UP));
|
||||
@@ -78,6 +79,8 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3);
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityFluidicPlenisher() {
|
||||
super("FluidicPlenisher", MachineType.FLUIDIC_PLENISHER.getStorage());
|
||||
inventory = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
@@ -119,6 +122,12 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
operatingTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,4 +454,9 @@ public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implemen
|
||||
public TileComponentSecurity getSecurity() {
|
||||
return securityComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(fluidTank.getFluidAmount(), fluidTank.getCapacity());
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import mekanism.api.gas.IGasItem;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.SideData;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
@@ -39,12 +40,11 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, IRedstoneControl, ISideConfiguration, ISecurityTile, ITierUpgradeable,
|
||||
IComputerIntegration {
|
||||
IComputerIntegration, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getMaxGas", "getStoredGas", "getGas"};
|
||||
/**
|
||||
@@ -297,9 +297,9 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||
return side != 0 && side != 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
double fractionFull = (float) gasTank.getStored() / (float) gasTank.getMaxGas();
|
||||
return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
return MekanismUtils.redstoneLevelFromContents(gasTank.getStored(), gasTank.getMaxGas());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
@@ -188,8 +187,7 @@ public class TileEntityLaserAmplifier extends TileEntityContainerBlock implement
|
||||
if (outputMode != RedstoneOutput.ENERGY_CONTENTS) {
|
||||
return 0;
|
||||
}
|
||||
double fractionFull = getEnergy() / getMaxEnergy();
|
||||
return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
return MekanismUtils.redstoneLevelFromContents(getEnergy(), getMaxEnergy());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,6 +9,7 @@ import mekanism.api.lasers.ILaserReceptor;
|
||||
import mekanism.common.LaserManager;
|
||||
import mekanism.common.LaserManager.LaserInfo;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
@@ -19,6 +20,7 @@ import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.StackUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -27,7 +29,7 @@ import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityLaserTractorBeam extends TileEntityContainerBlock implements ILaserReceptor, ISecurityTile {
|
||||
public class TileEntityLaserTractorBeam extends TileEntityContainerBlock implements ILaserReceptor, ISecurityTile, IComparatorSupport {
|
||||
|
||||
public static final double MAX_ENERGY = 5E9;
|
||||
public static int[] availableSlotIDs = InventoryUtils.getIntRange(0, 26);
|
||||
@@ -196,4 +198,9 @@ public class TileEntityLaserTractorBeam extends TileEntityContainerBlock impleme
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return Container.calcRedstoneFromInventory(this);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.HashList;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.ILogisticalTransporter;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
@@ -52,7 +53,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
|
||||
public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implements IRedstoneControl, ISpecialConfigData, ISustainedData, ISecurityTile,
|
||||
IComputerIntegration, IUpgradeTile {
|
||||
IComputerIntegration, IUpgradeTile, IComparatorSupport {
|
||||
|
||||
public HashList<TransporterFilter> filters = new HashList<>();
|
||||
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||
@@ -65,6 +66,7 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement
|
||||
public TileComponentUpgrade upgradeComponent;
|
||||
public TileComponentSecurity securityComponent = new TileComponentSecurity(this);
|
||||
public String[] methods = {"setDefaultColor", "setRoundRobin", "setAutoEject", "addFilter", "removeFilter", "addOreFilter", "removeOreFilter", "setSingleItem"};
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityLogisticalSorter() {
|
||||
super("machine.logisticalsorter", "LogisticalSorter", MachineType.LOGISTICAL_SORTER.getStorage(), 3);
|
||||
@@ -136,6 +138,12 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement
|
||||
Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new TileNetworkList())), (EntityPlayerMP) player);
|
||||
}
|
||||
}
|
||||
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,6 +645,11 @@ public class TileEntityLogisticalSorter extends TileEntityEffectsBlock implement
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return isActive ? 15 : 0;
|
||||
}
|
||||
|
||||
private class StrictFilterFinder extends Finder {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import mekanism.common.Mekanism;
|
||||
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;
|
||||
@@ -43,7 +44,8 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityRotaryCondensentrator extends TileEntityMachine implements ISustainedData, IFluidHandlerWrapper, IGasHandler, IUpgradeInfoHandler, ITankManager {
|
||||
public class TileEntityRotaryCondensentrator extends TileEntityMachine implements ISustainedData, IFluidHandlerWrapper, IGasHandler, IUpgradeInfoHandler, ITankManager,
|
||||
IComparatorSupport {
|
||||
|
||||
private static final int[] GAS_SLOTS = {0, 1};
|
||||
private static final int[] LIQUID_SLOTS = {2, 3};
|
||||
@@ -60,6 +62,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement
|
||||
public int gasOutput = 256;
|
||||
|
||||
public double clientEnergyUsed;
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityRotaryCondensentrator() {
|
||||
super("machine.rotarycondensentrator", "RotaryCondensentrator", MachineType.ROTARY_CONDENSENTRATOR.getStorage(),
|
||||
@@ -116,6 +119,11 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement
|
||||
}
|
||||
}
|
||||
prevEnergy = getEnergy();
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,4 +362,12 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
if (mode == 0) {
|
||||
return MekanismUtils.redstoneLevelFromContents(gasTank.getStored(), gasTank.getMaxGas());
|
||||
}
|
||||
return MekanismUtils.redstoneLevelFromContents(fluidTank.getFluidAmount(), fluidTank.getCapacity());
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import mekanism.common.Upgrade;
|
||||
import mekanism.common.Upgrade.IUpgradeInfoHandler;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ITankManager;
|
||||
@@ -44,7 +45,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, IBoundingBlock, IGasHandler, IActiveState, ISustainedData,
|
||||
ITankManager, ISecurityTile, IUpgradeTile, IUpgradeInfoHandler {
|
||||
ITankManager, ISecurityTile, IUpgradeTile, IUpgradeInfoHandler, IComparatorSupport {
|
||||
|
||||
public static final int MAX_GAS = 10000;
|
||||
private static final int[] INPUT_SLOT = {0};
|
||||
@@ -57,6 +58,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
|
||||
|
||||
private SolarNeutronRecipe cachedRecipe;
|
||||
|
||||
private int currentRedstoneLevel;
|
||||
private boolean isActive;
|
||||
private boolean needsRainCheck;
|
||||
|
||||
@@ -107,6 +109,12 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
|
||||
if (world.getTotalWorldTime() % 20 == 0) {
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())), new Range4D(Coord4D.get(this)));
|
||||
}
|
||||
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,4 +359,9 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
|
||||
public boolean isItemValidForSlot(int slot, @Nonnull ItemStack stack) {
|
||||
return stack.getItem() instanceof IGasItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(inputTank.getStored(), inputTank.getMaxGas());
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
@@ -51,7 +52,7 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityTeleporter extends TileEntityElectricBlock implements IComputerIntegration, IChunkLoader, IFrequencyHandler, IRedstoneControl, ISecurityTile,
|
||||
IUpgradeTile {
|
||||
IUpgradeTile, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "canTeleport", "getMaxEnergy", "teleport", "setFrequency"};
|
||||
public AxisAlignedBB teleportBounds = null;
|
||||
@@ -164,6 +165,8 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
if (shouldRender != prevShouldRender) {
|
||||
Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new TileNetworkList())),
|
||||
Coord4D.get(this).getTargetPoint(40D));
|
||||
//This also means the comparator output changed so notify the neighbors we have a change
|
||||
MekanismUtils.notifyLoadedNeighborsOfTileChange(world, Coord4D.get(this));
|
||||
}
|
||||
prevShouldRender = shouldRender;
|
||||
teleDelay = Math.max(0, teleDelay - 1);
|
||||
@@ -555,4 +558,9 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo
|
||||
public TileComponentUpgrade getComponent() {
|
||||
return upgradeComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return shouldRender ? 15 : 0;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IHeatTransfer;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
@@ -15,9 +16,10 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
|
||||
public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporationBlock implements IFluidHandlerWrapper, IHeatTransfer {
|
||||
public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporationBlock implements IFluidHandlerWrapper, IHeatTransfer, IComparatorSupport {
|
||||
|
||||
public boolean prevMaster = false;
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
@@ -32,6 +34,11 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat
|
||||
}
|
||||
}
|
||||
prevMaster = master != null;
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,4 +151,13 @@ public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporat
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
TileEntityThermalEvaporationController controller = getController();
|
||||
if (controller != null) {
|
||||
return MekanismUtils.redstoneLevelFromContents(controller.inputTank.getFluidAmount(), controller.inputTank.getCapacity());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,13 @@ import io.netty.buffer.ByteBuf;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public abstract class TileEntityOperationalMachine extends TileEntityMachine {
|
||||
public abstract class TileEntityOperationalMachine extends TileEntityMachine implements IComparatorSupport {
|
||||
|
||||
public int operatingTicks;
|
||||
|
||||
@@ -71,4 +73,9 @@ public abstract class TileEntityOperationalMachine extends TileEntityMachine {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return Container.calcRedstoneFromInventory(this);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user