Search in sources :

Example 36 with AttributeInstance

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

the class NMSImpl method updatePathfindingRange.

@Override
public void updatePathfindingRange(NPC npc, float pathfindingRange) {
    if (!npc.isSpawned() || !npc.getEntity().getType().isAlive())
        return;
    EntityLiving en = NMSImpl.getHandle((LivingEntity) npc.getEntity());
    if (!(en instanceof EntityInsentient)) {
        if (en instanceof EntityHumanNPC) {
            ((EntityHumanNPC) en).updatePathfindingRange(pathfindingRange);
        }
        return;
    }
    if (PATHFINDING_RANGE == null)
        return;
    EntityInsentient handle = (EntityInsentient) en;
    NavigationAbstract navigation = handle.getNavigation();
    try {
        AttributeInstance inst = (AttributeInstance) PATHFINDING_RANGE.get(navigation);
        inst.setValue(pathfindingRange);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : EntityLiving(net.minecraft.server.v1_13_R2.EntityLiving) AttributeInstance(net.minecraft.server.v1_13_R2.AttributeInstance) EntityInsentient(net.minecraft.server.v1_13_R2.EntityInsentient) NavigationAbstract(net.minecraft.server.v1_13_R2.NavigationAbstract) EntityHumanNPC(net.citizensnpcs.nms.v1_13_R2.entity.EntityHumanNPC)

Example 37 with AttributeInstance

use of net.minecraft.server.v1_15_R1.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_R1.AttributeInstance) AttributeModifier(net.minecraft.server.v1_7_R1.AttributeModifier)

Example 38 with AttributeInstance

use of net.minecraft.server.v1_15_R1.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_6_R2.AttributeInstance) AttributeModifier(net.minecraft.server.v1_6_R2.AttributeModifier)

Example 39 with AttributeInstance

use of net.minecraft.server.v1_15_R1.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_6_R3.AttributeInstance) AttributeModifier(net.minecraft.server.v1_6_R3.AttributeModifier)

Example 40 with AttributeInstance

use of net.minecraft.server.v1_15_R1.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_8_R2.AttributeInstance) AttributeModifier(net.minecraft.server.v1_8_R2.AttributeModifier)

Aggregations

IOException (java.io.IOException)7 Socket (java.net.Socket)7 AttributeInstance (net.minecraft.server.v1_10_R1.AttributeInstance)5 AttributeInstance (net.minecraft.server.v1_13_R2.AttributeInstance)5 AttributeInstance (net.minecraft.server.v1_8_R3.AttributeInstance)5 AttributeInstance (net.minecraft.server.v1_11_R1.AttributeInstance)4 AttributeInstance (net.minecraft.server.v1_12_R1.AttributeInstance)4 AttributeInstance (net.minecraft.server.v1_14_R1.AttributeInstance)3 AttributeInstance (net.minecraft.server.v1_15_R1.AttributeInstance)3 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_13_R2.entity.EntityHumanNPC)2 EntityHumanNPC (net.citizensnpcs.nms.v1_14_R1.entity.EntityHumanNPC)2 EntityHumanNPC (net.citizensnpcs.nms.v1_15_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_14_R1.EntityLiving)2 EntityInsentient (net.minecraft.server.v1_15_R1.EntityInsentient)2