feat: added item search command
also renamed because it clashed with import
This commit is contained in:
parent
72333dfd33
commit
c2874312d3
1 changed files with 17 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package ftbsc.bscv.commands;
|
package ftbsc.bscv.commands;
|
||||||
|
|
||||||
import com.google.auto.service.AutoService;
|
import com.google.auto.service.AutoService;
|
||||||
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
|
||||||
import ftbsc.bscv.api.ILoadable;
|
import ftbsc.bscv.api.ILoadable;
|
||||||
|
@ -8,11 +9,15 @@ import ftbsc.bscv.tools.Inventory;
|
||||||
import net.minecraft.command.CommandSource;
|
import net.minecraft.command.CommandSource;
|
||||||
import net.minecraft.command.Commands;
|
import net.minecraft.command.Commands;
|
||||||
import net.minecraft.inventory.container.Slot;
|
import net.minecraft.inventory.container.Slot;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
|
||||||
import static ftbsc.bscv.Boscovicino.log;
|
import static ftbsc.bscv.Boscovicino.log;
|
||||||
|
|
||||||
@AutoService(ILoadable.class)
|
@AutoService(ILoadable.class)
|
||||||
public class Item extends AbstractCommand {
|
public class ItemCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "item"; }
|
||||||
|
|
||||||
public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) {
|
public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) {
|
||||||
return builder
|
return builder
|
||||||
|
@ -32,6 +37,17 @@ public class Item extends AbstractCommand {
|
||||||
return 1;
|
return 1;
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
.then(
|
||||||
|
Commands.literal("search")
|
||||||
|
.then(
|
||||||
|
Commands.argument("id", IntegerArgumentType.integer(0))
|
||||||
|
.executes(ctx -> {
|
||||||
|
int item_id = ctx.getArgument("id", Integer.class);
|
||||||
|
log("item #[%d] >> %s", item_id, Item.byId(item_id).toString());
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
.executes(ctx -> {
|
.executes(ctx -> {
|
||||||
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
|
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
|
||||||
if (!slot.hasItem()) return 0;
|
if (!slot.hasItem()) return 0;
|
Loading…
Reference in a new issue