Skip to content

Commit

Permalink
Brute-force Fix of RAM Usage Problem When Using Alfheim (GregTechCEu#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MCTian-mi authored Jun 4, 2024
1 parent 09e44d9 commit ec756bb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
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;
}
}

0 comments on commit ec756bb

Please sign in to comment.