Can now have the mob they spawn change by placing the corresponding spawn egg
This commit is contained in:
@@ -99,4 +99,27 @@ shared_ptr<TileEntity> 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);
|
||||
}
|
||||
}
|
||||
@@ -46,4 +46,5 @@ public:
|
||||
// 4J Added
|
||||
virtual shared_ptr<TileEntity> clone();
|
||||
void setEntityId(const wstring &id);
|
||||
void setEntityIdFromEgg(const wstring &id);
|
||||
};
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user