use of org.bukkit.event.entity.EntityPortalExitEvent in project Glowstone by GlowstoneMC.
the class GlowEntity method pulse.
/**
* Called every game cycle. Subclasses should implement this to implement
* periodic functionality e.g. mob AI.
*/
public void pulse() {
ticksLived++;
if (!getLocation().getChunk().isLoaded()) {
return;
}
if (fireTicks > 0) {
--fireTicks;
}
metadata.setBit(MetadataIndex.STATUS, StatusFlags.ON_FIRE, fireTicks > 0);
// resend position if it's been a while, causes ItemFrames to disappear.
if (ticksLived % (30 * 20) == 0) {
if (!(this instanceof GlowItemFrame)) {
teleported = true;
}
}
if (this instanceof GlowLivingEntity && !isDead() && ((GlowLivingEntity) this).hasAI() && this.getLocation().getChunk().isLoaded()) {
GlowLivingEntity entity = (GlowLivingEntity) this;
entity.getTaskManager().pulse();
}
pulsePhysics();
if (hasMoved()) {
Block currentBlock = location.getBlock();
if (currentBlock.getType() == Material.ENDER_PORTAL) {
EventFactory.callEvent(new EntityPortalEnterEvent(this, currentBlock.getLocation()));
if (server.getAllowEnd()) {
Location previousLocation = location.clone();
boolean success;
if (getWorld().getEnvironment() == Environment.THE_END) {
success = teleportToSpawn();
} else {
success = teleportToEnd();
}
if (success) {
EntityPortalExitEvent e = EventFactory.callEvent(new EntityPortalExitEvent(this, previousLocation, location.clone(), velocity.clone(), new Vector()));
if (!e.getAfter().equals(velocity)) {
setVelocity(e.getAfter());
}
}
}
}
}
}
Aggregations