示例#1
0
        public override void Initialize(ICoreAPI api, JsonObject properties)
        {
            base.Initialize(api, properties);

            if (Api.Side == EnumAppSide.Server)
            {
                listenerId = Blockentity.RegisterGameTickListener(OnTick, callbackTimeMs + Api.World.Rand.Next(callbackTimeMs));
            }

            stemBlock   = Api.World.GetBlock(ownBe.Block.CodeWithVariant("type", "stem"));
            branchBlock = Api.World.GetBlock(ownBe.Block.CodeWithVariant("type", "branch")) as BlockFruitTreeBranch;
            leavesBlock = Api.World.GetBlock(AssetLocation.Create(ownBe.Block.Attributes["foliageBlock"].AsString(), ownBe.Block.Code.Domain)) as BlockFruitTreeFoliage;

            if (ownBe.Block == leavesBlock)
            {
                ownBe.PartType = EnumTreePartType.Leaves;
            }
            if (ownBe.Block == branchBlock)
            {
                ownBe.PartType = EnumTreePartType.Branch;
            }

            if (ownBe.lastGrowthAttemptTotalDays == 0)
            {
                ownBe.lastGrowthAttemptTotalDays = api.World.Calendar.TotalDays;
            }
        }
示例#2
0
        public override void Initialize(ICoreAPI api, JsonObject properties)
        {
            base.Initialize(api, properties);

            if (api.Side == EnumAppSide.Server)
            {
                Blockentity.RegisterGameTickListener(onRootTick, 5000, api.World.Rand.Next(5000));
            }

            roomreg = api.ModLoader.GetModSystem <RoomRegistry>();

            blockBranch = be.Block as BlockFruitTreeBranch;

            RegisterTreeType(bebr.TreeType);

            double totalDays = api.World.Calendar.TotalDays;

            if (TreePlantedTotalDays == 0)
            {
                TreePlantedTotalDays  = totalDays;
                LastRootTickTotalDays = totalDays;
            }
            else
            {
                // In case this block was imported from another older world. In that case lastCheckAtTotalDays would be a future date.
                TreePlantedTotalDays  = Math.Min(TreePlantedTotalDays, totalDays);
                LastRootTickTotalDays = Math.Min(LastRootTickTotalDays, totalDays);
            }
        }