-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: additional energy usage for patterns in the autocrafter
- Loading branch information
1 parent
30d00dc
commit add98dd
Showing
15 changed files
with
151 additions
and
57 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
...ge-common/src/main/java/com/refinedmods/refinedstorage/common/AbstractModInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 47 additions & 5 deletions
52
...n/java/com/refinedmods/refinedstorage/api/network/impl/node/relay/RelayComponentType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,50 @@ | ||
package com.refinedmods.refinedstorage.api.network.impl.node.relay; | ||
|
||
public enum RelayComponentType { | ||
ENERGY, | ||
SECURITY, | ||
STORAGE, | ||
AUTOCRAFTING | ||
import com.refinedmods.refinedstorage.api.core.NullableType; | ||
import com.refinedmods.refinedstorage.api.network.Network; | ||
import com.refinedmods.refinedstorage.api.network.autocrafting.AutocraftingNetworkComponent; | ||
import com.refinedmods.refinedstorage.api.network.energy.EnergyNetworkComponent; | ||
import com.refinedmods.refinedstorage.api.network.security.SecurityNetworkComponent; | ||
import com.refinedmods.refinedstorage.api.network.storage.StorageNetworkComponent; | ||
|
||
import java.util.Set; | ||
import java.util.function.Consumer; | ||
import java.util.function.Function; | ||
|
||
public class RelayComponentType<T> { | ||
public static final RelayComponentType<EnergyNetworkComponent> ENERGY = new RelayComponentType<>( | ||
network -> network.getComponent(EnergyNetworkComponent.class), | ||
output -> output::setEnergyDelegate | ||
); | ||
public static final RelayComponentType<SecurityNetworkComponent> SECURITY = new RelayComponentType<>( | ||
network -> network.getComponent(SecurityNetworkComponent.class), | ||
output -> output::setSecurityDelegate | ||
); | ||
public static final RelayComponentType<StorageNetworkComponent> STORAGE = new RelayComponentType<>( | ||
network -> network.getComponent(StorageNetworkComponent.class), | ||
output -> output::setStorageDelegate | ||
); | ||
public static final RelayComponentType<AutocraftingNetworkComponent> AUTOCRAFTING = new RelayComponentType<>( | ||
network -> network.getComponent(AutocraftingNetworkComponent.class), | ||
output -> output::setAutocraftingDelegate | ||
); | ||
public static final Set<RelayComponentType<?>> ALL = Set.of(ENERGY, SECURITY, STORAGE, AUTOCRAFTING); | ||
|
||
private final Function<Network, T> componentProvider; | ||
private final Function<RelayOutputNetworkNode, Consumer<@NullableType T>> componentApplier; | ||
|
||
private RelayComponentType(final Function<Network, T> componentProvider, | ||
final Function<RelayOutputNetworkNode, Consumer<@NullableType T>> componentApplier) { | ||
this.componentProvider = componentProvider; | ||
this.componentApplier = componentApplier; | ||
} | ||
|
||
void apply(final Network network, final RelayOutputNetworkNode output) { | ||
final T component = componentProvider.apply(network); | ||
componentApplier.apply(output).accept(component); | ||
} | ||
|
||
void remove(final RelayOutputNetworkNode output) { | ||
componentApplier.apply(output).accept(null); | ||
} | ||
} |
Oops, something went wrong.