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

Brute-force Fix of RAM Usage Problem When Using Alfheim #2475

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/main/java/gregtech/api/util/Mods.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public enum Mods {
VoxelMap(Names.VOXEL_MAP),
XaerosMinimap(Names.XAEROS_MINIMAP),
Vintagium(Names.VINTAGIUM),
Alfheim(Names.ALFHEIM),

// Special Optifine handler, but consolidated here for simplicity
Optifine(null) {
Expand Down Expand Up @@ -137,6 +138,7 @@ public static class Names {
public static final String VOXEL_MAP = "voxelmap";
public static final String XAEROS_MINIMAP = "xaerominimap";
public static final String VINTAGIUM = "vintagium";
public static final String ALFHEIM = "alfheim";
}

private final String ID;
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/gregtech/api/util/world/DummyWorld.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gregtech.api.util.world;

import gregtech.api.util.Mods;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.profiler.Profiler;
Expand All @@ -10,6 +12,7 @@
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
import net.minecraftforge.fml.common.Optional.Method;
import net.minecraftforge.fml.relauncher.FMLLaunchHandler;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -37,6 +40,12 @@ public DummyWorld() {
// De-allocate lightUpdateBlockList, checkLightFor uses this
ObfuscationReflectionHelper.setPrivateValue(World.class, this, null,
FMLLaunchHandler.isDeobfuscatedEnvironment() ? "lightUpdateBlockList" : "field_72994_J");

// De-allocate alfheim lighting engine
if (Mods.Alfheim.isModLoaded()) {
ObfuscationReflectionHelper.setPrivateValue(World.class, this, null,
"alfheim$lightingEngine");
}
}

@Override
Expand Down Expand Up @@ -90,4 +99,21 @@ protected boolean isChunkLoaded(int x, int z, boolean allowEmpty) {
public boolean checkLightFor(@NotNull EnumSkyBlock lightType, @NotNull BlockPos pos) {
return true;
}

@Override
@Method(modid = Mods.Names.ALFHEIM)
public World init() {
return this;
}

@Override
@Method(modid = Mods.Names.ALFHEIM)
public int getLightFromNeighborsFor(EnumSkyBlock type, BlockPos pos) {
return 15;
}

@Method(modid = Mods.Names.ALFHEIM)
public int alfheim$getLight(BlockPos pos, boolean checkNeighbors) {
return 15;
}
}
Loading