Hbm's Nuclear Tech Mod

Hbm's Nuclear Tech Mod

1M Downloads

Tom agricide effects even without Tom

Vaern opened this issue · 1 comments

commented

Describe the bug

I've already mentioned this on the discords before, but the issue seems to have been ignored.

On any worlds running x4053 and up, the leaves on trees, and the grass in the shade of said trees, will slowly die and decay even when Tom has not been launched; it always leaves the upper layer of leaves, which leads me to believe that it's a result of Tom's light level checks.

I doubt Pu-238 wouldn't have discovered the issue in his fork, so it might've been a result of code regarding it being merged improperly, but I can't be certain for sure. Either way, it'd be really nice if this bug could be rectified.

Please solve this equation to x

x²+3x-19=√(9x²)+6
x²+3x-19=3x+6
x²-19=6
√x²=√25
x = 5

commented

I believe

public static void die(World world, int x, int y, int z) {

	int light = Math.max(world.getSavedLightValue(EnumSkyBlock.Block, x, y + 1, z), (int) (world.getBlockLightValue(x, y + 1, z) * (1 - ModEventHandler.dust)));
		
	if(light < 4) {
			
		if(world.getBlock(x, y, z) == Blocks.grass) {
			world.setBlock(x, y, z, Blocks.dirt);
		} else if(world.getBlock(x, y, z) instanceof BlockBush) {
			world.setBlock(x, y, z, Blocks.air);
		} else if(world.getBlock(x, y, z) instanceof BlockLeaves) {
			world.setBlock(x, y, z, Blocks.air);
		} else if(world.getBlock(x, y, z) instanceof BlockVine) {
			world.setBlock(x, y, z, Blocks.air);
		}
	}
}

is what's causing the problem. The method is part of the ImpactWorldHandler and is called every tick with no additional checks on the impact's fire or dust vars. I think the math behind light is supposed to only trigger the condition if dust is not zero, but apparently it does so anyway. I personally haven't worked with either getSavedLightValue and getBlockLightValue but if I had to guess then both of these could return a value <4 under pre-impact circumstances which triggers the block below it, killing plants. I added an additional dust > 0 condition which hopefully works.