mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-25 06:14:41 +00:00
Update to 9.7.2
This commit is contained in:
62 files changed
+1035
-418
No files matched your search
+2
-2
@@ -3,7 +3,7 @@ mappings_version=stable_39
|
||||
forge_version=14.23.5.2825
|
||||
mcmp_version=2.5.3
|
||||
jei_version=4.15.0.269
|
||||
mod_version=9.7.1
|
||||
mod_version=9.7.2
|
||||
tesla_version=1.0.63
|
||||
invtweak_version=1.64+dev.146
|
||||
opencomputers_version=1.7.4.153
|
||||
@@ -15,4 +15,4 @@ ic2_version=2.8.111-ex112
|
||||
crafttweaker_version=4.1.15.527
|
||||
computercraft_version=1.80pr1
|
||||
top_version=1.12-1.4.23-16
|
||||
ae2_version=rv6-stable-6
|
||||
ae2_version=rv6-stable-6
|
||||
@@ -15,6 +15,11 @@ import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public class MekanismAPI {
|
||||
|
||||
/**
|
||||
* The version of the api classes - may not always match the mod's version
|
||||
*/
|
||||
public static final String API_VERSION = "9.7.2";
|
||||
|
||||
/**
|
||||
* Mekanism debug mode
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@API(apiVersion = "9.0.0", owner = "mekanism", provides = "MekanismAPI|energy")
|
||||
@API(apiVersion = MekanismAPI.API_VERSION, owner = "mekanism", provides = "MekanismAPI|energy")
|
||||
package mekanism.api.energy;
|
||||
|
||||
import mekanism.api.MekanismAPI;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@API(apiVersion = "9.1.0", owner = "mekanism", provides = "MekanismAPI|gas")
|
||||
@API(apiVersion = MekanismAPI.API_VERSION, owner = "mekanism", provides = "MekanismAPI|gas")
|
||||
package mekanism.api.gas;
|
||||
|
||||
import mekanism.api.MekanismAPI;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@API(apiVersion = "9.0.0", owner = "mekanism", provides = "MekanismAPI|infuse")
|
||||
@API(apiVersion = MekanismAPI.API_VERSION, owner = "mekanism", provides = "MekanismAPI|infuse")
|
||||
package mekanism.api.infuse;
|
||||
|
||||
import mekanism.api.MekanismAPI;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@API(apiVersion = "9.0.0", owner = "mekanism", provides = "MekanismAPI|laser")
|
||||
@API(apiVersion = MekanismAPI.API_VERSION, owner = "mekanism", provides = "MekanismAPI|laser")
|
||||
package mekanism.api.lasers;
|
||||
|
||||
import mekanism.api.MekanismAPI;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@API(apiVersion = "9.0.0", owner = "mekanism", provides = "MekanismAPI|core")
|
||||
@API(apiVersion = MekanismAPI.API_VERSION, owner = "mekanism", provides = "MekanismAPI|core")
|
||||
package mekanism.api;
|
||||
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IClientTicker;
|
||||
import mekanism.api.Range4D;
|
||||
@@ -22,15 +23,17 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implements IClientTicker, INetworkDataHandler {
|
||||
public abstract class DynamicNetwork<ACCEPTOR, NETWORK extends DynamicNetwork<ACCEPTOR, NETWORK, BUFFER>, BUFFER> implements
|
||||
IClientTicker, INetworkDataHandler {
|
||||
|
||||
public LinkedHashSet<IGridTransmitter<A, N>> transmitters = Sets.newLinkedHashSet();
|
||||
public LinkedHashSet<IGridTransmitter<A, N>> transmittersToAdd = Sets.newLinkedHashSet();
|
||||
public LinkedHashSet<IGridTransmitter<A, N>> transmittersAdded = Sets.newLinkedHashSet();
|
||||
public LinkedHashSet<IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>> transmitters = Sets.newLinkedHashSet();
|
||||
public LinkedHashSet<IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>> transmittersToAdd = Sets.newLinkedHashSet();
|
||||
public LinkedHashSet<IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>> transmittersAdded = Sets.newLinkedHashSet();
|
||||
|
||||
public HashMap<Coord4D, A> possibleAcceptors = new HashMap<>();
|
||||
public HashMap<Coord4D, ACCEPTOR> possibleAcceptors = new HashMap<>();
|
||||
public HashMap<Coord4D, EnumSet<EnumFacing>> acceptorDirections = new HashMap<>();
|
||||
public HashMap<IGridTransmitter<A, N>, EnumSet<EnumFacing>> changedAcceptors = Maps.newHashMap();
|
||||
public HashMap<IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>, EnumSet<EnumFacing>> changedAcceptors = Maps
|
||||
.newHashMap();
|
||||
protected Range4D packetRange = null;
|
||||
protected int capacity = 0;
|
||||
protected double meanCapacity = 0;
|
||||
@@ -40,13 +43,13 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
protected World world = null;
|
||||
private Set<DelayQueue> updateQueue = new LinkedHashSet<>();
|
||||
|
||||
public void addNewTransmitters(Collection<IGridTransmitter<A, N>> newTransmitters) {
|
||||
public void addNewTransmitters(Collection<IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>> newTransmitters) {
|
||||
transmittersToAdd.addAll(newTransmitters);
|
||||
}
|
||||
|
||||
public void commit() {
|
||||
if (!transmittersToAdd.isEmpty()) {
|
||||
for (IGridTransmitter<A, N> transmitter : transmittersToAdd) {
|
||||
for (IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter : transmittersToAdd) {
|
||||
if (transmitter.isValid()) {
|
||||
if (world == null) {
|
||||
world = transmitter.world();
|
||||
@@ -56,7 +59,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
updateTransmitterOnSide(transmitter, side);
|
||||
}
|
||||
|
||||
transmitter.setTransmitterNetwork((N) this);
|
||||
transmitter.setTransmitterNetwork((NETWORK) this);
|
||||
absorbBuffer(transmitter);
|
||||
transmitters.add(transmitter);
|
||||
}
|
||||
@@ -69,8 +72,9 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
}
|
||||
|
||||
if (!changedAcceptors.isEmpty()) {
|
||||
for (Entry<IGridTransmitter<A, N>, EnumSet<EnumFacing>> entry : changedAcceptors.entrySet()) {
|
||||
IGridTransmitter<A, N> transmitter = entry.getKey();
|
||||
for (Entry<IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>, EnumSet<EnumFacing>> entry : changedAcceptors
|
||||
.entrySet()) {
|
||||
IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter = entry.getKey();
|
||||
|
||||
if (transmitter.isValid()) {
|
||||
EnumSet<EnumFacing> directionsChanged = entry.getValue();
|
||||
@@ -85,8 +89,8 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTransmitterOnSide(IGridTransmitter<A, N> transmitter, EnumFacing side) {
|
||||
A acceptor = transmitter.getAcceptor(side);
|
||||
public void updateTransmitterOnSide(IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter, EnumFacing side) {
|
||||
ACCEPTOR acceptor = transmitter.getAcceptor(side);
|
||||
Coord4D acceptorCoord = transmitter.coord().offset(side);
|
||||
EnumSet<EnumFacing> directions = acceptorDirections.get(acceptorCoord);
|
||||
|
||||
@@ -114,7 +118,12 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
|
||||
}
|
||||
|
||||
public abstract void absorbBuffer(IGridTransmitter<A, N> transmitter);
|
||||
@Nullable
|
||||
public BUFFER getBuffer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract void absorbBuffer(IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter);
|
||||
|
||||
public abstract void clampBuffer();
|
||||
|
||||
@@ -126,12 +135,12 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
clampBuffer();
|
||||
|
||||
//Update all shares
|
||||
for (IGridTransmitter<A, N> transmitter : transmitters) {
|
||||
for (IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter : transmitters) {
|
||||
transmitter.updateShare();
|
||||
}
|
||||
|
||||
//Now invalidate the transmitters
|
||||
for (IGridTransmitter<A, N> transmitter : transmitters) {
|
||||
for (IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter : transmitters) {
|
||||
invalidateTransmitter(transmitter);
|
||||
}
|
||||
|
||||
@@ -139,7 +148,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
deregister();
|
||||
}
|
||||
|
||||
public void invalidateTransmitter(IGridTransmitter<A, N> transmitter) {
|
||||
public void invalidateTransmitter(IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter) {
|
||||
if (!world.isRemote && transmitter.isValid()) {
|
||||
transmitter.takeShare();
|
||||
transmitter.setTransmitterNetwork(null);
|
||||
@@ -147,7 +156,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
}
|
||||
}
|
||||
|
||||
public void acceptorChanged(IGridTransmitter<A, N> transmitter, EnumFacing side) {
|
||||
public void acceptorChanged(IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter, EnumFacing side) {
|
||||
EnumSet<EnumFacing> directions = changedAcceptors.get(transmitter);
|
||||
|
||||
if (directions != null) {
|
||||
@@ -159,9 +168,9 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
TransmitterNetworkRegistry.registerChangedNetwork(this);
|
||||
}
|
||||
|
||||
public void adoptTransmittersAndAcceptorsFrom(N net) {
|
||||
for (IGridTransmitter<A, N> transmitter : net.transmitters) {
|
||||
transmitter.setTransmitterNetwork((N) this);
|
||||
public void adoptTransmittersAndAcceptorsFrom(NETWORK net) {
|
||||
for (IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> transmitter : net.transmitters) {
|
||||
transmitter.setTransmitterNetwork((NETWORK) this);
|
||||
transmitters.add(transmitter);
|
||||
transmittersAdded.add(transmitter);
|
||||
}
|
||||
@@ -196,7 +205,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
return null;
|
||||
}
|
||||
|
||||
IGridTransmitter<A, N> initTransmitter = transmitters.iterator().next();
|
||||
IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> initTransmitter = transmitters.iterator().next();
|
||||
Coord4D initCoord = initTransmitter.coord();
|
||||
|
||||
int minX = initCoord.x;
|
||||
@@ -285,7 +294,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
return world;
|
||||
}
|
||||
|
||||
public abstract Set<Pair<Coord4D, A>> getAcceptors(Object data);
|
||||
public abstract Set<Pair<Coord4D, ACCEPTOR>> getAcceptors(Object data);
|
||||
|
||||
public void tick() {
|
||||
onUpdate();
|
||||
@@ -333,7 +342,7 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
public void clientTick() {
|
||||
}
|
||||
|
||||
public void queueClientUpdate(Collection<IGridTransmitter<A, N>> newTransmitters) {
|
||||
public void queueClientUpdate(Collection<IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>> newTransmitters) {
|
||||
transmittersAdded.addAll(newTransmitters);
|
||||
updateDelay = 5;
|
||||
}
|
||||
@@ -342,9 +351,17 @@ public abstract class DynamicNetwork<A, N extends DynamicNetwork<A, N>> implemen
|
||||
updateQueue.add(new DelayQueue(player));
|
||||
}
|
||||
|
||||
public boolean isCompatibleWith(NETWORK other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean compatibleWithBuffer(BUFFER buffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class TransmittersAddedEvent extends Event {
|
||||
|
||||
public DynamicNetwork<?, ?> network;
|
||||
public DynamicNetwork<?, ?, ?> network;
|
||||
public boolean newNetwork;
|
||||
public Collection<IGridTransmitter> newTransmitters;
|
||||
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
}
|
||||
@@ -130,10 +130,10 @@ public class TransmitterNetworkRegistry {
|
||||
orphanTransmitters.clear();
|
||||
}
|
||||
|
||||
public <A, N extends DynamicNetwork<A, N>> DynamicNetwork<A, N> getNetworkFromOrphan(
|
||||
IGridTransmitter<A, N> startOrphan) {
|
||||
public <A, N extends DynamicNetwork<A, N, BUFFER>, BUFFER> DynamicNetwork<A, N, BUFFER> getNetworkFromOrphan(
|
||||
IGridTransmitter<A, N, BUFFER> startOrphan) {
|
||||
if (startOrphan.isValid() && startOrphan.isOrphan()) {
|
||||
OrphanPathFinder<A, N> finder = new OrphanPathFinder<>(startOrphan);
|
||||
OrphanPathFinder<A, N, BUFFER> finder = new OrphanPathFinder<>(startOrphan);
|
||||
finder.start();
|
||||
N network;
|
||||
|
||||
@@ -167,6 +167,13 @@ public class TransmitterNetworkRegistry {
|
||||
|
||||
network.addNewTransmitters(finder.connectedTransmitters);
|
||||
|
||||
if (finder.someNetworksFailed) {
|
||||
//At least one network that connection was attempted with is not compatible
|
||||
// So inform this transmitter that there was a failed connection attempt
|
||||
// so that it can refresh the connections
|
||||
startOrphan.connectionFailed();
|
||||
}
|
||||
|
||||
return network;
|
||||
}
|
||||
|
||||
@@ -197,18 +204,20 @@ public class TransmitterNetworkRegistry {
|
||||
return strings;
|
||||
}
|
||||
|
||||
public class OrphanPathFinder<A, N extends DynamicNetwork<A, N>> {
|
||||
public class OrphanPathFinder<A, N extends DynamicNetwork<A, N, BUFFER>, BUFFER> {
|
||||
|
||||
public IGridTransmitter<A, N> startPoint;
|
||||
public IGridTransmitter<A, N, BUFFER> startPoint;
|
||||
|
||||
public HashSet<Coord4D> iterated = Sets.newHashSet();
|
||||
|
||||
public HashSet<IGridTransmitter<A, N>> connectedTransmitters = Sets.newHashSet();
|
||||
public HashSet<IGridTransmitter<A, N, BUFFER>> connectedTransmitters = Sets.newHashSet();
|
||||
public HashSet<N> networksFound = Sets.newHashSet();
|
||||
|
||||
private Deque<Coord4D> queue = new LinkedList<>();
|
||||
|
||||
public OrphanPathFinder(IGridTransmitter<A, N> start) {
|
||||
public boolean someNetworksFailed;
|
||||
|
||||
public OrphanPathFinder(IGridTransmitter<A, N, BUFFER> start) {
|
||||
startPoint = start;
|
||||
}
|
||||
|
||||
@@ -231,9 +240,10 @@ public class TransmitterNetworkRegistry {
|
||||
iterated.add(from);
|
||||
|
||||
if (orphanTransmitters.containsKey(from)) {
|
||||
IGridTransmitter<A, N> transmitter = orphanTransmitters.get(from);
|
||||
IGridTransmitter<A, N, BUFFER> transmitter = orphanTransmitters.get(from);
|
||||
|
||||
if (transmitter.isValid() && transmitter.isOrphan()) {
|
||||
if (transmitter.isValid() && transmitter.isOrphan() && (connectedTransmitters.isEmpty()
|
||||
|| connectedTransmitters.stream().anyMatch(existing -> existing.isCompatibleWith(transmitter)))) {
|
||||
connectedTransmitters.add(transmitter);
|
||||
transmitter.setOrphan(false);
|
||||
|
||||
@@ -256,8 +266,15 @@ public class TransmitterNetworkRegistry {
|
||||
|
||||
public void addNetworkToIterated(Coord4D from) {
|
||||
N net = startPoint.getExternalNetwork(from);
|
||||
if (net != null) {
|
||||
networksFound.add(net);
|
||||
//Make sure that there is an external network and that it is compatible with this buffer
|
||||
if (net != null && net.compatibleWithBuffer(startPoint.getBuffer())) {
|
||||
if (networksFound.isEmpty() || networksFound.iterator().next().isCompatibleWith(net)) {
|
||||
networksFound.add(net);
|
||||
} else {
|
||||
//If it a network was found but it is incompatible, then mark we have a failed
|
||||
// network so we can inform the transmitter it should do a tick delayed refresh
|
||||
someNetworksFailed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@API(apiVersion = "9.0.0", owner = "mekanism", provides = "MekanismAPI|transmitter")
|
||||
@API(apiVersion = MekanismAPI.API_VERSION, owner = "mekanism", provides = "MekanismAPI|transmitter")
|
||||
package mekanism.api.transmitters;
|
||||
|
||||
import mekanism.api.MekanismAPI;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
@@ -111,8 +111,6 @@ import mekanism.common.CommonProxy;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismItems;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.GasTankTier;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.ISideConfiguration;
|
||||
import mekanism.common.base.IUpgradeTile;
|
||||
@@ -144,6 +142,8 @@ import mekanism.common.item.ItemPortableTeleporter;
|
||||
import mekanism.common.item.ItemSeismicReader;
|
||||
import mekanism.common.item.ItemWalkieTalkie;
|
||||
import mekanism.common.network.PacketPortableTeleporter.PortableTeleporterMessage;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.GasTankTier;
|
||||
import mekanism.common.tile.TileEntityAdvancedFactory;
|
||||
import mekanism.common.tile.TileEntityAmbientAccumulator;
|
||||
import mekanism.common.tile.TileEntityBin;
|
||||
@@ -175,7 +175,6 @@ import mekanism.common.tile.TileEntityGasTank;
|
||||
import mekanism.common.tile.TileEntityInductionCasing;
|
||||
import mekanism.common.tile.TileEntityLaserAmplifier;
|
||||
import mekanism.common.tile.TileEntityLaserTractorBeam;
|
||||
import mekanism.common.tile.TileEntityLogisticalSorter;
|
||||
import mekanism.common.tile.TileEntityMetallurgicInfuser;
|
||||
import mekanism.common.tile.TileEntityOredictionificator;
|
||||
import mekanism.common.tile.TileEntityOsmiumCompressor;
|
||||
@@ -670,8 +669,10 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY
|
||||
|| type == MachineType.ELITE_FACTORY) {
|
||||
RecipeType recipe = RecipeType.values()[((ItemBlockMachine) stack.getItem()).getRecipeType(stack)];
|
||||
resource = "mekanism:" + type.getName() + "_" + recipe.getName();
|
||||
RecipeType recipe = ((ItemBlockMachine) stack.getItem()).getRecipeTypeOrNull(stack);
|
||||
if (recipe != null) {
|
||||
resource = "mekanism:" + type.getName() + "_" + recipe.getName();
|
||||
}
|
||||
}
|
||||
|
||||
return machineResources.get(resource);
|
||||
|
||||
@@ -76,8 +76,8 @@ public class GuiFactory extends GuiMekanismTile<TileEntityFactory> {
|
||||
+ ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis);
|
||||
} else if (tileEntity.getRecipeType() == RecipeType.INFUSING) {
|
||||
drawHoveringText(
|
||||
tileEntity.infuseStored.type != null ? tileEntity.infuseStored.type.getLocalizedName() + ": "
|
||||
+ tileEntity.infuseStored.amount : LangUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
tileEntity.infuseStored.getType() != null ? tileEntity.infuseStored.getType().getLocalizedName() + ": "
|
||||
+ tileEntity.infuseStored.getAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
}
|
||||
}
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
@@ -116,7 +116,7 @@ public class GuiFactory extends GuiMekanismTile<TileEntityFactory> {
|
||||
}
|
||||
} else if (tileEntity.getRecipeType() == RecipeType.INFUSING) {
|
||||
if (tileEntity.getScaledInfuseLevel(160) > 0) {
|
||||
displayGauge(8, 78, tileEntity.getScaledInfuseLevel(160), 5, tileEntity.infuseStored.type.sprite);
|
||||
displayGauge(8, 78, tileEntity.getScaledInfuseLevel(160), 5, tileEntity.infuseStored.getType().sprite);
|
||||
}
|
||||
}
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
|
||||
@@ -71,8 +71,8 @@ public class GuiMetallurgicInfuser extends GuiMekanismTile<TileEntityMetallurgic
|
||||
int yAxis = (mouseY - (height - ySize) / 2);
|
||||
if (xAxis >= 7 && xAxis <= 11 && yAxis >= 17 && yAxis <= 69) {
|
||||
drawHoveringText(
|
||||
tileEntity.infuseStored.type != null ? tileEntity.infuseStored.type.getLocalizedName() + ": "
|
||||
+ tileEntity.infuseStored.amount : LangUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
tileEntity.infuseStored.getType() != null ? tileEntity.infuseStored.getType().getLocalizedName() + ": "
|
||||
+ tileEntity.infuseStored.getAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis);
|
||||
}
|
||||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
@@ -84,11 +84,11 @@ public class GuiMetallurgicInfuser extends GuiMekanismTile<TileEntityMetallurgic
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
||||
if (tileEntity.infuseStored.type != null) {
|
||||
if (tileEntity.infuseStored.getType() != null) {
|
||||
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
int displayInt = tileEntity.getScaledInfuseLevel(52);
|
||||
drawTexturedRectFromIcon(guiWidth + 7, guiHeight + 17 + 52 - displayInt,
|
||||
tileEntity.infuseStored.type.sprite, 4, displayInt);
|
||||
tileEntity.infuseStored.getType().sprite, 4, displayInt);
|
||||
}
|
||||
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,10 @@ public class MekanismJEI implements IModPlugin {
|
||||
}
|
||||
|
||||
if (itemStack.getItem() instanceof IFactory) {
|
||||
ret += ":" + RecipeType.values()[((IFactory) itemStack.getItem()).getRecipeType(itemStack)].getName();
|
||||
RecipeType recipeType = ((IFactory) itemStack.getItem()).getRecipeTypeOrNull(itemStack);
|
||||
if (recipeType != null) {
|
||||
ret += ":" + recipeType.getName();
|
||||
}
|
||||
}
|
||||
|
||||
if (itemStack.getItem() instanceof ItemBlockGasTank) {
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class MetallurgicInfuserRecipeCategory extends BaseRecipeCategory {
|
||||
itemStacks.init(2, true, 11, 18);
|
||||
itemStacks.set(0, tempRecipe.getInput().inputStack);
|
||||
itemStacks.set(1, tempRecipe.getOutput().output);
|
||||
itemStacks.set(2, getInfuseStacks(tempRecipe.getInput().infuse.type));
|
||||
itemStacks.set(2, getInfuseStacks(tempRecipe.getInput().infuse.getType()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -23,7 +23,7 @@ public class MetallurgicInfuserRecipeWrapper implements IRecipeWrapper {
|
||||
@Override
|
||||
public void getIngredients(IIngredients ingredients) {
|
||||
List<ItemStack> inputStacks = Collections.singletonList(recipe.recipeInput.inputStack);
|
||||
List<ItemStack> infuseStacks = MetallurgicInfuserRecipeCategory.getInfuseStacks(recipe.getInput().infuse.type);
|
||||
List<ItemStack> infuseStacks = MetallurgicInfuserRecipeCategory.getInfuseStacks(recipe.getInput().infuse.getType());
|
||||
ingredients.setInput(VanillaTypes.ITEM, recipe.recipeInput.inputStack);
|
||||
ingredients.setInputLists(VanillaTypes.ITEM, Arrays.asList(inputStacks, infuseStacks));
|
||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.recipeOutput.output);
|
||||
@@ -37,7 +37,7 @@ public class MetallurgicInfuserRecipeWrapper implements IRecipeWrapper {
|
||||
public void drawInfo(Minecraft mc, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
|
||||
if (mc.currentScreen != null) {
|
||||
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
mc.currentScreen.drawTexturedModalRect(2, 2, recipe.getInput().infuse.type.sprite, 4, 52);
|
||||
mc.currentScreen.drawTexturedModalRect(2, 2, recipe.getInput().infuse.getType().sprite, 4, 52);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class MetallurgicInfuserRecipeWrapper implements IRecipeWrapper {
|
||||
public List<String> getTooltipStrings(int mouseX, int mouseY) {
|
||||
if (mouseX >= 2 && mouseX < 6 && mouseY >= 2 && mouseY < 54) {
|
||||
InfuseStorage infuse = recipe.getInput().infuse;
|
||||
return Collections.singletonList(infuse.type.getLocalizedName() + ": " + infuse.amount);
|
||||
return Collections.singletonList(infuse.getType().getLocalizedName() + ": " + infuse.getAmount());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -117,8 +117,7 @@ public class MekanismRenderer {
|
||||
spriteLocation = fluid.getFlowing();
|
||||
}
|
||||
|
||||
TextureAtlasSprite sprite = texMap.getTextureExtry(spriteLocation.toString());
|
||||
return sprite != null ? sprite : missingIcon;
|
||||
return getTextureAtlasSprite(spriteLocation);
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getFluidTexture(FluidStack fluidStack, FluidType type) {
|
||||
@@ -134,6 +133,10 @@ public class MekanismRenderer {
|
||||
} else {
|
||||
spriteLocation = fluid.getFlowing(fluidStack);
|
||||
}
|
||||
return getTextureAtlasSprite(spriteLocation);
|
||||
}
|
||||
|
||||
public static TextureAtlasSprite getTextureAtlasSprite(ResourceLocation spriteLocation) {
|
||||
TextureAtlasSprite sprite = texMap.getTextureExtry(spriteLocation.toString());
|
||||
return sprite != null ? sprite : missingIcon;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package mekanism.client.render.obj;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import javax.annotation.Nonnull;
|
||||
import mekanism.client.render.obj.MekanismOBJModel.OBJModelType;
|
||||
import mekanism.common.Mekanism;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
@@ -15,6 +16,7 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.registry.IRegistry;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.ICustomModelLoader;
|
||||
import net.minecraftforge.client.model.IModel;
|
||||
@@ -23,10 +25,10 @@ import net.minecraftforge.client.model.ModelLoaderRegistry;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.OBJState;
|
||||
import net.minecraftforge.common.model.IModelState;
|
||||
import net.minecraftforge.fml.common.FMLLog;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
public class MekanismOBJLoader implements ICustomModelLoader {
|
||||
|
||||
@@ -39,13 +41,12 @@ public class MekanismOBJLoader implements ICustomModelLoader {
|
||||
public void onModelBake(ModelBakeEvent event) {
|
||||
GlowPanelModel.forceRebake();
|
||||
|
||||
IRegistry<ModelResourceLocation, IBakedModel> modelRegistry = event.getModelRegistry();
|
||||
for (String s : OBJ_RENDERS) {
|
||||
ModelResourceLocation model = new ModelResourceLocation("mekanism:" + s, "inventory");
|
||||
IBakedModel bakedModel = event.getModelRegistry().getObject(model);
|
||||
event.getModelRegistry().putObject(model,
|
||||
createBakedObjItemModel(bakedModel, "mekanism:models/block/" + s + ".obj.mek",
|
||||
new OBJModel.OBJState(Lists.newArrayList(OBJModel.Group.ALL), true),
|
||||
DefaultVertexFormats.ITEM));
|
||||
IBakedModel bakedModel = modelRegistry.getObject(model);
|
||||
modelRegistry.putObject(model, createBakedObjItemModel(bakedModel, "mekanism:models/block/" + s +
|
||||
".obj.mek", new OBJState(Lists.newArrayList(OBJModel.Group.ALL), true), DefaultVertexFormats.ITEM));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +64,13 @@ public class MekanismOBJLoader implements ICustomModelLoader {
|
||||
TextureAtlasSprite missing = textureGetter.apply(new ResourceLocation("missingno"));
|
||||
|
||||
for (String s : objModel.getMatLib().getMaterialNames()) {
|
||||
if (objModel.getMatLib().getMaterial(s).getTexture().getTextureLocation().getPath().startsWith("#")) {
|
||||
FMLLog.log(Level.ERROR, "OBJLoader: Unresolved texture '%s' for obj model '%s'",
|
||||
objModel.getMatLib().getMaterial(s).getTexture().getTextureLocation().getPath(),
|
||||
ResourceLocation texture = objModel.getMatLib().getMaterial(s).getTexture().getTextureLocation();
|
||||
if (texture.getPath().startsWith("#")) {
|
||||
Mekanism.logger.error("OBJLoader: Unresolved texture '{}' for obj model '{}'", texture.getPath(),
|
||||
modelLocation);
|
||||
builder.put(s, missing);
|
||||
} else {
|
||||
builder.put(s,
|
||||
textureGetter.apply(objModel.getMatLib().getMaterial(s).getTexture().getTextureLocation()));
|
||||
builder.put(s, textureGetter.apply(texture));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,8 +166,9 @@ public abstract class OBJBakedModelBase extends OBJBakedModel {
|
||||
for (Face f : faces) {
|
||||
String groupName = groupNameMap.get(f);
|
||||
|
||||
if (getOverrideTexture(f, groupName) != null) {
|
||||
tempSprite = getOverrideTexture(f, groupName);
|
||||
TextureAtlasSprite overrideTexture = getOverrideTexture(f, groupName);
|
||||
if (overrideTexture != null) {
|
||||
tempSprite = overrideTexture;
|
||||
} else if (getModel().getMatLib().getMaterial(f.getMaterialName()).isWhite()) {
|
||||
for (Vertex v : f.getVertices()) {
|
||||
if (!v.getMaterial().equals(getModel().getMatLib().getMaterial(v.getMaterial().getName()))) {
|
||||
@@ -182,8 +183,9 @@ public abstract class OBJBakedModelBase extends OBJBakedModel {
|
||||
|
||||
float[] color = new float[]{1, 1, 1, 1};
|
||||
|
||||
if (getOverrideColor(f, groupName) != null) {
|
||||
color = getOverrideColor(f, groupName);
|
||||
float[] overrideColor = getOverrideColor(f, groupName);
|
||||
if (overrideColor != null) {
|
||||
color = overrideColor;
|
||||
}
|
||||
|
||||
EnumFacing facing = EnumFacing.getFacingFromVector(f.getNormal().x, f.getNormal().y, f.getNormal().z);
|
||||
@@ -214,9 +216,7 @@ public abstract class OBJBakedModelBase extends OBJBakedModel {
|
||||
bakedQuads.add(quad);
|
||||
}
|
||||
|
||||
List<BakedQuad> quadList = Collections.synchronizedList(Lists.newArrayList(bakedQuads));
|
||||
|
||||
return quadList;
|
||||
return bakedQuads;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -68,12 +68,13 @@ public class TransmitterModel extends OBJBakedModelBase {
|
||||
private TransmitterModel itemCache;
|
||||
private IBlockState tempState;
|
||||
private ItemStack tempStack;
|
||||
private TextureAtlasSprite particle;
|
||||
private TransmitterOverride override = new TransmitterOverride();
|
||||
|
||||
public TransmitterModel(IBakedModel base, OBJModel model, IModelState state, VertexFormat format,
|
||||
ImmutableMap<String, TextureAtlasSprite> textures, HashMap<TransformType, Matrix4f> transform) {
|
||||
super(base, model, state, format, textures, transform);
|
||||
|
||||
particle = textureMap.getOrDefault("None_Center", textureMap.getOrDefault("CentreMaterial", tempSprite));
|
||||
modelInstances.add(this);
|
||||
}
|
||||
|
||||
@@ -179,6 +180,12 @@ public class TransmitterModel extends OBJBakedModelBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public TextureAtlasSprite getParticleTexture() {
|
||||
return particle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureAtlasSprite getOverrideTexture(Face f, String groupName) {
|
||||
if (tempState != null) {
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package mekanism.client.render.particle;
|
||||
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.common.base.ITieredTile;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MekanismParticleHelper {
|
||||
|
||||
/** Centre offset? */
|
||||
private static final double OFFSET_1 = 0.20000000298023224D;
|
||||
|
||||
/** Side offset? */
|
||||
private static final double OFFSET_2 = 0.10000000149011612D;
|
||||
|
||||
/**
|
||||
* Adds block hit particles for the specified block, accounting for tier colour
|
||||
* @see ParticleManager#addBlockHitEffects(net.minecraft.util.math.BlockPos, net.minecraft.util.EnumFacing) for source of copy
|
||||
*
|
||||
* @param world relevant world
|
||||
* @param pos position of block
|
||||
* @param side which side was hit
|
||||
* @param manager vanilla particle manager in use
|
||||
* @return true if handled (always true)
|
||||
*/
|
||||
public static boolean addBlockHitEffects(World world, BlockPos pos, EnumFacing side, ParticleManager manager) {
|
||||
TileEntity tile = MekanismUtils.getTileEntitySafe(world, pos);
|
||||
EnumColor color = null;
|
||||
IBlockState iblockstate = world.getBlockState(pos);
|
||||
//Makes it so transmitters don't need to change their tier
|
||||
iblockstate = iblockstate.getBlock().getActualState(iblockstate, world, pos);
|
||||
if (tile instanceof ITieredTile) {
|
||||
color = ((ITieredTile) tile).getTier().getColor();
|
||||
}
|
||||
|
||||
if (iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE) {
|
||||
int blockX = pos.getX();
|
||||
int blockY = pos.getY();
|
||||
int blockZ = pos.getZ();
|
||||
AxisAlignedBB axisalignedbb = iblockstate.getBoundingBox(world, pos);
|
||||
double particleX = (double) blockX + world.rand.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX
|
||||
- OFFSET_1) + OFFSET_2 + axisalignedbb.minX;
|
||||
double particleY = (double) blockY + world.rand.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY
|
||||
- OFFSET_1) + OFFSET_2 + axisalignedbb.minY;
|
||||
double particleZ = (double) blockZ + world.rand.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ
|
||||
- OFFSET_1) + OFFSET_2 + axisalignedbb.minZ;
|
||||
|
||||
if (side == EnumFacing.DOWN) {
|
||||
particleY = (double) blockY + axisalignedbb.minY - OFFSET_2;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.UP) {
|
||||
particleY = (double) blockY + axisalignedbb.maxY + OFFSET_2;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.NORTH) {
|
||||
particleZ = (double) blockZ + axisalignedbb.minZ - OFFSET_2;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.SOUTH) {
|
||||
particleZ = (double) blockZ + axisalignedbb.maxZ + OFFSET_2;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.WEST) {
|
||||
particleX = (double) blockX + axisalignedbb.minX - OFFSET_2;
|
||||
}
|
||||
|
||||
if (side == EnumFacing.EAST) {
|
||||
particleX = (double) blockX + axisalignedbb.maxX + OFFSET_2;
|
||||
}
|
||||
|
||||
manager.addEffect(new TieredParticleDigging(world, particleX, particleY, particleZ, 0, 0, 0, iblockstate, color)
|
||||
.setBlockPos(pos).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package mekanism.client.render.particle;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.EnumColor;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleDigging;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TieredParticleDigging extends ParticleDigging {
|
||||
|
||||
@Nullable
|
||||
private final EnumColor color;
|
||||
|
||||
public TieredParticleDigging(World world, double xCoord, double yCoord, double zCoord, double xSpeed,
|
||||
double ySpeed, double zSpeed, IBlockState state, EnumColor color) {
|
||||
super(world, xCoord, yCoord, zCoord, xSpeed, ySpeed, zSpeed, state);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void multiplyColor(@Nullable BlockPos pos) {
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
this.particleRed *= color.getColor(0);
|
||||
this.particleGreen *= color.getColor(1);
|
||||
this.particleBlue *= color.getColor(2);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
package mekanism.client.render.transmitter;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.ColourRGBA;
|
||||
import mekanism.common.tile.transmitter.TileEntityTransmitter;
|
||||
@@ -22,6 +23,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.Attributes;
|
||||
import net.minecraftforge.client.model.obj.OBJLoader;
|
||||
import net.minecraftforge.client.model.obj.OBJModel;
|
||||
import net.minecraftforge.client.model.obj.OBJModel.OBJState;
|
||||
import net.minecraftforge.client.model.pipeline.LightUtil;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -47,15 +49,12 @@ public abstract class RenderTransmitterBase<T extends TileEntityTransmitter> ext
|
||||
|
||||
public static HashMap<String, IBakedModel> buildModelMap(OBJModel objModel) {
|
||||
HashMap<String, IBakedModel> modelParts = new HashMap<>();
|
||||
|
||||
if (!objModel.getMatLib().getGroups().keySet().isEmpty()) {
|
||||
for (String key : objModel.getMatLib().getGroups().keySet()) {
|
||||
String k = key;
|
||||
|
||||
Set<String> keys = objModel.getMatLib().getGroups().keySet();
|
||||
if (!keys.isEmpty()) {
|
||||
for (String key : keys) {
|
||||
if (!modelParts.containsKey(key)) {
|
||||
modelParts.put(k, objModel
|
||||
.bake(new OBJModel.OBJState(ImmutableList.of(k), false), Attributes.DEFAULT_BAKED_FORMAT,
|
||||
textureGetterFlipV));
|
||||
modelParts.put(key, objModel.bake(new OBJState(Collections.singletonList(key), false),
|
||||
Attributes.DEFAULT_BAKED_FORMAT, textureGetterFlipV));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package mekanism.common;
|
||||
|
||||
import mekanism.api.infuse.InfuseObject;
|
||||
import mekanism.api.infuse.InfuseRegistry;
|
||||
import mekanism.api.infuse.InfuseType;
|
||||
import mekanism.common.base.ISustainedData;
|
||||
@@ -8,9 +9,9 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
public class InfuseStorage implements ISustainedData {
|
||||
|
||||
public InfuseType type;
|
||||
private InfuseType type;
|
||||
|
||||
public int amount;
|
||||
private int amount;
|
||||
|
||||
public InfuseStorage() {
|
||||
}
|
||||
@@ -30,6 +31,32 @@ public class InfuseStorage implements ISustainedData {
|
||||
} else if (type == storage.type) {
|
||||
amount = 0;
|
||||
}
|
||||
if (amount <= 0) {
|
||||
type = null;
|
||||
amount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void increase(InfuseStorage input) {
|
||||
if (type == null) {
|
||||
type = input.type;
|
||||
amount = input.amount;
|
||||
} else if (type == input.type) {
|
||||
amount += input.amount;
|
||||
} else {
|
||||
Mekanism.logger.error("Tried to increase infusion storage with an incompatible type", new Exception());
|
||||
}
|
||||
}
|
||||
|
||||
public void increase(InfuseObject input) {
|
||||
if (type == null) {
|
||||
type = input.type;
|
||||
amount = input.stored;
|
||||
} else if (type == input.type) {
|
||||
amount += input.stored;
|
||||
} else {
|
||||
Mekanism.logger.error("Tried to increase infusion storage with an incompatible type", new Exception());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,4 +79,30 @@ public class InfuseStorage implements ISustainedData {
|
||||
amount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public InfuseType getType() {
|
||||
return amount == 0 ? null : type;
|
||||
}
|
||||
|
||||
public InfuseStorage setType(InfuseType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return type == null ? 0 : amount;
|
||||
}
|
||||
|
||||
public InfuseStorage setAmount(int amount) {
|
||||
if (amount < 0) {
|
||||
throw new IllegalArgumentException("Amount must be positive");
|
||||
}
|
||||
this.amount = amount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setEmpty() {
|
||||
this.amount = 0;
|
||||
this.type = null;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.base;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.InfuseStorage;
|
||||
@@ -44,6 +45,15 @@ public interface IFactory {
|
||||
*/
|
||||
int getRecipeType(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Gets the recipe type this Factory currently has.
|
||||
*
|
||||
* @param itemStack - stack to check
|
||||
* @return RecipeType or null if it has invalid NBT
|
||||
*/
|
||||
@Nullable
|
||||
RecipeType getRecipeTypeOrNull(ItemStack itemStack);
|
||||
|
||||
/**
|
||||
* Sets the recipe type of this Smelting Factory to a new value.
|
||||
*
|
||||
@@ -158,7 +168,7 @@ public interface IFactory {
|
||||
} else if (fuelType == MachineFuelType.CHANCE) {
|
||||
return getChanceRecipe(slotStack);
|
||||
} else if (this == INFUSING) {
|
||||
if (infuse.type != null) {
|
||||
if (infuse.getType() != null) {
|
||||
return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuse, slotStack));
|
||||
} else {
|
||||
for (Entry<InfusionInput, MetallurgicInfuserRecipe> entry : Recipe.METALLURGIC_INFUSER.get()
|
||||
|
||||
@@ -12,7 +12,7 @@ import mekanism.common.transmitters.grid.InventoryNetwork;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
public interface ILogisticalTransporter extends IGridTransmitter<TileEntity, InventoryNetwork>, IBlockableConnection {
|
||||
public interface ILogisticalTransporter extends IGridTransmitter<TileEntity, InventoryNetwork, Void>, IBlockableConnection {
|
||||
|
||||
TransitResponse insert(Coord4D original, TransitRequest request, EnumColor color, boolean doEmit, int min);
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package mekanism.common.base;
|
||||
|
||||
import mekanism.common.tier.BaseTier;
|
||||
|
||||
public interface ITieredTile {
|
||||
|
||||
BaseTier getTier();
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.IMekWrench;
|
||||
import mekanism.api.energy.IEnergizedItem;
|
||||
import mekanism.api.energy.IStrictEnergyStorage;
|
||||
import mekanism.client.render.particle.MekanismParticleHelper;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tier.FluidTankTier;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IBoundingBlock;
|
||||
import mekanism.common.base.IFactory;
|
||||
@@ -32,6 +32,7 @@ import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMess
|
||||
import mekanism.common.network.PacketLogisticalSorterGui.SorterGuiPacket;
|
||||
import mekanism.common.security.ISecurityItem;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tier.FluidTankTier;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.tile.TileEntityFluidTank;
|
||||
import mekanism.common.tile.TileEntityLaser;
|
||||
@@ -56,6 +57,7 @@ import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -77,6 +79,7 @@ import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult.Type;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.Explosion;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -806,6 +809,22 @@ public abstract class BlockMachine extends BlockContainer {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addHitEffects(IBlockState state, World world, RayTraceResult target, ParticleManager manager) {
|
||||
if (!target.typeOfHit.equals(Type.BLOCK)) {
|
||||
return super.addHitEffects(state, world, target, manager);
|
||||
}
|
||||
MachineType type = state.getValue(getTypeProperty());
|
||||
//If it is one of the types that block state won't have a color for
|
||||
if (type == MachineType.FLUID_TANK) {
|
||||
if (MekanismParticleHelper.addBlockHitEffects(world, target.getBlockPos(), target.sideHit, manager)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return super.addHitEffects(state, world, target, manager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectRedstone(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side) {
|
||||
MachineType type = MachineType.get(getMachineBlock(), state.getBlock().getMetaFromState(state));
|
||||
|
||||
@@ -6,9 +6,9 @@ import java.util.Random;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.IMekWrench;
|
||||
import mekanism.client.render.particle.MekanismParticleHelper;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.base.ITierItem;
|
||||
import mekanism.common.block.property.PropertyConnection;
|
||||
import mekanism.common.block.states.BlockStateTransmitter;
|
||||
@@ -16,6 +16,7 @@ import mekanism.common.block.states.BlockStateTransmitter.TransmitterType;
|
||||
import mekanism.common.block.states.BlockStateTransmitter.TransmitterType.Size;
|
||||
import mekanism.common.integration.multipart.MultipartMekanism;
|
||||
import mekanism.common.integration.wrenches.Wrenches;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tile.transmitter.TileEntityDiversionTransporter;
|
||||
import mekanism.common.tile.transmitter.TileEntityLogisticalTransporter;
|
||||
import mekanism.common.tile.transmitter.TileEntityMechanicalPipe;
|
||||
@@ -33,6 +34,7 @@ import net.minecraft.block.ITileEntityProvider;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.particle.ParticleManager;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -49,6 +51,7 @@ import net.minecraft.util.NonNullList;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult.Type;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@@ -286,6 +289,16 @@ public class BlockTransmitter extends Block implements ITileEntityProvider {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean addHitEffects(IBlockState state, World world, RayTraceResult target, ParticleManager manager) {
|
||||
if (!target.typeOfHit.equals(Type.BLOCK)) {
|
||||
return super.addHitEffects(state, world, target, manager);
|
||||
}
|
||||
return MekanismParticleHelper.addBlockHitEffects(world, target.getBlockPos(), target.sideHit, manager) ||
|
||||
super.addHitEffects(state, world, target, manager);
|
||||
}
|
||||
|
||||
public ItemStack dismantleBlock(IBlockState state, World world, BlockPos pos, boolean returnBlock) {
|
||||
ItemStack itemStack = getPickBlock(state, null, world, pos, null);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager;
|
||||
/**
|
||||
* Created by ben on 03/05/16.
|
||||
*/
|
||||
public class DefaultGridTransmitter<A, N extends DynamicNetwork<A, N>> implements IGridTransmitter<A, N> {
|
||||
public class DefaultGridTransmitter<A, N extends DynamicNetwork<A, N, BUFFER>, BUFFER> implements IGridTransmitter<A, N, BUFFER> {
|
||||
|
||||
public static void register() {
|
||||
CapabilityManager.INSTANCE.register(IGridTransmitter.class, new NullStorage<>(), DefaultGridTransmitter::new);
|
||||
@@ -130,7 +130,7 @@ public class DefaultGridTransmitter<A, N extends DynamicNetwork<A, N>> implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBuffer() {
|
||||
public BUFFER getBuffer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -142,4 +142,9 @@ public class DefaultGridTransmitter<A, N extends DynamicNetwork<A, N>> implement
|
||||
public TransmissionType getTransmissionType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatibleWith(IGridTransmitter<A, N, BUFFER> other) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.capabilities;
|
||||
import java.util.Collection;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.transmitters.IGridTransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.base.ILogisticalTransporter;
|
||||
import mekanism.common.capabilities.DefaultStorageHelper.NullStorage;
|
||||
@@ -188,7 +189,7 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBuffer() {
|
||||
public Void getBuffer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -200,4 +201,9 @@ public class DefaultLogisticalTransporter implements ILogisticalTransporter {
|
||||
public TransmissionType getTransmissionType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatibleWith(IGridTransmitter<TileEntity, InventoryNetwork, Void> other) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -312,11 +312,11 @@ public class EntityRobit extends EntityCreature implements IInventory, ISustaine
|
||||
setFollowing(false);
|
||||
|
||||
if (world.provider.getDimension() != homeLocation.dimensionId) {
|
||||
changeDimension(homeLocation.dimensionId);
|
||||
changeDimension(homeLocation.dimensionId, (world1, entity, yaw) -> entity.setLocationAndAngles(homeLocation.x + 0.5, homeLocation.y + 0.3, homeLocation.z + 0.5, yaw, rotationPitch));
|
||||
} else {
|
||||
setPositionAndUpdate(homeLocation.x + 0.5, homeLocation.y + 0.3, homeLocation.z + 0.5);
|
||||
}
|
||||
|
||||
setPositionAndUpdate(homeLocation.x + 0.5, homeLocation.y + 0.3, homeLocation.z + 0.5);
|
||||
|
||||
motionX = 0;
|
||||
motionY = 0;
|
||||
motionZ = 0;
|
||||
|
||||
+2
-2
@@ -173,8 +173,8 @@ public class MekRecipesCommand extends CraftTweakerCommand {
|
||||
type = Recipe.METALLURGIC_INFUSER;
|
||||
for (MetallurgicInfuserRecipe recipe : Recipe.METALLURGIC_INFUSER.get().values()) {
|
||||
CraftTweakerAPI.logCommand(String.format("mods.mekanism.infuser.addRecipe(%s, %s, %s, %s)",
|
||||
recipe.getInput().infuse.type,
|
||||
recipe.getInput().infuse.amount,
|
||||
recipe.getInput().infuse.getType(),
|
||||
recipe.getInput().infuse.getAmount(),
|
||||
RecipeInfoHelper.getItemName(recipe.getInput().inputStack),
|
||||
RecipeInfoHelper.getItemName(recipe.getOutput().output)
|
||||
));
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ public class IngredientHelper {
|
||||
} else if (in instanceof InfusionInput) {
|
||||
InfusionInput input = (InfusionInput) in;
|
||||
return matches(input.inputStack, toMatch.getIngredient()) && (toMatch.getInfuseType().isEmpty() || toMatch
|
||||
.getInfuseType().equalsIgnoreCase(input.infuse.type.name));
|
||||
.getInfuseType().equalsIgnoreCase(input.infuse.getType().name));
|
||||
} else if (in instanceof IntegerInput) {
|
||||
IntegerInput input = (IntegerInput) in;
|
||||
return input.ingredient == toMatch.getAmount();
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ContainerFactory extends ContainerMekanism<TileEntityFactory> {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
} else if (tileEntity.getRecipeType() == RecipeType.INFUSING && InfuseRegistry.getObject(slotStack) != null
|
||||
&& (tileEntity.infuseStored.type == null || tileEntity.infuseStored.type == InfuseRegistry
|
||||
&& (tileEntity.infuseStored.getType() == null || tileEntity.infuseStored.getType() == InfuseRegistry
|
||||
.getObject(slotStack).type)) {
|
||||
if (transferExtraSlot(slotID, slotStack)) {
|
||||
return ItemStack.EMPTY;
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ContainerMetallurgicInfuser extends ContainerMekanism<TileEntityMet
|
||||
stack = slotStack.copy();
|
||||
|
||||
if (slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) {
|
||||
if (InfuseRegistry.getObject(slotStack) != null && (tileEntity.infuseStored.type == null
|
||||
|| tileEntity.infuseStored.type == InfuseRegistry.getObject(slotStack).type)) {
|
||||
if (InfuseRegistry.getObject(slotStack) != null && (tileEntity.infuseStored.getType() == null
|
||||
|| tileEntity.infuseStored.getType() == InfuseRegistry.getObject(slotStack).type)) {
|
||||
if (!mergeItemStack(slotStack, 0, 1, false)) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ public class ContainerMetallurgicInfuser extends ContainerMekanism<TileEntityMet
|
||||
}
|
||||
|
||||
public boolean isInputItem(ItemStack itemStack) {
|
||||
if (tileEntity.infuseStored.type != null) {
|
||||
if (tileEntity.infuseStored.getType() != null) {
|
||||
return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(tileEntity.infuseStored, itemStack))
|
||||
!= null;
|
||||
} else {
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.Range4D;
|
||||
@@ -17,8 +18,6 @@ import mekanism.client.MekKeyHandler;
|
||||
import mekanism.client.MekanismClient;
|
||||
import mekanism.client.MekanismKeyHandler;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.FluidTankTier;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.FluidItemWrapper;
|
||||
import mekanism.common.base.IFactory;
|
||||
@@ -45,6 +44,8 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityItem;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.security.ISecurityTile.SecurityMode;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.FluidTankTier;
|
||||
import mekanism.common.tile.TileEntityFactory;
|
||||
import mekanism.common.tile.TileEntityFluidTank;
|
||||
import mekanism.common.tile.TileEntityQuantumEntangloporter;
|
||||
@@ -144,19 +145,19 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY
|
||||
|| type == MachineType.ELITE_FACTORY) {
|
||||
BaseTier tier = type == MachineType.BASIC_FACTORY ? BaseTier.BASIC
|
||||
: (type == MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED : BaseTier.ELITE);
|
||||
BaseTier tier = type.factoryTier.getBaseTier();
|
||||
|
||||
if (I18n.canTranslate(
|
||||
"tile." + tier.getSimpleName() + RecipeType.values()[getRecipeType(itemstack)].getTranslationKey()
|
||||
+ "Factory")) {
|
||||
return LangUtils.localize(
|
||||
"tile." + tier.getSimpleName() + RecipeType.values()[getRecipeType(itemstack)].getTranslationKey()
|
||||
+ "Factory");
|
||||
RecipeType recipeType = getRecipeTypeOrNull(itemstack);
|
||||
if (recipeType != null) {
|
||||
|
||||
String langKey = "tile." + tier.getSimpleName() + recipeType.getTranslationKey() + "Factory";
|
||||
if (I18n.canTranslate(langKey)) {
|
||||
return LangUtils.localize(langKey);
|
||||
}
|
||||
|
||||
return tier.getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super
|
||||
.getItemStackDisplayName(itemstack);
|
||||
}
|
||||
|
||||
return tier.getLocalizedName() + " " + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName()
|
||||
+ " " + super.getItemStackDisplayName(itemstack);
|
||||
} else if (type == MachineType.FLUID_TANK) {
|
||||
return LangUtils.localize("tile.FluidTank" + getBaseTier(itemstack).getSimpleName() + ".name");
|
||||
}
|
||||
@@ -222,9 +223,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY
|
||||
|| type == MachineType.ELITE_FACTORY) {
|
||||
list.add(
|
||||
EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + EnumColor.GREY + RecipeType
|
||||
.values()[getRecipeType(itemstack)].getLocalizedName());
|
||||
|
||||
RecipeType recipeType = getRecipeTypeOrNull(itemstack);
|
||||
if (recipeType != null) {
|
||||
list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + EnumColor.GREY
|
||||
+ recipeType.getLocalizedName());
|
||||
}
|
||||
}
|
||||
|
||||
if (type == MachineType.FLUID_TANK) {
|
||||
@@ -361,8 +365,10 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
if (tileEntity instanceof TileEntityFactory) {
|
||||
TileEntityFactory factory = (TileEntityFactory) tileEntity;
|
||||
RecipeType recipeType = RecipeType.values()[getRecipeType(stack)];
|
||||
factory.setRecipeType(recipeType);
|
||||
RecipeType recipeType = getRecipeTypeOrNull(stack);
|
||||
if (recipeType != null) {
|
||||
factory.setRecipeType(recipeType);
|
||||
}
|
||||
world.notifyNeighborsOfStateChange(pos, tileEntity.getBlockType(), true);
|
||||
|
||||
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity),
|
||||
@@ -529,6 +535,16 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
return itemStack.getTagCompound().getInteger("recipeType");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public RecipeType getRecipeTypeOrNull(ItemStack itemStack) {
|
||||
int recipeType = getRecipeType(itemStack);
|
||||
if (recipeType < RecipeType.values().length) {
|
||||
return RecipeType.values()[recipeType];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipeType(int type, ItemStack itemStack) {
|
||||
if (itemStack.getTagCompound() == null) {
|
||||
@@ -627,9 +643,9 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
if (machineType.isFactory()) {
|
||||
// 200*tier.processes*recipeType.getEnergyUsage(); // From TileEntityFactory
|
||||
RecipeType recipeType = RecipeType.values()[getRecipeType(itemStack)];
|
||||
RecipeType recipeType = getRecipeTypeOrNull(itemStack);
|
||||
int tierProcess = machineType.factoryTier.processes;
|
||||
double baseMaxEnergy = 200 * tierProcess * recipeType.getEnergyUsage();
|
||||
double baseMaxEnergy = 200 * tierProcess * (recipeType == null ? 1 : recipeType.getEnergyUsage());
|
||||
|
||||
return MekanismUtils.getMaxEnergy(itemStack, baseMaxEnergy);
|
||||
}
|
||||
|
||||
@@ -7,12 +7,10 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.IGridTransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.base.EnergyAcceptorWrapper;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage;
|
||||
@@ -25,7 +23,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
@@ -40,14 +37,21 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||
return null;
|
||||
}
|
||||
|
||||
PacketHandler.handlePacket(() ->
|
||||
{
|
||||
if (message.packetType == PacketType.UPDATE) {
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.world);
|
||||
PacketHandler.handlePacket(() -> {
|
||||
if (message.coord4D == null) {
|
||||
return;
|
||||
}
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.world);
|
||||
|
||||
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) {
|
||||
IGridTransmitter transmitter = CapabilityUtils
|
||||
.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null);
|
||||
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) {
|
||||
IGridTransmitter transmitter = CapabilityUtils
|
||||
.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null);
|
||||
if (transmitter == null) {
|
||||
//Should never be the case, but removes the warning
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.packetType == PacketType.UPDATE) {
|
||||
DynamicNetwork network = transmitter.hasTransmitterNetwork() && !message.newNetwork ? transmitter
|
||||
.getTransmitterNetwork() : transmitter.createEmptyNetwork();
|
||||
network.register();
|
||||
@@ -63,37 +67,21 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||
}
|
||||
|
||||
network.updateCapacity();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (MekanismConfig.current().client.opaqueTransmitters.val() || message.coord4D == null) {
|
||||
return;
|
||||
}
|
||||
if (MekanismConfig.current().client.opaqueTransmitters.val() || !transmitter.hasTransmitterNetwork()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.packetType == PacketType.ENERGY) {
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.world);
|
||||
|
||||
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) {
|
||||
IGridTransmitter transmitter = CapabilityUtils
|
||||
.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null);
|
||||
|
||||
if (transmitter.hasTransmitterNetwork()
|
||||
&& transmitter.getTransmissionType() == TransmissionType.ENERGY) {
|
||||
((IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork>) transmitter)
|
||||
.getTransmitterNetwork().clientEnergyScale = message.power;
|
||||
TransmissionType transmissionType = transmitter.getTransmissionType();
|
||||
if (message.packetType == PacketType.ENERGY) {
|
||||
if (transmissionType == TransmissionType.ENERGY) {
|
||||
((EnergyNetwork) transmitter.getTransmitterNetwork()).clientEnergyScale = message.power;
|
||||
}
|
||||
}
|
||||
} else if (message.packetType == PacketType.GAS) {
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.world);
|
||||
|
||||
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) {
|
||||
IGridTransmitter transmitter = CapabilityUtils
|
||||
.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null);
|
||||
|
||||
if (transmitter.hasTransmitterNetwork()
|
||||
&& transmitter.getTransmissionType() == TransmissionType.GAS) {
|
||||
GasNetwork net = ((IGridTransmitter<IGasHandler, GasNetwork>) transmitter)
|
||||
.getTransmitterNetwork();
|
||||
} else if (message.packetType == PacketType.GAS) {
|
||||
if (transmissionType == TransmissionType.GAS) {
|
||||
GasNetwork net = (GasNetwork) transmitter.getTransmitterNetwork();
|
||||
|
||||
if (message.gasType != null) {
|
||||
net.refGas = message.gasType;
|
||||
@@ -102,18 +90,9 @@ public class PacketTransmitterUpdate implements IMessageHandler<TransmitterUpdat
|
||||
net.buffer = message.gasStack;
|
||||
net.didTransfer = message.didGasTransfer;
|
||||
}
|
||||
}
|
||||
} else if (message.packetType == PacketType.FLUID) {
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.world);
|
||||
|
||||
if (CapabilityUtils.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) {
|
||||
IGridTransmitter transmitter = CapabilityUtils
|
||||
.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, null);
|
||||
|
||||
if (transmitter.hasTransmitterNetwork()
|
||||
&& transmitter.getTransmissionType() == TransmissionType.FLUID) {
|
||||
FluidNetwork net = ((IGridTransmitter<IFluidHandler, FluidNetwork>) transmitter)
|
||||
.getTransmitterNetwork();
|
||||
} else if (message.packetType == PacketType.FLUID) {
|
||||
if (transmissionType == TransmissionType.FLUID) {
|
||||
FluidNetwork net = (FluidNetwork) transmitter.getTransmitterNetwork();
|
||||
|
||||
if (message.fluidType != null) {
|
||||
net.refFluid = message.fluidType;
|
||||
|
||||
@@ -25,7 +25,7 @@ public class InfusionInput extends MachineInput<InfusionInput> {
|
||||
public ItemStack inputStack = ItemStack.EMPTY;
|
||||
|
||||
public InfusionInput(InfuseStorage storage, ItemStack itemStack) {
|
||||
infuse = new InfuseStorage(storage.type, storage.amount);
|
||||
infuse = new InfuseStorage(storage.getType(), storage.getAmount());
|
||||
inputStack = itemStack;
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ public class InfusionInput extends MachineInput<InfusionInput> {
|
||||
|
||||
@Override
|
||||
public InfusionInput copy() {
|
||||
return new InfusionInput(infuse.type, infuse.amount, inputStack.copy());
|
||||
return new InfusionInput(infuse.getType(), infuse.getAmount(), inputStack.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return infuse.type != null && !inputStack.isEmpty();
|
||||
return infuse.getType() != null && !inputStack.isEmpty();
|
||||
}
|
||||
|
||||
public boolean use(NonNullList<ItemStack> inventory, int index, InfuseStorage infuseStorage, boolean deplete) {
|
||||
@@ -70,7 +70,7 @@ public class InfusionInput extends MachineInput<InfusionInput> {
|
||||
|
||||
@Override
|
||||
public int hashIngredients() {
|
||||
return infuse.type.unlocalizedName.hashCode() << 8 | StackUtils.hashItemStack(inputStack);
|
||||
return infuse.getType().unlocalizedName.hashCode() << 8 | StackUtils.hashItemStack(inputStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +79,7 @@ public class InfusionInput extends MachineInput<InfusionInput> {
|
||||
return !other.isValid();
|
||||
}
|
||||
|
||||
return infuse.type == other.infuse.type && MachineInput.inputItemMatches(inputStack, other.inputStack);
|
||||
return infuse.getType() == other.infuse.getType() && MachineInput.inputItemMatches(inputStack, other.inputStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -342,11 +342,6 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
}
|
||||
|
||||
if (infuseStored.amount <= 0) {
|
||||
infuseStored.amount = 0;
|
||||
infuseStored.type = null;
|
||||
}
|
||||
|
||||
lastUsage = prev - getEnergy();
|
||||
prevEnergy = getEnergy();
|
||||
}
|
||||
@@ -479,7 +474,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}*/ else if (cached.recipeInput instanceof InfusionInput) {
|
||||
InfusionInput infusionInput = (InfusionInput) cached.recipeInput;
|
||||
recipeInput = infusionInput.inputStack;
|
||||
secondaryMatch = infuseStored.amount == 0 || infuseStored.type == infusionInput.infuse.type;
|
||||
secondaryMatch = infuseStored.getAmount() == 0 || infuseStored.getType() == infusionInput.infuse.getType();
|
||||
}
|
||||
//If there is no cached item input or it doesn't match our fallback
|
||||
// then it is an out of date cache so we compare against the new one
|
||||
@@ -536,13 +531,11 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
inventory.get(4).shrink(1);
|
||||
}
|
||||
} else if (recipeType == RecipeType.INFUSING) {
|
||||
if (InfuseRegistry.getObject(inventory.get(4)) != null) {
|
||||
InfuseObject infuse = InfuseRegistry.getObject(inventory.get(4));
|
||||
|
||||
if (infuseStored.type == null || infuseStored.type == infuse.type) {
|
||||
if (infuseStored.amount + infuse.stored <= maxInfuse) {
|
||||
infuseStored.amount += infuse.stored;
|
||||
infuseStored.type = infuse.type;
|
||||
InfuseObject pendingInfusionInput = InfuseRegistry.getObject(inventory.get(4));
|
||||
if (pendingInfusionInput != null) {
|
||||
if (infuseStored.getType() == null || infuseStored.getType() == pendingInfusionInput.type) {
|
||||
if (infuseStored.getAmount() + pendingInfusionInput.stored <= maxInfuse) {
|
||||
infuseStored.increase(pendingInfusionInput);
|
||||
inventory.get(4).shrink(1);
|
||||
}
|
||||
}
|
||||
@@ -620,8 +613,8 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
} else if (recipeType.getFuelType() == MachineFuelType.DOUBLE) {
|
||||
return recipeType.hasRecipeForExtra(itemstack);
|
||||
} else if (recipeType == RecipeType.INFUSING) {
|
||||
return InfuseRegistry.getObject(itemstack) != null && (infuseStored.type == null
|
||||
|| infuseStored.type == InfuseRegistry.getObject(itemstack).type);
|
||||
return InfuseRegistry.getObject(itemstack) != null && (infuseStored.getType() == null
|
||||
|| infuseStored.getType() == InfuseRegistry.getObject(itemstack).type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +626,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
}
|
||||
|
||||
public int getScaledInfuseLevel(int i) {
|
||||
return infuseStored.amount * i / maxInfuse;
|
||||
return infuseStored.getAmount() * i / maxInfuse;
|
||||
}
|
||||
|
||||
public int getScaledGasLevel(int i) {
|
||||
@@ -765,8 +758,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
sorting = !sorting;
|
||||
} else if (type == 1) {
|
||||
gasTank.setGas(null);
|
||||
infuseStored.amount = 0;
|
||||
infuseStored.type = null;
|
||||
infuseStored.setEmpty();
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -782,9 +774,12 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
sorting = dataStream.readBoolean();
|
||||
upgraded = dataStream.readBoolean();
|
||||
lastUsage = dataStream.readDouble();
|
||||
infuseStored.amount = dataStream.readInt();
|
||||
if (infuseStored.amount > 0) {
|
||||
infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream));
|
||||
int amount = dataStream.readInt();
|
||||
if (amount > 0) {
|
||||
infuseStored.setAmount(amount);
|
||||
infuseStored.setType(InfuseRegistry.get(PacketHandler.readString(dataStream)));
|
||||
} else {
|
||||
infuseStored.setEmpty();
|
||||
}
|
||||
|
||||
if (recipeType != oldRecipe) {
|
||||
@@ -816,8 +811,11 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades());
|
||||
recipeTicks = nbtTags.getInteger("recipeTicks");
|
||||
sorting = nbtTags.getBoolean("sorting");
|
||||
infuseStored.amount = nbtTags.getInteger("infuseStored");
|
||||
infuseStored.type = InfuseRegistry.get(nbtTags.getString("type"));
|
||||
int amount = nbtTags.getInteger("infuseStored");
|
||||
if (amount != 0) {
|
||||
infuseStored.setAmount(amount);
|
||||
infuseStored.setType(InfuseRegistry.get(nbtTags.getString("type")));
|
||||
}
|
||||
|
||||
for (int i = 0; i < tier.processes; i++) {
|
||||
progress[i] = nbtTags.getInteger("progress" + i);
|
||||
@@ -834,10 +832,9 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
nbtTags.setInteger("recipeType", recipeType.ordinal());
|
||||
nbtTags.setInteger("recipeTicks", recipeTicks);
|
||||
nbtTags.setBoolean("sorting", sorting);
|
||||
nbtTags.setInteger("infuseStored", infuseStored.amount);
|
||||
|
||||
if (infuseStored.type != null) {
|
||||
nbtTags.setString("type", infuseStored.type.name);
|
||||
if (infuseStored.getType() != null) {
|
||||
nbtTags.setString("type", infuseStored.getType().name);
|
||||
nbtTags.setInteger("infuseStored", infuseStored.getAmount());
|
||||
} else {
|
||||
nbtTags.setString("type", "null");
|
||||
}
|
||||
@@ -861,9 +858,9 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
data.add(upgraded);
|
||||
data.add(lastUsage);
|
||||
|
||||
data.add(infuseStored.amount);
|
||||
if (infuseStored.amount > 0) {
|
||||
data.add(infuseStored.type.name);
|
||||
data.add(infuseStored.getAmount());
|
||||
if (infuseStored.getAmount() > 0) {
|
||||
data.add(infuseStored.getType().name);
|
||||
}
|
||||
|
||||
data.add(progress);
|
||||
|
||||
@@ -8,8 +8,6 @@ import mekanism.api.IConfigurable;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.FluidTankTier;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IActiveState;
|
||||
import mekanism.common.base.IFluidContainerManager;
|
||||
@@ -17,10 +15,13 @@ import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.base.ISustainedTank;
|
||||
import mekanism.common.base.ITankManager;
|
||||
import mekanism.common.base.ITierUpgradeable;
|
||||
import mekanism.common.base.ITieredTile;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.security.ISecurityTile;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.FluidTankTier;
|
||||
import mekanism.common.tile.component.TileComponentSecurity;
|
||||
import mekanism.common.tile.prefab.TileEntityContainerBlock;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
@@ -51,7 +52,8 @@ 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 {
|
||||
IFluidHandlerWrapper, ISustainedTank, IFluidContainerManager, ITankManager, ISecurityTile, ITierUpgradeable,
|
||||
ITieredTile {
|
||||
|
||||
public boolean isActive;
|
||||
|
||||
@@ -288,9 +290,10 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
tier = FluidTankTier.values()[nbtTags.getInteger("tier")];
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")];
|
||||
//Needs to be outside the hasKey check because this is just based on the tier which is known information
|
||||
fluidTank.setCapacity(tier.getStorage());
|
||||
|
||||
if (nbtTags.hasKey("fluidTank")) {
|
||||
fluidTank.setCapacity(tier.getStorage());
|
||||
fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank"));
|
||||
}
|
||||
}
|
||||
@@ -573,4 +576,9 @@ public class TileEntityFluidTank extends TileEntityContainerBlock implements IAc
|
||||
public TileComponentSecurity getSecurity() {
|
||||
return securityComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseTier getTier() {
|
||||
return tier.getBaseTier();
|
||||
}
|
||||
}
|
||||
@@ -87,13 +87,11 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
ChargeUtils.discharge(4, this);
|
||||
|
||||
if (!inventory.get(1).isEmpty()) {
|
||||
if (InfuseRegistry.getObject(inventory.get(1)) != null) {
|
||||
InfuseObject infuse = InfuseRegistry.getObject(inventory.get(1));
|
||||
|
||||
if (infuseStored.type == null || infuseStored.type == infuse.type) {
|
||||
if (infuseStored.amount + infuse.stored <= MAX_INFUSE) {
|
||||
infuseStored.amount += infuse.stored;
|
||||
infuseStored.type = infuse.type;
|
||||
InfuseObject pendingInfuseInput = InfuseRegistry.getObject(inventory.get(1));
|
||||
if (pendingInfuseInput != null) {
|
||||
if (infuseStored.getType() == null || infuseStored.getType() == pendingInfuseInput.type) {
|
||||
if (infuseStored.getAmount() + pendingInfuseInput.stored <= MAX_INFUSE) {
|
||||
infuseStored.increase(pendingInfuseInput);
|
||||
inventory.get(1).shrink(1);
|
||||
}
|
||||
}
|
||||
@@ -122,11 +120,6 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
operatingTicks = 0;
|
||||
}
|
||||
|
||||
if (infuseStored.amount <= 0) {
|
||||
infuseStored.amount = 0;
|
||||
infuseStored.type = null;
|
||||
}
|
||||
|
||||
prevEnergy = getEnergy();
|
||||
}
|
||||
}
|
||||
@@ -207,13 +200,13 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
if (slotID == 3) {
|
||||
return false;
|
||||
} else if (slotID == 1) {
|
||||
return InfuseRegistry.getObject(itemstack) != null && (infuseStored.type == null
|
||||
|| infuseStored.type == InfuseRegistry.getObject(itemstack).type);
|
||||
return InfuseRegistry.getObject(itemstack) != null && (infuseStored.getType() == null
|
||||
|| infuseStored.getType() == InfuseRegistry.getObject(itemstack).type);
|
||||
} else if (slotID == 0) {
|
||||
return itemstack.getItem() == MekanismItems.SpeedUpgrade
|
||||
|| itemstack.getItem() == MekanismItems.EnergyUpgrade;
|
||||
} else if (slotID == 2) {
|
||||
if (infuseStored.type != null) {
|
||||
if (infuseStored.getType() != null) {
|
||||
return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuseStored, itemstack)) != null;
|
||||
} else {
|
||||
return Recipe.METALLURGIC_INFUSER.get().keySet().stream()
|
||||
@@ -242,15 +235,18 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
}
|
||||
|
||||
public int getScaledInfuseLevel(int i) {
|
||||
return infuseStored.amount * i / MAX_INFUSE;
|
||||
return infuseStored.getAmount() * i / MAX_INFUSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbtTags) {
|
||||
super.readFromNBT(nbtTags);
|
||||
|
||||
infuseStored.amount = nbtTags.getInteger("infuseStored");
|
||||
infuseStored.type = InfuseRegistry.get(nbtTags.getString("type"));
|
||||
int amount = nbtTags.getInteger("infuseStored");
|
||||
if (amount != 0) {
|
||||
infuseStored.setAmount(amount);
|
||||
infuseStored.setType(InfuseRegistry.get(nbtTags.getString("type")));
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@@ -258,10 +254,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound nbtTags) {
|
||||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setInteger("infuseStored", infuseStored.amount);
|
||||
|
||||
if (infuseStored.type != null) {
|
||||
nbtTags.setString("type", infuseStored.type.name);
|
||||
if (infuseStored.getType() != null) {
|
||||
nbtTags.setString("type", infuseStored.getType().name);
|
||||
nbtTags.setInteger("infuseStored", infuseStored.getAmount());
|
||||
} else {
|
||||
nbtTags.setString("type", "null");
|
||||
}
|
||||
@@ -274,16 +269,19 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
@Override
|
||||
public void handlePacketData(ByteBuf dataStream) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
infuseStored.amount = dataStream.readInt();
|
||||
infuseStored.setAmount(dataStream.readInt());
|
||||
return;
|
||||
}
|
||||
|
||||
super.handlePacketData(dataStream);
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
infuseStored.amount = dataStream.readInt();
|
||||
if (infuseStored.amount > 0) {
|
||||
infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream));
|
||||
int amount = dataStream.readInt();
|
||||
if (amount > 0) {
|
||||
infuseStored.setAmount(amount);
|
||||
infuseStored.setType(InfuseRegistry.get(PacketHandler.readString(dataStream)));
|
||||
} else {
|
||||
infuseStored.setEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,9 +290,9 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
public TileNetworkList getNetworkedData(TileNetworkList data) {
|
||||
super.getNetworkedData(data);
|
||||
|
||||
data.add(infuseStored.amount);
|
||||
if (infuseStored.amount > 0) {
|
||||
data.add(infuseStored.type.name);
|
||||
data.add(infuseStored.getAmount());
|
||||
if (infuseStored.getAmount() > 0) {
|
||||
data.add(infuseStored.getType().name);
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -323,7 +321,7 @@ public class TileEntityMetallurgicInfuser extends TileEntityOperationalMachine i
|
||||
case 6:
|
||||
return new Object[]{infuseStored};
|
||||
case 7:
|
||||
return new Object[]{MAX_INFUSE - infuseStored.amount};
|
||||
return new Object[]{MAX_INFUSE - infuseStored.getAmount()};
|
||||
default:
|
||||
throw new NoSuchMethodException();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class TileEntityLogisticalTransporter extends TileEntityTransmitter<TileEntity, InventoryNetwork> {
|
||||
public class TileEntityLogisticalTransporter extends TileEntityTransmitter<TileEntity, InventoryNetwork, Void> {
|
||||
|
||||
private final int SYNC_PACKET = 1;
|
||||
private final int BATCH_PACKET = 2;
|
||||
@@ -385,7 +385,7 @@ public class TileEntityLogisticalTransporter extends TileEntityTransmitter<TileE
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBuffer() {
|
||||
public Void getBuffer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.PipeTier;
|
||||
import mekanism.common.base.FluidHandlerWrapper;
|
||||
import mekanism.common.base.IFluidHandlerWrapper;
|
||||
import mekanism.common.block.states.BlockStateTransmitter.TransmitterType;
|
||||
import mekanism.common.capabilities.CapabilityWrapperManager;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.PipeTier;
|
||||
import mekanism.common.transmitters.grid.FluidNetwork;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
@@ -26,7 +26,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||
|
||||
public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandler, FluidNetwork> implements
|
||||
public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandler, FluidNetwork, FluidStack> implements
|
||||
IFluidHandlerWrapper {
|
||||
|
||||
public PipeTier tier = PipeTier.BASIC;
|
||||
@@ -167,6 +167,19 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
|
||||
return PipeUtils.isValidAcceptorOnSide(acceptor, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidTransmitter(TileEntity tileEntity) {
|
||||
if (!super.isValidTransmitter(tileEntity)) {
|
||||
return false;
|
||||
}
|
||||
if (!(tileEntity instanceof TileEntityMechanicalPipe)) {
|
||||
return true;
|
||||
}
|
||||
FluidStack buffer = getBufferWithFallback();
|
||||
FluidStack otherBuffer = ((TileEntityMechanicalPipe) tileEntity).getBufferWithFallback();
|
||||
return buffer == null || otherBuffer == null || buffer.isFluidEqual(otherBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidNetwork createNewNetwork() {
|
||||
return new FluidNetwork();
|
||||
@@ -177,11 +190,17 @@ public class TileEntityMechanicalPipe extends TileEntityTransmitter<IFluidHandle
|
||||
return new FluidNetwork(networks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canHaveIncompatibleNetworks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return tier.getPipeCapacity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public FluidStack getBuffer() {
|
||||
return buffer == null ? null : buffer.getFluid();
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.tile.transmitter;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -10,10 +11,10 @@ import mekanism.api.gas.GasTank;
|
||||
import mekanism.api.gas.GasTankInfo;
|
||||
import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.TubeTier;
|
||||
import mekanism.common.block.states.BlockStateTransmitter.TransmitterType;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.tier.TubeTier;
|
||||
import mekanism.common.transmitters.grid.GasNetwork;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
import mekanism.common.util.GasUtils;
|
||||
@@ -22,7 +23,8 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler, GasNetwork> implements IGasHandler {
|
||||
public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler, GasNetwork, GasStack> implements
|
||||
IGasHandler {
|
||||
|
||||
public TubeTier tier = TubeTier.BASIC;
|
||||
|
||||
@@ -169,6 +171,19 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
|
||||
return GasUtils.isValidAcceptorOnSide(tile, side);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidTransmitter(TileEntity tileEntity) {
|
||||
if (!super.isValidTransmitter(tileEntity)) {
|
||||
return false;
|
||||
}
|
||||
if (!(tileEntity instanceof TileEntityPressurizedTube)) {
|
||||
return true;
|
||||
}
|
||||
GasStack buffer = getBufferWithFallback();
|
||||
GasStack otherBuffer = ((TileEntityPressurizedTube) tileEntity).getBufferWithFallback();
|
||||
return buffer == null || otherBuffer == null || buffer.isGasEqual(otherBuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasNetwork createNewNetwork() {
|
||||
return new GasNetwork();
|
||||
@@ -179,14 +194,24 @@ public class TileEntityPressurizedTube extends TileEntityTransmitter<IGasHandler
|
||||
return new GasNetwork(networks);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canHaveIncompatibleNetworks() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return tier.getTubeCapacity();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public GasStack getBuffer() {
|
||||
return buffer == null ? null : buffer.getGas();
|
||||
if (buffer == null) {
|
||||
return null;
|
||||
}
|
||||
GasStack gas = buffer.getGas();
|
||||
return gas == null || gas.amount == 0 ? null : gas;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,13 +10,12 @@ import mekanism.api.Coord4D;
|
||||
import mekanism.api.EnumColor;
|
||||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.Range4D;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.api.transmitters.IBlockableConnection;
|
||||
import mekanism.api.transmitters.ITransmitter;
|
||||
import mekanism.api.transmitters.TransmissionType;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.base.ITileNetwork;
|
||||
import mekanism.api.TileNetworkList;
|
||||
import mekanism.common.block.BlockTransmitter;
|
||||
import mekanism.common.block.property.PropertyConnection;
|
||||
import mekanism.common.block.states.BlockStateTransmitter.TransmitterType;
|
||||
@@ -25,6 +24,7 @@ import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.integration.multipart.MultipartMekanism;
|
||||
import mekanism.common.integration.multipart.MultipartTileNetworkJoiner;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tier.BaseTier;
|
||||
import mekanism.common.util.CapabilityUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MultipartUtils;
|
||||
@@ -60,13 +60,13 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
public byte currentTransmitterConnections = 0x00;
|
||||
|
||||
public boolean sendDesc = false;
|
||||
public boolean redstonePowered = false;
|
||||
private boolean redstonePowered = false;
|
||||
|
||||
public boolean redstoneReactive = false;
|
||||
private boolean redstoneReactive = false;
|
||||
|
||||
public boolean forceUpdate = true;
|
||||
|
||||
public boolean redstoneSet = false;
|
||||
private boolean redstoneSet = false;
|
||||
|
||||
public ConnectionType[] connectionTypes = {ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL,
|
||||
ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL};
|
||||
@@ -101,9 +101,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
} else if (delayTicks < 5) {
|
||||
delayTicks++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getWorld().isRemote) {
|
||||
} else {
|
||||
if (forceUpdate) {
|
||||
refreshConnections();
|
||||
forceUpdate = false;
|
||||
@@ -148,8 +146,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite())
|
||||
&& TransmissionType.checkTransmissionType(CapabilityUtils
|
||||
.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()),
|
||||
getTransmitterType().getTransmission())
|
||||
&& isValidTransmitter(tileEntity)) {
|
||||
getTransmitterType().getTransmission()) && isValidTransmitter(tileEntity)) {
|
||||
connections |= 1 << side.ordinal();
|
||||
}
|
||||
}
|
||||
@@ -196,8 +193,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
.hasCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite())
|
||||
&& TransmissionType.checkTransmissionType(CapabilityUtils
|
||||
.getCapability(tileEntity, Capabilities.GRID_TRANSMITTER_CAPABILITY, side.getOpposite()),
|
||||
getTransmitterType().getTransmission())
|
||||
&& isValidTransmitter(tileEntity);
|
||||
getTransmitterType().getTransmission()) && isValidTransmitter(tileEntity);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -312,18 +308,23 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
|
||||
@Override
|
||||
public boolean canConnect(EnumFacing side) {
|
||||
if (!redstoneSet) {
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
if(connectionTypes[side.ordinal()] == ConnectionType.NONE) {
|
||||
return false;
|
||||
}
|
||||
if (handlesRedstone()) {
|
||||
if (!redstoneSet) {
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
}
|
||||
|
||||
redstoneSet = true;
|
||||
}
|
||||
|
||||
redstoneSet = true;
|
||||
}
|
||||
|
||||
if (handlesRedstone() && redstoneReactive && redstonePowered) {
|
||||
return false;
|
||||
if (redstoneReactive && redstonePowered) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (Mekanism.hooks.MCMPLoaded) {
|
||||
@@ -401,24 +402,49 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
}
|
||||
|
||||
public void refreshConnections() {
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
}
|
||||
if (handlesRedstone()) {
|
||||
boolean previouslyPowered = redstonePowered;
|
||||
if (redstoneReactive) {
|
||||
redstonePowered = MekanismUtils.isGettingPowered(getWorld(), new Coord4D(getPos(), getWorld()));
|
||||
} else {
|
||||
redstonePowered = false;
|
||||
}
|
||||
//If the redstone mode changed properly update the connection to other transmitters/networks
|
||||
if (previouslyPowered != redstonePowered) {
|
||||
//Has to be markDirtyTransmitters instead of notify tile change
|
||||
// or it will not properly tell the neighboring connections that
|
||||
// it is no longer valid
|
||||
markDirtyTransmitters();
|
||||
}
|
||||
|
||||
redstoneSet = true;
|
||||
redstoneSet = true;
|
||||
}
|
||||
|
||||
if (!getWorld().isRemote) {
|
||||
byte possibleTransmitters = getPossibleTransmitterConnections();
|
||||
byte possibleAcceptors = getPossibleAcceptorConnections();
|
||||
byte newlyEnabledTransmitters = 0;
|
||||
|
||||
if ((possibleTransmitters | possibleAcceptors) != getAllCurrentConnections()) {
|
||||
sendDesc = true;
|
||||
|
||||
if (possibleTransmitters != currentTransmitterConnections) {
|
||||
//If they don't match get the difference
|
||||
newlyEnabledTransmitters = (byte) (possibleTransmitters ^ currentTransmitterConnections);
|
||||
//Now remove all bits that already where enabled so we only have the
|
||||
// ones that are newly enabled. There is no need to recheck for a
|
||||
// network merge on two transmitters if one is no longer accessible
|
||||
newlyEnabledTransmitters &= ~currentTransmitterConnections;
|
||||
}
|
||||
}
|
||||
|
||||
currentTransmitterConnections = possibleTransmitters;
|
||||
currentAcceptorConnections = possibleAcceptors;
|
||||
|
||||
if (newlyEnabledTransmitters != 0) {
|
||||
//If any sides are now valid transmitters that were not before recheck the connection
|
||||
recheckConnections(newlyEnabledTransmitters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,19 +452,47 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
if (!getWorld().isRemote) {
|
||||
boolean possibleTransmitter = getPossibleTransmitterConnection(side);
|
||||
boolean possibleAcceptor = getPossibleAcceptorConnection(side);
|
||||
boolean transmitterChanged = false;
|
||||
|
||||
if ((possibleTransmitter || possibleAcceptor) != connectionMapContainsSide(getAllCurrentConnections(),
|
||||
side)) {
|
||||
sendDesc = true;
|
||||
|
||||
if (possibleTransmitter != connectionMapContainsSide(currentTransmitterConnections, side)) {
|
||||
//If it doesn't match check if it is now enabled, as we don't care about it changing to disabled
|
||||
transmitterChanged = possibleTransmitter;
|
||||
}
|
||||
}
|
||||
|
||||
currentTransmitterConnections = setConnectionBit(currentTransmitterConnections, possibleTransmitter, side);
|
||||
currentAcceptorConnections = setConnectionBit(currentAcceptorConnections, possibleAcceptor, side);
|
||||
|
||||
if (transmitterChanged) {
|
||||
//If this side is now a valid transmitter and it wasn't before recheck the connection
|
||||
recheckConnection(side);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from server side
|
||||
* @param newlyEnabledTransmitters The transmitters that are now enabled and were not before.
|
||||
*/
|
||||
protected void recheckConnections(byte newlyEnabledTransmitters) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Only call this from server side
|
||||
* @param side The side that a transmitter is now enabled on after having been disabled.
|
||||
*/
|
||||
protected void recheckConnection(EnumFacing side) {
|
||||
}
|
||||
|
||||
protected void onModeChange(EnumFacing side) {
|
||||
markDirtyAcceptor(side);
|
||||
if (getPossibleTransmitterConnections() != currentTransmitterConnections) {
|
||||
markDirtyTransmitters();
|
||||
}
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@@ -479,6 +533,10 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
@Override
|
||||
public void onLoad() {
|
||||
onWorldJoin();
|
||||
if (getPossibleTransmitterConnections() != currentTransmitterConnections) {
|
||||
//Mark the transmitters as invalidated if they do not match what we have stored/calculated
|
||||
refreshConnections();
|
||||
}
|
||||
super.onLoad();
|
||||
}
|
||||
|
||||
@@ -487,16 +545,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
}
|
||||
|
||||
public void onNeighborBlockChange(EnumFacing side) {
|
||||
if (handlesRedstone()) {
|
||||
boolean prevPowered = redstonePowered;
|
||||
refreshConnections();
|
||||
|
||||
if (prevPowered != redstonePowered) {
|
||||
markDirtyTransmitters();
|
||||
}
|
||||
} else {
|
||||
refreshConnections();
|
||||
}
|
||||
refreshConnections();
|
||||
}
|
||||
|
||||
public void onPartChanged(IMultipart part) {
|
||||
@@ -534,18 +583,29 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
} else {
|
||||
EnumFacing hitSide = sideHit(hit.subHit + 1);
|
||||
|
||||
if(hitSide == null) {
|
||||
if (connectionTypes[side.ordinal()] != ConnectionType.NONE && onConfigure(player, 6, side) == EnumActionResult.SUCCESS) {
|
||||
return EnumActionResult.SUCCESS;
|
||||
}
|
||||
hitSide = side;
|
||||
}
|
||||
|
||||
if (hitSide != null) {
|
||||
connectionTypes[hitSide.ordinal()] = connectionTypes[hitSide.ordinal()].next();
|
||||
sendDesc = true;
|
||||
|
||||
onModeChange(EnumFacing.byIndex(hitSide.ordinal()));
|
||||
|
||||
refreshConnections();
|
||||
notifyTileChange();
|
||||
|
||||
player.sendMessage(
|
||||
new TextComponentGroup().translation("tooltip.configurator.modeChange").string(" ")
|
||||
.translation(connectionTypes[hitSide.ordinal()].translationKey()));
|
||||
|
||||
return EnumActionResult.SUCCESS;
|
||||
} else {
|
||||
return onConfigure(player, 6, side);
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -632,8 +692,7 @@ public abstract class TileEntitySidedPipe extends TileEntity implements ITileNet
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, EnumFacing facing) {
|
||||
return capability == Capabilities.CONFIGURABLE_CAPABILITY || capability == Capabilities.TILE_NETWORK_CAPABILITY
|
||||
||
|
||||
capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY || super.hasCapability(capability, facing);
|
||||
|| capability == Capabilities.BLOCKABLE_CONNECTION_CAPABILITY || super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public class TileEntityThermodynamicConductor extends TileEntityTransmitter<IHeatTransfer, HeatNetwork> implements
|
||||
public class TileEntityThermodynamicConductor extends TileEntityTransmitter<IHeatTransfer, HeatNetwork, Void> implements
|
||||
IHeatTransfer {
|
||||
|
||||
public ConductorTier tier = ConductorTier.BASIC;
|
||||
@@ -58,7 +58,7 @@ public class TileEntityThermodynamicConductor extends TileEntityTransmitter<IHea
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBuffer() {
|
||||
public Void getBuffer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,11 @@ package mekanism.common.tile.transmitter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.IAlloyInteraction;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
@@ -20,14 +23,14 @@ import net.minecraft.util.EnumHand;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
|
||||
public abstract class TileEntityTransmitter<A, N extends DynamicNetwork<A, N>> extends TileEntitySidedPipe implements
|
||||
IAlloyInteraction {
|
||||
public abstract class TileEntityTransmitter<A, N extends DynamicNetwork<A, N, BUFFER>, BUFFER> extends
|
||||
TileEntitySidedPipe implements IAlloyInteraction {
|
||||
|
||||
public TransmitterImpl<A, N> transmitterDelegate;
|
||||
public TransmitterImpl<A, N, BUFFER> transmitterDelegate;
|
||||
|
||||
public boolean unloaded = true;
|
||||
|
||||
public boolean dataRequest = false;
|
||||
public boolean delayedRefresh = false;
|
||||
|
||||
private N lastClientNetwork = null;
|
||||
|
||||
@@ -35,7 +38,7 @@ public abstract class TileEntityTransmitter<A, N extends DynamicNetwork<A, N>> e
|
||||
transmitterDelegate = new TransmitterImpl<>(this);
|
||||
}
|
||||
|
||||
public TransmitterImpl<A, N> getTransmitter() {
|
||||
public TransmitterImpl<A, N, BUFFER> getTransmitter() {
|
||||
return transmitterDelegate;
|
||||
}
|
||||
|
||||
@@ -58,6 +61,13 @@ public abstract class TileEntityTransmitter<A, N extends DynamicNetwork<A, N>> e
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (delayedRefresh) {
|
||||
//Gets run the tick after the variable has been set. This is enough
|
||||
// time to ensure that the transmitter has been registered.
|
||||
delayedRefresh = false;
|
||||
refreshConnections();
|
||||
}
|
||||
|
||||
if (getWorld().isRemote) {
|
||||
if (!dataRequest) {
|
||||
dataRequest = true;
|
||||
@@ -105,6 +115,103 @@ public abstract class TileEntityTransmitter<A, N extends DynamicNetwork<A, N>> e
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean canHaveIncompatibleNetworks() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void recheckConnections(byte newlyEnabledTransmitters) {
|
||||
if (canHaveIncompatibleNetworks() && getTransmitter().hasTransmitterNetwork()) {
|
||||
//We only need to check if we can have incompatible networks and if we actually have a network
|
||||
boolean networkUpdated = false;
|
||||
for (EnumFacing side : EnumFacing.values()) {
|
||||
if (connectionMapContainsSide(newlyEnabledTransmitters, side)) {
|
||||
//Recheck the side that is now enabled, as we manually merge this
|
||||
// cannot be simplified to a first match is good enough
|
||||
networkUpdated |= recheckConnectionPrechecked(side);
|
||||
}
|
||||
}
|
||||
if (networkUpdated) {
|
||||
refreshNetwork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void recheckConnection(EnumFacing side) {
|
||||
if (canHaveIncompatibleNetworks() && getTransmitter().hasTransmitterNetwork()) {
|
||||
//We only need to check if we can have incompatible networks and if we actually have a network
|
||||
if (recheckConnectionPrechecked(side)) {
|
||||
refreshNetwork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshNetwork() {
|
||||
//Queue an update for all the transmitters in the network just in case something went wrong
|
||||
// and to update the rendering of them
|
||||
N network = getTransmitter().getTransmitterNetwork();
|
||||
network.queueClientUpdate(network.transmitters);
|
||||
//Copy values into a set so that we don't risk a CME
|
||||
Set<IGridTransmitter<A, N, BUFFER>> transmitters = new HashSet<>(network.transmitters);
|
||||
//TODO: Make some better way of refreshing the connections, given we only need to refresh
|
||||
// connections to ourself anyways
|
||||
// The best way to do this is probably by making a method that updates the values for
|
||||
// the valid transmitters manually if the network is the same object.
|
||||
for (IGridTransmitter<A, N, BUFFER> transmitter : transmitters) {
|
||||
if (transmitter instanceof TransmitterImpl) {
|
||||
//Refresh the connections because otherwise sometimes they need to wait for a block update
|
||||
((TransmitterImpl<A, N, BUFFER>) transmitter).containingTile.refreshConnections();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean recheckConnectionPrechecked(EnumFacing side) {
|
||||
N network = getTransmitter().getTransmitterNetwork();
|
||||
TileEntity tileEntity = getWorld().getTileEntity(getPos().offset(side));
|
||||
if (tileEntity instanceof TileEntityTransmitter) {
|
||||
TileEntityTransmitter other = (TileEntityTransmitter) tileEntity;
|
||||
//The other one should always have the same incompatible networks state as us
|
||||
// But just in case it doesn't just check the boolean
|
||||
if (other.canHaveIncompatibleNetworks() && other.getTransmitter().hasTransmitterNetwork()) {
|
||||
N otherNetwork = (N) other.getTransmitter().getTransmitterNetwork();
|
||||
if (network != otherNetwork && network.isCompatibleWith(otherNetwork)) {
|
||||
//We have two networks that are now compatible and they are not the same source network
|
||||
// The most common cause they would be same source network is that they would merge
|
||||
// from the first pipe checking when it attempts to reconnect, and then the second
|
||||
// pipe still is going to be checking the connection.
|
||||
|
||||
if (getBufferWithFallback() == null) {
|
||||
//If we don't have any use them as primary network
|
||||
N tempNetwork = network;
|
||||
network = otherNetwork;
|
||||
otherNetwork = tempNetwork;
|
||||
}
|
||||
|
||||
// Manually merge the networks.
|
||||
// This code is not in network registry as there is special handling needed to ensure
|
||||
// it visually updates properly. There also were above checks that get us to a certain
|
||||
// point where we can make some assumptions about the networks and if it is actually
|
||||
// valid to merge them when otherwise people may try to merge things when they shouldn't
|
||||
// be merged causing unexpected bugs.
|
||||
network.adoptTransmittersAndAcceptorsFrom(otherNetwork);
|
||||
//Unregister the other network
|
||||
otherNetwork.deregister();
|
||||
//Commit the changes of the new network
|
||||
network.commit();
|
||||
|
||||
//We did not have these as part of the update because they got directly added
|
||||
// This means that we have to update the capacity/buffer and queue client updates
|
||||
// ourselves
|
||||
network.updateCapacity();
|
||||
network.clampBuffer();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract A getCachedAcceptor(EnumFacing side);
|
||||
|
||||
protected TileEntity getCachedTile(EnumFacing side) {
|
||||
@@ -169,7 +276,18 @@ public abstract class TileEntityTransmitter<A, N extends DynamicNetwork<A, N>> e
|
||||
|
||||
public abstract int getCapacity();
|
||||
|
||||
public abstract Object getBuffer();
|
||||
@Nullable
|
||||
public abstract BUFFER getBuffer();
|
||||
|
||||
@Nullable
|
||||
public BUFFER getBufferWithFallback() {
|
||||
BUFFER buffer = getBuffer();
|
||||
//If we don't have a buffer try falling back to the network's buffer
|
||||
if (buffer == null && getTransmitter().hasTransmitterNetwork()) {
|
||||
return getTransmitter().getTransmitterNetwork().getBuffer();
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public abstract void takeShare();
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ import net.minecraftforge.fml.common.Optional;
|
||||
@Optional.InterfaceList(
|
||||
@Optional.Interface(iface = "cofh.redstoneflux.api.IEnergyReceiver", modid = MekanismHooks.REDSTONEFLUX_MOD_ID)
|
||||
)
|
||||
public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyAcceptorWrapper, EnergyNetwork> implements
|
||||
public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyAcceptorWrapper, EnergyNetwork, EnergyStack> implements
|
||||
IStrictEnergyAcceptor, IStrictEnergyStorage, IEnergyReceiver {
|
||||
|
||||
public CableTier tier = CableTier.BASIC;
|
||||
@@ -240,7 +240,7 @@ public class TileEntityUniversalCable extends TileEntityTransmitter<EnergyAccept
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBuffer() {
|
||||
public EnergyStack getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,19 +3,19 @@ package mekanism.common.transmitters;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.IGridTransmitter;
|
||||
|
||||
public abstract class Transmitter<A, N extends DynamicNetwork<A, N>> implements IGridTransmitter<A, N> {
|
||||
public abstract class Transmitter<ACCEPTOR, NETWORK extends DynamicNetwork<ACCEPTOR, NETWORK, BUFFER>, BUFFER> implements IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> {
|
||||
|
||||
public N theNetwork = null;
|
||||
public NETWORK theNetwork = null;
|
||||
|
||||
public boolean orphaned = true;
|
||||
|
||||
@Override
|
||||
public N getTransmitterNetwork() {
|
||||
public NETWORK getTransmitterNetwork() {
|
||||
return theNetwork;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransmitterNetwork(N network) {
|
||||
public void setTransmitterNetwork(NETWORK network) {
|
||||
if (theNetwork == network) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mekanism.common.transmitters;
|
||||
|
||||
import java.util.Collection;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.IGridTransmitter;
|
||||
@@ -12,11 +13,11 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TransmitterImpl<A, N extends DynamicNetwork<A, N>> extends Transmitter<A, N> {
|
||||
public class TransmitterImpl<ACCEPTOR, NETWORK extends DynamicNetwork<ACCEPTOR, NETWORK, BUFFER>, BUFFER> extends Transmitter<ACCEPTOR, NETWORK, BUFFER> {
|
||||
|
||||
public TileEntityTransmitter<A, N> containingTile;
|
||||
public TileEntityTransmitter<ACCEPTOR, NETWORK, BUFFER> containingTile;
|
||||
|
||||
public TransmitterImpl(TileEntityTransmitter<A, N> multiPart) {
|
||||
public TransmitterImpl(TileEntityTransmitter<ACCEPTOR, NETWORK, BUFFER> multiPart) {
|
||||
setTileEntity(multiPart);
|
||||
}
|
||||
|
||||
@@ -61,7 +62,20 @@ public class TransmitterImpl<A, N extends DynamicNetwork<A, N>> extends Transmit
|
||||
}
|
||||
|
||||
@Override
|
||||
public A getAcceptor(EnumFacing side) {
|
||||
public boolean isCompatibleWith(IGridTransmitter<ACCEPTOR, NETWORK, BUFFER> other) {
|
||||
if (other instanceof TransmitterImpl) {
|
||||
return containingTile.isValidTransmitter(((TransmitterImpl) other).containingTile);
|
||||
}
|
||||
return true;//allow non-Transmitter impls to connect?
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionFailed() {
|
||||
containingTile.delayedRefresh = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ACCEPTOR getAcceptor(EnumFacing side) {
|
||||
return getTileEntity().getCachedAcceptor(side);
|
||||
}
|
||||
|
||||
@@ -78,12 +92,12 @@ public class TransmitterImpl<A, N extends DynamicNetwork<A, N>> extends Transmit
|
||||
}
|
||||
|
||||
@Override
|
||||
public N createEmptyNetwork() {
|
||||
public NETWORK createEmptyNetwork() {
|
||||
return getTileEntity().createNewNetwork();
|
||||
}
|
||||
|
||||
@Override
|
||||
public N getExternalNetwork(Coord4D from) {
|
||||
public NETWORK getExternalNetwork(Coord4D from) {
|
||||
TileEntity tile = from.getTileEntity(world());
|
||||
|
||||
if (CapabilityUtils.hasCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, null)) {
|
||||
@@ -91,7 +105,7 @@ public class TransmitterImpl<A, N extends DynamicNetwork<A, N>> extends Transmit
|
||||
.getCapability(tile, Capabilities.GRID_TRANSMITTER_CAPABILITY, null);
|
||||
|
||||
if (TransmissionType.checkTransmissionType(transmitter, getTransmissionType())) {
|
||||
return ((IGridTransmitter<A, N>) transmitter).getTransmitterNetwork();
|
||||
return ((IGridTransmitter<ACCEPTOR, NETWORK, BUFFER>) transmitter).getTransmitterNetwork();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,13 +122,20 @@ public class TransmitterImpl<A, N extends DynamicNetwork<A, N>> extends Transmit
|
||||
containingTile.updateShare();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getBuffer() {
|
||||
public BUFFER getBuffer() {
|
||||
return getTileEntity().getBuffer();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public N mergeNetworks(Collection<N> toMerge) {
|
||||
public BUFFER getBufferWithFallback() {
|
||||
return getTileEntity().getBufferWithFallback();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NETWORK mergeNetworks(Collection<NETWORK> toMerge) {
|
||||
return getTileEntity().createNetworkByMerging(toMerge);
|
||||
}
|
||||
|
||||
@@ -128,11 +149,11 @@ public class TransmitterImpl<A, N extends DynamicNetwork<A, N>> extends Transmit
|
||||
containingTile.sendDesc = true;
|
||||
}
|
||||
|
||||
public TileEntityTransmitter<A, N> getTileEntity() {
|
||||
public TileEntityTransmitter<ACCEPTOR, NETWORK, BUFFER> getTileEntity() {
|
||||
return containingTile;
|
||||
}
|
||||
|
||||
public void setTileEntity(TileEntityTransmitter<A, N> containingPart) {
|
||||
public void setTileEntity(TileEntityTransmitter<ACCEPTOR, NETWORK, BUFFER> containingPart) {
|
||||
this.containingTile = containingPart;
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public class TransporterImpl extends TransmitterImpl<TileEntity, InventoryNetwork> implements ILogisticalTransporter {
|
||||
public class TransporterImpl extends TransmitterImpl<TileEntity, InventoryNetwork, Void> implements ILogisticalTransporter {
|
||||
|
||||
private Map<Integer, TransporterStack> transit = new HashMap<>();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.energy.EnergyStack;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
@@ -20,7 +21,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class EnergyNetwork extends DynamicNetwork<EnergyAcceptorWrapper, EnergyNetwork> {
|
||||
public class EnergyNetwork extends DynamicNetwork<EnergyAcceptorWrapper, EnergyNetwork, EnergyStack> {
|
||||
|
||||
public double clientEnergyScale = 0;
|
||||
public EnergyStack buffer = new EnergyStack(0);
|
||||
@@ -34,15 +35,6 @@ public class EnergyNetwork extends DynamicNetwork<EnergyAcceptorWrapper, EnergyN
|
||||
public EnergyNetwork(Collection<EnergyNetwork> networks) {
|
||||
for (EnergyNetwork net : networks) {
|
||||
if (net != null) {
|
||||
if (net.jouleBufferLastTick > jouleBufferLastTick || net.clientEnergyScale > clientEnergyScale) {
|
||||
clientEnergyScale = net.clientEnergyScale;
|
||||
jouleBufferLastTick = net.jouleBufferLastTick;
|
||||
joulesTransmitted = net.joulesTransmitted;
|
||||
lastPowerScale = net.lastPowerScale;
|
||||
}
|
||||
|
||||
buffer.amount += net.buffer.amount;
|
||||
|
||||
adoptTransmittersAndAcceptorsFrom(net);
|
||||
net.deregister();
|
||||
}
|
||||
@@ -51,13 +43,31 @@ public class EnergyNetwork extends DynamicNetwork<EnergyAcceptorWrapper, EnergyN
|
||||
register();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adoptTransmittersAndAcceptorsFrom(EnergyNetwork net) {
|
||||
if (net.jouleBufferLastTick > jouleBufferLastTick || net.clientEnergyScale > clientEnergyScale) {
|
||||
clientEnergyScale = net.clientEnergyScale;
|
||||
jouleBufferLastTick = net.jouleBufferLastTick;
|
||||
joulesTransmitted = net.joulesTransmitted;
|
||||
lastPowerScale = net.lastPowerScale;
|
||||
}
|
||||
|
||||
buffer.amount += net.buffer.amount;
|
||||
super.adoptTransmittersAndAcceptorsFrom(net);
|
||||
}
|
||||
|
||||
public static double round(double d) {
|
||||
return Math.round(d * 10000) / 10000;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnergyStack getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorbBuffer(IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork> transmitter) {
|
||||
EnergyStack energy = (EnergyStack) transmitter.getBuffer();
|
||||
public void absorbBuffer(IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork, EnergyStack> transmitter) {
|
||||
EnergyStack energy = transmitter.getBuffer();
|
||||
buffer.amount += energy.amount;
|
||||
energy.amount = 0;
|
||||
}
|
||||
@@ -78,7 +88,7 @@ public class EnergyNetwork extends DynamicNetwork<EnergyAcceptorWrapper, EnergyN
|
||||
int numCables = transmitters.size();
|
||||
double reciprocalSum = 0;
|
||||
|
||||
for (IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork> cable : transmitters) {
|
||||
for (IGridTransmitter<EnergyAcceptorWrapper, EnergyNetwork, EnergyStack> cable : transmitters) {
|
||||
reciprocalSum += 1.0 / (double) cable.getCapacity();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.transmitters.DynamicNetwork;
|
||||
import mekanism.api.transmitters.IGridTransmitter;
|
||||
@@ -25,7 +26,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork> {
|
||||
public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork, FluidStack> {
|
||||
|
||||
public int transferDelay = 0;
|
||||
|
||||
@@ -47,21 +48,6 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork> {
|
||||
public FluidNetwork(Collection<FluidNetwork> networks) {
|
||||
for (FluidNetwork net : networks) {
|
||||
if (net != null) {
|
||||
if (net.buffer != null) {
|
||||
if (buffer == null) {
|
||||
buffer = net.buffer.copy();
|
||||
} else {
|
||||
if (buffer.getFluid() == net.buffer.getFluid()) {
|
||||
buffer.amount += net.buffer.amount;
|
||||
} else if (net.buffer.amount > buffer.amount) {
|
||||
buffer = net.buffer.copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
net.buffer = null;
|
||||
}
|
||||
|
||||
adoptTransmittersAndAcceptorsFrom(net);
|
||||
net.deregister();
|
||||
}
|
||||
@@ -73,15 +59,37 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorbBuffer(IGridTransmitter<IFluidHandler, FluidNetwork> transmitter) {
|
||||
Object b = transmitter.getBuffer();
|
||||
public void adoptTransmittersAndAcceptorsFrom(FluidNetwork net) {
|
||||
if (net.buffer != null) {
|
||||
if (buffer == null) {
|
||||
buffer = net.buffer.copy();
|
||||
} else {
|
||||
if (buffer.getFluid() == net.buffer.getFluid()) {
|
||||
buffer.amount += net.buffer.amount;
|
||||
} else if (net.buffer.amount > buffer.amount) {
|
||||
buffer = net.buffer.copy();
|
||||
}
|
||||
|
||||
if (!(b instanceof FluidStack) || ((FluidStack) b).getFluid() == null || ((FluidStack) b).amount == 0) {
|
||||
}
|
||||
|
||||
net.buffer = null;
|
||||
}
|
||||
super.adoptTransmittersAndAcceptorsFrom(net);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public FluidStack getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorbBuffer(IGridTransmitter<IFluidHandler, FluidNetwork, FluidStack> transmitter) {
|
||||
FluidStack fluid = transmitter.getBuffer();
|
||||
|
||||
if (fluid == null || fluid.getFluid() == null || fluid.amount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
FluidStack fluid = (FluidStack) b;
|
||||
|
||||
if (buffer == null || buffer.getFluid() == null || buffer.amount == 0) {
|
||||
buffer = fluid.copy();
|
||||
fluid.amount = 0;
|
||||
@@ -108,7 +116,7 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork> {
|
||||
int numCables = transmitters.size();
|
||||
double sum = 0;
|
||||
|
||||
for (IGridTransmitter<IFluidHandler, FluidNetwork> pipe : transmitters) {
|
||||
for (IGridTransmitter<IFluidHandler, FluidNetwork, FluidStack> pipe : transmitters) {
|
||||
sum += pipe.getCapacity();
|
||||
}
|
||||
|
||||
@@ -309,6 +317,17 @@ public class FluidNetwork extends DynamicNetwork<IFluidHandler, FluidNetwork> {
|
||||
return prevTransferAmount + " mB/t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatibleWith(FluidNetwork other) {
|
||||
return super.isCompatibleWith(other) && (this.buffer == null || other.buffer == null || this.buffer
|
||||
.isFluidEqual(other.buffer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compatibleWithBuffer(FluidStack buffer) {
|
||||
return super.compatibleWithBuffer(buffer) && (this.buffer == null || buffer == null || this.buffer.isFluidEqual(buffer));
|
||||
}
|
||||
|
||||
public static class FluidTransferEvent extends Event {
|
||||
|
||||
public final FluidNetwork fluidNetwork;
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
@@ -29,7 +30,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
*
|
||||
* @author aidancbrady
|
||||
*/
|
||||
public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> {
|
||||
public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork, GasStack> {
|
||||
|
||||
public int transferDelay = 0;
|
||||
|
||||
@@ -51,33 +52,6 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> {
|
||||
public GasNetwork(Collection<GasNetwork> networks) {
|
||||
for (GasNetwork net : networks) {
|
||||
if (net != null) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
if (net.refGas != null && net.gasScale > gasScale) {
|
||||
gasScale = net.gasScale;
|
||||
refGas = net.refGas;
|
||||
buffer = net.buffer;
|
||||
|
||||
net.gasScale = 0;
|
||||
net.refGas = null;
|
||||
net.buffer = null;
|
||||
}
|
||||
} else {
|
||||
if (net.buffer != null) {
|
||||
if (buffer == null) {
|
||||
buffer = net.buffer.copy();
|
||||
} else {
|
||||
if (buffer.isGasEqual(net.buffer)) {
|
||||
buffer.amount += net.buffer.amount;
|
||||
} else if (net.buffer.amount > buffer.amount) {
|
||||
buffer = net.buffer.copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
net.buffer = null;
|
||||
}
|
||||
}
|
||||
|
||||
adoptTransmittersAndAcceptorsFrom(net);
|
||||
net.deregister();
|
||||
}
|
||||
@@ -89,15 +63,48 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorbBuffer(IGridTransmitter<IGasHandler, GasNetwork> transmitter) {
|
||||
Object b = transmitter.getBuffer();
|
||||
public void adoptTransmittersAndAcceptorsFrom(GasNetwork net) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
|
||||
if (net.refGas != null && net.gasScale > gasScale) {
|
||||
gasScale = net.gasScale;
|
||||
refGas = net.refGas;
|
||||
buffer = net.buffer;
|
||||
|
||||
if (!(b instanceof GasStack) || ((GasStack) b).getGas() == null || ((GasStack) b).amount == 0) {
|
||||
net.gasScale = 0;
|
||||
net.refGas = null;
|
||||
net.buffer = null;
|
||||
}
|
||||
} else {
|
||||
if (net.buffer != null) {
|
||||
if (buffer == null) {
|
||||
buffer = net.buffer.copy();
|
||||
} else {
|
||||
if (buffer.isGasEqual(net.buffer)) {
|
||||
buffer.amount += net.buffer.amount;
|
||||
} else if (net.buffer.amount > buffer.amount) {
|
||||
buffer = net.buffer.copy();
|
||||
}
|
||||
|
||||
}
|
||||
net.buffer = null;
|
||||
}
|
||||
}
|
||||
super.adoptTransmittersAndAcceptorsFrom(net);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GasStack getBuffer() {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorbBuffer(IGridTransmitter<IGasHandler, GasNetwork, GasStack> transmitter) {
|
||||
GasStack gas = transmitter.getBuffer();
|
||||
|
||||
if (gas == null || gas.getGas() == null || gas.amount == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
GasStack gas = (GasStack) b;
|
||||
|
||||
if (buffer == null || buffer.getGas() == null || buffer.amount == 0) {
|
||||
buffer = gas.copy();
|
||||
gas.amount = 0;
|
||||
@@ -303,6 +310,18 @@ public class GasNetwork extends DynamicNetwork<IGasHandler, GasNetwork> {
|
||||
return prevTransferAmount + "/t";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCompatibleWith(GasNetwork other) {
|
||||
return super.isCompatibleWith(other) && (this.buffer == null || other.buffer == null || this.buffer
|
||||
.isGasEqual(other.buffer));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean compatibleWithBuffer(GasStack buffer) {
|
||||
return super.compatibleWithBuffer(buffer) && (this.buffer == null || buffer == null || this.buffer
|
||||
.isGasEqual(buffer));
|
||||
}
|
||||
|
||||
public static class GasTransferEvent extends Event {
|
||||
|
||||
public final GasNetwork gasNetwork;
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
//import mekanism.common.multipart.MultipartTransmitter;
|
||||
|
||||
public class HeatNetwork extends DynamicNetwork<IHeatTransfer, HeatNetwork> {
|
||||
public class HeatNetwork extends DynamicNetwork<IHeatTransfer, HeatNetwork, Void> {
|
||||
|
||||
public double meanTemp = 0;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class HeatNetwork extends DynamicNetwork<IHeatTransfer, HeatNetwork> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorbBuffer(IGridTransmitter<IHeatTransfer, HeatNetwork> transmitter) {
|
||||
public void absorbBuffer(IGridTransmitter<IHeatTransfer, HeatNetwork, Void> transmitter) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,7 +76,7 @@ public class HeatNetwork extends DynamicNetwork<IHeatTransfer, HeatNetwork> {
|
||||
double newHeatTransferred = 0;
|
||||
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
for (IGridTransmitter<IHeatTransfer, HeatNetwork> transmitter : transmitters) {
|
||||
for (IGridTransmitter<IHeatTransfer, HeatNetwork, Void> transmitter : transmitters) {
|
||||
if (transmitter instanceof TransmitterImpl && ((TransmitterImpl) transmitter).getTileEntity()
|
||||
.hasCapability(Capabilities.HEAT_TRANSFER_CAPABILITY, null)) {
|
||||
IHeatTransfer heatTransmitter = (IHeatTransfer) ((TransmitterImpl) transmitter).getTileEntity()
|
||||
@@ -87,7 +87,7 @@ public class HeatNetwork extends DynamicNetwork<IHeatTransfer, HeatNetwork> {
|
||||
}
|
||||
}
|
||||
|
||||
for (IGridTransmitter<IHeatTransfer, HeatNetwork> transmitter : transmitters) {
|
||||
for (IGridTransmitter<IHeatTransfer, HeatNetwork, Void> transmitter : transmitters) {
|
||||
if (transmitter instanceof TransmitterImpl && ((TransmitterImpl) transmitter).getTileEntity()
|
||||
.hasCapability(Capabilities.HEAT_TRANSFER_CAPABILITY, null)) {
|
||||
IHeatTransfer heatTransmitter = (IHeatTransfer) ((TransmitterImpl) transmitter).getTileEntity()
|
||||
|
||||
@@ -18,7 +18,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
|
||||
public class InventoryNetwork extends DynamicNetwork<TileEntity, InventoryNetwork> {
|
||||
public class InventoryNetwork extends DynamicNetwork<TileEntity, InventoryNetwork, Void> {
|
||||
|
||||
public InventoryNetwork() {
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class InventoryNetwork extends DynamicNetwork<TileEntity, InventoryNetwor
|
||||
}
|
||||
|
||||
@Override
|
||||
public void absorbBuffer(IGridTransmitter<TileEntity, InventoryNetwork> transmitter) {
|
||||
public void absorbBuffer(IGridTransmitter<TileEntity, InventoryNetwork, Void> transmitter) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.Upgrade;
|
||||
import mekanism.common.base.IFactory;
|
||||
import mekanism.common.base.IFactory.RecipeType;
|
||||
import mekanism.common.base.ITierItem;
|
||||
import mekanism.common.block.states.BlockStateBasic.BasicBlockType;
|
||||
import mekanism.common.block.states.BlockStateMachine.MachineType;
|
||||
@@ -47,8 +48,10 @@ public class RecipeUtils {
|
||||
|
||||
if (target.getItem() instanceof IFactory && input.getItem() instanceof IFactory) {
|
||||
if (isFactory(target) && isFactory(input)) {
|
||||
return ((IFactory) target.getItem()).getRecipeType(target) == ((IFactory) input.getItem())
|
||||
.getRecipeType(input);
|
||||
RecipeType recipeTypeInput = ((IFactory) input.getItem()).getRecipeTypeOrNull(input);
|
||||
//If either factory has invalid NBT don't crash it
|
||||
return recipeTypeInput != null
|
||||
&& ((IFactory) target.getItem()).getRecipeTypeOrNull(target) == recipeTypeInput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,9 @@ public class MekanismTools implements IModule {
|
||||
|
||||
@EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
//Load the config
|
||||
proxy.loadConfiguration();
|
||||
|
||||
addItems();
|
||||
}
|
||||
|
||||
@@ -104,9 +107,6 @@ public class MekanismTools implements IModule {
|
||||
//Register this class to the event bus for special mob spawning (mobs with Mekanism armor/tools)
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
//Load the proxy
|
||||
proxy.loadConfiguration();
|
||||
|
||||
//Finalization
|
||||
Mekanism.logger.info("Loaded 'Mekanism: Tools' module.");
|
||||
}
|
||||
@@ -147,10 +147,6 @@ public class MekanismTools implements IModule {
|
||||
armorSTEEL = getArmorMaterial("STEEL", MekanismConfig.current().tools.armorSTEEL,
|
||||
SoundEvents.ITEM_ARMOR_EQUIP_IRON);
|
||||
|
||||
if (Mekanism.configuration.hasChanged()) {
|
||||
Mekanism.configuration.save();
|
||||
}
|
||||
|
||||
ToolsItems.initializeItems();
|
||||
ToolsItems.setHarvestLevels();
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 4.1 KiB |
@@ -1,4 +1,7 @@
|
||||
{
|
||||
"textures": {
|
||||
"particle": "#glass"
|
||||
},
|
||||
"elements": [
|
||||
{
|
||||
"name": "RightGlass",
|
||||
|
||||
Reference in new issue
Block a user