feat: added item command

mostly for debugging autotool...
This commit is contained in:
əlemi 2023-03-04 01:30:59 +01:00
parent 414fbf4962
commit 8813dda003
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -0,0 +1,43 @@
package ftbsc.bscv.commands;
import com.google.auto.service.AutoService;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.tools.Inventory;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.inventory.container.Slot;
import static ftbsc.bscv.Boscovicino.log;
@AutoService(ILoadable.class)
public class Item extends AbstractCommand {
public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) {
return builder
.then(
Commands.literal("damage")
.executes(ctx -> {
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
if (!slot.hasItem()) return 0;
log(
String.format(
"A %.1f | S %.1f | DPS %.2f",
Inventory.itemAttackDamage(slot.getItem()),
Inventory.itemAttackSpeed(slot.getItem()),
Inventory.itemDPS(slot.getItem())
)
);
return 1;
})
)
.executes(ctx -> {
Slot slot = Inventory.hotbar(MC.player).get(MC.player.inventory.selected);
if (!slot.hasItem()) return 0;
log(slot.getItem().toString());
return 1;
});
}
}