Skip to content

Commit

Permalink
feat(utils): methods for teleporting entity to dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Aug 13, 2022
1 parent 768716c commit b89379a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Expand Up @@ -5,6 +5,7 @@
import java.util.function.Predicate;
import javax.annotation.Nullable;
import net.minecraft.core.Vec3i;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntitySelector;
import net.minecraft.world.entity.LivingEntity;
Expand All @@ -31,6 +32,14 @@ public static void teleportTo(Entity entity, Vec3 pos) {
entity.teleportTo(pos.x, pos.y, pos.z);
}

public static void teleportTo(Entity entity, ResourceKey<Level> dim, Vec3 pos) {
entity.changeDimension(LevelUtils.getLevel(dim), LevelUtils.createSimpleTeleporter(pos));
}

public static void teleportTo(Entity entity, ResourceKey<Level> dim, Vec3i pos) {
entity.changeDimension(LevelUtils.getLevel(dim), LevelUtils.createSimpleTeleporter(pos));
}

// #endregion Teleport

/*================================================================================================================*/
Expand Down
Expand Up @@ -48,6 +48,10 @@ static ITeleporter createSimpleTeleporter(Vec3i pos) {
return createSimpleTeleporter(Vec3.atCenterOf(pos), false);
}

static ITeleporter createSimpleTeleporter(Vec3 pos) {
return createSimpleTeleporter(pos, false);
}

static ITeleporter createSimpleTeleporter(double x, double y, double z) {
return createSimpleTeleporter(new Vec3(x, y, z), false);
}
Expand Down

0 comments on commit b89379a

Please sign in to comment.