2020-09-22 15:11:20 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
|
|
|
|
2021-08-19 21:24:09 +02:00
|
|
|
import java.util.function.Predicate;
|
|
|
|
|
2021-08-19 19:52:35 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.ButterflyEntity;
|
2021-03-04 21:35:49 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.CastSpellEntity;
|
2021-02-18 21:30:43 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.FloatingArtefactEntity;
|
2021-08-23 16:32:28 +02:00
|
|
|
import com.minelittlepony.unicopia.item.UItems;
|
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;
|
2021-08-23 16:32:28 +02:00
|
|
|
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
|
2020-09-22 15:11:20 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityDimensions;
|
|
|
|
import net.minecraft.entity.EntityType;
|
|
|
|
import net.minecraft.entity.SpawnGroup;
|
2021-08-23 16:32:28 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.item.Items;
|
2020-09-22 15:11:20 +02:00
|
|
|
import net.minecraft.util.Identifier;
|
|
|
|
import net.minecraft.util.registry.Registry;
|
2021-08-23 16:32:28 +02:00
|
|
|
import net.minecraft.village.TradeOffer;
|
|
|
|
import net.minecraft.village.VillagerProfession;
|
2021-08-19 21:24:09 +02:00
|
|
|
import net.minecraft.world.biome.Biome;
|
|
|
|
import net.minecraft.world.biome.Biome.Category;
|
2020-09-22 15:11:20 +02:00
|
|
|
|
2021-08-19 21:24:09 +02:00
|
|
|
@SuppressWarnings("deprecation")
|
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)));
|
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)
|
|
|
|
.dimensions(EntityDimensions.fixed(1, 1)));
|
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();
|
|
|
|
return Registry.register(Registry.ENTITY_TYPE, new Identifier("unicopia", name), type);
|
|
|
|
}
|
|
|
|
|
2021-08-19 19:52:35 +02:00
|
|
|
static void bootstrap() {
|
|
|
|
FabricDefaultAttributeRegistry.register(BUTTERFLY, ButterflyEntity.createButterflyAttributes());
|
2021-08-19 21:24:09 +02:00
|
|
|
|
|
|
|
final Predicate<BiomeSelectionContext> butterflySpawnable = BiomeSelectors.foundInOverworld()
|
|
|
|
.and(ctx -> ctx.getBiome().getPrecipitation() == Biome.Precipitation.RAIN);
|
|
|
|
|
|
|
|
BiomeModifications.addSpawn(butterflySpawnable.and(BiomeSelectors.categories(Category.RIVER, Category.FOREST, Category.EXTREME_HILLS)), SpawnGroup.AMBIENT, BUTTERFLY, 3, 3, 12);
|
|
|
|
BiomeModifications.addSpawn(butterflySpawnable.and(BiomeSelectors.categories(Category.PLAINS, Category.JUNGLE)), SpawnGroup.AMBIENT, BUTTERFLY, 7, 5, 19);
|
2021-08-23 16:32:28 +02:00
|
|
|
|
|
|
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.MASON, 1, factories -> {
|
|
|
|
factories.add((e, rng) -> new TradeOffer(UItems.GEMSTONE.getDefaultStack(), Items.EMERALD.getDefaultStack(), 30, 2, 0.05F));
|
|
|
|
});
|
|
|
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.LIBRARIAN, 1, factories -> {
|
|
|
|
factories.add((e, rng) -> new TradeOffer(new ItemStack(UItems.GEMSTONE, 2), Items.EMERALD.getDefaultStack(), 20, 1, 0.05F));
|
|
|
|
factories.add((e, rng) -> new TradeOffer(new ItemStack(UItems.GEMSTONE, 30), UItems.GOLDEN_FEATHER.getDefaultStack(), UItems.GOLDEN_WING.getDefaultStack(), 30, 2, 0.05F));
|
|
|
|
});
|
|
|
|
TradeOfferHelper.registerVillagerOffers(VillagerProfession.CARTOGRAPHER, 1, factories -> {
|
|
|
|
factories.add((e, rng) -> new TradeOffer(new ItemStack(UItems.GEMSTONE, 3), Items.EMERALD.getDefaultStack(), 20, 1, 0.05F));
|
|
|
|
});
|
2021-08-19 19:52:35 +02:00
|
|
|
}
|
2020-09-22 15:11:20 +02:00
|
|
|
}
|