Giter Site home page Giter Site logo

prismarine-entity's Introduction

prismarine-entity

NPM version Build Status

Represent a minecraft entity

Usage

const Entity = require("prismarine-entity")('1.8.9')

const entity = new Entity(0)
console.log(entity)

API

Entity

Entities represent players, mobs, and objects.

entity.id

entity.type

Choices:

  • player
  • mob
  • object
  • global - lightning
  • orb - experience orb.
  • other - introduced with a recent Minecraft update and not yet recognized or used by a third-party mod

entity.username

If the entity type is player, this field will be set.

entity.mobType

If the entity type is mob, this field will be set.

entity.displayName

Field set for mob and object. A long name in multiple words.

entity.entityType

Field set for mob and object. The numerical type of the entity (1,2,...)

entity.kind

Field set for mob and object. The kind of entity (for example Hostile mobs, Passive mobs, NPCs).

entity.name

Field set for mob and object. A short name for the entity.

entity.objectType

If the entity type is object, this field will be set.

entity.count

If the entity type is orb, this field will be how much experience you get from collecting the orb.

entity.position

entity.velocity

entity.yaw

entity.pitch

entity.height

entity.width

entity.onGround

entity.equipment[5]

Version dependent.

1.8 Layout:

  • 0 - held item
  • 1 - shoes
  • 2 - legging
  • 3 - torso
  • 4 - head

1.9 and later:

  • 0 - held item
  • 1 - off-hand
  • 2 - shoes
  • 3 - legging
  • 4 - torso
  • 5 - head

entity.heldItem

Equivalent to entity.equipment[0].

entity.metadata

See http://wiki.vg/Entities#Entity_Metadata_Format for more details.

entity.noClip

entity.vehicle

Entity that this entity is riding on

entity.passenger

Entity that is riding on this entity

entity.health

The health of the player, default: 20

entity.food

The food of the player, default: 20

entity.elytraFlying

Whether or not the entity is elytra flying.

entity.player

The player

entity.getCustomName()

returns a prismarine-chat ChatMessage object for the name of the entity or null if there isn't one

entity.getDroppedItem()

returns a prismarine-item Item object for the dropped item, if this is a dropped item, or it will return null

History

2.4.0

2.3.1

2.3.0

2.2.0

  • mcData to registry refactoring (step towards #2450)

2.1.1

  • Update mcdata

2.1.0

  • Adds Entity#getDroppedItem

2.0.0

  • require mcversion in constructor
  • add Entity#getCustomName()
  • Add attributes for entity entity collision calculation (thanks @O-of)

1.2.0

  • Add food saturation to typings
  • Add id to typings
  • Add effects to typings

1.1.0

  • Added entity width property

1.0.0

  • typescript definitions (thanks @IdanHo)

0.2.0

  • extend EventEmitter

0.1.0

  • Import from mineflayer

prismarine-entity's People

Contributors

chitasa avatar dependabot-preview[bot] avatar dependabot[bot] avatar epirito avatar extremeheat avatar icetank avatar idanho avatar karang avatar lkwilson avatar mat-1 avatar rom1504 avatar rom1504bot avatar sefirosweb avatar szdytom avatar thedudefromci avatar u9g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

prismarine-entity's Issues

Entity types do not correspond with documentation

Some entities types that are given to entities are not included in the documentation or typescript types.

For example when you run this code with a mineflayer bot:

let nearest = bot.nearestEntity((entity: any) => {
      console.log(entity.type);
});

There will be other types such as 'water_creature' or 'hostile' which isn't listed in the documentation or in the typescript types.

To reproduce

  1. Open a singleplayer world to lan in 1.19.3
  2. Create a mineflayer bot
  3. Run the aforementioned code

New types

It appears as though some of the new types are:

'animal',
'player',
'hostile',
'ambient',
'other',
'water_creature',
'orb'

There may be more, but from what I can tell this is all.

I got this information by running this code:

let types = new Set();

let nearest = bot.nearestEntity((entity: any) => {
    types.add(entity.type);
});

console.log(types)

I then put several different kind of entitles around the bot to try and see if there were any others.

If I missed something please let me know, thank you for anything is advance :)

Unclear documentation

Some of the documentation is unclear:

Is id the unique entity id, the numerical entity type id, or the entity name?

What's the difference between mobType, entityType and objectType?

What is player?

It's also unclear that position and velocity are Vec3s.

getDroppedItem may throw error on some entities

I used getDroppedItem on entities in the bots render distance and got this error once

TypeError: Cannot read properties of undefined (reading 'blockId')
     at Function.fromNotch (/home/pi/Documents/mineflayer-auto-shepherd/node_modules/prismarine-item/index.js:81:18)
     at Entity.getDroppedItem (/home/pi/Documents/mineflayer-auto-shepherd/node_modules/prismarine-entity/index.js:44:19)
     at /home/pi/Documents/mineflayer-auto-shepherd/dist/plugins/autoShepherd.js:27:98
     at Array.filter (<anonymous>)

The server is running on paper 1.12.2 and there should not be any weird entities around.
I don't know how to reproduce that error as it only happened once
The code calling the function looks like this

const droppedItems = Object.values(bot.entities).filter(e => {
  return e.name === 'item' && e.position.distanceTo(bot.entity.position) < 30 && e.getDroppedItem()?.name?.includes('wool')
})

Add headYaw property to entity

headYaw send by the 1.19 server in spawn_entity packets is currently not part off entity but is used to store a players rotation.

Check if entity is visible

I have to check if a given entity is visible.

My bot chases the invisible anti cheat fake players flying around him all the time.

I would love to see something like an entity.visible

Thank you!

Add specific entities to d.ts

Give the different ways that entities are named and categorized in Minecraft, it would be useful to have all entities listed in the autocomplete for the Typescript header. This would make entity validation a much smoother process.

Button bot lagging

I made a button bot for cannons and every time tnt goes of the bot lags and stops pressing the button
the code im using is

`async function holdCommand(message) {
keepPressing = true;
pressButton();
}

async function stopCommand(message) {
keepPressing = false;
}

async function pressButton() {
for (let i = 0; i < mcClients.length; i++) {
const button = mcClients[i].findBlock({ point: mcClients[i].entity.position, matching: 77, maxDistance: 1 });
if (button)
mcClients[i].activateBlock(button[0]);
}
if (keepPressing == true) {
setTimeout(pressButton, 10);
}
}`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.