From 22dc8323da445a898bbb2345fdc8afb36c2466d1 Mon Sep 17 00:00:00 2001 From: Brady Stanton Date: Sun, 29 Dec 2024 09:29:17 -0800 Subject: [PATCH 1/3] Converted from .net framework to dotnet 7 --- AccessControls/AccessControls.csproj | 76 +-- AccessControls/Properties/AssemblyInfo.cs | 38 +- AnvilMetalRecovery/AnvilMetalRecovery.csproj | 99 +-- .../MoldDestructionRecovererBehavior.cs | 194 +++--- AnvilMetalRecovery/MetalRecoverySystem.cs | 636 +++++++++--------- AnvilMetalRecovery/Properties/AssemblyInfo.cs | 41 +- Assorted/Assorted.csproj | 182 +++-- Assorted/Properties/AssemblyInfo.cs | 38 +- ElementalTools/ElementalTools.csproj | 212 +++--- ElementalTools/Properties/AssemblyInfo.cs | 42 +- FirstMachineAge_Common/Common.csproj | 36 +- .../Properties/AssemblyInfo.cs | 38 +- First_Machine_Age.sln | 12 +- PsudeoTarget/Properties/AssemblyInfo.cs | 38 +- PsudeoTarget/PsudeoTarget.csproj | 30 +- 15 files changed, 720 insertions(+), 992 deletions(-) diff --git a/AccessControls/AccessControls.csproj b/AccessControls/AccessControls.csproj index a8576f8..bd32e5a 100644 --- a/AccessControls/AccessControls.csproj +++ b/AccessControls/AccessControls.csproj @@ -1,22 +1,16 @@ - - + - Debug - AnyCPU - {180853A2-7E1D-4876-9D1E-AA8608D701C3} + net7.0 Library FirstMachineAge - AccessControls - v4.5 + false + AccessControls + Melchior + 1.0.* - true - full - false bin\Debug DEBUG; - prompt - 4 false @@ -26,58 +20,35 @@ - true bin\Release - prompt - 4 false - - ..\FirstMachineAge_Common\vs_libs\VintagestoryAPI.dll + $(VINTAGE_STORY)\VintagestoryAPI.dll False - ..\FirstMachineAge_Common\vs_libs\VSEssentials.dll + $(VINTAGE_STORY)\mods\VSEssentials.dll False - ..\FirstMachineAge_Common\vs_libs\VSCreativeMod.dll + $(VINTAGE_STORY)\mods\VSCreativeMod.dll False - ..\FirstMachineAge_Common\vs_libs\VSSurvivalMod.dll + $(VINTAGE_STORY)\mods\VSSurvivalMod.dll False - ..\FirstMachineAge_Common\vs_libs\protobuf-net.dll + $(VINTAGE_STORY)\lib\protobuf-net.dll False - ..\FirstMachineAge_Common\vs_libs\VintagestoryLib.dll + $(VINTAGE_STORY)\VintagestoryLib.dll False - - - - - - - - - - - - - - - - - - - @@ -92,37 +63,32 @@ - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - - - {DE0A4E7D-E5FA-441D-A11A-8279E6AC5BBC} - Common - + - \ No newline at end of file diff --git a/AccessControls/Properties/AssemblyInfo.cs b/AccessControls/Properties/AssemblyInfo.cs index a674124..35cd384 100644 --- a/AccessControls/Properties/AssemblyInfo.cs +++ b/AccessControls/Properties/AssemblyInfo.cs @@ -1,27 +1,11 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("AccessControls")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("Melchior")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +using System.Reflection; +using System.Runtime.CompilerServices; +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/AnvilMetalRecovery/AnvilMetalRecovery.csproj b/AnvilMetalRecovery/AnvilMetalRecovery.csproj index f3e5e38..6923db6 100644 --- a/AnvilMetalRecovery/AnvilMetalRecovery.csproj +++ b/AnvilMetalRecovery/AnvilMetalRecovery.csproj @@ -1,22 +1,18 @@ - - + - Debug - AnyCPU - {3EC9A581-655C-4F68-898C-4E773C292082} + net7.0 Library - AnvilMetalRecovery - AnvilMetalRecovery - v4.6.1 + false + AnvilMetalRecovery + Mod plugin for V.S. + DEBUG + First_Machine_Age_component + Melchior + 0.1.9 - true - full - false bin\Debug DEBUG; - prompt - 4 false @@ -26,10 +22,7 @@ - true bin\Release - prompt - 4 false @@ -39,100 +32,72 @@ - - vs_libs\VintagestoryAPI.dll + $(VINTAGE_STORY)\VintagestoryAPI.dll False - vs_libs\VintagestoryLib.dll + $(VINTAGE_STORY)\VintagestoryLib.dll False - vs_libs\VSCreativeMod.dll + $(VINTAGE_STORY)\mods\VSCreativeMod.dll False - vs_libs\VSEssentials.dll + $(VINTAGE_STORY)\mods\VSEssentials.dll False - vs_libs\VSSurvivalMod.dll - False - - - vs_libs\Newtonsoft.Json.dll + $(VINTAGE_STORY)\mods\VSSurvivalMod.dll False - vs_libs\0Harmony.dll + $(VINTAGE_STORY)\lib\0Harmony.dll False - vs_libs\protobuf-net.dll + $(VINTAGE_STORY)\lib\protobuf-net.dll False - - - - - - - - - - - - - - - - - - + Always - + Always - + Always - + Always - + Always - - - + Always - + Always - + Always - + Always - + Always - + Always - - - - @@ -160,5 +125,13 @@ - + + + + + + + + + \ No newline at end of file diff --git a/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs b/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs index 1835de2..4fc17c9 100644 --- a/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs +++ b/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs @@ -1,97 +1,97 @@ -using System; - -using Vintagestory.API.Client; -using Vintagestory.API.Common; -using Vintagestory.API.Common.Entities; -using Vintagestory.API.Config; -using Vintagestory.API.Datastructures; -using Vintagestory.API.MathTools; -using Vintagestory.API.Server; -using Vintagestory.GameContent; - -namespace AnvilMetalRecovery -{ - public class MoldDestructionRecovererBehavior : BlockBehavior - { - public static readonly string BehaviorClassName = @"MoldDestructionRecoverer"; - private readonly AssetLocation MetalBits_partial = new AssetLocation(GlobalConstants.DefaultDomain, @"metalbit"); - private const int shavingValue = 5; - - - - public MoldDestructionRecovererBehavior(Block block) : base(block) - { - - } - - public override void OnBlockBroken(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, ref EnumHandling handling) - { - if (world.Api.Side.IsClient( )) return; - ICoreAPI CoreAPI = world.Api; - ICoreServerAPI ServerAPI = world.Api as ICoreServerAPI; - - - #if DEBUG - world.Api.Logger.VerboseDebug("MoldDestructionRecovererBehavior::OnBlockBroken"); - #endif - - - var someBlock = ServerAPI.World.BlockAccessor.GetBlock(pos); - var someBlockEntity = ServerAPI.World.BlockAccessor.GetBlockEntity(pos); - - - if (someBlockEntity is BlockEntityIngotMold) { - var ingotMold = someBlockEntity as BlockEntityIngotMold; - #if DEBUG - world.Api.Logger.VerboseDebug("{0} Ingot Mold(s) with L {1} Units, R {2} Units", ingotMold.quantityMolds, ingotMold.fillLevelLeft, ingotMold.fillLevelRight); - #endif - - if ( ingotMold.fillLevelLeft >= shavingValue && ingotMold.contentsLeft != null) - { - var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"]; - SpawnMetalBits(world, pos, ingotMold.fillLevelLeft, ingotMetal); - } - - if ( ingotMold.fillLevelRight >= shavingValue && ingotMold.contentsRight != null) - { - var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"]; - SpawnMetalBits(world, pos, ingotMold.fillLevelRight, ingotMetal); - } - - return; - } - - if (someBlockEntity is BlockEntityToolMold) { - var toolMold = someBlockEntity as BlockEntityToolMold; - #if DEBUG - world.Api.Logger.VerboseDebug("Tool Mold with {0} Units", toolMold.fillLevel); - #endif - if ( toolMold.fillLevel >= shavingValue && toolMold.metalContent != null) - { - var metalCode = toolMold.metalContent.Collectible.Variant.AnyKeys(@"metal", @"material"); - SpawnMetalBits(world, pos, toolMold.fillLevel, metalCode); - } - } - - } - - internal void SpawnMetalBits(IWorldAccessor world, BlockPos pos, int unitQuantity, string baseMetalCode) - { - if (unitQuantity > 0 && pos != null && !string.IsNullOrEmpty(baseMetalCode)) - { - int shavingQty = unitQuantity / shavingValue; - Item metalShavingsItem = world.Api.World.GetItem(MetalBits_partial.AppendPathVariant(baseMetalCode)); - - if (shavingQty >= 1 && metalShavingsItem != null) - { - var metalShavingsStack = new ItemStack(metalShavingsItem, shavingQty); - #if DEBUG - world.Api.Logger.VerboseDebug("Creating '{0}' @{1} *{2} Units",metalShavingsItem, pos, shavingQty); - #endif - world.Api.World.SpawnItemEntity(metalShavingsStack, pos.ToVec3d( ).Add(0.1d, 0, 0)); - } - } - } - } -} - +using System; + +using Vintagestory.API.Client; +using Vintagestory.API.Common; +using Vintagestory.API.Common.Entities; +using Vintagestory.API.Config; +using Vintagestory.API.Datastructures; +using Vintagestory.API.MathTools; +using Vintagestory.API.Server; +using Vintagestory.GameContent; + +namespace AnvilMetalRecovery +{ + public class MoldDestructionRecovererBehavior : BlockBehavior + { + public static readonly string BehaviorClassName = @"MoldDestructionRecoverer"; + private readonly AssetLocation MetalBits_partial = new AssetLocation(GlobalConstants.DefaultDomain, @"metalbit"); + private const int shavingValue = 5; + + + + public MoldDestructionRecovererBehavior(Block block) : base(block) + { + + } + + public override void OnBlockBroken(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, ref EnumHandling handling) + { + if (world.Api.Side.IsClient( )) return; + ICoreAPI CoreAPI = world.Api; + ICoreServerAPI ServerAPI = world.Api as ICoreServerAPI; + + + #if DEBUG + world.Api.Logger.VerboseDebug("MoldDestructionRecovererBehavior::OnBlockBroken"); + #endif + + + var someBlock = ServerAPI.World.BlockAccessor.GetBlock(pos); + var someBlockEntity = ServerAPI.World.BlockAccessor.GetBlockEntity(pos); + + + if (someBlockEntity is BlockEntityIngotMold) { + var ingotMold = someBlockEntity as BlockEntityIngotMold; + #if DEBUG + //world.Api.Logger.VerboseDebug("{0} Ingot Mold(s) with L {1} Units, R {2} Units", ingotMold.quantityMolds, ingotMold.fillLevelLeft, ingotMold.fillLevelRight); + #endif + + if ( ingotMold.fillLevelLeft >= shavingValue && ingotMold.contentsLeft != null) + { + var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"]; + SpawnMetalBits(world, pos, ingotMold.fillLevelLeft, ingotMetal); + } + + if ( ingotMold.fillLevelRight >= shavingValue && ingotMold.contentsRight != null) + { + var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"]; + SpawnMetalBits(world, pos, ingotMold.fillLevelRight, ingotMetal); + } + + return; + } + + if (someBlockEntity is BlockEntityToolMold) { + var toolMold = someBlockEntity as BlockEntityToolMold; + #if DEBUG + world.Api.Logger.VerboseDebug("Tool Mold with {0} Units", toolMold.fillLevel); + #endif + if ( toolMold.fillLevel >= shavingValue && toolMold.metalContent != null) + { + var metalCode = toolMold.metalContent.Collectible.Variant.AnyKeys(@"metal", @"material"); + SpawnMetalBits(world, pos, toolMold.fillLevel, metalCode); + } + } + + } + + internal void SpawnMetalBits(IWorldAccessor world, BlockPos pos, int unitQuantity, string baseMetalCode) + { + if (unitQuantity > 0 && pos != null && !string.IsNullOrEmpty(baseMetalCode)) + { + int shavingQty = unitQuantity / shavingValue; + Item metalShavingsItem = world.Api.World.GetItem(MetalBits_partial.AppendPathVariant(baseMetalCode)); + + if (shavingQty >= 1 && metalShavingsItem != null) + { + var metalShavingsStack = new ItemStack(metalShavingsItem, shavingQty); + #if DEBUG + world.Api.Logger.VerboseDebug("Creating '{0}' @{1} *{2} Units",metalShavingsItem, pos, shavingQty); + #endif + world.Api.World.SpawnItemEntity(metalShavingsStack, pos.ToVec3d( ).Add(0.1d, 0, 0)); + } + } + } + } +} + diff --git a/AnvilMetalRecovery/MetalRecoverySystem.cs b/AnvilMetalRecovery/MetalRecoverySystem.cs index 760e8b3..4f521d5 100644 --- a/AnvilMetalRecovery/MetalRecoverySystem.cs +++ b/AnvilMetalRecovery/MetalRecoverySystem.cs @@ -1,319 +1,319 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; - -using HarmonyLib; - -using Vintagestory.API.Client; -using Vintagestory.API.Common; -using Vintagestory.API.Server; -using Vintagestory.API.Util; -using Vintagestory.Client.NoObf; -using Vintagestory.GameContent; -using Vintagestory.Server; - -/* IDEAS / ISSUES - * # DONE: Watering Can (molten-metal state) Ingot Cooling *Tssss* - * # WIP : Mold breaks -> Metal fragments : bits... - * # DONE: Tool-break configurable ratio - * # IDEA: Recycling Bench block/tool -*/ -namespace AnvilMetalRecovery -{ - public partial class MetalRecoverySystem : ModSystem - { - internal const string _configFilename = @"amr_config.json"; - internal const string anvilKey = @"Anvil"; - internal const string metalFragmentsCode = @"fma:metal_fragments"; - internal const string metalShavingsCode = @"metal_shaving"; - internal const string itemFilterListCacheKey = @"AMR_ItemFilters"; - - public const float IngotVoxelDefault = 2.38f; - public const string ItemDamageChannelName = @"ItemDamageEvents"; - - internal IServerNetworkChannel _ConfigDownlink; - internal IClientNetworkChannel _ConfigUplink; - - public event Action AMR_DataReady; - - protected RecoveryEntryTable itemToVoxelLookup = new RecoveryEntryTable();//Item Asset Code to: Ammount & Material - public static Dictionary MetalProperties;//for easy lookup - - private ICoreAPI CoreAPI; - - private ServerCoreAPI ServerCore { get; set; } - private ClientCoreAPI ClientCore { get; set; } - - public AMRConfig CachedConfiguration { - get - { - return ( AMRConfig )CoreAPI.ObjectCache[_configFilename]; - } - set - { - CoreAPI.ObjectCache.Add(_configFilename, value); - } - } - - internal List SmithingRecipies - { - get { return CoreAPI.ModLoader.GetModSystem( ).SmithingRecipes; } - } - - public static RecoveryEntryTable GetCachedLookupTable(IWorldAccessor world ) - { - return ( RecoveryEntryTable )world.Api.ObjectCache[MetalRecoverySystem.itemFilterListCacheKey]; - } - - /// - /// Valid Items that are 'recoverable' (Asset Codes) only - /// - /// The item filter list. - public List ItemFilterList { - get - { - return itemToVoxelLookup.Keys.ToList( ); - } - } - - /// - /// ALL Items that have were derivable from smithing recipies (and are 'tool' / have durability property) - /// / - /// The item filter list. - public RecoveryEntryTable ItemRecoveryTable { - get - { - return itemToVoxelLookup; - } - set - { - itemToVoxelLookup = value; - } - } - - public override bool AllowRuntimeReload { - get { return false; } - } - - public override bool ShouldLoad(EnumAppSide forSide) - { - return true; - } - - public override double ExecuteOrder( ) - { - return 0.11d; - } - - public override void Start(ICoreAPI api) - { - this.CoreAPI = api; - - RegisterItemClassMappings( ); - //RegisterBlockClassMappings( ); - RegisterBlockBehaviors( ); - - if (api.Side.IsServer()) - { - if (api is ServerCoreAPI) { - ServerCore = api as ServerCoreAPI; - } - } - else - { - ClientCore = api as ClientCoreAPI; - } - - #if DEBUG - //Harmony.DEBUG = true; - #endif - var harmony = new Harmony(this.Mod.Info.ModID); - harmony.PatchAll( ); - - base.Start(api); - } - - public override void StartServerSide(ICoreServerAPI api) - { - PrepareServersideConfig( ); - PrepareDownlinkChannel( ); - ServerCore.Event.PlayerJoin += SendClientConfigMessage; - ServerCore.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, PersistServersideConfig); - ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, UnravelMetalProperties); - ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering); - ServerCore.Event.ServerRunPhase(EnumServerRunPhase.RunGame, CacheRecoveryDataTable); - - SetupGeneralObservers( ); - - Mod.Logger.VerboseDebug("Anvil Metal Recovery - should be running..."); - - #if DEBUG - ServerCore.RegisterCommand("durability", "edit durability of item", " (Held tool) and #", EditDurability, Privilege.give); - #endif - - } - - public override void StartClientSide(ICoreClientAPI api) - { - base.StartClientSide(api); - - ListenForServerConfigMessage( ); - - Mod.Logger.VerboseDebug("Anvil Metal Recovery - should be running..."); - #if DEBUG - //ClientCore.Event.LevelFinalize += DebugStuffs; - #endif - } - - public override void AssetsLoaded(ICoreAPI api) - { - Mod.Logger.VerboseDebug("AssetsLoaded"); - } - - - public override void AssetsFinalize(ICoreAPI api) - { - Mod.Logger.VerboseDebug("AssetsFinalize"); - - if (api.Side.IsServer()) - { - AttachExtraBlockBehaviors( ); - } - } - - private void RegisterItemClassMappings( ) - { - this.CoreAPI.RegisterItemClass(@"VariableMetalItem", typeof(VariableMetalItem)); - this.CoreAPI.RegisterItemClass(@"SmartSmeltableItem", typeof(SmartSmeltableItem)); - } - - private void RegisterBlockBehaviors() - { - #if DEBUG - Mod.Logger.Debug("RegisterBlockBehaviors"); - #endif - this.CoreAPI.RegisterBlockBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName, typeof(MoldDestructionRecovererBehavior)); - this.CoreAPI.RegisterCollectibleBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName, typeof(MoldDestructionRecovererBehavior)); - } - - - - private void AttachExtraBlockBehaviors() - { - Collection mold_behaviorsAppendList = new Collection( ) { - new AssetLocation(@"game",@"ingotmold-burned"), - new AssetLocation(@"game",@"toolmold-burned-*"), - }; - - var moldRecoverBehaviorType = ServerCore.ClassRegistry.GetBlockBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName); - foreach (var assetName in mold_behaviorsAppendList) { - if (!assetName.IsWildCard) - { - this.CoreAPI.AddBlockBehavior(assetName, MoldDestructionRecovererBehavior.BehaviorClassName, moldRecoverBehaviorType); - #if DEBUG - Mod.Logger.VerboseDebug("Attached Block-Behavior {0} to '{1}' ", MoldDestructionRecovererBehavior.BehaviorClassName, assetName); - #endif - } - else { - var searchResults = ServerCore.World.SearchBlocks(assetName); - if (searchResults != null && searchResults.Length > 0) { - #if DEBUG - Mod.Logger.VerboseDebug("Attaching Block-Behaviors, wildcard matches from '{0}'", assetName); - #endif - for (int index = 0; index < searchResults.Length; index++) - { - var matchBlock = searchResults[index]; - this.CoreAPI.AddBlockBehavior(matchBlock.Code, MoldDestructionRecovererBehavior.BehaviorClassName, moldRecoverBehaviorType); - #if DEBUG - Mod.Logger.VerboseDebug("Attached Block-Behavior {0} to '{1}' ", MoldDestructionRecovererBehavior.BehaviorClassName, matchBlock.Code); - #endif - } - } - } - } - - } - - private void SetupGeneralObservers( ){ - ServerCore.Event.RegisterEventBusListener(Item_DamageEventReciever, 1.0f, ItemDamageChannelName); - } - - private void PrepareServersideConfig( ) - { - AMRConfig config = ServerCore.LoadModConfig(_configFilename); - - if (config == null) - { - //Regen default - Mod.Logger.Warning("Regenerating default config as it was missing / unparsable..."); - ServerCore.StoreModConfig(new AMRConfig(true), _configFilename); - config = ServerCore.LoadModConfig(_configFilename); - } - else if( config.BlackList == null || config.BlackList.Count == 0) - { - AMRConfig defaults = new AMRConfig(true); - config.BlackList = defaults.BlackList; - } - - this.CachedConfiguration = config; - } - - private void PersistServersideConfig( ) - { - if (this.CachedConfiguration != null) { - Mod.Logger.Notification("Persisting configuration."); - ServerCore.StoreModConfig(this.CachedConfiguration, _configFilename); - } - } - - private void PrepareDownlinkChannel( ) - { - _ConfigDownlink = ServerCore.Network.RegisterChannel(_configFilename); - _ConfigDownlink.RegisterMessageType( ); - } - - private void SendClientConfigMessage(IServerPlayer byPlayer) - { - #if DEBUG - Mod.Logger.VerboseDebug("Sending joiner: {0} a copy of config data.", byPlayer.PlayerName); - #endif - - _ConfigDownlink.SendPacket(this.CachedConfiguration, byPlayer); - } - - private void ListenForServerConfigMessage( ) - { - _ConfigUplink = ClientCore.Network.RegisterChannel(_configFilename); - _ConfigUplink = _ConfigUplink.RegisterMessageType( ); - - #if DEBUG - Mod.Logger.VerboseDebug("Registered RX channel: '{0}'", _ConfigUplink.ChannelName); - #endif - - _ConfigUplink.SetMessageHandler(RecievedConfigMessage); - } - - private void RecievedConfigMessage(AMRConfig networkMessage) - { - #if DEBUG - Mod.Logger.Debug("Got Config message!"); - #endif - - if (networkMessage != null) { - Mod.Logger.Debug("Message value; Recover Broken Tools:{0}, VoxelEquiv:{1:F2}, Tool Recovery {3:P0}, Blacklisted:{2}", networkMessage.ToolFragmentRecovery, networkMessage.VoxelEquivalentValue, networkMessage.BlackList.Count, networkMessage.ToolRecoveryRate); - this.CachedConfiguration = networkMessage; - } - } - - private void CacheRecoveryDataTable( ) - { - this.AMR_DataReady?.Invoke(); - // Cache list too - #if DEBUG - Mod.Logger.VerboseDebug("Adding Recovery entries table to Cache..."); - #endif - ServerCore.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup); - } - } +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; + +using HarmonyLib; + +using Vintagestory.API.Client; +using Vintagestory.API.Common; +using Vintagestory.API.Server; +using Vintagestory.API.Util; +using Vintagestory.Client.NoObf; +using Vintagestory.GameContent; +using Vintagestory.Server; + +/* IDEAS / ISSUES + * # DONE: Watering Can (molten-metal state) Ingot Cooling *Tssss* + * # WIP : Mold breaks -> Metal fragments : bits... + * # DONE: Tool-break configurable ratio + * # IDEA: Recycling Bench block/tool +*/ +namespace AnvilMetalRecovery +{ + public partial class MetalRecoverySystem : ModSystem + { + internal const string _configFilename = @"amr_config.json"; + internal const string anvilKey = @"Anvil"; + internal const string metalFragmentsCode = @"fma:metal_fragments"; + internal const string metalShavingsCode = @"metal_shaving"; + internal const string itemFilterListCacheKey = @"AMR_ItemFilters"; + + public const float IngotVoxelDefault = 2.38f; + public const string ItemDamageChannelName = @"ItemDamageEvents"; + + internal IServerNetworkChannel _ConfigDownlink; + internal IClientNetworkChannel _ConfigUplink; + + public event Action AMR_DataReady; + + protected RecoveryEntryTable itemToVoxelLookup = new RecoveryEntryTable();//Item Asset Code to: Ammount & Material + public static Dictionary MetalProperties;//for easy lookup + + private ICoreAPI CoreAPI; + + private ServerCoreAPI ServerCore { get; set; } + private ClientCoreAPI ClientCore { get; set; } + + public AMRConfig CachedConfiguration { + get + { + return ( AMRConfig )CoreAPI.ObjectCache[_configFilename]; + } + set + { + CoreAPI.ObjectCache.Add(_configFilename, value); + } + } + + internal List SmithingRecipies + { + get { return CoreAPI.ModLoader.GetModSystem( ).SmithingRecipes; } + } + + public static RecoveryEntryTable GetCachedLookupTable(IWorldAccessor world ) + { + return ( RecoveryEntryTable )world.Api.ObjectCache[MetalRecoverySystem.itemFilterListCacheKey]; + } + + /// + /// Valid Items that are 'recoverable' (Asset Codes) only + /// + /// The item filter list. + public List ItemFilterList { + get + { + return itemToVoxelLookup.Keys.ToList( ); + } + } + + /// + /// ALL Items that have were derivable from smithing recipies (and are 'tool' / have durability property) + /// / + /// The item filter list. + public RecoveryEntryTable ItemRecoveryTable { + get + { + return itemToVoxelLookup; + } + set + { + itemToVoxelLookup = value; + } + } + + public override bool AllowRuntimeReload { + get { return false; } + } + + public override bool ShouldLoad(EnumAppSide forSide) + { + return true; + } + + public override double ExecuteOrder( ) + { + return 0.11d; + } + + public override void Start(ICoreAPI api) + { + this.CoreAPI = api; + + RegisterItemClassMappings( ); + //RegisterBlockClassMappings( ); + RegisterBlockBehaviors( ); + + if (api.Side.IsServer()) + { + if (api is ServerCoreAPI) { + ServerCore = api as ServerCoreAPI; + } + } + else + { + ClientCore = api as ClientCoreAPI; + } + + #if DEBUG + //Harmony.DEBUG = true; + #endif + var harmony = new Harmony(this.Mod.Info.ModID); + harmony.PatchAll( ); + + base.Start(api); + } + + public override void StartServerSide(ICoreServerAPI api) + { + PrepareServersideConfig( ); + PrepareDownlinkChannel( ); + ServerCore.Event.PlayerJoin += SendClientConfigMessage; + ServerCore.Event.ServerRunPhase(EnumServerRunPhase.Shutdown, PersistServersideConfig); + ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, UnravelMetalProperties); + ServerCore.Event.ServerRunPhase(EnumServerRunPhase.GameReady, MaterialDataGathering); + ServerCore.Event.ServerRunPhase(EnumServerRunPhase.RunGame, CacheRecoveryDataTable); + + SetupGeneralObservers( ); + + Mod.Logger.VerboseDebug("Anvil Metal Recovery - should be running..."); + + #if DEBUG + ServerCore.RegisterCommand("durability", "edit durability of item", " (Held tool) and #", EditDurability, Privilege.give); + #endif + + } + + public override void StartClientSide(ICoreClientAPI api) + { + base.StartClientSide(api); + + ListenForServerConfigMessage( ); + + Mod.Logger.VerboseDebug("Anvil Metal Recovery - should be running..."); + #if DEBUG + //ClientCore.Event.LevelFinalize += DebugStuffs; + #endif + } + + public override void AssetsLoaded(ICoreAPI api) + { + Mod.Logger.VerboseDebug("AssetsLoaded"); + } + + + public override void AssetsFinalize(ICoreAPI api) + { + Mod.Logger.VerboseDebug("AssetsFinalize"); + + if (api.Side.IsServer()) + { + AttachExtraBlockBehaviors( ); + } + } + + private void RegisterItemClassMappings( ) + { + this.CoreAPI.RegisterItemClass(@"VariableMetalItem", typeof(VariableMetalItem)); + this.CoreAPI.RegisterItemClass(@"SmartSmeltableItem", typeof(SmartSmeltableItem)); + } + + private void RegisterBlockBehaviors() + { + #if DEBUG + Mod.Logger.Debug("RegisterBlockBehaviors"); + #endif + this.CoreAPI.RegisterBlockBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName, typeof(MoldDestructionRecovererBehavior)); + this.CoreAPI.RegisterCollectibleBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName, typeof(MoldDestructionRecovererBehavior)); + } + + + + private void AttachExtraBlockBehaviors() + { + Collection mold_behaviorsAppendList = new Collection( ) { + new AssetLocation(@"game",@"ingotmold-burned"), + new AssetLocation(@"game",@"toolmold-burned-*"), + }; + + var moldRecoverBehaviorType = ServerCore.ClassRegistry.GetBlockBehaviorClass(MoldDestructionRecovererBehavior.BehaviorClassName); + foreach (var assetName in mold_behaviorsAppendList) { + if (!assetName.IsWildCard) + { + this.CoreAPI.AddBlockBehavior(assetName, MoldDestructionRecovererBehavior.BehaviorClassName, moldRecoverBehaviorType); + #if DEBUG + Mod.Logger.VerboseDebug("Attached Block-Behavior {0} to '{1}' ", MoldDestructionRecovererBehavior.BehaviorClassName, assetName); + #endif + } + else { + var searchResults = ServerCore.World.SearchBlocks(assetName); + if (searchResults != null && searchResults.Length > 0) { + #if DEBUG + Mod.Logger.VerboseDebug("Attaching Block-Behaviors, wildcard matches from '{0}'", assetName); + #endif + for (int index = 0; index < searchResults.Length; index++) + { + var matchBlock = searchResults[index]; + this.CoreAPI.AddBlockBehavior(matchBlock.Code, MoldDestructionRecovererBehavior.BehaviorClassName, moldRecoverBehaviorType); + #if DEBUG + Mod.Logger.VerboseDebug("Attached Block-Behavior {0} to '{1}' ", MoldDestructionRecovererBehavior.BehaviorClassName, matchBlock.Code); + #endif + } + } + } + } + + } + + private void SetupGeneralObservers( ){ + ServerCore.Event.RegisterEventBusListener(Item_DamageEventReciever, 1.0f, ItemDamageChannelName); + } + + private void PrepareServersideConfig( ) + { + AMRConfig config = ServerCore.LoadModConfig(_configFilename); + + if (config == null) + { + //Regen default + Mod.Logger.Warning("Regenerating default config as it was missing / unparsable..."); + ServerCore.StoreModConfig(new AMRConfig(true), _configFilename); + config = ServerCore.LoadModConfig(_configFilename); + } + else if( config.BlackList == null || config.BlackList.Count == 0) + { + AMRConfig defaults = new AMRConfig(true); + config.BlackList = defaults.BlackList; + } + + this.CachedConfiguration = config; + } + + private void PersistServersideConfig( ) + { + if (this.CachedConfiguration != null) { + Mod.Logger.Notification("Persisting configuration."); + ServerCore.StoreModConfig(this.CachedConfiguration, _configFilename); + } + } + + private void PrepareDownlinkChannel( ) + { + _ConfigDownlink = ServerCore.Network.RegisterChannel(_configFilename); + _ConfigDownlink.RegisterMessageType( ); + } + + private void SendClientConfigMessage(IServerPlayer byPlayer) + { + #if DEBUG + Mod.Logger.VerboseDebug("Sending joiner: {0} a copy of config data.", byPlayer.PlayerName); + #endif + + _ConfigDownlink.SendPacket(this.CachedConfiguration, byPlayer); + } + + private void ListenForServerConfigMessage( ) + { + _ConfigUplink = ClientCore.Network.RegisterChannel(_configFilename); + _ConfigUplink = _ConfigUplink.RegisterMessageType( ); + + #if DEBUG + Mod.Logger.VerboseDebug("Registered RX channel: '{0}'", _ConfigUplink.ChannelName); + #endif + + _ConfigUplink.SetMessageHandler(RecievedConfigMessage); + } + + private void RecievedConfigMessage(AMRConfig networkMessage) + { + #if DEBUG + Mod.Logger.Debug("Got Config message!"); + #endif + + if (networkMessage != null) { + Mod.Logger.Debug("Message value; Recover Broken Tools:{0}, VoxelEquiv:{1:F2}, Tool Recovery {3:P0}, Blacklisted:{2}", networkMessage.ToolFragmentRecovery, networkMessage.VoxelEquivalentValue, networkMessage.BlackList.Count, networkMessage.ToolRecoveryRate); + this.CachedConfiguration = networkMessage; + } + } + + private void CacheRecoveryDataTable( ) + { + this.AMR_DataReady?.Invoke(); + // Cache list too + #if DEBUG + Mod.Logger.VerboseDebug("Adding Recovery entries table to Cache..."); + #endif + ServerCore.ObjectCache.Add(itemFilterListCacheKey, itemToVoxelLookup); + } + } } \ No newline at end of file diff --git a/AnvilMetalRecovery/Properties/AssemblyInfo.cs b/AnvilMetalRecovery/Properties/AssemblyInfo.cs index 374448e..35cd384 100644 --- a/AnvilMetalRecovery/Properties/AssemblyInfo.cs +++ b/AnvilMetalRecovery/Properties/AssemblyInfo.cs @@ -1,30 +1,11 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("AnvilMetalRecovery")] -[assembly: AssemblyDescription("Mod plugin for V.S.")] -#if DEBUG -[assembly: AssemblyConfiguration("DEBUG")] -#else -[assembly: AssemblyConfiguration("RELEASE")] -#endif -[assembly: AssemblyProduct("First_Machine_Age_component")] -[assembly: AssemblyCopyright("Melchior")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("0.1.9")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +using System.Reflection; +using System.Runtime.CompilerServices; +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/Assorted/Assorted.csproj b/Assorted/Assorted.csproj index 0e94492..c373d2f 100644 --- a/Assorted/Assorted.csproj +++ b/Assorted/Assorted.csproj @@ -1,22 +1,16 @@ - - + - Debug - AnyCPU - {805B37F5-F87D-4A63-BD3F-66AE59F1C998} + net7.0 Library FirstMachineAge - Assorted - v4.6.1 + false + Assorted + librarian + 1.0.* - true - full - false bin\Debug DEBUG; - prompt - 4 false @@ -26,10 +20,7 @@ - true bin\Release - prompt - 4 false @@ -39,58 +30,37 @@ - - vs_libs\cairo-sharp.dll + $(VINTAGE_STORY)\lib\cairo-sharp.dll False - vs_libs\protobuf-net.dll + $(VINTAGE_STORY)\lib\protobuf-net.dll False - vs_libs\VintagestoryAPI.dll + $(VINTAGE_STORY)\VintagestoryAPI.dll False - vs_libs\VintagestoryLib.dll + $(VINTAGE_STORY)\VintagestoryLib.dll False - vs_libs\VSCreativeMod.dll + $(VINTAGE_STORY)\mods\VSCreativeMod.dll False - vs_libs\VSEssentials.dll + $(VINTAGE_STORY)\mods\VSEssentials.dll False - vs_libs\VSSurvivalMod.dll - False - - - vs_libs\Newtonsoft.Json.dll + $(VINTAGE_STORY)\mods\VSSurvivalMod.dll False - vs_libs\Enums.NET.dll + $(VINTAGE_STORY)\lib\Enums.NET.dll - - vs_libs\System.Runtime.CompilerServices.Unsafe.dll - - - - - - - - - - - - - - @@ -106,182 +76,180 @@ - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - - - + Always - + Always - + Always - - - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + + + + \ No newline at end of file diff --git a/Assorted/Properties/AssemblyInfo.cs b/Assorted/Properties/AssemblyInfo.cs index faa28aa..35cd384 100644 --- a/Assorted/Properties/AssemblyInfo.cs +++ b/Assorted/Properties/AssemblyInfo.cs @@ -1,27 +1,11 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Assorted")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("librarian")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +using System.Reflection; +using System.Runtime.CompilerServices; +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/ElementalTools/ElementalTools.csproj b/ElementalTools/ElementalTools.csproj index 013af90..fd40691 100644 --- a/ElementalTools/ElementalTools.csproj +++ b/ElementalTools/ElementalTools.csproj @@ -1,22 +1,18 @@ - - + - Debug - AnyCPU - {EA9BA3EC-EF08-4192-A844-4D3F398B1FFF} + net7.0 Library - ElementalTools - ElementalTools - v4.6.1 + false + Era_Of_Steel + Mod plugin for V.S. + DEBUG + First_Machine_Age_component + Melchior + 1.0.* - true - full - false bin\Debug DEBUG; - prompt - 4 false @@ -26,70 +22,43 @@ - true bin\Release - prompt - 4 false - - - vs_libs\Newtonsoft.Json.dll - False - - vs_libs\protobuf-net.dll + $(VINTAGE_STORY)\lib\protobuf-net.dll False - vs_libs\VintagestoryAPI.dll + $(VINTAGE_STORY)\VintagestoryAPI.dll False - vs_libs\VintagestoryLib.dll + $(VINTAGE_STORY)\VintagestoryLib.dll False - vs_libs\VSCreativeMod.dll + $(VINTAGE_STORY)\mods\VSCreativeMod.dll False - vs_libs\VSEssentials.dll + $(VINTAGE_STORY)\mods\VSEssentials.dll False - vs_libs\VSSurvivalMod.dll + $(VINTAGE_STORY)\mods\VSSurvivalMod.dll False - vs_libs\0Harmony.dll + $(VINTAGE_STORY)\lib\0Harmony.dll False - - - - + Always - - - - - - - - - - - - - - - - @@ -124,214 +93,203 @@ - + Always - + Always - + Always - + Always - + Always - - - + Always - + Always - + Always - + Always - + Always - + Always - + Always - - - - - + Always - + Always - + Always - + Always - + Always - + Always - - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - - + Always - - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - + Always - - - - + Always - - + Always - + Always - + + + \ No newline at end of file diff --git a/ElementalTools/Properties/AssemblyInfo.cs b/ElementalTools/Properties/AssemblyInfo.cs index a245d8d..35cd384 100644 --- a/ElementalTools/Properties/AssemblyInfo.cs +++ b/ElementalTools/Properties/AssemblyInfo.cs @@ -1,31 +1,11 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("Era_Of_Steel")] -[assembly: AssemblyDescription("Mod plugin for V.S.")] -#if DEBUG -[assembly: AssemblyConfiguration("DEBUG")] -#else -[assembly: AssemblyConfiguration("RELEASE")] -#endif -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("First_Machine_Age_component")] -[assembly: AssemblyCopyright("Melchior")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +using System.Reflection; +using System.Runtime.CompilerServices; +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/FirstMachineAge_Common/Common.csproj b/FirstMachineAge_Common/Common.csproj index b9251f0..02a8319 100644 --- a/FirstMachineAge_Common/Common.csproj +++ b/FirstMachineAge_Common/Common.csproj @@ -1,54 +1,38 @@ - - + - Debug - AnyCPU - {DE0A4E7D-E5FA-441D-A11A-8279E6AC5BBC} + net7.0 Library FirstMachineAge FirstMachineAge_Common - v4.5 + false + FirstMachineAge_Common + Melchior + 1.0.* - true - full - false bin\Debug DEBUG; - prompt - 4 false - true bin\Release - prompt - 4 false - - vs_libs\VintagestoryAPI.dll + $(VINTAGE_STORY)\VintagestoryAPI.dll - vs_libs\VSCreativeMod.dll + $(VINTAGE_STORY)\Mods\VSCreativeMod.dll - vs_libs\VSEssentials.dll + $(VINTAGE_STORY)\Mods\VSEssentials.dll - vs_libs\VSSurvivalMod.dll + $(VINTAGE_STORY)\Mods\VSSurvivalMod.dll - - - - - - - \ No newline at end of file diff --git a/FirstMachineAge_Common/Properties/AssemblyInfo.cs b/FirstMachineAge_Common/Properties/AssemblyInfo.cs index c66ed33..35cd384 100644 --- a/FirstMachineAge_Common/Properties/AssemblyInfo.cs +++ b/FirstMachineAge_Common/Properties/AssemblyInfo.cs @@ -1,27 +1,11 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("FirstMachineAge_Common")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("Melchior")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +using System.Reflection; +using System.Runtime.CompilerServices; +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/First_Machine_Age.sln b/First_Machine_Age.sln index 4b31299..a98a715 100644 --- a/First_Machine_Age.sln +++ b/First_Machine_Age.sln @@ -1,17 +1,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "FirstMachineAge_Common\Common.csproj", "{DE0A4E7D-E5FA-441D-A11A-8279E6AC5BBC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Common", "FirstMachineAge_Common\Common.csproj", "{DE0A4E7D-E5FA-441D-A11A-8279E6AC5BBC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccessControls", "AccessControls\AccessControls.csproj", "{180853A2-7E1D-4876-9D1E-AA8608D701C3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccessControls", "AccessControls\AccessControls.csproj", "{180853A2-7E1D-4876-9D1E-AA8608D701C3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnvilMetalRecovery", "AnvilMetalRecovery\AnvilMetalRecovery.csproj", "{3EC9A581-655C-4F68-898C-4E773C292082}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnvilMetalRecovery", "AnvilMetalRecovery\AnvilMetalRecovery.csproj", "{3EC9A581-655C-4F68-898C-4E773C292082}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assorted", "Assorted\Assorted.csproj", "{805B37F5-F87D-4A63-BD3F-66AE59F1C998}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Assorted", "Assorted\Assorted.csproj", "{805B37F5-F87D-4A63-BD3F-66AE59F1C998}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PsudeoTarget", "PsudeoTarget\PsudeoTarget.csproj", "{DF81DB59-817A-48BA-88CC-8173E6D2919D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PsudeoTarget", "PsudeoTarget\PsudeoTarget.csproj", "{DF81DB59-817A-48BA-88CC-8173E6D2919D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ElementalTools", "ElementalTools\ElementalTools.csproj", "{EA9BA3EC-EF08-4192-A844-4D3F398B1FFF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElementalTools", "ElementalTools\ElementalTools.csproj", "{EA9BA3EC-EF08-4192-A844-4D3F398B1FFF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/PsudeoTarget/Properties/AssemblyInfo.cs b/PsudeoTarget/Properties/AssemblyInfo.cs index 62b7270..35cd384 100644 --- a/PsudeoTarget/Properties/AssemblyInfo.cs +++ b/PsudeoTarget/Properties/AssemblyInfo.cs @@ -1,27 +1,11 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// Information about this assembly is defined by the following attributes. -// Change them to the values specific to your project. - -[assembly: AssemblyTitle("PsudeoTarget")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("librarian")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". -// The form "{Major}.{Minor}.*" will automatically update the build and revision, -// and "{Major}.{Minor}.{Build}.*" will update just the revision. - -[assembly: AssemblyVersion("1.0.*")] - -// The following attributes are used to specify the signing key for the assembly, -// if desired. See the Mono documentation for more information about signing. - -//[assembly: AssemblyDelaySign(false)] -//[assembly: AssemblyKeyFile("")] - +using System.Reflection; +using System.Runtime.CompilerServices; +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/PsudeoTarget/PsudeoTarget.csproj b/PsudeoTarget/PsudeoTarget.csproj index 284f8bf..d650326 100644 --- a/PsudeoTarget/PsudeoTarget.csproj +++ b/PsudeoTarget/PsudeoTarget.csproj @@ -1,37 +1,19 @@ - - + - Debug - AnyCPU - {DF81DB59-817A-48BA-88CC-8173E6D2919D} + net7.0 Exe - PsudeoTarget - PsudeoTarget - v4.5 + false + PsudeoTarget + librarian + 1.0.* - true - full - false bin\Debug DEBUG; - prompt - 4 true - true bin\Release - prompt - 4 true - - - - - - - - \ No newline at end of file From 4af309cc98f22360cf09e5530a74fd94455852c2 Mon Sep 17 00:00:00 2001 From: Brady Stanton Date: Sun, 29 Dec 2024 17:52:34 -0800 Subject: [PATCH 2/3] Got it to compile against VS 1.20.0-rc6 --- AnvilMetalRecovery/AnvilMetalRecovery.csproj | 2 +- .../MoldDestructionRecovererBehavior.cs | 22 +- .../Harmony/WateringCanDaptor.cs | 352 +++++++++--------- AnvilMetalRecovery/MetalRecoverySystem.cs | 6 +- AnvilMetalRecovery/modinfo.json | 24 +- Assorted/AssortedModLoader.cs | 168 +++++---- 6 files changed, 284 insertions(+), 290 deletions(-) diff --git a/AnvilMetalRecovery/AnvilMetalRecovery.csproj b/AnvilMetalRecovery/AnvilMetalRecovery.csproj index 6923db6..e8b828d 100644 --- a/AnvilMetalRecovery/AnvilMetalRecovery.csproj +++ b/AnvilMetalRecovery/AnvilMetalRecovery.csproj @@ -8,7 +8,7 @@ DEBUG First_Machine_Age_component Melchior - 0.1.9 + 0.2.0 bin\Debug diff --git a/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs b/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs index 4fc17c9..b6563b8 100644 --- a/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs +++ b/AnvilMetalRecovery/BlockBehaviors/MoldDestructionRecovererBehavior.cs @@ -43,19 +43,19 @@ namespace AnvilMetalRecovery if (someBlockEntity is BlockEntityIngotMold) { var ingotMold = someBlockEntity as BlockEntityIngotMold; #if DEBUG - //world.Api.Logger.VerboseDebug("{0} Ingot Mold(s) with L {1} Units, R {2} Units", ingotMold.quantityMolds, ingotMold.fillLevelLeft, ingotMold.fillLevelRight); + world.Api.Logger.VerboseDebug("{0} Ingot Mold(s) with L {1} Units, R {2} Units", ingotMold.QuantityMolds, ingotMold.FillLevelLeft, ingotMold.FillLevelRight); #endif - if ( ingotMold.fillLevelLeft >= shavingValue && ingotMold.contentsLeft != null) + if ( ingotMold.FillLevelLeft >= shavingValue && ingotMold.ContentsLeft != null) { - var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"]; - SpawnMetalBits(world, pos, ingotMold.fillLevelLeft, ingotMetal); + var ingotMetal = ingotMold.ContentsLeft.Collectible.Variant[@"metal"]; + SpawnMetalBits(world, pos, ingotMold.FillLevelLeft, ingotMetal); } - if ( ingotMold.fillLevelRight >= shavingValue && ingotMold.contentsRight != null) + if ( ingotMold.FillLevelRight >= shavingValue && ingotMold.ContentsRight != null) { - var ingotMetal = ingotMold.contentsLeft.Collectible.Variant[@"metal"]; - SpawnMetalBits(world, pos, ingotMold.fillLevelRight, ingotMetal); + var ingotMetal = ingotMold.ContentsLeft.Collectible.Variant[@"metal"]; + SpawnMetalBits(world, pos, ingotMold.FillLevelRight, ingotMetal); } return; @@ -64,12 +64,12 @@ namespace AnvilMetalRecovery if (someBlockEntity is BlockEntityToolMold) { var toolMold = someBlockEntity as BlockEntityToolMold; #if DEBUG - world.Api.Logger.VerboseDebug("Tool Mold with {0} Units", toolMold.fillLevel); + world.Api.Logger.VerboseDebug("Tool Mold with {0} Units", toolMold.FillLevel); #endif - if ( toolMold.fillLevel >= shavingValue && toolMold.metalContent != null) + if ( toolMold.FillLevel >= shavingValue && toolMold.MetalContent != null) { - var metalCode = toolMold.metalContent.Collectible.Variant.AnyKeys(@"metal", @"material"); - SpawnMetalBits(world, pos, toolMold.fillLevel, metalCode); + var metalCode = toolMold.MetalContent.Collectible.Variant.AnyKeys(@"metal", @"material"); + SpawnMetalBits(world, pos, toolMold.FillLevel, metalCode); } } diff --git a/AnvilMetalRecovery/Harmony/WateringCanDaptor.cs b/AnvilMetalRecovery/Harmony/WateringCanDaptor.cs index 41bd400..af6d19d 100644 --- a/AnvilMetalRecovery/Harmony/WateringCanDaptor.cs +++ b/AnvilMetalRecovery/Harmony/WateringCanDaptor.cs @@ -1,177 +1,177 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; - -using HarmonyLib; - -using Vintagestory.API.Client; -using Vintagestory.API.Common; -using Vintagestory.API.Config; -using Vintagestory.API.Datastructures; -using Vintagestory.API.MathTools; -using Vintagestory.API.Server; -using Vintagestory.GameContent; - -namespace AnvilMetalRecovery.Patches -{ - /// - /// Harmony patcher class to wrap Watering-can class - /// - [HarmonyPatch(typeof(BlockWateringCan))] - public class WateringCanDaptor - { - [HarmonyPrepare] - private static bool DeduplicatePatching(MethodBase original, Harmony harmony) - { - - if (original != null) { - foreach (var patched in harmony.GetPatchedMethods( )) { - if (patched.Name == original.Name) return false; //SKIPS PATCHING, its already there - } - } - - return true;//patch all other methods - } - - [HarmonyPostfix] - [HarmonyPatch(nameof(BlockWateringCan.OnHeldInteractStep))] - public static void OnHeldInteractStep(ref bool __result, float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, BlockWateringCan __instance) - { - var coreAPI = byEntity.Api; - #if DEBUG - coreAPI.Logger.VerboseDebug("BlockWateringCanPlus::OnHeldInteractStep"); - #endif - - var wc = new WateringCanAssist(__instance, byEntity.Api); - - wc.PerformBlockCooling(secondsUsed, slot, byEntity, blockSel, entitySel); - - } - - - } - - public class WateringCanAssist - { - private ICoreAPI CoreAPI { get; set; } - private ICoreServerAPI ServerAPI { get { return CoreAPI as ICoreServerAPI; } } - private ICoreClientAPI ClientAPI { get { return CoreAPI as ICoreClientAPI; } } - private BlockWateringCan Original { get; set; } - - private const float coolRateDefault = 0.0075f; - private const float flashPointTemp = 100f; - - private SimpleParticleProperties steamParticles = new SimpleParticleProperties { - MinPos = new Vec3d( ), - AddPos = new Vec3d( ), - MinQuantity = 6, - AddQuantity = 12, - Color = ColorUtil.ToRgba(100, 225, 225, 225), - OpacityEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, 1.0f), - GravityEffect = -0.015f, - WithTerrainCollision = false, - ShouldDieInLiquid = true, - ParticleModel = EnumParticleModel.Quad, - LifeLength = 2.0f, - MinVelocity = new Vec3f(-0.25f, 0.1f, -0.25f), - AddVelocity = new Vec3f(0.25f, 0.1f, 0.25f), - MinSize = 0.075f, - MaxSize = 0.1f, - WindAffected = true, - WindAffectednes = 0.4f, - }; - - public readonly AssetLocation CoolSoundEffect = new AssetLocation(@"game", @"sounds/sizzle"); - - public WateringCanAssist(BlockWateringCan original, ICoreAPI api) - { - this.CoreAPI = api; - this.Original = original; - } - - public void PerformBlockCooling(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) - { - - if (blockSel == null) return; - if (byEntity.Controls.Sneak) return; - - if ((DateTime.Now.Millisecond / 100) % 2 == 1) return; - - BlockPos targetPos = blockSel.Position; - - if (!slot.Empty && Original.GetRemainingWateringSeconds(slot.Itemstack) >= 0.1f) { - var server = (CoreAPI.World.Side.IsServer( )); - var someBlock = CoreAPI.World.BlockAccessor.GetBlock(targetPos); - - if (someBlock != null - && someBlock.BlockMaterial == EnumBlockMaterial.Ceramic - && (someBlock.Class == @"BlockIngotMold" || someBlock.Class == @"BlockToolMold")) { - var someBlockEntity = server ? ServerAPI.World.BlockAccessor.GetBlockEntity(targetPos) : ClientAPI.World.BlockAccessor.GetBlockEntity(targetPos); - - #if DEBUG - CoreAPI.Logger.VerboseDebug("Ok, its an Tool/Ingot mold.: {0}", someBlockEntity); - #endif - - if (someBlockEntity is BlockEntityIngotMold) { - var rightSide = AimAtRight(blockSel.HitPosition); - var ingotMold = someBlockEntity as BlockEntityIngotMold; - - if (rightSide && (ingotMold.fillLevelRight > 0 && ingotMold.TemperatureRight > flashPointTemp)) { - if (server) CoolContents(ingotMold.contentsRight); else GenerateSpecialEffects(blockSel.Position, blockSel.HitPosition, byEntity as EntityPlayer); - ingotMold.MarkDirty( ); - } - else if (ingotMold.fillLevelLeft > 0 && ingotMold.TemperatureLeft > flashPointTemp) { - if (server) CoolContents(ingotMold.contentsLeft); else GenerateSpecialEffects(blockSel.Position, blockSel.HitPosition, byEntity as EntityPlayer); - ingotMold.MarkDirty( ); - } - return; - } - - if (someBlockEntity is BlockEntityToolMold) { - var toolMold = someBlockEntity as BlockEntityToolMold; - if (toolMold.fillLevel > 0 && toolMold.Temperature > flashPointTemp) { - if (server) CoolContents(toolMold.metalContent); else GenerateSpecialEffects(blockSel.Position, blockSel.HitPosition, byEntity as EntityPlayer); - toolMold.MarkDirty( ); - } - return; - } - } - } - } - - internal void GenerateSpecialEffects(BlockPos blockLoc, Vec3d aimPoint, EntityPlayer playerEntity) - { - if ((DateTime.Now.Millisecond / 333) % 2 == 1) return; - - steamParticles.MinPos = blockLoc.ToVec3d( ).AddCopy(aimPoint); - steamParticles.AddPos = new Vec3d(0.05f, 0f, 0.05f); - - #if DEBUG - CoreAPI.Logger.VerboseDebug("Generate steam particles"); - #endif - - ClientAPI.World.SpawnParticles(steamParticles, playerEntity.Player); - ClientAPI.World.PlaySoundAt(CoolSoundEffect, playerEntity, playerEntity.Player, randomizePitch: false, volume: 0.5f); - } - - internal void CoolContents(ItemStack itemStack) - { - var temperature = itemStack.Collectible.GetTemperature(CoreAPI.World, itemStack); - if (temperature > 20f)//TODO: USE local AMBIENT Temp - itemStack.Collectible.SetTemperature(CoreAPI.World, itemStack, temperature - (temperature * coolRateDefault), false); - (itemStack.Attributes["temperature"] as ITreeAttribute)?.SetFloat("cooldownSpeed", 400); - - #if DEBUG - CoreAPI.Logger.VerboseDebug("Cooled Molten metal, temp: {0:F1} ", temperature); - #endif - } - - internal bool AimAtRight(Vec3d hitPosition) - { - return hitPosition.X >= 0.5f; - } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; + +using HarmonyLib; + +using Vintagestory.API.Client; +using Vintagestory.API.Common; +using Vintagestory.API.Config; +using Vintagestory.API.Datastructures; +using Vintagestory.API.MathTools; +using Vintagestory.API.Server; +using Vintagestory.GameContent; + +namespace AnvilMetalRecovery.Patches +{ + /// + /// Harmony patcher class to wrap Watering-can class + /// + [HarmonyPatch(typeof(BlockWateringCan))] + public class WateringCanDaptor + { + [HarmonyPrepare] + private static bool DeduplicatePatching(MethodBase original, Harmony harmony) + { + + if (original != null) { + foreach (var patched in harmony.GetPatchedMethods( )) { + if (patched.Name == original.Name) return false; //SKIPS PATCHING, its already there + } + } + + return true;//patch all other methods + } + + [HarmonyPostfix] + [HarmonyPatch(nameof(BlockWateringCan.OnHeldInteractStep))] + public static void OnHeldInteractStep(ref bool __result, float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, BlockWateringCan __instance) + { + var coreAPI = byEntity.Api; + #if DEBUG + coreAPI.Logger.VerboseDebug("BlockWateringCanPlus::OnHeldInteractStep"); + #endif + + var wc = new WateringCanAssist(__instance, byEntity.Api); + + wc.PerformBlockCooling(secondsUsed, slot, byEntity, blockSel, entitySel); + + } + + + } + + public class WateringCanAssist + { + private ICoreAPI CoreAPI { get; set; } + private ICoreServerAPI ServerAPI { get { return CoreAPI as ICoreServerAPI; } } + private ICoreClientAPI ClientAPI { get { return CoreAPI as ICoreClientAPI; } } + private BlockWateringCan Original { get; set; } + + private const float coolRateDefault = 0.0075f; + private const float flashPointTemp = 100f; + + private SimpleParticleProperties steamParticles = new SimpleParticleProperties { + MinPos = new Vec3d( ), + AddPos = new Vec3d( ), + MinQuantity = 6, + AddQuantity = 12, + Color = ColorUtil.ToRgba(100, 225, 225, 225), + OpacityEvolve = new EvolvingNatFloat(EnumTransformFunction.LINEAR, 1.0f), + GravityEffect = -0.015f, + WithTerrainCollision = false, + ShouldDieInLiquid = true, + ParticleModel = EnumParticleModel.Quad, + LifeLength = 2.0f, + MinVelocity = new Vec3f(-0.25f, 0.1f, -0.25f), + AddVelocity = new Vec3f(0.25f, 0.1f, 0.25f), + MinSize = 0.075f, + MaxSize = 0.1f, + WindAffected = true, + WindAffectednes = 0.4f, + }; + + public readonly AssetLocation CoolSoundEffect = new AssetLocation(@"game", @"sounds/sizzle"); + + public WateringCanAssist(BlockWateringCan original, ICoreAPI api) + { + this.CoreAPI = api; + this.Original = original; + } + + public void PerformBlockCooling(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel) + { + + if (blockSel == null) return; + if (byEntity.Controls.Sneak) return; + + if ((DateTime.Now.Millisecond / 100) % 2 == 1) return; + + BlockPos targetPos = blockSel.Position; + + if (!slot.Empty && Original.GetRemainingWateringSeconds(slot.Itemstack) >= 0.1f) { + var server = (CoreAPI.World.Side.IsServer( )); + var someBlock = CoreAPI.World.BlockAccessor.GetBlock(targetPos); + + if (someBlock != null + && someBlock.BlockMaterial == EnumBlockMaterial.Ceramic + && (someBlock.Class == @"BlockIngotMold" || someBlock.Class == @"BlockToolMold")) { + var someBlockEntity = server ? ServerAPI.World.BlockAccessor.GetBlockEntity(targetPos) : ClientAPI.World.BlockAccessor.GetBlockEntity(targetPos); + + #if DEBUG + CoreAPI.Logger.VerboseDebug("Ok, its an Tool/Ingot mold.: {0}", someBlockEntity); + #endif + + if (someBlockEntity is BlockEntityIngotMold) { + var rightSide = AimAtRight(blockSel.HitPosition); + var ingotMold = someBlockEntity as BlockEntityIngotMold; + + if (rightSide && (ingotMold.FillLevelRight > 0 && ingotMold.TemperatureRight > flashPointTemp)) { + if (server) CoolContents(ingotMold.ContentsRight); else GenerateSpecialEffects(blockSel.Position, blockSel.HitPosition, byEntity as EntityPlayer); + ingotMold.MarkDirty( ); + } + else if (ingotMold.FillLevelLeft > 0 && ingotMold.TemperatureLeft > flashPointTemp) { + if (server) CoolContents(ingotMold.ContentsLeft); else GenerateSpecialEffects(blockSel.Position, blockSel.HitPosition, byEntity as EntityPlayer); + ingotMold.MarkDirty( ); + } + return; + } + + if (someBlockEntity is BlockEntityToolMold) { + var toolMold = someBlockEntity as BlockEntityToolMold; + if (toolMold.FillLevel > 0 && toolMold.Temperature > flashPointTemp) { + if (server) CoolContents(toolMold.MetalContent); else GenerateSpecialEffects(blockSel.Position, blockSel.HitPosition, byEntity as EntityPlayer); + toolMold.MarkDirty( ); + } + return; + } + } + } + } + + internal void GenerateSpecialEffects(BlockPos blockLoc, Vec3d aimPoint, EntityPlayer playerEntity) + { + if ((DateTime.Now.Millisecond / 333) % 2 == 1) return; + + steamParticles.MinPos = blockLoc.ToVec3d( ).AddCopy(aimPoint); + steamParticles.AddPos = new Vec3d(0.05f, 0f, 0.05f); + + #if DEBUG + CoreAPI.Logger.VerboseDebug("Generate steam particles"); + #endif + + ClientAPI.World.SpawnParticles(steamParticles, playerEntity.Player); + ClientAPI.World.PlaySoundAt(CoolSoundEffect, playerEntity, playerEntity.Player, randomizePitch: false, volume: 0.5f); + } + + internal void CoolContents(ItemStack itemStack) + { + var temperature = itemStack.Collectible.GetTemperature(CoreAPI.World, itemStack); + if (temperature > 20f)//TODO: USE local AMBIENT Temp + itemStack.Collectible.SetTemperature(CoreAPI.World, itemStack, temperature - (temperature * coolRateDefault), false); + (itemStack.Attributes["temperature"] as ITreeAttribute)?.SetFloat("cooldownSpeed", 400); + + #if DEBUG + CoreAPI.Logger.VerboseDebug("Cooled Molten metal, temp: {0:F1} ", temperature); + #endif + } + + internal bool AimAtRight(Vec3d hitPosition) + { + return hitPosition.X >= 0.5f; + } + } + } \ No newline at end of file diff --git a/AnvilMetalRecovery/MetalRecoverySystem.cs b/AnvilMetalRecovery/MetalRecoverySystem.cs index 4f521d5..28c9042 100644 --- a/AnvilMetalRecovery/MetalRecoverySystem.cs +++ b/AnvilMetalRecovery/MetalRecoverySystem.cs @@ -92,11 +92,9 @@ namespace AnvilMetalRecovery } } - public override bool AllowRuntimeReload { - get { return false; } - } + //public override bool AllowRuntimeReload => false; - public override bool ShouldLoad(EnumAppSide forSide) + public override bool ShouldLoad(EnumAppSide forSide) { return true; } diff --git a/AnvilMetalRecovery/modinfo.json b/AnvilMetalRecovery/modinfo.json index 33ae647..91cc9b2 100644 --- a/AnvilMetalRecovery/modinfo.json +++ b/AnvilMetalRecovery/modinfo.json @@ -1,13 +1,11 @@ -{ - "type": "code", - "name": "Anvil Metal Recovery+", - "description" : "Get back smithing discards, broken tool scrap, failed molds; and MORE!", - "authors": ["Melchior"], - "ModID":"metalrecovery", - "version": "0.1.19-pre.1", - "dependencies": { - "game": "1.18.0", - "survival": "" - }, - "website": "http://nowebsite.nope" -} +{ + "type": "code", + "name": "Anvil Metal Recovery Revived", + "description" : "Get back smithing discards, broken tool scrap, failed molds; and MORE!", + "authors": ["Melchior", "btach"], + "ModID":"metalrecoveryrevived", + "version": "0.1.20", + "dependencies": { + "game": "1.20.0-rc.6", + } +} diff --git a/Assorted/AssortedModLoader.cs b/Assorted/AssortedModLoader.cs index 40b1b21..6c141f9 100644 --- a/Assorted/AssortedModLoader.cs +++ b/Assorted/AssortedModLoader.cs @@ -1,85 +1,83 @@ -using System; -using System.Collections.Generic; - -using Vintagestory.API; -using Vintagestory.API.Common; -using Vintagestory.API.Server; -using Vintagestory.Common; -using Vintagestory.Server; - -namespace FirstMachineAge -{ - public class AssortedModSystems : ModSystem - { - private ICoreAPI CoreAPI; - private ICoreServerAPI ServerAPI; - private ServerCoreAPI ServerCore { get; set; } - - public const string BoltableDoorEntityNameKey = @"BoltableDoorEntity"; - public const string CollapsingBlockEntityNameKey = @"CollapsingBlockEntity"; - - - public override bool AllowRuntimeReload { - get { return false; } - } - - public override bool ShouldLoad(EnumAppSide forSide) - { - return forSide.IsClient() || forSide.IsServer(); - } - - public override double ExecuteOrder( ) - { - return 0.1d; - } - - public override void Start(ICoreAPI api) - { - base.Start(api); - this.CoreAPI = api; - - RegisterBlockClasses( ); - RegisterBehaviorClasses( ); - } - - public override void StartServerSide(ICoreServerAPI api) - { - base.StartServerSide(api); - - this.ServerAPI = api; - - - if (api is ServerCoreAPI) { - ServerCore = api as ServerCoreAPI; - } - else { - Mod.Logger.Error("Cannot access 'ServerCoreAPI' class: API (implimentation) has changed, Contact Developer!"); - return; - } - - } - - private void RegisterBlockClasses( ) - { - CoreAPI.RegisterBlockClass(@"BoltableDoor", typeof(BoltableDoor)); - CoreAPI.RegisterBlockClass(@"FalseWall", typeof(FalseWall)); - CoreAPI.RegisterBlockClass(@"CollapsingBlock", typeof(CollapsingBlock)); - CoreAPI.RegisterBlockClass(@"RectangularBrazier", typeof(RectangularBrazier)); - - - CoreAPI.RegisterBlockEntityClass(BoltableDoorEntityNameKey, typeof(BoltableDoorBlockEntity)); - } - - private void RegisterBehaviorClasses( ) - { - CoreAPI.RegisterBlockBehaviorClass(@"FreeReinforcement", typeof(BlockBehaviorFreeReinforcement)); - CoreAPI.RegisterBlockBehaviorClass(@"VerticalOrentiation",typeof(BlockBehaviorVerticalOrientation)); - CoreAPI.RegisterBlockBehaviorClass(@"NeedSides", typeof(BlockBehaviorNeedSides)); - } - } - - - - -} - +using System; +using System.Collections.Generic; + +using Vintagestory.API; +using Vintagestory.API.Common; +using Vintagestory.API.Server; +using Vintagestory.Common; +using Vintagestory.Server; + +namespace FirstMachineAge +{ + public class AssortedModSystems : ModSystem + { + private ICoreAPI CoreAPI; + private ICoreServerAPI ServerAPI; + private ServerCoreAPI ServerCore { get; set; } + + public const string BoltableDoorEntityNameKey = @"BoltableDoorEntity"; + public const string CollapsingBlockEntityNameKey = @"CollapsingBlockEntity"; + + + //public override bool AllowRuntimeReload => false; + + public override bool ShouldLoad(EnumAppSide forSide) + { + return forSide.IsClient() || forSide.IsServer(); + } + + public override double ExecuteOrder( ) + { + return 0.1d; + } + + public override void Start(ICoreAPI api) + { + base.Start(api); + this.CoreAPI = api; + + RegisterBlockClasses( ); + RegisterBehaviorClasses( ); + } + + public override void StartServerSide(ICoreServerAPI api) + { + base.StartServerSide(api); + + this.ServerAPI = api; + + + if (api is ServerCoreAPI) { + ServerCore = api as ServerCoreAPI; + } + else { + Mod.Logger.Error("Cannot access 'ServerCoreAPI' class: API (implimentation) has changed, Contact Developer!"); + return; + } + + } + + private void RegisterBlockClasses( ) + { + CoreAPI.RegisterBlockClass(@"BoltableDoor", typeof(BoltableDoor)); + CoreAPI.RegisterBlockClass(@"FalseWall", typeof(FalseWall)); + CoreAPI.RegisterBlockClass(@"CollapsingBlock", typeof(CollapsingBlock)); + CoreAPI.RegisterBlockClass(@"RectangularBrazier", typeof(RectangularBrazier)); + + + CoreAPI.RegisterBlockEntityClass(BoltableDoorEntityNameKey, typeof(BoltableDoorBlockEntity)); + } + + private void RegisterBehaviorClasses( ) + { + CoreAPI.RegisterBlockBehaviorClass(@"FreeReinforcement", typeof(BlockBehaviorFreeReinforcement)); + CoreAPI.RegisterBlockBehaviorClass(@"VerticalOrentiation",typeof(BlockBehaviorVerticalOrientation)); + CoreAPI.RegisterBlockBehaviorClass(@"NeedSides", typeof(BlockBehaviorNeedSides)); + } + } + + + + +} + From bf36f187bd931d1a2ba65b5e0dfc0d3e12f596db Mon Sep 17 00:00:00 2001 From: Brady Stanton Date: Sun, 12 Jan 2025 06:19:31 -0800 Subject: [PATCH 3/3] removed comma --- AnvilMetalRecovery/modinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AnvilMetalRecovery/modinfo.json b/AnvilMetalRecovery/modinfo.json index 91cc9b2..552d373 100644 --- a/AnvilMetalRecovery/modinfo.json +++ b/AnvilMetalRecovery/modinfo.json @@ -6,6 +6,6 @@ "ModID":"metalrecoveryrevived", "version": "0.1.20", "dependencies": { - "game": "1.20.0-rc.6", + "game": "1.20.0-rc.6" } }