diff --git a/scripts/teleporter.zs b/scripts/teleporter.zs index 9098fad..b46f96e 100644 --- a/scripts/teleporter.zs +++ b/scripts/teleporter.zs @@ -12,15 +12,23 @@ import mods.contenttweaker.ActionResult; var small_teleporter = VanillaFactory.createItem("small_teleporter"); small_teleporter.itemRightClick = function(stack, world, player, hand) { - if (!world.remote && hand has "MAIN_HAND") { - Commands.call("pillar-spawn basement ~-13.5 ~-100 ~-13.5", player, world, false, true); - Commands.call("give @p contenttweaker:teleporter 1 0 {x:" + player.x + ",y:" + player.y + ",z:" + player.z + "}", player, world, false, true); - - stack.shrink(1); - - Commands.call("tp @p " + (player.x) as string + " " + ((player.y - 96)) as string + " " + (player.z) as string, player, world, false, true); - } - return "SUCCESS"; + if (!world.remote && hand == "MAIN_HAND") { + var x = player.x; + var y = player.y; + var z = player.z; + + Commands.call("pillar-spawn basement " + (x - 13.5) + " " + (y - 100.0) + " " + (z - 13.5), player, world, false, true); + + var nbtData as IData = {x: x, y: y, z: z}; + var teleporter = .withTag(nbtData); + + player.setItemToSlot(IEntityEquipmentSlot.mainHand(), teleporter); + + Commands.call("tp @p " + x as string + " " + (y - 96.0) as string + " " + z as string, player, world, false, true); + + return "SUCCESS"; + } + return "PASS"; }; small_teleporter.register();