using Platform; namespace Harmony.TEFeatureSignablePatches { [HarmonyPatch(typeof(TEFeatureSignable))] [HarmonyPatch("InitBlockActivationCommands")] public class InitBlockActivationCommandsPatch { public static void Postfix(TEFeatureSignable __instance, Action _addCallback) { _addCallback(new BlockActivationCommand("take", "hand", false), TileEntityComposite.EBlockCommandOrder.Normal, __instance.FeatureData); } } [HarmonyPatch(typeof(TEFeatureSignable))] [HarmonyPatch("UpdateBlockActivationCommands")] public class UpdateBlockActivationCommandsPatch { public static void Postfix(TEFeatureSignable __instance, ref BlockActivationCommand _command, ReadOnlySpan _commandName, WorldBase _world, Vector3i _blockPos, BlockValue _blockValue, EntityAlive _entityFocusing) { if (__instance.CommandIs(_commandName, "take")) { if (__instance.lockFeature != null && __instance.TryGetSelfOrFeature(out ITileEntityLootable storage)) { _command.enabled = storage.IsEmpty() && __instance.lockFeature.IsOwner(PlatformManager.InternalLocalUserIdentifier); } } } } [HarmonyPatch(typeof(TEFeatureSignable))] [HarmonyPatch("OnBlockActivated")] public class OnBlockActivatedPatch { public static void Postfix(TEFeatureSignable __instance, ReadOnlySpan _commandName, WorldBase _world, Vector3i _blockPos, BlockValue _blockValue, EntityPlayerLocal _player) { if (__instance.CommandIs(_commandName, "take")) { RebirthUtilities.TakeItemWithTimer(_world, 0, _blockPos, _blockValue, _player, 2f, null, "", 1, false); } } } }