Unicopia/src/main/java/com/minelittlepony/unicopia/entity/UEntities.java

63 lines
3.6 KiB
Java
Raw Normal View History

2020-04-15 19:06:45 +02:00
package com.minelittlepony.unicopia.entity;
2020-04-15 19:06:45 +02:00
import java.util.List;
2020-04-24 14:26:27 +02:00
import net.fabricmc.fabric.api.entity.FabricEntityTypeBuilder;
2020-01-17 14:27:26 +01:00
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCategory;
2020-04-24 14:26:27 +02:00
import net.minecraft.entity.EntityDimensions;
2020-01-17 14:27:26 +01:00
import net.minecraft.entity.EntityType;
import net.minecraft.util.Identifier;
2020-01-17 14:27:26 +01:00
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;
2020-04-15 12:37:14 +02:00
public interface UEntities {
2020-04-24 14:26:27 +02:00
EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellbookEntity::new).size(EntityDimensions.changing(0.6f, 0.6f)));
EntityType<SpellcastEntity> MAGIC_SPELL = register("magic_spell", FabricEntityTypeBuilder.create(EntityCategory.MISC, SpellcastEntity::new).size(EntityDimensions.changing(0.6F, 0.25F)));
EntityType<CloudEntity> CLOUD = register("cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, CloudEntity::new));
EntityType<WildCloudEntity> WILD_CLOUD = register("wild_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, WildCloudEntity::new));
EntityType<RacingCloudEntity> RACING_CLOUD = register("racing_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, RacingCloudEntity::new));
EntityType<ConstructionCloudEntity> CONSTRUCTION_CLOUD = register("construction_cloud", FabricEntityTypeBuilder.create(EntityCategory.CREATURE, ConstructionCloudEntity::new));
2020-04-24 14:26:27 +02:00
EntityType<RainbowEntity> RAINBOW = register("rainbow", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, RainbowEntity::new));
2020-04-24 14:26:27 +02:00
EntityType<CuccoonEntity> CUCCOON = register("cuccoon", FabricEntityTypeBuilder.create(EntityCategory.MISC, CuccoonEntity::new).size(EntityDimensions.changing(1.5F, 1.6F)));
2020-01-17 14:27:26 +01:00
EntityType<ButterflyEntity> BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(EntityCategory.AMBIENT, ButterflyEntity::new).size(EntityDimensions.fixed(1, 1)));
EntityType<ProjectileEntity> THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.<ProjectileEntity>create(EntityCategory.MISC, ProjectileEntity::new).trackable(100, 2));
EntityType<SpearEntity> THROWN_SPEAR = register("thrown_spear", FabricEntityTypeBuilder.<SpearEntity>create(EntityCategory.MISC, SpearEntity::new).trackable(100, 2));
2019-02-04 14:25:12 +01:00
2020-04-24 14:26:27 +02:00
static <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
2020-04-25 13:32:33 +02:00
return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), builder.build());
2020-01-17 14:27:26 +01:00
}
2019-03-21 16:03:59 +01:00
2020-01-17 14:27:26 +01:00
static void bootstrap() {
Registry.BIOME.forEach(biome -> {
if (!(biome instanceof NetherBiome || biome instanceof EndBiome)) {
2020-04-15 19:06:45 +02:00
addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), biome instanceof OceanBiome ? WildCloudEntity.SPAWN_ENTRY_OCEAN : WildCloudEntity.SPAWN_ENTRY_LAND);
addifAbsent(biome.getEntitySpawnList(EntityCategory.CREATURE), RainbowEntity.SPAWN_ENTRY);
2020-01-17 14:27:26 +01:00
}
2019-03-21 16:03:59 +01:00
2020-01-17 14:27:26 +01:00
if (biome instanceof PlainsBiome
|| biome instanceof RiverBiome
|| biome instanceof MountainsBiome
|| biome instanceof ForestBiome) {
2020-04-15 19:06:45 +02:00
addifAbsent(biome.getEntitySpawnList(EntityCategory.AMBIENT), ButterflyEntity.SPAWN_ENTRY);
2020-01-17 14:27:26 +01:00
}
});
2019-01-29 14:22:36 +01:00
}
2020-04-15 19:06:45 +02:00
static <T> void addifAbsent(List<T> entries, T entry) {
if (!entries.contains(entry)) {
entries.add(entry);
}
}
}