Modding:Adding Block Behavior: Difference between revisions

From Vintage Story Wiki
no edit summary
No edit summary
(9 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<languages />
<translate>
__FORCETOC__
__FORCETOC__


Line 9: Line 11:
== Setting up ==
== Setting up ==


A [[Setting up a dev environment|development workspace]] is required. Additionally you will need the assets (blocktype, texture and lang file). You can either create your one owns or use those pre-made ones: [http://wiki.vintagestory.at/images/2/2f/Moving_-_No_CS_File.zip Moving - No CS File.zip]
A [[Setting up your Development Environment|development workspace]] is required. Additionally you will need the assets (blocktype, texture and lang file). You can either create your one owns or use those pre-made ones: [https://wiki.vintagestory.at/images/2/2f/Moving_-_No_CS_File.zip Moving - No CS File.zip]


== Creating the behavior ==
== Creating the behavior ==


So first of all we need to create the behavior itself, which is a class extending BlockBehavior
So first of all we need to create the behavior itself, which is a class extending BlockBehavior
<syntaxhighlight lang="c#">
<syntaxhighlight lang="csharp">
class Moving : BlockBehavior
class Moving : BlockBehavior
{
{
Line 63: Line 65:


<syntaxhighlight lang="c#">
<syntaxhighlight lang="c#">
     public class MovingBlocks : ModBase
     public class MovingBlocks : ModSystem
     {
     {


Line 69: Line 71:
         {
         {
             base.Start(api);
             base.Start(api);
             api.RegisterEntityBehaviorClass("Moving", typeof(Moving));
             api.RegisterBlockBehaviorClass("Moving", typeof(Moving));
         }
         }


Line 75: Line 77:
</syntaxhighlight>
</syntaxhighlight>


Now all you need to do is to put the *.cs file in the zip file as well and you are ready to test/ distribute your mod.
== Distribution ==


You can download the example mod [http://wiki.vintagestory.at/images/c/cb/Moving.zip here].
In order to finish everything, open the modtools and type in <code>pack <your mod id></code>. Now you can take the zip file and share it with other people.
* for VS 1.9: [https://wiki.vintagestory.at/images/2/2a/Moving_v1.0.0.zip Moving_v1.0.0.zip]
* for VS 1.6: [https://wiki.vintagestory.at/images/c/cb/Moving.zip Moving.zip]


== Testing ==
== Testing ==
Line 172: Line 176:
The block will be pushed two blocks instead of one and the player can pull it by sneaking while right clicking.
The block will be pushed two blocks instead of one and the player can pull it by sneaking while right clicking.


You can download the complete mod [http://wiki.vintagestory.at/images/7/72/AdvancedMoving.zip here].
* for VS 1.9: [https://wiki.vintagestory.at/images/7/7b/Advancedmoving_v1.0.0.zip AdvancedMoving_v1.0.0.zip]
* for VS 1.6: [https://wiki.vintagestory.at/images/7/72/AdvancedMoving.zip AdvancedMoving.zip]
 
 
 
{{Navbox/modding|Vintage Story}}
 
 
</translate>
Confirmedusers, editor, Administrators
886

edits