Search in sources :

Example 16 with AttributeInstance

use of net.minecraft.server.v1_8_R2.AttributeInstance in project NoCheatPlus by NoCheatPlus.

the class AttributeAccess method getSpeedAttributeMultiplier.

@Override
public double getSpeedAttributeMultiplier(Player player) {
    final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
    final double val = attr.getValue() / attr.b();
    final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
    if (mod == null) {
        return val;
    } else {
        return val / AttribUtil.getMultiplier(mod.c(), mod.d());
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_7_R2.AttributeInstance) AttributeModifier(net.minecraft.server.v1_7_R2.AttributeModifier)

Example 17 with AttributeInstance

use of net.minecraft.server.v1_8_R2.AttributeInstance in project NoCheatPlus by NoCheatPlus.

the class AttributeAccess method getSpeedAttributeMultiplier.

@Override
public double getSpeedAttributeMultiplier(Player player) {
    final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.d);
    final double val = attr.getValue() / attr.b();
    final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
    if (mod == null) {
        return val;
    } else {
        return val / AttribUtil.getMultiplier(mod.c(), mod.d());
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_7_R3.AttributeInstance) AttributeModifier(net.minecraft.server.v1_7_R3.AttributeModifier)

Example 18 with AttributeInstance

use of net.minecraft.server.v1_8_R2.AttributeInstance in project NoCheatPlus by NoCheatPlus.

the class AttributeAccess method getSpeedAttributeMultiplier.

@Override
public double getSpeedAttributeMultiplier(Player player) {
    final AttributeInstance attr = ((CraftLivingEntity) player).getHandle().getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
    final double val = attr.getValue() / attr.b();
    final AttributeModifier mod = attr.a(AttribUtil.ID_SPRINT_BOOST);
    if (mod == null) {
        return val;
    } else {
        return val / AttribUtil.getMultiplier(mod.c(), mod.d());
    }
}
Also used : AttributeInstance(net.minecraft.server.v1_9_R2.AttributeInstance) AttributeModifier(net.minecraft.server.v1_9_R2.AttributeModifier)

Example 19 with AttributeInstance

use of net.minecraft.server.v1_8_R2.AttributeInstance in project Citizens2 by CitizensDev.

the class NMSImpl method attack.

@Override
public void attack(LivingEntity attacker, LivingEntity btarget) {
    EntityLiving handle = getHandle(attacker);
    EntityLiving target = getHandle(btarget);
    if (handle instanceof EntityPlayer) {
        EntityPlayer humanHandle = (EntityPlayer) handle;
        humanHandle.attack(target);
        PlayerAnimation.ARM_SWING.play(humanHandle.getBukkitEntity());
        return;
    }
    AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.ATTACK_DAMAGE);
    float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
    int i = 0;
    if (target instanceof EntityLiving) {
        f += EnchantmentManager.a(handle.bA(), target.getMonsterType());
        i += EnchantmentManager.a(handle);
    }
    boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);
    if (!flag)
        return;
    if (i > 0) {
        target.g(-Math.sin(handle.yaw * Math.PI / 180.0F) * i * 0.5F, 0.1D, Math.cos(handle.yaw * Math.PI / 180.0F) * i * 0.5F);
        handle.motX *= 0.6D;
        handle.motZ *= 0.6D;
    }
    int fireAspectLevel = EnchantmentManager.getFireAspectEnchantmentLevel(handle);
    if (fireAspectLevel > 0) {
        target.setOnFire(fireAspectLevel * 4);
    }
}
Also used : EntityLiving(net.minecraft.server.v1_8_R3.EntityLiving) AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) EntityPlayer(net.minecraft.server.v1_8_R3.EntityPlayer) PathPoint(net.minecraft.server.v1_8_R3.PathPoint)

Example 20 with AttributeInstance

use of net.minecraft.server.v1_8_R2.AttributeInstance in project Citizens2 by CitizensDev.

the class EntityHumanNPC method initialise.

private void initialise(MinecraftServer minecraftServer) {
    Socket socket = new EmptySocket();
    NetworkManager conn = null;
    try {
        conn = new EmptyNetworkManager(EnumProtocolDirection.CLIENTBOUND);
        playerConnection = new EmptyNetHandler(minecraftServer, conn, this);
        conn.a(playerConnection);
        socket.close();
    } catch (IOException e) {
    // swallow
    }
    AttributeInstance range = getAttributeInstance(GenericAttributes.FOLLOW_RANGE);
    if (range == null) {
        range = getAttributeMap().b(GenericAttributes.FOLLOW_RANGE);
    }
    range.setValue(Setting.DEFAULT_PATHFINDING_RANGE.asDouble());
    controllerJump = new PlayerControllerJump(this);
    controllerLook = new PlayerControllerLook(this);
    controllerMove = new PlayerControllerMove(this);
    navigation = new PlayerNavigation(this, world);
    // the default (0) breaks step climbing
    NMS.setStepHeight(getBukkitEntity(), 1);
    setSkinFlags((byte) 0xFF);
}
Also used : EmptyNetworkManager(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager) PlayerControllerLook(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerLook) EmptySocket(net.citizensnpcs.nms.v1_8_R3.network.EmptySocket) EmptyNetHandler(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetHandler) PlayerControllerMove(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerMove) PlayerNavigation(net.citizensnpcs.nms.v1_8_R3.util.PlayerNavigation) AttributeInstance(net.minecraft.server.v1_8_R3.AttributeInstance) PlayerControllerJump(net.citizensnpcs.nms.v1_8_R3.util.PlayerControllerJump) IOException(java.io.IOException) EmptyNetworkManager(net.citizensnpcs.nms.v1_8_R3.network.EmptyNetworkManager) NetworkManager(net.minecraft.server.v1_8_R3.NetworkManager) EmptySocket(net.citizensnpcs.nms.v1_8_R3.network.EmptySocket) Socket(java.net.Socket)

Aggregations

AttributeInstance (net.minecraft.server.v1_10_R1.AttributeInstance)5 AttributeInstance (net.minecraft.server.v1_11_R1.AttributeInstance)5 AttributeInstance (net.minecraft.server.v1_12_R1.AttributeInstance)5 AttributeInstance (net.minecraft.server.v1_8_R3.AttributeInstance)5 IOException (java.io.IOException)4 Socket (java.net.Socket)4 EntityHumanNPC (net.citizensnpcs.nms.v1_10_R1.entity.EntityHumanNPC)2 EntityHumanNPC (net.citizensnpcs.nms.v1_11_R1.entity.EntityHumanNPC)2 EntityHumanNPC (net.citizensnpcs.nms.v1_12_R1.entity.EntityHumanNPC)2 EntityHumanNPC (net.citizensnpcs.nms.v1_8_R3.entity.EntityHumanNPC)2 EntityLiving (net.minecraft.server.v1_10_R1.EntityLiving)2 EntityLiving (net.minecraft.server.v1_11_R1.EntityLiving)2 EntityLiving (net.minecraft.server.v1_12_R1.EntityLiving)2 EmptyNetHandler (net.citizensnpcs.nms.v1_10_R1.network.EmptyNetHandler)1 EmptyNetworkManager (net.citizensnpcs.nms.v1_10_R1.network.EmptyNetworkManager)1 EmptySocket (net.citizensnpcs.nms.v1_10_R1.network.EmptySocket)1 PlayerControllerJump (net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerJump)1 PlayerControllerLook (net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerLook)1 PlayerControllerMove (net.citizensnpcs.nms.v1_10_R1.util.PlayerControllerMove)1 PlayerNavigation (net.citizensnpcs.nms.v1_10_R1.util.PlayerNavigation)1