add dimension to waypoints

This commit is contained in:
ZXMushroom63 2024-12-16 18:52:13 +08:00
parent e33bd95b6a
commit b67cb8ec3a

View File

@ -92,7 +92,7 @@
if (!data[name]) {
data[name] = {};
}
data[name][waypointId] = [pos.x,pos.y,pos.z];
data[name][waypointId] = [pos.x,pos.y,pos.z,e.sender.dimension];
saveData();
e.sender.addChatMessage(ModAPI.reflect.getClassById("net.minecraft.util.ChatComponentText").constructors[0](ModAPI.util.str("Set waypoint "+waypointId+".")));
}
@ -103,6 +103,10 @@
if (waypointId && Array.isArray(data?.[name]?.[waypointId])) {
// Wildly important! regular setPosition triggers minecraft's built in anti-cheat and teleports you back in the same tick.
if (data?.[name]?.[waypointId]?.[3] && (data?.[name]?.[waypointId]?.[3] !== e.sender.dimension)) {
e.sender.travelToDimension(data?.[name]?.[waypointId]?.[3]);
}
e.sender.setPositionAndUpdate(...data?.[name]?.[waypointId]);
e.sender.addChatMessage(ModAPI.reflect.getClassById("net.minecraft.util.ChatComponentText").constructors[0](ModAPI.util.str("Teleported to waypoint " + waypointId + ".")));