diff --git a/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java b/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java index 904e9339..a1a7990e 100644 --- a/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java +++ b/src/main/java/de/ellpeck/naturesaura/api/recipes/AnimalSpawnerRecipe.java @@ -2,8 +2,10 @@ package de.ellpeck.naturesaura.api.recipes; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLiving; import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.EntityEntry; import net.minecraftforge.fml.common.registry.ForgeRegistries; @@ -24,11 +26,19 @@ public class AnimalSpawnerRecipe { this.time = time; } - public Entity makeEntity(World world) { + public Entity makeEntity(World world, double x, double y, double z) { EntityEntry entry = ForgeRegistries.ENTITIES.getValue(this.entity); if (entry == null) return null; - return entry.newInstance(world); + Entity entity = entry.newInstance(world); + entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F); + if (entity instanceof EntityLiving) { + EntityLiving living = (EntityLiving) entity; + living.rotationYawHead = entity.rotationYaw; + living.renderYawOffset = entity.rotationYaw; + living.onInitialSpawn(world.getDifficultyForLocation(living.getPosition()), null); + } + return entity; } public AnimalSpawnerRecipe register() { diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java index ab03fcd8..3b4a58cb 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalSpawner.java @@ -9,7 +9,6 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks; import de.ellpeck.naturesaura.packet.PacketHandler; import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; @@ -53,15 +52,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable this.time += 10; if (this.time >= this.currentRecipe.time) { - Entity entity = this.currentRecipe.makeEntity(this.world); - entity.setLocationAndAngles(this.spawnX, this.pos.getY() + 1, this.spawnZ, - MathHelper.wrapDegrees(this.world.rand.nextFloat() * 360F), 0F); - if (entity instanceof EntityLiving) { - EntityLiving living = (EntityLiving) entity; - living.rotationYawHead = entity.rotationYaw; - living.renderYawOffset = entity.rotationYaw; - living.onInitialSpawn(this.world.getDifficultyForLocation(living.getPosition()), null); - } + Entity entity = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ); this.world.spawnEntity(entity); this.currentRecipe = null; @@ -125,8 +116,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable this.world.rand.nextFloat() + 0.5F); if (this.entityClient == null) { - this.entityClient = this.currentRecipe.makeEntity(this.world); - this.entityClient.setPosition(this.spawnX, this.pos.getY() + 1, this.spawnZ); + this.entityClient = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ); } AxisAlignedBB bounds = this.entityClient.getEntityBoundingBox(); for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--) diff --git a/src/main/java/de/ellpeck/naturesaura/compat/jei/animal/AnimalSpawnerCategory.java b/src/main/java/de/ellpeck/naturesaura/compat/jei/animal/AnimalSpawnerCategory.java index 5abb4190..d448485c 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/jei/animal/AnimalSpawnerCategory.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/jei/animal/AnimalSpawnerCategory.java @@ -63,7 +63,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory