added options for drop command

This commit is contained in:
gnembon committed 2020-02-09 01:56:30 -04:00
1 parent 8ed56c1d81
commit 161b5d491d
2 files changed
+41

No files matched your search

@@ -53,7 +53,9 @@ public class PlayerCommand
.then(makeActionCommand("jump", EntityPlayerActionPack.ActionType.JUMP))
.then(makeActionCommand("attack", EntityPlayerActionPack.ActionType.ATTACK))
.then(makeActionCommand("drop", EntityPlayerActionPack.ActionType.DROP_ITEM))
.then(makeDropCommand("drop", false))
.then(makeActionCommand("dropStack", EntityPlayerActionPack.ActionType.DROP_STACK))
.then(makeDropCommand("dropStack", true))
.then(makeActionCommand("swapHands", EntityPlayerActionPack.ActionType.SWAP_HANDS))
.then(literal("kill").executes(PlayerCommand::kill))
.then(literal("shadow"). executes(PlayerCommand::shadow))
@@ -105,6 +107,19 @@ public class PlayerCommand
.executes(c -> action(c, type, EntityPlayerActionPack.Action.interval(IntegerArgumentType.getInteger(c, "ticks"))))));
}
private static LiteralArgumentBuilder<ServerCommandSource> makeDropCommand(String actionName, boolean dropAll)
{
return literal(actionName)
.then(literal("all").executes(c ->manipulate(c, ap -> ap.drop(-2,dropAll))))
.then(literal("mainhand").executes(c ->manipulate(c, ap -> ap.drop(-1,dropAll))))
.then(literal("offhand").executes(c ->manipulate(c, ap -> ap.drop(40,dropAll))))
.then(argument("slot", IntegerArgumentType.integer(0, 40)).
executes(c ->manipulate(c, ap -> ap.drop(
IntegerArgumentType.getInteger(c,"slot"),
dropAll
))));
}
private static Collection<String> getPlayers(ServerCommandSource source)
{
Set<String> players = Sets.newLinkedHashSet(Arrays.asList("Steve", "Alex"));