diff --git a/src/main/java/com/jsorrell/skyblock/SkyBlockExtension.java b/src/main/java/com/jsorrell/skyblock/SkyBlockExtension.java index af4aa01b..63a14e19 100644 --- a/src/main/java/com/jsorrell/skyblock/SkyBlockExtension.java +++ b/src/main/java/com/jsorrell/skyblock/SkyBlockExtension.java @@ -3,13 +3,16 @@ import carpet.CarpetExtension; import carpet.CarpetServer; import carpet.settings.SettingsManager; -import net.fabricmc.api.ModInitializer; - -import net.minecraft.util.registry.Registry; - import com.jsorrell.skyblock.criterion.Criteria; import com.jsorrell.skyblock.gen.SkyBlockChunkGenerator; import com.jsorrell.skyblock.gen.SkyBlockGenerationSettings; +import com.jsorrell.skyblock.mixin.SpawnRestrictionAccessor; +import net.fabricmc.api.ModInitializer; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.SpawnRestriction; +import net.minecraft.entity.mob.PiglinBruteEntity; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.Heightmap; public class SkyBlockExtension implements CarpetExtension, ModInitializer { private static SettingsManager settingsManager; @@ -22,6 +25,8 @@ public SkyBlockExtension() { public void onInitialize() { settingsManager = new SettingsManager(Build.VERSION, Build.ID, Build.NAME); settingsManager.parseSettingsClass(SkyBlockSettings.class); + // Restrict Piglin Brute spawning to the ground + SpawnRestrictionAccessor.register(EntityType.PIGLIN_BRUTE, SpawnRestriction.Location.ON_GROUND, Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, PiglinBruteEntity::canSpawnInDark); Registry.register( Registry.CHUNK_GENERATOR, SkyBlockGenerationSettings.NAME, SkyBlockChunkGenerator.CODEC); Criteria.registerAll(); diff --git a/src/main/java/com/jsorrell/skyblock/mixin/SpawnRestrictionAccessor.java b/src/main/java/com/jsorrell/skyblock/mixin/SpawnRestrictionAccessor.java new file mode 100644 index 00000000..65c0823a --- /dev/null +++ b/src/main/java/com/jsorrell/skyblock/mixin/SpawnRestrictionAccessor.java @@ -0,0 +1,16 @@ +package com.jsorrell.skyblock.mixin; + +import net.minecraft.entity.EntityType; +import net.minecraft.entity.SpawnRestriction; +import net.minecraft.entity.mob.MobEntity; +import net.minecraft.world.Heightmap; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(SpawnRestriction.class) +public interface SpawnRestrictionAccessor { + @Invoker("register") + static void register(EntityType type, SpawnRestriction.Location location, Heightmap.Type heightmapType, SpawnRestriction.SpawnPredicate predicate) { + throw new AssertionError(); + } +} diff --git a/src/main/resources/skyblock.mixins.json b/src/main/resources/skyblock.mixins.json index 3d464bc4..276a6dc1 100644 --- a/src/main/resources/skyblock.mixins.json +++ b/src/main/resources/skyblock.mixins.json @@ -15,6 +15,7 @@ "LightningEntityMixin", "LivingEntityMixin", "RamImpactTaskMixin", + "SpawnRestrictionAccessor", "WanderingTraderEntityMixin" ], "client": [