public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); this.sound = new AssetLocation("sounds/effect/swoosh"); weatherSystem = Api.ModLoader.GetModSystem <WeatherSystemBase>(); Blockentity.RegisterGameTickListener(CheckWindSpeed, 1000); }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); //sound = new AssetLocation("game:sounds/effect/swoosh"); Blockentity.RegisterGameTickListener(CheckWaterSpeed, 1000); }
private void initSoundsAndTicking() { fuelBlock = Api.World.BlockAccessor.GetBlock(FuelPos); l1 = Blockentity.RegisterGameTickListener(OnTick, 25); if (Api.Side == EnumAppSide.Server) { l2 = Blockentity.RegisterGameTickListener(OnSlowServerTick, 1000); } wsys = Api.ModLoader.GetModSystem <WeatherSystemBase>(); if (ambientSound == null && Api.Side == EnumAppSide.Client) { ambientSound = ((IClientWorldAccessor)Api.World).LoadSound(new SoundParams() { Location = new AssetLocation("sounds/environment/fire.ogg"), ShouldLoop = true, Position = FirePos.ToVec3f().Add(0.5f, 0.25f, 0.5f), DisposeOnFinish = false, Volume = 1f }); if (ambientSound != null) { ambientSound.PlaybackPosition = ambientSound.SoundLengthSeconds * (float)Api.World.Rand.NextDouble(); ambientSound.Start(); } } particleFacing = BlockFacing.FromNormal(new Vec3i(FirePos.X - FuelPos.X, FirePos.Y - FuelPos.Y, FirePos.Z - FuelPos.Z)); }
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; } }
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); } }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); if (Blockentity.Api.Side == EnumAppSide.Client) { Blockentity.RegisterGameTickListener(OnTick3s, 3000); } }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); if (api.Side.IsServer()) { face = BlockFacing.FromCode(Block.Variant["side"]); CheckWater(0); Blockentity.RegisterGameTickListener(CheckWater, 1000); } }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); this.AxisSign = new int[3] { 0, 1, 0 }; if (api.Side == EnumAppSide.Client) { Blockentity.RegisterGameTickListener(onEverySecond, 1000); } }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); if (api.Side == EnumAppSide.Client) { Blockentity.RegisterGameTickListener(onEverySecond, 1000); } if (largeGear != null) { if (largeGear.AngledGearNotAlreadyAdded(this.Position)) // during chunk loading it's random whether the angled gear or the large gear gets initialised first { this.tryConnect(this.orientation.Opposite); } } }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); Circuit.Initialize(api); listenerId = Blockentity.RegisterGameTickListener(Update, 50); block = Blockentity.Block; Pos = this.Blockentity.Pos; //facing = BlockFacing.FromCode(block?.LastCodePart(0)?.ToString()); //orientation = BlockFacing.FromCode(block?.LastCodePart(1)?.ToString()); facing = BlockFacing.FromCode(properties["side"]?.AsString("down")); orientation = BlockFacing.FromCode(properties["orientation"]?.AsString("north")); if (api.Side == EnumAppSide.Client) { ICoreClientAPI capi = (ICoreClientAPI)api; capi.Event.RegisterRenderer(renderer = new CircuitBoardRenderer(this.Blockentity.Pos, facing, orientation, capi), EnumRenderStage.Opaque, "circuitboard"); renderer.RegenCircuitMesh(Circuit); } }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); //this.Api = api; //Shape = GetShape(); //manager = Api.ModLoader.GetModSystem<MechanicalPowerMod>(); //if (Api.World.Side == EnumAppSide.Client) //{ // lightRbs = Api.World.BlockAccessor.GetLightRGBs(Blockentity.Pos); // if (NetworkId > 0) // { // network = manager.GetOrCreateNetwork(NetworkId); // JoinNetwork(network); // } //} //manager.AddDeviceForRender(this); //AxisSign = new int[3] { 0, 0, 1 }; //SetOrientations(); //if (api.Side == EnumAppSide.Server && OutFacingForNetworkDiscovery != null) //{ // CreateJoinAndDiscoverNetwork(OutFacingForNetworkDiscovery); //} if (api.Side == EnumAppSide.Client) { Blockentity.RegisterGameTickListener(onEverySecond, 1000); } if (largeGear != null) { if (largeGear.AngledGearNotAlreadyAdded(this.Position)) // during chunk loading it's random whether the angled gear or the large gear gets initialised first { this.tryConnect(this.orientation.Opposite); } } }
public override void Initialize(ICoreAPI api, JsonObject properties) { base.Initialize(api, properties); dateLastChecked = Api.World.Calendar.TotalDays; // Read the properties fruitCodeBases = properties["fruitCodeBases"].AsArray<string>(new string[0]); if (fruitCodeBases.Length == 0) return; positionsCount = properties["positions"].AsInt(0); if (positionsCount <= 0) return; string maturePlant = properties["maturePlant"].AsString(null); if (maturePlant == null) return; Block mature = api.World.GetBlock(new AssetLocation(maturePlant)); if (!(mature is BlockFruiting matureCrop)) return; if (Api.Side == EnumAppSide.Client) { points = matureCrop.GetFruitingPoints(); } maxFruit = properties["maxFruit"].AsInt(5); fruitStages = properties["fruitStages"].AsInt(6); maxGerminationDays = properties["maxGerminationDays"].AsFloat(6); transitionDays = properties["transitionDays"].AsFloat(1); successfulGrowthChance = properties["successfulGrowthChance"].AsFloat(0.75f); ripeStage = properties["ripeStage"].AsInt(fruitStages - 1); dropCode = new AssetLocation(properties["dropCode"].AsString(null)); // Set up the manager - used for the instanced renderer manager = Api.ModLoader.GetModSystem<FruitingSystem>(); // If initialising client-side after reading from tree attributes, send fruits to the renderer bool addToManager = false; if (Api.Side == EnumAppSide.Client && fruitPoints != null) { LightRgba = Api.World.BlockAccessor.GetLightRGBs(Blockentity.Pos); addToManager = true; } InitializeArrays(); if (addToManager) { for (int i = 0; i < positionsCount; i++) { FruitData val = fruitPoints[i]; if (val.variant >= fruitCodeBases.Length) val.variant %= fruitCodeBases.Length; if (val.variant >= 0 && val.currentStage > 0) { val.SetRandomRotation(Api.World, i, positions[i], this.Blockentity.Pos); manager.AddFruit(new AssetLocation(fruitCodeBases[val.variant] + val.currentStage), positions[i], val); } } } // Tick the blockEntity server-side only if (Api.Side == EnumAppSide.Server) Blockentity.RegisterGameTickListener(CheckForGrowth, 2250); }