NPCs
BlablaLib implements a custom NPC System and Entity.
To create your NPC Entity just use the /summon command :
/summon blablalib:npc ~ ~ ~ {Definition:"my_mod_id:my_custom_npc_definition"}
But wait, what is a NPC Definition ?
NPC Definitions
NPC Definition are a way to describe your NPCs. They should look like this :
{
"name(1)": "Bob",
"variables(2)": [
{
"type(3)": "bool",
"name(4)": "has_said_hello",
"default_value": false
}
],
"root_state(5)" : "idle",
"states": [
{
"state_name": "idle",
"dialogue(6)" : "blablalib:test_npc_first_dialogue",
"visual_state(7)": {
"model(8)": "blablalib:geometry.npc",
"texture": "blablalib:textures/entity/npc/default.png",
"animation": "idle"
},
"transitions(9)": [
{
"target_state(10)": "has_said_hello",
"condition": {
"type(11)": "blablalib:equals",
"variable" : "has_said_hello",
"value" : true
}
}
]
},
{
"state_name": "has_said_hello",
"dialogue" : "blablalib:test_npc_said_hello",
"visual_state": {
"model": "blablalib:geometry.npc",
"texture": "blablalib:textures/entity/npc/default.png",
"animation": "talk"
},
"transitions": [
]
}
]
}
- The name that will be displayed above your NPC's head
- Here you can define the different variables of your NPC
- Here is a complete list of variable type
- This is the name of the variable, you will use this name to reference the variable and getting or setting it's value
- The default state of your NPC
- The dialogue that will be played if the NPC is in that state
- The Visual State describre the physical appearance of your NPC
- The Model of your NPC must be a model defined inside of your ressource pack :
assets/<my_mod_id>/npc_models/my_model.geo.jsonYou use the model ID defined inside of the file to refenrce your model - Here you can define the different transition this state will be able to do.
- The target state of the transition
- The type of the condition. Here for more info.
Variable Types
Currently there are 4 variable types :
Boolean
Type Name : bool
Values : true or false
Number
Type Name : number
Values : any numerical values (integer or decimal)
String
Type name : string
Values : any text
Resource Location
Type name : resource_location
Values : a valid Resource Location
Transition Conditions
To transition from different states, you must use conditions
Here is a list of the different conditions :
Equal Condition
This condition verifies if the variable and the value you defined are the same.
Numerical Conditions
There are 4 Numerical Conditions : Less, Less than or Equal, Greater, Greater than of Equal
- Can be
"blablalib:less_than_or_equal","blablalib:less","blablalib:greater","blablalib:greater_than_or_equal"
Is In Dialogue Condition
This condition verifies if the player is currently in a dialogue
Not Condition
The condition verifies if the inner condition is false.
And / Or Condition
Verifies if the different inner conditions are all true for the And Condition or just one is true for the Or Condition.
"condition":
{
"type(1)": "blablalib:and",
"conditions" : [
{
"type" : "blablalib:is_in_dialogue"
},
{
"type" : "blablalib:equals",
"variable" : "my_variable"
"value" : "Bob"
}
]
}
- Can be
blablalib:andorblablalib:or
XOR Condition
This condition verifies that only one of the two inner conditions is true.
"condition":
{
"type(1)": "blablalib:xor",
"conditions" : [
{
"type" : "blablalib:is_in_dialogue"
},
{
"type" : "blablalib:equals",
"variable" : "my_variable"
"value" : "Bob"
}
]
}
Count Condition
This condition verifies that a minimum amount of inner conditions are true
"condition":
{
"type": "blablalib:count",
"required_amount" : 2,
"conditions" : [
{
"type" : "blablalib:is_in_dialogue"
},
{
"type" : "blablalib:equals",
"variable" : "my_variable"
"value" : "Bob"
},
{
"type" : "blablalib:greater",
"variable" : "my_other_variable"
"value" : 5
}
]
}
Random Condition
This condition generates a random number in the range 0 to 1 and checks wether it is greater than the chance value.
Quest Condition (requires QuestsLib)
Checks wheter a Quest or Task is in the specific State