Skip to content

Commit

Permalink
cstacksize -> ccalcstack
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Jul 2, 2020
1 parent becc848 commit 94ea858
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static void registerCommands(CommandDispatcher<ServerCommandSource> dispa
GlowCommand.register(dispatcher);
GetDataCommand.register(dispatcher);
ScriptCommand.register(dispatcher);
StackSizeCommand.register(dispatcher);
CalcStackCommand.register(dispatcher);

CrackRNGCommand.register(dispatcher);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import static net.earthcomputer.clientcommands.command.ClientCommandManager.*;
import static net.minecraft.server.command.CommandManager.*;

public class StackSizeCommand {
public class CalcStackCommand {

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
addClientSideCommand("cstacksize");
addClientSideCommand("ccalcstack");

dispatcher.register(literal("cstacksize")
dispatcher.register(literal("ccalcstack")
.then(argument("count", integer(0))
.then(argument("item", itemStack())
.executes(ctx -> {
Expand All @@ -31,29 +31,30 @@ public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
})));
}

public static int getStackSize(ServerCommandSource source, ItemStack stack, int count) {
private static int getStackSize(ServerCommandSource source, ItemStack stack, int count) {
int stacks = count / stack.getMaxCount();
int remainder = count % stack.getMaxCount();

if (stack.isEmpty()) {
if (remainder == 0) {
sendFeedback(new TranslatableText("commands.cstacksize.success.empty.exact", count, stacks));
sendFeedback(new TranslatableText("commands.ccalcstack.success.empty.exact", count, stacks));
} else {
sendFeedback(new TranslatableText("commands.cstacksize.success.empty", count, stacks, remainder));
sendFeedback(new TranslatableText("commands.ccalcstack.success.empty", count, stacks, remainder));
}
} else {
Text itemText = stack.toHoverableText();
if (remainder == 0) {
sendFeedback(new TranslatableText("commands.cstacksize.success.exact", count, itemText, stacks));
sendFeedback(new TranslatableText("commands.ccalcstack.success.exact", count, itemText, stacks));
} else {
sendFeedback(new TranslatableText("commands.cstacksize.success", count, itemText, stacks, remainder));
sendFeedback(new TranslatableText("commands.ccalcstack.success", count, itemText, stacks, remainder));
}
}

return 1;
}

public static int getStackSize(ServerCommandSource source, int count) {
private static int getStackSize(ServerCommandSource source, int count) {
assert MinecraftClient.getInstance().player != null;
ItemStack heldStack = MinecraftClient.getInstance().player.getStackInHand(Hand.MAIN_HAND).copy();
return getStackSize(source, heldStack, count);
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/assets/clientcommands/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"commands.ccalc.expected": "Expected %s",
"commands.ccalc.invalidArgumentCount": "Function \"%s\" cannot take %d arguments",

"commands.ccalcstack.success": "%d %s is %d stacks and %d extra",
"commands.ccalcstack.success.empty": "%d items is %d stacks and %d extra",
"commands.ccalcstack.success.empty.exact": "%d items is exactly %d stacks",
"commands.ccalcstack.success.exact": "%d %s is exactly %d stacks",

"commands.ccrackrng.starting": "Cracking player seed",
"commands.ccrackrng.success": "Player RNG cracked: %d",

Expand Down Expand Up @@ -36,11 +41,6 @@
"commands.cscript.reload.success": "Reloaded scripts",
"commands.cscript.run.success": "Script ran successfully",

"commands.cstacksize.success": "%d %s is %d stacks and %d extra",
"commands.cstacksize.success.empty": "%d items is %d stacks and %d extra",
"commands.cstacksize.success.empty.exact": "%d items is exactly %d stacks",
"commands.cstacksize.success.exact": "%d %s is exactly %d stacks",

"commands.ctask.list.noTasks": "No currently executing tasks",
"commands.ctask.list.success": "%d currently executing tasks",
"commands.ctask.stop.noMatch": "No matching tasks",
Expand Down

0 comments on commit 94ea858

Please sign in to comment.