cn.nukkit.entity.passive.EntityWaterAnimal Java Examples
The following examples show how to use
cn.nukkit.entity.passive.EntityWaterAnimal.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityMinecartEmpty.java From Nukkit with GNU General Public License v3.0 | 6 votes |
@Override public boolean onUpdate(int currentTick) { boolean update = super.onUpdate(currentTick); if (this.passengers.isEmpty()) { for (Entity entity : this.level.getCollidingEntities(this.boundingBox.grow(0.20000000298023224, 0.0D, 0.20000000298023224), this)) { if (entity.riding != null || !(entity instanceof EntityLiving) || entity instanceof Player || entity instanceof EntityWaterAnimal) { continue; } this.mountEntity(entity); update = true; break; } } return update; }
Example #2
Source File: EntityBoat.java From Nukkit with GNU General Public License v3.0 | 4 votes |
@Override public boolean onUpdate(int currentTick) { if (this.closed) { return false; } int tickDiff = currentTick - this.lastUpdate; if (tickDiff <= 0 && !this.justCreated) { return true; } this.lastUpdate = currentTick; boolean hasUpdate = this.entityBaseTick(tickDiff); if (this.isAlive()) { super.onUpdate(currentTick); double waterDiff = getWaterLevel(); if (!hasControllingPassenger()) { if (waterDiff > SINKING_DEPTH && !sinking) { sinking = true; } else if (waterDiff < -SINKING_DEPTH && sinking) { sinking = false; } if (waterDiff < -SINKING_DEPTH) { this.motionY = Math.min(0.05, this.motionY + 0.005); } else if (waterDiff < 0 || !sinking) { this.motionY = this.motionY > SINKING_MAX_SPEED ? Math.max(this.motionY - 0.02, SINKING_MAX_SPEED) : this.motionY + SINKING_SPEED; // this.motionY = this.motionY + SINKING_SPEED > SINKING_MAX_SPEED ? this.motionY - SINKING_SPEED : this.motionY + SINKING_SPEED; } } if (this.checkObstruction(this.x, this.y, this.z)) { hasUpdate = true; } this.move(this.motionX, this.motionY, this.motionZ); double friction = 1 - this.getDrag(); if (this.onGround && (Math.abs(this.motionX) > 0.00001 || Math.abs(this.motionZ) > 0.00001)) { friction *= this.getLevel().getBlock(this.temporalVector.setComponents((int) Math.floor(this.x), (int) Math.floor(this.y - 1), (int) Math.floor(this.z) - 1)).getFrictionFactor(); } this.motionX *= friction; if (!hasControllingPassenger()) { if (waterDiff > SINKING_DEPTH || sinking) { this.motionY = waterDiff > 0.5 ? this.motionY - this.getGravity() : (this.motionY - SINKING_SPEED < -SINKING_MAX_SPEED ? this.motionY : this.motionY - SINKING_SPEED); } } this.motionZ *= friction; Location from = new Location(lastX, lastY, lastZ, lastYaw, lastPitch, level); Location to = new Location(this.x, this.y, this.z, this.yaw, this.pitch, level); this.getServer().getPluginManager().callEvent(new VehicleUpdateEvent(this)); if (!from.equals(to)) { this.getServer().getPluginManager().callEvent(new VehicleMoveEvent(this, from, to)); } //TODO: lily pad collision this.updateMovement(); if (this.passengers.size() < 2) { for (Entity entity : this.level.getCollidingEntities(this.boundingBox.grow(0.20000000298023224, 0.0D, 0.20000000298023224), this)) { if (entity.riding != null || !(entity instanceof EntityLiving) || entity instanceof Player || entity instanceof EntityWaterAnimal || isPassenger(entity)) { continue; } this.mountEntity(entity); if (this.passengers.size() >= 2) { break; } } } } return hasUpdate || !this.onGround || Math.abs(this.motionX) > 0.00001 || Math.abs(this.motionY) > 0.00001 || Math.abs(this.motionZ) > 0.00001; }