Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
// DefaultModel is a Model for a default custom skin. It is a model with a 64x64 texture.
DefaultModel, _ = ReadModel(bytes.NewReader(defaultModel))
)
Functions ¶
func Create ¶
Create creates a new NPC with the Settings passed. A world.Loader is spawned in the background which follows the NPC to prevent it from despawning. Create panics if the world passed is nil. The HandlerFunc passed handles a player interacting with the NPC. Nil may be passed to avoid calling any function when the entity is interacted with. Create returns the *player.Player created. This entity has been added to the world passed. It may be removed from the world like any other entity by calling (*player.Player).Close.
Types ¶
type HandlerFunc ¶
HandlerFunc may be passed to Create to handle a *player.Player attacking an NPC.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is the model of a skin.Skin parsed with ParseModel or ReadModel.
func MustParseModel ¶
MustParseModel parses a Model from a JSON file at a specific path. It panics if the file could not be opened or if the JSON contained was invalid or not a proper model.
func ParseModel ¶
ParseModel parses a Model from a JSON file at a specific path. An error is returned if the file could not be opened or if the JSON contained was invalid or not a proper model.
type Settings ¶
type Settings struct { Name string Skin skin.Skin Position mgl64.Vec3 Yaw, Pitch float64 Scale float64 Immobile bool Vulnerable bool MainHand, OffHand, Helmet, Chestplate, Leggings, Boots item.Stack }
Settings holds different NPC settings such as the NPC's name, skin, position, etc. These values may be changed at runtime by calling the respective methods on the *player.Player returned by Create, the values passed in a Settings struct to Create are merely the initial values.
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture is the texture of a skin.Skin parsed with ParseTexture or ReadTexture.
func MustParseTexture ¶
MustParseTexture parses a Texture from an image file at a specific path. It panics if the file could not be opened or if it did not contain a valid skin image.
func ParseTexture ¶
ParseTexture parses a Texture from an image file at a specific path. An error is returned if the file could not be opened or if it did not contain a valid skin image.