change mob spawners: fix egg collision

This commit is contained in:
Sen 2025-06-16 18:23:05 +02:00
parent d45a1a8c4a
commit f7bb1b0fe7
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
6 changed files with 11 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 338 B

After

Width:  |  Height:  |  Size: 5.2 KiB

Before After
Before After

View file

@ -1,6 +1,5 @@
package common.block.tech;
import common.model.BlockLayer;
import common.tileentity.TileEntity;
import common.tileentity.TileEntityMobSpawner;
import common.world.World;
@ -9,8 +8,4 @@ public class BlockMobSpawner extends BlockMachine {
public TileEntity createNewTileEntity(World world) {
return new TileEntityMobSpawner();
}
public BlockLayer getBlockLayer() {
return BlockLayer.CUTOUT;
}
}

View file

@ -138,7 +138,7 @@ public abstract class DispenserRegistry {
double d1 = (double)((float)source.getBlockPos().getY() + 0.2F);
double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ();
Entity entity = ItemMonsterPlacer.spawnCreature(source.getWorld(), ((ItemMonsterPlacer)stack.getItem()).getSpawnedId(),
d0, d1, d2);
d0, d1, d2, false);
if (entity instanceof EntityLiving && stack.hasDisplayName())
{

View file

@ -91,7 +91,7 @@ public class ItemMonsterPlacer extends Item
// int amount = Math.min(stack.stackSize, 128);
// for(int z = 0; z < amount; z++) {
Entity entity = spawnCreature(worldIn, this.entityId, (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);
Entity entity = spawnCreature(worldIn, this.entityId, (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D, false);
if (entity != null)
{
@ -153,7 +153,7 @@ public class ItemMonsterPlacer extends Item
{
// int amount = Math.min(itemStackIn.stackSize, 128);
// for(int z = 0; z < amount; z++) {
Entity entity = spawnCreature(worldIn, this.entityId, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);
Entity entity = spawnCreature(worldIn, this.entityId, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D, false);
if (entity != null)
{
@ -184,14 +184,14 @@ public class ItemMonsterPlacer extends Item
}
}
public static EntityLiving spawnCreature(World worldIn, String entityID, double x, double y, double z) {
public static EntityLiving spawnCreature(World worldIn, String entityID, double x, double y, double z, boolean check) {
if (!EntityRegistry.SPAWN_EGGS.containsKey(entityID))
return null;
Entity entity = EntityRegistry.createEntityByName(entityID, worldIn);
if(!(entity instanceof EntityLiving living))
return null;
living.setLocationAndAngles(x, y, z, ExtMath.wrapf(worldIn.rand.floatv() * 360.0F), 0.0F);
if(!living.isNotColliding())
if(check && !living.isNotColliding())
return null;
living.headYaw = living.rotYaw;
living.yawOffset = living.rotYaw;

View file

@ -90,7 +90,7 @@ public class ItemNpcSpawner extends Item
// int amount = Math.min(stack.stackSize, 128);
// for(int z = 0; z < amount; z++) {
Entity entity = spawnNpc(worldIn, this.spawned, (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);
Entity entity = spawnNpc(worldIn, this.spawned, (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D, false);
if (entity != null)
{
@ -144,7 +144,7 @@ public class ItemNpcSpawner extends Item
{
// int amount = Math.min(itemStackIn.stackSize, 128);
// for(int z = 0; z < amount; z++) {
Entity entity = spawnNpc(worldIn, this.spawned, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D);
Entity entity = spawnNpc(worldIn, this.spawned, (double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D, false);
if (entity != null)
{
@ -170,7 +170,7 @@ public class ItemNpcSpawner extends Item
}
}
public static EntityNPC spawnNpc(World worldIn, CharacterInfo character, double x, double y, double z)
public static EntityNPC spawnNpc(World worldIn, CharacterInfo character, double x, double y, double z, boolean check)
{
EntityNPC entity;
try {
@ -180,7 +180,7 @@ public class ItemNpcSpawner extends Item
throw new RuntimeException(e);
}
entity.setLocationAndAngles(x, y, z, ExtMath.wrapf(worldIn.rand.floatv() * 360.0F), 0.0F);
if(!entity.isNotColliding())
if(check && !entity.isNotColliding())
return null;
entity.headYaw = entity.rotYaw;
entity.yawOffset = entity.rotYaw;

View file

@ -56,9 +56,9 @@ public class TileEntityMobSpawner extends TileEntityDevice implements ITickable
double z = (double)this.pos.getZ() + (this.worldObj.rand.doublev() - this.worldObj.rand.doublev()) * (double)this.spawnRange + 0.5D;
EntityLiving entity = null;
if(stack.getItem() instanceof ItemMonsterPlacer egg)
entity = ItemMonsterPlacer.spawnCreature(this.worldObj, egg.getSpawnedId(), x, y, z);
entity = ItemMonsterPlacer.spawnCreature(this.worldObj, egg.getSpawnedId(), x, y, z, true);
else if(stack.getItem() instanceof ItemNpcSpawner egg)
entity = ItemNpcSpawner.spawnNpc(this.worldObj, egg.getSpawnedChar(), x, y, z);
entity = ItemNpcSpawner.spawnNpc(this.worldObj, egg.getSpawnedChar(), x, y, z, true);
if (entity == null)
return true;
this.decrStackSize(0, 1);