diff --git a/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java b/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java index 4ecfc356c..733bb012d 100644 --- a/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java +++ b/src/main/java/com/majruszsdifficulty/gamemodifiers/list/SpawnBlocker.java @@ -1,16 +1,12 @@ package com.majruszsdifficulty.gamemodifiers.list; +import com.majruszsdifficulty.Registries; import com.majruszsdifficulty.config.GameStageStringListConfig; -import com.mlib.gamemodifiers.GameModifier;import com.majruszsdifficulty.Registries; +import com.mlib.Utility; +import com.mlib.gamemodifiers.GameModifier; import com.mlib.gamemodifiers.contexts.OnCheckSpawnContext; import com.mlib.gamemodifiers.data.OnCheckSpawnData; -import com.mlib.levels.LevelHelper; -import net.minecraft.core.Registry; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.tags.StructureTags; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.monster.Illusioner; -import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.Event; public class SpawnBlocker extends GameModifier { @@ -22,9 +18,7 @@ public SpawnBlocker() { super( Registries.Modifiers.DEFAULT, "SpawnBlocker", "Blocks certain mobs from spawning when given game stage is active." ); OnCheckSpawnContext onCheckSpawn = new OnCheckSpawnContext( this::blockSpawn ); - onCheckSpawn.addCondition( data->data.entity instanceof Illusioner && isVillageNearby( data.entity ) ) - .addCondition( data->this.isForbidden( data.entity ) ) - .addConfig( this.forbiddenEntities ); + onCheckSpawn.addCondition( data->this.isForbidden( data.entity ) ).addConfig( this.forbiddenEntities ); this.addContext( onCheckSpawn ); } @@ -34,13 +28,6 @@ private void blockSpawn( OnCheckSpawnData data ) { } private boolean isForbidden( Entity entity ) { - return this.forbiddenEntities.getCurrentGameStageValue().contains( Registry.ENTITY_TYPE.getKey( entity.getType() ).toString() ); - } - - private static boolean isVillageNearby( Entity entity ) { - if( !( entity.level instanceof ServerLevel level ) || !LevelHelper.isEntityIn( entity, Level.OVERWORLD ) ) - return false; - - return level.findNearestMapStructure( StructureTags.VILLAGE, entity.blockPosition(), 100, false ) != null; + return this.forbiddenEntities.getCurrentGameStageValue().contains( Utility.getRegistryString( entity.getType() ) ); } }