Modding:Advanced Blocks: Difference between revisions

From Vintage Story Wiki
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__FORCETOC__
__FORCETOC__
{{GameVersion|1.9}}


It's highly recommended to read [[Basic Block]] first. Additionally this tutorial requires a development environment. If you don't have one already you should read the tutorial [[Setting up your Development Environment]].
It's highly recommended to read [[Basic Block]] first. Additionally this tutorial requires a development environment. If you don't have one already you should read the tutorial [[Setting up your Development Environment]].
Line 84: Line 85:
public class TrampolineBlock : Block
public class TrampolineBlock : Block
{
{
     public override void onEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, bool isImpact)
     public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, Vec3d collideSpeed, bool isImpact)
     {
     {
         if (isImpact && facing.Axis == EnumAxis.Y)
         if (isImpact && facing.Axis == EnumAxis.Y)
         {
         {
            world.PlaySoundAt(tickSound, entity.Pos.X, entity.Pos.Y, entity.Pos.Z);
             entity.Pos.Motion.Y *= -0.8;
             entity.Pos.Motion.Y *= -0.8;
         }
         }
Line 130: Line 132:
         public AssetLocation tickSound = new AssetLocation("game", "tick");
         public AssetLocation tickSound = new AssetLocation("game", "tick");


         public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, bool isImpact)
         public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, Vec3d collideSpeed, bool isImpact)
         {
         {
             if (isImpact && facing.Axis == EnumAxis.Y)
             if (isImpact && facing.Axis == EnumAxis.Y)
Line 156: Line 158:
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. It will work in the same way as ordinary mods, you can install it by copying it into the <code>mods</code> folder.
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. It will work in the same way as ordinary mods, you can install it by copying it into the <code>mods</code> folder.


Here is my version: [https://wiki.vintagestory.at/images/c/ce/Trampoline.zip Trampoline.zip]
= Mod Download =


Here is my version:
* for VS v1.9: [https://wiki.vintagestory.at/images/2/24/Trampoline_vs1.9_v1.0.0.zip Trampoline_vs1.9_v1.0.0.zip]
* for VS v1.5: [https://wiki.vintagestory.at/images/c/ce/Trampoline.zip Trampoline.zip]
= Moving Forward =
Now that you've successfully made an advanced block you can go even further by learning how to utilize '''[[Modding:Block Entity| Block Entities]]''' and how to create your own '''[[Modding:Adding Block Behavior | Block Behaviors]]'''. Both of these tutorials will teach you how to add even more mechanics to your custom blocks.
Or, you can try out making an '''[[Modding:Advanced Items | Advanced Item]]''' if you haven't already.


{{Navbox/modding|Vintage Story}}
{{Navbox/modding|Vintage Story}}
219

edits