From f43ca6bfd31f60cbf1cc4c21a638ad5cb9c25ec1 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Mon, 6 Jan 2020 23:38:04 -0600 Subject: [PATCH] Fix skyblock spread command applying to the command executor not the argument --- .../common/core/command/CommandSkyblockSpread.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java index c552e7ab1..5bbb19433 100644 --- a/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java +++ b/src/main/java/vazkii/botania/common/core/command/CommandSkyblockSpread.java @@ -12,9 +12,12 @@ package vazkii.botania.common.core.command; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.context.CommandContext; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.command.CommandSource; import net.minecraft.command.Commands; import net.minecraft.command.arguments.EntityArgument; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.math.BlockPos; import vazkii.botania.common.core.helper.MathHelper; @@ -29,12 +32,13 @@ public class CommandSkyblockSpread { .requires(s -> s.hasPermissionLevel(2)) .then(Commands.argument("player", EntityArgument.player()) .then(Commands.argument("range", IntegerArgumentType.integer(250, 1000000)) - .executes(ctx -> run(ctx.getSource().asPlayer(), IntegerArgumentType.getInteger(ctx, "range")))) - .executes(ctx -> run(ctx.getSource().asPlayer(), DEFAULT_RANGE))) + .executes(ctx -> run(ctx, IntegerArgumentType.getInteger(ctx, "range")))) + .executes(ctx -> run(ctx, DEFAULT_RANGE))) ); } - private static int run(ServerPlayerEntity player, int range) { + private static int run(CommandContext ctx, int range) throws CommandSyntaxException { + PlayerEntity player = EntityArgument.getPlayer(ctx, "player"); int minDist = 100; BlockPos spawn = player.world.getSpawnPoint(); int x, z;