mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Inventory handling
This commit is contained in:
parent
c870f080f2
commit
bc449b404e
20 changed files with 538 additions and 44 deletions
42
MinecraftClient/Commands/ChangeSlot.cs
Normal file
42
MinecraftClient/Commands/ChangeSlot.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class ChangeSlot : Command
|
||||
{
|
||||
public override string CMDName { get { return "changeslot"; } }
|
||||
public override string CMDDesc { get { return "changeslot <1-9>: Change hotbar"; } }
|
||||
|
||||
public override string Run(McTcpClient handler, string command)
|
||||
{
|
||||
if (!handler.GetInventoryEnabled()) return "Please enable InventoryHandling in the config file first.";
|
||||
if (hasArg(command))
|
||||
{
|
||||
short slot;
|
||||
try
|
||||
{
|
||||
slot = Convert.ToInt16(getArg(command));
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
return "Could not change slot: Not a Number";
|
||||
}
|
||||
if (slot >= 1 && slot <= 9)
|
||||
{
|
||||
if (handler.ChangeSlot(slot-=1))
|
||||
{
|
||||
return "Changed to slot " + (slot+=1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Could not change slot";
|
||||
}
|
||||
}
|
||||
}
|
||||
return CMDDesc;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue