Fixed some mobs causing client crashes when spawning with the altar of birthing

Closes #140
This commit is contained in:
Ell 2020-09-02 21:25:02 +02:00
parent 71742c5b3a
commit 1ccdc83c1f
4 changed files with 12 additions and 16 deletions

View file

@ -110,7 +110,7 @@ dependencies {
compileOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0-beta2:api")
compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.15.1:6.0.0.4")
compile fg.deobf("quarris.enchantability:Enchantability:8.4.23")
compile fg.deobf("quarris.enchantability:Enchantability:8.1.17")
}
// Example for how to get properties into the manifest for reading by the runtime..

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,8 @@ 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.spawnX, this.pos.getY() + 1, this.spawnZ);
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();
for (int i = this.world.rand.nextInt(5) + 5; i >= 0; i--)

View file

@ -25,6 +25,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 java.util.Arrays;
import java.util.HashMap;
@ -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.minecraftforge.registries.ForgeRegistries;
@ -37,18 +38,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(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(world, null, null, null, pos, SpawnReason.SPAWNER, false, false);
}
@Override