Skip to content

Commit

Permalink
Prevent lava from loading chunks (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursivePineapple authored Feb 28, 2025
1 parent f413e28 commit 7a5129f
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public class SpeedupsConfig {
@Config.DefaultBoolean(true)
public static boolean limitMobSpawningToViewDistance;

@Config.Comment("Prevents chunk loads caused by lava blocks")
@Config.DefaultBoolean(true)
@Config.RequiresMcRestart
public static boolean lavaChunkLoading;

// Biomes O' Plenty

@Config.Comment("Speedup biome fog rendering in BiomesOPlenty")
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/mitchej123/hodgepodge/mixins/Mixins.java
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ public enum Mixins {
.addMixinClasses("minecraft.MixinNetHandlePlayServer_FixWrongBlockPlacementCheck")
.setApplyIf(() -> FixesConfig.fixWrongBlockPlacementDistanceCheck).addTargetedMod(TargetedMod.VANILLA)),

PREVENT_LAVA_CHUNK_LOADING(new Builder("Prevent lava blocks from loading chunks").setPhase(Phase.EARLY)
.setSide(Side.BOTH).addMixinClasses("minecraft.MixinBlockStaticLiquid")
.setApplyIf(() -> SpeedupsConfig.lavaChunkLoading).addTargetedMod(TargetedMod.VANILLA)),

// Ic2 adjustments
IC2_UNPROTECTED_GET_BLOCK_FIX(new Builder("IC2 Kinetic Fix").setPhase(Phase.EARLY).setSide(Side.BOTH)
.addMixinClasses("ic2.MixinIc2WaterKinetic").setApplyIf(() -> FixesConfig.fixIc2UnprotectedGetBlock)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.mitchej123.hodgepodge.mixins.early.minecraft;

import net.minecraft.block.Block;
import net.minecraft.block.BlockStaticLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(BlockStaticLiquid.class)
public class MixinBlockStaticLiquid {

@Redirect(
method = "updateTick",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlock(III)Lnet/minecraft/block/Block;"))
public Block wrapperUpdateTickGetBlock(World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) {
// return something that isn't air, but also doesn't block movement so that the loop continues
return Blocks.grass;
} else {
return world.getBlock(x, y, z);
}
}

@Redirect(method = "updateTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;isAirBlock(III)Z"))
public boolean wrapperUpdateTickIsAirBlock(World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) {
// return false so that this.isFlammable doesn't run
return false;
} else {
return world.isAirBlock(x, y, z);
}
}

@Redirect(
method = "isFlammable",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlock(III)Lnet/minecraft/block/Block;"))
public Block wrapperIsFlammableGetBlock(World world, int x, int y, int z) {
if (!world.blockExists(x, y, z)) {
// return something that isn't flammable so that the or's short circuit
return Blocks.air;
} else {
return world.getBlock(x, y, z);
}
}
}

0 comments on commit 7a5129f

Please sign in to comment.