Skip to content

Commit fe739bc

Browse files
committed
Multiblock validator performance improvements
1 parent 057a2f5 commit fe739bc

File tree

30 files changed

+287
-183
lines changed

30 files changed

+287
-183
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ dependencies {
112112
implementation 'org.spongepowered:mixin:0.8.5'
113113
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}"
114114

115-
compileOnly fg.deobf("com.gregtechceu.gtceu:gtceu-${mc_version}:${gtm_version}"){
115+
implementation fg.deobf("com.gregtechceu.gtceu:gtceu-${mc_version}:${gtm_version}"){
116116
transitive = false
117117
}
118118

@@ -128,7 +128,7 @@ dependencies {
128128
implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}") {
129129
transitive = false
130130
}*/
131-
implementation fg.deobf("curse.maven:multi-builder-tool-827020:6877370")
131+
implementation fg.deobf("curse.maven:multi-builder-tool-827020:7041820")
132132
runtimeOnly fg.deobf("curse.maven:ctm-267602:5983309")
133133
compileOnly fg.deobf("curse.maven:immersive-engineering-231951:5224387")
134134
implementation fg.deobf("curse.maven:thermal-foundation-222880:5443583")

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ org.gradle.daemon=true
55
org.gradle.parallel=true
66
org.gradle.caching=true
77

8-
mod_version=1.2.9
8+
mod_version=1.2.10
99

1010
mc_version=1.20.1
1111
mappings_version=2023.09.03
@@ -25,4 +25,4 @@ ctm_version=1.1.6+8
2525
kubejs_version=2001.6.5-build.16
2626
rhino_version=2001.2.3-build.6
2727
architectury_version=9.2.14
28-
gtm_version=1.6.4
28+
gtm_version=7.2.0

src/generated/resources/assets/nuclearcraft/lang/en_us.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2564,14 +2564,17 @@
25642564
"report.nc.1.accelerator.valid_coolers": "Valid Coolers: %s",
25652565
"report.nc.1.fusion_size": "Fusion Reactor Size: %s",
25662566
"report.nc.1.reactor_all_moderators": "All Moderators: %s",
2567+
"report.nc.1.stabilizers": "Stabilizers: %s",
25672568
"report.nc.1.target_chamber.all_detectors": "All Detectors: %s",
25682569
"report.nc.1.target_chamber.valid_detectors": "Valid Detectors: %s",
25692570
"report.nc.10.reactor_fuel_cells": "Fuel Cells: %s",
25702571
"report.nc.11.has_recipe": "Has Recipe: %s",
2572+
"report.nc.2.flux_regulators": "Flux Regulators: %s",
25712573
"report.nc.2.magnets": "Magnets: %s",
25722574
"report.nc.2.reactor_moderators": "Valid Moderators: %s",
25732575
"report.nc.3.amplifiers": "RF Amplifiers: %s",
25742576
"report.nc.3.reactor_moderator_attachments": "Moderator Attachments: %s",
2577+
"report.nc.3.transformers": "Transformers: %s",
25752578
"report.nc.4.fusion_rf_amplification": "RF Amplification: %s",
25762579
"report.nc.4.reactor_all_heat_sinks": "All Heat Sinks: %s",
25772580
"report.nc.5.casing_blocks": "Casing Blocks: %s",
@@ -2713,7 +2716,7 @@
27132716
"tooltip.nc.reactor.plasma_optimal": "Optimal: %s K",
27142717
"tooltip.nc.reactor.ready": "Ready",
27152718
"tooltip.nc.reactor.running": "Activation: %s",
2716-
"tooltip.nc.report_issue": "Report a Bug",
2719+
"tooltip.nc.report_issue": "Copy link to post a bug",
27172720
"tooltip.nc.rf_amplifier.efficiency": "Efficiency: %s%%",
27182721
"tooltip.nc.rf_amplifier.heat": "Heat: %s H/t",
27192722
"tooltip.nc.rf_amplifier.max_temp": "Max Temperature: %s K",

