Search in sources :

Example 1 with EntitySelector

use of net.minecraft.command.EntitySelector in project ArmorStandEditor by Patbox.

the class GeneralCommands method giveTool.

private static int giveTool(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
    ItemStack itemStack = ConfigManager.getConfig().armorStandTool.getDefaultStack();
    itemStack.getOrCreateTag().putBoolean("isArmorStandEditor", true);
    EntitySelector entitySelector = context.getArgument("targets", EntitySelector.class);
    for (ServerPlayerEntity player : entitySelector.getPlayers(context.getSource())) {
        player.inventory.offerOrDrop(player.world, itemStack);
        context.getSource().sendFeedback(new TranslatableText("armorstandeditor.command.give", player.getDisplayName()), true);
    }
    return 1;
}
Also used : TranslatableText(net.minecraft.text.TranslatableText) EntitySelector(net.minecraft.command.EntitySelector) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ItemStack(net.minecraft.item.ItemStack)

Aggregations

EntitySelector (net.minecraft.command.EntitySelector)1 ItemStack (net.minecraft.item.ItemStack)1 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1 TranslatableText (net.minecraft.text.TranslatableText)1