From 0c143b9bd866154712905a41f35665351c587cf6 Mon Sep 17 00:00:00 2001 From: Lord Cambion Date: Tue, 17 Mar 2026 01:28:12 +0100 Subject: [PATCH] Can now have the mob they spawn change by placing the corresponding spawn egg --- Minecraft.World/MobSpawnerTileEntity.cpp | 23 ++++++++++++++++++++ Minecraft.World/MobSpawnerTileEntity.h | 1 + Minecraft.World/SpawnEggItem.cpp | 27 ++++++++++++++++-------- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/Minecraft.World/MobSpawnerTileEntity.cpp b/Minecraft.World/MobSpawnerTileEntity.cpp index e3ee57d6..1db58f41 100644 --- a/Minecraft.World/MobSpawnerTileEntity.cpp +++ b/Minecraft.World/MobSpawnerTileEntity.cpp @@ -99,4 +99,27 @@ shared_ptr MobSpawnerTileEntity::clone() void MobSpawnerTileEntity::setEntityId(const wstring &id) { spawner->setEntityId(id); + + if (spawner != nullptr) + { + + spawner->spawnDelay = 20; + } + + if (level != nullptr) + { + level->sendTileUpdated(x, y, z); + } + +} + +void MobSpawnerTileEntity::setEntityIdFromEgg(const wstring &id) +{ + + spawner->setEntityId(id); + + + if (level != nullptr) { + level->sendTileUpdated(x, y, z); + } } \ No newline at end of file diff --git a/Minecraft.World/MobSpawnerTileEntity.h b/Minecraft.World/MobSpawnerTileEntity.h index b649702b..f1c16966 100644 --- a/Minecraft.World/MobSpawnerTileEntity.h +++ b/Minecraft.World/MobSpawnerTileEntity.h @@ -46,4 +46,5 @@ public: // 4J Added virtual shared_ptr clone(); void setEntityId(const wstring &id); + void setEntityIdFromEgg(const wstring &id); }; diff --git a/Minecraft.World/SpawnEggItem.cpp b/Minecraft.World/SpawnEggItem.cpp index 5124f668..da7c7ec7 100644 --- a/Minecraft.World/SpawnEggItem.cpp +++ b/Minecraft.World/SpawnEggItem.cpp @@ -193,20 +193,29 @@ bool SpawnEggItem::useOn(shared_ptr itemInstance, shared_ptrgetTile(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 mste = dynamic_pointer_cast( level->getTileEntity(x,y,z) ); - if(mste != nullptr) + + shared_ptr spawnerTile = dynamic_pointer_cast(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];