src/main/java/igentuman/nc/block/entity/MultiblockBuilderBE.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ public void tickClient() {
5050
BlockOverlayHandler.addBoxToOutline(boundingBox, 0.5f, 0.9f, 0.9f, 0.8f, getBlockPos().relative(getFacing().getOpposite(), offset));
5151
}
5252

53-
public void tickServer() {
54-
if (currentTick % 2 == 0) {
55-
return;
56-
}
57-
}
58-
5953
public void setBlockMap(HashMap<BlockPos, Block> blockMap) {
6054
if (getLevel().isClientSide()) {
6155
removeOverlayBox();

src/main/java/igentuman/nc/block/entity/processor/NCProcessorBE.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ public void tickServer() {
392392
}
393393
boolean updated = forceUpdate();
394394
boolean wasActive = isActive;
395+
//if no recipe - tick only 5 times per second
396+
if(!hasRecipe() && level.getGameTime() % 5 == 0) {
397+
return;
398+
}
395399
processRecipe();
396400
handleRecipeOutput();
397401
updated = updated || contentHandler().tick();

src/main/java/igentuman/nc/block/fission/entity/FissionPortBE.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public void tickServer() {
9393
if(getMultiblock() != null && controller() != null) {
9494
sendOutPower();
9595
}
96+
//if no recipe - tick only 5 times per second
97+
if(currentTick % 5 == 0 && controller() != null && !controller().hasRecipe()) {
98+
return;
99+
}
96100
boolean updated = updateController();
97101
if(currentTick % 20 == 0 && controller() != null) {
98102
pushPull();
@@ -155,7 +159,7 @@ protected void transferEnergyToSide(Direction direction) {
155159
}
156160
int wasEnergy = getEnergyStored();
157161
BlockEntity be = level.getExistingBlockEntity(worldPosition.relative(direction));
158-
if (be == null || be instanceof FissionPortBE) {
162+
if (be == null || be instanceof FissionPortBE || be instanceof FissionControllerBE) {
159163
return;
160164
}
161165
if((isGtLoaded() && isGTEUCapEnabled())) {

src/main/java/igentuman/nc/block/fusion/entity/FusionCoreBE.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ public void tickServer() {
400400
}
401401

402402
private void tickProxyBlocks() {
403+
//if no recipe - tick only 5 times per second
404+
if(!hasRecipe() && currentTick % 5 == 0) {
405+
return;
406+
}
403407
for(FusionCoreProxyBE proxy: getProxies()) {
404408
if(proxy == null) continue;
405409
proxy.forceTickServer(this);

src/main/java/igentuman/nc/block/fusion/entity/FusionCoreProxyBE.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ public void tickServer()
8787
level.removeBlock(worldPosition, false);
8888
return;
8989
}
90-
90+
//if no recipe - tick only 5 times per second
91+
if(currentTick % 5 == 0 && !core.hasRecipe()) {
92+
return;
93+
}
9194
if(wasSignal != core.analogSignal) {
9295
wasSignal = core.analogSignal;
9396
MultiblockHandler.get(level.dimension()).addIgnoreToUpdate(getBlockPos());
@@ -127,6 +130,7 @@ public void setCore(FusionCoreBE core) {
127130
if(wasCore != core) {
128131
MultiblockHandler.get(getLevel().dimension()).addIgnoreToUpdate(getBlockPos());
129132
setChanged();
133+
level.updateNeighborsAt(worldPosition, getBlockState().getBlock());
130134
level.sendBlockUpdated(worldPosition, getBlockState(), getBlockState(), Block.UPDATE_ALL);
131135
}
132136
}

src/main/java/igentuman/nc/block/kugelblitz/entity/ChamberPortBE.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.annotation.Nullable;
2424
import java.util.Objects;
2525

26+
import static igentuman.nc.NuclearCraft.currentTick;
2627
import static igentuman.nc.compat.gregtech.GTUtils.*;
2728
import static igentuman.nc.compat.oc2.FusionReactorDevice.DEVICE_CAPABILITY;
2829
import static igentuman.nc.multiblock.kugelblitz.KugelblitzRegistration.KUGELBLITZ_BE;
@@ -83,6 +84,10 @@ public boolean canInvalidateCache() {
8384
public void tickServer() {
8485
if(NuclearCraft.instance.isNcBeStopped || isRemoved()) return;
8586
super.tickServer();
87+
//if no blackhole - tick only 5 times per second
88+
if(currentTick % 5 == 0 && controller() != null && !controller().hasBlackhole()) {
89+
return;
90+
}
8691
int wasSignal = analogSignal;
8792
if(getMultiblock() != null || controller() != null) {
8893
sendOutPower();
@@ -136,7 +141,7 @@ protected void transferEnergyToSide(Direction direction) {
136141
}
137142
int wasEnergy = getEnergyStored();
138143
BlockEntity be = level.getExistingBlockEntity(worldPosition.relative(direction));
139-
if (be == null || be instanceof ChamberPortBE) {
144+
if (be == null || be instanceof ChamberPortBE || be instanceof ChamberTerminalBE) {
140145
return;
141146
}
142147
if((isGtLoaded() && isGTEUCapEnabled())) {

src/main/java/igentuman/nc/block/kugelblitz/entity/ChamberTerminalBE.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public class ChamberTerminalBE extends MultiblockControllerBE {
9393
@NBTField
9494
public int stabilizers = 0;
9595
public HashMap<Direction, Long> pulseEnergy = new HashMap<>();
96-
public int collectingEnergy = 2;
96+
public int collectingEnergy = 10;
9797

9898
protected Direction facing;
9999
public Recipe recipe;
@@ -262,7 +262,7 @@ public void tickServer() {
262262
if(isCasingValid && isInternalValid) {
263263
collectingEnergy--;
264264
if(collectingEnergy < 0) {
265-
collectingEnergy = 2;
265+
collectingEnergy = 10;
266266
if(pulseEnergy.size() == 6) {
267267
gotLaserBurst = true;
268268
}
@@ -301,6 +301,15 @@ public void tickServer() {
301301
}
302302
}
303303

304+
@Override
305+
public HashMap<String, String> getAnalyzeReport() {
306+
HashMap<String, String> report = new HashMap<>();
307+
report.put("report.nc.1.stabilizers", String.valueOf(stabilizers));
308+
report.put("report.nc.2.flux_regulators", String.valueOf(fluxRegulators));
309+
report.put("report.nc.3.transformers", String.valueOf(transformers));
310+
return report;
311+
}
312+
304313
private boolean isBlackHoleStable() {
305314
return blackholeStability > 39;
306315
}
@@ -658,7 +667,7 @@ private void handleBlackHole() {
658667
getMultiblock().blackHole = (BlackHoleBE) be;
659668
}
660669
}
661-
if(!(getMultiblock().isFormed() || isCasingValid) && getMultiblock().blackHole != null) {
670+
if(!getMultiblock().isValidating() && !(getMultiblock().isFormed() || isCasingValid) && getMultiblock().blackHole != null) {
662671
BlockPos pos = getMultiblock().blackHole.getBlockPos();
663672
getMultiblock().blackHole = null;
664673
getLevel().setBlockAndUpdate(pos, AIR.defaultBlockState());
@@ -679,7 +688,11 @@ private void handleBlackHole() {
679688

680689
public void gotEnergy(Direction facing) {
681690
pulseEnergy.put(facing, 1L);
682-
collectingEnergy = 2;
691+
collectingEnergy = 10;
692+
}
693+
694+
public boolean canAnalyze() {
695+
return analyzeDelay < 1;
683696
}
684697

685698
public static class Recipe extends NcRecipe {

0 commit comments

Comments
 (0)