Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prismarine-block

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prismarine-block - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

.circleci/config.yml

16

example.js

@@ -1,11 +0,17 @@

var Block=require("./")("1.8");
const Block = require('./')('1.8')
var stoneBlock=new Block(1,1,0);
const stoneBlock = new Block(1, 1, 0)
console.log(stoneBlock);
console.log(stoneBlock)
// can you harvest stone with an iron pickaxe ?
console.log(stoneBlock.canHarvest(257));
console.log(stoneBlock.canHarvest(257))
// how many milliseconds does it takes in usual conditions ? (on ground, not in water and not in creative mode)
console.log(stoneBlock.digTime(257));
console.log(stoneBlock.digTime(257))
const BlockNew = require('./')('1.13.2')
const redstoneBlock = BlockNew.fromStateId(3381, 0)
console.log(redstoneBlock)

@@ -1,74 +0,79 @@

module.exports = loader;
module.exports = loader
function loader(mcVersion)
{
var mcData=require('minecraft-data')(mcVersion);
Biome = require('prismarine-biome')(mcVersion);
blocks=mcData.blocks;
toolMultipliers = mcData.materials;
return Block;
function loader (mcVersion) {
const mcData = require('minecraft-data')(mcVersion)
Biome = require('prismarine-biome')(mcVersion)
blocks = mcData.blocks
blocksByStateId = mcData.blocksByStateId
toolMultipliers = mcData.materials
return Block
}
var Biome;
var blocks;
var toolMultipliers;
let Biome
let blocks
let blocksByStateId
let toolMultipliers
Block.fromStateId = function (stateId, biomeId) {
return new Block(undefined, biomeId, 0, stateId)
}
function Block(type, biomeId, metadata) {
this.type = type;
this.metadata = metadata;
this.light = 0;
this.skyLight = 0;
this.biome = new Biome(biomeId);
this.position = null;
function Block (type, biomeId, metadata, stateId) {
this.type = type
this.metadata = metadata
this.light = 0
this.skyLight = 0
this.biome = new Biome(biomeId)
this.position = null
this.stateId = stateId
var blockEnum = blocks[type];
if(blockEnum) {
this.name = blockEnum.name;
this.hardness = blockEnum.hardness;
this.displayName = blockEnum.displayName;
if("variations" in blockEnum)
for(var i in blockEnum["variations"]) {
if(blockEnum["variations"][i].metadata === metadata)
this.displayName = blockEnum["variations"][i].displayName;
}
this.boundingBox = blockEnum.boundingBox;
this.diggable = blockEnum.diggable;
this.material = blockEnum.material;
this.harvestTools = blockEnum.harvestTools;
this.drops = blockEnum.drops;
const blockEnum = stateId === undefined ? blocks[type] : blocksByStateId[stateId]
if (blockEnum) {
this.type = blockEnum.id
this.name = blockEnum.name
this.hardness = blockEnum.hardness
this.displayName = blockEnum.displayName
if ('variations' in blockEnum) {
Object.keys(blockEnum['variations']).forEach(i => {
if (blockEnum['variations'][i].metadata === metadata) { this.displayName = blockEnum['variations'][i].displayName }
})
}
this.boundingBox = blockEnum.boundingBox
this.diggable = blockEnum.diggable
this.material = blockEnum.material
this.harvestTools = blockEnum.harvestTools
this.drops = blockEnum.drops
} else {
this.name = "";
this.displayName = "";
this.hardness = 0;
this.boundingBox = "empty";
this.diggable = false;
this.name = ''
this.displayName = ''
this.hardness = 0
this.boundingBox = 'empty'
this.diggable = false
}
}
Block.prototype.canHarvest = function(heldItemType) {
if(this.harvestTools) {
var penalty = heldItemType === null || !this.harvestTools[heldItemType];
if(penalty) return false;
Block.prototype.canHarvest = function (heldItemType) {
if (this.harvestTools) {
const penalty = heldItemType === null || !this.harvestTools[heldItemType]
if (penalty) return false
}
return true;
};
return true
}
// http://minecraft.gamepedia.com/Breaking#Speed
Block.prototype.digTime = function(heldItemType,creative, inWater, notOnGround) {
if(creative) return 0;
var time = 1000 * this.hardness * 1.5;
Block.prototype.digTime = function (heldItemType, creative, inWater, notOnGround) {
if (creative) return 0
let time = 1000 * this.hardness * 1.5
if(!this.canHarvest(heldItemType))
return time * 10 / 3;
if (!this.canHarvest(heldItemType)) { return time * 10 / 3 }
// If the tool helps, then it increases digging speed by a constant multiplier
var toolMultiplier = toolMultipliers[this.material];
if(toolMultiplier && heldItemType) {
var multiplier = toolMultiplier[heldItemType];
if(multiplier) time /= multiplier;
const toolMultiplier = toolMultipliers[this.material]
if (toolMultiplier && heldItemType) {
const multiplier = toolMultiplier[heldItemType]
if (multiplier) time /= multiplier
}
if(notOnGround) time *= 5;
if(inWater) time *= 5;
return time;
};
if (notOnGround) time *= 5
if (inWater) time *= 5
return time
}
{
"name": "prismarine-block",
"version": "1.0.1",
"version": "1.1.0",
"description": "Represent a minecraft block with its associated data",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npm run lint",
"lint": "standard"
},

@@ -14,9 +15,10 @@ "repository": {

"dependencies": {
"prismarine-biome":"^1.0.0"
"prismarine-biome": "^1.0.0"
},
"peerDependencies": {
"minecraft-data":"^2.0.0"
"minecraft-data": "^2.0.0"
},
"devDependencies": {
"minecraft-data":"^2.0.0"
"minecraft-data": "^2.35.0",
"standard": "^11.0.1"
},

@@ -23,0 +25,0 @@ "keywords": [

# prismarine-block
[![NPM version](https://img.shields.io/npm/v/prismarine-block.svg)](http://npmjs.com/package/prismarine-block)
[![Build Status](https://circleci.com/gh/PrismarineJS/prismarine-block/tree/master.svg?style=shield)](https://circleci.com/gh/PrismarineJS/prismarine-block/tree/master)

@@ -9,5 +10,5 @@ Represent a minecraft block with its associated data

```js
var Block=require("prismarine-block")("1.8");
const Block=require("prismarine-block")("1.8");
var stoneBlock=new Block(1,1,0);
const stoneBlock=new Block(1,1,0);

@@ -28,2 +29,4 @@ console.log(stoneBlock);

#### Block.fromStateId(stateId, biomeId)
#### Block(type,biomeId,metadata)

@@ -120,2 +123,6 @@

### 1.1.0
* add block state id feature (for >= 1.13)
### 1.0.1

@@ -122,0 +129,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc