-
Notifications
You must be signed in to change notification settings - Fork 4
Creating a Fake Entity
iso2013 edited this page Apr 25, 2018
·
1 revision
To create a fake entity, we first need to obtain an IFakeEntityFactory from our IPacketEntityAPI instance:
IFakeEntityFactory factory = instance.getEntityFactory();
It doesn't matter if you cache this value or not because it's constant, but your code will be cleaner if you store it in a variable.
Then, you can simply pass the EntityType you want to the #createFakeEntity(EntityType) method. If you would like to populate a map of metadata values in the returned entity, also pass true
into the method.
Before you can send a spawn packet, you'll need to specify the location to spawn at using #setLocation(Location). You may also need to specify a few additional values using #setField(String, Object):
- If it is a painting, you must specify the
title
through the Bukkit Art enum that should be displayed. - If it is a painting or an item frame, you must specify the
direction
that the entity is facing in Bukkit BlockFace form. - If it is an experience orb, you must specify the
orbcount
(an integer) that represents the value of this orb. - If it is a projectile, you must specify an int
shooter
. - If it is a falling block, you must specify an
id
and adata
value. (Integer and byte, respectively.)
Additionally, if you would like to specify a velocity
, that should be in Vector form.