prismarine-entity 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/index.d.ts +2 -0
- package/index.js +9 -0
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ Represent a minecraft entity
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
9
|
```js
|
|
10
|
-
const Entity = require("prismarine-entity")
|
|
10
|
+
const Entity = require("prismarine-entity")('1.8.9')
|
|
11
11
|
|
|
12
12
|
const entity = new Entity(0)
|
|
13
13
|
console.log(entity)
|
|
@@ -118,8 +118,26 @@ The food of the player, default: 20
|
|
|
118
118
|
|
|
119
119
|
The player
|
|
120
120
|
|
|
121
|
+
#### entity.getCustomName()
|
|
122
|
+
|
|
123
|
+
returns a `prismarine-chat` ChatMessage object for the name of the entity or null if there isn't one
|
|
124
|
+
|
|
125
|
+
#### entity.getDroppedItem()
|
|
126
|
+
|
|
127
|
+
returns a `prismarine-item` Item object for the dropped item, if this is a dropped item, or it will return null
|
|
128
|
+
|
|
121
129
|
## History
|
|
122
130
|
|
|
131
|
+
### 2.1.0
|
|
132
|
+
|
|
133
|
+
* Adds Entity#getDroppedItem
|
|
134
|
+
|
|
135
|
+
### 2.0.0
|
|
136
|
+
|
|
137
|
+
* require mcversion in constructor
|
|
138
|
+
* add Entity#getCustomName()
|
|
139
|
+
* Add attributes for entity entity collision calculation (thanks @O-of)
|
|
140
|
+
|
|
123
141
|
### 1.2.0
|
|
124
142
|
|
|
125
143
|
* Add food saturation to typings
|
package/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare module 'prismarine-entity' {
|
|
|
18
18
|
constructor(id: number);
|
|
19
19
|
id: number;
|
|
20
20
|
type: EntityType;
|
|
21
|
+
uuid?: string;
|
|
21
22
|
username?: string;
|
|
22
23
|
mobType?: string;
|
|
23
24
|
displayName?: string;
|
|
@@ -44,6 +45,7 @@ declare module 'prismarine-entity' {
|
|
|
44
45
|
effects: Effect[];
|
|
45
46
|
setEquipment(index: number, item: Item): void;
|
|
46
47
|
getCustomName(): ChatMessage | null;
|
|
48
|
+
getDroppedItem(): Item | null;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
export type EntityType = 'player' | 'mob' | 'object' | 'global' | 'orb' | 'other';
|
package/index.js
CHANGED
|
@@ -3,6 +3,8 @@ const EventEmitter = require('events').EventEmitter
|
|
|
3
3
|
|
|
4
4
|
module.exports = (version) => {
|
|
5
5
|
const ChatMessage = require('prismarine-chat')(version)
|
|
6
|
+
const Item = require('prismarine-item')(version)
|
|
7
|
+
const mcData = require('minecraft-data')(version)
|
|
6
8
|
class Entity extends EventEmitter {
|
|
7
9
|
constructor (id) {
|
|
8
10
|
super()
|
|
@@ -34,6 +36,13 @@ module.exports = (version) => {
|
|
|
34
36
|
}
|
|
35
37
|
return ChatMessage.fromNotch(name)
|
|
36
38
|
}
|
|
39
|
+
|
|
40
|
+
getDroppedItem () {
|
|
41
|
+
if (this.name !== 'item' && this.name !== 'Item' && this.name !== 'item_stack') {
|
|
42
|
+
return null // not a dropped item
|
|
43
|
+
}
|
|
44
|
+
return Item.fromNotch(this.metadata[mcData.supportFeature('metadataIxOfItem')])
|
|
45
|
+
}
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
return Entity
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prismarine-entity",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Represent a minecraft entity",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -13,8 +13,10 @@
|
|
|
13
13
|
"url": "https://github.com/PrismarineJS/prismarine-entity.git"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"
|
|
17
|
-
"prismarine-chat": "^1.4.1"
|
|
16
|
+
"minecraft-data": "^2.114.1",
|
|
17
|
+
"prismarine-chat": "^1.4.1",
|
|
18
|
+
"prismarine-item": "^1.11.2",
|
|
19
|
+
"vec3": "^0.1.4"
|
|
18
20
|
},
|
|
19
21
|
"keywords": [
|
|
20
22
|
"minecraft",
|
|
@@ -28,8 +30,7 @@
|
|
|
28
30
|
},
|
|
29
31
|
"devDependencies": {
|
|
30
32
|
"@types/node": "^17.0.4",
|
|
31
|
-
"prismarine-
|
|
32
|
-
"standard": "^16.0.1"
|
|
33
|
-
"prismarine-entity": "file:."
|
|
33
|
+
"prismarine-entity": "file:.",
|
|
34
|
+
"standard": "^16.0.1"
|
|
34
35
|
}
|
|
35
36
|
}
|