Documentation ¶
Index ¶
- func IsObject(etype Type) bool
- type Attributes
- type Base
- func (b *Base) ApplyVelocity()
- func (b *Base) BlockPos() block.Pos
- func (b *Base) Collide(info *CollisionInfo)
- func (b *Base) EID() uint32
- func (b *Base) GetLiving() (*Living, bool)
- func (b *Base) Height() float64
- func (b *Base) Hit(other Entity)
- func (b *Base) Metadata() *metadata.Metadata
- func (b *Base) NeedsPosUpdate() bool
- func (b *Base) NeedsVelUpdate() bool
- func (b *Base) NewX() float64
- func (b *Base) NewY() float64
- func (b *Base) NewZ() float64
- func (b *Base) SetNewPosition(x, y, z float64)
- func (b *Base) SetVelocity(x, y, z int16)
- func (b *Base) Tick()
- func (b *Base) Time() int
- func (b *Base) Vx() int16
- func (b *Base) Vy() int16
- func (b *Base) Vz() int16
- func (b *Base) Width() float64
- func (b *Base) X() float64
- func (b *Base) Y() float64
- func (b *Base) Z() float64
- type CollisionInfo
- type Entity
- type Living
- type LivingBase
- type Object
- type StructuredEntityMetadata
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attributes ¶
type Attributes struct { CanFly bool Hostile bool Data int // contains filtered or unexported fields }
func (Attributes) Merge ¶
func (a Attributes) Merge(other Attributes) Attributes
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
func (*Base) ApplyVelocity ¶
func (b *Base) ApplyVelocity()
This sets the new position of the entity to be it's current position plus it's velocity. This should be called at the end of Tick(), if you are making custom entity AI.
Once Tick() has exited, if needs_pos_update is true, Collide will be called. If the position is valid, then position packets will be sent.
func (*Base) Collide ¶
func (b *Base) Collide(info *CollisionInfo)
Used internally once world collision is finished. Should never be called.
func (*Base) NeedsPosUpdate ¶
func (*Base) NeedsVelUpdate ¶
func (*Base) SetNewPosition ¶
This will trigger collision detection next tick, and verify this position at that time. This should be called if you want to move an entity (not a player, call Teleport for players).
func (*Base) SetVelocity ¶
This sets the entity's velocity. This does not ensure that any packets will be sent, as ApplyVelocity() still must be called.
func (*Base) Tick ¶
func (b *Base) Tick()
This does basic things, such as apply gravity to the velocity, and set needs_pos_update if the velocity is non zero. This should be called before anything else happens in a custom Tick() function.
type CollisionInfo ¶
type CollisionInfo struct { // Set to true if the hitbox has collided with any face DidCollide bool // this is the position that the entity should be at, so that they are not inside a block NewX, NewY, NewZ float64 // hit values for all directions. Used to set velocity to 0 if they were moving in that direciton // HitNY is essentially if they are on the ground HitPX, HitPY, HitPZ, HitNX, HitNY, HitNZ bool }
type Entity ¶
type Entity interface { // Used internally to see if the entity's position changed last tick NeedsPosUpdate() bool // Getter for position. Only updated after calling Tick() X() float64 Y() float64 Z() float64 // Getter for next position. Calculated on the spot, and is the position + velocity NewX() float64 NewY() float64 NewZ() float64 // Block getter. Finds the negative coordinate correctly. BlockPos() block.Pos // Hitbox size Width() float64 Height() float64 // Used internally for knockback, and entity velocity in general Vx() int16 Vy() int16 Vz() int16 // Entity's id in the world. Is a counter that starts from 1 EID() uint32 // Used for knockback. This might also trigger collision next tick, because of the subsequent position change. // If you are clearing the velicty, then it will not cause collision to occur. SetVelocity(x, y, z int16) // Will set the position fields, and trigger collision detection on the next tick. // Will also send position packets if the move was valid. Do not call this for players! Call Teleport for players. SetNewPosition(x, y, z float64) // Called when this entity gets punched by another entity. Hit(other Entity) // Called whenever the entity hits a block. Can be overriden to make bouncy snowballs, for example. Collide(info *CollisionInfo) // This will get a pointer to a living struct, if this is a living entity. // Used for combat, as all living entities have health/armor GetLiving() (*Living, bool) // Called internally whenever a game tick occurs. Do not call this function, unless you know what you are doing. // The main thing that will happen when you call this is that the position will be updated to whatever the New position is, // and velocity will be applied. This will also trigger pathfinding (if there is any). // It will basically speed up the entity if you call this. So don't call it Tick() // This gets a pointer to the metadata for this entity. It can be edited with Write(), // and will be marked dirty each time you update it. Metadata() *metadata.Metadata // Returns the number of ticks since this entity spawned. Used internally for timers, and attack damage // calculations. This is safe to call. Time() int }
type LivingBase ¶
type LivingBase struct { Base // contains filtered or unexported fields }
func NewLivingBase ¶
func NewLivingBase(attr Attributes, etype Type, eid uint32, uuid util.UUID, x, y, z float64, pitch, yaw, head_pitch byte, vx, vy, vz int16) *LivingBase
func (*LivingBase) Damage ¶
func (l *LivingBase) Damage(amount float32)
func (*LivingBase) Health ¶
func (l *LivingBase) Health() float32
func (*LivingBase) ImmuneToAttacks ¶
func (l *LivingBase) ImmuneToAttacks() bool
This returns true if the entity was attacked within half second
func (*LivingBase) SetHealth ¶
func (l *LivingBase) SetHealth(val float32)
func (*LivingBase) Tick ¶
func (l *LivingBase) Tick()
type StructuredEntityMetadata ¶
type StructuredEntityMetadata struct {
// contains filtered or unexported fields
}
type Type ¶
type Type int32
Entity type. Should be used by value. This understands what type it inherits from, and how to format entity metadata. It also knows what version it was added, and the versions that it's various fields were added. Whenever you need to reference an entity by type, you should use this type.
const ( Type_AreaEffectCloud Type = iota Type_ArmorStand Type_Arrow Type_Bat Type_Bee Type_Blaze Type_Boat Type_Cat Type_CaveSpider Type_Chicken Type_Cod Type_Cow Type_Creeper Type_Donkey Type_Dolphin Type_DragonFireball Type_Drowned Type_ElderGuardian Type_EndCrystal Type_EnderDragon Type_Enderman Type_Endermite Type_EvokerFangs Type_Evoker Type_ExpOrb Type_EyeOfEnder Type_FallingBlock Type_FireworkRocket Type_Fox Type_Ghast Type_Giant Type_Guardian Type_Horse Type_Husk Type_Illusioner Type_Item Type_ItemFrame Type_Fireball Type_LeashKnot Type_Llama Type_LlamaSpit Type_MagmaCube Type_Minecart Type_ChestMinecart Type_CommandMinecart Type_FurnaceMinecart Type_HopperMinecart Type_SpawnerMinecart Type_TntMinecart Type_Mule Type_Mooshroom Type_Ocelot Type_Painting Type_Panda Type_Parrot Type_Pig Type_Pufferfish Type_ZombiePigman Type_PolarBear Type_PrimedTNT Type_Rabbit Type_Salmon Type_Sheep Type_Shulker Type_ShulkerBullet Type_Silverfish Type_Skeleton Type_SkeletonHorse Type_Slime Type_SmallFireball Type_SnowGolem Type_Snowball Type_SpectralArrow Type_Spider Type_Squid Type_Stray Type_TraderLlama Type_TropicalFish Type_Turtle Type_ThrownEgg Type_ThrownEnderPearl Type_ThrownExpBottle Type_ThrownPotion Type_Trident Type_Vex Type_Villager Type_IronGolem Type_Vindicator Type_Pillager Type_WanderingTrader Type_Witch Type_Wither Type_WitherSkeleton Type_WitherSkull Type_Wolf Type_Zombie Type_ZombieHorse Type_ZombieVillager Type_Phantom Type_Ravager Type_LightningBolt Type_Player Type_FishingBobber )