Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PipeNet rewrite #2304

Open
wants to merge 168 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
f15f9d7
Shadow JGraphT
M-W-K Dec 14, 2023
2e1fee9
First batch of work
M-W-K Dec 14, 2023
610ed17
Second batch of work, API backbone complete?
M-W-K Dec 15, 2023
c14719e
Add NetGroups to reduce algorithm overhead
M-W-K Dec 15, 2023
4310e10
INodeData to allow for calculating edge weights
M-W-K Dec 15, 2023
65ccf24
Downgrade JGraphT to 1.4 for Java 8 compatibility, and a minor fix
M-W-K Dec 15, 2023
3318506
Improve path caching & fetching
M-W-K Dec 17, 2023
de9f555
Added INodeData math
M-W-K Dec 17, 2023
72a3955
Inefficient syntax begone
M-W-K Dec 17, 2023
e54c467
Running around putting out fires & applying spotless
M-W-K Dec 17, 2023
f487042
Pain and suffering (also fixed item pipe nets?)
M-W-K Dec 17, 2023
7b3982c
Directed graphing, cover predicates (if you squint), and more!
M-W-K Dec 18, 2023
2cf45ba
Final item pipenet cleanup
M-W-K Dec 18, 2023
31af627
Allow control over directed graphing
M-W-K Dec 18, 2023
3bdad1f
laughs in someone else's typo
M-W-K Dec 18, 2023
13b204c
API for single-path networks, converted optical and laser.
M-W-K Dec 18, 2023
55827da
Wait, the fluid net doesn't exist?
M-W-K Dec 18, 2023
cacb049
Finish converting the energy net (central monitor is angry)
M-W-K Dec 19, 2023
493ecaf
Lobotomized central monitor
M-W-K Dec 19, 2023
f4ff075
That took far too much work.
M-W-K Dec 20, 2023
f3bb292
Misc improvements so that the item net works properly.
M-W-K Dec 21, 2023
42ed146
Stack overflow moment
M-W-K Dec 21, 2023
f7955c9
Oops.
M-W-K Dec 21, 2023
9d4e2a2
More stack overflow, yay!
M-W-K Dec 21, 2023
3dc22d7
Deprecation of now obsolete API
M-W-K Dec 21, 2023
026bad7
Remove them spots
M-W-K Dec 21, 2023
7e300a2
Old world compat
M-W-K Dec 21, 2023
6af7e66
Less invasive & more generalized solution to stack overflow
M-W-K Dec 21, 2023
1fa8dbd
Fix NodeData not setting correctly for material pipes
M-W-K Dec 21, 2023
6eba12f
Fix old net conversion setting incorrect edge weights
M-W-K Dec 21, 2023
62d3ac5
Fix central monitor
M-W-K Dec 21, 2023
08aebe6
I didn't spotless the central monitor ;-;
M-W-K Dec 27, 2023
87e6c44
This is all your fault Tech
M-W-K Dec 27, 2023
1031cf2
Merge branch 'master' into graphed-pipenet
M-W-K Dec 29, 2023
a36147c
Merge branch 'master' into graphed-pipenet
M-W-K Jan 15, 2024
a432310
Various refactors & prep for nonticking fluid pipes
M-W-K Jan 17, 2024
e5f4a19
Fluid channels mostly done
M-W-K Jan 18, 2024
abb4edf
Merge remote-tracking branch 'origin/graphed-pipenet' into graphed-pi…
M-W-K Jan 18, 2024
6d8574a
Fluid channels done question mark
M-W-K Jan 19, 2024
2470f9f
Ensure nodes have a group on query
M-W-K Jan 19, 2024
8b4e2c2
Channel sink cover checks
M-W-K Jan 19, 2024
1072796
Channel - group integration
M-W-K Jan 20, 2024
e91fb37
Oh yea, spotless exists
M-W-K Jan 20, 2024
a7d2b48
Sink registration
M-W-K Jan 20, 2024
28c01cb
Remove some unnecessary things
M-W-K Jan 20, 2024
fd8d17c
Move stuff from tickable Fpipe class to normal Fpipe class
M-W-K Jan 22, 2024
c00ee72
Ticker (wait I thought this was supposed to be tickless)
M-W-K Jan 22, 2024
886bad4
Prevent nbt contamination by flow net calculation helpers
M-W-K Jan 23, 2024
fcd2c92
Improve ticker & spotlessify
M-W-K Jan 23, 2024
bb55064
Fix undirected flow nets not using the proper edge weight fetcher
M-W-K Jan 23, 2024
6148b69
Implement fluidpipe channel capacity scaling
M-W-K Jan 23, 2024
ab6c9ab
Bunch of fixes (but not enough)
M-W-K Feb 10, 2024
4e15156
More fixes & improvements
M-W-K Feb 11, 2024
6fc0e9c
Merge branch 'master' into graphed-pipenet
M-W-K Feb 11, 2024
52ee100
Fix nodes not deregistering killed channels
M-W-K Feb 12, 2024
c101711
Merge branch 'master' into graphed-pipenet
M-W-K Feb 24, 2024
f9dd458
Merge remote-tracking branch 'origin/master' into graphed-pipenet
M-W-K May 31, 2024
46616d0
Curse you Ghz
M-W-K May 31, 2024
feb830a
Fluid predicates
M-W-K May 31, 2024
1b63dfd
Fix a potential issue with predication
M-W-K May 31, 2024
1e93ca0
Spotless
M-W-K May 31, 2024
7e4a281
Fix issue with initialization of predicates
M-W-K Jun 4, 2024
8cbb972
flow improvements
M-W-K Jun 4, 2024
0886a4c
Truly Tickless fluid piping (pain)
M-W-K Jun 19, 2024
6e69da5
Fixes
M-W-K Jun 19, 2024
f9e18d7
The Great Generification (and spotless)
M-W-K Jun 19, 2024
801563f
misc
M-W-K Jun 21, 2024
044f325
Energy net overhaul
M-W-K Jun 23, 2024
559f63c
inflow edges & spotless
M-W-K Jun 25, 2024
9fc3e79
adjust cable heating behavior
M-W-K Jun 25, 2024
a920346
fluid net improvements
M-W-K Jun 26, 2024
6adfa6b
iteratorification
M-W-K Jun 27, 2024
569f23a
nth time running spotless
M-W-K Jun 27, 2024
da26fe7
misc improvements & fixes
M-W-K Jun 27, 2024
5f6c9f1
Fix weird compile failure issue
M-W-K Jun 27, 2024
d24b2d4
refactor
M-W-K Jun 27, 2024
907526c
fix energy net overamping
M-W-K Jun 28, 2024
d694934
Fully realized dynamic temp limits for cables
M-W-K Jun 28, 2024
2d24e73
spotless
M-W-K Jun 28, 2024
d5f3dd7
Complete rewrite pt1
M-W-K Jul 11, 2024
59309cb
Complete rewrite pt2
M-W-K Jul 13, 2024
b893b42
Complete rewrite pt3
M-W-K Jul 16, 2024
3c7fc39
Complete rewrite pt4
M-W-K Jul 18, 2024
f8c591d
Complete rewrite pt5
M-W-K Jul 26, 2024
aa8053f
Complete rewrite pt6
M-W-K Jul 27, 2024
e406f6b
Complete rewrite pt7
M-W-K Jul 28, 2024
dab9fbf
Compilable edition
M-W-K Jul 28, 2024
7a32d3e
Spotless edition
M-W-K Jul 28, 2024
cae5f3e
stability fixes
M-W-K Jul 28, 2024
7e0c6bb
baffled by normals
M-W-K Jul 30, 2024
f1abfec
Functional normals. Also some misc fixes.
M-W-K Jul 31, 2024
50cf37e
fixes & improvements
M-W-K Aug 1, 2024
570da02
refactors and improvements
M-W-K Aug 3, 2024
5a10bb3
Cover rendering & misc other
M-W-K Aug 4, 2024
d240268
misc improvements
M-W-K Aug 7, 2024
6febda5
Cover-controlled traversal
M-W-K Aug 11, 2024
695a1ab
Spotless
M-W-K Aug 11, 2024
c778444
Tile Interface
M-W-K Aug 11, 2024
93ffdc8
Bendy lasers & small improvements
M-W-K Aug 11, 2024
cf5857c
Overdue shuffling
M-W-K Aug 11, 2024
9d62953
Merge remote-tracking branch 'origin/master' into graphed-pipenet
M-W-K Aug 11, 2024
358758c
Fix pipe autoconnection to mtes & spotless
M-W-K Aug 11, 2024
ce0c597
address review
M-W-K Aug 11, 2024
fc1c35e
Oops
M-W-K Aug 11, 2024
d26a3e8
Review stuff I missed
M-W-K Aug 12, 2024
4df3020
Fix tricorder reporting of EU flow through cables
M-W-K Aug 12, 2024
b5ce31f
spotless
M-W-K Aug 12, 2024
0df5464
Fix round robin behavior
M-W-K Aug 13, 2024
c54d8f2
Remove unecessary generalization
M-W-K Aug 14, 2024
6f0fd56
Tweaks to logic data handling
M-W-K Aug 14, 2024
28a2752
Misc improvements and fix #2582
M-W-K Aug 15, 2024
b5e1ab7
Fix some very large issues
M-W-K Aug 17, 2024
fbdb32d
Add misc. frame logic
M-W-K Aug 21, 2024
b35af25
Merge remote-tracking branch 'upstream/master' into graphed-pipenet
M-W-K Aug 21, 2024
bdb51f3
Better weak sets
M-W-K Aug 23, 2024
b886cf1
New model registry
M-W-K Aug 23, 2024
522c2f9
Fix instances of me being stupid
M-W-K Aug 25, 2024
1adb2a6
Fix MultiNodeHelper
M-W-K Aug 25, 2024
134566f
Misc improvements & fixes
M-W-K Aug 25, 2024
df877e3
Merge remote-tracking branch 'upstream/master' into graphed-pipenet
M-W-K Aug 25, 2024
5f9760c
Split of world handling & world pos handling
M-W-K Aug 27, 2024
dcb9587
Reference tweaks
M-W-K Aug 29, 2024
689b20e
Annotation
M-W-K Aug 31, 2024
b8aa223
Misc fixes
M-W-K Sep 4, 2024
40950cc
Actually fix quad UVs
M-W-K Sep 4, 2024
8a210b3
Make quad recoloring smarter
M-W-K Sep 4, 2024
65d0051
spotless
M-W-K Sep 4, 2024
40b1cb7
me when I don't null check
M-W-K Sep 5, 2024
e37a1b2
Fix a minor mistake
M-W-K Sep 5, 2024
7848291
Fix misc stuff
M-W-K Sep 5, 2024
ff72f20
More fixes
M-W-K Sep 5, 2024
9e9d0a2
More fixes yey
M-W-K Sep 5, 2024
4b453f9
Accumulated fixes & TOP improvements
M-W-K Sep 6, 2024
0a9d473
Improve TOP formatting
M-W-K Sep 6, 2024
44d0214
Tooltip names
M-W-K Sep 6, 2024
df73818
Unconductive pipes & fix some temperature stuff
M-W-K Sep 6, 2024
65094e7
FluidStackElement for TOP
TechLord22 Sep 6, 2024
eb8cba2
Fix issues with cable burning & more
M-W-K Sep 6, 2024
b1e37c5
Me when I don't test something
M-W-K Sep 7, 2024
fc8094d
anti insert-to-our-source logic
M-W-K Sep 7, 2024
620f73f
Fix weak sets
M-W-K Sep 7, 2024
a7e6e80
Refactory data query logic
M-W-K Sep 7, 2024
40986a0
Move things with filters onto the net level
M-W-K Sep 7, 2024
b9abfbb
Tentative datafix edge rebuilding system
M-W-K Sep 7, 2024
c9fc15e
Prevent endless recursion on datafix
M-W-K Sep 7, 2024
ea3a84a
data fixers
TechLord22 Sep 8, 2024
90d40b6
Tiny fixes
M-W-K Sep 8, 2024
6440b0c
min length tubes
M-W-K Sep 9, 2024
47fdeb5
Merge remote-tracking branch 'main/master' into graphed-pipenet
M-W-K Sep 9, 2024
ee873ce
Merge remote-tracking branch 'main/master' into graphed-pipenet
M-W-K Sep 9, 2024
e36a45e
Fix tests
M-W-K Sep 9, 2024
1d787a8
Laser mirror cable recipe
M-W-K Sep 9, 2024
796e1ae
Fix material tree
M-W-K Sep 9, 2024
3eb8276
recipe adjustments
TechLord22 Sep 9, 2024
7f76d01
tooltip improvements and cleanup
TechLord22 Sep 10, 2024
659162a
Logic types & event-driven registration
M-W-K Sep 10, 2024
3dfb46f
New energy net impl (broken commit)
M-W-K Oct 26, 2024
6e294e4
stuff
M-W-K Nov 29, 2024
1db5648
Stuff, pt2
M-W-K Dec 5, 2024
0537c11
spotless
M-W-K Dec 5, 2024
b1fc4a9
covers & cleanup to compile :lets:
M-W-K Dec 20, 2024
67552a8
Fix issues I thought of in my sleep
M-W-K Dec 20, 2024
eb88875
pain
M-W-K Dec 21, 2024
ed3324a
Yeet some streams
M-W-K Dec 21, 2024
559ff49
Breakthrough on flood traverse; covers soon.tm
M-W-K Dec 22, 2024
8e0b84c
covers working and misc bugs patched
M-W-K Dec 24, 2024
7d43f8c
Improved caching
M-W-K Dec 25, 2024
6b71cb6
Fix temperature logic and allow iridium to carry l. helium
M-W-K Dec 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix tricorder reporting of EU flow through cables
  • Loading branch information
