TechbloxModdingAPI/GamecraftModdingAPI/Inventory/Hotbar.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2020-04-02 13:50:30 +00:00
using System;
using RobocraftX.Common.Input;
using RobocraftX.Multiplayer.Input;
using GamecraftModdingAPI.Blocks;
using GamecraftModdingAPI.Utility;
using Harmony;
namespace GamecraftModdingAPI.Inventory
{
public static class Hotbar
{
2020-04-04 18:48:12 +00:00
private static readonly HotbarEngine hotbarEngine = new HotbarEngine();
2020-04-02 13:50:30 +00:00
/// <summary>
/// Switch the block in the player's hand
/// </summary>
/// <param name="block">The block to switch to.</param>
/// <param name="playerID">The player. Omit this to use the local player.</param>
2020-04-02 13:50:30 +00:00
public static void EquipBlock(BlockIDs block, uint playerID = uint.MaxValue)
{
if (playerID == uint.MaxValue)
{
playerID = hotbarEngine.GetLocalPlayerID();
}
hotbarEngine.SelectBlock((int) block, playerID);
// cubeSelectedByPick = true will crash the game
// (this would be equivalent to mouse middle click pick block action)
// reason: the game expects a Dictionary entry for the tweaked stats
}
/// <summary>
/// Gets the block in the player's hand
/// </summary>
/// <returns>The equipped block.</returns>
2020-04-02 13:50:30 +00:00
public static BlockIDs GetEquippedBlock()
{
return HotbarSlotSelectionHandlerEnginePatch.EquippedPartID;
}
public static void Init()
{
GameEngineManager.AddGameEngine(hotbarEngine);
}
}
}