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
@@ -0,0 +1,6 @@
|
||||
package mekanism.common.base;
|
||||
|
||||
public interface IComparatorSupport {
|
||||
|
||||
int getRedstoneLevel();
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.ITierItem;
|
||||
import mekanism.common.block.states.BlockStateBasic;
|
||||
import mekanism.common.block.states.BlockStateBasic.BasicBlock;
|
||||
@@ -683,8 +684,9 @@ public abstract class BlockBasic extends BlockTileDrops {
|
||||
BasicBlockType basicBlockType = BasicBlockType.get(blockState);
|
||||
if (basicBlockType != null && basicBlockType.hasRedstoneOutput) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof TileEntityBin) {
|
||||
return ((TileEntityBin) tile).getRedstoneLevel();
|
||||
if (tile instanceof IComparatorSupport) {
|
||||
//TODO: Add support for induction port (will be done in induction cleanup PR)
|
||||
return ((IComparatorSupport) tile).getRedstoneLevel();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -10,6 +10,7 @@ import mekanism.client.render.particle.MekanismParticleHelper;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFactory;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.IRedstoneControl;
|
||||
@@ -476,10 +477,11 @@ public abstract class BlockMachine extends BlockMekanismContainer {
|
||||
@Deprecated
|
||||
public int getComparatorInputOverride(IBlockState state, World world, BlockPos pos) {
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (tileEntity instanceof TileEntityFluidTank) {
|
||||
return ((TileEntityFluidTank) tileEntity).getRedstoneLevel();
|
||||
if (tileEntity instanceof IComparatorSupport) {
|
||||
return ((IComparatorSupport) tileEntity).getRedstoneLevel();
|
||||
}
|
||||
if (tileEntity instanceof TileEntityLaserAmplifier) {
|
||||
//TODO: Move this over to using IComparatorSupport?
|
||||
TileEntityLaserAmplifier amplifier = (TileEntityLaserAmplifier) tileEntity;
|
||||
if (amplifier.outputMode == TileEntityLaserAmplifier.RedstoneOutput.ENERGY_CONTENTS) {
|
||||
return amplifier.getRedstoneLevel();
|
||||
|
||||
@@ -89,11 +89,11 @@ public class BlockStateBasic extends ExtendedBlockState {
|
||||
STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false, true),
|
||||
COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
|
||||
TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false, BlockStateUtils.NO_ROTATION, false, false, true),
|
||||
THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController::new, true, Plane.HORIZONTAL, true, false, false),
|
||||
THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false, true),
|
||||
THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort::new, true, BlockStateUtils.NO_ROTATION, true, false, false),
|
||||
@@ -102,7 +102,7 @@ public class BlockStateBasic extends ExtendedBlockState {
|
||||
SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser", TileEntityPressureDisperser::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false),
|
||||
BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve::new, true, BlockStateUtils.NO_ROTATION, false, false, false, true),
|
||||
SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk::new, true, Plane.HORIZONTAL, false, false, false);
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -116,7 +116,7 @@ public abstract class BoilerTank implements IFluidTank {
|
||||
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
if (steamBoiler.structure != null) {
|
||||
if (steamBoiler.structure != null && getFluid() != null) {
|
||||
return getFluid().amount;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -125,7 +125,7 @@ public class DynamicFluidTank implements IFluidTank {
|
||||
|
||||
@Override
|
||||
public int getFluidAmount() {
|
||||
if (dynamicTank.structure != null) {
|
||||
if (dynamicTank.structure != null && dynamicTank.structure.fluidStored != null) {
|
||||
return dynamicTank.structure.fluidStored.amount;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ import net.minecraft.util.EnumFacing.Axis;
|
||||
import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
@@ -1079,6 +1080,17 @@ public final class MekanismUtils {
|
||||
world.setBlockToAir(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amount Amount currently stored
|
||||
* @param capacity Total amount that can be stored.
|
||||
*
|
||||
* @return A redstone level based on the percentage of the amount stored.
|
||||
*/
|
||||
public static int redstoneLevelFromContents(double amount, double capacity) {
|
||||
double fractionFull = capacity == 0 ? 0 : amount / capacity;
|
||||
return MathHelper.floor((float) (fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clamp a double to int without using Math.min due to double representation issues. Primary use: power systems that use int, where Mek uses doubles internally
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@ import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.base.ISustainedInventory;
|
||||
import mekanism.common.base.ISustainedTank;
|
||||
@@ -542,4 +543,22 @@ public abstract class BlockGenerator extends BlockMekanismContainer {
|
||||
return super.canCreatureSpawn(state, world, pos, type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasComparatorInputOverride(IBlockState blockState) {
|
||||
GeneratorType generatorType = GeneratorType.get(blockState);
|
||||
return generatorType != null && generatorType.hasRedstoneOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
GeneratorType generatorType = GeneratorType.get(blockState);
|
||||
if (generatorType != null && generatorType.hasRedstoneOutput) {
|
||||
TileEntity tile = worldIn.getTileEntity(pos);
|
||||
if (tile instanceof IComparatorSupport) {
|
||||
return ((IComparatorSupport) tile).getRedstoneLevel();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -72,17 +72,17 @@ public class BlockStateGenerator extends ExtendedBlockState {
|
||||
}
|
||||
|
||||
public enum GeneratorType implements IStringSerializable, IBlockType {
|
||||
HEAT_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator::new, true, Plane.HORIZONTAL, false),
|
||||
HEAT_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator::new, true, Plane.HORIZONTAL, false, true),
|
||||
SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator::new, true, Plane.HORIZONTAL, false),
|
||||
GAS_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 3, "GasGenerator", 3, -1/*uses config, set after generators config loaded*/, TileEntityGasGenerator::new, true, Plane.HORIZONTAL, false),
|
||||
BIO_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 4, "BioGenerator", 4, 160000, TileEntityBioGenerator::new, true, Plane.HORIZONTAL, false),
|
||||
GAS_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 3, "GasGenerator", 3, -1/*uses config, set after generators config loaded*/, TileEntityGasGenerator::new, true, Plane.HORIZONTAL, false, true),
|
||||
BIO_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 4, "BioGenerator", 4, 160000, TileEntityBioGenerator::new, true, Plane.HORIZONTAL, false, true),
|
||||
ADVANCED_SOLAR_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator::new, true, Plane.HORIZONTAL, false),
|
||||
WIND_GENERATOR(GeneratorBlock.GENERATOR_BLOCK_1, 6, "WindGenerator", 5, 200000, TileEntityWindGenerator::new, true, Plane.HORIZONTAL, false),
|
||||
TURBINE_ROTOR(GeneratorBlock.GENERATOR_BLOCK_1, 7, "TurbineRotor", -1, -1, TileEntityTurbineRotor::new, false, BlockStateUtils.NO_ROTATION, false),
|
||||
ROTATIONAL_COMPLEX(GeneratorBlock.GENERATOR_BLOCK_1, 8, "RotationalComplex", -1, -1, TileEntityRotationalComplex::new, false, BlockStateUtils.NO_ROTATION, false),
|
||||
ELECTROMAGNETIC_COIL(GeneratorBlock.GENERATOR_BLOCK_1, 9, "ElectromagneticCoil", -1, -1, TileEntityElectromagneticCoil::new, false, BlockStateUtils.NO_ROTATION, false),
|
||||
TURBINE_CASING(GeneratorBlock.GENERATOR_BLOCK_1, 10, "TurbineCasing", -1, -1, TileEntityTurbineCasing::new, false, BlockStateUtils.NO_ROTATION, false),
|
||||
TURBINE_VALVE(GeneratorBlock.GENERATOR_BLOCK_1, 11, "TurbineValve", -1, -1, TileEntityTurbineValve::new, false, BlockStateUtils.NO_ROTATION, false),
|
||||
TURBINE_VALVE(GeneratorBlock.GENERATOR_BLOCK_1, 11, "TurbineValve", -1, -1, TileEntityTurbineValve::new, false, BlockStateUtils.NO_ROTATION, false, true),
|
||||
TURBINE_VENT(GeneratorBlock.GENERATOR_BLOCK_1, 12, "TurbineVent", -1, -1, TileEntityTurbineVent::new, false, BlockStateUtils.NO_ROTATION, false),
|
||||
SATURATING_CONDENSER(GeneratorBlock.GENERATOR_BLOCK_1, 13, "SaturatingCondenser", -1, -1, TileEntitySaturatingCondenser::new, false, BlockStateUtils.NO_ROTATION, false);
|
||||
|
||||
@@ -107,9 +107,15 @@ public class BlockStateGenerator extends ExtendedBlockState {
|
||||
public boolean hasModel;
|
||||
public Predicate<EnumFacing> facingPredicate;
|
||||
public boolean activable;
|
||||
public boolean hasRedstoneOutput;
|
||||
|
||||
GeneratorType(GeneratorBlock block, int i, String s, int j, double k, Supplier<TileEntity> tileClass, boolean model, Predicate<EnumFacing> predicate,
|
||||
boolean hasActiveTexture) {
|
||||
this(block, i, s, j, k, tileClass, model, predicate, hasActiveTexture, false);
|
||||
}
|
||||
|
||||
GeneratorType(GeneratorBlock block, int i, String s, int j, double k, Supplier<TileEntity> tileClass, boolean model, Predicate<EnumFacing> predicate,
|
||||
boolean hasActiveTexture, boolean hasRedstoneOutput) {
|
||||
blockType = block;
|
||||
meta = i;
|
||||
blockName = s;
|
||||
@@ -119,6 +125,7 @@ public class BlockStateGenerator extends ExtendedBlockState {
|
||||
hasModel = model;
|
||||
facingPredicate = predicate;
|
||||
activable = hasActiveTexture;
|
||||
this.hasRedstoneOutput = hasRedstoneOutput;
|
||||
}
|
||||
|
||||
public static List<GeneratorType> getGeneratorsForConfig() {
|
||||
|
||||
@@ -7,6 +7,7 @@ import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.FluidSlot;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
@@ -14,6 +15,7 @@ import mekanism.common.util.ChargeUtils;
|
||||
import mekanism.common.util.ItemDataUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
@@ -27,7 +29,7 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandlerWrapper, ISustainedData {
|
||||
public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandlerWrapper, ISustainedData, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"};
|
||||
private static FluidTankInfo[] ALL_TANKS = new FluidTankInfo[0];
|
||||
@@ -36,6 +38,8 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
*/
|
||||
public FluidSlot bioFuelSlot = new FluidSlot(24000, -1);
|
||||
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityBioGenerator() {
|
||||
super("bio", "BioGenerator", 160000, MekanismConfig.current().generators.bioGeneration.val() * 2);
|
||||
inventory = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
@@ -80,6 +84,13 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
} else if (!world.isRemote) {
|
||||
setActive(false);
|
||||
}
|
||||
if (!world.isRemote) {
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,4 +269,9 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui
|
||||
public FluidTankInfo[] getAllTanks() {
|
||||
return ALL_TANKS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return Container.calcRedstoneFromInventory(this);
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.FuelHandler;
|
||||
import mekanism.common.FuelHandler.FuelGas;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
@@ -26,7 +27,7 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ISustainedData {
|
||||
public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ISustainedData, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getGas", "getGasNeeded"};
|
||||
/**
|
||||
@@ -41,6 +42,7 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
public int maxBurnTicks;
|
||||
public double generationRate = 0;
|
||||
public int clientUsed;
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityGasGenerator() {
|
||||
super("gas", "GasGenerator", MekanismConfig.current().general.FROM_H2.val() * 100, MekanismConfig.current().general.FROM_H2.val() * 2);
|
||||
@@ -101,6 +103,11 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
clientUsed = 0;
|
||||
setActive(false);
|
||||
}
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,4 +316,9 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(fuelTank.getStored(), fuelTank.getMaxGas());
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.IHeatTransfer;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IComparatorSupport;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
@@ -37,7 +38,7 @@ import net.minecraftforge.fluids.FluidUtil;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandlerWrapper, ISustainedData, IHeatTransfer {
|
||||
public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandlerWrapper, ISustainedData, IHeatTransfer, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"};
|
||||
/**
|
||||
@@ -51,6 +52,7 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
||||
public double producingEnergy;
|
||||
public double lastTransferLoss;
|
||||
public double lastEnvironmentLoss;
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityHeatGenerator() {
|
||||
super("heat", "HeatGenerator", 160000, MekanismConfig.current().generators.heatGeneration.val() * 2);
|
||||
@@ -97,6 +99,12 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
||||
lastTransferLoss = loss[0];
|
||||
lastEnvironmentLoss = loss[1];
|
||||
producingEnergy = getEnergy() - prev;
|
||||
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,4 +369,9 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(lavaTank.getFluidAmount(), lavaTank.getCapacity());
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ 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.IEnergyWrapper;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
@@ -36,7 +37,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fml.common.Optional.Method;
|
||||
|
||||
public class TileEntityTurbineValve extends TileEntityTurbineCasing implements IFluidHandlerWrapper, IEnergyWrapper, IComputerIntegration {
|
||||
public class TileEntityTurbineValve extends TileEntityTurbineCasing implements IFluidHandlerWrapper, IEnergyWrapper, IComputerIntegration, IComparatorSupport {
|
||||
|
||||
private static final String[] methods = new String[]{"isFormed", "getSteam", "getFlowRate", "getMaxFlow",
|
||||
"getSteamInput"};
|
||||
@@ -44,6 +45,7 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
public TurbineFluidTank fluidTank;
|
||||
private CapabilityWrapperManager<IEnergyWrapper, TeslaIntegration> teslaManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, TeslaIntegration.class);
|
||||
private CapabilityWrapperManager<IEnergyWrapper, ForgeEnergyIntegration> forgeEnergyManager = new CapabilityWrapperManager<>(IEnergyWrapper.class, ForgeEnergyIntegration.class);
|
||||
private int currentRedstoneLevel;
|
||||
|
||||
public TileEntityTurbineValve() {
|
||||
super("TurbineValve");
|
||||
@@ -60,9 +62,13 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (structure != null) {
|
||||
double prev = getEnergy();
|
||||
CableUtils.emit(this);
|
||||
}
|
||||
int newRedstoneLevel = getRedstoneLevel();
|
||||
if (newRedstoneLevel != currentRedstoneLevel) {
|
||||
world.updateComparatorOutputLevel(pos, getBlockType());
|
||||
currentRedstoneLevel = newRedstoneLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,4 +411,9 @@ public class TileEntityTurbineValve extends TileEntityTurbineCasing implements I
|
||||
}
|
||||
return super.getCapability(capability, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRedstoneLevel() {
|
||||
return MekanismUtils.redstoneLevelFromContents(fluidTank.getFluidAmount(), fluidTank.getCapacity());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user