Can now have the mob they spawn change by placing the corresponding spawn egg

This commit is contained in:
Lord Cambion
2026-03-17 01:28:12 +01:00
parent 1494f4fe5b
commit 0c143b9bd8
3 changed files with 42 additions and 9 deletions
+18 -9
View File
@@ -193,20 +193,29 @@ bool SpawnEggItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Playe
int tile = level->getTile(x, y, z);
#ifndef _CONTENT_PACKAGE
if(app.DebugArtToolsOn() && tile == Tile::mobSpawner_Id)
if (tile == Tile::mobSpawner_Id)
{
// 4J Stu - Force adding this as a tile update
level->removeTile(x,y,z);
level->setTileAndData(x,y,z,Tile::mobSpawner_Id, 0, Tile::UPDATE_ALL);
shared_ptr<MobSpawnerTileEntity> mste = dynamic_pointer_cast<MobSpawnerTileEntity>( level->getTileEntity(x,y,z) );
if(mste != nullptr)
shared_ptr<MobSpawnerTileEntity> spawnerTile = dynamic_pointer_cast<MobSpawnerTileEntity>(level->getTileEntity(x, y, z));
if (spawnerTile != nullptr)
{
mste->setEntityId( EntityIO::getEncodeId(itemInstance->getAuxValue()) );
int mobId = itemInstance->getAuxValue() & 0xFFF;
spawnerTile->setEntityId(EntityIO::getEncodeId(mobId));
if (!player->abilities.instabuild && !bTestUseOnOnly)
{
itemInstance->count--;
}
return true;
}
}
#endif
x += Facing::STEP_X[face];
y += Facing::STEP_Y[face];