Files
Mekanism-Community-Edition/src/main/java/mekanism/api/transmitters/IGridTransmitter.java
T
Richard Freimer 0d4b50908f Formatting and code readability cleanup (#5467)
* First pass reformatting code to be more readable (common still not done)

* Replace google common collect calls with Java calls where possible

* Remove a bunch of unnecessary parenthesis leaving clarifying ones

* Add some missing @Nonnull annotations

* Fix checking wrong type

* Remove unnecessary continue/return statements and simplify comparision check

* Pass exception instead of directly printing stack trace

* Work on cleaning up common, through config so far

* Work on cleaning up common, through integration so far

* Work on cleaning up common, through network so far

* Work on cleaning up common, through tier so far

* Remove empty constructors that get created by default anyways

* Work on cleaning up common, through transmitters so far

* Work on cleaning up common, through utils so far

* Finish cleaning up spacing for common
2019-05-11 14:13:24 -04:00

101 lines
2.6 KiB
Java

package mekanism.api.transmitters;
import java.util.Collection;
import javax.annotation.Nullable;
import mekanism.api.Coord4D;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
public interface IGridTransmitter<ACCEPTOR, NETWORK extends DynamicNetwork<ACCEPTOR, NETWORK, BUFFER>, BUFFER> extends ITransmitter {
boolean hasTransmitterNetwork();
/**
* Gets the network currently in use by this transmitter segment.
*
* @return network this transmitter is using
*/
NETWORK getTransmitterNetwork();
/**
* Sets this transmitter segment's network to a new value.
*
* @param network - network to set to
*/
void setTransmitterNetwork(NETWORK network);
void setRequestsUpdate();
int getTransmitterNetworkSize();
int getTransmitterNetworkAcceptorSize();
String getTransmitterNetworkNeeded();
String getTransmitterNetworkFlow();
String getTransmitterNetworkBuffer();
double getTransmitterNetworkCapacity();
int getCapacity();
World world();
Coord4D coord();
Coord4D getAdjacentConnectableTransmitterCoord(EnumFacing side);
ACCEPTOR getAcceptor(EnumFacing side);
boolean isValid();
boolean isOrphan();
void setOrphan(boolean orphaned);
NETWORK createEmptyNetwork();
NETWORK mergeNetworks(Collection<NETWORK> toMerge);
NETWORK getExternalNetwork(Coord4D from);
void takeShare();
void updateShare();
/**
* @return The transmitter's buffer.
*/
@Nullable
BUFFER getBuffer();
/**
* If the transmitter does not have a buffer this will try to fallback on the network's buffer.
*
* @return The transmitter's buffer, or if null the network's buffer.
*/
@Nullable
default BUFFER getBufferWithFallback() {
BUFFER buffer = getBuffer();
//If we don't have a buffer try falling back to the network's buffer
if (buffer == null && hasTransmitterNetwork()) {
return getTransmitterNetwork().getBuffer();
}
return buffer;
}
default boolean isCompatibleWith(IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> other) {
return true;
}
/**
* Gets called on an orphan if at least one attempted network fails to connect due to having connected to another network that is incompatible with the next attempted
* ones.
*
* This is primarily used for if extra handling needs to be done, such as refreshing the connections visually on a minor delay so that it has time to have the buffer
* no longer be null and properly compare the connection.
*/
default void connectionFailed() {
}
}