2018-09-16 00:45:44 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
|
|
|
|
2019-01-29 14:22:36 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2018-09-16 00:45:44 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.EntityCloud;
|
|
|
|
import com.minelittlepony.unicopia.entity.EntityConstructionCloud;
|
|
|
|
import com.minelittlepony.unicopia.entity.EntityRacingCloud;
|
2018-09-21 17:53:33 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.EntitySpell;
|
2019-01-10 10:35:15 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.EntitySpellbook;
|
2019-01-06 22:31:34 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.EntityProjectile;
|
2018-09-16 00:45:44 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.EntityWildCloud;
|
|
|
|
import com.minelittlepony.unicopia.render.RenderCloud;
|
2018-09-21 17:53:33 +02:00
|
|
|
import com.minelittlepony.unicopia.render.RenderGem;
|
2019-01-06 22:31:34 +01:00
|
|
|
import com.minelittlepony.unicopia.render.RenderProjectile;
|
2019-01-10 10:35:15 +01:00
|
|
|
import com.minelittlepony.unicopia.render.RenderSpellbook;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2018-09-21 17:53:33 +02:00
|
|
|
import net.minecraft.entity.Entity;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraft.entity.EntityList.EntityEggInfo;
|
2019-01-29 14:22:36 +01:00
|
|
|
import net.minecraft.entity.EnumCreatureType;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2019-01-29 14:22:36 +01:00
|
|
|
import net.minecraft.world.biome.Biome;
|
|
|
|
import net.minecraft.world.biome.Biome.SpawnListEntry;
|
|
|
|
import net.minecraft.world.biome.BiomeEnd;
|
|
|
|
import net.minecraft.world.biome.BiomeHell;
|
|
|
|
import net.minecraftforge.common.BiomeManager;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
|
|
|
import net.minecraftforge.fml.common.registry.EntityEntry;
|
2019-01-06 22:31:34 +01:00
|
|
|
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
|
2018-09-16 00:45:44 +02:00
|
|
|
import net.minecraftforge.registries.IForgeRegistry;
|
|
|
|
|
|
|
|
public class UEntities {
|
2018-09-21 17:53:33 +02:00
|
|
|
private static final int BRUSHES_ROYALBLUE = 0x4169E1;
|
|
|
|
private static final int BRUSHES_CHARTREUSE = 0x7FFF00;
|
2018-09-16 00:45:44 +02:00
|
|
|
|
|
|
|
static void init(IForgeRegistry<EntityEntry> registry) {
|
2019-01-06 22:31:34 +01:00
|
|
|
registry.registerAll(
|
|
|
|
new Entry(EntityCloud.class, "cloud").withEgg(BRUSHES_ROYALBLUE, BRUSHES_CHARTREUSE),
|
|
|
|
new Entry(EntityWildCloud.class, "wild_cloud"),
|
|
|
|
new Entry(EntityRacingCloud.class, "racing_cloud"),
|
|
|
|
new Entry(EntityConstructionCloud.class, "construction_cloud"),
|
|
|
|
new Entry(EntitySpell.class, "magic_spell"),
|
2019-01-10 10:35:15 +01:00
|
|
|
new Entry(EntitySpellbook.class, "spellbook"),
|
2019-01-06 22:31:34 +01:00
|
|
|
EntityEntryBuilder.<EntityProjectile>create().entity(EntityProjectile.class).name("thrown_item").id(new ResourceLocation(Unicopia.MODID, "thrown_item"), 0).tracker(10, 5, true).build()
|
|
|
|
);
|
2018-09-21 17:53:33 +02:00
|
|
|
}
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2019-01-06 22:31:34 +01:00
|
|
|
static void preInit() {
|
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityCloud.class, RenderCloud::new);
|
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySpell.class, RenderGem::new);
|
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntityProjectile.class, RenderProjectile::new);
|
2019-01-10 10:35:15 +01:00
|
|
|
RenderingRegistry.registerEntityRenderingHandler(EntitySpellbook.class, RenderSpellbook::new);
|
2019-01-06 22:31:34 +01:00
|
|
|
}
|
|
|
|
|
2019-01-29 14:22:36 +01:00
|
|
|
static void registerSpawnEntries(Biome biome) {
|
|
|
|
|
|
|
|
if (!(biome instanceof BiomeHell || biome instanceof BiomeEnd)) {
|
2019-01-29 16:56:16 +01:00
|
|
|
List<SpawnListEntry> entries = biome.getSpawnableList(EnumCreatureType.AMBIENT);
|
2019-01-29 14:22:36 +01:00
|
|
|
entries.stream().filter(p -> p.entityClass == EntityWildCloud.class).findFirst().orElseGet(() -> {
|
|
|
|
entries.add(
|
|
|
|
BiomeManager.oceanBiomes.contains(biome) ?
|
|
|
|
EntityWildCloud.SPAWN_ENTRY_LAND : EntityWildCloud.SPAWN_ENTRY_OCEAN
|
|
|
|
);
|
|
|
|
return null;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-06 22:31:34 +01:00
|
|
|
static class Entry extends EntityEntry {
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2019-01-06 22:31:34 +01:00
|
|
|
public Entry(Class<? extends Entity> cls, String name) {
|
|
|
|
super(cls, name);
|
|
|
|
setRegistryName(Unicopia.MODID, name);
|
2018-09-21 17:53:33 +02:00
|
|
|
}
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2019-01-06 22:31:34 +01:00
|
|
|
Entry withEgg(int a, int b) {
|
|
|
|
setEgg(new EntityEggInfo(getRegistryName(), a, b));
|
2018-09-16 00:45:44 +02:00
|
|
|
|
2019-01-06 22:31:34 +01:00
|
|
|
return this;
|
|
|
|
}
|
2018-09-16 00:45:44 +02:00
|
|
|
}
|
|
|
|
}
|