From b67cb8ec3ad3bae00d9cf93cae185d006276a034 Mon Sep 17 00:00:00 2001 From: ZXMushroom63 Date: Mon, 16 Dec 2024 18:52:13 +0800 Subject: [PATCH] add dimension to waypoints --- examplemods/waypoints.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examplemods/waypoints.js b/examplemods/waypoints.js index e3794c3..29f6836 100644 --- a/examplemods/waypoints.js +++ b/examplemods/waypoints.js @@ -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 + ".")));