Enhanced AI

Enhanced AI

7M Downloads

1.20.x: Zombies can break blocks under miner_block_blacklist list

Elemeants opened this issue ยท 7 comments

commented

Describe the bug
While trying to set a "safe" base that can prevent zombies to break in, we found that somehow, the zombies were able to break blocks that shouldn't be able. Ref: miner_block_blacklist.json

Versions where you encountered the problem (Use the exact version numbers, not 'latest' or similar):

  • Minecraft: 1.20.1
  • Forge: 47.3.0
  • Enhanced AI: 1.20.x
  • InsaneLib: 1.12.0

Steps to reproduce

I added minecraft:obsidian to miner_block_blacklist.json file.

  1. We created a bedrock or crying_obisidian layer above zombies with pickaxes.
  2. Those zombies were able to break the bedrock/crying_obsidian. (A single layer)

Screenshots

image

Can the issue be reproduced with EnhancedAI only (or with a minimal set of mods)?
Yes

Some quick debug

I have never done any minecraft mod, so I may be super wrong lol.

Maybe the problem is that in the path-finding algorithm on BlockBreakerGoal#fillTargetBlocks we're taking in count the blacklist but when we are transversing the queue, the BlockBreakerGoal#canBreakBlock is not taking in count that?

	private boolean canBreakBlock() {
		if (!this.blockState.requiresCorrectToolForDrops() || !this.properToolRequired)
			return true;

		ItemStack stack = this.miner.getOffhandItem();
		if (stack.isEmpty())
			return false;

		return !this.blockState.is(MinerMobs.BLOCK_BLACKLIST) && stack.isCorrectToolForDrops(this.blockState);
	}

So we could check if the block is some of the blacklist and return false if so.

commented

Quick update, some zombies that aren't miners break blocks (I added the change I described above and didn't work too)

commented
    public EnhancedAI() {
        ...
        // Trying to determine if `BLOCK_BLACKLIST` has data
        Block obsidian = ForgeRegistries.BLOCKS.getValue(ResourceLocation.tryParse("minecraft:obsidian"));
        Block cryingObsidian = ForgeRegistries.BLOCKS.getValue(ResourceLocation.tryParse("minecraft:crying_obsidian"));

        boolean isObsidianInBlacklist = obsidian.defaultBlockState().is(MinerMobs.BLOCK_BLACKLIST);
        boolean isCryingObsidianInBlacklist = cryingObsidian.defaultBlockState().is(MinerMobs.BLOCK_BLACKLIST);

        // Trying to "manually" register the json file and then log the parsed results
        TagKey<Block> t = ForgeRegistries.BLOCKS.tags().createTagKey(new ResourceLocation(EnhancedAI.MOD_ID, "miner_block_blacklist"));
        List<Block> blocks = ForgeRegistries.BLOCKS.tags().getTag(t).stream().toList();
        LOGGER.warn(blocks);

        LOGGER.warn("Is Obsidian in BLACKLIST? " + isObsidianInBlacklist);
        LOGGER.warn("Is Crying Obsidian in BLACKLIST? " + isCryingObsidianInBlacklist);
    }

My Minecraft log was the following: it seems like the resources are never loaded.

[20:21:14] [modloading-worker-0/WARN] [in.en.EnhancedAI/]: []
[20:21:14] [modloading-worker-0/WARN] [in.en.EnhancedAI/]: Is Obsidian in BLACKLIST? false
[20:21:14] [modloading-worker-0/WARN] [in.en.EnhancedAI/]: Is Crying Obsidian in BLACKLIST? false
commented

Can't reproduce this. I've added stone and the miners don't mine it.

Also you can't check if stuff is in tags when the mod loads as they don't exist until a world is opened. To check if a block is in a block tag just check in F3 when looking at it on the right side

commented

I've removed the comment with the scummy link.

commented

Interesting @Insane96, Did u test it on a "flat" map world or how did u test it? I could try to do the same on my end and debug it.yo

Btw, any advices on how to debug the MinerMob behavior?

commented

In a normal world

commented

@Insane96 Will close this issue as the behavior was reproduced even after removing the mod, so it should be a different mod! Thanks!