use of net.minecraft.server.v1_7_R4.AttributeInstance in project Citizens2 by CitizensDev.
the class PlayerControllerMove method c.
@Override
public void c() {
this.a.bf = 0F;
if (this.f) {
this.f = false;
int i = MathHelper.floor(this.a.getBoundingBox().b + 0.5D);
double d0 = this.b - this.a.locX;
double d1 = this.d - this.a.locZ;
double d2 = this.c - i;
double d3 = d0 * d0 + d2 * d2 + d1 * d1;
if (d3 < 2.500000277905201E-007D) {
this.a.bf = (0.0F);
return;
}
float f = (float) Math.toDegrees(Math.atan2(d1, d0)) - 90.0F;
this.a.yaw = a(this.a.yaw, f, 90.0F);
NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
if (!(this.a instanceof EntitySlime)) {
speed.setValue(0.1D * this.e);
}
float movement = (float) (this.e * speed.getValue()) * 10;
this.a.l(movement);
this.a.bf = movement;
if (shouldSlimeJump() || ((d2 > 0.0D) && (d0 * d0 + d1 * d1 < 1.0D))) {
this.h = cg();
this.h /= 3;
if (this.a instanceof EntityHumanNPC) {
((EntityHumanNPC) this.a).getControllerJump().a();
} else {
((EntityInsentient) this.a).getControllerJump().a();
}
}
}
}
use of net.minecraft.server.v1_7_R4.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.getItemInMainHand(), target.getMonsterType());
i += EnchantmentManager.a(Enchantments.KNOCKBACK, handle);
}
boolean flag = target.damageEntity(DamageSource.mobAttack(handle), f);
if (!flag)
return;
if (i > 0) {
target.f(-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);
}
}
use of net.minecraft.server.v1_7_R4.AttributeInstance in project Citizens2 by CitizensDev.
the class PlayerControllerMove method a.
@Override
public void a() {
this.a.bg = 0F;
if (this.f) {
this.f = false;
int i = MathHelper.floor(this.a.getBoundingBox().b + 0.5D);
double d0 = this.b - this.a.locX;
double d1 = this.d - this.a.locZ;
double d2 = this.c - i;
double d3 = d0 * d0 + d2 * d2 + d1 * d1;
if (d3 < 2.500000277905201E-007D) {
this.a.bf = (0.0F);
return;
}
float f = (float) Math.toDegrees(Math.atan2(d1, d0)) - 90.0F;
this.a.yaw = a(this.a.yaw, f, 90.0F);
NMS.setHeadYaw(a.getBukkitEntity(), this.a.yaw);
AttributeInstance speed = this.a.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
if (!(this.a instanceof EntitySlime)) {
speed.setValue(0.1D * this.e);
}
float movement = (float) (this.e * speed.getValue()) * 10;
this.a.k(movement);
this.a.bg = movement;
if (shouldSlimeJump() || ((d2 > 0.0D) && (d0 * d0 + d1 * d1 < 1.0D))) {
this.h = cg();
this.h /= 3;
if (this.a instanceof EntityHumanNPC) {
((EntityHumanNPC) this.a).getControllerJump().a();
} else {
((EntityInsentient) this.a).getControllerJump().a();
}
}
}
}
use of net.minecraft.server.v1_7_R4.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.setPacketListener(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);
try {
ADVANCEMENT_DATA_PLAYER.set(this, new EmptyAdvancementDataPlayer(minecraftServer, CitizensAPI.getDataFolder().getParentFile(), this));
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_7_R4.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());
}
}
Aggregations