Search in sources :

Example 1 with ClientboundRemoveMobEffectPacket

use of net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket in project MechanicsMain by WeaponMechanics.

the class Scope_1_18_R2 method removeNightVision.

@Override
public void removeNightVision(org.bukkit.entity.Player player) {
    if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
        ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
        // Simply remove the entity effect
        ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
        entityPlayer.connection.send(removeEntityEffect);
        // resend the existing one
        MobEffectInstance mobEffect = entityPlayer.getEffect(MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
        ClientboundUpdateMobEffectPacket entityEffect = new ClientboundUpdateMobEffectPacket(player.getEntityId(), mobEffect);
        ((CraftPlayer) player).getHandle().connection.send(entityEffect);
        return;
    }
    // Simply remove the entity effect
    ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
    ((CraftPlayer) player).getHandle().connection.send(removeEntityEffect);
}
Also used : ClientboundRemoveMobEffectPacket(net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket) ServerPlayer(net.minecraft.server.level.ServerPlayer) MobEffectInstance(net.minecraft.world.effect.MobEffectInstance) CraftPlayer(org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) ClientboundUpdateMobEffectPacket(net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket)

Example 2 with ClientboundRemoveMobEffectPacket

use of net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket in project MechanicsMain by WeaponMechanics.

the class Scope_1_17_R1 method removeNightVision.

@Override
public void removeNightVision(org.bukkit.entity.Player player) {
    if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
        ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
        // Simply remove the entity effect
        ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
        entityPlayer.connection.send(removeEntityEffect);
        // resend the existing one
        MobEffectInstance mobEffect = entityPlayer.getEffect(MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
        ClientboundUpdateMobEffectPacket entityEffect = new ClientboundUpdateMobEffectPacket(player.getEntityId(), mobEffect);
        ((CraftPlayer) player).getHandle().connection.send(entityEffect);
        return;
    }
    // Simply remove the entity effect
    ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
    ((CraftPlayer) player).getHandle().connection.send(removeEntityEffect);
}
Also used : ClientboundRemoveMobEffectPacket(net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket) ServerPlayer(net.minecraft.server.level.ServerPlayer) MobEffectInstance(net.minecraft.world.effect.MobEffectInstance) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) ClientboundUpdateMobEffectPacket(net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket)

Example 3 with ClientboundRemoveMobEffectPacket

use of net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket in project MechanicsMain by WeaponMechanics.

the class Scope_1_18_R1 method removeNightVision.

@Override
public void removeNightVision(org.bukkit.entity.Player player) {
    if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
        ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
        // Simply remove the entity effect
        ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
        entityPlayer.connection.send(removeEntityEffect);
        // resend the existing one
        MobEffectInstance mobEffect = entityPlayer.getEffect(MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
        ClientboundUpdateMobEffectPacket entityEffect = new ClientboundUpdateMobEffectPacket(player.getEntityId(), mobEffect);
        ((CraftPlayer) player).getHandle().connection.send(entityEffect);
        return;
    }
    // Simply remove the entity effect
    ClientboundRemoveMobEffectPacket removeEntityEffect = new ClientboundRemoveMobEffectPacket(player.getEntityId(), MobEffect.byId(PotionEffectType.NIGHT_VISION.getId()));
    ((CraftPlayer) player).getHandle().connection.send(removeEntityEffect);
}
Also used : ClientboundRemoveMobEffectPacket(net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket) ServerPlayer(net.minecraft.server.level.ServerPlayer) MobEffectInstance(net.minecraft.world.effect.MobEffectInstance) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) ClientboundUpdateMobEffectPacket(net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket)

Aggregations

ClientboundRemoveMobEffectPacket (net.minecraft.network.protocol.game.ClientboundRemoveMobEffectPacket)3 ClientboundUpdateMobEffectPacket (net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket)3 ServerPlayer (net.minecraft.server.level.ServerPlayer)3 MobEffectInstance (net.minecraft.world.effect.MobEffectInstance)3 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)1 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)1