Advertisement
gnidmoo

Untitled

May 16th, 2020
1,829
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. mod:entity {
  2.     id = "item_drop",
  3.  
  4.     properties = {
  5.         visual = {
  6.             type = "inventorycube",
  7.             size = 0.25,
  8.             origin = {0.125, 0.125, 0.125},
  9.         },
  10.  
  11.         is_rotatable = true,
  12.  
  13.         animation = {
  14.             {
  15.                 type = "rotation",
  16.                 axis = {0, 0, 1},
  17.                 angle = 0.5
  18.             },
  19.             {
  20.                 type = "translation",
  21.                 delta = {0, 0, -0.0005},
  22.                 min = -0.2,
  23.                 max = 0,
  24.                 loop = true
  25.             }
  26.         },
  27.  
  28.         hitbox = {0, 0, 0, 0.25, 0.25, 0.25},
  29.     },
  30.  
  31.     on_spawn = function(entity, data)
  32.         entity:set_properties({
  33.             visual = {
  34.                 block_id = data.item_id,
  35.             },
  36.  
  37.             itemstack = {data.item_id, data.item_amount},
  38.         })
  39.  
  40.         entity:set_position(data.position[0], data.position[1], data.position[2])
  41.         entity:set_dimension(data.dimension)
  42.  
  43.         return true
  44.     end,
  45.  
  46.     on_collision = function(entity, other)
  47.         if other:type() == "player" then
  48.             other:inventory():add_item(entity:properties():itemstack())
  49.         end
  50.     end,
  51. }
  52.  
  53. openminer:add_listener(EventType.OnBlockDigged, function(pos, block, player, world, client, server)
  54.     openminer:spawn_entity("default:item_drop", {
  55.         position = {pos.x, pos.y, pos.z},
  56.         dimension = world:dimension():id(),
  57.  
  58.         item_id = block:string_id(),
  59.         item_amount = 1,
  60.     })
  61. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement