@Override public void attack(EntityDamageEvent source) { super.attack(source); if (source.isCancelled()) return; if (source instanceof EntityDamageByEntityEvent) { Entity damager = ((EntityDamageByEntityEvent) source).getDamager(); if (damager instanceof Player) { if (((Player) damager).isCreative()) { this.kill(); } if (this.getHealth() <= 0) { if (((Player) damager).isSurvival()) { this.level.dropItem(this, new ItemBoat()); } this.close(); } } } EntityEventPacket pk = new EntityEventPacket(); pk.eid = this.getId(); pk.event = this.getHealth() <= 0 ? EntityEventPacket.DEATH_ANIMATION : EntityEventPacket.HURT_ANIMATION; Server.broadcastPacket(this.hasSpawned.values(), pk); }
@Override protected void initEntity() { super.initEntity(); this.dataProperties.putByte(DATA_WOOD_ID, this.namedTag.getByte("woodID")); this.setHealth(4); this.setMaxHealth(4); }
@Override public void close() { super.close(); if (this.linkedEntity instanceof Player) { this.linkedEntity.riding = null; } SmokeParticle particle = new SmokeParticle(this); this.level.addParticle(particle); }
@Override public void spawnTo(Player player) { AddEntityPacket pk = new AddEntityPacket(); pk.eid = this.getId(); pk.type = EntityBoat.NETWORK_ID; pk.x = (float) this.x; pk.y = (float) this.y; pk.z = (float) this.z; pk.speedX = 0; pk.speedY = 0; pk.speedZ = 0; pk.yaw = (float) this.yaw; pk.pitch = (float) this.pitch; pk.metadata = this.dataProperties; player.dataPacket(pk); super.spawnTo(player); }