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) {
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(){
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);
+}