Skip to content

Commit

Permalink
add fix to vanilla fire spread sometimes cause NPE on thermos
Browse files Browse the repository at this point in the history
  • Loading branch information
llk89 committed Jul 16, 2021
1 parent 8c2e6bf commit d2295c6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,10 @@ public enum MixinSets {
Collections.singletonList("fixHopperHitBox.MixinBlockHopper")),
FIX_GET_BLOCK_LIGHT_VALUE("Fix vanilla light value calculation NPE",
() -> config.fixGetBlockLightValue,
Collections.singletonList("fixGetBlockLightValue.MixinWorld"))
Collections.singletonList("fixGetBlockLightValue.MixinWorld")),
FIX_FIRE_SPREAD("Fix vanilla fire spread NPE",
() -> config.fixFireSpread,
Collections.singletonList("fixFireSpread.MixinBlockFire"))
;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class LoadingConfig {
public boolean installAnchorAlarm;
public boolean hideIc2ReactorSlots;
public boolean fixGetBlockLightValue;
public boolean fixFireSpread;
// ASM
public boolean pollutionAsm;
public boolean cofhWorldTransformer;
Expand Down Expand Up @@ -53,6 +54,7 @@ public LoadingConfig(File file) {
fixGuiGameOver = config.get("fixes", "fixGuiGameOver", true, "Fix Game Over GUI buttons disabled if switching fullscreen").getBoolean();
fixHopperHitBox = config.get("fixes", "fixHopperHitBox", true, "Fix vanilla hopper hit box").getBoolean();
fixGetBlockLightValue = config.get("fixes", "fixGetBlockLightValue", true, "Fix vanilla light calculation sometimes cause NPE on thermos").getBoolean();
fixFireSpread = config.get("fixes", "fixFireSpread", true, "Fix vanilla fire spread sometimes cause NPE on thermos").getBoolean();

installAnchorAlarm = config.get("tweaks", "installAnchorAlarm", true, "Wake up passive & personal anchors on player login").getBoolean();
preventPickupLoot = config.get("tweaks", "preventPickupLoot", true, "Prevent monsters from picking up loot.").getBoolean();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mitchej123.hodgepodge.mixins.fixFireSpread;

import net.minecraft.block.BlockFire;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Random;

@Mixin(BlockFire.class)
public class MixinBlockFire {
@Inject(
method = "tryCatchFire(Lnet/minecraft/world/World;IIIILjava/util/Random;ILnet/minecraftforge/common/util/ForgeDirection;)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlock(III)Lnet/minecraft/block/Block;"),
cancellable = true
)
public void fixChunkNPE(World world, int x, int y, int z, int par5, Random par6, int par7, ForgeDirection face, CallbackInfo ci) {
if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000 && y >= 0 && y < 256) {
if (world.getChunkFromChunkCoords(x >> 4, z >> 4) == null)
ci.cancel();
}
}
}

0 comments on commit d2295c6

Please sign in to comment.