Modding:Block Entity/ru: Difference between revisions

From Vintage Story Wiki
Created page with "<syntaxhighlight lang="c#"> public override void Initialize(ICoreAPI api) { base.Initialize(api); } </syntaxhighlight>"
(Created page with "<syntaxhighlight lang="c#"> public void OnGameTick(float dt) { timer += dt; if(timer >= 3) { Block block = Api.World.BlockAccessor.GetBlock(Pos); if (block.Code.Path.EndsWith("-on")) { block = Api.World.GetBlock(block.CodeWithParts("off")); } else { block = Api.World.GetBlock(block.Code...")
(Created page with "<syntaxhighlight lang="c#"> public override void Initialize(ICoreAPI api) { base.Initialize(api); } </syntaxhighlight>")
Line 110: Line 110:
== Регистрация объекта блока ==
== Регистрация объекта блока ==


<div lang="en" dir="ltr" class="mw-content-ltr">
Регистрация класса блочной сущности довольно проста (скорее похожа на регистрацию блочного класса). Вам нужен класс мода и переопределить <code>Start(ICoreAPI)</code>:
Registering the blockentity class is rather simple (rather similar to registering a block class). You need a mod class and override <code>Start(ICoreAPI)</code>:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
     public class Ticking : ModSystem
     public class Ticking : ModSystem
     {
     {
</div>


         <div lang="en" dir="ltr" class="mw-content-ltr">
         public override void Start(ICoreAPI api)
public override void Start(ICoreAPI api)
         {
         {
             base.Start(api);
             base.Start(api);
             api.RegisterBlockEntityClass("tickingcounter", typeof(TickingBlockEntity));
             api.RegisterBlockEntityClass("tickingcounter", typeof(TickingBlockEntity));
         }
         }
</div>


     <div lang="en" dir="ltr" class="mw-content-ltr">
     }
}
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Confirmedusers
13,514

edits