Anonymous
Not logged in
English
Create account
Log in
Vintage Story Wiki
Search
Export translations
From Vintage Story Wiki
Namespaces
More
More
Page actions
Language statistics
Message group statistics
Export
Settings
Group
Accessibility
Adjustable FPS Video Recording
Alcohol brewing
Alum
Ambience Features
Animal husbandry
Anvil
Archimedes screw
Armor
Armor stand
Arrow
Arrowhead
Axe
Backpack
Bag
Bandage
Barrel
Base return teleporter
Basket
Bear
Bed
Beekeeping
Beenade
Bees
Beeswax
Bell
Berry
Bighorn sheep
Bismuth
Blackguard armor
Block reinforcement
Bloomery
Boards
Bone
Bonemeal
Bony ribcage
Bony soil
Book
Bookshelf
Bookshelf (legacy)
Borax
Bot System
Bow
Bowl
Brass
Bread
Brick blocks
Brigandine armor
Bronze
Bug net
Butterfly
Cabbage
Carpet
Carrot
Cassava
Casting
Category:Armor
Category:Bags
Category:Blocks
Category:Building Blocks
Category:Combustibles
Category:Creative Mode
Category:Creatures
Category:Crops
Category:Entity Loot
Category:Fertile Blocks
Category:Foods
Category:Fuels
Category:Game Content
Category:Guides
Category:Hostile creatures
Category:Inventions
Category:Items
Category:Light Emitters
Category:Liquid storage
Category:Lore
Category:Mechanisms
Category:Metals
Category:Minerals
Category:Outdated pages
Category:Pigments
Category:Priority translation
Category:Storage
Category:Structures
Category:Stubs
Category:Tools
Category:Transitionable
Category:Transport
Category:UI
Category:Under construction
Category:Weapons
Cellar
Ceramic Blocks
Chain armor
Charcoal
Cheese
Chest
Chicken
Chisel
Cinematic Camera
Cinnabar
Classes
Clay
Clay forming
Clay oven
Cleaver
Client startup parameters
Cloth
Clothes
Club
Coal
Coke
Collectibles
Combat
Compost
Container
Controller Compatibility
Controls
Cooking
Cooking pot
Coordinates
Copper
Cracked vessel
Crafting
Crafting Recipes
Crate
Crock
Crucible
Crude oar
Debarked log
Debugging
Display Case
Door
Drifter
Dry grass
Dye
Egg
Falx
Farming
Fat
Feather
Fence
Fire Brick
Firepit
Firestarter
Firewood
Flax
Flax fibers
Flint
Flower
Flowerpots
Food preservation
Foraging
Forge
Forlorn Hope armor
Fox
Framerate and Performance
Frequently Asked Questions (FAQ)
Fruit Press
Fruit tree
Fuel
Gambeson armor
Gazelle
Gemstone
Glass
Glider
Gold
Grain
Grass
Gravel
Greenhouse
Ground Storage
Guide:Creative mode
Halite
Hammer
Hand basket
Hare
Hay
Health
Help:How to help
Helve hammer
Henbox
Historic Crafting Recipes
Hoe
Honeycomb
Hostile entities
How to use WorldEdit
Humanoid
Hunter's backpack
Hyena
Immobilized eidolon
Improvised body armor
Ingot
Ink and quill
Installing the game on Linux
Iron
Jam
Jonas part
Knapping
Knife
Ladder
Lamellar armor
Land claiming
Lapis lazuli
Lead
Leather
Leather armor
Leather bracers
Leather jerkin
Leather reinforced mask
Leather working
Light sources
Lightning rod
Lime
Linen
Linen sack
List of client commands
List of client commands/cam
List of client commands/clientconfig
List of server commands
List of server commands/debug
List of server commands/entity
List of server commands/gamemode
List of server commands/group
List of server commands/info
List of server commands/land
List of server commands/macro
List of server commands/player
List of server commands/role
List of server commands/serverconfig
List of server commands/time
List of server commands/tp
List of server commands/weather
List of server commands/wgen
Locust
Log
Lore book
Macro
Main Page
Mantle
Meal
Meat
Meat stew
Mechanical
Mechanical power
Metal
Metal parts
Metal plate
Metal scraps
Metal spike
Meteoric iron
Meteorite
Mining
Mining bag
Modding:Adding Block Behavior
Modding:Advanced Blocks
Modding:Advanced Items
Modding:Animation
Modding:Asset System
Modding:Asset Type - BlockTypes
Modding:Asset Type - Entities
Modding:Asset Type - ItemTypes
Modding:Asset Type - Patches
Modding:Asset Type - Recipes
Modding:Asset Type - Recipes (Alloy)
Modding:Asset Type - Recipes (Barrel)
Modding:Asset Type - Recipes (Clayforming)
Modding:Asset Type - Recipes (Cooking)
Modding:Asset Type - Recipes (Grid)
Modding:Asset Type - Recipes (Knapping)
Modding:Asset Type - Recipes (Smithing)
Modding:Asset Type - Shapes
Modding:Asset Type - Sounds
Modding:Asset Type - Textures
Modding:Asset Type - WorldProperties
Modding:Basic Block
Modding:Basic Content Tutorials
Modding:Basic Entity
Modding:Basic Inventory Handling
Modding:Basic Item
Modding:Basic Modding Examples
Modding:Block and Item Interactions
Modding:Block Entity
Modding:Block Json Properties
Modding:Chunk Moddata
Modding:Code Mods
Modding:Code Tutorial Simple Block
Modding:Commands
Modding:Community Resources
Modding:Content Mods
Modding:Content Tutorial Basics
Modding:Content Tutorial Block Variants
Modding:Content Tutorial Item Variants
Modding:Content Tutorial Simple Block
Modding:Content Tutorial Simple Item
Modding:Content Tutorial Simple Recipe
Modding:Creating Recipes
Modding:Developing a Content Mod
Modding:Entity Json Properties
Modding:Getting Started
Modding:GUIs
Modding:Intermediate Content Tutorials
Modding:Item Json Properties
Modding:JSON Patching
Modding:Load Order
Modding:Mod Packaging
Modding:Mod-Engine Compatibility
Modding:Moddable Mod
Modding:Modding API Updates
Modding:Modding Efficiently
Modding:Network API
Modding:Other Content Tutorials
Modding:Preparing For Code Mods
Modding:Programming Languages
Modding:Rendering API
Modding:SaveGame ModData
Modding:Server-Client Considerations
Modding:Setting up your Development Environment
Modding:Simple Particles
Modding:Textures
Modding:The Remapper
Modding:Theme Pack
Modding:TreeAttribute
Modding:Tutorial Template
Modding:VS Model Creator
Modding:VS Model Creator tutorials
Modding:World Access
Modding:WorldGen API
Modding:WorldGen Concept
Modding:WorldGen Configuration
Modinfo
Mold
Mortar
Mushroom
Nails and strips
Nickel
Night vision mask
Off-hand
Omok
Onion
Ore
Ore blasting bomb
Ore Deposits
Other Plants
Painting
Panning
Parchment
Parsnip
Path
Peanut
Peat
Peat brick
Pickaxe
Pigment
Pineapple
Pit kiln
Planks
Plaque
Plaster
Porridge
Potash
Poultice
Prospecting Pick
Pulverizer
Pumpkin
Quern
Raccoon
Raft
Reed
Reed basket trap
Reed chest
Resin
Resonance Archives
Resonator
Resource Crafting
Rift ward
Rock
Roofing blocks
Room
Rope
Rot
Ruin
Rusty gears
Salmon
Saltpeter
Sand
Sandbox/darce/test
Sandbox/Daretmavi/maintest
Sandbox/Tyron/Home alt
Sandbox/ZulfBracket/Home
Sandbox/ZulfBracket/Home alt
Satiety
Saw
Scrambled eggs
Scrap weapon kit
Scythe
Sea shell
Seasons
Server Config
Server startup parameters
ServerBlockTicking
Setting up a Multiplayer Server
Sewing kit
Shears
Shelf
Shield
Shovel
Sieve
Sign
Signpost
Silver
Skep
Smithing
Soil
Soil Blocks
Soup
Soybean
Spear
Steel
Steel making
Stick
Stone Blocks
Storage vessel
Straw dummy
Strewn straw
Suggestions
Sulfur
Support beam
Surface
Survival Guide - Advanced tech
Survival Guide - Your first day
Tapestry
Temperature
Template:AnimalTabs
Template:AnimalTabs/doc
Template:Armor
Template:Block
Template:Block/doc
Template:Blocks navbox
Template:Breaking
Template:Breaking/doc
Template:Climate
Template:Content
Template:Cooking navbox
Template:Cooking navbox/doc
Template:Crafting
Template:Creature
Template:Development
Template:Development/doc
Template:Drops
Template:Drops/Nothing
Template:Drops/row/doc
Template:Entities navbox
Template:Entity infobox
Template:Entity infobox/doc
Template:Farming navbox
Template:Game navbox
Template:GameVersion
Template:GameVersion/doc
Template:Item
Template:Item/doc
Template:Item/Food
Template:Item/Food/Category
Template:Item/Fuel
Template:Item/Fuel/doc
Template:Item/Smeltable
Template:Item/Transitionable
Template:Items navbox
Template:Keypress/doc
Template:Metals navbox
Template:Navbox/codemodding
Template:Navbox/contentmodding
Template:Navbox/modding
Template:Navbox/properties-audio
Template:Navbox/properties-config
Template:Navbox/properties-gameobjects
Template:Navbox/properties-patches
Template:Navbox/properties-recipes
Template:Navbox/properties-template
Template:Navbox/properties-worldgen
Template:Navbox/properties-worldproperties
Template:Needs image
Template:Outdated
Template:Outdated/doc
Template:PageOutdated
Template:Protip
Template:Protip/doc
Template:Range
Template:Range/doc
Template:Sandbox/Xandoria/Testing
Template:SectionOutdated
Template:SneakClick
Template:Spawn
Template:Spoiler
Template:Sprint
Template:Stub
Template:Stub/doc
Template:Tool
Template:Tool/MiningSpeed
Template:Using
Template:Using/doc
Template:Weapon
Template:Weapon/Attack
Temporal gear
Temporal rift
Temporal stability
Temporal storm
Terminus teleporter
Termite
Termite mound
Terrain Generation
Thatch
Tin
Titanium
Tongs
Tool rack
Tools
Tools and Weapons
Torch
Trading
Translocator
Tree
Troubleshooting Guide
Trough
Tuning cylinder
Tuning spear
Turnip
Twine
Updating Old Worlds
User:Degradkal
User:Grimdian
User:Nateonus
User:Nateonus/navbox/content
User:Nateonus/navbox/main
User:Saricane/Sandbox/Firestarter
User:Saricane/Sandbox/Test1
User:Saricane/Sandbox/Test2
User:Xandoria/Sandbox/Test1
Vegetable stew
Version history
Vertical rack
Vintage Story Original Soundtrack
Vintage Story Wiki:How to translate the wiki
Vintage Story Wiki:Translation Tables
Vintage Story Wiki:Video Tutorials Needed
VintagestoryData folder
VTML
Wallpapers
Water
Weapons
Weather
Wild food
Wild pig
Windmill
Wolf
Wooden bucket
World Configuration
World generation
Worldmap
Wrench
Zinc
Language
aa - Afar
ab - Abkhazian
abs - Ambonese Malay
ace - Achinese
ady - Adyghe
ady-cyrl - Adyghe (Cyrillic script)
aeb - Tunisian Arabic
aeb-arab - Tunisian Arabic (Arabic script)
aeb-latn - Tunisian Arabic (Latin script)
af - Afrikaans
ak - Akan
aln - Gheg Albanian
alt - Southern Altai
am - Amharic
ami - Amis
an - Aragonese
ang - Old English
anp - Angika
ar - Arabic
arc - Aramaic
arn - Mapuche
arq - Algerian Arabic
ary - Moroccan Arabic
arz - Egyptian Arabic
as - Assamese
ase - American Sign Language
ast - Asturian
atj - Atikamekw
av - Avaric
avk - Kotava
awa - Awadhi
ay - Aymara
az - Azerbaijani
azb - South Azerbaijani
ba - Bashkir
ban - Balinese
ban-bali - ᬩᬲᬩᬮᬶ
bar - Bavarian
bbc - Batak Toba
bbc-latn - Batak Toba (Latin script)
bcc - Southern Balochi
bci - Baoulé
bcl - Central Bikol
be - Belarusian
be-tarask - Belarusian (Taraškievica orthography)
bg - Bulgarian
bgn - Western Balochi
bh - Bhojpuri
bho - Bhojpuri
bi - Bislama
bjn - Banjar
blk - Pa'O
bm - Bambara
bn - Bangla
bo - Tibetan
bpy - Bishnupriya
bqi - Bakhtiari
br - Breton
brh - Brahui
bs - Bosnian
btm - Batak Mandailing
bto - Iriga Bicolano
bug - Buginese
bxr - Russia Buriat
ca - Catalan
cbk-zam - Chavacano
cdo - Min Dong Chinese
ce - Chechen
ceb - Cebuano
ch - Chamorro
cho - Choctaw
chr - Cherokee
chy - Cheyenne
ckb - Central Kurdish
co - Corsican
cps - Capiznon
cr - Cree
crh - Crimean Tatar
crh-cyrl - Crimean Tatar (Cyrillic script)
crh-latn - Crimean Tatar (Latin script)
cs - Czech
csb - Kashubian
cu - Church Slavic
cv - Chuvash
cy - Welsh
da - Danish
dag - Dagbani
de - German
de-at - Austrian German
de-ch - Swiss High German
de-formal - German (formal address)
din - Dinka
diq - Zazaki
dsb - Lower Sorbian
dtp - Central Dusun
dty - Doteli
dv - Divehi
dz - Dzongkha
ee - Ewe
egl - Emilian
el - Greek
eml - Emiliano-Romagnolo
en - English
en-ca - Canadian English
en-gb - British English
eo - Esperanto
es - Spanish
es-419 - Latin American Spanish
es-formal - Spanish (formal address)
et - Estonian
eu - Basque
ext - Extremaduran
fa - Persian
ff - Fulah
fi - Finnish
fit - Tornedalen Finnish
fj - Fijian
fo - Faroese
fon - Fon
fr - French
frc - Cajun French
frp - Arpitan
frr - Northern Frisian
fur - Friulian
fy - Western Frisian
ga - Irish
gaa - Ga
gag - Gagauz
gan - Gan Chinese
gan-hans - Gan (Simplified)
gan-hant - Gan (Traditional)
gcr - Guianan Creole
gd - Scottish Gaelic
gl - Galician
gld - Nanai
glk - Gilaki
gn - Guarani
gom - Goan Konkani
gom-deva - Goan Konkani (Devanagari script)
gom-latn - Goan Konkani (Latin script)
gor - Gorontalo
got - Gothic
grc - Ancient Greek
gsw - Swiss German
gu - Gujarati
guc - Wayuu
gur - Frafra
guw - Gun
gv - Manx
ha - Hausa
hak - Hakka Chinese
haw - Hawaiian
he - Hebrew
hi - Hindi
hif - Fiji Hindi
hif-latn - Fiji Hindi (Latin script)
hil - Hiligaynon
ho - Hiri Motu
hr - Croatian
hrx - Hunsrik
hsb - Upper Sorbian
hsn - Xiang Chinese
ht - Haitian Creole
hu - Hungarian
hu-formal - Hungarian (formal address)
hy - Armenian
hyw - Western Armenian
hz - Herero
ia - Interlingua
id - Indonesian
ie - Interlingue
ig - Igbo
ii - Sichuan Yi
ik - Inupiaq
ike-cans - Eastern Canadian (Aboriginal syllabics)
ike-latn - Eastern Canadian (Latin script)
ilo - Iloko
inh - Ingush
io - Ido
is - Icelandic
it - Italian
iu - Inuktitut
ja - Japanese
jam - Jamaican Creole English
jbo - Lojban
jut - Jutish
jv - Javanese
ka - Georgian
kaa - Kara-Kalpak
kab - Kabyle
kbd - Kabardian
kbd-cyrl - Kabardian (Cyrillic script)
kbp - Kabiye
kcg - Tyap
kea - Kabuverdianu
kg - Kongo
khw - Khowar
ki - Kikuyu
kiu - Kirmanjki
kj - Kuanyama
kjp - Eastern Pwo
kk - Kazakh
kk-arab - Kazakh (Arabic script)
kk-cn - Kazakh (China)
kk-cyrl - Kazakh (Cyrillic script)
kk-kz - Kazakh (Kazakhstan)
kk-latn - Kazakh (Latin script)
kk-tr - Kazakh (Turkey)
kl - Kalaallisut
km - Khmer
kn - Kannada
ko - Korean
ko-kp - Korean (North Korea)
koi - Komi-Permyak
kr - Kanuri
krc - Karachay-Balkar
kri - Krio
krj - Kinaray-a
krl - Karelian
ks - Kashmiri
ks-arab - Kashmiri (Arabic script)
ks-deva - Kashmiri (Devanagari script)
ksh - Colognian
ksw - S'gaw Karen
ku - Kurdish
ku-arab - Kurdish (Arabic script)
ku-latn - Kurdish (Latin script)
kum - Kumyk
kv - Komi
kw - Cornish
ky - Kyrgyz
la - Latin
lad - Ladino
lb - Luxembourgish
lbe - Lak
lez - Lezghian
lfn - Lingua Franca Nova
lg - Ganda
li - Limburgish
lij - Ligurian
liv - Livonian
lki - Laki
lld - Ladin
lmo - Lombard
ln - Lingala
lo - Lao
loz - Lozi
lrc - Northern Luri
lt - Lithuanian
ltg - Latgalian
lus - Mizo
luz - Southern Luri
lv - Latvian
lzh - Literary Chinese
lzz - Laz
mad - Madurese
mai - Maithili
map-bms - Basa Banyumasan
mdf - Moksha
mg - Malagasy
mh - Marshallese
mhr - Eastern Mari
mi - Maori
min - Minangkabau
mk - Macedonian
ml - Malayalam
mn - Mongolian
mni - Manipuri
mnw - Mon
mo - Moldovan
mr - Marathi
mrh - Mara
mrj - Western Mari
ms - Malay
ms-arab - Malay (Jawi script)
mt - Maltese
mus - Muscogee
mwl - Mirandese
my - Burmese
myv - Erzya
mzn - Mazanderani
na - Nauru
nah - Nāhuatl
nan - Min Nan Chinese
nap - Neapolitan
nb - Norwegian Bokmål
nds - Low German
nds-nl - Low Saxon
ne - Nepali
new - Newari
ng - Ndonga
nia - Nias
niu - Niuean
nl - Dutch
nl-informal - Dutch (informal address)
nmz - Nawdm
nn - Norwegian Nynorsk
no - Norwegian
nod - Northern Thai
nov - Novial
nqo - N’Ko
nrm - Norman
nso - Northern Sotho
nv - Navajo
ny - Nyanja
nyn - Nyankole
nys - Nyungar
oc - Occitan
ojb - Northwestern Ojibwe
olo - Livvi-Karelian
om - Oromo
or - Odia
os - Ossetic
pa - Punjabi
pag - Pangasinan
pam - Pampanga
pap - Papiamento
pcd - Picard
pdc - Pennsylvania German
pdt - Plautdietsch
pfl - Palatine German
pi - Pali
pih - Norfuk / Pitkern
pl - Polish
pms - Piedmontese
pnb - Western Punjabi
pnt - Pontic
prg - Prussian
ps - Pashto
pt - Portuguese
pt-br - Brazilian Portuguese
pwn - Paiwan
qqq - Message documentation
qu - Quechua
qug - Chimborazo Highland Quichua
rgn - Romagnol
rif - Riffian
rm - Romansh
rmc - Carpathian Romani
rmy - Vlax Romani
rn - Rundi
ro - Romanian
roa-tara - Tarantino
rsk - руски
ru - Russian
rue - Rusyn
rup - Aromanian
ruq - Megleno-Romanian
ruq-cyrl - Megleno-Romanian (Cyrillic script)
ruq-latn - Megleno-Romanian (Latin script)
rw - Kinyarwanda
sa - Sanskrit
sah - Sakha
sat - Santali
sc - Sardinian
scn - Sicilian
sco - Scots
sd - Sindhi
sdc - Sassarese Sardinian
sdh - Southern Kurdish
se - Northern Sami
se-fi - davvisámegiella (Suoma bealde)
se-no - davvisámegiella (Norgga bealde)
se-se - davvisámegiella (Ruoŧa bealde)
sei - Seri
ses - Koyraboro Senni
sg - Sango
sgs - Samogitian
sh - Serbo-Croatian
shi - Tachelhit
shi-latn - Tachelhit (Latin script)
shi-tfng - Tachelhit (Tifinagh script)
shn - Shan
shy - Shawiya
shy-latn - Shawiya (Latin script)
si - Sinhala
simple - Simple English
sjd - Kildin Sami
sje - Pite Sami
sk - Slovak
skr - Saraiki
skr-arab - Saraiki (Arabic script)
sl - Slovenian
sli - Lower Silesian
sm - Samoan
sma - Southern Sami
smn - Inari Sami
sms - Skolt Sami
sn - Shona
so - Somali
sq - Albanian
sr - Serbian
sr-ec - Serbian (Cyrillic script)
sr-el - Serbian (Latin script)
srn - Sranan Tongo
ss - Swati
st - Southern Sotho
stq - Saterland Frisian
sty - Siberian Tatar
su - Sundanese
sv - Swedish
sw - Swahili
szl - Silesian
szy - Sakizaya
ta - Tamil
tay - Tayal
tcy - Tulu
te - Telugu
tet - Tetum
tg - Tajik
tg-cyrl - Tajik (Cyrillic script)
tg-latn - Tajik (Latin script)
th - Thai
ti - Tigrinya
tk - Turkmen
tl - Tagalog
tly - Talysh
tly-cyrl - толыши
tn - Tswana
to - Tongan
tpi - Tok Pisin
tr - Turkish
tru - Turoyo
trv - Taroko
ts - Tsonga
tt - Tatar
tt-cyrl - Tatar (Cyrillic script)
tt-latn - Tatar (Latin script)
tum - Tumbuka
tw - Twi
ty - Tahitian
tyv - Tuvinian
tzm - Central Atlas Tamazight
udm - Udmurt
ug - Uyghur
ug-arab - Uyghur (Arabic script)
ug-latn - Uyghur (Latin script)
uk - Ukrainian
ur - Urdu
uz - Uzbek
uz-cyrl - Uzbek (Cyrillic script)
uz-latn - Uzbek (Latin script)
ve - Venda
vec - Venetian
vep - Veps
vi - Vietnamese
vls - West Flemish
vmf - Main-Franconian
vmw - Makhuwa
vo - Volapük
vot - Votic
vro - Võro
wa - Walloon
war - Waray
wls - Wallisian
wo - Wolof
wuu - Wu Chinese
xal - Kalmyk
xh - Xhosa
xmf - Mingrelian
xsy - Saisiyat
yi - Yiddish
yo - Yoruba
yrl - Nheengatu
yue - Cantonese
za - Zhuang
zea - Zeelandic
zgh - Standard Moroccan Tamazight
zh - Chinese
zh-cn - Chinese (China)
zh-hans - Simplified Chinese
zh-hant - Traditional Chinese
zh-hk - Chinese (Hong Kong)
zh-mo - Chinese (Macau)
zh-my - Chinese (Malaysia)
zh-sg - Chinese (Singapore)
zh-tw - Chinese (Taiwan)
zu - Zulu
Format
Export for off-line translation
Export in native format
Fetch
<languages/> __TOC__ <div lang="en" dir="ltr" class="mw-content-ltr"> == Introduction == </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Objective === In this tutorial, you will be introduced to code modding by creating a block with custom functionality. You will create the assets for this project, find out how block classes are registered, and use a number of different functions. The block you will be creating is a trampoline, where as an entity collides with it, they will bounce. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Please note that this tutorial is quite detailed since it is the first in the code tutorial series. If you are new to modding, it is highly recommended to follow each of these steps. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Prerequisites === It is recommended to use the same project for all newer code tutorials, with the project name "VSTutorial". If you have not yet done this, please follow the following tutorials: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> # [[Modding:Preparing For Code Mods|Preparing For Code Mods]] # [[Modding:Creating A Code Mod|Creating A Code Mod]] </div> <div lang="en" dir="ltr" class="mw-content-ltr"> This tutorial also assumes that you have read: </div> <div lang="en" dir="ltr" class="mw-content-ltr"> * [[Modding:Code Tutorial Essentials|Code Tutorial Essentials]] </div> <div lang="en" dir="ltr" class="mw-content-ltr"> == Assets == [[File:VisualStudioOpenAssetsFolderInExplorerNeat.png|right|frameless]] Before you get started with any coding, it is important that you create the assets for your new trampoline block. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> In Visual Studio, your mod's assets are easy to access from the ''solution explorer.'' Right click on the folder called ''assets'', and then select ''Open Folder in File Explorer''. This will open the assets folder for your mod, which is an identical format to the assets folder in content mods. The opened folder should only contain another folder labeled ''vstutorial''. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> You need to add a few asset files for the trampoline. As always, these can be downloaded from GitHub [https://github.com/Nateonus/vsmodexamples/releases/tag/CodeSimpleBlock here]. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The downloaded zip file contains a folder called ''vstutorial.'' Copy this folder over your own, and the asset files will be added. You can verify this by going back to Visual Studio, looking at the solution explorer, and expanding the assets folder. You should now have a trampoline block type, as well as a lang and texture file. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Run the game, launch a world, and check the creative menu. You should see the trampoline block. It looks fancy, but has absolutely no functionality yet. {| class="wikitable mw-collapsible mw-collapsed" |Playing Vintage Story in fullscreen mode? |- |It is '''highly recommended''' to run the game in windowed mode when making code mods. If your code results in an error, Visual Studio will attempt to gain focus, and Vintage Story will stop responding. You can press F11 to easily switch between the fullscreen and windowed modes. |} </div> <div lang="en" dir="ltr" class="mw-content-ltr"> == Block Class == Close the game and go back to Visual Studio. To add custom functionality to the trampoline block, you'll need to create a '''block class'''. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> A block class is a script that offers custom functionality for any specific blocktype assets. Note that each blocktype can only have a single attached block class. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Creating a Block Class === Before you create a new block class, you should create a new folder called 'Blocks'. It is good practice to keep your classes and other scripts in folders relevant to what they are. In the solution explorer, right click on ''VSTutorial'' (the project, not the one labelled ''solution''), hover over ''Add'', and click ''New Folder''. You can then enter a name for your folder. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> You need a name for your new block's class. Generally, classes in Vintage Story follow the naming convention of {Type}{Name}. So, in the example of a trampoline block class, you should call this block class "BlockTrampoline". </div> <div lang="en" dir="ltr" class="mw-content-ltr"> With your folder now created, you need to create a new class. Right click the new folder, hover over ''Add'', and select ''Class''. This will open a menu with a lot of templates, and an input field to enter your class name. Make sure you have selected the standard ''Class'' at the top of the template list, and enter the name 'BlockTrampoline.cs'. Click ''Add'', and your class will be created. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The trampoline block's class should open automatically, but you can open it manually by double clicking its entry in the solution explorer. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Explaining Block Classes === Let's have a quick run down of how a block class works. Replace the entire contents of the new class with the following code: {| class="wikitable mw-collapsible mw-collapsed" |BlockTrampoline.cs |- |<syntaxhighlight lang="csharp" line="1"> //Here are the imports for this script. Most of these will add automatically. using Vintagestory.API.Common; using Vintagestory.API.MathTools; </div> <div lang="en" dir="ltr" class="mw-content-ltr"> /* * The namespace the class will be in. This is essentially the folder the script is found in. * If you need to use the BlockTrampoline class in any other script, you will have to add 'using VSTutorial.Blocks' to that script. */ namespace VSTutorial.Blocks { /* * The class definition. Here, you define BlockTrampoline as a child of Block, which * means you can 'override' many of the functions within the general Block class. */ internal class BlockTrampoline : Block { //Any code within this 'override' function will be called when a trampoline block is placed. public override void OnBlockPlaced(IWorldAccessor world, BlockPos blockPos, ItemStack byItemStack = null) { //Log a message to the console. api.Logger.Event("Trampoline Block Placed!"); //Perform any default logic when our block is placed. base.OnBlockPlaced(world, blockPos, byItemStack); } </div> <div lang="en" dir="ltr" class="mw-content-ltr"> //Any code within this 'override' function will be called when a trampoline block is broken. public override void OnBlockBroken(IWorldAccessor world, BlockPos pos, IPlayer byPlayer, float dropQuantityMultiplier = 1) { //Log a message to the console. api.Logger.Event("Trampoline Block Broken!"); //Perform any default logic when our block is broken (e.g., dropping the block as an item.) base.OnBlockBroken(world, pos, byPlayer, dropQuantityMultiplier); } } } </syntaxhighlight> |} Note the code comments throughout the file. These are marked by double slashes ( // '')'' or any text between /* and */. These give brief explanations on what every line of this example does. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> For further explanation, on line 15, the ''BlockTrampoline'' class is defined as a child of the ''Block'' class, which is in turn a child of the ''CollectibleObject'' class, and then the ''RegistryObject class''. This essentially means that any function within these three inherited classes marked as '<nowiki/>''virtual''<nowiki/>', '<nowiki/>''abstract'<nowiki/>'', or '<nowiki/>''override''' can be given custom functionality. For an exhaustive list of functions and attributes that can be overriden, take a look at the API documentation for the [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.Block.html#methods Block] and [https://apidocs.vintagestory.at/api/Vintagestory.API.Common.CollectibleObject.html#methods CollectibleObject] methods. {| class="wikitable mw-collapsible mw-collapsed" |Why so many code comments? |- |There is much debate about how many code comments are too many, and when/where they should be used. Although many people who are experienced with C# or other C programming languages may find this code easy to understand, this tutorial is designed for those who may not have ever used a C programming language, or even any programming language. |} </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Registering the Block Class === The class for the trampoline class is created, however before it can be used it needs to be registered through the game API. When you created your mod, a ''mod system'' will have been automatically made. Look for it in your solution explorer, it should be called ''VSTutorialModSystem'', and double click it to open it. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Your mod system will likely contain three functions at this point - ''Start, StartServerSide,'' and ''StartClientSide.'' The server and client side functions are not required here, so feel free to delete them or keep them in for the future. Either is fine. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> In the ''Start'' function, you need to make a call to the RegisterBlockClass function in the API class. Add the following code on a new line inside of the ''Start'' function's block:<syntaxhighlight lang="csharp"> api.RegisterBlockClass(); </syntaxhighlight>You'll notice that, currently, this results in an error. Hover over the 'RegisterBlockClass' with your mouse and it will show you a breakdown of the function. [[File:VSBlockTutorialRegisterBlockClassFunction.png|center|frameless|659x659px]] This tells you the function's parameters and a description of what it does. Not all functions in the code have descriptions attached to them, however as the modding API becomes more documented, these will hopefully become more populated. In this particular case, you need to pass in a class name, and a block type to the function. The class name argument should be fully lowercase, and should generally be your mod ID, joined with the name of the class you just made. The blockType will be the class you just made. Replace the function with the following:<syntaxhighlight lang="csharp"> api.RegisterBlockClass(Mod.Info.ModID + ".trampoline", typeof(BlockTrampoline)); </syntaxhighlight>This will register the BlockTrampoline class with the name "vstutorial.trampoline". {| class="wikitable mw-collapsible mw-collapsed" |Why include the mod id here? |- |If you've made code mods before the introduction of these new tutorials, you probably haven't included your mod ID when registering classes. As more and more mods are being made, there are occasional collisions in regards to class names. Say, for example, two mods both add in a 'trampoline' block class. Only one instance of the trampoline class will exist, which can cause issues if they had slightly different functionality. So, including your mod ID when registering classes will ensure that these 'collisions' do not occur. |} </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Adding Block Class to Asset === Before your block class will work, you need to add a new property to the blocktype JSON asset. In the solution explorer, open the file at ''assets/vstutorial/blocktypes/trampoline.json.'' </div> <div lang="en" dir="ltr" class="mw-content-ltr"> You need to add the following property to the file:<syntaxhighlight lang="json"> "class": "vstutorial.trampoline", </syntaxhighlight>Generally, this element is placed as the second property in your json file, immediately below the code property. Note that the value of this property is identical to the value we used in the ''RegisterBlockClass'' function. This is how the game links the JSON asset files to your code's registered classes. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> == Testing the Block Class == Press F5 again to run the game with the mod. Remember to set the game to windowed mode by pressing F11. Find the trampoline in the creative menu, place one, and destroy it. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> After doing so, take a look at the console that opened when launching the game. You should be able to see the following logs:<syntaxhighlight> [Client Event] Trampoline Block Placed! [Server Event] Trampoline Block Placed! [Client Event] Trampoline Block Broken! [Server Event] Trampoline Block Broken! </syntaxhighlight>Wait... what? The trampoline block was placed once, and broken once, so why are there two entries? Notice that each entry tells you whether it came from the client or server, and in this case, we have one of each. Due to running a singleplayer instance, there is both a client and server running at the same time. The overriden functions are being called once on the client, and once on the server. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> In many instances, this is exactly what is wanted. Most features are synced between the client and server, but it is important to remember that many functions get called twice in this system. There are a number of ways you can verify what 'side' is calling the function, or to limit certain code to one side. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Anyway, it's clear that the trampoline class is working, so close the game and go back to the ''BlockTrampoline'' class. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> == Trampoline Functionality == You need to create the actual functionality for the trampoline. When an entity collides with this block, the entity's vertical velocity should be reversed and multiplied by a certain amount. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The placed and break functions are unnecessary for this block, so you can remove them. Your script should look like the following: {| class="wikitable mw-collapsible mw-collapsed" |BlockTrampoline.cs |- |<syntaxhighlight lang="csharp"> //Here are the imports for this script. Most of these will add automatically. using Vintagestory.API.Common; using Vintagestory.API.MathTools; </div> <div lang="en" dir="ltr" class="mw-content-ltr"> /* * The namespace the class will be in. This is essentially the folder the script is found in. * If you need to use the BlockTrampoline class in any other script, you will have to add 'using VSTutorial.Blocks' to that script. */ namespace VSTutorial.Blocks { /* * The class definition. Here, you define BlockTrampoline as a child of Block, which * means you can 'override' many of the functions within the general Block class. */ internal class BlockTrampoline : Block { } } </syntaxhighlight> |} [[File:VisualStudioListBlockMethodsFromOverride.png|left|frameless|355x355px]] Click on the empty space, and type 'override ' (including the space). Visual Studio will show you a scrollable list of functions that can be overriden. If the menu closes, you can simply delete the space and replace it, and the menu will return. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Feel free to scroll through this menu and take a look at what is available. The functions here are all listed in the API documentation mentioned earlier. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The function you need to use is called ''OnEntityCollide''. With the mentioned menu above, type 'collide', and you should see a single result in the list. Press enter, tab, or double click on the entry, and Visual Studio will generate the function for you. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Take a look at the supplied arguments for this function. You have access to the world, the entity, the block's position, the 'facing' position of the collision, the collision speed, and whether this is an impact. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Making it Bounce === The following points determine when an entity should bounce on the trampoline block. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> # The entity should bounce in the moment it lands on top of the block, and not if it is standing on it already. Therefore, ''isImpact'' needs to be ''true''. # The entity should be colliding vertically. The sides of the block shouldn't push an entity away. In effect, ''facing.IsVertical'' needs to be ''true''. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> So, add the following block inside the function:<syntaxhighlight lang="csharp"> if (isImpact && facing.IsVertical) { } </syntaxhighlight>Now, you need to flip the motion of the entity. To do this, you can change the value at ''entity.Pos.Motion.Y.'' Add the following code inside the ''if'' block.<syntaxhighlight lang="csharp"> entity.Pos.Motion.Y *= -0.8f; </syntaxhighlight>This is a quicker way of writing:<syntaxhighlight lang="csharp"> entity.Pos.Motion.Y = entity.Pos.Motion.Y * -0.8f; </syntaxhighlight> Multiplying by -0.8 will result in reversing the velocity, and reducing it by 20%. Feel free to play with this value to see some different effects. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> The final script should look like the following: {| class="wikitable mw-collapsible mw-collapsed" |BlockTrampoline.cs |- |<syntaxhighlight lang="csharp"> //Here are the imports for this script. Most of these will add automatically. using Vintagestory.API.Common; using Vintagestory.API.Common.Entities; using Vintagestory.API.MathTools; </div> <div lang="en" dir="ltr" class="mw-content-ltr"> /* * The namespace the class will be in. This is essentially the folder the script is found in. * If you need to use the BlockTrampoline class in any other script, you will have to add 'using VSTutorial.Blocks' to that script. */ namespace VSTutorial.Blocks { /* * The class definition. Here, you define BlockTrampoline as a child of Block, which * means you can 'override' many of the functions within the general Block class. */ internal class BlockTrampoline : Block { public override void OnEntityCollide(IWorldAccessor world, Entity entity, BlockPos pos, BlockFacing facing, Vec3d collideSpeed, bool isImpact) { if (isImpact && facing.IsVertical) { entity.Pos.Motion.Y *= -0.8f; } } } } </syntaxhighlight> |} Give it a test! Falling onto your trampoline block should cause you to bounce! </div> <div lang="en" dir="ltr" class="mw-content-ltr"> == Finished Project == You can download the entire finished project from GitHub [https://github.com/Nateonus/vsmodexamples/raw/master/updated_code_mod_tutorials/zipped-tutorials/VSTutorial%20-%201%20-%20Simple%20Block%20Tutorial.zip here]. This is a full project setup that includes code comments on how everything works. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> == Conclusion == Congratulations, you've created, registered and tested a new block class! Although it's been a long tutorial, you've covered many topics here that will give you a great understanding of how coding for Vintage Story works. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> === Next Steps... === If you want to test your knowledge consider doing the tasks under the ''Going Further'' section below. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> When you're ready, take a look at the next tutorial. This will show you how to give extra functionality to an item. </div> <div lang="en" dir="ltr" class="mw-content-ltr"> == Going Further == Want to make some additional changes to this mod? Try and achieve the following things! </div> <div lang="en" dir="ltr" class="mw-content-ltr"> Make the trampoline super bouncy. {| class="wikitable mw-collapsible mw-collapsed" |To achieve this... |- |Replace the -0.8 value with -1.5 or lower. Although setting to -1 would technically reflect the motion perfectly, some velocity is lost on the frame the entity collides with the block. |} Change the functionality of the block to allow an entity to bounce on any side of the block. You should use ''facing.IsAxisNS'' and ''facing.IsAxisWE'' to determine what side the entity collides with. {| class="wikitable mw-collapsible mw-collapsed" |To achieve this... |- |You need to replace the contents of the ''OnEntityCollide'' function with something similar to the following:<syntaxhighlight lang="csharp"> if (isImpact && facing.IsVertical) { entity.Pos.Motion.Y *= -0.8f; } else if (facing.IsAxisNS) { entity.Pos.Motion.Z *= -1.2f; } else if (facing.IsAxisWE) { entity.Pos.Motion.X *= -1.2f; } </syntaxhighlight>Note that you will need to jump into the trampoline block to bounce off of it. |} </div> {{navbox/codemodding}}
Navigation
Navigation
Main page
Recent changes
Random page
VS related links
Website
Discord
Forum
Devlog
VS ModDB
Community portal
Noticeboard
Editing the wiki
Translating the wiki
Help about MediaWiki
Wiki tools
Wiki tools
Special pages
Page tools
Page tools
User page tools
More
Translate
Printable version