2021-08-24 21:15:43 +02:00
|
|
|
package com.minelittlepony.unicopia.entity;
|
2020-09-22 15:11:20 +02:00
|
|
|
|
2021-08-19 21:24:09 +02:00
|
|
|
import java.util.function.Predicate;
|
|
|
|
|
2022-08-27 15:14:00 +02:00
|
|
|
import com.minelittlepony.unicopia.Unicopia;
|
2022-08-27 16:37:37 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.behaviour.EntityBehaviour;
|
2020-09-22 15:11:20 +02:00
|
|
|
import com.minelittlepony.unicopia.projectile.MagicProjectileEntity;
|
|
|
|
|
2021-08-19 21:24:09 +02:00
|
|
|
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
|
|
|
|
import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext;
|
|
|
|
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors;
|
2021-08-19 19:52:35 +02:00
|
|
|
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
|
2020-09-22 15:11:20 +02:00
|
|
|
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityDimensions;
|
|
|
|
import net.minecraft.entity.EntityType;
|
|
|
|
import net.minecraft.entity.SpawnGroup;
|
2022-06-25 00:19:55 +02:00
|
|
|
import net.minecraft.tag.BiomeTags;
|
2020-09-22 15:11:20 +02:00
|
|
|
import net.minecraft.util.registry.Registry;
|
2021-08-19 21:24:09 +02:00
|
|
|
import net.minecraft.world.biome.Biome;
|
2020-09-22 15:11:20 +02:00
|
|
|
|
|
|
|
public interface UEntities {
|
2021-08-19 19:52:35 +02:00
|
|
|
EntityType<ButterflyEntity> BUTTERFLY = register("butterfly", FabricEntityTypeBuilder.create(SpawnGroup.AMBIENT, ButterflyEntity::new)
|
|
|
|
.dimensions(EntityDimensions.fixed(0.25F, 0.25F)));
|
2020-09-22 15:11:20 +02:00
|
|
|
EntityType<MagicProjectileEntity> THROWN_ITEM = register("thrown_item", FabricEntityTypeBuilder.<MagicProjectileEntity>create(SpawnGroup.MISC, MagicProjectileEntity::new)
|
2020-12-17 19:17:47 +01:00
|
|
|
.trackRangeBlocks(100)
|
|
|
|
.trackedUpdateRate(2)
|
2020-09-22 15:11:20 +02:00
|
|
|
.dimensions(EntityDimensions.fixed(0.25F, 0.25F)));
|
2022-03-27 16:02:14 +02:00
|
|
|
EntityType<PhysicsBodyProjectileEntity> MUFFIN = register("muffin", FabricEntityTypeBuilder.<PhysicsBodyProjectileEntity>create(SpawnGroup.MISC, PhysicsBodyProjectileEntity::new)
|
|
|
|
.trackRangeBlocks(100)
|
|
|
|
.trackedUpdateRate(2)
|
|
|
|
.dimensions(EntityDimensions.fixed(0.25F, 0.25F)));
|
2022-01-11 17:19:36 +01:00
|
|
|
EntityType<MagicProjectileEntity> MAGIC_BEAM = register("magic_beam", FabricEntityTypeBuilder.<MagicProjectileEntity>create(SpawnGroup.MISC, MagicProjectileEntity::new)
|
|
|
|
.trackRangeBlocks(100)
|
|
|
|
.trackedUpdateRate(2)
|
|
|
|
.dimensions(EntityDimensions.fixed(0.25F, 0.25F)));
|
2021-02-18 21:30:43 +01:00
|
|
|
EntityType<FloatingArtefactEntity> FLOATING_ARTEFACT = register("floating_artefact", FabricEntityTypeBuilder.create(SpawnGroup.MISC, FloatingArtefactEntity::new)
|
|
|
|
.trackRangeBlocks(200)
|
|
|
|
.dimensions(EntityDimensions.fixed(1, 1)));
|
2021-03-04 21:35:49 +01:00
|
|
|
EntityType<CastSpellEntity> CAST_SPELL = register("cast_spell", FabricEntityTypeBuilder.create(SpawnGroup.MISC, CastSpellEntity::new)
|
|
|
|
.trackRangeBlocks(200)
|
2021-12-27 01:15:48 +01:00
|
|
|
.dimensions(EntityDimensions.fixed(1, 0.4F)));
|
2021-12-27 13:05:31 +01:00
|
|
|
EntityType<FairyEntity> TWITTERMITE = register("twittermite", FabricEntityTypeBuilder.create(SpawnGroup.MISC, FairyEntity::new)
|
2021-12-27 01:15:48 +01:00
|
|
|
.trackRangeBlocks(200)
|
|
|
|
.dimensions(EntityDimensions.fixed(0.1F, 0.1F)));
|
2021-11-09 17:29:55 +01:00
|
|
|
EntityType<SpellbookEntity> SPELLBOOK = register("spellbook", FabricEntityTypeBuilder.create(SpawnGroup.MISC, SpellbookEntity::new)
|
|
|
|
.trackRangeBlocks(200)
|
2022-09-10 17:29:56 +02:00
|
|
|
.dimensions(EntityDimensions.fixed(0.9F, 0.5F)));
|
2020-09-22 15:11:20 +02:00
|
|
|
|
|
|
|
static <T extends Entity> EntityType<T> register(String name, FabricEntityTypeBuilder<T> builder) {
|
|
|
|
EntityType<T> type = builder.build();
|
2022-08-27 15:14:00 +02:00
|
|
|
return Registry.register(Registry.ENTITY_TYPE, Unicopia.id(name), type);
|
2020-09-22 15:11:20 +02:00
|
|
|
}
|
|
|
|
|
2021-08-19 19:52:35 +02:00
|
|
|
static void bootstrap() {
|
|
|
|
FabricDefaultAttributeRegistry.register(BUTTERFLY, ButterflyEntity.createButterflyAttributes());
|
2021-11-09 17:29:55 +01:00
|
|
|
FabricDefaultAttributeRegistry.register(SPELLBOOK, SpellbookEntity.createMobAttributes());
|
2021-12-27 13:05:31 +01:00
|
|
|
FabricDefaultAttributeRegistry.register(TWITTERMITE, FairyEntity.createMobAttributes());
|
2021-08-19 21:24:09 +02:00
|
|
|
|
|
|
|
final Predicate<BiomeSelectionContext> butterflySpawnable = BiomeSelectors.foundInOverworld()
|
|
|
|
.and(ctx -> ctx.getBiome().getPrecipitation() == Biome.Precipitation.RAIN);
|
|
|
|
|
2022-06-25 00:19:55 +02:00
|
|
|
BiomeModifications.addSpawn(butterflySpawnable.and(
|
|
|
|
BiomeSelectors.tag(BiomeTags.IS_RIVER)
|
|
|
|
.or(BiomeSelectors.tag(BiomeTags.IS_FOREST))
|
|
|
|
.or(BiomeSelectors.tag(BiomeTags.IS_HILL))
|
|
|
|
), SpawnGroup.AMBIENT, BUTTERFLY, 3, 3, 12);
|
|
|
|
BiomeModifications.addSpawn(butterflySpawnable.and(
|
|
|
|
BiomeSelectors.tag(BiomeTags.IS_JUNGLE)
|
|
|
|
.or(BiomeSelectors.tag(BiomeTags.IS_MOUNTAIN))
|
|
|
|
), SpawnGroup.AMBIENT, BUTTERFLY, 7, 5, 19);
|
2021-08-23 16:32:28 +02:00
|
|
|
|
2021-08-24 21:14:18 +02:00
|
|
|
UTradeOffers.bootstrap();
|
2022-08-27 16:37:37 +02:00
|
|
|
EntityBehaviour.bootstrap();
|
|
|
|
UEntityAttributes.bootstrap();
|
2021-08-19 19:52:35 +02:00
|
|
|
}
|
2020-09-22 15:11:20 +02:00
|
|
|
}
|