use of net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource in project fabric-name-history-lookup by Woolyenough.
the class ClientCommands method names.
private static int names(CommandContext<FabricClientCommandSource> context) {
CompletableFuture.runAsync(() -> {
String name = context.getInput().split(" ")[1];
String[] playerNameAndUUID = get_player_name_and_uuid(name);
String username = playerNameAndUUID[0];
String uuid = playerNameAndUUID[1];
if (Objects.equals(username, "None")) {
context.getSource().sendError(new LiteralText("No account exists by that name .-."));
} else {
context.getSource().sendFeedback(new LiteralText("§7[Hover] §eView name history of " + username).styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + username)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, get_player_name_history(username, uuid).append(new LiteralText("\n\n§7§oClick to open in NameMC!"))))));
}
});
return 0;
}
use of net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource in project isometric-renders by gliscowo.
the class IsoRenderCommand method register.
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(literal("isorender").then(literal("block").executes(context -> executeBlockTarget(context.getSource())).then(argument("block", BlockStateArgumentType.blockState()).executes(context -> {
final BlockStateArgument blockStateArgument = context.getArgument("block", BlockStateArgument.class);
final BlockState blockState = blockStateArgument.getBlockState();
return executeBlockState(context.getSource(), blockState, ((BlockStateArgumentAccessor) blockStateArgument).getData());
}))).then(literal("item").executes(context -> {
return executeItem(context.getSource(), context.getSource().getPlayer().getMainHandStack().copy());
}).then(argument("item", ItemStackArgumentType.itemStack()).executes(context -> {
final ItemStack stack = ItemStackArgumentType.getItemStackArgument(context, "item").createStack(1, false);
return executeItem(context.getSource(), stack);
}))).then(literal("entity").then(argument("entity", EntitySummonArgumentType.entitySummon()).suggests(CLIENT_SUMMONABLE_ENTITIES).executes(context -> {
Identifier id = context.getArgument("entity", Identifier.class);
return executeEntity(context.getSource(), EntitySummonArgumentTypeAccessor.invokeValidate(id), new CompoundTag());
}).then(argument("nbt", NbtCompoundTagArgumentType.nbtCompound()).executes(context -> {
Identifier id = context.getArgument("entity", Identifier.class);
return executeEntity(context.getSource(), EntitySummonArgumentTypeAccessor.invokeValidate(id), context.getArgument("nbt", CompoundTag.class));
})))).then(literal("insanity").executes(context -> {
RuntimeConfig.allowInsaneResolutions = !RuntimeConfig.allowInsaneResolutions;
if (RuntimeConfig.allowInsaneResolutions) {
context.getSource().sendFeedback(prefix("Insane resolutions §cunlocked§7. I will not be your place to cry if this blows up your computer."));
} else {
context.getSource().sendFeedback(prefix("Insane resolutions §alocked§7. You're safe again"));
}
return 0;
})).then(literal("area").then(argument("start", BlockPosArgumentType.blockPos()).then(argument("end", BlockPosArgumentType.blockPos()).executes(context -> {
DefaultPosArgument startArg = context.getArgument("start", DefaultPosArgument.class);
DefaultPosArgument endArg = context.getArgument("end", DefaultPosArgument.class);
BlockPos pos1 = IsometricRenderHelper.getPosFromArgument(startArg, context.getSource());
BlockPos pos2 = IsometricRenderHelper.getPosFromArgument(endArg, context.getSource());
BlockPos start = new BlockPos(Math.min(pos1.getX(), pos2.getX()), Math.min(pos1.getY(), pos2.getY()), Math.min(pos1.getZ(), pos2.getZ()));
BlockPos end = new BlockPos(Math.max(pos1.getX(), pos2.getX()), Math.max(pos1.getY(), pos2.getY()), Math.max(pos1.getZ(), pos2.getZ()));
AreaIsometricRenderScreen screen = new AreaIsometricRenderScreen();
IsometricRenderPresets.setupAreaRender(screen, start, end);
IsometricRenderHelper.scheduleScreen(screen);
return 0;
})))).then(literal("creative_tab").then(argument("itemgroup", ItemGroupArgumentType.itemGroup()).suggests(ITEM_GROUPS).then(literal("batch").then(literal("blocks").executes(context -> {
ItemGroup group = context.getArgument("itemgroup", ItemGroup.class);
IsometricRenderHelper.batchRenderItemGroupBlocks(group);
return 0;
})).then(literal("items").executes(context -> {
ItemGroup group = context.getArgument("itemgroup", ItemGroup.class);
IsometricRenderHelper.batchRenderItemGroupItems(group);
return 0;
}))).then(literal("atlas").executes(context -> {
ItemGroup group = context.getArgument("itemgroup", ItemGroup.class);
IsometricRenderHelper.renderItemGroupAtlas(group);
return 0;
})))));
}
use of net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource in project fabric-name-history-lookup by Woolyenough.
the class ClientCommands method namemc.
private static int namemc(CommandContext<FabricClientCommandSource> context) {
CompletableFuture.runAsync(() -> {
String name = context.getInput().split(" ")[1];
String[] playerNameAndUUID = get_player_name_and_uuid(name);
String username = playerNameAndUUID[0];
if (Objects.equals(username, "None")) {
context.getSource().sendFeedback(new LiteralText("§7[Click] §eSearch " + name + " on NameMC §c§o(account does not exist)").styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + name)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(name + "\n\n§7§oClick to open NameMC")))));
} else {
context.getSource().sendFeedback(new LiteralText("§7[Click] §eLook at " + username + "'s NameMC page").styled(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://namemc.com/profile/" + username)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new LiteralText(username + "\n\n§7§oClick to open NameMC")))));
}
});
return 0;
}
Aggregations