Respect NONE connection mode for Pipe Connections (#5387)

* prevent Out of Bounds exception in factory ItemMeshDefinition

* prevent Out of Bounds error in item stack display name

* Respect NONE connection between pipes. Fixes #4781

* prevent fluid/gas pipes from connecting if their contents arent the same (part 1)

* prevent some case of incorrect network merges that would convert/void a fluid/gas

* Add a way to check if a network is compatible with an buffer
Used for checking the orphan's buffer against the external network

* rename some generic type variables for readability

* introduce BUFFER generic type variable

* Fix missing null check causing new pipes not being able to be added to a network

* More checks for when there is an invalid factory

* bump api version & use a constant for all

* add default method to not break binary compat

* Refresh if a connection exists if a transmitter failed to combine two networks
Fallback to the network's buffer as if we have not saved any data yet the TE's buffer may still be null

* Add a way to get the pipes buffer falling back to the network, rather than doing it from the same method. This ensures that there is no accidental leakage where the count of the buffer matters

* Return a null buffer for pressurized tube buffer if the stack is empty

* Allow merging of networks when they are able to connect again
Visuals still need a minor update to sync the type it should be rendering

* Update network visuals when networks merge

* allow unconnected sides to have their mode set - except logistical transporters which already used that function, they only can un-NONE their unconnected sides
This commit is contained in:
Xander authored and GitHub committed 2019-04-20 13:38:14 +08:00
1 parent e187bc1bb8
commit bbcea85fc4
34 files changed
+635 -248

No files matched your search

@@ -1,11 +1,12 @@
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<A, N extends DynamicNetwork<A, N>> extends ITransmitter {
public interface IGridTransmitter<ACCEPTOR, NETWORK extends DynamicNetwork<ACCEPTOR, NETWORK, BUFFER>, BUFFER> extends ITransmitter {
boolean hasTransmitterNetwork();
@@ -14,14 +15,14 @@ public interface IGridTransmitter<A, N extends DynamicNetwork<A, N>> extends ITr
*
* @return network this transmitter is using
*/
N getTransmitterNetwork();
NETWORK getTransmitterNetwork();
/**
* Sets this transmitter segment's network to a new value.
*
* @param network - network to set to
*/
void setTransmitterNetwork(N network);
void setTransmitterNetwork(NETWORK network);
void setRequestsUpdate();
@@ -45,7 +46,7 @@ public interface IGridTransmitter<A, N extends DynamicNetwork<A, N>> extends ITr
Coord4D getAdjacentConnectableTransmitterCoord(EnumFacing side);
A getAcceptor(EnumFacing side);
ACCEPTOR getAcceptor(EnumFacing side);
boolean isValid();
@@ -53,15 +54,50 @@ public interface IGridTransmitter<A, N extends DynamicNetwork<A, N>> extends ITr
void setOrphan(boolean orphaned);
N createEmptyNetwork();
NETWORK createEmptyNetwork();
N mergeNetworks(Collection<N> toMerge);
NETWORK mergeNetworks(Collection<NETWORK> toMerge);
N getExternalNetwork(Coord4D from);
NETWORK getExternalNetwork(Coord4D from);
void takeShare();
void updateShare();
Object getBuffer();
/**
* @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() {
}
}