mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-26 21:28:35 +01:00
move this around so that it doesn't revert the sheep color setting
This commit is contained in:
parent
b336b74efa
commit
1104a10397
4 changed files with 17 additions and 17 deletions
|
@ -2,8 +2,10 @@ package de.ellpeck.naturesaura.api.recipes;
|
||||||
|
|
||||||
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.common.registry.EntityEntry;
|
import net.minecraftforge.fml.common.registry.EntityEntry;
|
||||||
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
import net.minecraftforge.fml.common.registry.ForgeRegistries;
|
||||||
|
@ -24,11 +26,19 @@ public class AnimalSpawnerRecipe {
|
||||||
this.time = time;
|
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);
|
EntityEntry entry = ForgeRegistries.ENTITIES.getValue(this.entity);
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return 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() {
|
public AnimalSpawnerRecipe register() {
|
||||||
|
|
|
@ -9,7 +9,6 @@ import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
|
||||||
import de.ellpeck.naturesaura.packet.PacketHandler;
|
import de.ellpeck.naturesaura.packet.PacketHandler;
|
||||||
import de.ellpeck.naturesaura.packet.PacketParticles;
|
import de.ellpeck.naturesaura.packet.PacketParticles;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLiving;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.Ingredient;
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
|
@ -53,15 +52,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
|
|
||||||
this.time += 10;
|
this.time += 10;
|
||||||
if (this.time >= this.currentRecipe.time) {
|
if (this.time >= this.currentRecipe.time) {
|
||||||
Entity entity = this.currentRecipe.makeEntity(this.world);
|
Entity entity = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ);
|
||||||
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);
|
|
||||||
}
|
|
||||||
this.world.spawnEntity(entity);
|
this.world.spawnEntity(entity);
|
||||||
|
|
||||||
this.currentRecipe = null;
|
this.currentRecipe = null;
|
||||||
|
@ -125,8 +116,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
|
||||||
this.world.rand.nextFloat() + 0.5F);
|
this.world.rand.nextFloat() + 0.5F);
|
||||||
|
|
||||||
if (this.entityClient == null) {
|
if (this.entityClient == null) {
|
||||||
this.entityClient = this.currentRecipe.makeEntity(this.world);
|
this.entityClient = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ);
|
||||||
this.entityClient.setPosition(this.spawnX, this.pos.getY() + 1, this.spawnZ);
|
|
||||||
}
|
}
|
||||||
AxisAlignedBB bounds = this.entityClient.getEntityBoundingBox();
|
AxisAlignedBB bounds = this.entityClient.getEntityBoundingBox();
|
||||||
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
|
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerWrapp
|
||||||
@Override
|
@Override
|
||||||
public void drawExtras(Minecraft minecraft) {
|
public void drawExtras(Minecraft minecraft) {
|
||||||
if (this.entity == null)
|
if (this.entity == null)
|
||||||
this.entity = this.recipe.makeEntity(minecraft.world);
|
this.entity = this.recipe.makeEntity(minecraft.world, 0, 0, 0);
|
||||||
|
|
||||||
float size = Math.max(1F, Math.max(this.entity.width, this.entity.height));
|
float size = Math.max(1F, Math.max(this.entity.width, this.entity.height));
|
||||||
renderEntity(this.entity, 35, 28, 35F, 100F / size * 0.4F, size * 0.5F);
|
renderEntity(this.entity, 35, 28, 35F, 100F / size * 0.4F, size * 0.5F);
|
||||||
|
|
|
@ -154,8 +154,8 @@ public final class ModRecipes {
|
||||||
500, 60, Ingredient.fromItem(ModItems.BIRTH_SPIRIT), Ingredient.fromItem(Items.MUTTON),
|
500, 60, Ingredient.fromItem(ModItems.BIRTH_SPIRIT), Ingredient.fromItem(Items.MUTTON),
|
||||||
Ingredient.fromStacks(new ItemStack(Blocks.WOOL, 1, color.getMetadata()))) {
|
Ingredient.fromStacks(new ItemStack(Blocks.WOOL, 1, color.getMetadata()))) {
|
||||||
@Override
|
@Override
|
||||||
public Entity makeEntity(World world) {
|
public Entity makeEntity(World world, double x, double y, double z) {
|
||||||
EntitySheep sheep = (EntitySheep) super.makeEntity(world);
|
EntitySheep sheep = (EntitySheep) super.makeEntity(world, x, y, z);
|
||||||
sheep.setFleeceColor(color);
|
sheep.setFleeceColor(color);
|
||||||
return sheep;
|
return sheep;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue