diff --git a/Source/Content/BlockEntityBehaviors/BEBehaviorTransient.cs b/Source/Content/BlockEntityBehaviors/BEBehaviorTransient.cs index be297ca..a9b5d19 100644 --- a/Source/Content/BlockEntityBehaviors/BEBehaviorTransient.cs +++ b/Source/Content/BlockEntityBehaviors/BEBehaviorTransient.cs @@ -21,13 +21,13 @@ public TransitionConditions(int RequiredSunlight) public class BEBehaviorTransient : BlockEntityBehavior { - double transitionAtTotalDays = -1; + double transitionAtTotalHours = -1; + double elapsedTime = 0; BlockPos Pos { get => Blockentity.Pos; } string fromCode; string toCode; public Block OwnBlock { get => Blockentity.Block; } public TransitionConditions conditions; - long id; public BEBehaviorTransient(BlockEntity blockentity) : base(blockentity) { @@ -36,10 +36,10 @@ public BEBehaviorTransient(BlockEntity blockentity) : base(blockentity) public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); - if (transitionAtTotalDays <= 0) + if (transitionAtTotalHours <= 0) { float hours = properties["inGameHours"].AsFloat(24); - transitionAtTotalDays = api.World.Calendar.TotalDays + hours / 24; + transitionAtTotalHours = api.World.Calendar.TotalHours + hours; } fromCode = properties["convertFrom"].AsString()?.WithDomain(OwnBlock.Code.Domain); toCode = properties["convertTo"].AsString()?.WithDomain(OwnBlock.Code.Domain); @@ -49,7 +49,7 @@ public override void Initialize(ICoreAPI api, JsonObject properties) { if (api.Side.IsServer()) { - id = Blockentity.RegisterGameTickListener(CheckTransition, 2000); + Blockentity.RegisterGameTickListener(CheckTransition, 2000); } } else api.World.BlockAccessor.RemoveBlockEntity(Pos); @@ -57,9 +57,11 @@ public override void Initialize(ICoreAPI api, JsonObject properties) public void CheckTransition(float dt) { - if (transitionAtTotalDays > Api.World.Calendar.TotalDays) return; - if (Api.World.BlockAccessor.GetLightLevel(this.Blockentity.Pos, EnumLightLevelType.OnlySunLight) < (conditions?.RequiredSunlight ?? -1)) return; - + int light = Api.World.BlockAccessor.GetLightLevel(this.Blockentity.Pos, EnumLightLevelType.OnlySunLight); + if (light < (conditions?.RequiredSunlight ?? -1)) return; + elapsedTime += dt; + if (Api.World.Calendar.TotalHours + elapsedTime < transitionAtTotalHours) return; + Block block = Api.World.BlockAccessor.GetBlock(Pos); Block tblock; @@ -87,26 +89,16 @@ public override void FromTreeAtributes(ITreeAttribute tree, IWorldAccessor world { base.FromTreeAtributes(tree, worldForResolving); - transitionAtTotalDays = tree.GetDouble("transitionAtTotalDays"); + transitionAtTotalHours = tree.GetDouble("transitionAtTotalDays"); + elapsedTime = tree.GetDouble("elapsedTime"); } public override void ToTreeAttributes(ITreeAttribute tree) { base.ToTreeAttributes(tree); - tree.SetDouble("transitionAtTotalDays", transitionAtTotalDays); - } - - public override void OnBlockUnloaded() - { - Blockentity?.UnregisterGameTickListener(id); - base.OnBlockUnloaded(); - } - - public override void OnBlockRemoved() - { - Blockentity?.UnregisterGameTickListener(id); - base.OnBlockRemoved(); + tree.SetDouble("transitionAtTotalDays", transitionAtTotalHours); + tree.SetDouble("elapsedTime", elapsedTime); } } } diff --git a/Source/Systems/InWorldCraftingSystem.cs b/Source/Systems/InWorldCraftingSystem.cs index 31683de..2cc921c 100644 --- a/Source/Systems/InWorldCraftingSystem.cs +++ b/Source/Systems/InWorldCraftingSystem.cs @@ -246,7 +246,7 @@ public void OnPlayerInteractStop(InWorldCraftingRecipe recipe, IPlayer byPlayer, if (recipe.Remove) (byPlayer as IServerPlayer)?.Entity.World.BlockAccessor.SetBlock(0, Pos); Block resolvedBlock = make.ResolvedItemstack.Block; (byPlayer as IServerPlayer)?.Entity.World.BlockAccessor.SetBlock(resolvedBlock.BlockId, Pos); - resolvedBlock.OnBlockPlaced(byPlayer.Entity.World, Pos); + //resolvedBlock.OnBlockPlaced(byPlayer.Entity.World, Pos); TakeOrDamage(recipe, slot, byPlayer); } } diff --git a/bin/Immersion/Immersion.dll b/bin/Immersion/Immersion.dll index 047f176..0ce01ca 100644 Binary files a/bin/Immersion/Immersion.dll and b/bin/Immersion/Immersion.dll differ diff --git a/bin/Immersion/Immersion.pdb b/bin/Immersion/Immersion.pdb index 6226469..68f0b14 100644 Binary files a/bin/Immersion/Immersion.pdb and b/bin/Immersion/Immersion.pdb differ diff --git a/bin/Immersion/modinfo.json b/bin/Immersion/modinfo.json index aa4f73c..3159f0c 100644 --- a/bin/Immersion/modinfo.json +++ b/bin/Immersion/modinfo.json @@ -6,7 +6,7 @@ "website": "https://github.com/TonyLiberatto/The-Neolithic-Mod", "authors": [ "Tony Liberatto","Novocain","Balduranne","BunnyViking" ], "contributors": ["Tyron", "Milo", "Stroam","Elwood","copygirl", "MarcAFK", "Demmon1", "jhendrix61978", "Ereketh"], - "version": "1.1.17", + "version": "1.1.18", "dependencies": { "carrycapacity": "0.4.7-rc.1", "game": "1.12.5"