Files
src
build.gradle
gradle.properties
settings.gradle
Code
17 627
src/main/java/com/dreaddweller/DreadDwellerMod.java
package com.dreaddweller;
import com.dreaddweller.entity.DreadDwellerEntity;
import com.dreaddweller.event.DreadEventHandler;
import com.dreaddweller.init.ModEntityTypes;
import net.minecraft.core.registries.Registries;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.entity.monster.Monster;
@Mod(DreadDwellerMod.MODID)
public class DreadDwellerMod {
public static final String MODID = "dreaddweller";
public DreadDwellerMod() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
ModEntityTypes.ENTITY_TYPES.register(modEventBus);
modEventBus.addListener(this::commonSetup);
modEventBus.addListener(this::registerAttributes);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.register(DreadEventHandler.class);
}
private void commonSetup(FMLCommonSetupEvent event) {
event.enqueueWork(() -> {
SpawnPlacements.register(
ModEntityTypes.DREAD_DWELLER.get(),
SpawnPlacements.Type.ON_GROUND,
Heightmap.Types.MOTION_BLOCKING_NO_LEAVES,
DreadDwellerEntity::checkDreadSpawnRules
);
});
}
private void registerAttributes(EntityAttributeCreationEvent event) {
event.put(ModEntityTypes.DREAD_DWELLER.get(), DreadDwellerEntity.createAttributes().build());
}
}