Search in sources :

Example 1 with BoatPaddleStateC2SPacket

use of net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket in project wildmod by Osmiooo.

the class MangroveBoatEntity method tick.

public void tick() {
    this.lastLocation = this.location;
    this.location = this.checkLocation();
    if (this.location != MangroveBoatEntity.Location.UNDER_WATER && this.location != MangroveBoatEntity.Location.UNDER_FLOWING_WATER) {
        this.ticksUnderwater = 0.0F;
    } else {
        ++this.ticksUnderwater;
    }
    if (!this.world.isClient && this.ticksUnderwater >= 60.0F) {
        this.removeAllPassengers();
    }
    if (this.getDamageWobbleTicks() > 0) {
        this.setDamageWobbleTicks(this.getDamageWobbleTicks() - 1);
    }
    if (this.getDamageWobbleStrength() > 0.0F) {
        this.setDamageWobbleStrength(this.getDamageWobbleStrength() - 1.0F);
    }
    super.tick();
    this.method_7555();
    if (this.isLogicalSideForUpdatingMovement()) {
        if (!(this.getFirstPassenger() instanceof PlayerEntity)) {
            this.setPaddleMovings(false, false);
        }
        this.updateVelocity();
        if (this.world.isClient) {
            this.updatePaddles();
            this.world.sendPacket(new BoatPaddleStateC2SPacket(this.isPaddleMoving(0), this.isPaddleMoving(1)));
        }
        this.move(MovementType.SELF, this.getVelocity());
    } else {
        this.setVelocity(Vec3d.ZERO);
    }
    this.handleBubbleColumn();
    for (int i = 0; i <= 1; ++i) {
        if (this.isPaddleMoving(i)) {
            if (!this.isSilent() && (double) (this.paddlePhases[i] % 6.2831855F) <= 0.7853981852531433D && ((double) this.paddlePhases[i] + 0.39269909262657166D) % 6.2831854820251465D >= 0.7853981852531433D) {
                SoundEvent soundEvent = this.getPaddleSoundEvent();
                if (soundEvent != null) {
                    Vec3d vec3d = this.getRotationVec(1.0F);
                    double d = i == 1 ? -vec3d.z : vec3d.z;
                    double e = i == 1 ? vec3d.x : -vec3d.x;
                    this.world.playSound((PlayerEntity) null, this.getX() + d, this.getY(), this.getZ() + e, soundEvent, this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.random.nextFloat());
                    this.world.emitGameEvent(this.getPrimaryPassenger(), GameEvent.SPLASH, new BlockPos(this.getX() + d, this.getY(), this.getZ() + e));
                }
            }
            float[] var10000 = this.paddlePhases;
            var10000[i] = (float) ((double) var10000[i] + 0.39269909262657166D);
        } else {
            this.paddlePhases[i] = 0.0F;
        }
    }
    this.checkBlockCollision();
    List<Entity> list = this.world.getOtherEntities(this, this.getBoundingBox().expand(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntityPredicates.canBePushedBy(this));
    if (!list.isEmpty()) {
        boolean bl = !this.world.isClient && !(this.getPrimaryPassenger() instanceof PlayerEntity);
        for (int j = 0; j < list.size(); ++j) {
            Entity entity = (Entity) list.get(j);
            if (!entity.hasPassenger(this)) {
                if (bl && this.getPassengerList().size() < 2 && !entity.hasVehicle() && entity.getWidth() < this.getWidth() && entity instanceof LivingEntity && !(entity instanceof WaterCreatureEntity) && !(entity instanceof PlayerEntity)) {
                    entity.startRiding(this);
                } else {
                    this.pushAwayFrom(entity);
                }
            }
        }
    }
}
Also used : BoatEntity(net.minecraft.entity.vehicle.BoatEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SoundEvent(net.minecraft.sound.SoundEvent) BoatPaddleStateC2SPacket(net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket)

Example 2 with BoatPaddleStateC2SPacket

use of net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket in project wildmod by Osmiooo.

the class ChestBoatEntity method tick.

public void tick() {
    this.lastLocation = this.location;
    this.location = this.checkLocation();
    if (this.location != ChestBoatEntity.Location.UNDER_WATER && this.location != ChestBoatEntity.Location.UNDER_FLOWING_WATER) {
        this.ticksUnderwater = 0.0F;
    } else {
        ++this.ticksUnderwater;
    }
    if (!this.world.isClient && this.ticksUnderwater >= 60.0F) {
        this.removeAllPassengers();
    }
    if (this.getDamageWobbleTicks() > 0) {
        this.setDamageWobbleTicks(this.getDamageWobbleTicks() - 1);
    }
    if (this.getDamageWobbleStrength() > 0.0F) {
        this.setDamageWobbleStrength(this.getDamageWobbleStrength() - 1.0F);
    }
    super.tick();
    this.method_7555();
    if (this.isLogicalSideForUpdatingMovement()) {
        if (!(this.getFirstPassenger() instanceof PlayerEntity)) {
            this.setPaddleMovings(false, false);
        }
        this.updateVelocity();
        if (this.world.isClient) {
            this.updatePaddles();
            this.world.sendPacket(new BoatPaddleStateC2SPacket(this.isPaddleMoving(0), this.isPaddleMoving(1)));
        }
        this.move(MovementType.SELF, this.getVelocity());
    } else {
        this.setVelocity(Vec3d.ZERO);
    }
    this.handleBubbleColumn();
    for (int i = 0; i <= 1; ++i) {
        if (this.isPaddleMoving(i)) {
            if (!this.isSilent() && (double) (this.paddlePhases[i] % 6.2831855F) <= 0.7853981852531433D && ((double) this.paddlePhases[i] + 0.39269909262657166D) % 6.2831854820251465D >= 0.7853981852531433D) {
                SoundEvent soundEvent = this.getPaddleSoundEvent();
                if (soundEvent != null) {
                    Vec3d vec3d = this.getRotationVec(1.0F);
                    double d = i == 1 ? -vec3d.z : vec3d.z;
                    double e = i == 1 ? vec3d.x : -vec3d.x;
                    this.world.playSound((PlayerEntity) null, this.getX() + d, this.getY(), this.getZ() + e, soundEvent, this.getSoundCategory(), 1.0F, 0.8F + 0.4F * this.random.nextFloat());
                    this.world.emitGameEvent(this.getPrimaryPassenger(), GameEvent.SPLASH, new BlockPos(this.getX() + d, this.getY(), this.getZ() + e));
                }
            }
            float[] var10000 = this.paddlePhases;
            var10000[i] = (float) ((double) var10000[i] + 0.39269909262657166D);
        } else {
            this.paddlePhases[i] = 0.0F;
        }
    }
}
Also used : SoundEvent(net.minecraft.sound.SoundEvent) PlayerEntity(net.minecraft.entity.player.PlayerEntity) BoatPaddleStateC2SPacket(net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket)

Aggregations

PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 BoatPaddleStateC2SPacket (net.minecraft.network.packet.c2s.play.BoatPaddleStateC2SPacket)2 SoundEvent (net.minecraft.sound.SoundEvent)2 WaterCreatureEntity (net.minecraft.entity.mob.WaterCreatureEntity)1 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)1 BoatEntity (net.minecraft.entity.vehicle.BoatEntity)1