aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/TileEntity.h
diff options
context:
space:
mode:
authordaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
committerdaoge_cmd <3523206925@qq.com>2026-03-01 12:16:08 +0800
commitb691c43c44ff180d10e7d4a9afc83b98551ff586 (patch)
tree3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/TileEntity.h
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/TileEntity.h')
-rw-r--r--Minecraft.World/TileEntity.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/Minecraft.World/TileEntity.h b/Minecraft.World/TileEntity.h
new file mode 100644
index 00000000..aa3ced4f
--- /dev/null
+++ b/Minecraft.World/TileEntity.h
@@ -0,0 +1,74 @@
+#pragma once
+using namespace std;
+
+#include "HashExtension.h"
+#include "..\Minecraft.World\JavaIntHash.h"
+
+class Level;
+class Packet;
+class CompoundTag;
+
+typedef TileEntity *(*tileEntityCreateFn)();
+
+class TileEntity : public enable_shared_from_this<TileEntity>
+{
+public:
+ static void staticCtor();
+ virtual eINSTANCEOF GetType() { return eTYPE_TILEENTITY; }
+private:
+ typedef unordered_map<wstring, tileEntityCreateFn> idToCreateMapType;
+ typedef unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> classToIdMapType;
+ static idToCreateMapType idCreateMap;
+ static classToIdMapType classIdMap;
+ static void setId(tileEntityCreateFn createFn, eINSTANCEOF clas, wstring id);
+ bool remove;
+ unsigned char renderRemoveStage; // 4J added
+
+public:
+ Level *level;
+ int x, y, z;
+
+ // 4J added
+ enum RenderRemoveStage
+ {
+ e_RenderRemoveStageKeep,
+ e_RenderRemoveStageFlaggedAtChunk,
+ e_RenderRemoveStageRemove
+ };
+
+ int data;
+ Tile *tile;
+
+public:
+ // 4J Java does not have a ctor, but we need one to do some initialisation of the member variables
+ TileEntity();
+ virtual ~TileEntity() {}
+
+ void setRenderRemoveStage(unsigned char stage); // 4J added
+ void upgradeRenderRemoveStage(); // 4J added
+ bool shouldRemoveForRender(); // 4J added
+
+ Level *getLevel();
+ void setLevel(Level *level);
+ bool hasLevel();
+ virtual void load(CompoundTag *tag);
+ virtual void save(CompoundTag *tag);
+ virtual void tick();
+ static shared_ptr<TileEntity> loadStatic(CompoundTag *tag);
+ int getData();
+ void setData(int data);
+ void setChanged();
+ double distanceToSqr(double xPlayer, double yPlayer, double zPlayer);
+ Tile *getTile();
+ virtual shared_ptr<Packet> getUpdatePacket();
+ virtual bool isRemoved();
+ virtual void setRemoved();
+ virtual void clearRemoved();
+ virtual void triggerEvent(int b0, int b1);
+ virtual void clearCache();
+
+ // 4J Added
+ virtual shared_ptr<TileEntity> clone() = 0;
+protected:
+ void clone(shared_ptr<TileEntity> tileEntity);
+}; \ No newline at end of file