M-W-K committed Aug 12, 2024
commit 4df3020b100f9eec94035b273ff62135a47286e1
Original file line number Diff line number Diff line change
Expand Up @@ -466,11 +466,7 @@ public void addCollisionBoxToList(@NotNull IBlockState state, @NotNull World wor
@Nullable Entity entityIn, boolean isActualState) {
PipeTileEntity tile = getTileEntity(worldIn, pos);
if (tile != null) {
if (hasPipeCollisionChangingItem(worldIn, pos, entityIn)) {
addCollisionBoxToList(pos, entityBox, collidingBoxes, FULL_BLOCK_AABB);
} else {
tile.getCoverBoxes(bb -> addCollisionBoxToList(pos, entityBox, collidingBoxes, bb));
}
tile.getCoverBoxes(bb -> addCollisionBoxToList(pos, entityBox, collidingBoxes, bb));
if (tile.getFrameMaterial() != null) {
addCollisionBoxToList(pos, entityBox, collidingBoxes, BlockFrame.COLLISION_BOX);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import gregtech.api.GregTechAPI;
import gregtech.api.capability.GregtechTileCapabilities;
import gregtech.api.cover.Cover;
import gregtech.api.graphnet.IGraphNet;
import gregtech.api.graphnet.logic.NetLogicData;
import gregtech.api.graphnet.logic.NetLogicEntry;
import gregtech.api.graphnet.logic.NetLogicRegistry;
Expand Down Expand Up @@ -431,8 +430,8 @@ public <T> T getCapability(@NotNull Capability<T> capability, @Nullable EnumFaci

// data sync management //

public NetLogicData getNetLogicData(IGraphNet net) {
return netLogicDatas.get(net.getNetworkID());
public NetLogicData getNetLogicData(int networkID) {
return netLogicDatas.get(networkID);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ default long getFlowLimit(@NotNull AbstractNetFlowEdge edge) {
* @param consumption the amount to consume from the edge's flow limit.
*/
@MustBeInvokedByOverriders
default void consumeFlowLimit(@NotNull AbstractNetFlowEdge edge, NetNode targetNode, long consumption) {
default void consumeFlowLimit(@NotNull AbstractNetFlowEdge edge, NetNode sourceNode, NetNode targetNode, long consumption) {
edge.consumeFlowLimit(this.getTestObject(), this.getGraphNet(), consumption, this.getQueryTick(),
this.getSimulatorKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ D extends ITraverseData<N, P>> long traverseFlood(

for (int i = 0; i < edges.size(); i++) {
E edge = edges.get(i);
N sourceNode = nodes.get(i);
N targetNode = nodes.get(i + 1);

if (targetNode.traverse(data.getQueryTick(), true)) {
Expand All @@ -69,7 +70,7 @@ D extends ITraverseData<N, P>> long traverseFlood(
} else continue pathloop;

pathFlow = Math.min(data.getFlowLimit(edge), pathFlow);
stack.add(flow -> data.consumeFlowLimit(edge, targetNode, flow),
stack.add(flow -> data.consumeFlowLimit(edge, sourceNode, targetNode, flow),
data.traverseToNode(targetNode, pathFlow));
pathFlow = stack.applyLatestLossFunction(pathFlow);

Expand Down Expand Up @@ -126,6 +127,7 @@ D extends ITraverseData<N, P>> long traverseDumb(

for (int i = 0; i < edges.size(); i++) {
E edge = edges.get(i);
N sourceNode = nodes.get(i);
N targetNode = nodes.get(i + 1);

if (targetNode.traverse(data.getQueryTick(), true)) {
Expand All @@ -145,7 +147,7 @@ D extends ITraverseData<N, P>> long traverseDumb(
if (finalOverflow > 0) overflowListener.accept(targetNode, finalOverflow);
});
}
stack.add(flow -> data.consumeFlowLimit(flowEdge, targetNode, flow),
stack.add(flow -> data.consumeFlowLimit(flowEdge, sourceNode, targetNode, flow),
data.traverseToNode(targetNode, pathFlow));
pathFlow = stack.applyLatestLossFunction(pathFlow);
}
Expand Down Expand Up @@ -265,6 +267,7 @@ D extends ITraverseData<N, P> & IEqualizableTraverseData<N, P>> long traverseEqu

for (int i = 0; i < edges.size(); i++) {
E edge = edges.get(i);
N sourceNode = nodes.get(i);
N targetNode = nodes.get(i + 1);

if (targetNode.traverse(data.getQueryTick(), true)) {
Expand All @@ -274,7 +277,7 @@ D extends ITraverseData<N, P> & IEqualizableTraverseData<N, P>> long traverseEqu
} else continue pathloop;

pathFlow = Math.min(data.getFlowLimit(edge), pathFlow);
stack.add(flow -> data.consumeFlowLimit(edge, targetNode, flow),
stack.add(flow -> data.consumeFlowLimit(edge, sourceNode, targetNode, flow),
data.traverseToNode(targetNode, pathFlow));
pathFlow = stack.applyLatestLossFunction(pathFlow);

Expand Down Expand Up @@ -436,6 +439,7 @@ D extends ITraverseData<N, P> & IRoundRobinTraverseData<N, P>> long rrTraverse(

for (int i = 0; i < edges.size(); i++) {
E edge = edges.get(i);
N sourceNode = nodes.get(i);
N targetNode = nodes.get(i + 1);

if (targetNode.traverse(data.getQueryTick(), true)) {
Expand All @@ -445,7 +449,8 @@ D extends ITraverseData<N, P> & IRoundRobinTraverseData<N, P>> long rrTraverse(
} else return strict ? -1 : 0;

pathFlow = Math.min(data.getFlowLimit(edge), pathFlow);
stack.add(flow -> data.consumeFlowLimit(edge, targetNode, flow), data.traverseToNode(targetNode, pathFlow));
stack.add(flow -> data.consumeFlowLimit(edge, sourceNode, targetNode, flow),
data.traverseToNode(targetNode, pathFlow));
pathFlow = stack.applyLatestLossFunction(pathFlow);

if (pathFlow <= 0) return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import gregtech.api.capability.IEnergyContainer;
import gregtech.api.capability.IWorkable;
import gregtech.api.capability.impl.FluidTankList;
import gregtech.api.graphnet.logic.NetLogicData;
import gregtech.api.graphnet.pipenet.WorldPipeNetNode;
import gregtech.api.graphnet.pipenet.physical.tile.PipeTileEntity;
import gregtech.api.items.metaitem.stats.IItemBehaviour;
import gregtech.api.metatileentity.IDataInfoProvider;
Expand All @@ -18,6 +20,9 @@
import gregtech.api.util.TextFormattingUtil;
import gregtech.api.worldgen.bedrockFluids.BedrockFluidVeinHandler;
import gregtech.common.ConfigHolder;
import gregtech.common.pipelike.net.energy.EnergyFlowData;
import gregtech.common.pipelike.net.energy.EnergyFlowLogic;
import gregtech.common.pipelike.net.energy.WorldEnergyNet;
import gregtech.core.sound.GTSoundEvents;

import net.minecraft.block.Block;
Expand All @@ -41,6 +46,7 @@
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidTank;
import net.minecraftforge.fml.common.FMLCommonHandler;

import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -277,6 +283,39 @@ else if (metaTileEntity instanceof IDataInfoProvider)
TextFormattingUtil.formatNumbers(block.getMetaFromState(world.getBlockState(pos))))
.setStyle(new Style().setColor(TextFormatting.BLUE))));
}
NetLogicData data = pipeTile.getNetLogicData(WorldEnergyNet.getWorldNet(world).getNetworkID());
if (data != null) {
int cumulativeCount = 0;
long cumulativeVoltage = 0;
long cumulativeAmperage = 0;
for (var memory : data.getLogicEntryDefaultable(EnergyFlowLogic.INSTANCE).getMemory().entrySet()) {
cumulativeCount++;
int count = 0;
double voltage = 0;
long amperage = 0;
for (EnergyFlowData flow : memory.getValue()) {
count++;
long prev = amperage;
amperage += flow.amperage();
// weighted average
voltage = voltage * prev / amperage + (double) (flow.voltage() * flow.amperage()) / amperage;
}
if (count != 0) {
cumulativeVoltage += voltage / count;
cumulativeAmperage += amperage / count;
}
}
if (cumulativeCount != 0) {
cumulativeVoltage /= cumulativeCount;
cumulativeAmperage /= cumulativeCount;
}
list.add(new TextComponentTranslation("behavior.tricorder.eut_per_sec",
new TextComponentTranslation(TextFormattingUtil.formatNumbers(cumulativeVoltage))
.setStyle(new Style().setColor(TextFormatting.RED))));
list.add(new TextComponentTranslation("behavior.tricorder.amp_per_sec",
new TextComponentTranslation(TextFormattingUtil.formatNumbers(cumulativeAmperage))
.setStyle(new Style().setColor(TextFormatting.RED))));
}

// pipe-specific info
if (tileEntity instanceof IDataInfoProvider provider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ private EnergyGroupData getEnergyData() {
@Override
public long getInputAmperage() {
if (tile == null) return 0;
return tile.getNetLogicData(net).getLogicEntryDefaultable(ThroughputLogic.INSTANCE).getValue();
return tile.getNetLogicData(net.getNetworkID()).getLogicEntryDefaultable(ThroughputLogic.INSTANCE).getValue();
}

@Override
public long getInputVoltage() {
if (tile == null) return 0;
return tile.getNetLogicData(net).getLogicEntryDefaultable(VoltageLimitLogic.INSTANCE).getValue();
return tile.getNetLogicData(net.getNetworkID()).getLogicEntryDefaultable(VoltageLimitLogic.INSTANCE).getValue();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ protected EnergyFlowLogic() {
super("EnergyFlow");
}

public @NotNull Long2ObjectOpenHashMap<List<EnergyFlowData>> getMemory() {
return memory;
}

public @NotNull List<EnergyFlowData> getFlow(long tick) {
return memory.getOrDefault(tick, Collections.emptyList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,27 @@ public long finalizeAtDestination(@NotNull WorldPipeNetNode destination, long fl
destination.getGroupSafe().getData() instanceof EnergyGroupData data) {
data.addEnergyOutPerSec(accepted * pathVoltage, getQueryTick());
}
if (accepted > 0) recordFlow(destination, accepted);
return accepted;
}

@Override
public void consumeFlowLimit(@NotNull AbstractNetFlowEdge edge, NetNode targetNode, long consumption) {
super.consumeFlowLimit(edge, targetNode, consumption);
EnergyFlowLogic logic = targetNode.getData().getLogicEntryNullable(EnergyFlowLogic.INSTANCE);
public void consumeFlowLimit(@NotNull AbstractNetFlowEdge edge, NetNode sourceNode, NetNode targetNode, long consumption) {
super.consumeFlowLimit(edge, sourceNode, targetNode, consumption);
if (consumption > 0) recordFlow(sourceNode, consumption);
}

private void recordFlow(@NotNull NetNode node, long amperes) {
EnergyFlowLogic logic = node.getData().getLogicEntryNullable(EnergyFlowLogic.INSTANCE);
if (logic == null) {
logic = EnergyFlowLogic.INSTANCE.getNew();
targetNode.getData().setLogicEntry(logic);
node.getData().setLogicEntry(logic);
}
logic.recordFlow(getQueryTick(), new EnergyFlowData(consumption, pathVoltage));
logic.recordFlow(getQueryTick(), new EnergyFlowData(amperes, pathVoltage));
}



private static int calculateHeatV(long amperage, long voltage, long maxVoltage) {
return (int) (amperage * (Math.log1p(Math.log((double) voltage / maxVoltage)) * 45 + 36.5));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,14 @@ public long finalizeAtDestination(@NotNull WorldPipeNetNode destination, long fl
(int) Math.min(Integer.MAX_VALUE, availableFlow), container, getSimulatorKey() == null);
}
}
return flowReachingDestination - availableFlow;
long accepted = flowReachingDestination - availableFlow;
temperatureUpdates.getOrDefault(destination, l -> {}).accept(accepted);
return accepted;
}

@Override
public void consumeFlowLimit(@NotNull AbstractNetFlowEdge edge, NetNode targetNode, long consumption) {
super.consumeFlowLimit(edge, targetNode, consumption);
temperatureUpdates.getOrDefault(targetNode, l -> {}).accept(consumption);
public void consumeFlowLimit(@NotNull AbstractNetFlowEdge edge, NetNode sourceNode, NetNode targetNode, long consumption) {
super.consumeFlowLimit(edge, sourceNode, targetNode, consumption);
temperatureUpdates.getOrDefault(sourceNode, l -> {}).accept(consumption);
}
}
Loading