Skip to content

Commit f3365dd

Browse files
committed
Fix /spawn not working
1 parent 6eabd50 commit f3365dd

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ org.gradle.jvmargs=-Xmx1G
99
fabric_version=0.92.2+1.20.1
1010

1111
# Mod Properties
12-
mod_version = 2.0.0
12+
mod_version = 2.0.1
1313
maven_group = com.lx862.svrutil
1414
archives_base_name = svrutil
1515

src/main/java/com/lx862/svrutil/commands/spawn.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
import net.minecraft.server.command.CommandManager;
1010
import net.minecraft.server.command.ServerCommandSource;
1111
import net.minecraft.server.network.ServerPlayerEntity;
12+
import net.minecraft.server.world.ServerWorld;
1213
import net.minecraft.text.Text;
1314
import net.minecraft.util.Formatting;
1415
import net.minecraft.util.math.BlockPos;
16+
import net.minecraft.world.World;
1517

1618
public class spawn {
1719
private static final CommandEntry defaultEntry = new CommandEntry("spawn", 0, true);
@@ -30,15 +32,18 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
3032
}
3133

3234
public static int execute(CommandContext<ServerCommandSource> context, ServerPlayerEntity player, boolean personal) throws CommandSyntaxException {
33-
BlockPos spawnPoint = null;
35+
final ServerWorld dimension;
36+
final BlockPos spawnPoint;
3437
if(personal) {
3538
spawnPoint = player.getSpawnPointPosition();
36-
}
37-
if(spawnPoint == null) {
39+
dimension = context.getSource().getServer().getWorld(player.getSpawnPointDimension());
40+
} else {
3841
spawnPoint = context.getSource().getWorld().getSpawnPos();
42+
dimension = context.getSource().getWorld();
3943
}
4044

41-
player.requestTeleportAndDismount(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ());
45+
player.dismountVehicle();
46+
player.requestTeleport(spawnPoint.getX(), spawnPoint.getY(), spawnPoint.getZ());
4247
context.getSource().sendFeedback(() -> Text.literal("Teleported back to spawn.").formatted(Formatting.GREEN), false);
4348
Commands.finishedExecution(context, defaultEntry);
4449
return 1;

0 commit comments

Comments
 (0)