]> git.lizzy.rs Git - dragonblocks.git/commitdiff
Added dragonblocks.handleNodeDrop 3/head
authorElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 24 Jun 2020 10:46:37 +0000 (12:46 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Wed, 24 Jun 2020 10:46:37 +0000 (12:46 +0200)
engine/item_entity.js
engine/map_interaction.js

index d73677329f4074e2270dda8885ababee65ae3271..2e790c376e399ae41eca00c25173883be9e10e2d 100644 (file)
@@ -26,10 +26,14 @@ dragonblocks.registerEntity({
        width: 0.4,
        height: 0.4,
        gravity: true,
+       verticalSpeed: 2,
        onpunch: self => {
                dragonblocks.dropItem(dragonblocks.player.give(self.meta.itemstring), self.x, self.y);
                self.despawn();
-       }
+       },
+       oncollide: self => {
+               self.jump();
+       },
 });
 
 dragonblocks.dropItem = function(itemstack, x, y) {
index a2e200f643c008a3a9bacf1809a4367ee5a8569a..3f2023a50e0fdee3b650525f9e4edf427a4c4cb4 100644 (file)
@@ -102,12 +102,8 @@ dragonblocks.MapIntercation = {
                if(! mapNode)
                        return;
                let node = mapNode.toNode();
-               if(this.dig(x, y)){
-                       if(node.drops instanceof Function)
-                               this.tmp.mainInventory.add(node.drops());
-                       else
-                               this.tmp.mainInventory.add(node.drops);
-               }
+               if (this.dig(x, y))
+                       dragonblocks.handleNodeDrop(this.tmp.mainInventory, node, x, y);
                document.getElementById("dragonblocks.crack[" + this.id + "]").style.visibility = "hidden";
        },
        digStop(){
@@ -158,3 +154,7 @@ dragonblocks.MapIntercation = {
                return (Math.sqrt(Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2)) <= this.tool.range) || this.meta.creative;
        },
 } 
+
+dragonblocks.handleNodeDrop = function(inventory, node, x, y) {
+       dragonblocks.dropItem(inventory.add((node.drops instanceof Function) ? node.drops() : node.drops), x + 0.2, y + 0.2);
+}