aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/TickNextTickData.cpp
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/TickNextTickData.cpp
parentdef8cb415354ac390b7e89052a50605285f1aca9 (diff)
Initial commit
Diffstat (limited to 'Minecraft.World/TickNextTickData.cpp')
-rw-r--r--Minecraft.World/TickNextTickData.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/Minecraft.World/TickNextTickData.cpp b/Minecraft.World/TickNextTickData.cpp
new file mode 100644
index 00000000..95cab285
--- /dev/null
+++ b/Minecraft.World/TickNextTickData.cpp
@@ -0,0 +1,69 @@
+#include "stdafx.h"
+
+#include "TickNextTickData.h"
+
+__int64 TickNextTickData::C = 0;
+
+TickNextTickData::TickNextTickData(int x, int y, int z, int tileId)
+{
+ m_delay = 0;
+ c = C++;
+
+ this->x = x;
+ this->y = y;
+ this->z = z;
+ this->tileId = tileId;
+}
+
+
+bool TickNextTickData::equals(const void *o) const
+{
+ // TODO 4J Is this safe to cast it before we do a dynamic_cast? Will the dynamic_cast still fail?
+ // We cannot dynamic_cast a void*
+ if ( dynamic_cast<TickNextTickData *>( (TickNextTickData *) o ) != NULL)
+ {
+ TickNextTickData *t = (TickNextTickData *) o;
+ return x == t->x && y == t->y && z == t->z && tileId == t->tileId;
+ }
+ return false;
+}
+
+int TickNextTickData::hashCode() const
+{
+ return (((x * 1024 * 1024) + (z * 1024) + y) * 256) + tileId;
+}
+
+TickNextTickData *TickNextTickData::delay(__int64 l)
+{
+ this->m_delay = l;
+ return this;
+}
+
+int TickNextTickData::compareTo(const TickNextTickData *tnd) const
+{
+ if (m_delay < tnd->m_delay) return -1;
+ if (m_delay > tnd->m_delay) return 1;
+ if (c < tnd->c) return -1;
+ if (c > tnd->c) return 1;
+ return 0;
+}
+
+//A class that takes two arguments of the same type as the container elements and returns a bool.
+//The expression comp(a,b), where comp is an object of this comparison class and a and b are elements of the container,
+//shall return true if a is to be placed at an earlier position than b in a strict weak ordering operation.
+//This can either be a class implementing a function call operator or a pointer to a function (see constructor for an example).
+//This defaults to less<Key>, which returns the same as applying the less-than operator (a<b).
+bool TickNextTickData::compare_fnct(const TickNextTickData &x, const TickNextTickData &y)
+{
+ return x.compareTo( &y ) < 0;
+}
+
+int TickNextTickData::hash_fnct(const TickNextTickData &k)
+{
+ return k.hashCode();
+}
+
+bool TickNextTickData::eq_test(const TickNextTickData &x, const TickNextTickData &y)
+{
+ return ( x.x == y.x ) && ( x.y == y.y ) && ( x.z == y.z ) && ( x.tileId == y.tileId );
+} \ No newline at end of file