pcal43 / mob-filter

Minecraft mod for controlling what mobs can spawn where
https://www.curseforge.com/minecraft/mc-mods/mob-filter
Apache License 2.0
7 stars 3 forks source link

BlockId filter is game crash #15

Closed bakrun closed 1 year ago

bakrun commented 1 year ago

crash by this code MFRules.java public String getBlockId() { final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1? return String.valueOf(Registries.BLOCK_ENTITY_TYPE.getId(be.getType())); }

unless blockPos like chest, this BlockEntity be is null so java.lang.NullPointerException: Cannot invoke "net.minecraft.class_2586.method_11017()" because "be" is null and crash game

fix this

        final BlockState be = serverWorld.getBlockState(this.blockPos.down()); // FIXME do we need to check at y+1?
        return String.valueOf(Registries.BLOCK.getId(be.getBlock()));

BlockState not down = air so use down This will get the block ID as intended

and mobfilter.yaml there is a typo dimensionId: ['minecraft:nether'] -> dimensionId: ['minecraft:the_nether']

pcal43 commented 1 year ago

can you try this one and see if it fixes it?

https://github.com/pcal43/mob-filter/releases/tag/blockfix

bakrun commented 1 year ago

can you try this one and see if it fixes it?

https://github.com/pcal43/mob-filter/releases/tag/blockfix

game not crash but doesn't work BlockId Because bs recognizes an air block 1 space above the block where monsters spawn, the block ID is displayed as air.

final BlockState bs = serverWorld.getBlockState(this.blockPos.down(1));

pcal43 commented 1 year ago

ok try this

https://github.com/pcal43/mob-filter/releases/tag/blockfix-2

bakrun commented 1 year ago

ok try this

https://github.com/pcal43/mob-filter/releases/tag/blockfix-2

it's work

pcal43 commented 1 year ago

Super. I just pushed out the fix in release 0.2.1+1.19.4.

Thanks a lot for testing it out.