mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Use fabric-dimensions API for x-dimension teleportation, fix #457
This commit is contained in:
3 files changed
+22
-9
No files matched your search
@@ -16,6 +16,7 @@ dependencies {
|
||||
api 'net.william278:DesertWell:2.0.4'
|
||||
api 'dev.dejvokep:boosted-yaml:1.3.1'
|
||||
api 'net.kyori:adventure-api:4.14.0'
|
||||
api 'net.kyori:adventure-text-serializer-gson:4.14.0'
|
||||
api('com.zaxxer:HikariCP:5.0.1') {
|
||||
exclude module: 'slf4j-api'
|
||||
}
|
||||
|
||||
+2
-1
@@ -16,7 +16,8 @@ dependencies {
|
||||
'fabric-lifecycle-events-v1',
|
||||
'fabric-entity-events-v1',
|
||||
'fabric-command-api-v2',
|
||||
'fabric-networking-api-v1'
|
||||
'fabric-networking-api-v1',
|
||||
'fabric-dimensions-v1',
|
||||
]
|
||||
fabricApiModules.forEach {
|
||||
modImplementation(fabricApi.module(it, fabric_api_version))
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package net.william278.huskhomes.user;
|
||||
|
||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
||||
import net.fabricmc.fabric.api.dimension.v1.FabricDimensions;
|
||||
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.minecraft.network.PacketByteBuf;
|
||||
@@ -28,6 +29,8 @@ import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.TeleportTarget;
|
||||
import net.william278.huskhomes.FabricHuskHomes;
|
||||
import net.william278.huskhomes.position.Location;
|
||||
import net.william278.huskhomes.position.Position;
|
||||
@@ -129,15 +132,23 @@ public class FabricUser extends OnlineUser {
|
||||
@Override
|
||||
public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException {
|
||||
final MinecraftServer server = player.getServer();
|
||||
assert server != null : "Server is null";
|
||||
final Identifier worldId = Identifier.tryParse(location.getWorld().getName());
|
||||
player.teleport(
|
||||
if (server == null) {
|
||||
throw new TeleportationException(TeleportationException.Type.ILLEGAL_TARGET_COORDINATES, plugin);
|
||||
}
|
||||
|
||||
FabricDimensions.teleport(
|
||||
player,
|
||||
server.getWorld(server.getWorldRegistryKeys().stream()
|
||||
.filter(key -> key.getValue().equals(worldId)).findFirst().orElseThrow(
|
||||
() -> new TeleportationException(TeleportationException.Type.WORLD_NOT_FOUND, plugin))
|
||||
),
|
||||
location.getX(), location.getY(), location.getZ(),
|
||||
location.getYaw(), location.getPitch()
|
||||
.filter(key -> key.getValue().equals(Identifier.tryParse(location.getWorld().getName())))
|
||||
.findFirst().orElseThrow(
|
||||
() -> new TeleportationException(TeleportationException.Type.WORLD_NOT_FOUND, plugin)
|
||||
)),
|
||||
new TeleportTarget(
|
||||
new Vec3d(location.getX(), location.getY(), location.getZ()),
|
||||
Vec3d.ZERO,
|
||||
location.getYaw(),
|
||||
location.getPitch()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user