fixed a merge issue

This commit is contained in:
Ell 2020-09-22 03:24:28 +02:00
parent 9e0a2a65d1
commit be408e2d70
3 changed files with 10 additions and 15 deletions

View file

@ -57,7 +57,7 @@ public class TileEntityAnimalSpawner extends TileEntityImpl implements ITickable
this.time += 10;
if (this.time >= this.currentRecipe.time) {
Entity entity = this.currentRecipe.makeEntity(this.world, this.spawnX, this.pos.getY() + 1, this.spawnZ);
Entity entity = this.currentRecipe.makeEntity(this.world, new BlockPos(this.spawnX, this.pos.getY() + 1, this.spawnZ));
this.world.addEntity(entity);
this.currentRecipe = null;
@ -121,7 +121,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, 0, 0, 0);
this.entityClient = this.currentRecipe.makeEntity(this.world, BlockPos.ZERO);
this.entityClient.setPosition(this.spawnX, this.pos.getY() + 1, this.spawnZ);
}
AxisAlignedBB bounds = this.entityClient.getBoundingBox();

View file

@ -23,6 +23,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.item.SpawnEggItem;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Quaternion;
import net.minecraft.util.math.vector.Vector3f;
@ -126,7 +127,7 @@ public class AnimalSpawnerCategory implements IRecipeCategory<AnimalSpawnerRecip
Minecraft minecraft = Minecraft.getInstance();
Entity entity = this.entityCache.get(recipe.entity);
if (entity == null) {
entity = recipe.makeEntity(minecraft.world, 0, 0, 0);
entity = recipe.makeEntity(minecraft.world, BlockPos.ZERO);
this.entityCache.put(recipe.entity, entity);
}

View file

@ -13,6 +13,7 @@ import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
@ -39,18 +40,11 @@ public class AnimalSpawnerRecipe extends ModRecipe {
this.time = time;
}
public Entity makeEntity(World world, double x, double y, double z) {
Entity entity = this.entity.create(world);
if (x == 0 && y == 0 && z == 0)
return entity;
entity.setLocationAndAngles(x, y, z, MathHelper.wrapDegrees(world.rand.nextFloat() * 360F), 0F);
if (entity instanceof MobEntity) {
MobEntity living = (MobEntity) entity;
living.rotationYawHead = entity.rotationYaw;
living.renderYawOffset = entity.rotationYaw;
living.onInitialSpawn((ServerWorld) world, world.getDifficultyForLocation(living.getPosition()), SpawnReason.SPAWNER, null, null);
}
return entity;
public Entity makeEntity(World world, BlockPos pos) {
// passed position is zero on the client, so we don't want to do initialization stuff for the entity
if (pos == BlockPos.ZERO)
return this.entity.create(world);
return this.entity.create((ServerWorld) world, null, null, null, pos, SpawnReason.SPAWNER, false, false);
}
@Override