Adding new board - Craluminum-Mods/TabletopGames GitHub Wiki
Read this first to understand how types work.
Create json file of your board, then add folllowing classes:
"class": "TabletopGames.BlockBoard",
"entityClass": "TabletopGames.Board"To setup custom shape, textures, name and description, read this.
In entityBehaviors: [ ] (add one if there is none), add the following behavior:
If your board needs extra non-interactable selection, add extraSelectionBoxes property to TabletopGames.BoardSelection in entityBehaviors:
{
"name": "TabletopGames.BoardSelection",
"properties": {
"extraSelectionBoxes": {
"*": [
// selection boxes you get from .bsedit
]
}
}
}In order to make our block visible in creative inventory and handbook, we need to add the following in creativeinventoryStacks: [ ] (add one if there is none):
{
"tabs": ["general", "decorative"],
"stacks": [
// note, that you can as many types in attributes as you want
// using size as a type here is just arbitrary
{ "type": "block", "code": "myboardname", "attributes": { "types": { "size": "8x8" } } }
]
}In behaviors: [ ] (add one if there is none), add the following behaviors:
{ "name": "BlockEntityInteract" },
{
"name": "TabletopGames.BoardData",
"properties": {
"boardData": { }
}
},
{
"name": "TabletopGames.BoardTags",
"properties": {
"tabletopTags": { }
}
}Properties of BoardData and BoardTags are empty for now, we will setup them in the next examples.
In order to make our board functional, we need to initialize some of the properties.
For example, if your board is 8x8, you need to do the following in TabletopGames.BoardData behavior:
{
"name": "TabletopGames.BoardData",
"properties": {
"boardData": {
"size-8x8": {
"quantitySlots": 64,
"size": { "x": 8, "y": 8 },
// the height of the board for correct piece placement
"slotYRange": { "x": 0, "y": 0.5 },
// used to set piece placement on the board with .tfedit
"attributeTransformCode": "onMyBoardTransform"
}
}
}
}To setup custom hitboxes for each slot, use slotsHitBoxes property:
{
"name": "TabletopGames.BoardData",
"properties": {
"boardData": {
"size-8x8": {
// note, that slotYRange and size won't work in this case
"quantitySlots": 64,
"attributeTransformCode": "onMyBoardTransform",
"slotsHitBoxes": [
// you need to do something like that for all 64 slots in this case
// { "x1": 0.8941, "y1": 0, "z1": 0.7659, "x2": 0.956, "y2": 0.0313, "z2": 0.825 },
// { "x1": 0.8941, "y1": 0, "z1": 0.7068, "x2": 0.956, "y2": 0.0313, "z2": 0.7659 },
// { "x1": 0.8941, "y1": 0, "z1": 0.6477, "x2": 0.956, "y2": 0.0313, "z2": 0.7068 },
// { "x1": 0.8941, "y1": 0, "z1": 0.5886, "x2": 0.956, "y2": 0.0313, "z2": 0.6477 }
// ..
]
}
}
}
}You can also limit how pieces behave in each slot with slotTypes property.
There are two slot types to choose from:
-
Normal: default behavior -
Random: used for dice to trigger theirrollbehavior.
For example, to make first and last slot random, do the following:
"slotTypes": {
"0": "Random", // slot 1
"63": "Random", // slot 64
"*": "Normal"
}Note, that you can also use regex instead of plain numbers, like here
For more examples on slotsHitBoxes and slotTypes, see backgammon board's json as example.
In order to be able to place any pieces, we need to fill boardTags property in TabletopGames.BoardTags behavior.
For example, to make first and last slot accept dice and rest of the slots to accept pieces suitable for backgammon, do the following:
{
"name": "TabletopGames.BoardTags",
"properties": {
"tabletopTags": {
"size-8x8": {
"tagsPerSlot": {
"0": ["dice"],
"63": ["dice"],
"*": ["backgammon"]
}
}
}
}
}Note, that you can also use regex instead of plain numbers, like here
{ "name": "TabletopGames.BoardSelection" }, { "name": "TabletopGames.BoardInteractions" }, { "name": "TabletopGames.BoardPreviewRenderer" } // adds 3D preview for held piece