mirror of
https://github.com/quizhizhe/LiteLoaderBDS-1.16.40.git
synced 2025-06-06 12:03:39 +00:00
28 lines
825 B
C++
28 lines
825 B
C++
#include <Global.h>
|
|
#include <MC/Level.hpp>
|
|
#include <MC/Mob.hpp>
|
|
#include <MC/Spawner.hpp>
|
|
#include <MC/ItemStack.hpp>
|
|
#include <MC/ActorDefinitionIdentifier.hpp>
|
|
|
|
Mob* Spawner::spawnMob(Vec3& pos, int dim, std::string name) {
|
|
try {
|
|
if (name.find("minecraft:") == 0)
|
|
name = name.substr(10);
|
|
Vec3 vec{pos.x, pos.y, pos.z};
|
|
ActorDefinitionIdentifier identifier(name);
|
|
return spawnMob(*Level::getBlockSource(dim), identifier, nullptr, vec, 0, 1, 0);
|
|
} catch (...) {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
ItemActor* Spawner::spawnItem(Vec3& pos, int dim, ItemStack* item) {
|
|
try {
|
|
Vec3 vec{pos.x, pos.y, pos.z};
|
|
ItemActor* ac = spawnItem(*Level::getBlockSource(dim), *item, nullptr, vec, 0);
|
|
return ac;
|
|
} catch (...) {
|
|
return nullptr;
|
|
}
|
|
} |