A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3KB

  1. using System;
  2. using RobocraftX.Common.Input;
  3. using RobocraftX.Multiplayer.Input;
  4. using GamecraftModdingAPI.Blocks;
  5. using GamecraftModdingAPI.Utility;
  6. using HarmonyLib;
  7. namespace GamecraftModdingAPI.Inventory
  8. {
  9. public static class Hotbar
  10. {
  11. private static readonly HotbarEngine hotbarEngine = new HotbarEngine();
  12. /// <summary>
  13. /// Switch the block in the player's hand
  14. /// </summary>
  15. /// <param name="block">The block to switch to.</param>
  16. /// <param name="playerID">The player. Omit this to use the local player.</param>
  17. public static void EquipBlock(BlockIDs block, uint playerID = uint.MaxValue)
  18. {
  19. if (playerID == uint.MaxValue)
  20. {
  21. playerID = hotbarEngine.GetLocalPlayerID();
  22. }
  23. hotbarEngine.SelectBlock((int) block, playerID);
  24. // cubeSelectedByPick = true will crash the game
  25. // (this would be equivalent to mouse middle click pick block action)
  26. // reason: the game expects a Dictionary entry for the tweaked stats
  27. }
  28. /// <summary>
  29. /// Gets the block in the player's hand
  30. /// </summary>
  31. /// <returns>The equipped block.</returns>
  32. public static BlockIDs GetEquippedBlock()
  33. {
  34. return HotbarSlotSelectionHandlerEnginePatch.EquippedPartID;
  35. }
  36. public static void Init()
  37. {
  38. GameEngineManager.AddGameEngine(hotbarEngine);
  39. }
  40. }
  41. }