package com.minelittlepony.unicopia.entity; import java.util.List; import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityCategory; import net.minecraft.entity.EntityDimensions; import net.minecraft.entity.EntityType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.EndBiome; import net.minecraft.world.biome.ForestBiome; import net.minecraft.world.biome.MountainsBiome; import net.minecraft.world.biome.NetherBiome; import net.minecraft.world.biome.OceanBiome; import net.minecraft.world.biome.PlainsBiome; import net.minecraft.world.biome.RiverBiome; public interface UEntities { EntityType SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new).size(EntityDimensions.changing(0.6f, 0.6f))); EntityType MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new).size(EntityDimensions.changing(0.6F, 0.25F))); EntityType CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new)); EntityType WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new)); EntityType RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new)); EntityType CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new)); EntityType RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new)); EntityType CUCCOON = register("cuccoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CuccoonEntity::new).size(EntityDimensions.changing(1.5F, 1.6F))); EntityType BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new)); EntityType THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.create(EntityCategory.MISC, ProjectileEntity::new).trackable(100, 10)); EntityType THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpearEntity::new).trackable(100, 10)); static EntityType register(String name, FabricEntityTypeBuilder builder) { return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), builder.build()); } static void bootstrap() { Registry.BIOME.forEach(biome -> { if (!(biome instanceof NetherBiome || biome instanceof EndBiome)) { addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), biome instanceof OceanBiome ? WildCloudEntity.SPAWN_ENTRY_OCEAN : WildCloudEntity.SPAWN_ENTRY_LAND); addifAbsent(biome.getEntitySpawnList(EntityCategory.CREATURE), RainbowEntity.SPAWN_ENTRY); } if (biome instanceof PlainsBiome || biome instanceof RiverBiome || biome instanceof MountainsBiome || biome instanceof ForestBiome) { addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), ButterflyEntity.SPAWN_ENTRY); } }); } static void addifAbsent(List entries, T entry) { if (!entries.contains(entry)) { entries.add(entry); } } }