3 dofile(minetest.get_modpath("player_api") .. "/api.lua")
5 -- Default player appearance
6 player_api.register_model("character.b3d", {
8 textures = {"player.png", },
10 -- Standard animations.
11 stand = {x = 5, y = 5},
13 lay = {x = 162, y = 162},
14 walk = {x = 168, y = 187},
15 mine = {x = 189, y = 198},
16 run = {x = 189, y = 198},
17 walk_mine = {x = 200, y = 219},
18 run_mine = {x = 200, y = 219},
19 sit = {x = 81, y = 160},
20 sneak = {x = 60, y = 60},
21 sneak_mine_stand = {x=20,y=30},
22 sneak_walk= {x = 60, y = 80},
23 sneak_mine_walk= {x = 40, y = 59},
25 collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
30 -- Update appearance when the player joins
31 minetest.register_on_joinplayer(function(player)
32 player_api.player_attached[player:get_player_name()] = false
33 player_api.set_model(player, "character.b3d")
34 player:set_local_animation(
43 minetest.register_entity("player_api:item", {
44 initial_properties = {
47 collide_with_objects = false,
48 collisionbox = {0, 0, 0, 0, 0, 0},
50 visual_size = {x = 0.21, y = 0.21},
52 spritediv = {x = 1, y = 1},
53 initial_sprite_basepos = {x = 0, y = 0},
60 set_item = function(self, item)
61 local stack = ItemStack(item or self.itemstring)
63 self.itemstring = stack:to_string()
66 -- Backwards compatibility: old clients use the texture
67 -- to get the type of the item
68 local itemname = stack:is_known() and stack:get_name() or "unknown"
70 local max_count = stack:get_stack_max()
71 local count = math.min(stack:get_count(), max_count)
74 local coll_height = size * 0.75
75 local def = minetest.registered_nodes[itemname]
76 local glow = def and def.light_source
78 local is_visible = true
79 if self.itemstring == "" then
84 self.object:set_properties({
85 is_visible = is_visible,
87 textures = {itemname},
88 visual_size = {x = size, y = size},
89 collisionbox = {-size, -0.21, -size,
90 size, coll_height, size},
91 selectionbox = {-size, -size, -size, size, size, size},
92 --automatic_rotate = math.pi * 0.5 * 0.2 / size,
93 wield_item = self.itemstring,
98 on_step = function(self, dtime)
99 if not self.wielder then