Skip to content

Commit

Permalink
Fix Piglin Brutes spawning in midair
Browse files Browse the repository at this point in the history
  • Loading branch information
jsorrell committed Feb 15, 2022
1 parent 6d8666a commit a1f5fe0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/com/jsorrell/skyblock/SkyBlockExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <T extends MobEntity> void register(EntityType<T> type, SpawnRestriction.Location location, Heightmap.Type heightmapType, SpawnRestriction.SpawnPredicate<T> predicate) {
throw new AssertionError();
}
}
1 change: 1 addition & 0 deletions src/main/resources/skyblock.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"LightningEntityMixin",
"LivingEntityMixin",
"RamImpactTaskMixin",
"SpawnRestrictionAccessor",
"WanderingTraderEntityMixin"
],
"client": [
Expand Down

0 comments on commit a1f5fe0

Please sign in to comment.