mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 15:46:01 +00:00
Improve Compat with TOP (#5427)
* Make TOP display full capacity of fluid and gas networks. Also fix some capabilities not returning the proper. TOP Gas integration now displays the gas color as well. * Ensure no repercussions for getting MechanicalPipe's TOP network tanks * Ensure no repercussions for getting PressurizedTube's TOP network tanks * Display hydrogen with a slightly incorrect color so TOP renders properly * Fix dynamic valve having item handler always disabled instead of just when multiblock is not made * Fix a few itemhandlers that should not be disabled for side == null TOP compat * Always expose networks buffer instead of local buffer if there is a network
This commit is contained in:
1 parent
9692debdcf
commit
075673fc56
17 files changed
+78
-23
No files matched your search
@@ -8,6 +8,7 @@ import mcjty.theoneprobe.api.IProgressStyle;
|
||||
import mcjty.theoneprobe.api.ITheOneProbe;
|
||||
import mcjty.theoneprobe.api.ProbeMode;
|
||||
import mcjty.theoneprobe.api.TextStyleClass;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasTankInfo;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
@@ -48,15 +49,26 @@ public class TOPProvider implements Function<ITheOneProbe, Void>, IProbeInfoProv
|
||||
GasTankInfo[] tanks = handler.getTankInfo();
|
||||
|
||||
for (GasTankInfo tank : tanks) {
|
||||
if (tank.getGas() != null) {
|
||||
probeInfo.text(TextStyleClass.NAME + "Gas: " + tank.getGas().getGas().getLocalizedName());
|
||||
}
|
||||
|
||||
IProgressStyle style = probeInfo.defaultProgressStyle().suffix("mB");
|
||||
if (tank.getGas() != null) {
|
||||
Gas gas = tank.getGas().getGas();
|
||||
probeInfo.text(TextStyleClass.NAME + "Gas: " + gas.getLocalizedName());
|
||||
int tint = gas.getTint();
|
||||
//TOP respects transparency so we need to filter out the transparent layer
|
||||
// if the gas has one. (Currently they are all fully transparent)
|
||||
if ((tint & 0xFF000000) == 0) {
|
||||
tint = 0xFF000000 | tint;
|
||||
}
|
||||
if (tint != 0xFFFFFFFF) {
|
||||
//TOP bugs out with full white background so just use default instead
|
||||
// The default is a slightly off white color so is better for readability
|
||||
style = style.filledColor(tint).alternateFilledColor(tint);
|
||||
}
|
||||
}
|
||||
probeInfo.progress(tank.getStored(), tank.getMaxGas(), style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,7 +287,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
return side != MekanismUtils.getLeft(facing) && side != MekanismUtils.getRight(facing);
|
||||
return side != null && side != MekanismUtils.getLeft(facing) && side != MekanismUtils.getRight(facing);
|
||||
} else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return side == facing || side == facing.getOpposite();
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ public class TileEntityChemicalInfuser extends TileEntityMachine implements IGas
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
return side != MekanismUtils.getLeft(facing) && side != MekanismUtils.getRight(facing) && side != facing;
|
||||
return side == EnumFacing.UP || side == EnumFacing.DOWN || side == facing.getOpposite();
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class TileEntityChemicalOxidizer extends TileEntityOperationalMachine imp
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
return side != MekanismUtils.getRight(facing);
|
||||
return side != null && side != MekanismUtils.getRight(facing);
|
||||
} else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return side == facing || side == facing.getOpposite();
|
||||
}
|
||||
|
||||
@@ -301,7 +301,7 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
return getTank(side) == null;
|
||||
return side != null && getTank(side) == null;
|
||||
} else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return side == facing || side == facing.getOpposite();
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFl
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return true;
|
||||
return !world.isRemote ? structure == null : !clientHasStructure;
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -501,9 +501,9 @@ public class TileEntityElectrolyticSeparator extends TileEntityMachine implement
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
return side != MekanismUtils.getLeft(facing) && side != MekanismUtils.getRight(facing);
|
||||
return side != null && side != MekanismUtils.getLeft(facing) && side != MekanismUtils.getRight(facing);
|
||||
} else if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return side != facing && side != facing.getOpposite() && side != MekanismUtils.getRight(facing);
|
||||
return side != null && side != facing && side != facing.getOpposite() && side != MekanismUtils.getRight(facing);
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -1037,6 +1037,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
if (configComponent.isCapabilityDisabled(capability, side, facing)) {
|
||||
return true;
|
||||
} else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
//If the gas capability is not disabled, check if this machine even actually supports gas
|
||||
return !recipeType.supportsGas();
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
|
||||
@@ -447,7 +447,7 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return side != EnumFacing.DOWN && side != EnumFacing.UP;
|
||||
return side != null && side != EnumFacing.DOWN && side != EnumFacing.UP;
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ public class TileEntityInductionPort extends TileEntityInductionCasing implement
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return false;
|
||||
return !world.isRemote ? structure == null : !clientHasStructure;
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
|
||||
return side != facing && side != facing.getOpposite();
|
||||
return side != null && side != facing && side != facing.getOpposite();
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -645,8 +645,8 @@ public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock imp
|
||||
return true;
|
||||
} else if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
//TODO: Figure out if checking ioState even needed
|
||||
return !hasFrequency()
|
||||
|| configComponent.getOutput(TransmissionType.GAS, side, facing).ioState == IOState.OFF;
|
||||
return side != null && (!hasFrequency()
|
||||
|| configComponent.getOutput(TransmissionType.GAS, side, facing).ioState == IOState.OFF);
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ public class TileEntityRotaryCondensentrator extends TileEntityMachine implement
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
return side != MekanismUtils.getLeft(facing);
|
||||
return side != null && side != MekanismUtils.getLeft(facing);
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock im
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
return side != facing && side != EnumFacing.DOWN;
|
||||
return side != null && side != facing && side != EnumFacing.DOWN;
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
||||
@Override
|
||||
public boolean isCapabilityDisabled(@Nonnull Capability<?> capability, EnumFacing side) {
|
||||
if (isStrictEnergy(capability) || capability == CapabilityEnergy.ENERGY || isTesla(capability, side)) {
|
||||
return !sideIsConsumer(side) && !sideIsOutput(side);
|
||||
return side != null && !sideIsConsumer(side) && !sideIsOutput(side);
|
||||
}
|
||||
return super.isCapabilityDisabled(capability, side);
|
||||
}
|
||||
|
||||
@@ -247,7 +247,8 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
||||
if (from != null && getConnectionType(from) != ConnectionType.NONE) {
|
||||
return new FluidTankInfo[]{buffer.getInfo()};
|
||||
//Our buffer or the network's buffer if we have a network
|
||||
return getAllTanks();
|
||||
}
|
||||
|
||||
return PipeUtils.EMPTY;
|
||||
@@ -255,6 +256,10 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getAllTanks() {
|
||||
if (getTransmitter().hasTransmitterNetwork()) {
|
||||
FluidNetwork network = getTransmitter().getTransmitterNetwork();
|
||||
return new FluidTankInfo[]{new FluidTankInfo(network.getBuffer(), network.getCapacity())};
|
||||
}
|
||||
return new FluidTankInfo[]{buffer.getInfo()};
|
||||
}
|
||||
|
||||
@@ -277,9 +282,8 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
|
||||
public int takeFluid(FluidStack fluid, boolean doEmit) {
|
||||
if (getTransmitter().hasTransmitterNetwork()) {
|
||||
return getTransmitter().getTransmitterNetwork().emit(fluid, doEmit);
|
||||
} else {
|
||||
return buffer.fill(fluid, doEmit);
|
||||
}
|
||||
return buffer.fill(fluid, doEmit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,35 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
|
||||
|
||||
public GasStack lastWrite;
|
||||
|
||||
//Read only handler for support with TOP and getting network data instead of this tube's data
|
||||
private IGasHandler nullHandler = new IGasHandler() {
|
||||
@Override
|
||||
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack drawGas(EnumFacing side, int amount, boolean doTransfer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(EnumFacing side, Gas type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrawGas(EnumFacing side, Gas type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public GasTankInfo[] getTankInfo() {
|
||||
return TileEntityPressurizedTube.this.getTankInfo();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public BaseTier getBaseTier() {
|
||||
return tier.getBaseTier();
|
||||
@@ -258,6 +287,12 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
|
||||
@Nonnull
|
||||
@Override
|
||||
public GasTankInfo[] getTankInfo() {
|
||||
if (getTransmitter().hasTransmitterNetwork()) {
|
||||
GasNetwork network = getTransmitter().getTransmitterNetwork();
|
||||
GasTank networkTank = new GasTank(network.getCapacity());
|
||||
networkTank.setGas(network.getBuffer());
|
||||
return new GasTankInfo[]{networkTank};
|
||||
}
|
||||
return new GasTankInfo[]{buffer};
|
||||
}
|
||||
|
||||
@@ -310,6 +345,9 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, EnumFacing side) {
|
||||
if (capability == Capabilities.GAS_HANDLER_CAPABILITY) {
|
||||
if (side == null) {
|
||||
return Capabilities.GAS_HANDLER_CAPABILITY.cast(nullHandler);
|
||||
}
|
||||
return Capabilities.GAS_HANDLER_CAPABILITY.cast(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user