Modding:Advanced Blocks
From Vintage Story Wiki
Revision as of 10:18, 28 March 2017 by CreativeMD (talk | contribs) (Created page with "__FORCETOC__ This tutorial requires a development environment. If you don't have one or don't know how to setup up something like that read the tutorial Setting up a dev en...")
This tutorial requires a development environment. If you don't have one or don't know how to setup up something like that read the tutorial Setting up a dev environment.
Tramopline
Block Json File
class: "trampoline",
You can download the assets here.
The Block Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vintagestory.API;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.API.MathTools;
namespace VSExampleMods
{
public class TrampolineMod : ModBase
{
public override void Start(ICoreAPI api)
{
base.Start(api);
api.RegisterBlockClass("trampoline", typeof(TrampolineBlock));
}
}
public class TrampolineBlock : Block
{
public override void onEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, bool isImpact)
{
if (isImpact && facing.Axis == EnumAxis.Y)
{
entity.PlayEntitySound("tick", EnumAppSide.Server);
entity.Pos.Motion.Y *= -0.8;
}
}
}
}