From b691c43c44ff180d10e7d4a9afc83b98551ff586 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Sun, 1 Mar 2026 12:16:08 +0800 Subject: Initial commit --- Minecraft.World/EntityIO.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Minecraft.World/EntityIO.h (limited to 'Minecraft.World/EntityIO.h') diff --git a/Minecraft.World/EntityIO.h b/Minecraft.World/EntityIO.h new file mode 100644 index 00000000..c9aa9f65 --- /dev/null +++ b/Minecraft.World/EntityIO.h @@ -0,0 +1,61 @@ +#pragma once +using namespace std; + +#include "Entity.h" +#include "JavaIntHash.h" + +class Level; +class CompoundTag; +typedef Entity *(*entityCreateFn)(Level *); +class EntityIO +{ +public: + class SpawnableMobInfo + { + public: + int id; + eMinecraftColour eggColor1; + eMinecraftColour eggColor2; + int nameId; // 4J Added + + SpawnableMobInfo(int id, eMinecraftColour eggColor1, eMinecraftColour eggColor2, int nameId) + { + this->id = id; + this->eggColor1 = eggColor1; + this->eggColor2 = eggColor2; + this->nameId = nameId; + } + }; + +private: + static unordered_map *idCreateMap; + static unordered_map *classIdMap; + static unordered_map *numCreateMap; + static unordered_map *numClassMap; + static unordered_map *classNumMap; + static unordered_map *idNumMap; + +public: + static unordered_map idsSpawnableInCreative; + +private: + static void setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum); + static void setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum, eMinecraftColour color1, eMinecraftColour color2, int nameId); + +public: + static void staticCtor(); + static shared_ptr newEntity(const wstring& id, Level *level); + static shared_ptr loadStatic(CompoundTag *tag, Level *level); + static shared_ptr newById(int id, Level *level); + static shared_ptr newByEnumType(eINSTANCEOF eType, Level *level); + static int getId(shared_ptr entity); + static wstring getEncodeId(shared_ptr entity); + static int getId(const wstring &encodeId); + static wstring getEncodeId(int entityIoValue); + static int getNameId(int entityIoValue); + static eINSTANCEOF getType(const wstring &idString); + static eINSTANCEOF getClass(int id); + + // 4J-JEV, added for enumerating mobs. + static int eTypeToIoid(eINSTANCEOF eType); +}; -- cgit v1.2.3