Skip to content

Commit

Permalink
Improve Performance and Auto Balancing of SolarFlux Solars
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Jan 26, 2025
1 parent 4dc0cf0 commit 0e2931a
Show file tree
Hide file tree
Showing 11 changed files with 584 additions and 0 deletions.
7 changes: 7 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ dependencies {
// FindMyItemsAndFluids (from CurseForge)
compileOnly rfg.deobf("curse.maven:findmyitemsandfluids-610085:3748963") // Version 1.0.0

// Solar Flux Reborn (from CurseForge)
compileOnly rfg.deobf("curse.maven:solar-flux-reborn-246974:3050838") // Version 12.4.11

/* -------------------------------- Soft Deps, Multiple Runtime Declaration -------------------------------- */
if (project.enable_draconic.toBoolean() || project.enable_thermal.toBoolean()) {
runtimeOnly "curse.maven:redstone-flux-270789:2920436" // Version 2.1.1.1
Expand Down Expand Up @@ -321,4 +324,8 @@ dependencies {
if (project.enable_mouse_tweaks.toBoolean()) {
runtimeOnly "curse.maven:mouse-tweaks-461660:4661407" // Mouse Tweaks Unofficial, Version 3.1.4
}

if (project.enable_solar.toBoolean()) {
runtimeOnly "curse.maven:solar-flux-reborn-246974:3050838" // Version 12.4.11
}
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,6 @@ enable_thermal = false

# Whether to enable Mouse Tweaks in runtime. Useful for testing interactions with various GUIs.
enable_mouse_tweaks = false

# Whether to enable Solar Flux Reborn in runtime. Improves performance of large solar fields.
enable_solar = false
1 change: 1 addition & 0 deletions src/main/java/com/nomiceu/nomilabs/LabsValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,5 @@ public class LabsValues {
public static final String BETTER_P2P_MODID = "betterp2p";
public static final String FIND_ME_MODID = "findme";
public static final String REDSTONE_FLUX_MODID = "redstoneflux";
public static final String SOLAR_FLUX_MODID = "solarflux";
}
38 changes: 38 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,44 @@ public static class ModIntegration {
@Config.Name("better p2p options")
public final BetterP2POptions betterP2POptions = new BetterP2POptions();

@Config.Comment("Solar Flux Performance Options")
@Config.LangKey("config.nomilabs.mod_integration.solar_flux")
@Config.Name("solar flux performance options")
public final SolarFluxPerformanceOptions solarFluxPerformanceOptions = new SolarFluxPerformanceOptions();

public static class SolarFluxPerformanceOptions {

@Config.Comment({ "Whether to enable Solar Flux Performance Optimizations.",
"This caches TE entries, upgrade and charger states, and improves autobalancing logic.",
"None of the below options work if this config is disabled.",
"[default: true]" })
@Config.LangKey("config.nomilabs.mod_integration.solar_flux.enable")
@Config.RequiresMcRestart
public boolean enableSolarFluxPerformance = true;

@Config.Comment({ "Frequency to perform auto balancing between solars.",
"The higher this value, the better the performance of solar grids.",
"If you experience issues with grids not balancing fast enough to achieve max transfer, decrease this value.",
"Solar Flux vanilla is 1 tick.",
"[default: 10]" })
@Config.LangKey("config.nomilabs.mod_integration.solar_flux.auto_balancing_freq")
@Config.RangeInt(min = 1)
public int autoBalancingFrequency = 10;

@Config.Comment({
"Whether to enable 'extra balancing' if needed, during solar auto push energy operations.",
"This may reduce performance, but can improve extraction rates.",
"[default: true]" })
@Config.LangKey("config.nomilabs.mod_integration.solar_flux.extra_balancing")
public boolean extraBalancing = true;

@Config.Comment({ "Maximum extra balancing to perform in a single tick.",
"[default: 1]" })
@Config.LangKey("config.nomilabs.mod_integration.solar_flux.extra_balancing_amount")
@Config.RangeInt(min = 0)
public int extraBalancingAmount = 1;
}

public static class BetterP2POptions {

@Config.Comment({ "Whether to highlight the Selected P2P by blinking, instead of with green.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.nomiceu.nomilabs.integration.solarflux;

public interface AccessibleInventoryDummy {

boolean labs$stateChanged();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.nomiceu.nomilabs.integration.solarflux;

import net.minecraft.util.EnumFacing;

public interface AccessibleTileBaseSolar {

void labs$addBlacklistSide(EnumFacing facing);

long labs$rawEnergy();

void labs$setEnergy(long amt);
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class LabsLateMixinLoader implements ILateMixinLoader {
.put(LabsValues.BQU_MODID, true)
.put(LabsValues.BETTER_P2P_MODID, true)
.put(LabsValues.STORAGE_DRAWERS_MODID, true)
.put(LabsValues.SOLAR_FLUX_MODID,
LabsConfig.modIntegration.solarFluxPerformanceOptions.enableSolarFluxPerformance)
.build();

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.nomiceu.nomilabs.mixin.solarflux;

import net.minecraft.item.ItemStack;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.nomiceu.nomilabs.integration.solarflux.AccessibleInventoryDummy;

import tk.zeitheron.solarflux.utils.InventoryDummy;

@Mixin(value = InventoryDummy.class, remap = false)
public class InventoryDummyMixin implements AccessibleInventoryDummy {

@Unique
private boolean labs$stateChanged = true;

@Override
public boolean labs$stateChanged() {
var old = labs$stateChanged;
labs$stateChanged = false;
return old;
}

@Inject(method = "markDirty", at = @At("RETURN"), remap = true)
private void handleMarkDirty(CallbackInfo ci) {
labs$stateChanged = true;
}

@Inject(method = "setInventorySlotContents", at = @At("RETURN"), remap = true)
private void handleInventoryChanged(int index, ItemStack stack, CallbackInfo ci) {
labs$stateChanged = true;
}
}
Loading

0 comments on commit 0e2931a

Please sign in to comment.