-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77efb8b
commit c330106
Showing
8 changed files
with
77 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/io/github/sakurawald/module/initializer/world/WorldInitializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.github.sakurawald.module.initializer.world; | ||
|
||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.CommandDispatcher; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
import io.github.sakurawald.common.structure.Position; | ||
import io.github.sakurawald.module.initializer.ModuleInitializer; | ||
import io.github.sakurawald.util.CommandUtil; | ||
import io.github.sakurawald.util.MessageUtil; | ||
import net.minecraft.command.CommandRegistryAccess; | ||
import net.minecraft.command.argument.DimensionArgumentType; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.screen.CraftingScreenHandler; | ||
import net.minecraft.screen.ScreenHandlerContext; | ||
import net.minecraft.screen.SimpleNamedScreenHandlerFactory; | ||
import net.minecraft.server.command.CommandManager; | ||
import net.minecraft.server.command.ServerCommandSource; | ||
import net.minecraft.server.world.ServerWorld; | ||
import net.minecraft.stat.Stats; | ||
import net.minecraft.text.Text; | ||
|
||
import java.awt.*; | ||
|
||
import static net.minecraft.server.command.CommandManager.argument; | ||
|
||
|
||
public class WorldInitializer extends ModuleInitializer { | ||
|
||
@Override | ||
public void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess, CommandManager.RegistrationEnvironment environment) { | ||
dispatcher.register(CommandManager.literal("world").then(argument(CommandUtil.ARGUMENT_NAME_DIMENSION, DimensionArgumentType.dimension()).executes(this::$world))); | ||
} | ||
|
||
private int $world(CommandContext<ServerCommandSource> ctx) { | ||
return CommandUtil.playerOnlyCommand(ctx, player -> { | ||
|
||
try { | ||
ServerWorld serverWorld = DimensionArgumentType.getDimensionArgument(ctx, CommandUtil.ARGUMENT_NAME_DIMENSION); | ||
Position.of(player, serverWorld).teleport(player); | ||
} catch (CommandSyntaxException e) { | ||
MessageUtil.sendMessage(player,"dimension.no_found"); | ||
} | ||
|
||
return Command.SINGLE_SUCCESS; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters