zlainsama / PeacefulSurface

This mod makes monsters can only spawn in completely darkness (lightlevel <= 0) thus surface will be much more peaceful
https://minecraft.curseforge.com/projects/peacefulsurface
MIT License
9 stars 0 forks source link

Blacklisting seems to be broken? #25

Open tequt opened 2 years ago

tequt commented 2 years ago

Here is my config

{
  "Disabled": false,
  "Living": false,
  "Mob": true,
  "Animal": false,
  "Tameable": false,
  "Checking_LightLevel": true,
  "Sunny": false,
  "Raining": false,
  "Thundering": true,
  "Day": false,
  "Night": false,
  "InvertedMobFilter": true,
  "InvertedDimensionFilter": false,
  "InvertedLightLevelChecking": false,
  "mobFilter": "(\\bZombie\\b)|(\\bSkeleton\\b)|(\\bCreeper\\b)|(\\bSpider\\b)|(\\bHusk\\b)|(\\bSkeleton_Warrior\\b)|(\\bStray\\b)|(\\bFestive_Creeper\\b)|(\\bSupport_Creeper\\b)|(\\bRocket_Creeper\\b)|(\\bAngry_Zombie\\b)",
  "dimensionFilter": "(\\bthe_end\\b)|(\\bthe_nether\\b)",
  "LightLevel": 0,
  "MoonPhase": 1,
  "DisabledUnderBloodmoon": false,
  "DisabledWhenSunny": false,
  "DisabledWhenRaining": false,
  "DisabledWhenThundering": false,
  "DisabledWhenDay": false,
  "DisabledWhenNight": false
}

Essentially, with InvertedMobFilter set to true and mobs written into the mobFilter, it's supposed to blacklist the mobs written into the filter. But only the mobs that only have one word names such as Creeper for example are managing to be blacklisted, mobs that have names with spaces and such are not being recognized. They still manage to spawn on the surface (circled are the blacklisted mobs): image

zlainsama commented 2 years ago

Which version are you using? Depend on the version, you might need to configure mobFilter differently.

tequt commented 2 years ago

I am using the 1.12.2. version of the mod.

tequt commented 2 years ago

https://www.curseforge.com/minecraft/mc-mods/peacefulsurface/files/2727271

zlainsama commented 2 years ago

What mod are those mobs coming from?

I think there are two possible causes for this issue:

  1. The names specified in mobFilter do not match with the actual names used in that mod.
  2. They are spawned differently from normal mobs, bypassing the CheckSpawn event that my mod relies on to filter mobs.
tequt commented 2 years ago

These mobs are from the mods Primitive Mobs and Thaumcraft, and they spawn just like any other hostile mob such as the Zombie or the Creeper. I tried a variation where the space between their names is an actual white space and a underscore and neither of these work, my guess is that there's a specific syntax with Regex so the error is in the 1st option.

The second option however cannot be as the mod worked as intended when I did not have the blacklist (AKA. "InvertedMobFilter" wasn't to true) enabled and creatures from Primitive Mobs did not spawn on the surface.

zlainsama commented 2 years ago

The AngryZombie is referred as "BrainyZombie" in Thaumcraft's code. Those creepers and skeleton warrior are referred as "rocket_creeper", "festive_creeper", "support_creeper", "skeleton_warrior" in PrimitiveMobs' code.

tequt commented 2 years ago

I see, so your config's filters are literally checking for the mobs' IDs and not the mob's display names. Correct?

zlainsama commented 2 years ago

Yes, in old versions, those ids are used when spawning those entities.

In newer versions, you will need formal registry ids such as "minecraft:slime".

tequt commented 2 years ago

Which one of these things does your Regex actually look for? I can't figure it out. image

Here's the code I've managed to write from the javascript flavour of Regular Expressions' syntax cheatsheets as a foundation. What syntax do you actually use so I can properly configure the .json?

{
  "Disabled": false,
  "Living": false,
  "Mob": true,
  "Animal": false,
  "Tameable": false,
  "Checking_LightLevel": true,
  "Sunny": false,
  "Raining": false,
  "Thundering": false,
  "Day": false,
  "Night": false,
  "InvertedMobFilter": true,
  "InvertedDimensionFilter": false,
  "InvertedLightLevelChecking": false,
  "mobFilter": "(([a-z]{0,}spider)|([a-z]{0,}.spider))|(([a-z]{0,}creeper)|([a-z]{0,}.creeper))|(([a-z]{0,}zombie)|([a-z]{0,}.zombie))|(([a-z]{0,}skeleton)|([a-z]{0,}.skeleton))",
  "dimensionFilter": "(\\bthe_end\\b)|(\\bthe_nether\\b)",
  "LightLevel": 0,
  "MoonPhase": 0,
  "DisabledUnderBloodmoon": false,
  "DisabledWhenSunny": false,
  "DisabledWhenRaining": false,
  "DisabledWhenThundering": false,
  "DisabledWhenDay": false,
  "DisabledWhenNight": false
}
zlainsama commented 2 years ago

In 1.12.2, the string my regex looking for is just some hardcoded magic string, there is no regulation at that time, modders can use whatever they want, you need to look into their code. Vanilla use something like 'Creeper', 'Zombie'.

I think you just need to use '\\' instead of single '\'.