use of WayofTime.bloodmagic.network.PlayerFallDistancePacketProcessor in project BloodMagic by WayofTime.
the class ItemLivingArmour method onArmorTick.
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack stack) {
super.onArmorTick(world, player, stack);
if (world.isRemote && this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
if (// Sanity check
player instanceof EntityPlayerSP) {
EntityPlayerSP spPlayer = (EntityPlayerSP) player;
if (FLAGS == null) {
try {
FLAGS = (DataParameter<Byte>) _FLAGS.get(null);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
if (FLAGS != null) {
if (LivingArmour.hasFullSet(player)) {
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgradeFromNBT(BloodMagic.MODID + ".upgrade.elytra", chestStack);
if (upgrade instanceof LivingArmourUpgradeElytra) {
if (spPlayer.movementInput.jump && !spPlayer.onGround && spPlayer.motionY < 0.0D && !spPlayer.capabilities.isFlying) {
if (spPlayer.motionY > -0.5D) {
BloodMagicPacketHandler.INSTANCE.sendToServer(new PlayerFallDistancePacketProcessor(1));
}
if (!spPlayer.isElytraFlying()) {
byte b0 = player.getDataManager().get(FLAGS);
player.getDataManager().set(FLAGS, (byte) (b0 | 1 << 7));
}
} else if (spPlayer.isElytraFlying() && !spPlayer.movementInput.jump && !spPlayer.onGround) {
byte b0 = player.getDataManager().get(FLAGS);
player.getDataManager().set(FLAGS, (byte) (b0 & ~(1 << 7)));
}
}
}
}
}
}
if (this == RegistrarBloodMagicItems.LIVING_ARMOUR_CHEST) {
if (!hasLivingArmour(stack)) {
setLivingArmour(stack, getLivingArmourFromStack(stack));
}
LivingArmour armour = getLivingArmour(stack);
if (LivingArmour.hasFullSet(player)) {
this.setIsEnabled(stack, true);
armour.onTick(world, player);
}
setLivingArmour(stack, armour, false);
}
}
Aggregations