mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Added clouds to the spawn list
This commit is contained in:
parent
841d326338
commit
f90d6ae480
4 changed files with 49 additions and 20 deletions
|
@ -1,5 +1,7 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.entity.EntityCloud;
|
||||
import com.minelittlepony.unicopia.entity.EntityConstructionCloud;
|
||||
import com.minelittlepony.unicopia.entity.EntityRacingCloud;
|
||||
|
@ -14,7 +16,13 @@ import com.minelittlepony.unicopia.render.RenderSpellbook;
|
|||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList.EntityEggInfo;
|
||||
import net.minecraft.entity.EnumCreatureType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||
import net.minecraftforge.fml.common.registry.EntityEntryBuilder;
|
||||
|
@ -43,6 +51,20 @@ public class UEntities {
|
|||
RenderingRegistry.registerEntityRenderingHandler(EntitySpellbook.class, RenderSpellbook::new);
|
||||
}
|
||||
|
||||
static void registerSpawnEntries(Biome biome) {
|
||||
|
||||
if (!(biome instanceof BiomeHell || biome instanceof BiomeEnd)) {
|
||||
List<SpawnListEntry> entries = biome.getSpawnableList(EnumCreatureType.AMBIENT);
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static class Entry extends EntityEntry {
|
||||
|
||||
public Entry(Class<? extends Entity> cls, String name) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.item.crafting.IRecipe;
|
|||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraftforge.client.event.ColorHandlerEvent;
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||
import net.minecraftforge.client.event.FOVUpdateEvent;
|
||||
|
@ -147,6 +148,8 @@ public class Unicopia implements IGuiHandler {
|
|||
types.put("unicopia:crafting_spell", SpellRecipe::deserialize);
|
||||
}
|
||||
};
|
||||
|
||||
Biome.REGISTRY.forEach(UEntities::registerSpawnEntries);
|
||||
}
|
||||
|
||||
public static CraftingManager getCraftingManager() {
|
||||
|
@ -154,33 +157,33 @@ public class Unicopia implements IGuiHandler {
|
|||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItemsStatic(RegistryEvent.Register<Item> event) {
|
||||
public static void registerItems(RegistryEvent.Register<Item> event) {
|
||||
UItems.registerItems(event.getRegistry());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerItemColoursStatic(ColorHandlerEvent.Item event) {
|
||||
public static void registerItemColours(ColorHandlerEvent.Item event) {
|
||||
UItems.registerColors(event.getItemColors());
|
||||
UBlocks.registerColors(event.getItemColors(), event.getBlockColors());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerBlocksStatic(RegistryEvent.Register<Block> event) {
|
||||
public static void registerBlocks(RegistryEvent.Register<Block> event) {
|
||||
UBlocks.registerBlocks(event.getRegistry());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerSounds(RegistryEvent.Register<IRecipe> event) {
|
||||
public static void registerRecipes(RegistryEvent.Register<IRecipe> event) {
|
||||
UItems.registerRecipes(event.getRegistry());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerRecipesStatic(RegistryEvent.Register<SoundEvent> event) {
|
||||
public static void registerSounds(RegistryEvent.Register<SoundEvent> event) {
|
||||
USounds.init(event.getRegistry());
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerEntitiesStatic(RegistryEvent.Register<EntityEntry> event) {
|
||||
public static void registerEntities(RegistryEvent.Register<EntityEntry> event) {
|
||||
UEntities.init(event.getRegistry());
|
||||
}
|
||||
|
||||
|
|
|
@ -147,18 +147,6 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void collideWithNearbyEntities() {
|
||||
|
||||
}
|
||||
|
||||
protected void checkLocation() {
|
||||
if (posY < world.provider.getCloudHeight() - 18) {
|
||||
setLocationAndAngles(posX, world.provider.getCloudHeight() - 18, posZ, rotationYaw, rotationPitch);
|
||||
}
|
||||
super.collideWithNearbyEntities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyEntityCollision(Entity other) {
|
||||
if (other instanceof EntityPlayer) {
|
||||
|
@ -234,9 +222,13 @@ public class EntityCloud extends EntityFlying implements IAnimals {
|
|||
|
||||
if (state.getBlock() instanceof BlockFarmland) {
|
||||
int moisture = state.getValue(BlockFarmland.MOISTURE);
|
||||
world.setBlockState(below, state.withProperty(BlockFarmland.MOISTURE, moisture + 1));
|
||||
|
||||
if (moisture < 7) {
|
||||
world.setBlockState(below, state.withProperty(BlockFarmland.MOISTURE, moisture + 1));
|
||||
}
|
||||
} else if (state.getBlock() instanceof BlockCrops) {
|
||||
int age = state.getValue(BlockCrops.AGE);
|
||||
|
||||
if (age < 7) {
|
||||
world.setBlockState(below, state.withProperty(BlockCrops.AGE, age + 1), 2);
|
||||
}
|
||||
|
|
|
@ -7,9 +7,13 @@ import net.minecraft.entity.IEntityLivingData;
|
|||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome.SpawnListEntry;
|
||||
|
||||
public class EntityWildCloud extends EntityCloud {
|
||||
|
||||
public static final SpawnListEntry SPAWN_ENTRY_LAND = new SpawnListEntry(EntityWildCloud.class, 3, 2, 5);
|
||||
public static final SpawnListEntry SPAWN_ENTRY_OCEAN = new SpawnListEntry(EntityWildCloud.class, 3, 1, 2);
|
||||
|
||||
public EntityWildCloud(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
@ -37,7 +41,15 @@ public class EntityWildCloud extends EntityCloud {
|
|||
|
||||
@Override
|
||||
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData livingdata) {
|
||||
checkLocation();
|
||||
float minSpawnHeight = world.provider.getAverageGroundLevel() + 18;
|
||||
|
||||
if (posY < minSpawnHeight) {
|
||||
minSpawnHeight += world.rand.nextInt(Math.max(1, world.provider.getActualHeight() - (int)minSpawnHeight));
|
||||
|
||||
setLocationAndAngles(posX, minSpawnHeight - 1, posZ, rotationYaw, rotationPitch);
|
||||
collideWithNearbyEntities();
|
||||
}
|
||||
|
||||
return super.onInitialSpawn(difficulty, livingdata);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue